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 pool_add $POOL || error "pool_add failed"
2616 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2617 $LFS setstripe -p $POOL $DIR/$tdir
2619 local pool=$($LFS getstripe -p $DIR/$tdir)
2621 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2623 $LFS setstripe -d $DIR/$tdir
2625 pool=$($LFS getstripe -p $DIR/$tdir)
2629 [ -z "$pool" ] || error "'$pool' is not empty"
2631 run_test 27G "Clear OST pool from stripe"
2634 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2635 skip "Need MDS version newer than 2.11.54"
2636 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2637 test_mkdir $DIR/$tdir
2638 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2639 touch $DIR/$tdir/$tfile
2640 $LFS getstripe -c $DIR/$tdir/$tfile
2641 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2642 error "two-stripe file doesn't have two stripes"
2644 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2645 $LFS getstripe -y $DIR/$tdir/$tfile
2646 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2647 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2648 error "expected l_ost_idx: [02]$ not matched"
2650 # make sure ost list has been cleared
2651 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2652 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2653 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2655 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2657 run_test 27H "Set specific OSTs stripe"
2660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2661 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2662 [[ $MDS1_VERSION -gt $(version_code 2.12.52) ]] ||
2663 skip "Need MDS version newer than 2.12.52"
2664 local pool=$TESTNAME
2665 local ostrange="1 1 1"
2667 save_layout_restore_at_exit $MOUNT
2668 $LFS setstripe -c 2 -i 0 $MOUNT
2669 pool_add $pool || error "pool_add failed"
2670 pool_add_targets $pool $ostrange || "pool_add_targets failed"
2671 test_mkdir $DIR/$tdir
2672 $LFS setstripe -p $pool $DIR/$tdir
2673 $MULTIOP $DIR/$tdir/$tfile Oc || error "multiop failed"
2674 $LFS getstripe $DIR/$tdir/$tfile
2676 run_test 27I "check that root dir striping does not break parent dir one"
2679 [[ $MDS1_VERSION -le $(version_code 2.12.51) ]] &&
2680 skip "Need MDS version newer than 2.12.51"
2682 test_mkdir $DIR/$tdir
2683 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2684 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2686 # create foreign file (raw way)
2687 create_foreign_file -f $DIR/$tdir/$tfile -x "${uuid1}@${uuid2}" \
2688 -t 1 -F 0xda08 || error "create_foreign_file failed"
2690 # verify foreign file (raw way)
2691 parse_foreign_file -f $DIR/$tdir/$tfile |
2692 grep "lov_foreign_magic: 0x0BD70BD0" ||
2693 error "$DIR/$tdir/$tfile: invalid LOV EA foreign magic"
2694 parse_foreign_file -f $DIR/$tdir/$tfile | grep "lov_xattr_size: 89" ||
2695 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2696 parse_foreign_file -f $DIR/$tdir/$tfile |
2697 grep "lov_foreign_size: 73" ||
2698 error "$DIR/$tdir/$tfile: invalid LOV EA foreign size"
2699 parse_foreign_file -f $DIR/$tdir/$tfile |
2700 grep "lov_foreign_type: 1" ||
2701 error "$DIR/$tdir/$tfile: invalid LOV EA foreign type"
2702 parse_foreign_file -f $DIR/$tdir/$tfile |
2703 grep "lov_foreign_flags: 0x0000DA08" ||
2704 error "$DIR/$tdir/$tfile: invalid LOV EA foreign flags"
2705 local lov=$(parse_foreign_file -f $DIR/$tdir/$tfile |
2706 grep "lov_foreign_value: 0x" |
2707 sed -e 's/lov_foreign_value: 0x//')
2708 local lov2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160)
2709 [[ $lov = ${lov2// /} ]] ||
2710 error "$DIR/$tdir/$tfile: invalid LOV EA foreign value"
2712 # create foreign file (lfs + API)
2713 $LFS setstripe --foreign=daos --flags 0xda08 \
2714 -x "${uuid1}@${uuid2}" $DIR/$tdir/${tfile}2 ||
2715 error "$DIR/$tdir/${tfile}2: create failed"
2717 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2718 grep "lfm_magic:.*0x0BD70BD0" ||
2719 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign magic"
2720 # lfm_length is LOV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2721 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_length:.*73" ||
2722 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign size"
2723 $LFS getstripe -v $DIR/$tdir/${tfile}2 | grep "lfm_type:.*daos" ||
2724 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign type"
2725 $LFS getstripe -v $DIR/$tdir/${tfile}2 |
2726 grep "lfm_flags:.*0x0000DA08" ||
2727 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign flags"
2728 $LFS getstripe $DIR/$tdir/${tfile}2 |
2729 grep "lfm_value:.*${uuid1}@${uuid2}" ||
2730 error "$DIR/$tdir/${tfile}2: invalid LOV EA foreign value"
2732 # modify striping should fail
2733 $LFS setstripe -c 2 $DIR/$tdir/$tfile &&
2734 error "$DIR/$tdir/$tfile: setstripe should fail"
2735 $LFS setstripe -c 2 $DIR/$tdir/${tfile}2 &&
2736 error "$DIR/$tdir/${tfile}2: setstripe should fail"
2739 cat $DIR/$tdir/$tfile && error "$DIR/$tdir/$tfile: read should fail"
2740 cat $DIR/$tdir/${tfile}2 &&
2741 error "$DIR/$tdir/${tfile}2: read should fail"
2742 cat /etc/passwd > $DIR/$tdir/$tfile &&
2743 error "$DIR/$tdir/$tfile: write should fail"
2744 cat /etc/passwd > $DIR/$tdir/${tfile}2 &&
2745 error "$DIR/$tdir/${tfile}2: write should fail"
2748 chmod 222 $DIR/$tdir/$tfile ||
2749 error "$DIR/$tdir/$tfile: chmod failed"
2750 chmod 222 $DIR/$tdir/${tfile}2 ||
2751 error "$DIR/$tdir/${tfile}2: chmod failed"
2754 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tfile ||
2755 error "$DIR/$tdir/$tfile: chown failed"
2756 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tfile}2 ||
2757 error "$DIR/$tdir/${tfile}2: chown failed"
2759 # rename should work
2760 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}.new ||
2761 error "$DIR/$tdir/$tfile: rename of foreign file has failed"
2762 mv $DIR/$tdir/${tfile}2 $DIR/$tdir/${tfile}2.new ||
2763 error "$DIR/$tdir/${tfile}2: rename of foreign file has failed"
2765 #remove foreign file
2766 rm $DIR/$tdir/${tfile}.new ||
2767 error "$DIR/$tdir/${tfile}.new: remove of foreign file has failed"
2768 rm $DIR/$tdir/${tfile}2.new ||
2769 error "$DIR/$tdir/${tfile}2.new: remove of foreign file has failed"
2771 run_test 27J "basic ops on file with foreign LOV"
2774 [[ $MDS1_VERSION -le $(version_code 2.12.49) ]] &&
2775 skip "Need MDS version newer than 2.12.49"
2777 test_mkdir $DIR/$tdir
2778 local uuid1=$(cat /proc/sys/kernel/random/uuid)
2779 local uuid2=$(cat /proc/sys/kernel/random/uuid)
2781 # create foreign dir (raw way)
2782 create_foreign_dir -d $DIR/$tdir/$tdir -x "${uuid1}@${uuid2}" -t 1 ||
2783 error "create_foreign_dir FAILED"
2785 # verify foreign dir (raw way)
2786 parse_foreign_dir -d $DIR/$tdir/$tdir |
2787 grep "lmv_foreign_magic:.*0xcd50cd0" ||
2788 error "$DIR/$tdir/$tfile: invalid LMV EA magic"
2789 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_xattr_size:.*89$" ||
2790 error "$DIR/$tdir/$tdir: invalid LMV EA size"
2791 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_type: 1$" ||
2792 error "$DIR/$tdir/$tdir: invalid LMV EA type"
2793 parse_foreign_dir -d $DIR/$tdir/$tdir | grep "lmv_foreign_flags: 0$" ||
2794 error "$DIR/$tdir/$tdir: invalid LMV EA flags"
2795 local lmv=$(parse_foreign_dir -d $DIR/$tdir/$tdir |
2796 grep "lmv_foreign_value: 0x" |
2797 sed 's/lmv_foreign_value: 0x//')
2798 local lmv2=$(echo -n "${uuid1}@${uuid2}" | od -A n -t x1 -w160 |
2800 [[ $lmv == $lmv2 ]] || error "$DIR/$tdir/$tdir: invalid LMV EA value"
2802 # create foreign dir (lfs + API)
2803 $LFS mkdir --foreign=daos --xattr="${uuid1}@${uuid2}" --flags=0xda05 \
2804 $DIR/$tdir/${tdir}2 ||
2805 error "$DIR/$tdir/${tdir}2: create failed"
2807 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2808 grep "lfm_magic:.*0x0CD50CD0" ||
2809 error "$DIR/$tdir/${tdir}2: invalid LMV EA magic"
2810 # lfm_length is LMV EA size - sizeof(lfm_magic) - sizeof(lfm_length)
2811 # - sizeof(lfm_type) - sizeof(lfm_flags)
2812 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_length:.*73" ||
2813 error "$DIR/$tdir/${tdir}2: invalid LMV EA size"
2814 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 | grep "lfm_type:.*daos" ||
2815 error "$DIR/$tdir/${tdir}2: invalid LMV EA type"
2816 $LFS getdirstripe -v $DIR/$tdir/${tdir}2 |
2817 grep "lfm_flags:.*0x0000DA05" ||
2818 error "$DIR/$tdir/${tdir}2: invalid LMV EA flags"
2819 $LFS getdirstripe $DIR/$tdir/${tdir}2 |
2820 grep "lfm_value.*${uuid1}@${uuid2}" ||
2821 error "$DIR/$tdir/${tdir}2: invalid LMV EA value"
2823 # file create in dir should fail
2824 touch $DIR/$tdir/$tdir/$tfile && "$DIR/$tdir: file create should fail"
2825 touch $DIR/$tdir/${tdir}2/$tfile &&
2826 "$DIR/${tdir}2: file create should fail"
2829 chmod 777 $DIR/$tdir/$tdir ||
2830 error "$DIR/$tdir: chmod failed"
2831 chmod 777 $DIR/$tdir/${tdir}2 ||
2832 error "$DIR/${tdir}2: chmod failed"
2835 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/$tdir ||
2836 error "$DIR/$tdir: chown failed"
2837 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/${tdir}2 ||
2838 error "$DIR/${tdir}2: chown failed"
2840 # rename should work
2841 mv $DIR/$tdir/$tdir $DIR/$tdir/${tdir}.new ||
2842 error "$DIR/$tdir/$tdir: rename of foreign dir has failed"
2843 mv $DIR/$tdir/${tdir}2 $DIR/$tdir/${tdir}2.new ||
2844 error "$DIR/$tdir/${tdir}2: rename of foreign dir has failed"
2847 rmdir $DIR/$tdir/${tdir}.new ||
2848 error "$DIR/$tdir/${tdir}.new: remove of foreign dir has failed"
2849 rmdir $DIR/$tdir/${tdir}2.new ||
2850 error "$DIR/$tdir/${tdir}2.new: remove of foreign dir has failed"
2852 run_test 27K "basic ops on dir with foreign LMV"
2855 remote_mds_nodsh && skip "remote MDS with nodsh"
2857 local POOL=${POOL:-$TESTNAME}
2859 pool_add $POOL || error "pool_add failed"
2861 lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" ||
2862 error "pool_list does not contain ${FSNAME}.${POOL}:" \
2863 "$(lfs pool_list $MOUNT | grep -F "${POOL}")"
2865 run_test 27L "lfs pool_list gives correct pool name"
2868 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2869 skip "Need MDS version >= than 2.12.57"
2870 remote_mds_nodsh && skip "remote MDS with nodsh"
2871 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2873 test_mkdir $DIR/$tdir
2875 # Set default striping on directory
2876 $LFS setstripe -C 4 $DIR/$tdir
2878 echo 1 > $DIR/$tdir/${tfile}.1
2879 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2881 [ $count -eq $setcount ] ||
2882 error "(1) stripe count $count, should be $setcount"
2884 # Capture existing append_stripe_count setting for restore
2885 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2886 local mdts=$(comma_list $(mdts_nodes))
2887 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2889 local appendcount=$orig_count
2890 echo 1 >> $DIR/$tdir/${tfile}.2_append
2891 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2892 [ $count -eq $appendcount ] ||
2893 error "(2)stripe count $count, should be $appendcount for append"
2895 # Disable O_APPEND striping, verify it works
2896 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2898 # Should now get the default striping, which is 4
2900 echo 1 >> $DIR/$tdir/${tfile}.3_append
2901 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2902 [ $count -eq $setcount ] ||
2903 error "(3) stripe count $count, should be $setcount"
2905 # Try changing the stripe count for append files
2906 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2908 # Append striping is now 2 (directory default is still 4)
2910 echo 1 >> $DIR/$tdir/${tfile}.4_append
2911 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2912 [ $count -eq $appendcount ] ||
2913 error "(4) stripe count $count, should be $appendcount for append"
2915 # Test append stripe count of -1
2916 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2917 appendcount=$OSTCOUNT
2918 echo 1 >> $DIR/$tdir/${tfile}.5
2919 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2920 [ $count -eq $appendcount ] ||
2921 error "(5) stripe count $count, should be $appendcount for append"
2923 # Set append striping back to default of 1
2924 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2926 # Try a new default striping, PFL + DOM
2927 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2929 # Create normal DOM file, DOM returns stripe count == 0
2931 touch $DIR/$tdir/${tfile}.6
2932 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2933 [ $count -eq $setcount ] ||
2934 error "(6) stripe count $count, should be $setcount"
2938 echo 1 >> $DIR/$tdir/${tfile}.7_append
2939 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2940 [ $count -eq $appendcount ] ||
2941 error "(7) stripe count $count, should be $appendcount for append"
2943 # Clean up DOM layout
2944 $LFS setstripe -d $DIR/$tdir
2946 # Now test that append striping works when layout is from root
2947 $LFS setstripe -c 2 $MOUNT
2948 # Make a special directory for this
2949 mkdir $DIR/${tdir}/${tdir}.2
2950 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2952 # Verify for normal file
2954 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2955 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2956 [ $count -eq $setcount ] ||
2957 error "(8) stripe count $count, should be $setcount"
2960 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2961 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2962 [ $count -eq $appendcount ] ||
2963 error "(9) stripe count $count, should be $appendcount for append"
2965 # Now test O_APPEND striping with pools
2966 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2967 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2970 pool_add $TESTNAME || error "pool creation failed"
2971 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2973 echo 1 >> $DIR/$tdir/${tfile}.10_append
2975 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2976 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2978 # Check that count is still correct
2980 echo 1 >> $DIR/$tdir/${tfile}.11_append
2981 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2982 [ $count -eq $appendcount ] ||
2983 error "(11) stripe count $count, should be $appendcount for append"
2985 # Disable O_APPEND stripe count, verify pool works separately
2986 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2988 echo 1 >> $DIR/$tdir/${tfile}.12_append
2990 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2991 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2993 # Remove pool setting, verify it's not applied
2994 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2996 echo 1 >> $DIR/$tdir/${tfile}.13_append
2998 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2999 [ "$pool" = "" ] || error "(13) pool found: $pool"
3001 run_test 27M "test O_APPEND striping"
3004 combined_mgs_mds && skip "needs separate MGS/MDT"
3006 pool_add $TESTNAME || error "pool_add failed"
3007 do_facet mgs "$LCTL pool_list $FSNAME" |
3008 grep -Fx "${FSNAME}.${TESTNAME}" ||
3009 error "lctl pool_list on MGS failed"
3011 run_test 27N "lctl pool_list on separate MGS gives correct pool name"
3013 # createtest also checks that device nodes are created and
3014 # then visible correctly (#2091)
3015 test_28() { # bug 2091
3017 $CREATETEST $DIR/d28/ct || error "createtest failed"
3019 run_test 28 "create/mknod/mkdir with bad file types ============"
3022 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3024 sync; sleep 1; sync # flush out any dirty pages from previous tests
3031 declare -i LOCKCOUNTORIG=0
3032 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3033 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
3035 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
3037 declare -i LOCKUNUSEDCOUNTORIG=0
3038 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3039 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
3046 declare -i LOCKCOUNTCURRENT=0
3047 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
3048 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
3051 declare -i LOCKUNUSEDCOUNTCURRENT=0
3052 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
3053 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
3056 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
3057 $LCTL set_param -n ldlm.dump_namespaces ""
3058 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
3059 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3060 log "dumped log to $TMP/test_29.dk (bug 5793)"
3063 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
3064 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
3065 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
3066 log "dumped log to $TMP/test_29.dk (bug 5793)"
3070 run_test 29 "IT_GETATTR regression ============================"
3072 test_30a() { # was test_30
3073 cp $(which ls) $DIR || cp /bin/ls $DIR
3074 $DIR/ls / || error "Can't execute binary from lustre"
3077 run_test 30a "execute binary from Lustre (execve) =============="
3080 cp `which ls` $DIR || cp /bin/ls $DIR
3082 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
3085 run_test 30b "execute binary from Lustre as non-root ==========="
3087 test_30c() { # b=22376
3088 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3090 cp $(which ls) $DIR || cp /bin/ls $DIR
3092 cancel_lru_locks mdc
3093 cancel_lru_locks osc
3094 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
3097 run_test 30c "execute binary from Lustre without read perms ===="
3100 cp $(which dd) $DIR || error "failed to copy dd to $DIR/dd"
3102 for i in {1..10}; do
3103 $DIR/dd bs=1M count=128 if=/dev/zero of=$DIR/$tfile &
3106 $LCTL set_param ldlm.namespaces.*MDT*.lru_size=clear
3107 wait $PID || error "executing dd from Lustre failed"
3113 run_test 30d "execute binary from Lustre while clear locks"
3116 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
3117 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
3119 run_test 31a "open-unlink file =================================="
3122 touch $DIR/f31 || error "touch $DIR/f31 failed"
3123 ln $DIR/f31 $DIR/f31b || error "ln failed"
3124 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
3125 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
3127 run_test 31b "unlink file with multiple links while open ======="
3130 touch $DIR/f31 || error "touch $DIR/f31 failed"
3131 ln $DIR/f31 $DIR/f31c || error "ln failed"
3132 multiop_bg_pause $DIR/f31 O_uc ||
3133 error "multiop_bg_pause for $DIR/f31 failed"
3135 $MULTIOP $DIR/f31c Ouc
3136 kill -USR1 $MULTIPID
3139 run_test 31c "open-unlink file with multiple links ============="
3142 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
3143 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
3145 run_test 31d "remove of open directory ========================="
3147 test_31e() { # bug 2904
3148 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
3150 run_test 31e "remove of open non-empty directory ==============="
3152 test_31f() { # bug 4554
3153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3156 test_mkdir $DIR/d31f
3157 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3158 cp /etc/hosts $DIR/d31f
3160 $LFS getstripe $DIR/d31f/hosts
3161 multiop_bg_pause $DIR/d31f D_c || return 1
3164 rm -rv $DIR/d31f || error "first of $DIR/d31f"
3165 test_mkdir $DIR/d31f
3166 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
3167 cp /etc/hosts $DIR/d31f
3169 $LFS getstripe $DIR/d31f/hosts
3170 multiop_bg_pause $DIR/d31f D_c || return 1
3173 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
3174 wait $MULTIPID || error "first opendir $MULTIPID failed"
3178 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
3179 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
3182 run_test 31f "remove of open directory with open-unlink file ==="
3185 echo "-- cross directory link --"
3186 test_mkdir -c1 $DIR/${tdir}ga
3187 test_mkdir -c1 $DIR/${tdir}gb
3188 touch $DIR/${tdir}ga/f
3189 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
3190 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
3191 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
3192 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
3193 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
3195 run_test 31g "cross directory link==============="
3198 echo "-- cross directory link --"
3199 test_mkdir -c1 $DIR/${tdir}
3200 test_mkdir -c1 $DIR/${tdir}/dir
3201 touch $DIR/${tdir}/f
3202 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
3203 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
3204 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
3205 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
3206 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
3208 run_test 31h "cross directory link under child==============="
3211 echo "-- cross directory link --"
3212 test_mkdir -c1 $DIR/$tdir
3213 test_mkdir -c1 $DIR/$tdir/dir
3214 touch $DIR/$tdir/dir/f
3215 ln $DIR/$tdir/dir/f $DIR/$tdir/g
3216 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
3217 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
3218 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
3219 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
3221 run_test 31i "cross directory link under parent==============="
3224 test_mkdir -c1 -p $DIR/$tdir
3225 test_mkdir -c1 -p $DIR/$tdir/dir1
3226 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
3227 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
3228 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
3229 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
3232 run_test 31j "link for directory==============="
3235 test_mkdir -c1 -p $DIR/$tdir
3237 touch $DIR/$tdir/exist
3238 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
3239 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
3240 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
3241 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
3242 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
3243 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
3244 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
3247 run_test 31k "link to file: the same, non-existing, dir==============="
3253 touch $DIR/d31m2/exist
3254 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
3255 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
3256 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
3257 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
3258 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
3259 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
3262 run_test 31m "link to file: the same, non-existing, dir==============="
3265 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
3266 nlink=$(stat --format=%h $DIR/$tfile)
3267 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3269 local cmd="exec $fd<$DIR/$tfile"
3272 trap "eval $cmd" EXIT
3273 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3274 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
3275 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
3276 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
3277 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
3280 run_test 31n "check link count of unlinked file"
3283 local tempfile=$(mktemp $1_XXXXXX)
3284 mlink $tempfile $1 2> /dev/null &&
3285 echo "$BASHPID: link $tempfile to $1 succeeded"
3289 test_31o() { # LU-2901
3290 test_mkdir $DIR/$tdir
3291 for LOOP in $(seq 100); do
3292 rm -f $DIR/$tdir/$tfile*
3293 for THREAD in $(seq 8); do
3294 link_one $DIR/$tdir/$tfile.$LOOP &
3297 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
3298 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
3299 error "$LINKS duplicate links to $tfile.$LOOP" &&
3303 run_test 31o "duplicate hard links with same filename"
3306 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3308 test_mkdir $DIR/$tdir
3309 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3310 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
3312 opendirunlink $DIR/$tdir/striped_dir/test1 ||
3313 error "open unlink test1 failed"
3314 opendirunlink $DIR/$tdir/striped_dir/test2 ||
3315 error "open unlink test2 failed"
3317 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
3318 error "test1 still exists"
3319 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
3320 error "test2 still exists"
3322 run_test 31p "remove of open striped directory"
3324 cleanup_test32_mount() {
3327 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
3328 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
3329 losetup -d $loopdev || true
3335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3337 echo "== more mountpoints and symlinks ================="
3338 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3339 trap cleanup_test32_mount EXIT
3340 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3341 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3342 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3343 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
3344 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
3345 cleanup_test32_mount
3347 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
3350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3352 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3353 trap cleanup_test32_mount EXIT
3354 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3355 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3356 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3357 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
3358 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
3359 cleanup_test32_mount
3361 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
3364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3366 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3367 trap cleanup_test32_mount EXIT
3368 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3369 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3370 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3371 test_mkdir -p $DIR/$tdir/d2/test_dir
3372 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3373 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
3374 cleanup_test32_mount
3376 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
3379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3381 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3382 trap cleanup_test32_mount EXIT
3383 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3384 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3385 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3386 test_mkdir -p $DIR/$tdir/d2/test_dir
3387 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
3388 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
3389 cleanup_test32_mount
3391 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
3395 test_mkdir -p $DIR/$tdir/tmp
3396 local tmp_dir=$DIR/$tdir/tmp
3397 ln -s $DIR/$tdir $tmp_dir/symlink11
3398 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3399 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3400 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
3402 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
3406 test_mkdir -p $DIR/$tdir/tmp
3407 local tmp_dir=$DIR/$tdir/tmp
3408 ln -s $DIR/$tdir $tmp_dir/symlink11
3409 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
3410 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
3411 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
3413 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
3416 local tmp_dir=$DIR/$tdir/tmp
3417 test_mkdir -p $tmp_dir
3418 test_mkdir $DIR/${tdir}2
3419 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3420 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3421 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
3422 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
3423 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
3424 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
3426 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3429 rm -fr $DIR/$tdir $DIR/${tdir}2
3430 tmp_dir=$DIR/$tdir/tmp
3431 test_mkdir -p $tmp_dir
3432 test_mkdir $DIR/${tdir}2
3433 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
3434 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
3435 ls $tmp_dir/symlink12 || error "listing symlink12"
3436 ls $DIR/$tdir/symlink02 || error "listing symlink02"
3438 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
3441 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3443 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3444 trap cleanup_test32_mount EXIT
3445 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3446 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3447 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3448 touch $DIR/$tdir/test_file
3449 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
3450 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
3451 cleanup_test32_mount
3453 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
3456 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3458 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3459 trap cleanup_test32_mount EXIT
3460 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3461 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3462 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3463 touch $DIR/$tdir/test_file
3464 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
3465 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
3466 cleanup_test32_mount
3468 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
3471 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3474 trap cleanup_test32_mount EXIT
3475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3477 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3478 test_mkdir -p $DIR/$tdir/d2
3479 touch $DIR/$tdir/d2/test_file || error "touch failed"
3480 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3481 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
3482 cleanup_test32_mount
3484 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
3487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3490 trap cleanup_test32_mount EXIT
3491 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3492 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3493 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3494 test_mkdir -p $DIR/$tdir/d2
3495 touch $DIR/$tdir/d2/test_file || error "touch failed"
3496 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
3497 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
3498 cleanup_test32_mount
3500 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
3504 test_mkdir -p $DIR/d32m/tmp
3505 TMP_DIR=$DIR/d32m/tmp
3506 ln -s $DIR $TMP_DIR/symlink11
3507 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3508 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
3509 error "symlink11 not a link"
3510 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3511 error "symlink01 not a link"
3513 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3517 test_mkdir -p $DIR/d32n/tmp
3518 TMP_DIR=$DIR/d32n/tmp
3519 ln -s $DIR $TMP_DIR/symlink11
3520 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3521 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3522 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3524 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3528 test_mkdir -p $DIR/d32o/tmp
3529 TMP_DIR=$DIR/d32o/tmp
3530 ln -s $DIR/$tfile $TMP_DIR/symlink12
3531 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3532 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3533 error "symlink12 not a link"
3534 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3535 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3536 error "$DIR/d32o/tmp/symlink12 not file type"
3537 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3538 error "$DIR/d32o/symlink02 not file type"
3540 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3550 test_mkdir -p $DIR/d32p/tmp
3552 TMP_DIR=$DIR/d32p/tmp
3554 ln -s $DIR/$tfile $TMP_DIR/symlink12
3556 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3558 cat $DIR/d32p/tmp/symlink12 ||
3559 error "Can't open $DIR/d32p/tmp/symlink12"
3561 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3564 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3569 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3570 trap cleanup_test32_mount EXIT
3571 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3572 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3573 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3574 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3575 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3576 cleanup_test32_mount
3578 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3583 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3584 trap cleanup_test32_mount EXIT
3585 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3586 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3587 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3588 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3589 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3590 cleanup_test32_mount
3592 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3597 chmod 444 $DIR/$tfile
3598 chown $RUNAS_ID $DIR/$tfile
3600 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3603 run_test 33aa "write file with mode 444 (should return error)"
3607 test_mkdir $DIR/$tdir
3608 chown $RUNAS_ID $DIR/$tdir
3609 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3610 error "$RUNAS create $tdir/$tfile failed"
3611 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3612 error "open RDWR" || true
3614 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3618 test_mkdir $DIR/$tdir
3619 chown $RUNAS_ID $DIR/$tdir
3620 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3622 run_test 33b "test open file with malformed flags (No panic)"
3625 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3626 remote_ost_nodsh && skip "remote OST with nodsh"
3635 test_mkdir $DIR/$tdir
3636 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3639 for ostnum in $(seq $OSTCOUNT); do
3640 # test-framework's OST numbering is one-based, while Lustre's
3642 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3643 # Parsing llobdstat's output sucks; we could grep the /proc
3644 # path, but that's likely to not be as portable as using the
3645 # llobdstat utility. So we parse lctl output instead.
3646 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3647 obdfilter/$ostname/stats |
3648 awk '/^write_bytes/ {print $7}' )
3649 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3650 if (( ${write_bytes:-0} > 0 ))
3657 $all_zeros || return 0
3660 echo foo > $DIR/$tdir/bar
3664 # Total up write_bytes after writing. We'd better find non-zeros.
3665 for ostnum in $(seq $OSTCOUNT); do
3666 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3667 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3668 obdfilter/$ostname/stats |
3669 awk '/^write_bytes/ {print $7}' )
3670 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3671 if (( ${write_bytes:-0} > 0 ))
3680 for ostnum in $(seq $OSTCOUNT); do
3681 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3682 echo "Check that write_bytes is present in obdfilter/*/stats:"
3683 do_facet ost$ostnum lctl get_param -n \
3684 obdfilter/$ostname/stats
3686 error "OST not keeping write_bytes stats (b22312)"
3689 run_test 33c "test llobdstat and write_bytes"
3692 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3693 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3696 local remote_dir=$DIR/$tdir/remote_dir
3698 test_mkdir $DIR/$tdir
3699 $LFS mkdir -i $MDTIDX $remote_dir ||
3700 error "create remote directory failed"
3702 touch $remote_dir/$tfile
3703 chmod 444 $remote_dir/$tfile
3704 chown $RUNAS_ID $remote_dir/$tfile
3706 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3708 chown $RUNAS_ID $remote_dir
3709 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3710 error "create" || true
3711 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3712 error "open RDWR" || true
3713 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3715 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3718 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3722 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3723 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3724 mkdir $DIR/$tdir/local_dir
3726 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3727 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3728 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3730 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3731 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3733 rmdir $DIR/$tdir/* || error "rmdir failed"
3736 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3737 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3738 mkdir $DIR/$tdir/local_dir
3740 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3741 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3742 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3744 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3745 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3747 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3750 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3751 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3752 mkdir $DIR/$tdir/local_dir
3754 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3755 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3756 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3758 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3759 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3761 run_test 33e "mkdir and striped directory should have same mode"
3765 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3769 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3770 remote_mds_nodsh && skip "remote MDS with nodsh"
3773 chmod go+rwx $DIR/$tdir
3774 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3775 trap cleanup_33f EXIT
3777 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3778 error "cannot create striped directory"
3780 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3781 error "cannot create files in striped directory"
3783 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3784 error "cannot remove files in striped directory"
3786 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3787 error "cannot remove striped directory"
3791 run_test 33f "nonroot user can create, access, and remove a striped directory"
3794 mkdir -p $DIR/$tdir/dir2
3796 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3798 [[ $err =~ "exists" ]] || error "Not exists error"
3800 run_test 33g "nonroot user create already existing root created file"
3803 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3804 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
3805 skip "Need MDS version at least 2.13.50"
3807 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir ||
3808 error "mkdir $tdir failed"
3809 touch $DIR/$tdir/$tfile || error "touch $tfile failed"
3811 local index=$($LFS getstripe -m $DIR/$tdir/$tfile)
3814 for fname in $DIR/$tdir/$tfile.bak \
3815 $DIR/$tdir/$tfile.SAV \
3816 $DIR/$tdir/$tfile.orig \
3817 $DIR/$tdir/$tfile~; do
3818 touch $fname || error "touch $fname failed"
3819 index2=$($LFS getstripe -m $fname)
3820 [ $index -eq $index2 ] ||
3821 error "$fname MDT index mismatch $index != $index2"
3825 for i in {1..50}; do
3826 for fname in $(mktemp -u $DIR/$tdir/.$tfile.XXXXXX) \
3827 $(mktemp $DIR/$tdir/$tfile.XXXXXXXX); do
3828 touch $fname || error "touch $fname failed"
3829 index2=$($LFS getstripe -m $fname)
3830 if [[ $index != $index2 ]]; then
3831 failed=$((failed + 1))
3832 echo "$fname MDT index mismatch $index != $index2"
3836 echo "$failed MDT index mismatches"
3837 (( failed < 4 )) || error "MDT index mismatch $failed times"
3840 run_test 33h "temp file is located on the same MDT as target"
3842 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3845 $MCREATE $DIR/f34 || error "mcreate failed"
3846 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3847 error "getstripe failed"
3848 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3849 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3850 error "getstripe failed"
3851 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3852 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3854 run_test 34a "truncate file that has not been opened ==========="
3857 [ ! -f $DIR/f34 ] && test_34a
3858 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3859 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3860 $OPENFILE -f O_RDONLY $DIR/f34
3861 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3862 error "getstripe failed"
3863 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3864 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3866 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3869 [ ! -f $DIR/f34 ] && test_34a
3870 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3871 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3872 $OPENFILE -f O_RDWR $DIR/f34
3873 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3874 error "$LFS getstripe failed"
3875 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3876 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3878 run_test 34c "O_RDWR opening file-with-size works =============="
3881 [ ! -f $DIR/f34 ] && test_34a
3882 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3884 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3885 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3888 run_test 34d "write to sparse file ============================="
3892 $MCREATE $DIR/f34e || error "mcreate failed"
3893 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3894 $CHECKSTAT -s 1000 $DIR/f34e ||
3895 error "Size of $DIR/f34e not equal to 1000 bytes"
3896 $OPENFILE -f O_RDWR $DIR/f34e
3897 $CHECKSTAT -s 1000 $DIR/f34e ||
3898 error "Size of $DIR/f34e not equal to 1000 bytes"
3900 run_test 34e "create objects, some with size and some without =="
3902 test_34f() { # bug 6242, 6243
3903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3907 $MCREATE $DIR/f34f || error "mcreate failed"
3908 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3909 dd if=$DIR/f34f of=$TMP/f34f
3910 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3911 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3912 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3913 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3914 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3916 run_test 34f "read from a file with no objects until EOF ======="
3919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3921 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3923 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3924 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3925 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3926 cancel_lru_locks osc
3927 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3928 error "wrong size after lock cancel"
3930 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3931 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3932 error "expanding truncate failed"
3933 cancel_lru_locks osc
3934 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3935 error "wrong expanded size after lock cancel"
3937 run_test 34g "truncate long file ==============================="
3940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3945 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3946 sync # Flush the cache so that multiop below does not block on cache
3947 # flush when getting the group lock
3948 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3951 # Since just timed wait is not good enough, let's do a sync write
3952 # that way we are sure enough time for a roundtrip + processing
3953 # passed + 2 seconds of extra margin.
3954 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3958 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3959 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3963 local nsz=`stat -c %s $DIR/$tfile`
3964 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3966 run_test 34h "ftruncate file under grouplock should not block"
3969 cp /bin/sh $DIR/f35a
3971 chown $RUNAS_ID $DIR/f35a
3972 $RUNAS $DIR/f35a && error || true
3975 run_test 35a "exec file with mode 444 (should return and not leak)"
3979 utime $DIR/f36 || error "utime failed for MDS"
3981 run_test 36a "MDS utime check (mknod, utime)"
3985 utime $DIR/f36 || error "utime failed for OST"
3987 run_test 36b "OST utime check (open, utime)"
3992 chown $RUNAS_ID $DIR/d36
3993 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3995 run_test 36c "non-root MDS utime check (mknod, utime)"
3998 [ ! -d $DIR/d36 ] && test_36c
3999 echo "" > $DIR/d36/f36
4000 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
4002 run_test 36d "non-root OST utime check (open, utime)"
4005 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
4007 test_mkdir $DIR/$tdir
4008 touch $DIR/$tdir/$tfile
4009 $RUNAS utime $DIR/$tdir/$tfile &&
4010 error "utime worked, expected failure" || true
4012 run_test 36e "utime on non-owned file (should return error)"
4016 local LANG_SAVE=$LANG
4017 local LC_LANG_SAVE=$LC_LANG
4018 export LANG=C LC_LANG=C # for date language
4020 DATESTR="Dec 20 2000"
4021 test_mkdir $DIR/$tdir
4022 lctl set_param fail_loc=$fl
4024 cp /etc/hosts $DIR/$tdir/$tfile
4025 sync & # write RPC generated with "current" inode timestamp, but delayed
4027 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
4028 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
4029 cancel_lru_locks $OSC
4030 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
4032 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
4033 echo "BEFORE: $LS_BEFORE" && \
4034 echo "AFTER : $LS_AFTER" && \
4035 echo "WANT : $DATESTR" && \
4036 error "$DIR/$tdir/$tfile timestamps changed" || true
4038 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
4042 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4044 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4045 subr_36fh "0x80000214"
4047 run_test 36f "utime on file racing with OST BRW write =========="
4050 remote_ost_nodsh && skip "remote OST with nodsh"
4051 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4052 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
4053 skip "Need MDS version at least 2.12.51"
4058 local tgt="obdfilter"
4060 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
4062 test_mkdir $DIR/$tdir
4063 fmd_max_age=$(do_facet $facet \
4064 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
4067 echo "FMD max age: ${fmd_max_age}s"
4068 touch $DIR/$tdir/$tfile
4069 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4070 gawk '{cnt=cnt+$1} END{print cnt}')
4071 echo "FMD before: $fmd"
4073 error "FMD wasn't create by touch"
4074 sleep $((fmd_max_age + 12))
4075 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
4076 gawk '{cnt=cnt+$1} END{print cnt}')
4077 echo "FMD after: $fmd"
4079 error "FMD wasn't expired by ping"
4081 run_test 36g "FMD cache expiry ====================="
4084 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4086 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
4087 subr_36fh "0x80000227"
4089 run_test 36h "utime on file racing with OST BRW write =========="
4092 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
4094 test_mkdir $DIR/$tdir
4095 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4097 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
4098 local new_mtime=$((mtime + 200))
4100 #change Modify time of striped dir
4101 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
4102 error "change mtime failed"
4104 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
4106 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
4108 run_test 36i "change mtime on striped directory"
4110 # test_37 - duplicate with tests 32q 32r
4113 local file=$DIR/$tfile
4115 openfile -f O_DIRECTORY $file
4118 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
4119 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
4121 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
4123 test_39a() { # was test_39
4125 touch $DIR/${tfile}2
4126 # ls -l $DIR/$tfile $DIR/${tfile}2
4127 # ls -lu $DIR/$tfile $DIR/${tfile}2
4128 # ls -lc $DIR/$tfile $DIR/${tfile}2
4130 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
4131 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
4133 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
4135 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
4137 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
4138 error "O_TRUNC didn't change timestamps"
4141 run_test 39a "mtime changed on create"
4144 test_mkdir -c1 $DIR/$tdir
4145 cp -p /etc/passwd $DIR/$tdir/fopen
4146 cp -p /etc/passwd $DIR/$tdir/flink
4147 cp -p /etc/passwd $DIR/$tdir/funlink
4148 cp -p /etc/passwd $DIR/$tdir/frename
4149 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
4152 echo "aaaaaa" >> $DIR/$tdir/fopen
4153 echo "aaaaaa" >> $DIR/$tdir/flink
4154 echo "aaaaaa" >> $DIR/$tdir/funlink
4155 echo "aaaaaa" >> $DIR/$tdir/frename
4157 local open_new=`stat -c %Y $DIR/$tdir/fopen`
4158 local link_new=`stat -c %Y $DIR/$tdir/flink`
4159 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
4160 local rename_new=`stat -c %Y $DIR/$tdir/frename`
4162 cat $DIR/$tdir/fopen > /dev/null
4163 ln $DIR/$tdir/flink $DIR/$tdir/flink2
4164 rm -f $DIR/$tdir/funlink2
4165 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
4167 for (( i=0; i < 2; i++ )) ; do
4168 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
4169 local link_new2=`stat -c %Y $DIR/$tdir/flink`
4170 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
4171 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
4173 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
4174 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
4175 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
4176 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
4178 cancel_lru_locks $OSC
4179 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4182 run_test 39b "mtime change on open, link, unlink, rename ======"
4184 # this should be set to past
4185 TEST_39_MTIME=`date -d "1 year ago" +%s`
4191 local mtime0=`stat -c %Y $DIR1/$tfile`
4193 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4194 local mtime1=`stat -c %Y $DIR1/$tfile`
4195 [ "$mtime1" = $TEST_39_MTIME ] || \
4196 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
4199 echo hello >> $DIR1/$tfile
4201 local mtime2=`stat -c %Y $DIR1/$tfile`
4202 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
4203 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
4205 mv $DIR1/$tfile $DIR1/$tfile-1
4207 for (( i=0; i < 2; i++ )) ; do
4208 local mtime3=`stat -c %Y $DIR1/$tfile-1`
4209 [ "$mtime2" = "$mtime3" ] || \
4210 error "mtime ($mtime2) changed (to $mtime3) on rename"
4212 cancel_lru_locks $OSC
4213 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4216 run_test 39c "mtime change on rename ==========================="
4220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4223 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4225 for (( i=0; i < 2; i++ )) ; do
4226 local mtime=`stat -c %Y $DIR1/$tfile`
4227 [ $mtime = $TEST_39_MTIME ] || \
4228 error "mtime($mtime) is not set to $TEST_39_MTIME"
4230 cancel_lru_locks $OSC
4231 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4234 run_test 39d "create, utime, stat =============================="
4238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4241 local mtime1=`stat -c %Y $DIR1/$tfile`
4243 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4245 for (( i=0; i < 2; i++ )) ; do
4246 local mtime2=`stat -c %Y $DIR1/$tfile`
4247 [ $mtime2 = $TEST_39_MTIME ] || \
4248 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4250 cancel_lru_locks $OSC
4251 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4254 run_test 39e "create, stat, utime, stat ========================"
4258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4261 mtime1=`stat -c %Y $DIR1/$tfile`
4264 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4266 for (( i=0; i < 2; i++ )) ; do
4267 local mtime2=`stat -c %Y $DIR1/$tfile`
4268 [ $mtime2 = $TEST_39_MTIME ] || \
4269 error "mtime($mtime2) is not set to $TEST_39_MTIME"
4271 cancel_lru_locks $OSC
4272 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4275 run_test 39f "create, stat, sleep, utime, stat ================="
4279 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4281 echo hello >> $DIR1/$tfile
4282 local mtime1=`stat -c %Y $DIR1/$tfile`
4285 chmod o+r $DIR1/$tfile
4287 for (( i=0; i < 2; i++ )) ; do
4288 local mtime2=`stat -c %Y $DIR1/$tfile`
4289 [ "$mtime1" = "$mtime2" ] || \
4290 error "lost mtime: $mtime2, should be $mtime1"
4292 cancel_lru_locks $OSC
4293 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4296 run_test 39g "write, chmod, stat ==============================="
4300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4306 echo hello >> $DIR1/$tfile
4307 local mtime1=`stat -c %Y $DIR1/$tfile`
4309 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4311 if [ "$d1" != "$d2" ]; then
4312 echo "write and touch not within one second"
4314 for (( i=0; i < 2; i++ )) ; do
4315 local mtime2=`stat -c %Y $DIR1/$tfile`
4316 [ "$mtime2" = $TEST_39_MTIME ] || \
4317 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
4319 cancel_lru_locks $OSC
4320 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4324 run_test 39h "write, utime within one second, stat ============="
4327 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4332 echo hello >> $DIR1/$tfile
4333 local mtime1=`stat -c %Y $DIR1/$tfile`
4335 mv $DIR1/$tfile $DIR1/$tfile-1
4337 for (( i=0; i < 2; i++ )) ; do
4338 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4340 [ "$mtime1" = "$mtime2" ] || \
4341 error "lost mtime: $mtime2, should be $mtime1"
4343 cancel_lru_locks $OSC
4344 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4347 run_test 39i "write, rename, stat =============================="
4350 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4352 start_full_debug_logging
4356 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
4357 lctl set_param fail_loc=0x80000412
4358 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
4359 error "multiop failed"
4361 local mtime1=`stat -c %Y $DIR1/$tfile`
4363 mv $DIR1/$tfile $DIR1/$tfile-1
4365 kill -USR1 $multipid
4366 wait $multipid || error "multiop close failed"
4368 for (( i=0; i < 2; i++ )) ; do
4369 local mtime2=`stat -c %Y $DIR1/$tfile-1`
4370 [ "$mtime1" = "$mtime2" ] ||
4371 error "mtime is lost on close: $mtime2, " \
4375 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4377 lctl set_param fail_loc=0
4378 stop_full_debug_logging
4380 run_test 39j "write, rename, close, stat ======================="
4383 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4388 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
4390 local mtime1=`stat -c %Y $DIR1/$tfile`
4392 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
4394 kill -USR1 $multipid
4395 wait $multipid || error "multiop close failed"
4397 for (( i=0; i < 2; i++ )) ; do
4398 local mtime2=`stat -c %Y $DIR1/$tfile`
4400 [ "$mtime2" = $TEST_39_MTIME ] || \
4401 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
4404 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4407 run_test 39k "write, utime, close, stat ========================"
4409 # this should be set to future
4410 TEST_39_ATIME=`date -d "1 year" +%s`
4413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4414 remote_mds_nodsh && skip "remote MDS with nodsh"
4416 local atime_diff=$(do_facet $SINGLEMDS \
4417 lctl get_param -n mdd.*MDT0000*.atime_diff)
4421 # test setting directory atime to future
4422 touch -a -d @$TEST_39_ATIME $DIR/$tdir
4423 local atime=$(stat -c %X $DIR/$tdir)
4424 [ "$atime" = $TEST_39_ATIME ] ||
4425 error "atime is not set to future: $atime, $TEST_39_ATIME"
4427 # test setting directory atime from future to now
4428 local now=$(date +%s)
4429 touch -a -d @$now $DIR/$tdir
4431 atime=$(stat -c %X $DIR/$tdir)
4432 [ "$atime" -eq "$now" ] ||
4433 error "atime is not updated from future: $atime, $now"
4435 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
4438 # test setting directory atime when now > dir atime + atime_diff
4439 local d1=$(date +%s)
4441 local d2=$(date +%s)
4442 cancel_lru_locks mdc
4443 atime=$(stat -c %X $DIR/$tdir)
4444 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4445 error "atime is not updated : $atime, should be $d2"
4447 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
4450 # test not setting directory atime when now < dir atime + atime_diff
4452 cancel_lru_locks mdc
4453 atime=$(stat -c %X $DIR/$tdir)
4454 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
4455 error "atime is updated to $atime, should remain $d1<atime<$d2"
4457 do_facet $SINGLEMDS \
4458 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4460 run_test 39l "directory atime update ==========================="
4463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4467 local far_past_mtime=$(date -d "May 29 1953" +%s)
4468 local far_past_atime=$(date -d "Dec 17 1903" +%s)
4470 touch -m -d @$far_past_mtime $DIR1/$tfile
4471 touch -a -d @$far_past_atime $DIR1/$tfile
4473 for (( i=0; i < 2; i++ )) ; do
4474 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
4475 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
4476 error "atime or mtime set incorrectly"
4478 cancel_lru_locks $OSC
4479 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
4482 run_test 39m "test atime and mtime before 1970"
4484 test_39n() { # LU-3832
4485 remote_mds_nodsh && skip "remote MDS with nodsh"
4487 local atime_diff=$(do_facet $SINGLEMDS \
4488 lctl get_param -n mdd.*MDT0000*.atime_diff)
4493 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
4496 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
4497 atime0=$(stat -c %X $DIR/$tfile)
4500 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4501 atime1=$(stat -c %X $DIR/$tfile)
4504 cancel_lru_locks mdc
4505 cancel_lru_locks osc
4506 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
4507 atime2=$(stat -c %X $DIR/$tfile)
4509 do_facet $SINGLEMDS \
4510 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
4512 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
4513 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
4515 run_test 39n "check that O_NOATIME is honored"
4518 TESTDIR=$DIR/$tdir/$tfile
4519 [ -e $TESTDIR ] && rm -rf $TESTDIR
4526 links2=$(stat -c %h .)
4527 [ $(($links1 + 2)) != $links2 ] &&
4528 error "wrong links count $(($links1 + 2)) != $links2"
4530 links3=$(stat -c %h .)
4531 [ $(($links1 + 1)) != $links3 ] &&
4532 error "wrong links count $links1 != $links3"
4535 run_test 39o "directory cached attributes updated after create"
4538 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
4541 TESTDIR=$DIR/$tdir/$tdir
4542 [ -e $TESTDIR ] && rm -rf $TESTDIR
4543 test_mkdir -p $TESTDIR
4547 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
4548 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
4550 links2=$(stat -c %h .)
4551 [ $(($links1 + 2)) != $links2 ] &&
4552 error "wrong links count $(($links1 + 2)) != $links2"
4554 links3=$(stat -c %h .)
4555 [ $(($links1 + 1)) != $links3 ] &&
4556 error "wrong links count $links1 != $links3"
4559 run_test 39p "remote directory cached attributes updated after create ========"
4562 [ $OST1_VERSION -ge $(version_code 2.13.52) ] ||
4563 skip "no atime update on old OST"
4564 if [ "$ost1_FSTYPE" != ldiskfs ]; then
4565 skip_env "ldiskfs only test"
4569 saved_adiff=$(do_facet ost1 \
4570 lctl get_param -n obdfilter.*OST0000.atime_diff)
4571 stack_trap "do_facet ost1 \
4572 lctl set_param obdfilter.*.atime_diff=$saved_adiff"
4574 do_facet ost1 "lctl set_param obdfilter.*.atime_diff=5"
4576 $LFS setstripe -i 0 $DIR/$tfile
4577 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
4578 error "can't write initial file"
4579 cancel_lru_locks osc
4581 # exceed atime_diff and access file
4583 dd if=$DIR/$tfile of=/dev/null || error "can't udpate atime"
4585 local atime_cli=$(stat -c %X $DIR/$tfile)
4586 echo "client atime: $atime_cli"
4587 # allow atime update to be written to device
4588 do_facet ost1 "$LCTL set_param -n osd*.*OST*.force_sync 1"
4591 local ostdev=$(ostdevname 1)
4592 local fid=($(lfs getstripe -y $DIR/$tfile |
4593 awk '/l_fid:/ { print $2 }' | tr ':' ' '))
4594 local objpath="O/0/d$((${fid[1]} % 32))/$((${fid[1]}))"
4595 local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
4597 echo "OST atime: $(do_facet ost1 "$cmd" |& grep atime)"
4598 local atime_ost=$(do_facet ost1 "$cmd" |&
4599 awk -F'[: ]' '/atime:/ { print $4 }')
4600 (( atime_cli == atime_ost )) ||
4601 error "atime on client $atime_cli != ost $atime_ost"
4603 run_test 39r "lazy atime update on OST"
4605 test_39q() { # LU-8041
4606 local testdir=$DIR/$tdir
4608 multiop_bg_pause $testdir D_c || error "multiop failed"
4610 cancel_lru_locks mdc
4611 kill -USR1 $multipid
4612 local atime=$(stat -c %X $testdir)
4613 [ "$atime" -ne 0 ] || error "atime is zero"
4615 run_test 39q "close won't zero out atime"
4618 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4619 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4620 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4621 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4622 error "$tfile is not 4096 bytes in size"
4624 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4628 small_write $DIR/f41 18
4630 run_test 41 "test small file write + fstat ====================="
4632 count_ost_writes() {
4633 lctl get_param -n ${OSC}.*.stats |
4634 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4635 END { printf("%0.0f", writes) }'
4642 BG_DIRTY_RATIO_SAVE=10
4643 MAX_BG_DIRTY_RATIO=25
4647 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4648 # dirty_ratio, dirty_background_ratio
4649 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4650 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4651 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4652 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4654 # if file not here, we are a 2.4 kernel
4655 kill -CONT `pidof kupdated`
4660 # setup the trap first, so someone cannot exit the test at the
4661 # exact wrong time and mess up a machine
4662 trap start_writeback EXIT
4663 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4664 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4665 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4666 sysctl -w vm.dirty_writeback_centisecs=0
4667 sysctl -w vm.dirty_writeback_centisecs=0
4668 # save and increase /proc/sys/vm/dirty_ratio
4669 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4670 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4671 # save and increase /proc/sys/vm/dirty_background_ratio
4672 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4673 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4675 # if file not here, we are a 2.4 kernel
4676 kill -STOP `pidof kupdated`
4680 # ensure that all stripes have some grant before we test client-side cache
4682 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4683 dd if=/dev/zero of=$i bs=4k count=1
4688 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4689 # file truncation, and file removal.
4691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4694 cancel_lru_locks $OSC
4696 sync; sleep 1; sync # just to be safe
4697 BEFOREWRITES=`count_ost_writes`
4698 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4699 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4700 AFTERWRITES=`count_ost_writes`
4701 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4702 error "$BEFOREWRITES < $AFTERWRITES"
4705 run_test 42a "ensure that we don't flush on close"
4708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4711 cancel_lru_locks $OSC
4714 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4715 BEFOREWRITES=$(count_ost_writes)
4716 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4717 AFTERWRITES=$(count_ost_writes)
4718 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4719 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4721 BEFOREWRITES=$(count_ost_writes)
4722 sync || error "sync: $?"
4723 AFTERWRITES=$(count_ost_writes)
4724 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4725 error "$BEFOREWRITES < $AFTERWRITES on sync"
4727 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4731 run_test 42b "test destroy of file with cached dirty data ======"
4733 # if these tests just want to test the effect of truncation,
4734 # they have to be very careful. consider:
4735 # - the first open gets a {0,EOF}PR lock
4736 # - the first write conflicts and gets a {0, count-1}PW
4737 # - the rest of the writes are under {count,EOF}PW
4738 # - the open for truncate tries to match a {0,EOF}PR
4739 # for the filesize and cancels the PWs.
4740 # any number of fixes (don't get {0,EOF} on open, match
4741 # composite locks, do smarter file size management) fix
4742 # this, but for now we want these tests to verify that
4743 # the cancellation with truncate intent works, so we
4744 # start the file with a full-file pw lock to match against
4745 # until the truncate.
4750 cancel_lru_locks $OSC
4752 # prime the file with 0,EOF PW to match
4756 # now the real test..
4757 dd if=/dev/zero of=$file bs=1024 count=100
4758 BEFOREWRITES=`count_ost_writes`
4759 $TRUNCATE $file $offset
4760 cancel_lru_locks $OSC
4761 AFTERWRITES=`count_ost_writes`
4766 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4769 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4770 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4773 run_test 42c "test partial truncate of file with cached dirty data"
4776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4779 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4780 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4783 run_test 42d "test complete truncate of file with cached dirty data"
4785 test_42e() { # bug22074
4786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4788 local TDIR=$DIR/${tdir}e
4789 local pages=16 # hardcoded 16 pages, don't change it.
4790 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4791 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4795 test_mkdir $DIR/${tdir}e
4796 $LFS setstripe -c 1 $TDIR
4797 createmany -o $TDIR/f $files
4799 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4801 # we assume that with $OSTCOUNT files, at least one of them will
4802 # be allocated on OST0.
4803 warmup_files=$((OSTCOUNT * max_dirty_mb))
4804 createmany -o $TDIR/w $warmup_files
4806 # write a large amount of data into one file and sync, to get good
4807 # avail_grant number from OST.
4808 for ((i=0; i<$warmup_files; i++)); do
4809 idx=$($LFS getstripe -i $TDIR/w$i)
4810 [ $idx -ne 0 ] && continue
4811 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4814 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4816 $LCTL get_param $proc_osc0/cur_dirty_bytes
4817 $LCTL get_param $proc_osc0/cur_grant_bytes
4819 # create as much dirty pages as we can while not to trigger the actual
4820 # RPCs directly. but depends on the env, VFS may trigger flush during this
4821 # period, hopefully we are good.
4822 for ((i=0; i<$warmup_files; i++)); do
4823 idx=$($LFS getstripe -i $TDIR/w$i)
4824 [ $idx -ne 0 ] && continue
4825 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4827 $LCTL get_param $proc_osc0/cur_dirty_bytes
4828 $LCTL get_param $proc_osc0/cur_grant_bytes
4830 # perform the real test
4831 $LCTL set_param $proc_osc0/rpc_stats 0
4832 for ((;i<$files; i++)); do
4833 [ $($LFS getstripe -i $TDIR/f$i) -eq 0 ] || continue
4834 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4837 $LCTL get_param $proc_osc0/rpc_stats
4840 local have_ppr=false
4841 $LCTL get_param $proc_osc0/rpc_stats |
4842 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4843 # skip lines until we are at the RPC histogram data
4844 [ "$PPR" == "pages" ] && have_ppr=true && continue
4845 $have_ppr || continue
4847 # we only want the percent stat for < 16 pages
4848 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4850 percent=$((percent + WPCT))
4851 if [[ $percent -gt 15 ]]; then
4852 error "less than 16-pages write RPCs" \
4859 run_test 42e "verify sub-RPC writes are not done synchronously"
4861 test_43A() { # was test_43
4862 test_mkdir $DIR/$tdir
4863 cp -p /bin/ls $DIR/$tdir/$tfile
4864 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4866 # give multiop a chance to open
4869 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4872 run_test 43A "execution of file opened for write should return -ETXTBSY"
4875 test_mkdir $DIR/$tdir
4876 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4877 $DIR/$tdir/sleep 60 &
4879 # Make sure exec of $tdir/sleep wins race with truncate
4881 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4884 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4887 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4889 test_mkdir $DIR/$tdir
4890 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4891 $DIR/$tdir/sleep 60 &
4893 # Make sure exec of $tdir/sleep wins race with truncate
4895 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4898 run_test 43b "truncate of file being executed should return -ETXTBSY"
4901 local testdir="$DIR/$tdir"
4904 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4905 ( cd $testdir && md5sum -c )
4907 run_test 43c "md5sum of copy into lustre"
4909 test_44A() { # was test_44
4910 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4912 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4913 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4915 run_test 44A "zero length read from a sparse stripe"
4918 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4920 [ -z "$nstripe" ] && skip "can't get stripe info"
4921 [[ $nstripe -gt $OSTCOUNT ]] &&
4922 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4924 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4926 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4927 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4931 OFFSETS="0 $((stride/2)) $((stride-1))"
4932 for offset in $OFFSETS; do
4933 for i in $(seq 0 $((nstripe-1))); do
4934 local GLOBALOFFSETS=""
4936 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4937 local myfn=$DIR/d44a-$size
4938 echo "--------writing $myfn at $size"
4939 ll_sparseness_write $myfn $size ||
4940 error "ll_sparseness_write"
4941 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4942 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4943 error "ll_sparseness_verify $GLOBALOFFSETS"
4945 for j in $(seq 0 $((nstripe-1))); do
4947 size=$((((j + $nstripe )*$stride + $offset)))
4948 ll_sparseness_write $myfn $size ||
4949 error "ll_sparseness_write"
4950 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4952 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4953 error "ll_sparseness_verify $GLOBALOFFSETS"
4958 run_test 44a "test sparse pwrite ==============================="
4962 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4968 before=`dirty_osc_total`
4969 echo executing "\"$*\""
4971 after=`dirty_osc_total`
4972 echo before $before, after $after
4975 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4978 # Obtain grants from OST if it supports it
4979 echo blah > ${f}_grant
4982 do_dirty_record "echo blah > $f"
4983 [[ $before -eq $after ]] && error "write wasn't cached"
4984 do_dirty_record "> $f"
4985 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4986 do_dirty_record "echo blah > $f"
4987 [[ $before -eq $after ]] && error "write wasn't cached"
4988 do_dirty_record "sync"
4989 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4990 do_dirty_record "echo blah > $f"
4991 [[ $before -eq $after ]] && error "write wasn't cached"
4992 do_dirty_record "cancel_lru_locks osc"
4993 [[ $before -gt $after ]] ||
4994 error "lock cancellation didn't lower dirty count"
4997 run_test 45 "osc io page accounting ============================"
4999 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
5000 # test tickles a bug where re-dirtying a page was failing to be mapped to the
5001 # objects offset and an assert hit when an rpc was built with 1023's mapped
5002 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
5004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5009 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5011 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
5012 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
5016 run_test 46 "dirtying a previously written page ================"
5018 # test_47 is removed "Device nodes check" is moved to test_28
5020 test_48a() { # bug 2399
5021 [ "$mds1_FSTYPE" = "zfs" ] &&
5022 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
5023 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
5025 test_mkdir $DIR/$tdir
5027 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
5028 test_mkdir $DIR/$tdir
5029 touch foo || error "'touch foo' failed after recreating cwd"
5031 touch .foo || error "'touch .foo' failed after recreating cwd"
5033 ls . > /dev/null || error "'ls .' failed after recreating cwd"
5034 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5035 cd . || error "'cd .' failed after recreating cwd"
5036 mkdir . && error "'mkdir .' worked after recreating cwd"
5037 rmdir . && error "'rmdir .' worked after recreating cwd"
5038 ln -s . baz || error "'ln -s .' failed after recreating cwd"
5039 cd .. || error "'cd ..' failed after recreating cwd"
5041 run_test 48a "Access renamed working dir (should return errors)="
5043 test_48b() { # bug 2399
5045 test_mkdir $DIR/$tdir
5047 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
5048 touch foo && error "'touch foo' worked after removing cwd"
5049 mkdir foo && error "'mkdir foo' worked after removing cwd"
5050 touch .foo && error "'touch .foo' worked after removing cwd"
5051 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
5052 ls . > /dev/null && error "'ls .' worked after removing cwd"
5053 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
5054 mkdir . && error "'mkdir .' worked after removing cwd"
5055 rmdir . && error "'rmdir .' worked after removing cwd"
5056 ln -s . foo && error "'ln -s .' worked after removing cwd"
5057 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
5059 run_test 48b "Access removed working dir (should return errors)="
5061 test_48c() { # bug 2350
5062 #lctl set_param debug=-1
5065 test_mkdir -p $DIR/$tdir/dir
5067 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5068 $TRACE touch foo && error "touch foo worked after removing cwd"
5069 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
5070 touch .foo && error "touch .foo worked after removing cwd"
5071 mkdir .foo && error "mkdir .foo worked after removing cwd"
5072 $TRACE ls . && error "'ls .' worked after removing cwd"
5073 $TRACE ls .. || error "'ls ..' failed after removing cwd"
5074 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
5075 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
5076 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
5077 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
5079 run_test 48c "Access removed working subdir (should return errors)"
5081 test_48d() { # bug 2350
5082 #lctl set_param debug=-1
5085 test_mkdir -p $DIR/$tdir/dir
5087 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5088 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5089 $TRACE touch foo && error "'touch foo' worked after removing parent"
5090 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
5091 touch .foo && error "'touch .foo' worked after removing parent"
5092 mkdir .foo && error "mkdir .foo worked after removing parent"
5093 $TRACE ls . && error "'ls .' worked after removing parent"
5094 $TRACE ls .. && error "'ls ..' worked after removing parent"
5095 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
5096 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
5097 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
5100 run_test 48d "Access removed parent subdir (should return errors)"
5102 test_48e() { # bug 4134
5103 #lctl set_param debug=-1
5106 test_mkdir -p $DIR/$tdir/dir
5108 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
5109 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
5110 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
5111 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
5112 # On a buggy kernel addition of "touch foo" after cd .. will
5113 # produce kernel oops in lookup_hash_it
5114 touch ../foo && error "'cd ..' worked after recreate parent"
5116 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
5118 run_test 48e "Access to recreated parent subdir (should return errors)"
5120 test_49() { # LU-1030
5121 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5122 remote_ost_nodsh && skip "remote OST with nodsh"
5124 # get ost1 size - $FSNAME-OST0000
5125 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
5127 # write 800M at maximum
5128 [[ $ost1_size -lt 2 ]] && ost1_size=2
5129 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
5131 $LFS setstripe -c 1 -i 0 $DIR/$tfile
5132 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
5135 # change max_pages_per_rpc while writing the file
5136 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
5137 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
5138 # loop until dd process exits
5139 while ps ax -opid | grep -wq $dd_pid; do
5140 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
5141 sleep $((RANDOM % 5 + 1))
5143 # restore original max_pages_per_rpc
5144 $LCTL set_param $osc1_mppc=$orig_mppc
5145 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
5147 run_test 49 "Change max_pages_per_rpc won't break osc extent"
5151 test_mkdir $DIR/$tdir
5153 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
5155 run_test 50 "special situations: /proc symlinks ==============="
5157 test_51a() { # was test_51
5158 # bug 1516 - create an empty entry right after ".." then split dir
5159 test_mkdir -c1 $DIR/$tdir
5160 touch $DIR/$tdir/foo
5161 $MCREATE $DIR/$tdir/bar
5163 createmany -m $DIR/$tdir/longfile 201
5165 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
5166 $MCREATE $DIR/$tdir/longfile$FNUM
5171 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
5173 run_test 51a "special situations: split htree with empty entry =="
5175 cleanup_print_lfs_df () {
5182 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5184 local dir=$DIR/$tdir
5185 local nrdirs=$((65536 + 100))
5187 # cleanup the directory
5194 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
5195 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
5196 [[ $numfree -lt $nrdirs ]] &&
5197 skip "not enough free inodes ($numfree) on MDT$mdtidx"
5199 # need to check free space for the directories as well
5200 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
5201 numfree=$(( blkfree / $(fs_inode_ksize) ))
5202 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
5204 trap cleanup_print_lfs_df EXIT
5207 createmany -d $dir/d $nrdirs || {
5208 unlinkmany $dir/d $nrdirs
5209 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
5213 nrdirs=$(ls -U $dir | wc -l)
5215 # unlink all but 100 subdirectories, then check it still works
5217 local delete=$((nrdirs - left))
5222 # for ldiskfs the nlink count should be 1, but this is OSD specific
5223 # and so this is listed for informational purposes only
5224 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
5225 unlinkmany -d $dir/d $delete ||
5226 error "unlink of first $delete subdirs failed"
5228 echo "nlink between: $(stat -c %h $dir)"
5229 local found=$(ls -U $dir | wc -l)
5230 [ $found -ne $left ] &&
5231 error "can't find subdirs: found only $found, expected $left"
5233 unlinkmany -d $dir/d $delete $left ||
5234 error "unlink of second $left subdirs failed"
5235 # regardless of whether the backing filesystem tracks nlink accurately
5236 # or not, the nlink count shouldn't be more than "." and ".." here
5237 local after=$(stat -c %h $dir)
5238 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
5239 echo "nlink after: $after"
5241 cleanup_print_lfs_df
5243 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
5246 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5247 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
5249 test_mkdir $DIR/$tdir
5250 createmany -o $DIR/$tdir/t- 1000
5251 $LFS getstripe $DIR/$tdir > $TMP/$tfile
5252 for N in $(seq 0 $((OSTCOUNT - 1))); do
5253 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
5254 END { printf("%0.0f", objs) }' $TMP/$tfile)
5255 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
5256 '($1 == '$N') { objs += 1 } \
5257 END { printf("%0.0f", objs) }')
5258 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
5260 unlinkmany $DIR/$tdir/t- 1000
5263 for N in $(seq 1 $((OSTCOUNT - 1))); do
5264 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
5265 error "OST $N has less objects vs OST $NLAST" \
5266 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5267 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
5268 error "OST $N has less objects vs OST $NLAST" \
5269 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
5271 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
5272 error "OST $N has less #0 objects vs OST $NLAST" \
5273 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5274 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
5275 error "OST $N has less #0 objects vs OST $NLAST" \
5276 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
5281 run_test 51d "check object distribution"
5284 if [ "$mds1_FSTYPE" != ldiskfs ]; then
5285 skip_env "ldiskfs only test"
5288 test_mkdir -c1 $DIR/$tdir
5289 test_mkdir -c1 $DIR/$tdir/d0
5291 touch $DIR/$tdir/d0/foo
5292 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
5293 error "file exceed 65000 nlink limit!"
5294 unlinkmany $DIR/$tdir/d0/f- 65001
5297 run_test 51e "check file nlink limit"
5300 test_mkdir $DIR/$tdir
5303 local ulimit_old=$(ulimit -n)
5304 local spare=20 # number of spare fd's for scripts/libraries, etc.
5305 local mdt=$($LFS getstripe -m $DIR/$tdir)
5306 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
5308 echo "MDT$mdt numfree=$numfree, max=$max"
5309 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
5310 if [ $((numfree + spare)) -gt $ulimit_old ]; then
5311 while ! ulimit -n $((numfree + spare)); do
5312 numfree=$((numfree * 3 / 4))
5314 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
5316 echo "left ulimit at $ulimit_old"
5319 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
5320 unlinkmany $DIR/$tdir/f $numfree
5321 error "create+open $numfree files in $DIR/$tdir failed"
5323 ulimit -n $ulimit_old
5325 # if createmany exits at 120s there will be fewer than $numfree files
5326 unlinkmany $DIR/$tdir/f $numfree || true
5328 run_test 51f "check many open files limit"
5331 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
5332 test_mkdir $DIR/$tdir
5333 touch $DIR/$tdir/foo
5334 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
5335 echo bar >> $DIR/$tdir/foo || error "append bar failed"
5336 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5337 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5338 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5340 echo foo >> $DIR/$tdir/foo || error "append foo failed"
5341 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5342 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
5344 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
5345 cp -r $DIR/$tdir $TMP/
5346 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
5348 run_test 52a "append-only flag test (should return errors)"
5351 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
5352 test_mkdir $DIR/$tdir
5353 touch $DIR/$tdir/foo
5354 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
5355 cat test > $DIR/$tdir/foo && error "cat test worked"
5356 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
5357 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
5358 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
5360 echo foo >> $DIR/$tdir/foo && error "echo worked"
5361 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
5362 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
5363 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
5364 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
5366 chattr -i $DIR/$tdir/foo || error "chattr failed"
5368 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
5370 run_test 52b "immutable flag test (should return errors) ======="
5373 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5374 remote_mds_nodsh && skip "remote MDS with nodsh"
5375 remote_ost_nodsh && skip "remote OST with nodsh"
5388 local support_last_seq=true
5390 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
5391 support_last_seq=false
5394 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
5396 for value in $(do_facet $SINGLEMDS \
5397 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
5398 param=$(echo ${value[0]} | cut -d "=" -f1)
5399 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
5401 if $support_last_seq; then
5402 param_seq=$(echo $param |
5403 sed -e s/prealloc_last_id/prealloc_last_seq/g)
5404 mds_last_seq=$(do_facet $SINGLEMDS \
5405 $LCTL get_param -n $param_seq)
5407 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
5409 ostnum=$(index_from_ostuuid ${ostname}_UUID)
5410 node=$(facet_active_host ost$((ostnum+1)))
5411 param="obdfilter.$ostname.last_id"
5412 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
5413 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
5414 ost_last_id=$ost_last
5416 if $support_last_seq; then
5417 ost_last_id=$(echo $ost_last |
5418 awk -F':' '{print $2}' |
5420 ost_last_seq=$(echo $ost_last |
5421 awk -F':' '{print $1}')
5422 [[ $ost_last_seq = $mds_last_seq ]] || continue
5425 if [[ $ost_last_id != $mds_last ]]; then
5426 error "$ost_last_id != $mds_last"
5433 $found || error "can not match last_seq/last_id for $mdtosc"
5436 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
5439 perl -MSocket -e ';' || skip "no Socket perl module installed"
5441 $SOCKETSERVER $DIR/socket ||
5442 error "$SOCKETSERVER $DIR/socket failed: $?"
5443 $SOCKETCLIENT $DIR/socket ||
5444 error "$SOCKETCLIENT $DIR/socket failed: $?"
5445 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
5447 run_test 54a "unix domain socket test =========================="
5453 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
5455 run_test 54b "char device works in lustre ======================"
5458 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
5459 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
5460 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
5462 for i in $(seq 3 7); do
5463 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
5472 loopdev="$DIR/loop54c"
5475 $UMOUNT $DIR/$tdir || rc=$?
5476 losetup -d $loopdev || true
5477 losetup -d $LOOPDEV || true
5478 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
5483 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5485 loopdev="$DIR/loop54c"
5488 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
5489 trap cleanup_54c EXIT
5490 mknod $loopdev b 7 $LOOPNUM
5491 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
5492 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
5493 losetup $loopdev $DIR/$tfile ||
5494 error "can't set up $loopdev for $DIR/$tfile"
5495 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
5496 test_mkdir $DIR/$tdir
5497 mount -t ext2 $loopdev $DIR/$tdir ||
5498 error "error mounting $loopdev on $DIR/$tdir"
5499 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
5502 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
5506 run_test 54c "block device works in lustre ====================="
5512 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
5514 run_test 54d "fifo device works in lustre ======================"
5519 cp -aL /dev/console $f
5520 echo $string > $f || error "echo $string to $f failed"
5522 run_test 54e "console/tty device works in lustre ======================"
5526 local dir=$DIR/$tdir
5529 test_mkdir -p $dir/dir
5530 for i in $(seq $numfiles); do
5532 touch $dir/dir/file$i
5535 local numcomp=$($LFS getstripe --component-count $dir)
5537 [[ $numcomp == 0 ]] && numcomp=1
5539 # test lfs getstripe with --recursive
5540 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
5542 [[ $filenum -eq $((numfiles * 2)) ]] ||
5543 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
5544 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
5545 [[ $filenum -eq $numfiles ]] ||
5546 error "$LFS getstripe $dir: found $filenum, not $numfiles"
5547 echo "$LFS getstripe showed obdidx or l_ost_idx"
5549 # test lfs getstripe with file instead of dir
5550 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
5551 [[ $filenum -eq 1 ]] ||
5552 error "$LFS getstripe $dir/file1: found $filenum, not 1"
5553 echo "$LFS getstripe file1 passed"
5555 #test lfs getstripe with --verbose
5556 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
5557 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5558 error "$LFS getstripe --verbose $dir: "\
5559 "got $filenum want $((numfiles * numcomp)) lmm_magic"
5560 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
5561 error "$LFS getstripe $dir: showed lmm_magic"
5563 #test lfs getstripe with -v prints lmm_fid
5564 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
5565 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
5566 error "$LFS getstripe -v $dir: "\
5567 "got $filenum want $((numfiles * numcomp)) lmm_fid"
5568 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
5569 error "$LFS getstripe $dir: showed lmm_fid by default"
5570 echo "$LFS getstripe --verbose passed"
5572 #check for FID information
5573 local fid1=$($LFS getstripe --fid $dir/file1)
5574 local fid2=$($LFS getstripe --verbose $dir/file1 |
5575 awk '/lmm_fid: / { print $2; exit; }')
5576 local fid3=$($LFS path2fid $dir/file1)
5578 [ "$fid1" != "$fid2" ] &&
5579 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
5580 [ "$fid1" != "$fid3" ] &&
5581 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
5582 echo "$LFS getstripe --fid passed"
5584 #test lfs getstripe with --obd
5585 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
5586 error "$LFS getstripe --obd wrong_uuid: should return error"
5588 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5591 local obduuid=$(ostuuid_from_index $ostidx)
5592 local found=$($LFS getstripe -r --obd $obduuid $dir |
5593 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5595 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5596 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5598 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5601 [[ $found -eq $filenum ]] ||
5602 error "$LFS getstripe --obd: found $found expect $filenum"
5603 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5604 sed '/^[ ]*'${ostidx}'[ ]/d' |
5605 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5606 error "$LFS getstripe --obd: should not show file on other obd"
5607 echo "$LFS getstripe --obd passed"
5609 run_test 56a "check $LFS getstripe"
5612 local dir=$DIR/$tdir
5616 for i in $(seq $numdirs); do
5617 test_mkdir $dir/dir$i
5620 # test lfs getdirstripe default mode is non-recursion, which is
5621 # different from lfs getstripe
5622 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5624 [[ $dircnt -eq 1 ]] ||
5625 error "$LFS getdirstripe: found $dircnt, not 1"
5626 dircnt=$($LFS getdirstripe --recursive $dir |
5627 grep -c lmv_stripe_count)
5628 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5629 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5631 run_test 56b "check $LFS getdirstripe"
5634 remote_ost_nodsh && skip "remote OST with nodsh"
5637 local ost_name=$(ostname_from_index $ost_idx)
5638 local old_status=$(ost_dev_status $ost_idx)
5639 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
5641 [[ -z "$old_status" ]] ||
5642 skip_env "OST $ost_name is in $old_status status"
5644 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5645 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
5646 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5647 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
5648 save_lustre_params ost1 osd-*.$ost_name.nonrotational > $p
5649 do_facet ost1 $LCTL set_param -n osd-*.$ost_name.nonrotational=1
5652 [[ $($LFS df -v $MOUNT |& grep -c "inactive device") -eq 0 ]] ||
5653 error "$LFS df -v showing inactive devices"
5656 local new_status=$(ost_dev_status $ost_idx $MOUNT -v)
5658 [[ "$new_status" =~ "D" ]] ||
5659 error "$ost_name status is '$new_status', missing 'D'"
5660 if [[ $OST1_VERSION -ge $(version_code 2.12.55) ]]; then
5661 [[ "$new_status" =~ "N" ]] ||
5662 error "$ost_name status is '$new_status', missing 'N'"
5664 if [[ $OST1_VERSION -ge $(version_code 2.12.57) ]]; then
5665 [[ "$new_status" =~ "f" ]] ||
5666 error "$ost_name status is '$new_status', missing 'f'"
5669 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5670 [[ $OST1_VERSION -lt $(version_code 2.12.55) ]] || do_facet ost1 \
5671 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5672 [[ -z "$p" ]] && restore_lustre_params < $p || true
5675 new_status=$(ost_dev_status $ost_idx)
5676 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5677 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5678 # can't check 'f' as devices may actually be on flash
5680 run_test 56c "check 'lfs df' showing device status"
5683 local mdts=$($LFS df -v $MOUNT | grep -c MDT)
5684 local osts=$($LFS df -v $MOUNT | grep -c OST)
5688 (( mdts == MDSCOUNT )) ||
5689 error "lfs df -v showed $mdts MDTs, not $MDSCOUNT"
5690 (( osts == OSTCOUNT )) ||
5691 error "lfs df -v showed $osts OSTs, not $OSTCOUNT"
5693 run_test 56d "'lfs df -v' prints only configured devices"
5698 local local_tdir="$1"
5699 local local_numfiles="$2"
5700 local local_numdirs="$3"
5701 local dir_params="$4"
5702 local dir_stripe_params="$5"
5704 if [ ! -d "$local_tdir" ] ; then
5705 test_mkdir -p $dir_stripe_params $local_tdir
5706 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5707 for i in $(seq $local_numfiles) ; do
5708 touch $local_tdir/file$i
5710 for i in $(seq $local_numdirs) ; do
5711 test_mkdir $dir_stripe_params $local_tdir/dir$i
5712 for j in $(seq $local_numfiles) ; do
5713 touch $local_tdir/dir$i/file$j
5719 setup_56_special() {
5721 local local_numfiles=$2
5722 local local_numdirs=$3
5724 setup_56 $local_tdir $local_numfiles $local_numdirs
5726 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5727 for i in $(seq $local_numfiles) ; do
5728 mknod $local_tdir/loop${i}b b 7 $i
5729 mknod $local_tdir/null${i}c c 1 3
5730 ln -s $local_tdir/file1 $local_tdir/link${i}
5732 for i in $(seq $local_numdirs) ; do
5733 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5734 mknod $local_tdir/dir$i/null${i}c c 1 3
5735 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5741 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5742 local expected=$(($NUMDIRS + 2))
5744 setup_56 $dir $NUMFILES $NUMDIRS
5746 # test lfs find with -name
5747 for i in $(seq $NUMFILES) ; do
5748 local nums=$($LFS find -name "*$i" $dir | wc -l)
5750 [ $nums -eq $expected ] ||
5751 error "lfs find -name '*$i' $dir wrong: "\
5752 "found $nums, expected $expected"
5755 run_test 56g "check lfs find -name"
5758 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5759 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5761 setup_56 $dir $NUMFILES $NUMDIRS
5763 # test lfs find with ! -name
5764 for i in $(seq $NUMFILES) ; do
5765 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5767 [ $nums -eq $expected ] ||
5768 error "lfs find ! -name '*$i' $dir wrong: "\
5769 "found $nums, expected $expected"
5772 run_test 56h "check lfs find ! -name"
5775 local dir=$DIR/$tdir
5779 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5782 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5784 run_test 56i "check 'lfs find -ost UUID' skips directories"
5787 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5789 setup_56_special $dir $NUMFILES $NUMDIRS
5791 local expected=$((NUMDIRS + 1))
5792 local cmd="$LFS find -type d $dir"
5793 local nums=$($cmd | wc -l)
5795 [ $nums -eq $expected ] ||
5796 error "'$cmd' wrong: found $nums, expected $expected"
5798 run_test 56j "check lfs find -type d"
5801 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5803 setup_56_special $dir $NUMFILES $NUMDIRS
5805 local expected=$(((NUMDIRS + 1) * NUMFILES))
5806 local cmd="$LFS find -type f $dir"
5807 local nums=$($cmd | wc -l)
5809 [ $nums -eq $expected ] ||
5810 error "'$cmd' wrong: found $nums, expected $expected"
5812 run_test 56k "check lfs find -type f"
5815 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5817 setup_56_special $dir $NUMFILES $NUMDIRS
5819 local expected=$((NUMDIRS + NUMFILES))
5820 local cmd="$LFS find -type b $dir"
5821 local nums=$($cmd | wc -l)
5823 [ $nums -eq $expected ] ||
5824 error "'$cmd' wrong: found $nums, expected $expected"
5826 run_test 56l "check lfs find -type b"
5829 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5831 setup_56_special $dir $NUMFILES $NUMDIRS
5833 local expected=$((NUMDIRS + NUMFILES))
5834 local cmd="$LFS find -type c $dir"
5835 local nums=$($cmd | wc -l)
5836 [ $nums -eq $expected ] ||
5837 error "'$cmd' wrong: found $nums, expected $expected"
5839 run_test 56m "check lfs find -type c"
5842 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5843 setup_56_special $dir $NUMFILES $NUMDIRS
5845 local expected=$((NUMDIRS + NUMFILES))
5846 local cmd="$LFS find -type l $dir"
5847 local nums=$($cmd | wc -l)
5849 [ $nums -eq $expected ] ||
5850 error "'$cmd' wrong: found $nums, expected $expected"
5852 run_test 56n "check lfs find -type l"
5855 local dir=$DIR/$tdir
5857 setup_56 $dir $NUMFILES $NUMDIRS
5858 utime $dir/file1 > /dev/null || error "utime (1)"
5859 utime $dir/file2 > /dev/null || error "utime (2)"
5860 utime $dir/dir1 > /dev/null || error "utime (3)"
5861 utime $dir/dir2 > /dev/null || error "utime (4)"
5862 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5863 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5866 local nums=$($LFS find -mtime +0 $dir | wc -l)
5868 [ $nums -eq $expected ] ||
5869 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5872 cmd="$LFS find -mtime 0 $dir"
5873 nums=$($cmd | wc -l)
5874 [ $nums -eq $expected ] ||
5875 error "'$cmd' wrong: found $nums, expected $expected"
5877 run_test 56o "check lfs find -mtime for old files"
5880 local dir=$DIR/$tdir
5884 # just to make sure there is something that won't be found
5886 touch $dir/$tfile.now
5888 for age in year week day hour min; do
5889 count=$((count + 1))
5891 touch $dir/$tfile-a.$age $dir/$tfile-m.$age
5892 touch --date="$count $age ago" -a $dir/$tfile-a.$age
5893 touch --date="$count $age ago" -m $dir/$tfile-m.$age
5895 local cmd="$LFS find $dir -mtime $count${age:0:1}"
5896 local nums=$($cmd | wc -l)
5897 [ $nums -eq $expected ] ||
5898 error "'$cmd' wrong: found $nums, expected $expected"
5900 cmd="$LFS find $dir -atime $count${age:0:1}"
5901 nums=$($cmd | wc -l)
5902 [ $nums -eq $expected ] ||
5903 error "'$cmd' wrong: found $nums, expected $expected"
5907 cmd="$LFS find $dir -ctime +1s -type f"
5908 nums=$($cmd | wc -l)
5909 (( $nums == $count * 2 + 1)) ||
5910 error "'$cmd' wrong: found $nums, expected $((expected*2+1))"
5912 run_test 56ob "check lfs find -atime -mtime -ctime with units"
5914 test_newerXY_base() {
5917 local dir=$DIR/$tdir
5921 if [ $y == "t" ]; then
5922 if [ $x == "b" ]; then
5923 ref="\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\""
5925 ref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5928 ref=$DIR/$tfile.newer.$x$y
5929 touch $ref || error "touch $ref failed"
5932 setup_56 $dir $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
5934 if [ $y == "t" ]; then
5935 if [ $x == "b" ]; then
5936 negref="\"$(do_facet mds1 date +"%Y-%m-%d\ %H:%M:%S")\""
5938 negref="\"$(date +"%Y-%m-%d %H:%M:%S")\""
5941 negref=$DIR/$tfile.negnewer.$x$y
5942 touch $negref || error "touch $negref failed"
5945 local cmd="$LFS find $dir -newer$x$y $ref"
5946 local nums=$(eval $cmd | wc -l)
5947 local expected=$(((NUMFILES + 2) * NUMDIRS + 1))
5949 [ $nums -eq $expected ] ||
5950 error "'$cmd' wrong: found $nums, expected $expected"
5952 cmd="$LFS find $dir ! -newer$x$y $negref"
5953 nums=$(eval $cmd | wc -l)
5954 [ $nums -eq $expected ] ||
5955 error "'$cmd' wrong: found $nums, expected $expected"
5957 cmd="$LFS find $dir -newer$x$y $ref ! -newer$x$y $negref"
5958 nums=$(eval $cmd | wc -l)
5959 [ $nums -eq $expected ] ||
5960 error "'$cmd' wrong: found $nums, expected $expected"
5966 test_newerXY_base "b" "t"
5967 test_newerXY_base "a" "a"
5968 test_newerXY_base "a" "m"
5969 test_newerXY_base "a" "c"
5970 test_newerXY_base "m" "a"
5971 test_newerXY_base "m" "m"
5972 test_newerXY_base "m" "c"
5973 test_newerXY_base "c" "a"
5974 test_newerXY_base "c" "m"
5975 test_newerXY_base "c" "c"
5976 test_newerXY_base "b" "b"
5977 test_newerXY_base "a" "t"
5978 test_newerXY_base "m" "t"
5979 test_newerXY_base "c" "t"
5980 test_newerXY_base "b" "t"
5982 run_test 56oc "check lfs find -newerXY work"
5985 local dir=$DIR/$tdir
5990 $LFS find $dir -btime -1d -type f
5997 [ $MDS1_VERSION -lt $(version_code 2.13.53) ] &&
5998 ! btime_supported && skip "btime unsupported on MDS"
6000 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
6001 ! btime_supported && skip "btime unsupported on clients"
6003 local dir=$DIR/$tdir
6004 local ref=$DIR/$tfile.ref
6005 local negref=$DIR/$tfile.negref
6007 mkdir $dir || error "mkdir $dir failed"
6008 touch $dir/$tfile.n1 || error "touch $dir/$tfile.n1 failed"
6009 touch $dir/$tfile.n2 || error "touch $dir/$tfile.n2 failed"
6010 mkdir $dir/$tdir.n1 || error "mkdir $dir/$tdir.n1 failed"
6011 mkdir $dir/$tdir.n2 || error "mkdir $dir/$tdir.n2 failed"
6012 touch $ref || error "touch $ref failed"
6013 # sleep 3 seconds at least
6016 local before=$(do_facet mds1 date +%s)
6017 local skew=$(($(date +%s) - before + 1))
6019 if (( skew < 0 && skew > -5 )); then
6020 sleep $((0 - skew + 1))
6024 # Set the dir stripe params to limit files all on MDT0,
6025 # otherwise we need to calc the max clock skew between
6026 # the client and MDTs.
6027 setup_56 $dir/d.btime $NUMFILES $NUMDIRS "-i0 -c1" "-i0 -c1"
6029 touch $negref || error "touch $negref failed"
6031 local cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type f"
6032 local nums=$($cmd | wc -l)
6033 local expected=$(((NUMFILES + 1) * NUMDIRS))
6035 [ $nums -eq $expected ] ||
6036 error "'$cmd' wrong: found $nums, expected $expected"
6038 cmd="$LFS find $dir -newerbb $ref ! -newerbb $negref -type d"
6039 nums=$($cmd | wc -l)
6040 expected=$((NUMFILES + 1))
6041 [ $nums -eq $expected ] ||
6042 error "'$cmd' wrong: found $nums, expected $expected"
6044 [ $skew -lt 0 ] && return
6046 local after=$(do_facet mds1 date +%s)
6047 local age=$((after - before + 1 + skew))
6049 cmd="$LFS find $dir -btime -${age}s -type f"
6050 nums=$($cmd | wc -l)
6051 expected=$(((NUMFILES + 1) * NUMDIRS))
6053 echo "Clock skew between client and server: $skew, age:$age"
6054 [ $nums -eq $expected ] ||
6055 error "'$cmd' wrong: found $nums, expected $expected"
6057 expected=$(($NUMDIRS + 1))
6058 cmd="$LFS find $dir -btime -${age}s -type d"
6059 nums=$($cmd | wc -l)
6060 [ $nums -eq $expected ] ||
6061 error "'$cmd' wrong: found $nums, expected $expected"
6062 rm -f $ref $negref || error "Failed to remove $ref $negref"
6064 run_test 56od "check lfs find -btime with units"
6067 [ $RUNAS_ID -eq $UID ] &&
6068 skip_env "RUNAS_ID = UID = $UID -- skipping"
6070 local dir=$DIR/$tdir
6072 setup_56 $dir $NUMFILES $NUMDIRS
6073 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
6075 local expected=$NUMFILES
6076 local cmd="$LFS find -uid $RUNAS_ID $dir"
6077 local nums=$($cmd | wc -l)
6079 [ $nums -eq $expected ] ||
6080 error "'$cmd' wrong: found $nums, expected $expected"
6082 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
6083 cmd="$LFS find ! -uid $RUNAS_ID $dir"
6084 nums=$($cmd | wc -l)
6085 [ $nums -eq $expected ] ||
6086 error "'$cmd' wrong: found $nums, expected $expected"
6088 run_test 56p "check lfs find -uid and ! -uid"
6091 [ $RUNAS_ID -eq $UID ] &&
6092 skip_env "RUNAS_ID = UID = $UID -- skipping"
6094 local dir=$DIR/$tdir
6096 setup_56 $dir $NUMFILES $NUMDIRS
6097 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
6099 local expected=$NUMFILES
6100 local cmd="$LFS find -gid $RUNAS_GID $dir"
6101 local nums=$($cmd | wc -l)
6103 [ $nums -eq $expected ] ||
6104 error "'$cmd' wrong: found $nums, expected $expected"
6106 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
6107 cmd="$LFS find ! -gid $RUNAS_GID $dir"
6108 nums=$($cmd | wc -l)
6109 [ $nums -eq $expected ] ||
6110 error "'$cmd' wrong: found $nums, expected $expected"
6112 run_test 56q "check lfs find -gid and ! -gid"
6115 local dir=$DIR/$tdir
6117 setup_56 $dir $NUMFILES $NUMDIRS
6120 local cmd="$LFS find -size 0 -type f -lazy $dir"
6121 local nums=$($cmd | wc -l)
6123 [ $nums -eq $expected ] ||
6124 error "'$cmd' wrong: found $nums, expected $expected"
6125 cmd="$LFS find -size 0 -type f $dir"
6126 nums=$($cmd | wc -l)
6127 [ $nums -eq $expected ] ||
6128 error "'$cmd' wrong: found $nums, expected $expected"
6131 cmd="$LFS find ! -size 0 -type f -lazy $dir"
6132 nums=$($cmd | wc -l)
6133 [ $nums -eq $expected ] ||
6134 error "'$cmd' wrong: found $nums, expected $expected"
6135 cmd="$LFS find ! -size 0 -type f $dir"
6136 nums=$($cmd | wc -l)
6137 [ $nums -eq $expected ] ||
6138 error "'$cmd' wrong: found $nums, expected $expected"
6140 echo "test" > $dir/$tfile
6141 echo "test2" > $dir/$tfile.2 && sync
6143 cmd="$LFS find -size 5 -type f -lazy $dir"
6144 nums=$($cmd | wc -l)
6145 [ $nums -eq $expected ] ||
6146 error "'$cmd' wrong: found $nums, expected $expected"
6147 cmd="$LFS find -size 5 -type f $dir"
6148 nums=$($cmd | wc -l)
6149 [ $nums -eq $expected ] ||
6150 error "'$cmd' wrong: found $nums, expected $expected"
6153 cmd="$LFS find -size +5 -type f -lazy $dir"
6154 nums=$($cmd | wc -l)
6155 [ $nums -eq $expected ] ||
6156 error "'$cmd' wrong: found $nums, expected $expected"
6157 cmd="$LFS find -size +5 -type f $dir"
6158 nums=$($cmd | wc -l)
6159 [ $nums -eq $expected ] ||
6160 error "'$cmd' wrong: found $nums, expected $expected"
6163 cmd="$LFS find -size +0 -type f -lazy $dir"
6164 nums=$($cmd | wc -l)
6165 [ $nums -eq $expected ] ||
6166 error "'$cmd' wrong: found $nums, expected $expected"
6167 cmd="$LFS find -size +0 -type f $dir"
6168 nums=$($cmd | wc -l)
6169 [ $nums -eq $expected ] ||
6170 error "'$cmd' wrong: found $nums, expected $expected"
6173 cmd="$LFS find ! -size -5 -type f -lazy $dir"
6174 nums=$($cmd | wc -l)
6175 [ $nums -eq $expected ] ||
6176 error "'$cmd' wrong: found $nums, expected $expected"
6177 cmd="$LFS find ! -size -5 -type f $dir"
6178 nums=$($cmd | wc -l)
6179 [ $nums -eq $expected ] ||
6180 error "'$cmd' wrong: found $nums, expected $expected"
6183 cmd="$LFS find -size -5 -type f -lazy $dir"
6184 nums=$($cmd | wc -l)
6185 [ $nums -eq $expected ] ||
6186 error "'$cmd' wrong: found $nums, expected $expected"
6187 cmd="$LFS find -size -5 -type f $dir"
6188 nums=$($cmd | wc -l)
6189 [ $nums -eq $expected ] ||
6190 error "'$cmd' wrong: found $nums, expected $expected"
6192 run_test 56r "check lfs find -size works"
6199 cancel_lru_locks $OSC
6201 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6202 local nums=$($cmd | wc -l)
6204 [ $nums -eq $expected ] ||
6205 error "'$cmd' wrong: found $nums, expected $expected"
6207 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
6209 if (( rpcs_before + glimpses != rpcs_after )); then
6210 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
6211 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
6213 if [[ $glimpses == 0 ]]; then
6214 error "'$cmd' should not send glimpse RPCs to OST"
6216 error "'$cmd' should send $glimpses glimpse RPCs to OST"
6222 [[ $MDS1_VERSION -gt $(version_code 2.12.58) ]] ||
6223 skip "MDS < 2.12.58 doesn't return LSOM data"
6224 local dir=$DIR/$tdir
6226 [[ $OSC == "mdc" ]] && skip "DoM files" && return
6228 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6229 # open and close all files to ensure LSOM is updated
6230 cancel_lru_locks $OSC
6231 find $dir -type f | xargs cat > /dev/null
6233 # expect_found glimpse_rpcs command_to_run
6234 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
6235 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
6236 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
6237 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
6239 echo "test" > $dir/$tfile
6240 echo "test2" > $dir/$tfile.2 && sync
6241 cancel_lru_locks $OSC
6242 cat $dir/$tfile $dir/$tfile.2 > /dev/null
6244 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
6245 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
6246 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
6247 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
6249 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
6250 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
6251 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
6252 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
6253 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
6254 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
6256 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
6259 local dir=$DIR/$tdir
6260 local tmp=$TMP/$tfile.log
6263 test_mkdir -p $dir || error "failed to mkdir $dir"
6264 $LFS setstripe -c 1 -i 0 $dir/$tfile ||
6265 error "failed to setstripe $dir/$tfile"
6266 dd if=/dev/zero of=$dir/$tfile bs=1M count=1
6268 stack_trap "rm -f $tmp" EXIT
6269 $LFS find --size +100K --ost 0 $dir 2>&1 | tee $tmp
6270 [ -z "$(cat $tmp | grep "obd_uuid: ")" ] ||
6271 error "failed to find --size +100K --ost 0 $dir"
6272 $LFS find --size +100K --mdt $mdt_idx $dir 2>&1 | tee $tmp
6273 [ -z "$(cat $tmp | grep "obd_uuid: ")" ] ||
6274 error "failed to find --size +100K --mdt $mdt_idx $dir"
6276 run_test 56rb "check lfs find --size --ost/--mdt works"
6278 test_56s() { # LU-611 #LU-9369
6279 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
6281 local dir=$DIR/$tdir
6282 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
6284 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
6285 for i in $(seq $NUMDIRS); do
6286 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
6289 local expected=$NUMDIRS
6290 local cmd="$LFS find -c $OSTCOUNT $dir"
6291 local nums=$($cmd | wc -l)
6293 [ $nums -eq $expected ] || {
6294 $LFS getstripe -R $dir
6295 error "'$cmd' wrong: found $nums, expected $expected"
6298 expected=$((NUMDIRS + onestripe))
6299 cmd="$LFS find -stripe-count +0 -type f $dir"
6300 nums=$($cmd | wc -l)
6301 [ $nums -eq $expected ] || {
6302 $LFS getstripe -R $dir
6303 error "'$cmd' wrong: found $nums, expected $expected"
6307 cmd="$LFS find -stripe-count 1 -type f $dir"
6308 nums=$($cmd | wc -l)
6309 [ $nums -eq $expected ] || {
6310 $LFS getstripe -R $dir
6311 error "'$cmd' wrong: found $nums, expected $expected"
6314 cmd="$LFS find -stripe-count -2 -type f $dir"
6315 nums=$($cmd | wc -l)
6316 [ $nums -eq $expected ] || {
6317 $LFS getstripe -R $dir
6318 error "'$cmd' wrong: found $nums, expected $expected"
6322 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
6323 nums=$($cmd | wc -l)
6324 [ $nums -eq $expected ] || {
6325 $LFS getstripe -R $dir
6326 error "'$cmd' wrong: found $nums, expected $expected"
6329 run_test 56s "check lfs find -stripe-count works"
6331 test_56t() { # LU-611 #LU-9369
6332 local dir=$DIR/$tdir
6334 setup_56 $dir 0 $NUMDIRS
6335 for i in $(seq $NUMDIRS); do
6336 $LFS setstripe -S 8M $dir/dir$i/$tfile
6339 local expected=$NUMDIRS
6340 local cmd="$LFS find -S 8M $dir"
6341 local nums=$($cmd | wc -l)
6343 [ $nums -eq $expected ] || {
6344 $LFS getstripe -R $dir
6345 error "'$cmd' wrong: found $nums, expected $expected"
6349 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
6351 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
6353 expected=$(((NUMDIRS + 1) * NUMFILES))
6354 cmd="$LFS find -stripe-size 512k -type f $dir"
6355 nums=$($cmd | wc -l)
6356 [ $nums -eq $expected ] ||
6357 error "'$cmd' wrong: found $nums, expected $expected"
6359 cmd="$LFS find -stripe-size +320k -type f $dir"
6360 nums=$($cmd | wc -l)
6361 [ $nums -eq $expected ] ||
6362 error "'$cmd' wrong: found $nums, expected $expected"
6364 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
6365 cmd="$LFS find -stripe-size +200k -type f $dir"
6366 nums=$($cmd | wc -l)
6367 [ $nums -eq $expected ] ||
6368 error "'$cmd' wrong: found $nums, expected $expected"
6370 cmd="$LFS find -stripe-size -640k -type f $dir"
6371 nums=$($cmd | wc -l)
6372 [ $nums -eq $expected ] ||
6373 error "'$cmd' wrong: found $nums, expected $expected"
6376 cmd="$LFS find -stripe-size 256k -type f $dir"
6377 nums=$($cmd | wc -l)
6378 [ $nums -eq $expected ] ||
6379 error "'$cmd' wrong: found $nums, expected $expected"
6381 cmd="$LFS find -stripe-size -320k -type f $dir"
6382 nums=$($cmd | wc -l)
6383 [ $nums -eq $expected ] ||
6384 error "'$cmd' wrong: found $nums, expected $expected"
6387 cmd="$LFS find -stripe-size 1024k -type f $dir"
6388 nums=$($cmd | wc -l)
6389 [ $nums -eq $expected ] ||
6390 error "'$cmd' wrong: found $nums, expected $expected"
6392 run_test 56t "check lfs find -stripe-size works"
6394 test_56u() { # LU-611
6395 local dir=$DIR/$tdir
6397 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
6399 if [[ $OSTCOUNT -gt 1 ]]; then
6400 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
6406 local expected=$(((NUMDIRS + 1) * NUMFILES))
6407 local cmd="$LFS find -stripe-index 0 -type f $dir"
6408 local nums=$($cmd | wc -l)
6410 [ $nums -eq $expected ] ||
6411 error "'$cmd' wrong: found $nums, expected $expected"
6414 cmd="$LFS find -stripe-index 1 -type f $dir"
6415 nums=$($cmd | wc -l)
6416 [ $nums -eq $expected ] ||
6417 error "'$cmd' wrong: found $nums, expected $expected"
6419 cmd="$LFS find ! -stripe-index 0 -type f $dir"
6420 nums=$($cmd | wc -l)
6421 [ $nums -eq $expected ] ||
6422 error "'$cmd' wrong: found $nums, expected $expected"
6425 # This should produce an error and not return any files
6426 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
6427 nums=$($cmd 2>/dev/null | wc -l)
6428 [ $nums -eq $expected ] ||
6429 error "'$cmd' wrong: found $nums, expected $expected"
6431 if [[ $OSTCOUNT -gt 1 ]]; then
6432 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
6433 cmd="$LFS find -stripe-index 0,1 -type f $dir"
6434 nums=$($cmd | wc -l)
6435 [ $nums -eq $expected ] ||
6436 error "'$cmd' wrong: found $nums, expected $expected"
6439 run_test 56u "check lfs find -stripe-index works"
6443 local dir=$DIR/$tdir
6445 setup_56 $dir $NUMFILES $NUMDIRS
6447 UUID=$(mdtuuid_from_index $mdt_idx $dir)
6448 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
6450 for file in $($LFS find -m $UUID $dir); do
6451 file_midx=$($LFS getstripe -m $file)
6452 [ $file_midx -eq $mdt_idx ] ||
6453 error "lfs find -m $UUID != getstripe -m $file_midx"
6456 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
6459 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6460 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6462 local dir=$DIR/$tdir
6464 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
6466 local stripe_size=$($LFS getstripe -S -d $dir) ||
6467 error "$LFS getstripe -S -d $dir failed"
6468 stripe_size=${stripe_size%% *}
6470 local file_size=$((stripe_size * OSTCOUNT))
6471 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
6472 local required_space=$((file_num * file_size))
6473 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
6475 [[ $free_space -le $((required_space / 1024)) ]] &&
6476 skip_env "need $required_space, have $free_space kbytes"
6479 local dd_count=$((file_size / dd_bs))
6481 # write data into the files
6486 for i in $(seq $NUMFILES); do
6488 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6489 error "write data into $file failed"
6491 for i in $(seq $NUMDIRS); do
6492 for j in $(seq $NUMFILES); do
6493 file=$dir/dir$i/file$j
6494 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
6495 error "write data into $file failed"
6499 # $LFS_MIGRATE will fail if hard link migration is unsupported
6500 if [[ $MDS1_VERSION -gt $(version_code 2.5.55) ]]; then
6501 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
6502 error "creating links to $dir/dir1/file1 failed"
6507 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
6510 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
6513 eval $cmd || error "$cmd failed"
6515 check_stripe_count $dir/file1 $expected
6517 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
6519 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
6520 # OST 1 if it is on OST 0. This file is small enough to
6521 # be on only one stripe.
6522 file=$dir/migr_1_ost
6523 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
6524 error "write data into $file failed"
6525 local obdidx=$($LFS getstripe -i $file)
6526 local oldmd5=$(md5sum $file)
6529 [[ $obdidx -eq 0 ]] && newobdidx=1
6530 cmd="$LFS migrate -i $newobdidx $file"
6532 eval $cmd || error "$cmd failed"
6534 local realobdix=$($LFS getstripe -i $file)
6535 local newmd5=$(md5sum $file)
6537 [[ $newobdidx -ne $realobdix ]] &&
6538 error "new OST is different (was=$obdidx, "\
6539 "wanted=$newobdidx, got=$realobdix)"
6540 [[ "$oldmd5" != "$newmd5" ]] &&
6541 error "md5sum differ: $oldmd5, $newmd5"
6545 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
6547 eval $cmd || error "$cmd failed"
6549 for j in $(seq $NUMFILES); do
6550 check_stripe_count $dir/dir1/file$j $expected
6553 # lfs_migrate works with lfs find
6554 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
6555 $LFS_MIGRATE -y -c $expected"
6557 eval $cmd || error "$cmd failed"
6559 for i in $(seq 2 $NUMFILES); do
6560 check_stripe_count $dir/file$i $expected
6562 for i in $(seq 2 $NUMDIRS); do
6563 for j in $(seq $NUMFILES); do
6564 check_stripe_count $dir/dir$i/file$j $expected
6568 run_test 56w "check lfs_migrate -c stripe_count works"
6571 local file1=$DIR/$tdir/file1
6572 local create_pool=false
6573 local initial_pool=$($LFS getstripe -p $DIR)
6577 echo -n "Creating test dir..."
6578 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6581 echo -n "Creating test file..."
6582 touch $file1 || error "cannot create file"
6585 echo -n "Detecting existing pools..."
6586 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
6588 if [ ${#pool_list[@]} -gt 0 ]; then
6589 echo "${pool_list[@]}"
6590 for thispool in "${pool_list[@]}"; do
6591 if [[ -z "$initial_pool" ||
6592 "$initial_pool" != "$thispool" ]]; then
6594 echo "Using existing pool '$pool'"
6599 echo "none detected."
6601 if [ -z "$pool" ]; then
6602 pool=${POOL:-testpool}
6603 [ "$initial_pool" = "$pool" ] && pool="testpool2"
6604 echo -n "Creating pool '$pool'..."
6606 pool_add $pool &> /dev/null ||
6607 error "pool_add failed"
6610 echo -n "Adding target to pool..."
6611 pool_add_targets $pool 0 0 1 &> /dev/null ||
6612 error "pool_add_targets failed"
6616 echo -n "Setting pool using -p option..."
6617 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
6618 error "migrate failed rc = $?"
6621 echo -n "Verifying test file is in pool after migrating..."
6622 [ "$($LFS getstripe -p $file1)" = $pool ] ||
6623 error "file was not migrated to pool $pool"
6626 echo -n "Removing test file from pool '$pool'..."
6627 # "lfs migrate $file" won't remove the file from the pool
6628 # until some striping information is changed.
6629 $LFS migrate -c 1 $file1 &> /dev/null ||
6630 error "cannot remove from pool"
6631 [ "$($LFS getstripe -p $file1)" ] &&
6632 error "pool still set"
6635 echo -n "Setting pool using --pool option..."
6636 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
6637 error "migrate failed rc = $?"
6642 if $create_pool; then
6643 destroy_test_pools 2> /dev/null ||
6644 error "destroy test pools failed"
6647 run_test 56wb "check lfs_migrate pool support"
6650 local file1="$DIR/$tdir/file1"
6657 echo -n "Creating test dir..."
6658 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
6659 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
6660 error "cannot set stripe by '-S 1M -c 1'"
6663 echo -n "Setting initial stripe for test file..."
6664 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
6665 error "cannot set stripe"
6666 cur_ssize=$($LFS getstripe -S "$file1")
6667 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
6670 # File currently set to -S 512K -c 1
6672 # Ensure -c and -S options are rejected when -R is set
6673 echo -n "Verifying incompatible options are detected..."
6674 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
6675 error "incompatible -c and -R options not detected"
6676 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
6677 error "incompatible -S and -R options not detected"
6680 # Ensure unrecognized options are passed through to 'lfs migrate'
6681 echo -n "Verifying -S option is passed through to lfs migrate..."
6682 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
6683 error "migration failed"
6684 cur_ssize=$($LFS getstripe -S "$file1")
6685 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
6688 # File currently set to -S 1M -c 1
6690 # Ensure long options are supported
6691 echo -n "Verifying long options supported..."
6692 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
6693 error "long option without argument not supported"
6694 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
6695 error "long option with argument not supported"
6696 cur_ssize=$($LFS getstripe -S "$file1")
6697 [ $cur_ssize -eq 524288 ] ||
6698 error "migrate --stripe-size $cur_ssize != 524288"
6701 # File currently set to -S 512K -c 1
6703 if [ "$OSTCOUNT" -gt 1 ]; then
6704 echo -n "Verifying explicit stripe count can be set..."
6705 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
6706 error "migrate failed"
6707 cur_scount=$($LFS getstripe -c "$file1")
6708 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
6712 # File currently set to -S 512K -c 1 or -S 512K -c 2
6714 # Ensure parent striping is used if -R is set, and no stripe
6715 # count or size is specified
6716 echo -n "Setting stripe for parent directory..."
6717 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6718 error "cannot set stripe '-S 2M -c 1'"
6721 echo -n "Verifying restripe option uses parent stripe settings..."
6722 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
6723 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
6724 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
6725 error "migrate failed"
6726 cur_ssize=$($LFS getstripe -S "$file1")
6727 [ $cur_ssize -eq $parent_ssize ] ||
6728 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
6729 cur_scount=$($LFS getstripe -c "$file1")
6730 [ $cur_scount -eq $parent_scount ] ||
6731 error "migrate -R stripe_count $cur_scount != $parent_scount"
6734 # File currently set to -S 1M -c 1
6736 # Ensure striping is preserved if -R is not set, and no stripe
6737 # count or size is specified
6738 echo -n "Verifying striping size preserved when not specified..."
6739 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
6740 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
6741 error "cannot set stripe on parent directory"
6742 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6743 error "migrate failed"
6744 cur_ssize=$($LFS getstripe -S "$file1")
6745 [ $cur_ssize -eq $orig_ssize ] ||
6746 error "migrate by default $cur_ssize != $orig_ssize"
6749 # Ensure file name properly detected when final option has no argument
6750 echo -n "Verifying file name properly detected..."
6751 $LFS_MIGRATE -y "$file1" &> /dev/null ||
6752 error "file name interpreted as option argument"
6758 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
6761 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6763 local file1=$DIR/$tdir/file1
6765 echo -n "Creating test dir..."
6766 test_mkdir $DIR/$tdir || error "cannot create dir"
6769 echo -n "Creating test file..."
6773 # Ensure 'lfs migrate' will fail by using a non-existent option,
6774 # and make sure rsync is not called to recover
6775 echo -n "Make sure --no-rsync option works..."
6776 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
6777 grep -q 'refusing to fall back to rsync' ||
6778 error "rsync was called with --no-rsync set"
6781 # Ensure rsync is called without trying 'lfs migrate' first
6782 echo -n "Make sure --rsync option works..."
6783 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
6784 grep -q 'falling back to rsync' &&
6785 error "lfs migrate was called with --rsync set"
6788 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
6789 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
6790 grep -q 'at the same time' ||
6791 error "--rsync and --no-rsync accepted concurrently"
6797 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
6800 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6801 check_swap_layouts_support
6803 local dir=$DIR/$tdir
6804 local ref1=/etc/passwd
6805 local file1=$dir/file1
6807 test_mkdir $dir || error "creating dir $dir"
6808 $LFS setstripe -c 2 $file1
6810 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
6811 stripe=$($LFS getstripe -c $file1)
6812 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6813 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6818 run_test 56x "lfs migration support"
6821 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6822 check_swap_layouts_support
6824 local dir=$DIR/$tdir/$testnum
6828 local ref1=/etc/passwd
6829 local file1=$dir/file1
6831 $LFS setstripe -c 2 $file1
6833 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6835 local stripe=$($LFS getstripe -c $file1)
6837 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6838 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6843 run_test 56xa "lfs migration --block support"
6845 check_migrate_links() {
6847 local file1="$dir/file1"
6851 local total_count=$(($begin + $count - 1))
6852 local symlink_count=10
6855 if [ ! -f "$file1" ]; then
6856 echo -n "creating initial file..."
6857 $LFS setstripe -c 1 -S "512k" "$file1" ||
6858 error "cannot setstripe initial file"
6861 echo -n "creating symlinks..."
6862 for s in $(seq 1 $symlink_count); do
6863 ln -s "$file1" "$dir/slink$s" ||
6864 error "cannot create symlinks"
6868 echo -n "creating nonlinked files..."
6869 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6870 error "cannot create nonlinked files"
6875 if [ ! -f "$dir/file$total_count" ]; then
6876 echo -n "creating hard links $begin:$total_count..."
6877 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6878 /dev/null || error "cannot create hard links"
6882 echo -n "checking number of hard links listed in xattrs..."
6883 local fid=$($LFS getstripe -F "$file1")
6884 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6887 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6888 skip "hard link list has unexpected size, skipping test"
6890 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6891 error "link names should exceed xattrs size"
6894 echo -n "migrating files..."
6895 local migrate_out=$($runas $LFS_MIGRATE -y -S '1m' $dir)
6897 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6900 # make sure all links have been properly migrated
6901 echo -n "verifying files..."
6902 fid=$($LFS getstripe -F "$file1") ||
6903 error "cannot get fid for file $file1"
6904 for i in $(seq 2 $total_count); do
6905 local fid2=$($LFS getstripe -F $dir/file$i)
6907 [ "$fid2" == "$fid" ] ||
6908 error "migrated hard link has mismatched FID"
6911 # make sure hard links were properly detected, and migration was
6912 # performed only once for the entire link set; nonlinked files should
6914 local actual=$(grep -c 'done' <<< "$migrate_out")
6915 local expected=$(($uniq_count + 1))
6917 [ "$actual" -eq "$expected" ] ||
6918 error "hard links individually migrated ($actual != $expected)"
6920 # make sure the correct number of hard links are present
6921 local hardlinks=$(stat -c '%h' "$file1")
6923 [ $hardlinks -eq $total_count ] ||
6924 error "num hard links $hardlinks != $total_count"
6931 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6932 skip "Need MDS version at least 2.10.55"
6934 local dir="$DIR/$tdir"
6936 test_mkdir "$dir" || error "cannot create dir $dir"
6938 echo "testing lfs migrate mode when all links fit within xattrs"
6939 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6941 echo "testing rsync mode when all links fit within xattrs"
6942 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6944 echo "testing lfs migrate mode when all links do not fit within xattrs"
6945 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6947 echo "testing rsync mode when all links do not fit within xattrs"
6948 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6950 chown -R $RUNAS_ID $dir
6951 echo "testing non-root lfs migrate mode when not all links are in xattr"
6952 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100 "$RUNAS"
6957 run_test 56xb "lfs migration hard link support"
6960 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6962 local dir="$DIR/$tdir"
6964 test_mkdir "$dir" || error "cannot create dir $dir"
6966 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6967 echo -n "Setting initial stripe for 20MB test file..."
6968 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6969 error "cannot setstripe 20MB file"
6971 echo -n "Sizing 20MB test file..."
6972 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6974 echo -n "Verifying small file autostripe count is 1..."
6975 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6976 error "cannot migrate 20MB file"
6977 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6978 error "cannot get stripe for $dir/20mb"
6979 [ $stripe_count -eq 1 ] ||
6980 error "unexpected stripe count $stripe_count for 20MB file"
6984 # Test 2: File is small enough to fit within the available space on
6985 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6986 # have at least an additional 1KB for each desired stripe for test 3
6987 echo -n "Setting stripe for 1GB test file..."
6988 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6990 echo -n "Sizing 1GB test file..."
6991 # File size is 1GB + 3KB
6992 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6995 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6996 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6997 if (( avail > 524288 * OSTCOUNT )); then
6998 echo -n "Migrating 1GB file..."
6999 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
7000 error "cannot migrate 1GB file"
7002 echo -n "Verifying autostripe count is sqrt(n) + 1..."
7003 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
7004 error "cannot getstripe for 1GB file"
7005 [ $stripe_count -eq 2 ] ||
7006 error "unexpected stripe count $stripe_count != 2"
7010 # Test 3: File is too large to fit within the available space on
7011 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
7012 if [ $OSTCOUNT -ge 3 ]; then
7013 # The required available space is calculated as
7014 # file size (1GB + 3KB) / OST count (3).
7015 local kb_per_ost=349526
7017 echo -n "Migrating 1GB file with limit..."
7018 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
7019 error "cannot migrate 1GB file with limit"
7022 stripe_count=$($LFS getstripe -c "$dir/1gb")
7023 echo -n "Verifying 1GB autostripe count with limited space..."
7024 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
7025 error "unexpected stripe count $stripe_count (min 3)"
7032 run_test 56xc "lfs migration autostripe"
7035 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7037 local dir=$DIR/$tdir
7038 local f_mgrt=$dir/$tfile.mgrt
7039 local f_yaml=$dir/$tfile.yaml
7040 local f_copy=$dir/$tfile.copy
7041 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7042 local layout_copy="-c 2 -S 2M -i 1"
7043 local yamlfile=$dir/yamlfile
7044 local layout_before;
7047 test_mkdir "$dir" || error "cannot create dir $dir"
7048 $LFS setstripe $layout_yaml $f_yaml ||
7049 error "cannot setstripe $f_yaml with layout $layout_yaml"
7050 $LFS getstripe --yaml $f_yaml > $yamlfile
7051 $LFS setstripe $layout_copy $f_copy ||
7052 error "cannot setstripe $f_copy with layout $layout_copy"
7054 dd if=/dev/zero of=$f_mgrt bs=1M count=4
7056 # 1. test option --yaml
7057 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
7058 error "cannot migrate $f_mgrt with --yaml $yamlfile"
7059 layout_before=$(get_layout_param $f_yaml)
7060 layout_after=$(get_layout_param $f_mgrt)
7061 [ "$layout_after" == "$layout_before" ] ||
7062 error "lfs_migrate --yaml: $layout_after != $layout_before"
7064 # 2. test option --copy
7065 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
7066 error "cannot migrate $f_mgrt with --copy $f_copy"
7067 layout_before=$(get_layout_param $f_copy)
7068 layout_after=$(get_layout_param $f_mgrt)
7069 [ "$layout_after" == "$layout_before" ] ||
7070 error "lfs_migrate --copy: $layout_after != $layout_before"
7072 run_test 56xd "check lfs_migrate --yaml and --copy support"
7075 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7077 local dir=$DIR/$tdir
7078 local f_comp=$dir/$tfile
7079 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
7080 local layout_before=""
7081 local layout_after=""
7083 test_mkdir "$dir" || error "cannot create dir $dir"
7084 $LFS setstripe $layout $f_comp ||
7085 error "cannot setstripe $f_comp with layout $layout"
7086 layout_before=$(get_layout_param $f_comp)
7087 dd if=/dev/zero of=$f_comp bs=1M count=4
7089 # 1. migrate a comp layout file by lfs_migrate
7090 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
7091 layout_after=$(get_layout_param $f_comp)
7092 [ "$layout_before" == "$layout_after" ] ||
7093 error "lfs_migrate: $layout_before != $layout_after"
7095 # 2. migrate a comp layout file by lfs migrate
7096 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7097 layout_after=$(get_layout_param $f_comp)
7098 [ "$layout_before" == "$layout_after" ] ||
7099 error "lfs migrate: $layout_before != $layout_after"
7101 run_test 56xe "migrate a composite layout file"
7104 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7106 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
7107 skip "Need server version at least 2.13.53"
7109 local dir=$DIR/$tdir
7110 local f_comp=$dir/$tfile
7111 local layout="-E 1M -c1 -E -1 -c2"
7115 test_mkdir "$dir" || error "cannot create dir $dir"
7116 $LFS setstripe $layout $f_comp ||
7117 error "cannot setstripe $f_comp with layout $layout"
7118 fid_before=$($LFS getstripe --fid $f_comp)
7119 dd if=/dev/zero of=$f_comp bs=1M count=4
7121 # 1. migrate a comp layout file to a comp layout
7122 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
7123 fid_after=$($LFS getstripe --fid $f_comp)
7124 [ "$fid_before" == "$fid_after" ] ||
7125 error "comp-to-comp migrate: $fid_before != $fid_after"
7127 # 2. migrate a comp layout file to a plain layout
7128 $LFS migrate -c2 $f_comp ||
7129 error "cannot migrate $f_comp by lfs migrate"
7130 fid_after=$($LFS getstripe --fid $f_comp)
7131 [ "$fid_before" == "$fid_after" ] ||
7132 error "comp-to-plain migrate: $fid_before != $fid_after"
7134 # 3. migrate a plain layout file to a comp layout
7135 $LFS migrate $layout $f_comp ||
7136 error "cannot migrate $f_comp by lfs migrate"
7137 fid_after=$($LFS getstripe --fid $f_comp)
7138 [ "$fid_before" == "$fid_after" ] ||
7139 error "plain-to-comp migrate: $fid_before != $fid_after"
7141 run_test 56xf "FID is not lost during migration of a composite layout file"
7144 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
7145 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
7148 local dir=$DIR/$tdir
7152 test_mkdir -p $dir || error "creating dir $dir"
7153 touch $f1 || error "creating std file $f1"
7154 $MULTIOP $f2 H2c || error "creating released file $f2"
7156 # a directory can be raid0, so ask only for files
7157 res=$($LFS find $dir -L raid0 -type f | wc -l)
7158 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
7160 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
7161 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
7163 # only files can be released, so no need to force file search
7164 res=$($LFS find $dir -L released)
7165 [[ $res == $f2 ]] || error "search released: found $res != $f2"
7167 res=$($LFS find $dir -type f \! -L released)
7168 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
7170 run_test 56y "lfs find -L raid0|released"
7172 test_56z() { # LU-4824
7173 # This checks to make sure 'lfs find' continues after errors
7174 # There are two classes of errors that should be caught:
7175 # - If multiple paths are provided, all should be searched even if one
7177 # - If errors are encountered during the search, it should not terminate
7179 local dir=$DIR/$tdir
7183 for i in d{0..9}; do
7185 touch $dir/$i/$tfile
7187 $LFS find $DIR/non_existent_dir $dir &&
7188 error "$LFS find did not return an error"
7189 # Make a directory unsearchable. This should NOT be the last entry in
7190 # directory order. Arbitrarily pick the 6th entry
7191 chmod 700 $($LFS find $dir -type d | sed '6!d')
7193 $RUNAS $LFS find $DIR/non_existent $dir
7194 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
7196 # The user should be able to see 10 directories and 9 files
7197 (( count == 19 )) ||
7198 error "$LFS find found $count != 19 entries after error"
7200 run_test 56z "lfs find should continue after an error"
7202 test_56aa() { # LU-5937
7203 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
7205 local dir=$DIR/$tdir
7208 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
7210 createmany -o $dir/striped_dir/${tfile}- 1024
7211 local dirs=$($LFS find --size +8k $dir/)
7213 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
7215 run_test 56aa "lfs find --size under striped dir"
7217 test_56ab() { # LU-10705
7218 test_mkdir $DIR/$tdir
7219 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
7220 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
7221 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
7222 # Flush writes to ensure valid blocks. Need to be more thorough for
7223 # ZFS, since blocks are not allocated/returned to client immediately.
7225 wait_zfs_commit ost1 2
7226 cancel_lru_locks osc
7229 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
7231 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
7233 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
7234 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
7236 rm -f $DIR/$tdir/$tfile.[123]
7238 run_test 56ab "lfs find --blocks"
7241 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
7242 skip "Need MDS version at least 2.10.50"
7244 # Create composite files with one component
7245 local dir=$DIR/$tdir
7247 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
7248 # Create composite files with three components
7249 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
7250 # Create non-composite files
7251 createmany -o $dir/${tfile}- 10
7253 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
7255 [[ $nfiles == 10 ]] ||
7256 error "lfs find -E 1M found $nfiles != 10 files"
7258 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
7259 [[ $nfiles == 25 ]] ||
7260 error "lfs find ! -E 1M found $nfiles != 25 files"
7262 # All files have a component that starts at 0
7263 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
7264 [[ $nfiles == 35 ]] ||
7265 error "lfs find --component-start 0 - $nfiles != 35 files"
7267 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
7268 [[ $nfiles == 15 ]] ||
7269 error "lfs find --component-start 2M - $nfiles != 15 files"
7271 # All files created here have a componenet that does not starts at 2M
7272 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
7273 [[ $nfiles == 35 ]] ||
7274 error "lfs find ! --component-start 2M - $nfiles != 35 files"
7276 # Find files with a specified number of components
7277 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
7278 [[ $nfiles == 15 ]] ||
7279 error "lfs find --component-count 3 - $nfiles != 15 files"
7281 # Remember non-composite files have a component count of zero
7282 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
7283 [[ $nfiles == 10 ]] ||
7284 error "lfs find --component-count 0 - $nfiles != 10 files"
7286 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
7287 [[ $nfiles == 20 ]] ||
7288 error "lfs find ! --component-count 3 - $nfiles != 20 files"
7290 # All files have a flag called "init"
7291 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
7292 [[ $nfiles == 35 ]] ||
7293 error "lfs find --component-flags init - $nfiles != 35 files"
7295 # Multi-component files will have a component not initialized
7296 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
7297 [[ $nfiles == 15 ]] ||
7298 error "lfs find !--component-flags init - $nfiles != 15 files"
7303 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
7306 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
7307 skip "Need MDS version at least 2.10.57"
7317 # create mirrored directories and mirrored files
7318 mkdir $td || error "mkdir $td failed"
7319 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
7320 createmany -o $tf- 10 || error "create $tf- failed"
7322 for i in $(seq 2); do
7324 mkdir $dir || error "mkdir $dir failed"
7325 $LFS mirror create -N$((3 + i)) $dir ||
7326 error "create mirrored dir $dir failed"
7327 createmany -o $dir/$tfile- 10 ||
7328 error "create $dir/$tfile- failed"
7331 # change the states of some mirrored files
7333 for i in $(seq 2); do
7335 for j in $(seq 4 9); do
7336 echo foo > $dir/$tfile-$j
7340 # find mirrored files with specific mirror count
7341 cmd="$LFS find --mirror-count 3 --type f $td"
7342 nfiles=$($cmd | wc -l)
7343 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
7345 cmd="$LFS find ! --mirror-count 3 --type f $td"
7346 nfiles=$($cmd | wc -l)
7347 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
7349 cmd="$LFS find --mirror-count +2 --type f $td"
7350 nfiles=$($cmd | wc -l)
7351 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7353 cmd="$LFS find --mirror-count -6 --type f $td"
7354 nfiles=$($cmd | wc -l)
7355 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7357 # find mirrored files with specific file state
7358 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
7359 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
7361 cmd="$LFS find --mirror-state=ro --type f $td"
7362 nfiles=$($cmd | wc -l)
7363 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
7365 cmd="$LFS find ! --mirror-state=ro --type f $td"
7366 nfiles=$($cmd | wc -l)
7367 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7369 cmd="$LFS find --mirror-state=wp --type f $td"
7370 nfiles=$($cmd | wc -l)
7371 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
7373 cmd="$LFS find ! --mirror-state=sp --type f $td"
7374 nfiles=$($cmd | wc -l)
7375 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
7377 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
7380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7381 # note test will not do anything if MDS is not local
7382 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7383 skip_env "ldiskfs only test"
7385 remote_mds_nodsh && skip "remote MDS with nodsh"
7387 local MNTDEV="osd*.*MDT*.mntdev"
7388 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
7389 [ -z "$DEV" ] && error "can't access $MNTDEV"
7390 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
7391 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
7392 error "can't access $DEV"
7393 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
7394 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
7398 run_test 57a "verify MDS filesystem created with large inodes =="
7401 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7402 if [ "$mds1_FSTYPE" != ldiskfs ]; then
7403 skip_env "ldiskfs only test"
7405 remote_mds_nodsh && skip "remote MDS with nodsh"
7407 local dir=$DIR/$tdir
7410 local fileN=$dir/f$filecount
7412 rm -rf $dir || error "removing $dir"
7414 local mdtidx=$($LFS getstripe -m $dir)
7415 local mdtname=MDT$(printf %04x $mdtidx)
7416 local facet=mds$((mdtidx + 1))
7418 echo "mcreating $filecount files"
7419 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
7421 # verify that files do not have EAs yet
7422 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
7423 error "$file1 has an EA"
7424 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
7425 error "$fileN has an EA"
7429 df $dir #make sure we get new statfs data
7430 local mdsfree=$(do_facet $facet \
7431 lctl get_param -n osd*.*$mdtname.kbytesfree)
7432 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7435 echo "opening files to create objects/EAs"
7436 for file in $(seq -f $dir/f%g 1 $filecount); do
7437 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
7438 error "opening $file"
7441 # verify that files have EAs now
7442 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
7443 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
7445 sleep 1 #make sure we get new statfs data
7447 local mdsfree2=$(do_facet $facet \
7448 lctl get_param -n osd*.*$mdtname.kbytesfree)
7449 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
7451 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
7452 if [ "$mdsfree" != "$mdsfree2" ]; then
7453 error "MDC before $mdcfree != after $mdcfree2"
7455 echo "MDC before $mdcfree != after $mdcfree2"
7456 echo "unable to confirm if MDS has large inodes"
7461 run_test 57b "default LOV EAs are stored inside large inodes ==="
7464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7465 [ -z "$(which wiretest 2>/dev/null)" ] &&
7466 skip_env "could not find wiretest"
7470 run_test 58 "verify cross-platform wire constants =============="
7473 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7475 echo "touch 130 files"
7476 createmany -o $DIR/f59- 130
7478 unlinkmany $DIR/f59- 130
7480 # wait for commitment of removal
7481 wait_delete_completed
7483 run_test 59 "verify cancellation of llog records async ========="
7485 TEST60_HEAD="test_60 run $RANDOM"
7487 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7488 remote_mgs_nodsh && skip "remote MGS with nodsh"
7489 do_facet mgs "! which run-llog.sh &> /dev/null" &&
7490 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
7491 skip_env "missing subtest run-llog.sh"
7493 log "$TEST60_HEAD - from kernel mode"
7494 do_facet mgs "$LCTL dk > /dev/null"
7495 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
7496 do_facet mgs $LCTL dk > $TMP/$tfile
7498 # LU-6388: test llog_reader
7499 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
7500 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
7501 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
7502 skip_env "missing llog_reader"
7503 local fstype=$(facet_fstype mgs)
7504 [ $fstype != ldiskfs -a $fstype != zfs ] &&
7505 skip_env "Only for ldiskfs or zfs type mgs"
7507 local mntpt=$(facet_mntpt mgs)
7508 local mgsdev=$(mgsdevname 1)
7520 #get fid and record list
7521 fid_list=($(awk '/9_sub.*record/ { print $NF }' $TMP/$tfile |
7523 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' $TMP/$tfile |
7525 #remount mgs as ldiskfs or zfs type
7526 stop mgs || error "stop mgs failed"
7527 mount_fstype mgs || error "remount mgs failed"
7528 for ((i = 0; i < ${#fid_list[@]}; i++)); do
7531 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
7532 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
7537 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
7539 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
7541 echo "obj_file is $obj_file"
7542 do_facet mgs $llog_reader $obj_file
7544 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
7545 awk '{ print $3 }' | sed -e "s/^type=//g")
7546 if [ $rec_type != $rec ]; then
7547 echo "FAILED test_60a wrong record type $rec_type," \
7553 #check obj path if record type is LLOG_LOGID_MAGIC
7554 if [ "$rec" == "1064553b" ]; then
7555 path=$(do_facet mgs $llog_reader $obj_file |
7556 grep "path=" | awk '{ print $NF }' |
7557 sed -e "s/^path=//g")
7558 if [ $obj_file != $mntpt/$path ]; then
7559 echo "FAILED test_60a wrong obj path" \
7560 "$montpt/$path, should be $obj_file"
7567 #restart mgs before "error", otherwise it will block the next test
7568 stop mgs || error "stop mgs failed"
7569 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
7570 $pass || error "test failed, see FAILED test_60a messages for specifics"
7572 run_test 60a "llog_test run from kernel module and test llog_reader"
7574 test_60b() { # bug 6411
7575 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7578 LLOG_COUNT=$(do_facet mgs dmesg |
7579 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
7580 /llog_[a-z]*.c:[0-9]/ {
7592 [[ $LLOG_COUNT -gt 120 ]] &&
7593 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
7595 run_test 60b "limit repeated messages from CERROR/CWARN"
7598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7600 echo "create 5000 files"
7601 createmany -o $DIR/f60c- 5000
7602 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
7603 lctl set_param fail_loc=0x80000137
7604 unlinkmany $DIR/f60c- 5000
7605 lctl set_param fail_loc=0
7607 run_test 60c "unlink file when mds full"
7610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7612 SAVEPRINTK=$(lctl get_param -n printk)
7613 # verify "lctl mark" is even working"
7614 MESSAGE="test message ID $RANDOM $$"
7615 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7616 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
7618 lctl set_param printk=0 || error "set lnet.printk failed"
7619 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
7620 MESSAGE="new test message ID $RANDOM $$"
7621 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
7622 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
7623 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
7625 lctl set_param -n printk="$SAVEPRINTK"
7627 run_test 60d "test printk console message masking"
7630 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7631 remote_mds_nodsh && skip "remote MDS with nodsh"
7634 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
7635 do_facet mds1 lctl set_param fail_loc=0x15b
7638 run_test 60e "no space while new llog is being created"
7644 test_mkdir -c $MDSCOUNT $DIR/$tdir
7649 $LFS setdirstripe -i $(($index % $MDSCOUNT)) \
7650 -c $MDSCOUNT $DIR/$tdir/subdir$index \
7652 mkdir $DIR/$tdir/subdir$index 2>/dev/null
7653 rmdir $DIR/$tdir/subdir$index 2>/dev/null
7654 index=$((index + 1))
7660 for i in {0..100}; do
7661 # define OBD_FAIL_OSD_TXN_START 0x19a
7662 local index=$((i % MDSCOUNT + 1))
7664 do_facet mds$index $LCTL set_param fail_loc=0x8000019a \
7671 for i in $(seq $MDSCOUNT); do
7672 do_facet mds$i $LCTL set_param fail_loc=0 > /dev/null
7675 mkdir $DIR/$tdir/new || error "mkdir failed"
7676 rmdir $DIR/$tdir/new || error "rmdir failed"
7678 do_facet mds1 $LCTL lfsck_start -M $(facet_svc mds1) -A -C \
7680 for i in $(seq $MDSCOUNT); do
7681 wait_update_facet mds$i "$LCTL get_param -n \
7682 mdd.$(facet_svc mds$i).lfsck_namespace |
7683 awk '/^status/ { print \\\$2 }'" "completed"
7686 ls -R $DIR/$tdir || error "ls failed"
7687 rm -rf $DIR/$tdir || error "rmdir failed"
7689 run_test 60g "transaction abort won't cause MDT hung"
7692 [ $MDS1_VERSION -le $(version_code 2.12.52) ] &&
7693 skip "Need MDS version at least 2.12.52"
7694 [ $MDSCOUNT -lt 2 ] && skip "Need at least 2 MDTs"
7698 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
7699 #define OBD_FAIL_MDS_STRIPE_FID 0x189
7700 for fail_loc in 0x80000188 0x80000189; do
7701 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
7702 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
7703 error "mkdir $dir-$fail_loc failed"
7704 for i in {0..10}; do
7705 # create may fail on missing stripe
7706 echo $i > $DIR/$tdir-$fail_loc/$i
7708 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7709 error "getdirstripe $tdir-$fail_loc failed"
7710 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
7711 error "migrate $tdir-$fail_loc failed"
7712 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
7713 error "getdirstripe $tdir-$fail_loc failed"
7714 pushd $DIR/$tdir-$fail_loc
7716 echo $f | cmp $f - || error "$f data mismatch"
7719 rm -rf $DIR/$tdir-$fail_loc
7722 run_test 60h "striped directory with missing stripes can be accessed"
7725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7728 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
7729 cancel_lru_locks osc
7730 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
7733 run_test 61a "mmap() writes don't make sync hang ================"
7736 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
7738 run_test 61b "mmap() of unstriped file is successful"
7740 # bug 2330 - insufficient obd_match error checking causes LBUG
7742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7746 cancel_lru_locks osc
7747 lctl set_param fail_loc=0x405
7748 cat $f && error "cat succeeded, expect -EIO"
7749 lctl set_param fail_loc=0
7751 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
7752 # match every page all of the time.
7753 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
7755 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
7756 # Though this test is irrelevant anymore, it helped to reveal some
7757 # other grant bugs (LU-4482), let's keep it.
7758 test_63a() { # was test_63
7759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7761 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
7763 for i in `seq 10` ; do
7764 dd if=/dev/zero of=$DIR/f63 bs=8k &
7770 rm -f $DIR/f63 || true
7772 run_test 63a "Verify oig_wait interruption does not crash ======="
7774 # bug 2248 - async write errors didn't return to application on sync
7775 # bug 3677 - async write errors left page locked
7777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7780 lctl set_param debug=-1
7782 # ensure we have a grant to do async writes
7783 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
7786 sync # sync lest earlier test intercept the fail_loc
7788 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7789 lctl set_param fail_loc=0x80000406
7790 $MULTIOP $DIR/$tfile Owy && \
7791 error "sync didn't return ENOMEM"
7792 sync; sleep 2; sync # do a real sync this time to flush page
7793 lctl get_param -n llite.*.dump_page_cache | grep locked && \
7794 error "locked page left in cache after async error" || true
7797 run_test 63b "async write errors should be returned to fsync ==="
7800 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7803 lctl get_param osc.*[oO][sS][cC][_-]*.cur* | grep "=[1-9]"
7805 run_test 64a "verify filter grant calculations (in kernel) ====="
7808 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7810 sh oos.sh $MOUNT || error "oos.sh failed: $?"
7812 run_test 64b "check out-of-space detection on client"
7815 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
7817 run_test 64c "verify grant shrink"
7819 # this does exactly what osc_request.c:osc_announce_cached() does in
7820 # order to calculate max amount of grants to ask from server
7824 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
7825 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
7827 ((rpc_in_flight ++));
7828 nrpages=$((nrpages * rpc_in_flight))
7830 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
7832 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
7834 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
7835 local undirty=$((nrpages * PAGE_SIZE))
7837 local max_extent_pages
7838 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
7839 grep grant_max_extent_size | awk '{print $2}')
7840 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
7841 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
7842 local grant_extent_tax
7843 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7844 grep grant_extent_tax | awk '{print $2}')
7846 undirty=$((undirty + nrextents * grant_extent_tax))
7851 # this is size of unit for grant allocation. It should be equal to
7852 # what tgt_grant.c:tgt_grant_chunk() calculates
7856 local grant_extent_tax
7858 max_brw_size=$($LCTL get_param osc.${tgt}.import |
7859 grep max_brw_size | awk '{print $2}')
7861 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
7862 grep grant_extent_tax | awk '{print $2}')
7864 echo $(((max_brw_size + grant_extent_tax) * 2))
7868 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
7869 skip "OST < 2.10.55 doesn't limit grants enough"
7871 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
7872 local file=$DIR/$tfile
7874 [[ $($LCTL get_param osc.${tgt}.import |
7875 grep "connect_flags:.*grant_param") ]] ||
7876 skip "no grant_param connect flag"
7878 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
7880 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
7882 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
7883 stack_trap "rm -f $file" EXIT
7885 $LFS setstripe $file -i 0 -c 1
7886 dd if=/dev/zero of=$file bs=1M count=1000 &
7891 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
7892 if [[ $cur_grant -gt $max_cur_granted ]]
7895 error "cur_grant $cur_grant > $max_cur_granted"
7898 [[ $? -ne 0 ]] && break;
7903 wait_delete_completed
7904 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7906 run_test 64d "check grant limit exceed"
7908 # bug 1414 - set/get directories' stripe info
7910 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7912 test_mkdir $DIR/$tdir
7914 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7916 run_test 65a "directory with no stripe info"
7919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7921 test_mkdir $DIR/$tdir
7922 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7924 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7927 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7929 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7932 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7933 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7935 test_mkdir $DIR/$tdir
7936 local stripesize=$($LFS getstripe -S $DIR/$tdir)
7938 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7939 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7941 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7943 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7948 test_mkdir $DIR/$tdir
7949 local STRIPECOUNT=$($LFS getstripe -c $DIR/$tdir)
7950 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7952 if [[ $STRIPECOUNT -le 0 ]]; then
7954 elif [[ $STRIPECOUNT -gt $LOV_MAX_STRIPE_COUNT ]]; then
7955 [[ $OSTCOUNT -gt $LOV_MAX_STRIPE_COUNT ]] &&
7956 sc=$LOV_MAX_STRIPE_COUNT || sc=$(($OSTCOUNT - 1))
7958 sc=$(($STRIPECOUNT - 1))
7960 $LFS setstripe -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7961 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7962 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7963 error "lverify failed"
7965 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7968 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7970 test_mkdir $DIR/$tdir
7972 $LFS setstripe $DIR/$tdir || error "setstripe"
7973 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7974 error "no stripe info failed"
7976 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7978 run_test 65e "directory setstripe defaults"
7981 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7983 test_mkdir $DIR/${tdir}f
7984 $RUNAS $LFS setstripe $DIR/${tdir}f &&
7985 error "setstripe succeeded" || true
7987 run_test 65f "dir setstripe permission (should return error) ==="
7990 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7992 test_mkdir $DIR/$tdir
7993 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
7995 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7996 error "setstripe -S failed"
7997 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7998 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7999 error "delete default stripe failed"
8001 run_test 65g "directory setstripe -d"
8004 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8006 test_mkdir $DIR/$tdir
8007 local STRIPESIZE=$($LFS getstripe -S $DIR/$tdir)
8009 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
8010 error "setstripe -S failed"
8011 test_mkdir $DIR/$tdir/dd1
8012 [ $($LFS getstripe -c $DIR/$tdir) = $($LFS getstripe -c $DIR/$tdir/dd1) ] ||
8013 error "stripe info inherit failed"
8015 run_test 65h "directory stripe info inherit ===================="
8018 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8020 save_layout_restore_at_exit $MOUNT
8022 # bug6367: set non-default striping on root directory
8023 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
8025 # bug12836: getstripe on -1 default directory striping
8026 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
8028 # bug12836: getstripe -v on -1 default directory striping
8029 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
8031 # bug12836: new find on -1 default directory striping
8032 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
8034 run_test 65i "various tests to set root directory striping"
8036 test_65j() { # bug6367
8037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8041 # if we aren't already remounting for each test, do so for this test
8042 if [ "$I_MOUNTED" = "yes" ]; then
8043 cleanup || error "failed to unmount"
8047 save_layout_restore_at_exit $MOUNT
8049 $LFS setstripe -d $MOUNT || error "setstripe failed"
8051 run_test 65j "set default striping on root directory (bug 6367)="
8055 wait_delete_completed
8056 do_facet $SINGLEMDS "lctl set_param -n \
8057 osp.$ost*MDT0000.max_create_count=$max_count"
8058 do_facet $SINGLEMDS "lctl set_param -n \
8059 osp.$ost*MDT0000.create_count=$count"
8060 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8061 echo $INACTIVE_OSC "is Activate"
8063 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8066 test_65k() { # bug11679
8067 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8068 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8069 remote_mds_nodsh && skip "remote MDS with nodsh"
8071 local disable_precreate=true
8072 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
8073 disable_precreate=false
8075 echo "Check OST status: "
8076 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
8077 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
8079 for OSC in $MDS_OSCS; do
8080 echo $OSC "is active"
8081 do_facet $SINGLEMDS lctl --device %$OSC activate
8084 for INACTIVE_OSC in $MDS_OSCS; do
8085 local ost=$(osc_to_ost $INACTIVE_OSC)
8086 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
8087 lov.*md*.target_obd |
8088 awk -F: /$ost/'{ print $1 }' | head -n 1)
8091 $LFS setstripe -i $ostnum -c 1 $DIR/$tdir
8092 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
8094 echo "Deactivate: " $INACTIVE_OSC
8095 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
8097 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
8098 osp.$ost*MDT0000.create_count")
8099 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
8100 osp.$ost*MDT0000.max_create_count")
8101 $disable_precreate &&
8102 do_facet $SINGLEMDS "lctl set_param -n \
8103 osp.$ost*MDT0000.max_create_count=0"
8105 for idx in $(seq 0 $((OSTCOUNT - 1))); do
8106 [ -f $DIR/$tdir/$idx ] && continue
8107 echo "$LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx"
8108 $LFS setstripe -i $idx -c 1 $DIR/$tdir/$idx ||
8110 error "setstripe $idx should succeed"; }
8111 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
8113 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
8116 do_facet $SINGLEMDS "lctl set_param -n \
8117 osp.$ost*MDT0000.max_create_count=$max_count"
8118 do_facet $SINGLEMDS "lctl set_param -n \
8119 osp.$ost*MDT0000.create_count=$count"
8120 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
8121 echo $INACTIVE_OSC "is Activate"
8123 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
8126 run_test 65k "validate manual striping works properly with deactivated OSCs"
8128 test_65l() { # bug 12836
8129 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8131 test_mkdir -p $DIR/$tdir/test_dir
8132 $LFS setstripe -c -1 $DIR/$tdir/test_dir
8133 $LFS find -mtime -1 $DIR/$tdir >/dev/null
8135 run_test 65l "lfs find on -1 stripe dir ========================"
8138 local layout=$(save_layout $MOUNT)
8139 $RUNAS $LFS setstripe -c 2 $MOUNT && {
8140 restore_layout $MOUNT $layout
8141 error "setstripe should fail by non-root users"
8145 run_test 65m "normal user can't set filesystem default stripe"
8148 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
8149 [[ $MDS1_VERSION -ge $(version_code 2.12.50) ]] ||
8150 skip "Need MDS version at least 2.12.50"
8151 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
8153 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
8154 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
8155 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
8157 local root_layout=$(save_layout $MOUNT)
8158 stack_trap "restore_layout $MOUNT $root_layout" EXIT
8160 # new subdirectory under root directory should not inherit
8161 # the default layout from root
8162 local dir1=$MOUNT/$tdir-1
8163 mkdir $dir1 || error "mkdir $dir1 failed"
8164 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
8165 error "$dir1 shouldn't have LOV EA"
8167 # delete the default layout on root directory
8168 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
8170 local dir2=$MOUNT/$tdir-2
8171 mkdir $dir2 || error "mkdir $dir2 failed"
8172 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
8173 error "$dir2 shouldn't have LOV EA"
8175 # set a new striping pattern on root directory
8176 local def_stripe_size=$($LFS getstripe -S $MOUNT)
8177 local new_def_stripe_size=$((def_stripe_size * 2))
8178 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
8179 error "set stripe size on $MOUNT failed"
8181 # new file created in $dir2 should inherit the new stripe size from
8182 # the filesystem default
8183 local file2=$dir2/$tfile-2
8184 touch $file2 || error "touch $file2 failed"
8186 local file2_stripe_size=$($LFS getstripe -S $file2)
8187 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
8188 error "$file2 didn't inherit stripe size $new_def_stripe_size"
8190 local dir3=$MOUNT/$tdir-3
8191 mkdir $dir3 || error "mkdir $dir3 failed"
8192 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
8193 # the root layout, which is the actual default layout that will be used
8194 # when new files are created in $dir3.
8195 local dir3_layout=$(get_layout_param $dir3)
8196 local root_dir_layout=$(get_layout_param $MOUNT)
8197 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
8198 error "$dir3 should show the default layout from $MOUNT"
8200 # set OST pool on root directory
8201 local pool=$TESTNAME
8202 pool_add $pool || error "add $pool failed"
8203 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
8204 error "add targets to $pool failed"
8206 $LFS setstripe -p $pool $MOUNT ||
8207 error "set OST pool on $MOUNT failed"
8209 # new file created in $dir3 should inherit the pool from
8210 # the filesystem default
8211 local file3=$dir3/$tfile-3
8212 touch $file3 || error "touch $file3 failed"
8214 local file3_pool=$($LFS getstripe -p $file3)
8215 [[ "$file3_pool" = "$pool" ]] ||
8216 error "$file3 didn't inherit OST pool $pool"
8218 local dir4=$MOUNT/$tdir-4
8219 mkdir $dir4 || error "mkdir $dir4 failed"
8220 local dir4_layout=$(get_layout_param $dir4)
8221 root_dir_layout=$(get_layout_param $MOUNT)
8222 echo "$LFS getstripe -d $dir4"
8223 $LFS getstripe -d $dir4
8224 echo "$LFS getstripe -d $MOUNT"
8225 $LFS getstripe -d $MOUNT
8226 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
8227 error "$dir4 should show the default layout from $MOUNT"
8229 # new file created in $dir4 should inherit the pool from
8230 # the filesystem default
8231 local file4=$dir4/$tfile-4
8232 touch $file4 || error "touch $file4 failed"
8234 local file4_pool=$($LFS getstripe -p $file4)
8235 [[ "$file4_pool" = "$pool" ]] ||
8236 error "$file4 didn't inherit OST pool $pool"
8238 # new subdirectory under non-root directory should inherit
8239 # the default layout from its parent directory
8240 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
8241 error "set directory layout on $dir4 failed"
8243 local dir5=$dir4/$tdir-5
8244 mkdir $dir5 || error "mkdir $dir5 failed"
8246 dir4_layout=$(get_layout_param $dir4)
8247 local dir5_layout=$(get_layout_param $dir5)
8248 [[ "$dir4_layout" = "$dir5_layout" ]] ||
8249 error "$dir5 should inherit the default layout from $dir4"
8251 # though subdir under ROOT doesn't inherit default layout, but
8252 # its sub dir/file should be created with default layout.
8253 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
8254 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
8255 skip "Need MDS version at least 2.12.59"
8257 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
8258 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
8259 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
8261 if [ $default_lmv_hash == "none" ]; then
8262 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
8264 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
8265 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
8268 $LFS setdirstripe -D -c 2 $MOUNT ||
8269 error "setdirstripe -D -c 2 failed"
8270 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
8271 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
8272 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
8274 run_test 65n "don't inherit default layout from root for new subdirectories"
8276 # bug 2543 - update blocks count on client
8278 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8281 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
8282 sync; sync_all_data; sync; sync_all_data
8283 cancel_lru_locks osc
8284 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
8285 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
8287 run_test 66 "update inode blocks count on client ==============="
8290 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
8294 swapon -s | awk '($1 == "'$1'") { print $4 }'
8297 # bug5265, obdfilter oa2dentry return -ENOENT
8298 # #define OBD_FAIL_SRV_ENOENT 0x217
8300 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8301 remote_ost_nodsh && skip "remote OST with nodsh"
8304 $LFS setstripe -c 1 -i 0 $f
8306 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
8308 do_facet ost1 lctl set_param fail_loc=0x217
8309 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
8310 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
8312 do_facet ost1 lctl set_param fail_loc=0
8313 $DIRECTIO write $f 0 2 || error "write error"
8315 cancel_lru_locks osc
8316 $DIRECTIO read $f 0 1 || error "read error"
8318 do_facet ost1 lctl set_param fail_loc=0x217
8319 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
8321 do_facet ost1 lctl set_param fail_loc=0
8324 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
8327 test_mkdir $DIR/$tdir
8328 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
8329 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
8331 run_test 71 "Running dbench on lustre (don't segment fault) ===="
8333 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
8334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8335 [ "$RUNAS_ID" = "$UID" ] &&
8336 skip_env "RUNAS_ID = UID = $UID -- skipping"
8337 # Check that testing environment is properly set up. Skip if not
8338 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
8339 skip_env "User $RUNAS_ID does not exist - skipping"
8342 chmod 777 $DIR/$tfile
8343 chmod ug+s $DIR/$tfile
8344 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
8345 error "$RUNAS dd $DIR/$tfile failed"
8346 # See if we are still setuid/sgid
8347 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8348 error "S/gid is not dropped on write"
8349 # Now test that MDS is updated too
8350 cancel_lru_locks mdc
8351 [ -u $DIR/$tfile ] || [ -g $DIR/$tfile ] &&
8352 error "S/gid is not dropped on MDS"
8355 run_test 72a "Test that remove suid works properly (bug5695) ===="
8357 test_72b() { # bug 24226 -- keep mode setting when size is not changing
8360 [ "$RUNAS_ID" = "$UID" ] &&
8361 skip_env "RUNAS_ID = UID = $UID -- skipping"
8362 [ "$RUNAS_ID" -eq 0 ] &&
8363 skip_env "RUNAS_ID = 0 -- skipping"
8364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8365 # Check that testing environment is properly set up. Skip if not
8366 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
8367 skip_env "User $RUNAS_ID does not exist - skipping"
8369 touch $DIR/${tfile}-f{g,u}
8370 test_mkdir $DIR/${tfile}-dg
8371 test_mkdir $DIR/${tfile}-du
8372 chmod 770 $DIR/${tfile}-{f,d}{g,u}
8373 chmod g+s $DIR/${tfile}-{f,d}g
8374 chmod u+s $DIR/${tfile}-{f,d}u
8375 for perm in 777 2777 4777; do
8376 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
8377 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
8378 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
8379 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
8383 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
8385 # bug 3462 - multiple simultaneous MDC requests
8387 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8389 test_mkdir $DIR/d73-1
8390 test_mkdir $DIR/d73-2
8391 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
8394 lctl set_param fail_loc=0x80000129
8395 $MULTIOP $DIR/d73-1/f73-2 Oc &
8397 lctl set_param fail_loc=0
8399 $MULTIOP $DIR/d73-2/f73-3 Oc &
8403 wait $pid1 || return 1
8407 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
8408 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
8409 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
8413 run_test 73 "multiple MDC requests (should not deadlock)"
8415 test_74a() { # bug 6149, 6184
8416 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8419 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8421 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8422 # will spin in a tight reconnection loop
8423 $LCTL set_param fail_loc=0x8000030e
8424 # get any lock that won't be difficult - lookup works.
8426 $LCTL set_param fail_loc=0
8430 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
8432 test_74b() { # bug 13310
8433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8435 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
8437 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
8438 # will spin in a tight reconnection loop
8439 $LCTL set_param fail_loc=0x8000030e
8440 # get a "difficult" lock
8442 $LCTL set_param fail_loc=0
8446 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
8449 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8451 #define OBD_FAIL_LDLM_NEW_LOCK
8452 $LCTL set_param fail_loc=0x319
8453 touch $DIR/$tfile && error "touch successful"
8454 $LCTL set_param fail_loc=0
8457 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
8460 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
8463 test_76() { # Now for bug 20433, added originally in bug 1443
8464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8466 cancel_lru_locks osc
8467 local cpus=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
8468 local before=$(num_inodes)
8469 local count=$((512 * cpus))
8470 [ "$SLOW" = "no" ] && count=$((64 * cpus))
8472 echo "before inodes: $before"
8473 for i in $(seq $count); do
8477 cancel_lru_locks osc
8478 local after=$(num_inodes)
8479 echo "after inodes: $after"
8480 while (( after > before + 8 * ${cpus:-1} )); do
8484 (( wait % 5 == 0 )) && echo "wait $wait seconds inodes: $after"
8485 if (( wait > 30 )); then
8486 error "inode slab grew from $before to $after"
8490 run_test 76 "confirm clients recycle inodes properly ===="
8496 # Note: in sptlrpc modes which enable its own bulk checksum, the
8497 # original crc32_le bulk checksum will be automatically disabled,
8498 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
8499 # will be checked by sptlrpc code against sptlrpc bulk checksum.
8500 # In this case set_checksums() will not be no-op, because sptlrpc
8501 # bulk checksum will be enabled all through the test.
8503 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
8504 lctl set_param -n osc.*.checksums $1
8508 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8509 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
8510 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
8511 tr -d [] | head -n1)}
8514 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
8516 log "set checksum type to $1, rc = $rc"
8520 get_osc_checksum_type()
8522 # arugment 1: OST name, like OST0000
8524 checksum_type=$(lctl get_param -n osc.*${ost}-osc-[^mM]*.checksum_type |
8525 sed 's/.*\[\(.*\)\].*/\1/g')
8527 [ $rc -ne 0 ] && error "failed to get checksum type of $ost, rc = $rc, output = $checksum_type"
8531 F77_TMP=$TMP/f77-temp
8534 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
8535 error "error writing to $F77_TMP"
8538 test_77a() { # bug 10889
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8540 $GSS && skip_env "could not run with gss"
8542 [ ! -f $F77_TMP ] && setup_f77
8544 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
8548 run_test 77a "normal checksum read/write operation"
8550 test_77b() { # bug 10889
8551 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8552 $GSS && skip_env "could not run with gss"
8554 [ ! -f $F77_TMP ] && setup_f77
8555 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8556 $LCTL set_param fail_loc=0x80000409
8559 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8560 error "dd error: $?"
8561 $LCTL set_param fail_loc=0
8563 for algo in $CKSUM_TYPES; do
8564 cancel_lru_locks osc
8565 set_checksum_type $algo
8566 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8567 $LCTL set_param fail_loc=0x80000408
8568 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
8569 $LCTL set_param fail_loc=0
8572 set_checksum_type $ORIG_CSUM_TYPE
8575 run_test 77b "checksum error on client write, read"
8580 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
8582 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
8583 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
8584 $check_ost && [ -n "$ost_file_prefix" ] &&
8585 do_facet ost1 rm -f ${ost_file_prefix}\*
8589 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8590 $GSS && skip_env "could not run with gss"
8591 remote_ost_nodsh && skip "remote OST with nodsh"
8594 local osc_file_prefix
8596 local check_ost=false
8597 local ost_file_prefix
8603 # ensure corruption will occur on first OSS/OST
8604 $LFS setstripe -i 0 $DIR/$tfile
8606 [ ! -f $F77_TMP ] && setup_f77
8607 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
8608 error "dd write error: $?"
8609 fid=$($LFS path2fid $DIR/$tfile)
8611 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
8614 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
8615 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
8617 echo "OSS do not support bulk pages dump upon error"
8620 osc_file_prefix=$($LCTL get_param -n debug_path)
8621 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
8623 trap cleanup_77c EXIT
8626 # enable bulk pages dump upon error on Client
8627 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
8628 # enable bulk pages dump upon error on OSS
8630 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
8632 # flush Client cache to allow next read to reach OSS
8633 cancel_lru_locks osc
8635 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8636 $LCTL set_param fail_loc=0x80000408
8637 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
8638 $LCTL set_param fail_loc=0
8642 # check cksum dump on Client
8643 osc_file=$(ls ${osc_file_prefix}*)
8644 [ -n "$osc_file" ] || error "no checksum dump file on Client"
8645 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
8646 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
8647 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
8648 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
8650 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
8651 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8652 error "dump content does not match on Client"
8654 $check_ost || skip "No need to check cksum dump on OSS"
8656 # check cksum dump on OSS
8657 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
8658 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
8659 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
8660 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
8661 [[ "$orig_cksum" == "$dump_cksum" ]] ||
8662 error "dump content does not match on OSS"
8666 run_test 77c "checksum error on client read with debug"
8668 test_77d() { # bug 10889
8669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8670 $GSS && skip_env "could not run with gss"
8672 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8673 $LCTL set_param fail_loc=0x80000409
8675 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8676 error "direct write: rc=$?"
8677 $LCTL set_param fail_loc=0
8680 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
8681 $LCTL set_param fail_loc=0x80000408
8683 cancel_lru_locks osc
8684 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
8685 error "direct read: rc=$?"
8686 $LCTL set_param fail_loc=0
8689 run_test 77d "checksum error on OST direct write, read"
8691 test_77f() { # bug 10889
8692 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8693 $GSS && skip_env "could not run with gss"
8696 for algo in $CKSUM_TYPES; do
8697 cancel_lru_locks osc
8698 set_checksum_type $algo
8699 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
8700 $LCTL set_param fail_loc=0x409
8701 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
8702 error "direct write succeeded"
8703 $LCTL set_param fail_loc=0
8705 set_checksum_type $ORIG_CSUM_TYPE
8708 run_test 77f "repeat checksum error on write (expect error)"
8710 test_77g() { # bug 10889
8711 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8712 $GSS && skip_env "could not run with gss"
8713 remote_ost_nodsh && skip "remote OST with nodsh"
8715 [ ! -f $F77_TMP ] && setup_f77
8717 local file=$DIR/$tfile
8718 stack_trap "rm -f $file" EXIT
8720 $LFS setstripe -c 1 -i 0 $file
8721 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
8722 do_facet ost1 lctl set_param fail_loc=0x8000021a
8724 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
8725 error "write error: rc=$?"
8726 do_facet ost1 lctl set_param fail_loc=0
8729 cancel_lru_locks osc
8730 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
8731 do_facet ost1 lctl set_param fail_loc=0x8000021b
8733 cmp $F77_TMP $file || error "file compare failed"
8734 do_facet ost1 lctl set_param fail_loc=0
8737 run_test 77g "checksum error on OST write, read"
8739 test_77k() { # LU-10906
8740 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8741 $GSS && skip_env "could not run with gss"
8743 local cksum_param="osc.$FSNAME*.checksums"
8744 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
8748 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
8749 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
8750 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
8754 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
8755 error "failed to set checksum=$i on MGS"
8756 wait_update $HOSTNAME "$get_checksum" $i
8758 echo "remount client, checksum should be $i"
8759 remount_client $MOUNT || error "failed to remount client"
8760 checksum=$(eval $get_checksum)
8761 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8763 # remove persistent param to avoid races with checksum mountopt below
8764 do_facet mgs $LCTL set_param -P -d $cksum_param ||
8765 error "failed to delete checksum on MGS"
8767 for opt in "checksum" "nochecksum"; do
8768 #remount with mount option
8769 echo "remount client with option $opt, checksum should be $i"
8770 umount_client $MOUNT || error "failed to umount client"
8771 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
8772 error "failed to mount client with option '$opt'"
8773 checksum=$(eval $get_checksum)
8774 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
8778 remount_client $MOUNT || error "failed to remount client"
8780 run_test 77k "enable/disable checksum correctly"
8783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8784 $GSS && skip_env "could not run with gss"
8787 stack_trap "set_checksums $ORIG_CSUM" EXIT
8788 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
8790 set_checksum_type invalid && error "unexpected success of invalid checksum type"
8792 $LFS setstripe -c 1 -i 0 $DIR/$tfile
8793 for algo in $CKSUM_TYPES; do
8794 set_checksum_type $algo || error "fail to set checksum type $algo"
8795 osc_algo=$(get_osc_checksum_type OST0000)
8796 [ "$osc_algo" != "$algo" ] && error "checksum type is $osc_algo after setting it to $algo"
8798 # no locks, no reqs to let the connection idle
8799 cancel_lru_locks osc
8800 lru_resize_disable osc
8801 wait_osc_import_state client ost1 IDLE
8803 # ensure ost1 is connected
8804 stat $DIR/$tfile >/dev/null || error "can't stat"
8805 wait_osc_import_state client ost1 FULL
8807 osc_algo=$(get_osc_checksum_type OST0000)
8808 [ "$osc_algo" != "$algo" ] && error "checksum type changed from $algo to $osc_algo after reconnection"
8812 run_test 77l "preferred checksum type is remembered after reconnected"
8814 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
8823 test_78() { # bug 10901
8824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8825 remote_ost || skip_env "local OST"
8828 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
8829 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
8830 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
8831 echo "MemTotal: $MEMTOTAL"
8833 # reserve 256MB of memory for the kernel and other running processes,
8834 # and then take 1/2 of the remaining memory for the read/write buffers.
8835 if [ $MEMTOTAL -gt 512 ] ;then
8836 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
8838 # for those poor memory-starved high-end clusters...
8839 MEMTOTAL=$((MEMTOTAL / 2))
8841 echo "Mem to use for directio: $MEMTOTAL"
8843 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
8844 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
8845 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
8846 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
8848 echo "Smallest OST: $SMALLESTOST"
8849 [[ $SMALLESTOST -lt 10240 ]] &&
8850 skip "too small OSTSIZE, useless to run large O_DIRECT test"
8852 trap cleanup_test_78 EXIT
8854 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
8855 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
8857 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
8858 echo "File size: $F78SIZE"
8859 $LFS setstripe -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
8860 for i in $(seq 1 $NSEQ); do
8861 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
8862 echo directIO rdwr round $i of $NSEQ
8863 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
8868 run_test 78 "handle large O_DIRECT writes correctly ============"
8870 test_79() { # bug 12743
8871 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8873 wait_delete_completed
8875 BKTOTAL=$(calc_osc_kbytes kbytestotal)
8876 BKFREE=$(calc_osc_kbytes kbytesfree)
8877 BKAVAIL=$(calc_osc_kbytes kbytesavail)
8879 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
8880 DFTOTAL=`echo $STRING | cut -d, -f1`
8881 DFUSED=`echo $STRING | cut -d, -f2`
8882 DFAVAIL=`echo $STRING | cut -d, -f3`
8883 DFFREE=$(($DFTOTAL - $DFUSED))
8885 ALLOWANCE=$((64 * $OSTCOUNT))
8887 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
8888 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
8889 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
8891 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
8892 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
8893 error "df free($DFFREE) mismatch OST free($BKFREE)"
8895 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
8896 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
8897 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
8900 run_test 79 "df report consistency check ======================="
8902 test_80() { # bug 10718
8903 remote_ost_nodsh && skip "remote OST with nodsh"
8904 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8906 # relax strong synchronous semantics for slow backends like ZFS
8907 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
8908 local soc="obdfilter.*.sync_lock_cancel"
8909 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8911 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
8912 if [ -z "$save" ]; then
8913 soc="obdfilter.*.sync_on_lock_cancel"
8914 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
8917 if [ "$save" != "never" ]; then
8918 local hosts=$(comma_list $(osts_nodes))
8920 do_nodes $hosts $LCTL set_param $soc=never
8921 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
8925 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
8927 local before=$(date +%s)
8928 cancel_lru_locks osc
8929 local after=$(date +%s)
8930 local diff=$((after - before))
8931 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
8935 run_test 80 "Page eviction is equally fast at high offsets too"
8937 test_81a() { # LU-456
8938 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8939 remote_ost_nodsh && skip "remote OST with nodsh"
8941 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8942 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8943 do_facet ost1 lctl set_param fail_loc=0x80000228
8945 # write should trigger a retry and success
8946 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8947 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8949 if [ $RC -ne 0 ] ; then
8950 error "write should success, but failed for $RC"
8953 run_test 81a "OST should retry write when get -ENOSPC ==============="
8955 test_81b() { # LU-456
8956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8957 remote_ost_nodsh && skip "remote OST with nodsh"
8959 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8960 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8961 do_facet ost1 lctl set_param fail_loc=0x228
8963 # write should retry several times and return -ENOSPC finally
8964 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8965 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8968 if [ $RC -ne $ENOSPC ] ; then
8969 error "dd should fail for -ENOSPC, but succeed."
8972 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8974 test_82() { # LU-1031
8975 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8979 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8981 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8983 kill -USR1 $MULTIPID2
8985 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8986 error "First grouplock does not block second one"
8988 echo "Second grouplock blocks first one"
8990 kill -USR1 $MULTIPID1
8994 run_test 82 "Basic grouplock test"
8997 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8999 test_mkdir $DIR/$tdir.cvsroot
9000 chown $RUNAS_ID $DIR/$tdir.cvsroot
9003 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
9006 # some versions of cvs import exit(1) when asked to import links or
9007 # files they can't read. ignore those files.
9008 local toignore=$(find . -type l -printf '-I %f\n' -o \
9009 ! -perm /4 -printf '-I %f\n')
9010 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
9011 $tdir.reposname vtag rtag
9014 test_mkdir $DIR/$tdir.reposname
9015 chown $RUNAS_ID $DIR/$tdir.reposname
9016 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
9018 cd $DIR/$tdir.reposname
9020 $RUNAS cvs add -m 'addmsg' foo99
9022 $RUNAS cvs commit -m 'nomsg' foo99
9023 rm -fr $DIR/$tdir.cvsroot
9025 run_test 99 "cvs strange file/directory operations"
9028 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9029 [[ "$NETTYPE" =~ tcp ]] ||
9030 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
9031 remote_ost_nodsh && skip "remote OST with nodsh"
9032 remote_mds_nodsh && skip "remote MDS with nodsh"
9034 skip "useless for local single node setup"
9036 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
9037 [ "$PROT" != "tcp" ] && continue
9038 RPORT=$(echo $REMOTE | cut -d: -f2)
9039 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
9042 LPORT=`echo $LOCAL | cut -d: -f2`
9043 if [ $LPORT -ge 1024 ]; then
9044 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
9046 error_exit "local: $LPORT > 1024, remote: $RPORT"
9049 [ "$rc" = 0 ] || error_exit "privileged port not found" )
9051 run_test 100 "check local port using privileged port ==========="
9053 function get_named_value()
9062 echo $line | sed "s/^$tag[ ]*//"
9069 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
9070 awk '/^max_cached_mb/ { print $2 }')
9073 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
9078 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9083 local cache_limit=32
9085 $LCTL set_param -n osc.*-osc*.rpc_stats 0
9086 trap cleanup_101a EXIT
9087 $LCTL set_param -n llite.*.read_ahead_stats 0
9088 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
9091 # randomly read 10000 of 64K chunks from file 3x 32MB in size
9093 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
9094 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
9097 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
9098 get_named_value 'read but discarded' | cut -d" " -f1); do
9099 discard=$(($discard + $s))
9103 $LCTL get_param osc.*-osc*.rpc_stats
9104 $LCTL get_param llite.*.read_ahead_stats
9106 # Discard is generally zero, but sometimes a few random reads line up
9107 # and trigger larger readahead, which is wasted & leads to discards.
9108 if [[ $(($discard)) -gt $nreads ]]; then
9109 error "too many ($discard) discarded pages"
9111 rm -f $DIR/$tfile || true
9113 run_test 101a "check read-ahead for random reads"
9116 test_mkdir $DIR/$tdir
9118 local FILE_LENGTH=$2
9121 local FILE_SIZE_MB=$((FILE_LENGTH / ssize))
9123 local list=$(comma_list $(osts_nodes))
9124 set_osd_param $list '' read_cache_enable 0
9125 set_osd_param $list '' writethrough_cache_enable 0
9127 trap cleanup_test101bc EXIT
9128 # prepare the read-ahead file
9129 $LFS setstripe -S $ssize -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
9131 dd if=/dev/zero of=$DIR/$tfile bs=$ssize \
9132 count=$FILE_SIZE_MB 2> /dev/null
9136 cleanup_test101bc() {
9141 local list=$(comma_list $(osts_nodes))
9142 set_osd_param $list '' read_cache_enable 1
9143 set_osd_param $list '' writethrough_cache_enable 1
9147 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
9152 local STRIPE_SIZE=$2
9153 local FILE_LENGTH=$3
9154 local RA_INC=1048576
9155 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
9156 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
9157 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
9158 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
9159 get_named_value 'read but discarded' |
9160 cut -d" " -f1 | calc_total)
9161 if [[ $DISCARD -gt $discard_limit ]]; then
9162 $LCTL get_param llite.*.read_ahead_stats
9163 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
9165 echo "Read-ahead success for size ${READ_SIZE}"
9170 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9171 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9173 local STRIPE_SIZE=1048576
9174 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
9176 if [ $SLOW == "yes" ]; then
9177 local FILE_LENGTH=$((STRIDE_SIZE * 64))
9179 local FILE_LENGTH=$((STRIDE_SIZE * 8))
9182 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
9184 # prepare the read-ahead file
9185 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9186 cancel_lru_locks osc
9187 for BIDX in 2 4 8 16 32 64 128 256
9189 local BSIZE=$((BIDX*4096))
9190 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
9191 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
9192 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
9193 $LCTL set_param -n llite.*.read_ahead_stats 0
9194 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
9195 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
9196 cancel_lru_locks osc
9197 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
9202 run_test 101b "check stride-io mode read-ahead ================="
9205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9207 local STRIPE_SIZE=1048576
9208 local FILE_LENGTH=$((STRIPE_SIZE*100))
9213 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
9215 cancel_lru_locks osc
9216 $LCTL set_param osc.*.rpc_stats 0
9217 $READS -f $DIR/$tfile -s$FILE_LENGTH -b$rsize -n$nreads -t 180
9218 $LCTL get_param osc.*.rpc_stats
9219 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
9220 local stats=$($LCTL get_param -n $osc_rpc_stats)
9221 local lines=$(echo "$stats" | awk 'END {print NR;}')
9224 if [ $lines -le 20 ]; then
9225 echo "continue debug"
9228 for size in 1 2 4 8; do
9229 local rpc=$(echo "$stats" |
9230 awk '($1 == "'$size':") {print $2; exit; }')
9231 [ $rpc != 0 ] && ((size * PAGE_SIZE < rsize)) &&
9232 error "Small $((size*PAGE_SIZE)) read IO $rpc!"
9234 echo "$osc_rpc_stats check passed!"
9239 run_test 101c "check stripe_size aligned read-ahead ================="
9242 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9244 local file=$DIR/$tfile
9245 local sz_MB=${FILESIZE_101d:-80}
9246 local ra_MB=${READAHEAD_MB:-40}
9248 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
9249 [ $free_MB -lt $sz_MB ] &&
9250 skip "Need free space ${sz_MB}M, have ${free_MB}M"
9252 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
9253 $LFS setstripe -c -1 $file || error "setstripe failed"
9255 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
9256 echo Cancel LRU locks on lustre client to flush the client cache
9257 cancel_lru_locks osc
9259 echo Disable read-ahead
9260 local old_RA=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9261 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9262 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_RA" EXIT
9263 $LCTL get_param -n llite.*.max_read_ahead_mb
9265 echo "Reading the test file $file with read-ahead disabled"
9266 local sz_KB=$((sz_MB * 1024 / 4))
9267 # 10485760 bytes transferred in 0.000938 secs (11179579337 bytes/sec)
9268 # 104857600 bytes (105 MB) copied, 0.00876352 s, 12.0 GB/s
9269 local raOFF=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
9270 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
9272 echo "Cancel LRU locks on lustre client to flush the client cache"
9273 cancel_lru_locks osc
9274 echo Enable read-ahead with ${ra_MB}MB
9275 $LCTL set_param -n llite.*.max_read_ahead_mb=$ra_MB
9277 echo "Reading the test file $file with read-ahead enabled"
9278 local raON=$(LANG=C dd if=$file of=/dev/null bs=4k count=$sz_KB |&
9279 sed -e '/records/d' -e 's/.* \([0-9]*\.[0-9]*\) *s.*/\1/')
9281 echo "read-ahead disabled time read $raOFF"
9282 echo "read-ahead enabled time read $raON"
9285 wait_delete_completed
9287 # use awk for this check instead of bash because it handles decimals
9288 awk "{ exit !($raOFF < 1.0 || $raOFF > $raON) }" <<<"ignore_me" ||
9289 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
9291 run_test 101d "file read with and without read-ahead enabled"
9294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9296 local file=$DIR/$tfile
9297 local size_KB=500 #KB
9301 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
9302 local need_KB=$((count * size_KB))
9303 [[ $free_KB -le $need_KB ]] &&
9304 skip_env "Need free space $need_KB, have $free_KB"
9306 echo "Creating $count ${size_KB}K test files"
9307 for ((i = 0; i < $count; i++)); do
9308 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
9311 echo "Cancel LRU locks on lustre client to flush the client cache"
9312 cancel_lru_locks $OSC
9314 echo "Reset readahead stats"
9315 $LCTL set_param -n llite.*.read_ahead_stats 0
9317 for ((i = 0; i < $count; i++)); do
9318 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
9321 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9322 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9324 for ((i = 0; i < $count; i++)); do
9325 rm -rf $file.$i 2>/dev/null
9328 #10000 means 20% reads are missing in readahead
9329 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
9331 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
9334 which iozone || skip_env "no iozone installed"
9336 local old_debug=$($LCTL get_param debug)
9337 old_debug=${old_debug#*=}
9338 $LCTL set_param debug="reada mmap"
9340 # create a test file
9341 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
9343 echo Cancel LRU locks on lustre client to flush the client cache
9344 cancel_lru_locks osc
9346 echo Reset readahead stats
9347 $LCTL set_param -n llite.*.read_ahead_stats 0
9349 echo mmap read the file with small block size
9350 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
9353 echo checking missing pages
9354 $LCTL get_param llite.*.read_ahead_stats
9355 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9356 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9358 $LCTL set_param debug="$old_debug"
9359 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
9362 run_test 101f "check mmap read performance"
9364 test_101g_brw_size_test() {
9366 local pages=$((mb * 1048576 / PAGE_SIZE))
9367 local file=$DIR/$tfile
9369 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
9370 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
9371 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
9372 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
9376 stack_trap "rm -f $file" EXIT
9377 $LCTL set_param -n osc.*.rpc_stats=0
9379 # 10 RPCs should be enough for the test
9381 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
9382 { error "dd write ${mb} MB blocks failed"; return 3; }
9383 cancel_lru_locks osc
9384 dd of=/dev/null if=$file bs=${mb}M count=$count ||
9385 { error "dd write ${mb} MB blocks failed"; return 4; }
9387 # calculate number of full-sized read and write RPCs
9388 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
9389 sed -n '/pages per rpc/,/^$/p' |
9390 awk '/'$pages':/ { reads += $2; writes += $6 }; \
9391 END { print reads,writes }'))
9392 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
9394 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
9401 remote_ost_nodsh && skip "remote OST with nodsh"
9404 local osts=$(get_facets OST)
9405 local list=$(comma_list $(osts_nodes))
9406 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
9407 local brw_size="obdfilter.*.brw_size"
9409 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9411 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
9413 if { [ $OST1_VERSION -ge $(version_code 2.8.52) ] ||
9414 { [ $OST1_VERSION -ge $(version_code 2.7.17) ] &&
9415 [ $OST1_VERSION -lt $(version_code 2.7.50) ]; }; } &&
9416 { [ $CLIENT_VERSION -ge $(version_code 2.8.52) ] ||
9417 { [ $CLIENT_VERSION -ge $(version_code 2.7.17) ] &&
9418 [ $CLIENT_VERSION -lt $(version_code 2.7.50) ]; }; }; then
9420 [ $OST1_VERSION -ge $(version_code 2.9.52) ] &&
9423 if [[ $orig_mb -lt 16 ]]; then
9424 save_lustre_params $osts "$brw_size" > $p
9425 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
9426 error "set 16MB RPC size failed"
9428 echo "remount client to enable new RPC size"
9429 remount_client $MOUNT || error "remount_client failed"
9432 test_101g_brw_size_test 16 || error "16MB RPC test failed"
9433 # should be able to set brw_size=12, but no rpc_stats for that
9434 test_101g_brw_size_test 8 || error "8MB RPC test failed"
9437 test_101g_brw_size_test 4 || error "4MB RPC test failed"
9439 if [[ $orig_mb -lt 16 ]]; then
9440 restore_lustre_params < $p
9441 remount_client $MOUNT || error "remount_client restore failed"
9444 rm -f $p $DIR/$tfile
9446 run_test 101g "Big bulk(4/16 MiB) readahead"
9449 $LFS setstripe -i 0 -c 1 $DIR/$tfile
9451 dd if=/dev/zero of=$DIR/$tfile bs=1M count=70 ||
9452 error "dd 70M file failed"
9453 echo Cancel LRU locks on lustre client to flush the client cache
9454 cancel_lru_locks osc
9456 echo "Reset readahead stats"
9457 $LCTL set_param -n llite.*.read_ahead_stats 0
9459 echo "Read 10M of data but cross 64M bundary"
9460 dd if=$DIR/$tfile of=/dev/null bs=10M skip=6 count=1
9461 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9462 get_named_value 'misses' | cut -d" " -f1 | calc_total)
9463 [ $miss -eq 1 ] || error "expected miss 1 but got $miss"
9464 rm -f $p $DIR/$tfile
9466 run_test 101h "Readahead should cover current read window"
9469 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 ||
9470 error "dd 10M file failed"
9472 local max_per_file_mb=$($LCTL get_param -n \
9473 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
9474 cancel_lru_locks osc
9475 stack_trap "$LCTL set_param llite.*.max_read_ahead_per_file_mb=$max_per_file_mb"
9476 $LCTL set_param llite.*.max_read_ahead_per_file_mb=1 ||
9477 error "set max_read_ahead_per_file_mb to 1 failed"
9479 echo "Reset readahead stats"
9480 $LCTL set_param llite.*.read_ahead_stats=0
9482 dd if=$DIR/$tfile of=/dev/null bs=2M
9484 $LCTL get_param llite.*.read_ahead_stats
9485 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9486 awk '/misses/ { print $2 }')
9487 [ $miss -eq 5 ] || error "expected misses 5 but got $miss"
9490 run_test 101i "allow current readahead to exceed reservation"
9493 $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
9494 error "setstripe $DIR/$tfile failed"
9495 local file_size=$((1048576 * 16))
9496 local old_ra=$($LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1)
9497 stack_trap "$LCTL set_param -n llite.*.max_read_ahead_mb $old_ra" EXIT
9499 echo Disable read-ahead
9500 $LCTL set_param -n llite.*.max_read_ahead_mb=0
9502 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$(($file_size / 1048576))
9503 for blk in $PAGE_SIZE 1048576 $file_size; do
9504 cancel_lru_locks osc
9505 echo "Reset readahead stats"
9506 $LCTL set_param -n llite.*.read_ahead_stats=0
9507 local count=$(($file_size / $blk))
9508 dd if=$DIR/$tfile bs=$blk count=$count of=/dev/null
9509 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
9510 get_named_value 'failed to fast read' |
9511 cut -d" " -f1 | calc_total)
9512 $LCTL get_param -n llite.*.read_ahead_stats
9513 [ $miss -eq $count ] || error "expected $count got $miss"
9516 rm -f $p $DIR/$tfile
9518 run_test 101j "A complete read block should be submitted when no RA"
9521 test_mkdir $DIR/$tdir
9522 chown $RUNAS_ID $DIR/$tdir
9525 STRIPE_COUNT=$OSTCOUNT
9526 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
9528 trap cleanup_test102 EXIT
9530 $1 $LFS setstripe -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
9532 for num in 1 2 3 4; do
9533 for count in $(seq 1 $STRIPE_COUNT); do
9534 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
9535 local size=`expr $STRIPE_SIZE \* $num`
9536 local file=file"$num-$idx-$count"
9537 $1 $LFS setstripe -S $size -i $idx -c $count $file
9543 $1 tar cf $TMP/f102.tar $tdir --xattrs
9549 rm -rf $DIR/d0.sanity/d102
9553 [ "$UID" != 0 ] && skip "must run as root"
9554 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
9555 skip_env "must have user_xattr"
9557 [ -z "$(which setfattr 2>/dev/null)" ] &&
9558 skip_env "could not find setfattr"
9560 local testfile=$DIR/$tfile
9563 echo "set/get xattr..."
9564 setfattr -n trusted.name1 -v value1 $testfile ||
9565 error "setfattr -n trusted.name1=value1 $testfile failed"
9566 getfattr -n trusted.name1 $testfile 2> /dev/null |
9567 grep "trusted.name1=.value1" ||
9568 error "$testfile missing trusted.name1=value1"
9570 setfattr -n user.author1 -v author1 $testfile ||
9571 error "setfattr -n user.author1=author1 $testfile failed"
9572 getfattr -n user.author1 $testfile 2> /dev/null |
9573 grep "user.author1=.author1" ||
9574 error "$testfile missing trusted.author1=author1"
9577 setfattr -n trusted.name2 -v value2 $testfile ||
9578 error "$testfile unable to set trusted.name2"
9579 setfattr -n trusted.name3 -v value3 $testfile ||
9580 error "$testfile unable to set trusted.name3"
9581 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
9582 grep "trusted.name" | wc -l) -eq 3 ] ||
9583 error "$testfile missing 3 trusted.name xattrs"
9585 setfattr -n user.author2 -v author2 $testfile ||
9586 error "$testfile unable to set user.author2"
9587 setfattr -n user.author3 -v author3 $testfile ||
9588 error "$testfile unable to set user.author3"
9589 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
9590 grep "user.author" | wc -l) -eq 3 ] ||
9591 error "$testfile missing 3 user.author xattrs"
9593 echo "remove xattr..."
9594 setfattr -x trusted.name1 $testfile ||
9595 error "$testfile error deleting trusted.name1"
9596 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
9597 error "$testfile did not delete trusted.name1 xattr"
9599 setfattr -x user.author1 $testfile ||
9600 error "$testfile error deleting user.author1"
9601 echo "set lustre special xattr ..."
9602 $LFS setstripe -c1 $testfile
9603 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
9604 awk -F "=" '/trusted.lov/ { print $2 }' )
9605 setfattr -n "trusted.lov" -v $lovea $testfile ||
9606 error "$testfile doesn't ignore setting trusted.lov again"
9607 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
9608 error "$testfile allow setting invalid trusted.lov"
9611 run_test 102a "user xattr test =================================="
9613 check_102b_layout() {
9615 local testfile=$DIR/$tfile
9617 echo "test layout '$layout'"
9618 $LFS setstripe $layout $testfile || error "setstripe failed"
9619 $LFS getstripe -y $testfile
9621 echo "get/set/list trusted.lov xattr ..." # b=10930
9622 local value=$(getfattr -n trusted.lov -e hex $testfile | grep trusted)
9623 [[ "$value" =~ "trusted.lov" ]] ||
9624 error "can't get trusted.lov from $testfile"
9625 local stripe_count_orig=$($LFS getstripe -c $testfile) ||
9626 error "getstripe failed"
9628 $MCREATE $testfile.2 || error "mcreate $testfile.2 failed"
9630 value=$(cut -d= -f2 <<<$value)
9631 # LU-13168: truncated xattr should fail if short lov_user_md header
9632 [ $CLIENT_VERSION -lt $(version_code 2.13.53) ] &&
9633 lens="${#value}" || lens="$(seq 4 2 ${#value})"
9634 for len in $lens; do
9635 echo "setfattr $len $testfile.2"
9636 setfattr -n trusted.lov -v ${value:0:$len} $testfile.2 &&
9637 [ $len -lt 66 ] && error "short xattr len=$len worked"
9639 local stripe_size=$($LFS getstripe -S $testfile.2)
9640 local stripe_count=$($LFS getstripe -c $testfile.2)
9641 [[ $stripe_size -eq 65536 ]] ||
9642 error "stripe size $stripe_size != 65536"
9643 [[ $stripe_count -eq $stripe_count_orig ]] ||
9644 error "stripe count $stripe_count != $stripe_count_orig"
9645 rm $testfile $testfile.2
9649 [ -z "$(which setfattr 2>/dev/null)" ] &&
9650 skip_env "could not find setfattr"
9651 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9653 # check plain layout
9654 check_102b_layout -S 65536 -i 1 -c $OSTCOUNT
9656 # and also check composite layout
9657 check_102b_layout -E 1M -S 65536 -i 1 -c $OSTCOUNT -Eeof -S4M
9660 run_test 102b "getfattr/setfattr for trusted.lov EAs"
9663 [ -z "$(which setfattr 2>/dev/null)" ] &&
9664 skip_env "could not find setfattr"
9665 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9667 # b10930: get/set/list lustre.lov xattr
9668 echo "get/set/list lustre.lov xattr ..."
9669 test_mkdir $DIR/$tdir
9670 chown $RUNAS_ID $DIR/$tdir
9671 local testfile=$DIR/$tdir/$tfile
9672 $RUNAS $LFS setstripe -S 65536 -i 1 -c $OSTCOUNT $testfile ||
9673 error "setstripe failed"
9674 local STRIPECOUNT=$($RUNAS $LFS getstripe -c $testfile) ||
9675 error "getstripe failed"
9676 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
9677 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
9679 local testfile2=${testfile}2
9680 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
9681 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
9683 $RUNAS $MCREATE $testfile2
9684 $RUNAS setfattr -n lustre.lov -v $value $testfile2
9685 local stripe_size=$($RUNAS $LFS getstripe -S $testfile2)
9686 local stripe_count=$($RUNAS $LFS getstripe -c $testfile2)
9687 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
9688 [ $stripe_count -eq $STRIPECOUNT ] ||
9689 error "stripe count $stripe_count != $STRIPECOUNT"
9691 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
9693 compare_stripe_info1() {
9694 local stripe_index_all_zero=true
9696 for num in 1 2 3 4; do
9697 for count in $(seq 1 $STRIPE_COUNT); do
9698 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
9699 local size=$((STRIPE_SIZE * num))
9700 local file=file"$num-$offset-$count"
9701 stripe_size=$($LFS getstripe -S $PWD/$file)
9702 [[ $stripe_size -ne $size ]] &&
9703 error "$file: size $stripe_size != $size"
9704 stripe_count=$($LFS getstripe -c $PWD/$file)
9705 # allow fewer stripes to be created, ORI-601
9706 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
9707 error "$file: count $stripe_count != $count"
9708 stripe_index=$($LFS getstripe -i $PWD/$file)
9709 [[ $stripe_index -ne 0 ]] &&
9710 stripe_index_all_zero=false
9714 $stripe_index_all_zero &&
9715 error "all files are being extracted starting from OST index 0"
9719 have_xattrs_include() {
9720 tar --help | grep -q xattrs-include &&
9721 echo --xattrs-include="lustre.*"
9725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9726 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9728 XINC=$(have_xattrs_include)
9730 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9732 compare_stripe_info1
9734 run_test 102d "tar restore stripe info from tarfile,not keep osts"
9737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9738 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9740 XINC=$(have_xattrs_include)
9742 test_mkdir $DIR/$tdir.restore
9744 tar cf - --xattrs $tdir | tar xf - \
9745 -C $DIR/$tdir.restore --xattrs $XINC
9746 cd $DIR/$tdir.restore/$tdir
9747 compare_stripe_info1
9749 run_test 102f "tar copy files, not keep osts"
9752 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
9753 skip "must have user_xattr"
9754 [ -z "$(which setfattr 2>/dev/null)" ] &&
9755 skip_env "could not find setfattr"
9756 [ -z "$(which getfattr 2>/dev/null)" ] &&
9757 skip_env "could not find getfattr"
9759 local xsize=${1:-1024} # in bytes
9760 local file=$DIR/$tfile
9761 local value="$(generate_string $xsize)"
9762 local xbig=trusted.big
9766 log "save $xbig on $file"
9769 setfattr -n $xbig -v $value $file ||
9770 error "saving $xbig on $file failed"
9772 setfattr -n $xbig -v $value $file &&
9773 error "saving $xbig on $file succeeded"
9777 local orig=$(get_xattr_value $xbig $file)
9778 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
9780 local xsml=trusted.sml
9781 log "save $xsml on $file"
9782 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
9784 local new=$(get_xattr_value $xbig $file)
9785 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
9787 log "grow $xsml on $file"
9788 setfattr -n $xsml -v "$value" $file ||
9789 error "growing $xsml on $file failed"
9791 new=$(get_xattr_value $xbig $file)
9792 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
9793 log "$xbig still valid after growing $xsml"
9798 test_102h() { # bug 15777
9801 run_test 102h "grow xattr from inside inode to external block"
9804 large_xattr_enabled || skip_env "ea_inode feature disabled"
9806 echo "setting xattr of max xattr size: $(max_xattr_size)"
9807 grow_xattr $(max_xattr_size)
9809 echo "setting xattr of > max xattr size: $(max_xattr_size) + 10"
9810 echo "This should fail:"
9811 grow_xattr $(($(max_xattr_size) + 10)) 1
9813 run_test 102ha "grow xattr from inside inode to external inode"
9815 test_102i() { # bug 17038
9816 [ -z "$(which getfattr 2>/dev/null)" ] &&
9817 skip "could not find getfattr"
9820 ln -s $DIR/$tfile $DIR/${tfile}link
9821 getfattr -n trusted.lov $DIR/$tfile ||
9822 error "lgetxattr on $DIR/$tfile failed"
9823 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
9824 grep -i "no such attr" ||
9825 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
9826 rm -f $DIR/$tfile $DIR/${tfile}link
9828 run_test 102i "lgetxattr test on symbolic link ============"
9831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9832 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9834 XINC=$(have_xattrs_include)
9835 setup_test102 "$RUNAS"
9836 chown $RUNAS_ID $DIR/$tdir
9837 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
9839 compare_stripe_info1 "$RUNAS"
9841 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
9844 [ -z "$(which setfattr 2>/dev/null)" ] &&
9845 skip "could not find setfattr"
9848 # b22187 just check that does not crash for regular file.
9849 setfattr -n trusted.lov $DIR/$tfile
9850 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
9851 local test_kdir=$DIR/$tdir
9852 test_mkdir $test_kdir
9853 local default_size=$($LFS getstripe -S $test_kdir)
9854 local default_count=$($LFS getstripe -c $test_kdir)
9855 local default_offset=$($LFS getstripe -i $test_kdir)
9856 $LFS setstripe -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
9857 error 'dir setstripe failed'
9858 setfattr -n trusted.lov $test_kdir
9859 local stripe_size=$($LFS getstripe -S $test_kdir)
9860 local stripe_count=$($LFS getstripe -c $test_kdir)
9861 local stripe_offset=$($LFS getstripe -i $test_kdir)
9862 [ $stripe_size -eq $default_size ] ||
9863 error "stripe size $stripe_size != $default_size"
9864 [ $stripe_count -eq $default_count ] ||
9865 error "stripe count $stripe_count != $default_count"
9866 [ $stripe_offset -eq $default_offset ] ||
9867 error "stripe offset $stripe_offset != $default_offset"
9868 rm -rf $DIR/$tfile $test_kdir
9870 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
9873 [ -z "$(which getfattr 2>/dev/null)" ] &&
9874 skip "could not find getfattr"
9876 # LU-532 trusted. xattr is invisible to non-root
9877 local testfile=$DIR/$tfile
9881 echo "listxattr as user..."
9882 chown $RUNAS_ID $testfile
9883 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
9884 grep -q "trusted" &&
9885 error "$testfile trusted xattrs are user visible"
9889 run_test 102l "listxattr size test =================================="
9891 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
9892 local path=$DIR/$tfile
9895 listxattr_size_check $path || error "listattr_size_check $path failed"
9897 run_test 102m "Ensure listxattr fails on small bufffer ========"
9901 getxattr() { # getxattr path name
9902 # Return the base64 encoding of the value of xattr name on path.
9906 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
9908 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9910 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
9912 getfattr --absolute-names --encoding=base64 --name=$name $path |
9913 awk -F= -v name=$name '$1 == name {
9914 print substr($0, index($0, "=") + 1);
9918 test_102n() { # LU-4101 mdt: protect internal xattrs
9919 [ -z "$(which setfattr 2>/dev/null)" ] &&
9920 skip "could not find setfattr"
9921 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
9923 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
9926 local file0=$DIR/$tfile.0
9927 local file1=$DIR/$tfile.1
9928 local xattr0=$TMP/$tfile.0
9929 local xattr1=$TMP/$tfile.1
9930 local namelist="lov lma lmv link fid version som hsm"
9934 rm -rf $file0 $file1 $xattr0 $xattr1
9937 # Get 'before' xattrs of $file1.
9938 getfattr --absolute-names --dump --match=- $file1 > $xattr0
9940 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
9941 namelist+=" lfsck_namespace"
9942 for name in $namelist; do
9943 # Try to copy xattr from $file0 to $file1.
9944 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9946 setfattr --name=trusted.$name --value="$value" $file1 ||
9947 error "setxattr 'trusted.$name' failed"
9949 # Try to set a garbage xattr.
9950 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9952 if [[ x$name == "xlov" ]]; then
9953 setfattr --name=trusted.lov --value="$value" $file1 &&
9954 error "setxattr invalid 'trusted.lov' success"
9956 setfattr --name=trusted.$name --value="$value" $file1 ||
9957 error "setxattr invalid 'trusted.$name' failed"
9960 # Try to remove the xattr from $file1. We don't care if this
9961 # appears to succeed or fail, we just don't want there to be
9962 # any changes or crashes.
9963 setfattr --remove=$trusted.$name $file1 2> /dev/null
9966 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
9969 # Try to copy xattr from $file0 to $file1.
9970 value=$(getxattr $file0 trusted.$name 2> /dev/null)
9972 setfattr --name=trusted.$name --value="$value" $file1 ||
9973 error "setxattr 'trusted.$name' failed"
9975 # Try to set a garbage xattr.
9976 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
9978 setfattr --name=trusted.$name --value="$value" $file1 ||
9979 error "setxattr 'trusted.$name' failed"
9981 # Try to remove the xattr from $file1. We don't care if this
9982 # appears to succeed or fail, we just don't want there to be
9983 # any changes or crashes.
9984 setfattr --remove=$trusted.$name $file1 2> /dev/null
9987 # Get 'after' xattrs of file1.
9988 getfattr --absolute-names --dump --match=- $file1 > $xattr1
9990 if ! diff $xattr0 $xattr1; then
9991 error "before and after xattrs of '$file1' differ"
9994 rm -rf $file0 $file1 $xattr0 $xattr1
9998 run_test 102n "silently ignore setxattr on internal trusted xattrs"
10000 test_102p() { # LU-4703 setxattr did not check ownership
10001 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
10002 skip "MDS needs to be at least 2.5.56"
10004 local testfile=$DIR/$tfile
10008 echo "setfacl as user..."
10009 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
10010 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
10012 echo "setfattr as user..."
10013 setfacl -m "u:$RUNAS_ID:---" $testfile
10014 $RUNAS setfattr -x system.posix_acl_access $testfile
10015 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
10017 run_test 102p "check setxattr(2) correctly fails without permission"
10020 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
10021 skip "MDS needs to be at least 2.6.92"
10023 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
10025 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
10028 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
10029 skip "MDS needs to be at least 2.6.93"
10031 touch $DIR/$tfile || error "touch"
10032 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
10033 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
10034 rm $DIR/$tfile || error "rm"
10037 mkdir -p $DIR/$tdir || error "mkdir"
10038 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10039 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10040 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10041 error "$testfile error deleting user.author1"
10042 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10043 grep "user.$(basename $tdir)" &&
10044 error "$tdir did not delete user.$(basename $tdir)"
10045 rmdir $DIR/$tdir || error "rmdir"
10048 test_mkdir $DIR/$tdir
10049 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
10050 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
10051 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
10052 error "$testfile error deleting user.author1"
10053 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
10054 grep "user.$(basename $tdir)" &&
10055 error "$tdir did not delete user.$(basename $tdir)"
10056 rmdir $DIR/$tdir || error "rm striped dir"
10058 run_test 102r "set EAs with empty values"
10061 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10062 skip "MDS needs to be at least 2.11.52"
10064 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10066 save_lustre_params client "llite.*.xattr_cache" > $save
10068 for cache in 0 1; do
10069 lctl set_param llite.*.xattr_cache=$cache
10072 touch $DIR/$tfile || error "touch"
10073 for prefix in lustre security system trusted user; do
10074 # Note getxattr() may fail with 'Operation not
10075 # supported' or 'No such attribute' depending
10076 # on prefix and cache.
10077 getfattr -n $prefix.n102s $DIR/$tfile &&
10078 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
10082 restore_lustre_params < $save
10084 run_test 102s "getting nonexistent xattrs should fail"
10087 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
10088 skip "MDS needs to be at least 2.11.52"
10090 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
10092 save_lustre_params client "llite.*.xattr_cache" > $save
10094 for cache in 0 1; do
10095 lctl set_param llite.*.xattr_cache=$cache
10097 for buf_size in 0 256; do
10099 touch $DIR/$tfile || error "touch"
10100 setfattr -n user.multiop $DIR/$tfile
10101 $MULTIOP $DIR/$tfile oa$buf_size ||
10102 error "cannot get zero length xattr value (buf_size = $buf_size)"
10106 restore_lustre_params < $save
10108 run_test 102t "zero length xattr values handled correctly"
10112 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
10117 [ "$UID" != 0 ] && skip "must run as root"
10118 $GSS && skip_env "could not run under gss"
10119 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
10120 skip_env "must have acl enabled"
10121 [ -z "$(which setfacl 2>/dev/null)" ] &&
10122 skip_env "could not find setfacl"
10123 remote_mds_nodsh && skip "remote MDS with nodsh"
10125 gpasswd -a daemon bin # LU-5641
10126 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
10128 declare -a identity_old
10130 for num in $(seq $MDSCOUNT); do
10131 switch_identity $num true || identity_old[$num]=$?
10134 SAVE_UMASK=$(umask)
10136 mkdir -p $DIR/$tdir
10139 echo "performing cp ..."
10140 run_acl_subtest cp || error "run_acl_subtest cp failed"
10141 echo "performing getfacl-noacl..."
10142 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
10143 echo "performing misc..."
10144 run_acl_subtest misc || error "misc test failed"
10145 echo "performing permissions..."
10146 run_acl_subtest permissions || error "permissions failed"
10147 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
10148 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
10149 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
10150 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
10152 echo "performing permissions xattr..."
10153 run_acl_subtest permissions_xattr ||
10154 error "permissions_xattr failed"
10156 echo "performing setfacl..."
10157 run_acl_subtest setfacl || error "setfacl test failed"
10159 # inheritance test got from HP
10160 echo "performing inheritance..."
10161 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
10162 chmod +x make-tree || error "chmod +x failed"
10163 run_acl_subtest inheritance || error "inheritance test failed"
10166 echo "LU-974 ignore umask when acl is enabled..."
10167 run_acl_subtest 974 || error "LU-974 umask test failed"
10168 if [ $MDSCOUNT -ge 2 ]; then
10169 run_acl_subtest 974_remote ||
10170 error "LU-974 umask test failed under remote dir"
10173 echo "LU-2561 newly created file is same size as directory..."
10174 if [ "$mds1_FSTYPE" != "zfs" ]; then
10175 run_acl_subtest 2561 || error "LU-2561 test failed"
10177 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
10180 run_acl_subtest 4924 || error "LU-4924 test failed"
10185 for num in $(seq $MDSCOUNT); do
10186 if [ "${identity_old[$num]}" = 1 ]; then
10187 switch_identity $num false || identity_old[$num]=$?
10191 run_test 103a "acl test"
10197 for U in {0..511}; do
10199 local O=$(printf "%04o" $U)
10201 umask $(printf "%04o" $((511 ^ $O)))
10202 $LFS setstripe -c 1 $DIR/$tfile.s$O
10203 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
10205 (( $S == ($O & 0666) )) ||
10206 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
10208 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
10209 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
10210 (( $S == ($O & 0666) )) ||
10211 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
10213 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
10214 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
10215 (( $S == ($O & 0666) )) ||
10216 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
10217 rm -f $DIR/$tfile.[smp]$0
10221 # limit the concurrently running threads to 64. LU-11878
10222 local idx=$((U % 64))
10223 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
10228 run_test 103b "umask lfs setstripe"
10231 mkdir -p $DIR/$tdir
10232 cp -rp $DIR/$tdir $DIR/$tdir.bak
10234 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
10235 error "$DIR/$tdir shouldn't contain default ACL"
10236 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
10237 error "$DIR/$tdir.bak shouldn't contain default ACL"
10240 run_test 103c "'cp -rp' won't set empty acl"
10243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10246 lfs df || error "lfs df failed"
10247 lfs df -ih || error "lfs df -ih failed"
10248 lfs df -h $DIR || error "lfs df -h $DIR failed"
10249 lfs df -i $DIR || error "lfs df -i $DIR failed"
10250 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
10251 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
10253 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
10254 lctl --device %$OSC deactivate
10255 lfs df || error "lfs df with deactivated OSC failed"
10256 lctl --device %$OSC activate
10257 # wait the osc back to normal
10258 wait_osc_import_ready client ost
10260 lfs df || error "lfs df with reactivated OSC failed"
10263 run_test 104a "lfs df [-ih] [path] test ========================="
10266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10267 [ $RUNAS_ID -eq $UID ] &&
10268 skip_env "RUNAS_ID = UID = $UID -- skipping"
10270 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
10271 grep "Permission denied" | wc -l)))
10272 if [ $denied_cnt -ne 0 ]; then
10273 error "lfs check servers test failed"
10276 run_test 104b "$RUNAS lfs check servers test ===================="
10279 # doesn't work on 2.4 kernels
10281 if $(flock_is_enabled); then
10282 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
10284 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
10288 run_test 105a "flock when mounted without -o flock test ========"
10292 if $(flock_is_enabled); then
10293 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
10295 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
10299 run_test 105b "fcntl when mounted without -o flock test ========"
10303 if $(flock_is_enabled); then
10304 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
10306 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
10310 run_test 105c "lockf when mounted without -o flock test"
10312 test_105d() { # bug 15924
10313 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10315 test_mkdir $DIR/$tdir
10316 flock_is_enabled || skip_env "mount w/o flock enabled"
10317 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
10318 $LCTL set_param fail_loc=0x80000315
10319 flocks_test 2 $DIR/$tdir
10321 run_test 105d "flock race (should not freeze) ========"
10323 test_105e() { # bug 22660 && 22040
10324 flock_is_enabled || skip_env "mount w/o flock enabled"
10327 flocks_test 3 $DIR/$tfile
10329 run_test 105e "Two conflicting flocks from same process"
10331 test_106() { #bug 10921
10332 test_mkdir $DIR/$tdir
10333 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
10334 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
10336 run_test 106 "attempt exec of dir followed by chown of that dir"
10339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10347 local save_pattern=$(sysctl -n kernel.core_pattern)
10348 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
10349 sysctl -w kernel.core_pattern=$file
10350 sysctl -w kernel.core_uses_pid=0
10352 ulimit -c unlimited
10358 kill -s 11 $SLEEPPID
10360 if [ -e $file ]; then
10361 size=`stat -c%s $file`
10362 [ $size -eq 0 ] && error "Fail to create core file $file"
10364 error "Fail to create core file $file"
10367 sysctl -w kernel.core_pattern=$save_pattern
10368 sysctl -w kernel.core_uses_pid=$save_uses_pid
10371 run_test 107 "Coredump on SIG"
10374 test_mkdir $DIR/$tdir
10375 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
10376 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
10377 error "mkdir with 256 char should fail, but did not"
10378 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
10379 error "create with 255 char failed"
10380 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
10381 error "create with 256 char should fail, but did not"
10386 run_test 110 "filename length checking"
10389 # Purpose: To verify dynamic thread (OSS) creation.
10392 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10393 remote_ost_nodsh && skip "remote OST with nodsh"
10395 # Lustre does not stop service threads once they are started.
10396 # Reset number of running threads to default.
10401 local save_params="$TMP/sanity-$TESTNAME.parameters"
10403 # Get ll_ost_io count before I/O
10404 OSTIO_pre=$(do_facet ost1 \
10405 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
10406 # Exit if lustre is not running (ll_ost_io not running).
10407 [ -z "$OSTIO_pre" ] && error "no OSS threads"
10409 echo "Starting with $OSTIO_pre threads"
10410 local thread_max=$((OSTIO_pre * 2))
10411 local rpc_in_flight=$((thread_max * 2))
10412 # Number of I/O Process proposed to be started.
10414 local facets=$(get_facets OST)
10416 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
10417 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
10419 # Set in_flight to $rpc_in_flight
10420 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
10421 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
10422 nfiles=${rpc_in_flight}
10423 # Set ost thread_max to $thread_max
10424 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
10426 # 5 Minutes should be sufficient for max number of OSS
10427 # threads(thread_max) to be created.
10431 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
10432 test_mkdir $DIR/$tdir
10433 for i in $(seq $nfiles); do
10434 local file=$DIR/$tdir/${tfile}-$i
10435 $LFS setstripe -c -1 -i 0 $file
10436 ($WTL $file $timeout)&
10439 # I/O Started - Wait for thread_started to reach thread_max or report
10440 # error if thread_started is more than thread_max.
10441 echo "Waiting for thread_started to reach thread_max"
10442 local thread_started=0
10443 local end_time=$((SECONDS + timeout))
10445 while [ $SECONDS -le $end_time ] ; do
10447 # Get ost i/o thread_started count.
10448 thread_started=$(do_facet ost1 \
10450 ost.OSS.ost_io.threads_started | cut -d= -f2")
10451 # Break out if thread_started is equal/greater than thread_max
10452 if [[ $thread_started -ge $thread_max ]]; then
10453 echo ll_ost_io thread_started $thread_started, \
10454 equal/greater than thread_max $thread_max
10460 # Cleanup - We have the numbers, Kill i/o jobs if running.
10461 jobcount=($(jobs -p))
10462 for i in $(seq 0 $((${#jobcount[@]}-1)))
10464 kill -9 ${jobcount[$i]}
10465 if [ $? -ne 0 ] ; then
10467 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
10471 # Cleanup files left by WTL binary.
10472 for i in $(seq $nfiles); do
10473 local file=$DIR/$tdir/${tfile}-$i
10475 if [ $? -ne 0 ] ; then
10476 echo "Warning: Failed to delete file $file"
10480 restore_lustre_params <$save_params
10481 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
10483 # Error out if no new thread has started or Thread started is greater
10485 if [[ $thread_started -le $OSTIO_pre ||
10486 $thread_started -gt $thread_max ]]; then
10487 error "ll_ost_io: thread_started $thread_started" \
10488 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
10489 "No new thread started or thread started greater " \
10493 run_test 115 "verify dynamic thread creation===================="
10496 wait_delete_completed
10497 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
10498 echo "OST kbytes available: ${AVAIL[@]}"
10503 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
10504 #echo OST $i: ${AVAIL[i]}kb
10505 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
10509 if [[ ${AVAIL[i]} -lt $MINV ]]; then
10514 echo "Min free space: OST $MINI: $MINV"
10515 echo "Max free space: OST $MAXI: $MAXV"
10518 test_116a() { # was previously test_116()
10519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10520 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10521 remote_mds_nodsh && skip "remote MDS with nodsh"
10523 echo -n "Free space priority "
10524 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
10529 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
10530 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
10531 trap simple_cleanup_common EXIT
10533 # Check if we need to generate uneven OSTs
10534 test_mkdir -p $DIR/$tdir/OST${MINI}
10535 local FILL=$((MINV / 4))
10536 local DIFF=$((MAXV - MINV))
10537 local DIFF2=$((DIFF * 100 / MINV))
10539 local threshold=$(do_facet $SINGLEMDS \
10540 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
10541 threshold=${threshold%%%}
10542 echo -n "Check for uneven OSTs: "
10543 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
10545 if [[ $DIFF2 -gt $threshold ]]; then
10547 echo "Don't need to fill OST$MINI"
10549 # generate uneven OSTs. Write 2% over the QOS threshold value
10551 DIFF=$((threshold - DIFF2 + 2))
10552 DIFF2=$((MINV * DIFF / 100))
10553 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
10554 $LFS setstripe -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
10555 error "setstripe failed"
10556 DIFF=$((DIFF2 / 2048))
10558 while [ $i -lt $DIFF ]; do
10560 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
10561 bs=2M count=1 2>/dev/null
10570 DIFF=$((MAXV - MINV))
10571 DIFF2=$((DIFF * 100 / MINV))
10572 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
10573 if [ $DIFF2 -gt $threshold ]; then
10576 echo "failed - QOS mode won't be used"
10577 simple_cleanup_common
10578 skip "QOS imbalance criteria not met"
10586 # now fill using QOS
10587 $LFS setstripe -c 1 $DIR/$tdir
10588 FILL=$((FILL / 200))
10589 if [ $FILL -gt 600 ]; then
10592 echo "writing $FILL files to QOS-assigned OSTs"
10594 while [ $i -lt $FILL ]; do
10596 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
10597 count=1 2>/dev/null
10600 echo "wrote $i 200k files"
10604 echo "Note: free space may not be updated, so measurements might be off"
10606 DIFF2=$((MAXV - MINV))
10607 echo "free space delta: orig $DIFF final $DIFF2"
10608 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
10609 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
10610 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
10611 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
10612 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
10613 if [[ $DIFF -gt 0 ]]; then
10614 FILL=$((DIFF2 * 100 / DIFF - 100))
10615 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
10618 # Figure out which files were written where
10619 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10620 awk '/'$MINI1': / {print $2; exit}')
10622 MINC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10623 echo "$MINC files created on smaller OST $MINI1"
10624 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
10625 awk '/'$MAXI1': / {print $2; exit}')
10627 MAXC=$($LFS getstripe --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
10628 echo "$MAXC files created on larger OST $MAXI1"
10629 if [[ $MINC -gt 0 ]]; then
10630 FILL=$((MAXC * 100 / MINC - 100))
10631 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
10633 [[ $MAXC -gt $MINC ]] ||
10634 error_ignore LU-9 "stripe QOS didn't balance free space"
10635 simple_cleanup_common
10637 run_test 116a "stripe QOS: free space balance ==================="
10639 test_116b() { # LU-2093
10640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10641 remote_mds_nodsh && skip "remote MDS with nodsh"
10643 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
10644 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
10645 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
10646 [ -z "$old_rr" ] && skip "no QOS"
10647 do_facet $SINGLEMDS lctl set_param \
10648 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
10649 mkdir -p $DIR/$tdir
10650 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
10651 createmany -o $DIR/$tdir/f- 20 || error "can't create"
10652 do_facet $SINGLEMDS lctl set_param fail_loc=0
10654 do_facet $SINGLEMDS lctl set_param \
10655 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
10657 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
10659 test_117() # bug 10891
10661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10663 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
10664 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
10665 lctl set_param fail_loc=0x21e
10666 > $DIR/$tfile || error "truncate failed"
10667 lctl set_param fail_loc=0
10668 echo "Truncate succeeded."
10671 run_test 117 "verify osd extend =========="
10673 NO_SLOW_RESENDCOUNT=4
10674 export OLD_RESENDCOUNT=""
10675 set_resend_count () {
10676 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
10677 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
10678 lctl set_param -n $PROC_RESENDCOUNT $1
10679 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
10682 # for reduce test_118* time (b=14842)
10683 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10685 # Reset async IO behavior after error case
10687 FILE=$DIR/reset_async
10689 # Ensure all OSCs are cleared
10690 $LFS setstripe -c -1 $FILE
10691 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
10696 test_118a() #bug 11710
10698 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10702 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10703 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10704 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10706 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10707 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10712 run_test 118a "verify O_SYNC works =========="
10716 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10717 remote_ost_nodsh && skip "remote OST with nodsh"
10721 #define OBD_FAIL_SRV_ENOENT 0x217
10722 set_nodes_failloc "$(osts_nodes)" 0x217
10723 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10725 set_nodes_failloc "$(osts_nodes)" 0
10726 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10727 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10730 if [[ $RC -eq 0 ]]; then
10731 error "Must return error due to dropped pages, rc=$RC"
10735 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10736 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10740 echo "Dirty pages not leaked on ENOENT"
10742 # Due to the above error the OSC will issue all RPCs syncronously
10743 # until a subsequent RPC completes successfully without error.
10744 $MULTIOP $DIR/$tfile Ow4096yc
10749 run_test 118b "Reclaim dirty pages on fatal error =========="
10753 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10755 # for 118c, restore the original resend count, LU-1940
10756 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
10757 set_resend_count $OLD_RESENDCOUNT
10758 remote_ost_nodsh && skip "remote OST with nodsh"
10762 #define OBD_FAIL_OST_EROFS 0x216
10763 set_nodes_failloc "$(osts_nodes)" 0x216
10765 # multiop should block due to fsync until pages are written
10766 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10770 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10771 error "Multiop failed to block on fsync, pid=$MULTIPID"
10774 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10776 if [[ $WRITEBACK -eq 0 ]]; then
10777 error "No page in writeback, writeback=$WRITEBACK"
10780 set_nodes_failloc "$(osts_nodes)" 0
10783 if [[ $RC -ne 0 ]]; then
10784 error "Multiop fsync failed, rc=$RC"
10787 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10788 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10790 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10791 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10795 echo "Dirty pages flushed via fsync on EROFS"
10798 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
10800 # continue to use small resend count to reduce test_118* time (b=14842)
10801 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
10805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10806 remote_ost_nodsh && skip "remote OST with nodsh"
10810 #define OBD_FAIL_OST_BRW_PAUSE_BULK
10811 set_nodes_failloc "$(osts_nodes)" 0x214
10812 # multiop should block due to fsync until pages are written
10813 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10817 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
10818 error "Multiop failed to block on fsync, pid=$MULTIPID"
10821 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10823 if [[ $WRITEBACK -eq 0 ]]; then
10824 error "No page in writeback, writeback=$WRITEBACK"
10827 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
10828 set_nodes_failloc "$(osts_nodes)" 0
10830 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10831 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10833 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10834 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10838 echo "Dirty pages gaurenteed flushed via fsync"
10841 run_test 118d "Fsync validation inject a delay of the bulk =========="
10844 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10848 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
10849 lctl set_param fail_loc=0x8000040a
10851 # Should simulate EINVAL error which is fatal
10852 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10854 if [[ $RC -eq 0 ]]; then
10855 error "Must return error due to dropped pages, rc=$RC"
10858 lctl set_param fail_loc=0x0
10860 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10861 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10862 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10864 if [[ $LOCKED -ne 0 ]]; then
10865 error "Locked pages remain in cache, locked=$LOCKED"
10868 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10869 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10873 echo "No pages locked after fsync"
10878 run_test 118f "Simulate unrecoverable OSC side error =========="
10881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10885 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
10886 lctl set_param fail_loc=0x406
10888 # simulate local -ENOMEM
10889 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10892 lctl set_param fail_loc=0
10893 if [[ $RC -eq 0 ]]; then
10894 error "Must return error due to dropped pages, rc=$RC"
10897 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10898 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10899 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10901 if [[ $LOCKED -ne 0 ]]; then
10902 error "Locked pages remain in cache, locked=$LOCKED"
10905 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10906 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10910 echo "No pages locked after fsync"
10915 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
10918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10919 remote_ost_nodsh && skip "remote OST with nodsh"
10923 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10924 set_nodes_failloc "$(osts_nodes)" 0x20e
10925 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10926 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
10929 set_nodes_failloc "$(osts_nodes)" 0
10930 if [[ $RC -eq 0 ]]; then
10931 error "Must return error due to dropped pages, rc=$RC"
10934 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10935 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10936 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
10938 if [[ $LOCKED -ne 0 ]]; then
10939 error "Locked pages remain in cache, locked=$LOCKED"
10942 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10943 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10947 echo "No pages locked after fsync"
10951 run_test 118h "Verify timeout in handling recoverables errors =========="
10953 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10956 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10957 remote_ost_nodsh && skip "remote OST with nodsh"
10961 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
10962 set_nodes_failloc "$(osts_nodes)" 0x20e
10964 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
10965 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
10968 set_nodes_failloc "$(osts_nodes)" 0
10972 if [[ $RC -ne 0 ]]; then
10973 error "got error, but should be not, rc=$RC"
10976 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
10977 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
10978 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
10979 if [[ $LOCKED -ne 0 ]]; then
10980 error "Locked pages remain in cache, locked=$LOCKED"
10983 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
10984 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
10988 echo "No pages locked after fsync"
10992 run_test 118i "Fix error before timeout in recoverable error =========="
10994 [ "$SLOW" = "no" ] && set_resend_count 4
10997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10998 remote_ost_nodsh && skip "remote OST with nodsh"
11002 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
11003 set_nodes_failloc "$(osts_nodes)" 0x220
11005 # return -EIO from OST
11006 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
11008 set_nodes_failloc "$(osts_nodes)" 0x0
11009 if [[ $RC -eq 0 ]]; then
11010 error "Must return error due to dropped pages, rc=$RC"
11013 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
11014 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
11015 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
11016 if [[ $LOCKED -ne 0 ]]; then
11017 error "Locked pages remain in cache, locked=$LOCKED"
11020 # in recoverable error on OST we want resend and stay until it finished
11021 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
11022 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
11026 echo "No pages locked after fsync"
11030 run_test 118j "Simulate unrecoverable OST side error =========="
11034 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11035 remote_ost_nodsh && skip "remote OSTs with nodsh"
11037 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
11038 set_nodes_failloc "$(osts_nodes)" 0x20e
11039 test_mkdir $DIR/$tdir
11041 for ((i=0;i<10;i++)); do
11042 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
11043 error "dd to $DIR/$tdir/$tfile-$i failed" )&
11050 set_nodes_failloc "$(osts_nodes)" 0
11053 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
11055 test_118l() # LU-646
11057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11059 test_mkdir $DIR/$tdir
11060 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
11063 run_test 118l "fsync dir"
11065 test_118m() # LU-3066
11067 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11069 test_mkdir $DIR/$tdir
11070 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
11073 run_test 118m "fdatasync dir ========="
11075 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
11082 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11083 remote_ost_nodsh && skip "remote OSTs with nodsh"
11085 # Sleep to avoid a cached response.
11086 #define OBD_STATFS_CACHE_SECONDS 1
11089 # Inject a 10 second delay in the OST_STATFS handler.
11090 #define OBD_FAIL_OST_STATFS_DELAY 0x242
11091 set_nodes_failloc "$(osts_nodes)" 0x242
11094 stat --file-system $MOUNT > /dev/null
11097 set_nodes_failloc "$(osts_nodes)" 0
11099 if ((end - begin > 20)); then
11100 error "statfs took $((end - begin)) seconds, expected 10"
11103 run_test 118n "statfs() sends OST_STATFS requests in parallel"
11105 test_119a() # bug 11737
11107 BSIZE=$((512 * 1024))
11108 directio write $DIR/$tfile 0 1 $BSIZE
11109 # We ask to read two blocks, which is more than a file size.
11110 # directio will indicate an error when requested and actual
11111 # sizes aren't equeal (a normal situation in this case) and
11112 # print actual read amount.
11113 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
11114 if [ "$NOB" != "$BSIZE" ]; then
11115 error "read $NOB bytes instead of $BSIZE"
11119 run_test 119a "Short directIO read must return actual read amount"
11121 test_119b() # bug 11737
11123 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11125 $LFS setstripe -c 2 $DIR/$tfile || error "setstripe failed"
11126 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
11128 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
11129 error "direct read failed"
11132 run_test 119b "Sparse directIO read must return actual read amount"
11134 test_119c() # bug 13099
11137 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
11138 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
11141 run_test 119c "Testing for direct read hitting hole"
11143 test_119d() # bug 15950
11145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11147 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
11148 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
11150 $LFS setstripe $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
11151 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
11152 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
11153 lctl set_param fail_loc=0x40d
11154 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
11157 cat $DIR/$tfile > /dev/null &
11158 lctl set_param fail_loc=0
11161 log "the DIO writes have completed, now wait for the reads (should not block very long)"
11163 [ -n "`ps h -p $pid_reads -o comm`" ] && \
11164 error "the read rpcs have not completed in 2s"
11166 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
11168 run_test 119d "The DIO path should try to send a new rpc once one is completed"
11171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11172 remote_mds_nodsh && skip "remote MDS with nodsh"
11173 test_mkdir -i0 -c1 $DIR/$tdir
11174 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11175 skip_env "no early lock cancel on server"
11177 lru_resize_disable mdc
11178 lru_resize_disable osc
11179 cancel_lru_locks mdc
11180 # asynchronous object destroy at MDT could cause bl ast to client
11181 cancel_lru_locks osc
11183 stat $DIR/$tdir > /dev/null
11184 can1=$(do_facet mds1 \
11185 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11186 awk '/ldlm_cancel/ {print $2}')
11187 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11188 awk '/ldlm_bl_callback/ {print $2}')
11189 test_mkdir -i0 -c1 $DIR/$tdir/d1
11190 can2=$(do_facet mds1 \
11191 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11192 awk '/ldlm_cancel/ {print $2}')
11193 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11194 awk '/ldlm_bl_callback/ {print $2}')
11195 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11196 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11197 lru_resize_enable mdc
11198 lru_resize_enable osc
11200 run_test 120a "Early Lock Cancel: mkdir test"
11203 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11204 remote_mds_nodsh && skip "remote MDS with nodsh"
11205 test_mkdir $DIR/$tdir
11206 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11207 skip_env "no early lock cancel on server"
11209 lru_resize_disable mdc
11210 lru_resize_disable osc
11211 cancel_lru_locks mdc
11212 stat $DIR/$tdir > /dev/null
11213 can1=$(do_facet $SINGLEMDS \
11214 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11215 awk '/ldlm_cancel/ {print $2}')
11216 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11217 awk '/ldlm_bl_callback/ {print $2}')
11218 touch $DIR/$tdir/f1
11219 can2=$(do_facet $SINGLEMDS \
11220 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11221 awk '/ldlm_cancel/ {print $2}')
11222 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11223 awk '/ldlm_bl_callback/ {print $2}')
11224 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11225 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11226 lru_resize_enable mdc
11227 lru_resize_enable osc
11229 run_test 120b "Early Lock Cancel: create test"
11232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11233 remote_mds_nodsh && skip "remote MDS with nodsh"
11234 test_mkdir -i0 -c1 $DIR/$tdir
11235 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11236 skip "no early lock cancel on server"
11238 lru_resize_disable mdc
11239 lru_resize_disable osc
11240 test_mkdir -i0 -c1 $DIR/$tdir/d1
11241 test_mkdir -i0 -c1 $DIR/$tdir/d2
11242 touch $DIR/$tdir/d1/f1
11243 cancel_lru_locks mdc
11244 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
11245 can1=$(do_facet mds1 \
11246 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11247 awk '/ldlm_cancel/ {print $2}')
11248 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11249 awk '/ldlm_bl_callback/ {print $2}')
11250 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11251 can2=$(do_facet mds1 \
11252 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11253 awk '/ldlm_cancel/ {print $2}')
11254 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11255 awk '/ldlm_bl_callback/ {print $2}')
11256 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11257 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11258 lru_resize_enable mdc
11259 lru_resize_enable osc
11261 run_test 120c "Early Lock Cancel: link test"
11264 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11265 remote_mds_nodsh && skip "remote MDS with nodsh"
11266 test_mkdir -i0 -c1 $DIR/$tdir
11267 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11268 skip_env "no early lock cancel on server"
11270 lru_resize_disable mdc
11271 lru_resize_disable osc
11273 cancel_lru_locks mdc
11274 stat $DIR/$tdir > /dev/null
11275 can1=$(do_facet mds1 \
11276 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11277 awk '/ldlm_cancel/ {print $2}')
11278 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11279 awk '/ldlm_bl_callback/ {print $2}')
11280 chmod a+x $DIR/$tdir
11281 can2=$(do_facet mds1 \
11282 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11283 awk '/ldlm_cancel/ {print $2}')
11284 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11285 awk '/ldlm_bl_callback/ {print $2}')
11286 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11287 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11288 lru_resize_enable mdc
11289 lru_resize_enable osc
11291 run_test 120d "Early Lock Cancel: setattr test"
11294 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11295 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11296 skip_env "no early lock cancel on server"
11297 remote_mds_nodsh && skip "remote MDS with nodsh"
11299 local dlmtrace_set=false
11301 test_mkdir -i0 -c1 $DIR/$tdir
11302 lru_resize_disable mdc
11303 lru_resize_disable osc
11304 ! $LCTL get_param debug | grep -q dlmtrace &&
11305 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
11306 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
11307 cancel_lru_locks mdc
11308 cancel_lru_locks osc
11309 dd if=$DIR/$tdir/f1 of=/dev/null
11310 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
11311 # XXX client can not do early lock cancel of OST lock
11312 # during unlink (LU-4206), so cancel osc lock now.
11314 cancel_lru_locks osc
11315 can1=$(do_facet mds1 \
11316 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11317 awk '/ldlm_cancel/ {print $2}')
11318 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11319 awk '/ldlm_bl_callback/ {print $2}')
11320 unlink $DIR/$tdir/f1
11322 can2=$(do_facet mds1 \
11323 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11324 awk '/ldlm_cancel/ {print $2}')
11325 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11326 awk '/ldlm_bl_callback/ {print $2}')
11327 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
11328 $LCTL dk $TMP/cancel.debug.txt
11329 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
11330 $LCTL dk $TMP/blocking.debug.txt
11331 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
11332 lru_resize_enable mdc
11333 lru_resize_enable osc
11335 run_test 120e "Early Lock Cancel: unlink test"
11338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11339 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11340 skip_env "no early lock cancel on server"
11341 remote_mds_nodsh && skip "remote MDS with nodsh"
11343 test_mkdir -i0 -c1 $DIR/$tdir
11344 lru_resize_disable mdc
11345 lru_resize_disable osc
11346 test_mkdir -i0 -c1 $DIR/$tdir/d1
11347 test_mkdir -i0 -c1 $DIR/$tdir/d2
11348 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
11349 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
11350 cancel_lru_locks mdc
11351 cancel_lru_locks osc
11352 dd if=$DIR/$tdir/d1/f1 of=/dev/null
11353 dd if=$DIR/$tdir/d2/f2 of=/dev/null
11354 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
11355 # XXX client can not do early lock cancel of OST lock
11356 # during rename (LU-4206), so cancel osc lock now.
11358 cancel_lru_locks osc
11359 can1=$(do_facet mds1 \
11360 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11361 awk '/ldlm_cancel/ {print $2}')
11362 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11363 awk '/ldlm_bl_callback/ {print $2}')
11364 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
11366 can2=$(do_facet mds1 \
11367 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11368 awk '/ldlm_cancel/ {print $2}')
11369 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11370 awk '/ldlm_bl_callback/ {print $2}')
11371 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
11372 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
11373 lru_resize_enable mdc
11374 lru_resize_enable osc
11376 run_test 120f "Early Lock Cancel: rename test"
11379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11380 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
11381 skip_env "no early lock cancel on server"
11382 remote_mds_nodsh && skip "remote MDS with nodsh"
11384 lru_resize_disable mdc
11385 lru_resize_disable osc
11387 echo create $count files
11388 test_mkdir $DIR/$tdir
11389 cancel_lru_locks mdc
11390 cancel_lru_locks osc
11393 can0=$(do_facet $SINGLEMDS \
11394 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11395 awk '/ldlm_cancel/ {print $2}')
11396 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11397 awk '/ldlm_bl_callback/ {print $2}')
11398 createmany -o $DIR/$tdir/f $count
11400 can1=$(do_facet $SINGLEMDS \
11401 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11402 awk '/ldlm_cancel/ {print $2}')
11403 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11404 awk '/ldlm_bl_callback/ {print $2}')
11406 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
11407 echo rm $count files
11410 can2=$(do_facet $SINGLEMDS \
11411 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
11412 awk '/ldlm_cancel/ {print $2}')
11413 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
11414 awk '/ldlm_bl_callback/ {print $2}')
11416 echo total: $count removes in $((t2-t1))
11417 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
11419 # wait for commitment of removal
11420 lru_resize_enable mdc
11421 lru_resize_enable osc
11423 run_test 120g "Early Lock Cancel: performance test"
11425 test_121() { #bug #10589
11426 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11429 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
11430 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
11431 lctl set_param fail_loc=0x310
11432 cancel_lru_locks osc > /dev/null
11433 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
11434 lctl set_param fail_loc=0
11435 [[ $reads -eq $writes ]] ||
11436 error "read $reads blocks, must be $writes blocks"
11438 run_test 121 "read cancel race ========="
11440 test_123a_base() { # was test 123, statahead(bug 11401)
11444 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
11445 log "testing UP system. Performance may be lower than expected."
11450 test_mkdir $DIR/$tdir
11451 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
11452 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
11454 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
11455 createmany -o $DIR/$tdir/$tfile $j $((i - j))
11457 max=$(lctl get_param -n llite.*.statahead_max | head -n 1)
11458 lctl set_param -n llite.*.statahead_max 0
11459 lctl get_param llite.*.statahead_max
11460 cancel_lru_locks mdc
11461 cancel_lru_locks osc
11463 time $lsx $DIR/$tdir | wc -l
11465 delta=$((etime - stime))
11466 log "$lsx $i files without statahead: $delta sec"
11467 lctl set_param llite.*.statahead_max=$max
11469 swrong=$(lctl get_param -n llite.*.statahead_stats |
11470 grep "statahead wrong:" | awk '{print $3}')
11471 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
11472 cancel_lru_locks mdc
11473 cancel_lru_locks osc
11475 time $lsx $DIR/$tdir | wc -l
11477 delta_sa=$((etime - stime))
11478 log "$lsx $i files with statahead: $delta_sa sec"
11479 lctl get_param -n llite.*.statahead_stats
11480 ewrong=$(lctl get_param -n llite.*.statahead_stats |
11481 grep "statahead wrong:" | awk '{print $3}')
11483 [[ $swrong -lt $ewrong ]] &&
11484 log "statahead was stopped, maybe too many locks held!"
11485 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
11487 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
11488 max=$(lctl get_param -n llite.*.statahead_max |
11490 lctl set_param -n llite.*.statahead_max 0
11491 lctl get_param llite.*.statahead_max
11492 cancel_lru_locks mdc
11493 cancel_lru_locks osc
11495 time $lsx $DIR/$tdir | wc -l
11497 delta=$((etime - stime))
11498 log "$lsx $i files again without statahead: $delta sec"
11499 lctl set_param llite.*.statahead_max=$max
11500 if [ $((delta_sa * 100 > delta * 105 && delta_sa > delta + 2)) ]; then
11501 if [ $SLOWOK -eq 0 ]; then
11502 error "$lsx $i files is slower with statahead!"
11504 log "$lsx $i files is slower with statahead!"
11510 [ $delta -gt 20 ] && break
11511 [ $delta -gt 8 ] && MULT=$((50 / delta))
11512 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
11520 delta=$((etime - stime))
11521 log "rm -r $DIR/$tdir/: $delta seconds"
11523 lctl get_param -n llite.*.statahead_stats
11527 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11529 test_123a_base "ls -l"
11531 run_test 123aa "verify statahead work"
11534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11536 statx_supported || skip_env "Test must be statx() syscall supported"
11538 test_123a_base "$STATX -l"
11540 run_test 123ab "verify statahead work by using statx"
11543 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11545 statx_supported || skip_env "Test must be statx() syscall supported"
11552 cancel_lru_locks $OSC
11553 rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
11554 agl_before=$($LCTL get_param -n llite.*.statahead_stats |
11555 awk '/agl.total:/ {print $3}')
11556 test_123a_base "$STATX -c \"%n %i %A %h %u %g %W %X %Z\" -D"
11557 test_123a_base "$STATX --cached=always -D"
11558 agl_after=$($LCTL get_param -n llite.*.statahead_stats |
11559 awk '/agl.total:/ {print $3}')
11560 [ $agl_before -eq $agl_after ] ||
11561 error "Should not trigger AGL thread - $agl_before:$agl_after"
11562 rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
11563 [ $rpcs_after -eq $rpcs_before ] ||
11564 error "$STATX should not send glimpse RPCs to $OSC"
11566 run_test 123ac "verify statahead work by using statx without glimpse RPCs"
11568 test_123b () { # statahead(bug 15027)
11569 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11571 test_mkdir $DIR/$tdir
11572 createmany -o $DIR/$tdir/$tfile-%d 1000
11574 cancel_lru_locks mdc
11575 cancel_lru_locks osc
11577 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
11578 lctl set_param fail_loc=0x80000803
11579 ls -lR $DIR/$tdir > /dev/null
11581 lctl set_param fail_loc=0x0
11582 lctl get_param -n llite.*.statahead_stats
11587 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
11590 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
11592 test_mkdir -i 0 -c 1 $DIR/$tdir.0
11593 test_mkdir -i 1 -c 1 $DIR/$tdir.1
11594 touch $DIR/$tdir.1/{1..3}
11595 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
11597 remount_client $MOUNT
11599 $MULTIOP $DIR/$tdir.0 Q
11601 # let statahead to complete
11602 ls -l $DIR/$tdir.0 > /dev/null
11604 testid=$(echo $TESTNAME | tr '_' ' ')
11605 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
11606 error "statahead warning" || true
11608 run_test 123c "Can not initialize inode warning on DNE statahead"
11611 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11612 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11613 skip_env "no lru resize on server"
11617 test_mkdir $DIR/$tdir
11619 log "create $NR files at $DIR/$tdir"
11620 createmany -o $DIR/$tdir/f $NR ||
11621 error "failed to create $NR files in $DIR/$tdir"
11623 cancel_lru_locks mdc
11624 ls -l $DIR/$tdir > /dev/null
11628 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
11629 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
11630 LRU_SIZE=$($LCTL get_param -n $PARAM)
11631 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
11632 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
11634 log "NS=$(basename $NSDIR)"
11639 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
11640 skip "Not enough cached locks created!"
11642 log "LRU=$LRU_SIZE"
11646 # We know that lru resize allows one client to hold $LIMIT locks
11647 # for 10h. After that locks begin to be killed by client.
11649 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
11651 if [ $LIMIT -lt $LRU_SIZE ]; then
11652 skip "Limit is too small $LIMIT"
11655 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
11656 # killing locks. Some time was spent for creating locks. This means
11657 # that up to the moment of sleep finish we must have killed some of
11658 # them (10-100 locks). This depends on how fast ther were created.
11659 # Many of them were touched in almost the same moment and thus will
11660 # be killed in groups.
11661 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
11663 # Use $LRU_SIZE_B here to take into account real number of locks
11664 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
11665 local LRU_SIZE_B=$LRU_SIZE
11667 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
11668 log "OLD_LVF=$OLD_LVF"
11669 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
11671 # Let's make sure that we really have some margin. Client checks
11672 # cached locks every 10 sec.
11673 SLEEP=$((SLEEP+20))
11674 log "Sleep ${SLEEP} sec"
11676 while ((SEC<$SLEEP)); do
11680 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
11681 echo -n "$LRU_SIZE"
11684 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
11685 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
11687 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
11688 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
11689 unlinkmany $DIR/$tdir/f $NR
11693 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
11694 log "unlink $NR files at $DIR/$tdir"
11695 unlinkmany $DIR/$tdir/f $NR
11697 run_test 124a "lru resize ======================================="
11699 get_max_pool_limit()
11701 local limit=$($LCTL get_param \
11702 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
11704 for l in $limit; do
11705 if [[ $l -gt $max ]]; then
11713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11714 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11715 skip_env "no lru resize on server"
11717 LIMIT=$(get_max_pool_limit)
11719 NR=$(($(default_lru_size)*20))
11720 if [[ $NR -gt $LIMIT ]]; then
11721 log "Limit lock number by $LIMIT locks"
11725 IFree=$(mdsrate_inodes_available)
11726 if [ $IFree -lt $NR ]; then
11727 log "Limit lock number by $IFree inodes"
11731 lru_resize_disable mdc
11732 test_mkdir -p $DIR/$tdir/disable_lru_resize
11734 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
11735 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
11736 cancel_lru_locks mdc
11739 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11742 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11745 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
11749 nolruresize_delta=$((etime-stime))
11750 log "ls -la time: $nolruresize_delta seconds"
11751 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11752 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
11754 lru_resize_enable mdc
11755 test_mkdir -p $DIR/$tdir/enable_lru_resize
11757 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
11758 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
11759 cancel_lru_locks mdc
11762 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11765 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11768 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
11772 lruresize_delta=$((etime-stime))
11773 log "ls -la time: $lruresize_delta seconds"
11774 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
11776 if [ $lruresize_delta -gt $nolruresize_delta ]; then
11777 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
11778 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
11779 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
11781 log "lru resize performs the same with no lru resize"
11783 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
11785 run_test 124b "lru resize (performance test) ======================="
11788 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11789 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11790 skip_env "no lru resize on server"
11792 # cache ununsed locks on client
11794 cancel_lru_locks mdc
11795 test_mkdir $DIR/$tdir
11796 createmany -o $DIR/$tdir/f $nr ||
11797 error "failed to create $nr files in $DIR/$tdir"
11798 ls -l $DIR/$tdir > /dev/null
11800 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11801 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11802 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11803 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11804 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11806 # set lru_max_age to 1 sec
11807 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11808 echo "sleep $((recalc_p * 2)) seconds..."
11809 sleep $((recalc_p * 2))
11811 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11812 # restore lru_max_age
11813 $LCTL set_param -n $nsdir.lru_max_age $max_age
11814 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11815 unlinkmany $DIR/$tdir/f $nr
11817 run_test 124c "LRUR cancel very aged locks"
11820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11821 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
11822 skip_env "no lru resize on server"
11824 # cache ununsed locks on client
11827 lru_resize_disable mdc
11828 stack_trap "lru_resize_enable mdc" EXIT
11830 cancel_lru_locks mdc
11832 # asynchronous object destroy at MDT could cause bl ast to client
11833 test_mkdir $DIR/$tdir
11834 createmany -o $DIR/$tdir/f $nr ||
11835 error "failed to create $nr files in $DIR/$tdir"
11836 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
11838 ls -l $DIR/$tdir > /dev/null
11840 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11841 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11842 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
11843 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
11845 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
11847 # set lru_max_age to 1 sec
11848 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
11849 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
11851 echo "sleep $((recalc_p * 2)) seconds..."
11852 sleep $((recalc_p * 2))
11854 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
11856 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
11858 run_test 124d "cancel very aged locks if lru-resize diasbaled"
11860 test_125() { # 13358
11861 $LCTL get_param -n llite.*.client_type | grep -q local ||
11862 skip "must run as local client"
11863 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
11864 skip_env "must have acl enabled"
11865 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11867 test_mkdir $DIR/$tdir
11868 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
11869 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
11870 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
11872 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
11874 test_126() { # bug 12829/13455
11875 $GSS && skip_env "must run as gss disabled"
11876 $LCTL get_param -n llite.*.client_type | grep -q local ||
11877 skip "must run as local client"
11878 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
11880 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
11881 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
11883 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
11885 run_test 126 "check that the fsgid provided by the client is taken into account"
11887 test_127a() { # bug 15521
11888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11889 local name count samp unit min max sum sumsq
11891 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
11892 echo "stats before reset"
11893 $LCTL get_param osc.*.stats
11894 $LCTL set_param osc.*.stats=0
11895 local fsize=$((2048 * 1024))
11897 dd if=/dev/zero of=$DIR/$tfile bs=$fsize count=1
11898 cancel_lru_locks osc
11899 dd if=$DIR/$tfile of=/dev/null bs=$fsize
11901 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/$tfile.tmp
11902 stack_trap "rm -f $TMP/$tfile.tmp"
11903 while read name count samp unit min max sum sumsq; do
11904 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11905 [ ! $min ] && error "Missing min value for $name proc entry"
11906 eval $name=$count || error "Wrong proc format"
11909 read_bytes|write_bytes)
11910 [[ "$unit" =~ "bytes" ]] ||
11911 error "unit is not 'bytes': $unit"
11912 (( $min >= 4096 )) || error "min is too small: $min"
11913 (( $min <= $fsize )) || error "min is too big: $min"
11914 (( $max >= 4096 )) || error "max is too small: $max"
11915 (( $max <= $fsize )) || error "max is too big: $max"
11916 (( $sum == $fsize )) || error "sum is wrong: $sum"
11917 (( $sumsq >= ($fsize / 4096) * (4096 * 4096) )) ||
11918 error "sumsquare is too small: $sumsq"
11919 (( $sumsq <= $fsize * $fsize )) ||
11920 error "sumsquare is too big: $sumsq"
11922 ost_read|ost_write)
11923 [[ "$unit" =~ "usec" ]] ||
11924 error "unit is not 'usec': $unit"
11928 done < $DIR/$tfile.tmp
11930 #check that we actually got some stats
11931 [ "$read_bytes" ] || error "Missing read_bytes stats"
11932 [ "$write_bytes" ] || error "Missing write_bytes stats"
11933 [ "$read_bytes" != 0 ] || error "no read done"
11934 [ "$write_bytes" != 0 ] || error "no write done"
11936 run_test 127a "verify the client stats are sane"
11938 test_127b() { # bug LU-333
11939 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11940 local name count samp unit min max sum sumsq
11942 echo "stats before reset"
11943 $LCTL get_param llite.*.stats
11944 $LCTL set_param llite.*.stats=0
11946 # perform 2 reads and writes so MAX is different from SUM.
11947 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11948 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
11949 cancel_lru_locks osc
11950 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11951 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
11953 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
11954 stack_trap "rm -f $TMP/$tfile.tmp"
11955 while read name count samp unit min max sum sumsq; do
11956 echo "got name=$name count=$count unit=$unit min=$min max=$max"
11957 eval $name=$count || error "Wrong proc format"
11960 read_bytes|write_bytes)
11961 [[ "$unit" =~ "bytes" ]] ||
11962 error "unit is not 'bytes': $unit"
11963 (( $count == 2 )) || error "count is not 2: $count"
11964 (( $min == $PAGE_SIZE )) ||
11965 error "min is not $PAGE_SIZE: $min"
11966 (( $max == $PAGE_SIZE )) ||
11967 error "max is not $PAGE_SIZE: $max"
11968 (( $sum == $PAGE_SIZE * 2 )) ||
11969 error "sum is not $((PAGE_SIZE * 2)): $sum"
11972 [[ "$unit" =~ "usec" ]] ||
11973 error "unit is not 'usec': $unit"
11977 done < $TMP/$tfile.tmp
11979 #check that we actually got some stats
11980 [ "$read_bytes" ] || error "Missing read_bytes stats"
11981 [ "$write_bytes" ] || error "Missing write_bytes stats"
11982 [ "$read_bytes" != 0 ] || error "no read done"
11983 [ "$write_bytes" != 0 ] || error "no write done"
11985 run_test 127b "verify the llite client stats are sane"
11987 test_127c() { # LU-12394
11988 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11995 $LCTL set_param llite.*.extents_stats=1
11996 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
11998 # Use two stripes so there is enough space in default config
11999 $LFS setstripe -c 2 $DIR/$tfile
12001 # Extent stats start at 0-4K and go in power of two buckets
12002 # LL_HIST_START = 12 --> 2^12 = 4K
12003 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
12004 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
12006 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
12008 # Write and read, 2x each, second time at a non-zero offset
12009 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
12010 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
12011 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
12012 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
12016 $LCTL get_param llite.*.extents_stats
12019 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
12021 local bucket=$($LCTL get_param -n llite.*.extents_stats |
12023 reads=$(echo $bucket | awk '{print $5}')
12024 writes=$(echo $bucket | awk '{print $9}')
12025 [ "$reads" -eq $count ] ||
12026 error "$reads reads in < $bsize bucket, expect $count"
12027 [ "$writes" -eq $count ] ||
12028 error "$writes writes in < $bsize bucket, expect $count"
12031 # Test mmap write and read
12032 $LCTL set_param llite.*.extents_stats=c
12034 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
12035 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
12036 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
12038 $LCTL get_param llite.*.extents_stats
12040 count=$(((size*1024) / PAGE_SIZE))
12042 bsize=$((2 * PAGE_SIZE / 1024))K
12044 bucket=$($LCTL get_param -n llite.*.extents_stats |
12046 reads=$(echo $bucket | awk '{print $5}')
12047 writes=$(echo $bucket | awk '{print $9}')
12048 # mmap writes fault in the page first, creating an additonal read
12049 [ "$reads" -eq $((2 * count)) ] ||
12050 error "$reads reads in < $bsize bucket, expect $count"
12051 [ "$writes" -eq $count ] ||
12052 error "$writes writes in < $bsize bucket, expect $count"
12054 run_test 127c "test llite extent stats with regular & mmap i/o"
12056 test_128() { # bug 15212
12058 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
12063 result=$(grep error $TMP/$tfile.log)
12064 rm -f $DIR/$tfile $TMP/$tfile.log
12065 [ -z "$result" ] ||
12066 error "consecutive find's under interactive lfs failed"
12068 run_test 128 "interactive lfs for 2 consecutive find's"
12070 set_dir_limits () {
12075 local ldproc=/proc/fs/ldiskfs
12076 local facets=$(get_facets MDS)
12078 for facet in ${facets//,/ }; do
12079 canondev=$(ldiskfs_canon \
12080 *.$(convert_facet2label $facet).mntdev $facet)
12081 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
12082 ldproc=/sys/fs/ldiskfs
12083 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
12084 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
12088 check_mds_dmesg() {
12089 local facets=$(get_facets MDS)
12090 for facet in ${facets//,/ }; do
12091 do_facet $facet "dmesg | tail -3 | grep $1" && return 0
12097 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12098 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
12099 skip "Need MDS version with at least 2.5.56"
12100 if [ "$mds1_FSTYPE" != ldiskfs ]; then
12101 skip_env "ldiskfs only test"
12103 remote_mds_nodsh && skip "remote MDS with nodsh"
12106 local has_warning=false
12109 mkdir -p $DIR/$tdir
12111 # block size of mds1
12112 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8))
12113 set_dir_limits $maxsize $((maxsize * 6 / 8))
12114 stack_trap "set_dir_limits 0 0"
12115 stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true"
12116 local dirsize=$(stat -c%s "$DIR/$tdir")
12118 while (( $dirsize <= $maxsize )); do
12119 $MCREATE $DIR/$tdir/file_base_$nfiles
12121 # check two errors:
12122 # ENOSPC for ext4 max_dir_size, which has been used since
12123 # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0
12124 if (( rc == ENOSPC )); then
12126 echo "rc=$rc returned as expected after $nfiles files"
12128 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
12129 error "create failed w/o dir size limit"
12131 # messages may be rate limited if test is run repeatedly
12132 check_mds_dmesg '"is approaching max"' ||
12133 echo "warning message should be output"
12134 check_mds_dmesg '"has reached max"' ||
12135 echo "reached message should be output"
12137 dirsize=$(stat -c%s "$DIR/$tdir")
12139 [[ $dirsize -ge $maxsize ]] && return 0
12140 error "dirsize $dirsize < $maxsize after $nfiles files"
12141 elif (( rc != 0 )); then
12144 nfiles=$((nfiles + 1))
12145 dirsize=$(stat -c%s "$DIR/$tdir")
12148 error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles"
12150 run_test 129 "test directory size limit ========================"
12159 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12160 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12162 trap cleanup_130 EXIT RETURN
12164 local fm_file=$DIR/$tfile
12165 $LFS setstripe -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
12166 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
12167 error "dd failed for $fm_file"
12169 # LU-1795: test filefrag/FIEMAP once, even if unsupported
12170 filefrag -ves $fm_file
12172 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12173 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12174 [ $RC != 0 ] && error "filefrag $fm_file failed"
12176 filefrag_op=$(filefrag -ve -k $fm_file |
12177 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12178 lun=$($LFS getstripe -i $fm_file)
12180 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
12183 for line in $filefrag_op
12185 frag_lun=`echo $line | cut -d: -f5`
12186 ext_len=`echo $line | cut -d: -f4`
12187 if (( $frag_lun != $lun )); then
12189 error "FIEMAP on 1-stripe file($fm_file) failed"
12192 (( tot_len += ext_len ))
12195 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
12197 error "FIEMAP on 1-stripe file($fm_file) failed;"
12203 echo "FIEMAP on single striped file succeeded"
12205 run_test 130a "FIEMAP (1-stripe file)"
12208 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
12210 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12211 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12213 trap cleanup_130 EXIT RETURN
12215 local fm_file=$DIR/$tfile
12216 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12217 error "setstripe on $fm_file"
12218 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12219 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12221 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
12222 error "dd failed on $fm_file"
12224 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12225 filefrag_op=$(filefrag -ve -k $fm_file |
12226 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12228 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12229 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12234 for line in $filefrag_op
12236 frag_lun=$(echo $line | cut -d: -f5 |
12237 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12238 ext_len=$(echo $line | cut -d: -f4)
12239 if (( $frag_lun != $last_lun )); then
12240 if (( tot_len != 1024 )); then
12242 error "FIEMAP on $fm_file failed; returned " \
12243 "len $tot_len for OST $last_lun instead of 1024"
12246 (( num_luns += 1 ))
12250 (( tot_len += ext_len ))
12253 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
12255 error "FIEMAP on $fm_file failed; returned wrong number of " \
12256 "luns or wrong len for OST $last_lun"
12262 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
12264 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
12267 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12269 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12270 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12272 trap cleanup_130 EXIT RETURN
12274 local fm_file=$DIR/$tfile
12275 $LFS setstripe -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
12276 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12277 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12279 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
12280 error "dd failed on $fm_file"
12282 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12283 filefrag_op=$(filefrag -ve -k $fm_file |
12284 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12286 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12287 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12292 for line in $filefrag_op
12294 frag_lun=$(echo $line | cut -d: -f5 |
12295 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12296 ext_len=$(echo $line | cut -d: -f4)
12297 if (( $frag_lun != $last_lun )); then
12298 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
12299 if (( logical != 512 )); then
12301 error "FIEMAP on $fm_file failed; returned " \
12302 "logical start for lun $logical instead of 512"
12305 if (( tot_len != 512 )); then
12307 error "FIEMAP on $fm_file failed; returned " \
12308 "len $tot_len for OST $last_lun instead of 1024"
12311 (( num_luns += 1 ))
12315 (( tot_len += ext_len ))
12318 if (( num_luns != 2 || tot_len != 512 )); then
12320 error "FIEMAP on $fm_file failed; returned wrong number of " \
12321 "luns or wrong len for OST $last_lun"
12327 echo "FIEMAP on 2-stripe file with hole succeeded"
12329 run_test 130c "FIEMAP (2-stripe file with hole)"
12332 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
12334 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12335 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12337 trap cleanup_130 EXIT RETURN
12339 local fm_file=$DIR/$tfile
12340 $LFS setstripe -S 65536 -c $OSTCOUNT $fm_file ||
12341 error "setstripe on $fm_file"
12342 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12343 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12345 local actual_stripe_count=$($LFS getstripe -c $fm_file)
12346 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
12347 error "dd failed on $fm_file"
12349 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12350 filefrag_op=$(filefrag -ve -k $fm_file |
12351 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12353 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12354 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12359 for line in $filefrag_op
12361 frag_lun=$(echo $line | cut -d: -f5 |
12362 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12363 ext_len=$(echo $line | cut -d: -f4)
12364 if (( $frag_lun != $last_lun )); then
12365 if (( tot_len != 1024 )); then
12367 error "FIEMAP on $fm_file failed; returned " \
12368 "len $tot_len for OST $last_lun instead of 1024"
12371 (( num_luns += 1 ))
12375 (( tot_len += ext_len ))
12378 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
12380 error "FIEMAP on $fm_file failed; returned wrong number of " \
12381 "luns or wrong len for OST $last_lun"
12387 echo "FIEMAP on N-stripe file succeeded"
12389 run_test 130d "FIEMAP (N-stripe file)"
12392 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
12394 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12395 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
12397 trap cleanup_130 EXIT RETURN
12399 local fm_file=$DIR/$tfile
12400 $LFS setstripe -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
12401 [ "$(facet_fstype ost$(($($LFS getstripe -i $fm_file) + 1)))" = "zfs" ] &&
12402 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
12405 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
12406 for ((i = 0; i < $NUM_BLKS; i++))
12408 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
12411 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12412 filefrag_op=$(filefrag -ve -k $fm_file |
12413 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
12415 last_lun=$(echo $filefrag_op | cut -d: -f5 |
12416 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12421 for line in $filefrag_op
12423 frag_lun=$(echo $line | cut -d: -f5 |
12424 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
12425 ext_len=$(echo $line | cut -d: -f4)
12426 if (( $frag_lun != $last_lun )); then
12427 if (( tot_len != $EXPECTED_LEN )); then
12429 error "FIEMAP on $fm_file failed; returned " \
12430 "len $tot_len for OST $last_lun instead " \
12434 (( num_luns += 1 ))
12438 (( tot_len += ext_len ))
12441 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
12443 error "FIEMAP on $fm_file failed; returned wrong number " \
12444 "of luns or wrong len for OST $last_lun"
12450 echo "FIEMAP with continuation calls succeeded"
12452 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
12455 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
12456 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
12458 local fm_file=$DIR/$tfile
12459 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
12460 error "multiop create with lov_delay_create on $fm_file"
12462 filefrag -ves $fm_file || error "filefrag $fm_file failed"
12463 filefrag_extents=$(filefrag -vek $fm_file |
12464 awk '/extents? found/ { print $2 }')
12465 if [[ "$filefrag_extents" != "0" ]]; then
12466 error "FIEMAP on $fm_file failed; " \
12467 "returned $filefrag_extents expected 0"
12472 run_test 130f "FIEMAP (unstriped file)"
12474 # Test for writev/readv
12476 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
12477 error "writev test failed"
12478 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
12479 error "readv failed"
12482 run_test 131a "test iov's crossing stripe boundary for writev/readv"
12485 local fsize=$((524288 + 1048576 + 1572864))
12486 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
12487 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12488 error "append writev test failed"
12490 ((fsize += 1572864 + 1048576))
12491 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
12492 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
12493 error "append writev test failed"
12496 run_test 131b "test append writev"
12499 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
12502 run_test 131c "test read/write on file w/o objects"
12505 rwv -f $DIR/$tfile -w -n 1 1572864
12506 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
12507 if [ "$NOB" != 1572864 ]; then
12508 error "Short read filed: read $NOB bytes instead of 1572864"
12512 run_test 131d "test short read"
12515 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
12516 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
12517 error "read hitting hole failed"
12520 run_test 131e "test read hitting hole"
12529 mds*) res=$(do_facet $facet \
12530 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
12532 ost*) res=$(do_facet $facet \
12533 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
12535 *) error "Wrong facet '$facet'" ;;
12537 [ "$res" ] || error "The counter for $op on $facet was not incremented"
12538 # if the argument $3 is zero, it means any stat increment is ok.
12539 if [[ $want -gt 0 ]]; then
12540 local count=$(echo $res | awk '{ print $2 }')
12541 [[ $count -ne $want ]] &&
12542 error "The $op counter on $facet is $count, not $want"
12547 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12548 remote_ost_nodsh && skip "remote OST with nodsh"
12549 remote_mds_nodsh && skip "remote MDS with nodsh"
12550 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12551 skip_env "MDS doesn't support rename stats"
12553 local testdir=$DIR/${tdir}/stats_testdir
12555 mkdir -p $DIR/${tdir}
12558 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12559 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12561 # verify mdt stats first.
12562 mkdir ${testdir} || error "mkdir failed"
12563 check_stats $SINGLEMDS "mkdir" 1
12564 touch ${testdir}/${tfile} || error "touch failed"
12565 check_stats $SINGLEMDS "open" 1
12566 check_stats $SINGLEMDS "close" 1
12567 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
12568 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
12569 check_stats $SINGLEMDS "mknod" 2
12571 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
12572 check_stats $SINGLEMDS "unlink" 1
12573 rm -f ${testdir}/${tfile} || error "file remove failed"
12574 check_stats $SINGLEMDS "unlink" 2
12576 # remove working dir and check mdt stats again.
12577 rmdir ${testdir} || error "rmdir failed"
12578 check_stats $SINGLEMDS "rmdir" 1
12580 local testdir1=$DIR/${tdir}/stats_testdir1
12581 mkdir -p ${testdir}
12582 mkdir -p ${testdir1}
12583 touch ${testdir1}/test1
12584 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
12585 check_stats $SINGLEMDS "crossdir_rename" 1
12587 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
12588 check_stats $SINGLEMDS "samedir_rename" 1
12590 rm -rf $DIR/${tdir}
12592 run_test 133a "Verifying MDT stats ========================================"
12597 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12598 remote_ost_nodsh && skip "remote OST with nodsh"
12599 remote_mds_nodsh && skip "remote MDS with nodsh"
12601 local testdir=$DIR/${tdir}/stats_testdir
12603 mkdir -p ${testdir} || error "mkdir failed"
12604 touch ${testdir}/${tfile} || error "touch failed"
12605 cancel_lru_locks mdc
12608 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12609 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12611 # extra mdt stats verification.
12612 chmod 444 ${testdir}/${tfile} || error "chmod failed"
12613 check_stats $SINGLEMDS "setattr" 1
12614 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12615 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
12617 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
12618 check_stats $SINGLEMDS "getattr" 1
12620 rm -rf $DIR/${tdir}
12622 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
12623 # so the check below is not reliable
12624 [ $MDSCOUNT -eq 1 ] || return 0
12626 # Sleep to avoid a cached response.
12627 #define OBD_STATFS_CACHE_SECONDS 1
12629 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12630 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12631 $LFS df || error "lfs failed"
12632 check_stats $SINGLEMDS "statfs" 1
12634 # check aggregated statfs (LU-10018)
12635 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
12637 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
12640 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12641 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
12643 check_stats $SINGLEMDS "statfs" 1
12645 # We want to check that the client didn't send OST_STATFS to
12646 # ost1 but the MDT also uses OST_STATFS for precreate. So some
12647 # extra care is needed here.
12648 if remote_mds; then
12649 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
12650 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
12652 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
12653 [ "$res" ] && error "OST got STATFS"
12658 run_test 133b "Verifying extra MDT stats =================================="
12661 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12662 remote_ost_nodsh && skip "remote OST with nodsh"
12663 remote_mds_nodsh && skip "remote MDS with nodsh"
12665 local testdir=$DIR/$tdir/stats_testdir
12667 test_mkdir -p $testdir
12669 # verify obdfilter stats.
12670 $LFS setstripe -c 1 -i 0 $testdir/$tfile
12672 cancel_lru_locks osc
12673 wait_delete_completed
12676 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
12677 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
12679 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
12682 cancel_lru_locks osc
12683 check_stats ost1 "write" 1
12685 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
12686 check_stats ost1 "read" 1
12688 > $testdir/$tfile || error "truncate failed"
12689 check_stats ost1 "punch" 1
12691 rm -f $testdir/$tfile || error "file remove failed"
12692 wait_delete_completed
12693 check_stats ost1 "destroy" 1
12697 run_test 133c "Verifying OST stats ========================================"
12704 while [ $value -ge 2 ]; do
12709 if [ $orig -gt $order ]; then
12717 local size=('K' 'M' 'G' 'T');
12719 local size_string=$value
12721 while [ $value -ge 1024 ]; do
12722 if [ $i -gt 3 ]; then
12723 #T is the biggest unit we get here, if that is bigger,
12725 size_string=${value}T
12728 value=$((value >> 10))
12729 if [ $value -lt 1024 ]; then
12730 size_string=${value}${size[$i]}
12739 get_rename_size() {
12741 local context=${2:-.}
12742 local sample=$(do_facet $SINGLEMDS $LCTL \
12743 get_param mdt.$FSNAME-MDT0000.rename_stats |
12744 grep -A1 $context |
12745 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
12750 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12751 remote_ost_nodsh && skip "remote OST with nodsh"
12752 remote_mds_nodsh && skip "remote MDS with nodsh"
12753 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
12754 skip_env "MDS doesn't support rename stats"
12756 local testdir1=$DIR/${tdir}/stats_testdir1
12757 local testdir2=$DIR/${tdir}/stats_testdir2
12758 mkdir -p $DIR/${tdir}
12760 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12762 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
12763 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
12765 createmany -o $testdir1/test 512 || error "createmany failed"
12767 # check samedir rename size
12768 mv ${testdir1}/test0 ${testdir1}/test_0
12770 local testdir1_size=$(ls -l $DIR/${tdir} |
12771 awk '/stats_testdir1/ {print $5}')
12772 local testdir2_size=$(ls -l $DIR/${tdir} |
12773 awk '/stats_testdir2/ {print $5}')
12775 testdir1_size=$(order_2 $testdir1_size)
12776 testdir2_size=$(order_2 $testdir2_size)
12778 testdir1_size=$(size_in_KMGT $testdir1_size)
12779 testdir2_size=$(size_in_KMGT $testdir2_size)
12781 echo "source rename dir size: ${testdir1_size}"
12782 echo "target rename dir size: ${testdir2_size}"
12784 local cmd="do_facet $SINGLEMDS $LCTL "
12785 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
12787 eval $cmd || error "$cmd failed"
12788 local samedir=$($cmd | grep 'same_dir')
12789 local same_sample=$(get_rename_size $testdir1_size)
12790 [ -z "$samedir" ] && error "samedir_rename_size count error"
12791 [[ $same_sample -eq 1 ]] ||
12792 error "samedir_rename_size error $same_sample"
12793 echo "Check same dir rename stats success"
12795 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
12797 # check crossdir rename size
12798 mv ${testdir1}/test_0 ${testdir2}/test_0
12800 testdir1_size=$(ls -l $DIR/${tdir} |
12801 awk '/stats_testdir1/ {print $5}')
12802 testdir2_size=$(ls -l $DIR/${tdir} |
12803 awk '/stats_testdir2/ {print $5}')
12805 testdir1_size=$(order_2 $testdir1_size)
12806 testdir2_size=$(order_2 $testdir2_size)
12808 testdir1_size=$(size_in_KMGT $testdir1_size)
12809 testdir2_size=$(size_in_KMGT $testdir2_size)
12811 echo "source rename dir size: ${testdir1_size}"
12812 echo "target rename dir size: ${testdir2_size}"
12814 eval $cmd || error "$cmd failed"
12815 local crossdir=$($cmd | grep 'crossdir')
12816 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
12817 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
12818 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
12819 [[ $src_sample -eq 1 ]] ||
12820 error "crossdir_rename_size error $src_sample"
12821 [[ $tgt_sample -eq 1 ]] ||
12822 error "crossdir_rename_size error $tgt_sample"
12823 echo "Check cross dir rename stats success"
12824 rm -rf $DIR/${tdir}
12826 run_test 133d "Verifying rename_stats ========================================"
12829 remote_mds_nodsh && skip "remote MDS with nodsh"
12830 remote_ost_nodsh && skip "remote OST with nodsh"
12831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12833 local testdir=$DIR/${tdir}/stats_testdir
12834 local ctr f0 f1 bs=32768 count=42 sum
12836 mkdir -p ${testdir} || error "mkdir failed"
12838 $LFS setstripe -c 1 -i 0 ${testdir}/${tfile}
12840 for ctr in {write,read}_bytes; do
12842 cancel_lru_locks osc
12844 do_facet ost1 $LCTL set_param -n \
12845 "obdfilter.*.exports.clear=clear"
12847 if [ $ctr = write_bytes ]; then
12849 f1=${testdir}/${tfile}
12851 f0=${testdir}/${tfile}
12855 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
12858 cancel_lru_locks osc
12860 sum=$(do_facet ost1 $LCTL get_param \
12861 "obdfilter.*.exports.*.stats" |
12862 awk -v ctr=$ctr 'BEGIN { sum = 0 }
12863 $1 == ctr { sum += $7 }
12864 END { printf("%0.0f", sum) }')
12866 if ((sum != bs * count)); then
12867 error "Bad $ctr sum, expected $((bs * count)), got $sum"
12871 rm -rf $DIR/${tdir}
12873 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
12876 [[ $(lustre_version_code $facet) -ge $(version_code 2.7.65) ]] ||
12877 skip "too old lustre for get_param -R ($facet_ver)"
12879 # verifying readability.
12880 $LCTL get_param -R '*' &> /dev/null
12882 # Verifing writability with badarea_io.
12883 $LCTL list_param -FR '*' | grep '=' | tr -d = |
12884 egrep -v 'force_lbug|changelog_mask' | xargs badarea_io ||
12885 error "client badarea_io failed"
12887 # remount the FS in case writes/reads /proc break the FS
12888 cleanup || error "failed to unmount"
12889 setup || error "failed to setup"
12891 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
12894 remote_mds_nodsh && skip "remote MDS with nodsh"
12895 remote_ost_nodsh && skip "remote OST with nodsh"
12898 for facet in mds1 ost1; do
12899 local facet_ver=$(lustre_version_code $facet)
12900 if [ $facet_ver -ge $(version_code 2.7.65) ]; then
12901 do_facet $facet "$LCTL get_param -R '*'" &> /dev/null
12903 log "$facet: too old lustre for get_param -R"
12905 if [ $facet_ver -ge $(version_code 2.5.54) ]; then
12906 do_facet $facet "$LCTL list_param -FR '*' | grep '=' |
12907 tr -d = | egrep -v 'force_lbug|changelog_mask' |
12908 xargs badarea_io" ||
12909 error "$facet badarea_io failed"
12911 skip_noexit "$facet: too old lustre for get_param -R"
12915 # remount the FS in case writes/reads /proc break the FS
12916 cleanup || error "failed to unmount"
12917 setup || error "failed to setup"
12919 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
12922 remote_mds_nodsh && skip "remote MDS with nodsh"
12923 remote_ost_nodsh && skip "remote OST with nodsh"
12924 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
12925 skip "Need MDS version at least 2.9.54"
12928 for facet in client mds1 ost1; do
12929 # Get the list of files that are missing the terminating newline
12930 local plist=$(do_facet $facet
12931 $LCTL list_param -FR '*' | grep '=' | tr -d =)
12933 for ent in $plist; do
12934 local missing=$(do_facet $facet $LCTL get_param $ent \|\
12935 awk -v FS='\v' -v RS='\v\v' \
12936 "'END { if(NR>0 && \\\$NF !~ /.*\\\n\$/) \
12937 print FILENAME}'" 2>/dev/null)
12938 [ -z $missing ] || {
12939 do_facet $facet $LCTL get_param $ent | od -An -tx1
12940 error "file does not end with newline: $facet-$ent"
12945 run_test 133h "Proc files should end with newlines"
12948 remote_mds_nodsh && skip "remote MDS with nodsh"
12949 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12950 skip "Need MDS version at least 2.7.54"
12952 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12953 cancel_lru_locks mdc
12955 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
12956 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12957 [ $unused -eq 0 ] || error "$unused locks are not cleared"
12960 createmany -o $DIR/$tdir/f $nr ||
12961 error "failed to create $nr files in $DIR/$tdir"
12962 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
12964 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
12965 do_facet mds1 $LCTL set_param fail_loc=0x327
12966 do_facet mds1 $LCTL set_param fail_val=500
12969 echo "sleep 10 seconds ..."
12971 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
12973 do_facet mds1 $LCTL set_param fail_loc=0
12974 do_facet mds1 $LCTL set_param fail_val=0
12975 [ $lck_cnt -lt $unused ] ||
12976 error "No locks reclaimed, before:$unused, after:$lck_cnt"
12979 unlinkmany $DIR/$tdir/f $nr
12981 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
12984 remote_mds_nodsh && skip "remote MDS with nodsh"
12985 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
12986 skip "Need MDS version at least 2.7.54"
12988 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
12989 cancel_lru_locks mdc
12991 local low_wm=$(do_facet mds1 $LCTL get_param -n \
12992 ldlm.lock_reclaim_threshold_mb)
12993 # disable reclaim temporarily
12994 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
12996 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
12997 do_facet mds1 $LCTL set_param fail_loc=0x328
12998 do_facet mds1 $LCTL set_param fail_val=500
13000 $LCTL set_param debug=+trace
13003 createmany -o $DIR/$tdir/f $nr &
13004 local create_pid=$!
13006 echo "Sleep $TIMEOUT seconds ..."
13008 if ! ps -p $create_pid > /dev/null 2>&1; then
13009 do_facet mds1 $LCTL set_param fail_loc=0
13010 do_facet mds1 $LCTL set_param fail_val=0
13011 do_facet mds1 $LCTL set_param \
13012 ldlm.lock_reclaim_threshold_mb=${low_wm}m
13013 error "createmany finished incorrectly!"
13015 do_facet mds1 $LCTL set_param fail_loc=0
13016 do_facet mds1 $LCTL set_param fail_val=0
13017 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
13018 wait $create_pid || return 1
13020 unlinkmany $DIR/$tdir/f $nr
13022 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
13025 remote_mds_nodsh && skip "remote MDS with nodsh"
13026 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
13027 skip "Need MDS version at least 2.13.50"
13030 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13032 #define OBD_FAIL_PLAIN_RECORDS 0x1319
13033 #set only one record at plain llog
13034 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1319 fail_val=1
13036 #fill already existed plain llog each 64767
13037 #wrapping whole catalog
13038 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
13040 createmany -o $DIR/$tdir/$tfile_ 64700
13041 for (( i = 0; i < 64700; i = i + 2 ))
13043 rm $DIR/$tdir/$tfile_$i &
13044 rm $DIR/$tdir/$tfile_$((i + 1)) &
13049 #waiting osp synchronization
13050 wait_delete_completed
13052 run_test 135 "Race catalog processing"
13055 remote_mds_nodsh && skip "remote MDS with nodsh"
13056 [[ $MDS1_VERSION -lt $(version_code 2.13.50) ]] &&
13057 skip "Need MDS version at least 2.13.50"
13060 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
13061 $LFS setstripe -c 1 -i 0 $DIR/$tdir || error "failed to set striping"
13062 #set only one record at plain llog
13063 #define OBD_FAIL_CATALOG_FULL_CHECK 0x131a
13064 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x131a fail_val=1
13066 #fill already existed 2 plain llogs each 64767
13067 #wrapping whole catalog
13068 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 1))
13069 createmany -o -u $DIR/$tdir/$tfile- $((64767 * 3 / 2))
13070 wait_delete_completed
13072 createmany -o $DIR/$tdir/$tfile_ 10
13075 do_facet $SINGLEMDS $LCTL set_param fail_val=3
13076 for (( i = 0; i < 10; i = i + 3 ))
13078 rm $DIR/$tdir/$tfile_$i &
13079 rm $DIR/$tdir/$tfile_$((i + 1)) &
13083 rm $DIR/$tdir/$tfile_$((i + 2)) &
13086 #waiting osp synchronization
13087 wait_delete_completed
13089 run_test 136 "Race catalog processing 2"
13091 test_140() { #bug-17379
13092 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13094 test_mkdir $DIR/$tdir
13095 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
13096 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
13098 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
13099 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
13101 while i=$((i + 1)); do
13103 cd $i || error "Changing to $i"
13104 ln -s ../stat stat || error "Creating stat symlink"
13105 # Read the symlink until ELOOP present,
13106 # not LBUGing the system is considered success,
13107 # we didn't overrun the stack.
13108 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
13109 if [ $ret -ne 0 ]; then
13110 if [ $ret -eq 40 ]; then
13113 error "Open stat symlink"
13119 echo "The symlink depth = $i"
13120 [ $i -eq 5 ] || [ $i -eq 7 ] || [ $i -eq 8 ] || [ $i -eq 40 ] ||
13121 error "Invalid symlink depth"
13123 # Test recursive symlink
13124 ln -s symlink_self symlink_self
13125 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
13126 echo "open symlink_self returns $ret"
13127 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
13129 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
13132 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13134 local TF="$TMP/$tfile"
13136 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13138 cancel_lru_locks $OSC
13139 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
13140 remount_client $MOUNT
13142 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
13145 $TRUNCATE $DIR/$tfile 6000
13146 cancel_lru_locks $OSC
13147 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
13150 echo "12345" >>$DIR/$tfile
13151 cancel_lru_locks $OSC
13152 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
13155 echo "12345" >>$DIR/$tfile
13156 cancel_lru_locks $OSC
13157 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
13162 run_test 150a "truncate/append tests"
13165 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13166 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13167 skip "Need OST version at least 2.13.53"
13169 check_fallocate $DIR/$tfile || error "fallocate failed"
13171 run_test 150b "Verify fallocate (prealloc) functionality"
13177 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13178 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13179 skip "Need OST version at least 2.13.53"
13181 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
13182 fallocate -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
13183 sync; sync_all_data
13184 cancel_lru_locks $OSC
13186 bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
13187 want=$((OSTCOUNT * 1048576))
13189 # Must allocate all requested space, not more than 5% extra
13190 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
13191 error "bytes $bytes is not $want"
13193 run_test 150c "Verify fallocate Size and Blocks"
13199 [ "$ost1_FSTYPE" != ldiskfs ] && skip "non-ldiskfs backend"
13200 [ $OST1_VERSION -lt $(version_code 2.13.50) ] &&
13201 skip "Need OST version at least 2.13.53"
13203 $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed"
13204 fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed"
13205 sync; sync_all_data
13206 cancel_lru_locks $OSC
13208 bytes=$(($(stat -c '%b * %B' $DIR/$tdir)))
13209 want=$((OSTCOUNT * 1048576))
13211 # Must allocate all requested space, not more than 5% extra
13212 (( $bytes >= $want && $bytes < $want * 105 / 100 )) ||
13213 error "bytes $bytes is not $want"
13215 run_test 150d "Verify fallocate Size and Blocks - Non zero start"
13217 #LU-2902 roc_hit was not able to read all values from lproc
13218 function roc_hit_init() {
13219 local list=$(comma_list $(osts_nodes))
13220 local dir=$DIR/$tdir-check
13221 local file=$dir/$tfile
13227 #use setstripe to do a write to every ost
13228 for i in $(seq 0 $((OSTCOUNT-1))); do
13229 $LFS setstripe -c 1 -i $i $dir || error "$LFS setstripe $file failed"
13230 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
13231 idx=$(printf %04x $i)
13232 BEFORE=$(get_osd_param $list *OST*$idx stats |
13233 awk '$1 == "cache_access" {sum += $7}
13234 END { printf("%0.0f", sum) }')
13236 cancel_lru_locks osc
13237 cat $file >/dev/null
13239 AFTER=$(get_osd_param $list *OST*$idx stats |
13240 awk '$1 == "cache_access" {sum += $7}
13241 END { printf("%0.0f", sum) }')
13243 echo BEFORE:$BEFORE AFTER:$AFTER
13244 if ! let "AFTER - BEFORE == 4"; then
13246 error "roc_hit is not safe to use"
13254 function roc_hit() {
13255 local list=$(comma_list $(osts_nodes))
13256 echo $(get_osd_param $list '' stats |
13257 awk '$1 == "cache_hit" {sum += $7}
13258 END { printf("%0.0f", sum) }')
13261 function set_cache() {
13264 if [ "$2" == "off" ]; then
13267 local list=$(comma_list $(osts_nodes))
13268 set_osd_param $list '' $1_cache_enable $on
13270 cancel_lru_locks osc
13274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13275 remote_ost_nodsh && skip "remote OST with nodsh"
13278 local list=$(comma_list $(osts_nodes))
13280 # check whether obdfilter is cache capable at all
13281 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
13282 skip "not cache-capable obdfilter"
13285 # check cache is enabled on all obdfilters
13286 if get_osd_param $list '' read_cache_enable | grep 0; then
13287 skip "oss cache is disabled"
13290 set_osd_param $list '' writethrough_cache_enable 1
13292 # check write cache is enabled on all obdfilters
13293 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
13294 skip "oss write cache is NOT enabled"
13299 #define OBD_FAIL_OBD_NO_LRU 0x609
13300 do_nodes $list $LCTL set_param fail_loc=0x609
13302 # pages should be in the case right after write
13303 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
13306 local BEFORE=$(roc_hit)
13307 cancel_lru_locks osc
13308 cat $DIR/$tfile >/dev/null
13309 local AFTER=$(roc_hit)
13311 do_nodes $list $LCTL set_param fail_loc=0
13313 if ! let "AFTER - BEFORE == CPAGES"; then
13314 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
13317 cancel_lru_locks osc
13318 # invalidates OST cache
13319 do_nodes $list "echo 1 > /proc/sys/vm/drop_caches"
13320 set_osd_param $list '' read_cache_enable 0
13321 cat $DIR/$tfile >/dev/null
13323 # now data shouldn't be found in the cache
13325 cancel_lru_locks osc
13326 cat $DIR/$tfile >/dev/null
13328 if let "AFTER - BEFORE != 0"; then
13329 error "IN CACHE: before: $BEFORE, after: $AFTER"
13332 set_osd_param $list '' read_cache_enable 1
13335 run_test 151 "test cache on oss and controls ==============================="
13338 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13340 local TF="$TMP/$tfile"
13342 # simulate ENOMEM during write
13343 #define OBD_FAIL_OST_NOMEM 0x226
13344 lctl set_param fail_loc=0x80000226
13345 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
13347 sync || error "sync failed"
13348 lctl set_param fail_loc=0
13350 # discard client's cache
13351 cancel_lru_locks osc
13353 # simulate ENOMEM during read
13354 lctl set_param fail_loc=0x80000226
13355 cmp $TF $DIR/$tfile || error "cmp failed"
13356 lctl set_param fail_loc=0
13360 run_test 152 "test read/write with enomem ============================"
13363 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
13365 run_test 153 "test if fdatasync does not crash ======================="
13367 dot_lustre_fid_permission_check() {
13369 local ffid=$MOUNT/.lustre/fid/$fid
13372 echo "stat fid $fid"
13373 stat $ffid > /dev/null || error "stat $ffid failed."
13374 echo "touch fid $fid"
13375 touch $ffid || error "touch $ffid failed."
13376 echo "write to fid $fid"
13377 cat /etc/hosts > $ffid || error "write $ffid failed."
13378 echo "read fid $fid"
13379 diff /etc/hosts $ffid || error "read $ffid failed."
13380 echo "append write to fid $fid"
13381 cat /etc/hosts >> $ffid || error "append write $ffid failed."
13382 echo "rename fid $fid"
13383 mv $ffid $test_dir/$tfile.1 &&
13384 error "rename $ffid to $tfile.1 should fail."
13385 touch $test_dir/$tfile.1
13386 mv $test_dir/$tfile.1 $ffid &&
13387 error "rename $tfile.1 to $ffid should fail."
13388 rm -f $test_dir/$tfile.1
13389 echo "truncate fid $fid"
13390 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
13391 echo "link fid $fid"
13392 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
13393 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
13394 echo "setfacl fid $fid"
13395 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
13396 echo "getfacl fid $fid"
13397 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
13399 echo "unlink fid $fid"
13400 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
13401 echo "mknod fid $fid"
13402 mknod $ffid c 1 3 && error "mknod $ffid should fail."
13404 fid=[0xf00000400:0x1:0x0]
13405 ffid=$MOUNT/.lustre/fid/$fid
13407 echo "stat non-exist fid $fid"
13408 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
13409 echo "write to non-exist fid $fid"
13410 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
13411 echo "link new fid $fid"
13412 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
13414 mkdir -p $test_dir/$tdir
13415 touch $test_dir/$tdir/$tfile
13416 fid=$($LFS path2fid $test_dir/$tdir)
13419 error "error: could not get fid for $test_dir/$dir/$tfile."
13421 ffid=$MOUNT/.lustre/fid/$fid
13424 ls $ffid > /dev/null || error "ls $ffid failed."
13425 echo "touch $fid/$tfile.1"
13426 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
13428 echo "touch $MOUNT/.lustre/fid/$tfile"
13429 touch $MOUNT/.lustre/fid/$tfile && \
13430 error "touch $MOUNT/.lustre/fid/$tfile should fail."
13432 echo "setxattr to $MOUNT/.lustre/fid"
13433 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
13435 echo "listxattr for $MOUNT/.lustre/fid"
13436 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
13438 echo "delxattr from $MOUNT/.lustre/fid"
13439 setfattr -x trusted.name1 $MOUNT/.lustre/fid
13441 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
13442 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
13443 error "touch invalid fid should fail."
13445 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
13446 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
13447 error "touch non-normal fid should fail."
13449 echo "rename $tdir to $MOUNT/.lustre/fid"
13450 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
13451 error "rename to $MOUNT/.lustre/fid should fail."
13453 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
13455 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
13456 local new_obf_mode=777
13458 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
13459 chmod $new_obf_mode $DIR/.lustre/fid ||
13460 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
13462 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
13463 [ $obf_mode -eq $new_obf_mode ] ||
13464 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
13466 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
13467 chmod $old_obf_mode $DIR/.lustre/fid ||
13468 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
13471 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
13472 fid=$($LFS path2fid $test_dir/$tfile-2)
13474 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
13476 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
13477 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
13478 error "create lov data thru .lustre failed"
13480 echo "cp /etc/passwd $test_dir/$tfile-2"
13481 cp /etc/passwd $test_dir/$tfile-2 ||
13482 error "copy to $test_dir/$tfile-2 failed."
13483 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
13484 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
13485 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
13487 rm -rf $test_dir/tfile.lnk
13488 rm -rf $test_dir/$tfile-2
13492 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13493 skip "Need MDS version at least 2.4.1"
13495 local tf=$DIR/$tfile
13498 local fid=$($LFS path2fid $tf)
13499 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
13501 # check that we get the same pathname back
13502 local found=$($LFS fid2path $MOUNT "$fid")
13503 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
13504 [ "$found" == "$tf" ] ||
13505 error "fid2path($fid=path2fid($tf)) = $found != $tf"
13507 run_test 154A "lfs path2fid and fid2path basic checks"
13510 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13511 skip "Need MDS version at least 2.4.1"
13513 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
13514 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
13515 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
13516 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
13518 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
13519 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
13521 # check that we get the same pathname
13522 echo "PFID: $PFID, name: $name"
13523 local FOUND=$($LFS fid2path $MOUNT "$PFID")
13524 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
13525 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
13526 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
13528 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
13530 run_test 154B "verify the ll_decode_linkea tool"
13533 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13534 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13535 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13536 skip "Need MDS version at least 2.2.51"
13537 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
13539 cp /etc/hosts $DIR/$tfile
13541 fid=$($LFS path2fid $DIR/$tfile)
13543 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
13545 dot_lustre_fid_permission_check "$fid" $DIR ||
13546 error "dot lustre permission check $fid failed"
13548 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
13550 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
13552 touch $MOUNT/.lustre/file &&
13553 error "creation is not allowed under .lustre"
13555 mkdir $MOUNT/.lustre/dir &&
13556 error "mkdir is not allowed under .lustre"
13560 run_test 154a "Open-by-FID"
13563 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13564 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13565 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13566 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
13567 skip "Need MDS version at least 2.2.51"
13569 local remote_dir=$DIR/$tdir/remote_dir
13573 mkdir -p $DIR/$tdir
13574 $LFS mkdir -i $MDTIDX $remote_dir ||
13575 error "create remote directory failed"
13577 cp /etc/hosts $remote_dir/$tfile
13579 fid=$($LFS path2fid $remote_dir/$tfile)
13581 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
13583 dot_lustre_fid_permission_check "$fid" $remote_dir ||
13584 error "dot lustre permission check $fid failed"
13587 run_test 154b "Open-by-FID for remote directory"
13590 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
13591 skip "Need MDS version at least 2.4.1"
13593 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
13594 local FID1=$($LFS path2fid $DIR/$tfile.1)
13595 local FID2=$($LFS path2fid $DIR/$tfile.2)
13596 local FID3=$($LFS path2fid $DIR/$tfile.3)
13599 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
13600 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
13601 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
13603 [ "$FID" = "${!want}" ] ||
13604 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
13608 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
13610 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
13611 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
13615 run_test 154c "lfs path2fid and fid2path multiple arguments"
13618 remote_mds_nodsh && skip "remote MDS with nodsh"
13619 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
13620 skip "Need MDS version at least 2.5.53"
13622 if remote_mds; then
13623 nid=$($LCTL list_nids | sed "s/\./\\\./g")
13627 local proc_ofile="mdt.*.exports.'$nid'.open_files"
13634 local fid=$($LFS path2fid $DIR/$tfile)
13637 cmd="exec $fd<$DIR/$tfile"
13639 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
13640 echo "$fid_list" | grep "$fid"
13643 cmd="exec $fd>/dev/null"
13645 if [ $rc -ne 0 ]; then
13646 error "FID $fid not found in open files list $fid_list"
13649 run_test 154d "Verify open file fid"
13653 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
13654 skip "Need MDS version at least 2.6.50"
13656 if ls -a $MOUNT | grep -q '^\.lustre$'; then
13657 error ".lustre returned by readdir"
13660 run_test 154e ".lustre is not returned by readdir"
13663 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13665 # create parent directory on a single MDT to avoid cross-MDT hardlinks
13666 test_mkdir -p -c1 $DIR/$tdir/d
13667 # test dirs inherit from its stripe
13668 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
13669 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
13670 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
13671 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
13674 # get fid of parents
13675 local FID0=$($LFS path2fid $DIR/$tdir/d)
13676 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
13677 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
13678 local FID3=$($LFS path2fid $DIR)
13680 # check that path2fid --parents returns expected <parent_fid>/name
13681 # 1) test for a directory (single parent)
13682 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
13683 [ "$parent" == "$FID0/foo1" ] ||
13684 error "expected parent: $FID0/foo1, got: $parent"
13686 # 2) test for a file with nlink > 1 (multiple parents)
13687 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
13688 echo "$parent" | grep -F "$FID1/$tfile" ||
13689 error "$FID1/$tfile not returned in parent list"
13690 echo "$parent" | grep -F "$FID2/link" ||
13691 error "$FID2/link not returned in parent list"
13693 # 3) get parent by fid
13694 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
13695 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13696 echo "$parent" | grep -F "$FID1/$tfile" ||
13697 error "$FID1/$tfile not returned in parent list (by fid)"
13698 echo "$parent" | grep -F "$FID2/link" ||
13699 error "$FID2/link not returned in parent list (by fid)"
13701 # 4) test for entry in root directory
13702 parent=$($LFS path2fid --parents $DIR/f)
13703 echo "$parent" | grep -F "$FID3/f" ||
13704 error "$FID3/f not returned in parent list"
13706 # 5) test it on root directory
13707 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
13708 error "$MOUNT should not have parents"
13710 # enable xattr caching and check that linkea is correctly updated
13711 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
13712 save_lustre_params client "llite.*.xattr_cache" > $save
13713 lctl set_param llite.*.xattr_cache 1
13715 # 6.1) linkea update on rename
13716 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
13718 # get parents by fid
13719 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13720 # foo1 should no longer be returned in parent list
13721 echo "$parent" | grep -F "$FID1" &&
13722 error "$FID1 should no longer be in parent list"
13723 # the new path should appear
13724 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
13725 error "$FID2/$tfile.moved is not in parent list"
13727 # 6.2) linkea update on unlink
13728 rm -f $DIR/$tdir/d/foo2/link
13729 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
13730 # foo2/link should no longer be returned in parent list
13731 echo "$parent" | grep -F "$FID2/link" &&
13732 error "$FID2/link should no longer be in parent list"
13736 restore_lustre_params < $save
13739 run_test 154f "get parent fids by reading link ea"
13743 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13744 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
13745 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
13746 skip "Need MDS version at least 2.6.92"
13748 mkdir -p $DIR/$tdir
13749 llapi_fid_test -d $DIR/$tdir
13751 run_test 154g "various llapi FID tests"
13753 test_155_small_load() {
13754 local temp=$TMP/$tfile
13755 local file=$DIR/$tfile
13757 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
13758 error "dd of=$temp bs=6096 count=1 failed"
13760 cancel_lru_locks $OSC
13761 cmp $temp $file || error "$temp $file differ"
13763 $TRUNCATE $temp 6000
13764 $TRUNCATE $file 6000
13765 cmp $temp $file || error "$temp $file differ (truncate1)"
13767 echo "12345" >>$temp
13768 echo "12345" >>$file
13769 cmp $temp $file || error "$temp $file differ (append1)"
13771 echo "12345" >>$temp
13772 echo "12345" >>$file
13773 cmp $temp $file || error "$temp $file differ (append2)"
13779 test_155_big_load() {
13780 remote_ost_nodsh && skip "remote OST with nodsh"
13782 local temp=$TMP/$tfile
13783 local file=$DIR/$tfile
13786 local cache_size=$(do_facet ost$((MAXI+1)) \
13787 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
13788 local large_file_size=$((cache_size * 2))
13790 echo "OSS cache size: $cache_size KB"
13791 echo "Large file size: $large_file_size KB"
13793 [ $MAXV -le $large_file_size ] &&
13794 skip_env "max available OST size needs > $large_file_size KB"
13796 $LFS setstripe $file -c 1 -i $MAXI || error "$LFS setstripe $file failed"
13798 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
13799 error "dd of=$temp bs=$large_file_size count=1k failed"
13802 cancel_lru_locks osc
13803 cmp $temp $file || error "$temp $file differ"
13809 save_writethrough() {
13810 local facets=$(get_facets OST)
13812 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
13816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13818 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13820 save_writethrough $p
13823 set_cache writethrough on
13824 test_155_small_load
13825 restore_lustre_params < $p
13828 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
13831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13833 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13835 save_writethrough $p
13838 set_cache writethrough off
13839 test_155_small_load
13840 restore_lustre_params < $p
13843 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
13846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13848 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13850 save_writethrough $p
13853 set_cache writethrough on
13854 test_155_small_load
13855 restore_lustre_params < $p
13858 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
13861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13863 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13865 save_writethrough $p
13868 set_cache writethrough off
13869 test_155_small_load
13870 restore_lustre_params < $p
13873 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
13876 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13878 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13880 save_writethrough $p
13883 set_cache writethrough on
13885 restore_lustre_params < $p
13888 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
13891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13893 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13895 save_writethrough $p
13898 set_cache writethrough off
13900 restore_lustre_params < $p
13903 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
13906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13908 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13910 save_writethrough $p
13913 set_cache writethrough on
13915 restore_lustre_params < $p
13918 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
13921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13923 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13925 save_writethrough $p
13928 set_cache writethrough off
13930 restore_lustre_params < $p
13933 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
13936 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13937 remote_ost_nodsh && skip "remote OST with nodsh"
13938 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
13939 skip "stats not implemented on old servers"
13940 [ "$ost1_FSTYPE" = "zfs" ] &&
13941 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
13946 local file="$DIR/$tfile"
13947 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
13949 save_writethrough $p
13952 log "Turn on read and write cache"
13954 set_cache writethrough on
13956 log "Write data and read it back."
13957 log "Read should be satisfied from the cache."
13958 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
13960 cancel_lru_locks osc
13961 cat $file >/dev/null
13963 if ! let "AFTER - BEFORE == CPAGES"; then
13964 error "NOT IN CACHE (2): before: $BEFORE, after: $AFTER"
13966 log "cache hits: before: $BEFORE, after: $AFTER"
13969 log "Read again; it should be satisfied from the cache."
13971 cancel_lru_locks osc
13972 cat $file >/dev/null
13974 if ! let "AFTER - BEFORE == CPAGES"; then
13975 error "NOT IN CACHE (3): before: $BEFORE, after: $AFTER"
13977 log "cache hits:: before: $BEFORE, after: $AFTER"
13980 log "Turn off the read cache and turn on the write cache"
13982 set_cache writethrough on
13984 log "Read again; it should be satisfied from the cache."
13986 cancel_lru_locks osc
13987 cat $file >/dev/null
13989 if ! let "AFTER - BEFORE == CPAGES"; then
13990 error "NOT IN CACHE (4): before: $BEFORE, after: $AFTER"
13992 log "cache hits:: before: $BEFORE, after: $AFTER"
13995 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
13996 # > 2.12.56 uses pagecache if cached
13997 log "Read again; it should not be satisfied from the cache."
13999 cancel_lru_locks osc
14000 cat $file >/dev/null
14002 if ! let "AFTER - BEFORE == 0"; then
14003 error "IN CACHE (5): before: $BEFORE, after: $AFTER"
14005 log "cache hits:: before: $BEFORE, after: $AFTER"
14009 log "Write data and read it back."
14010 log "Read should be satisfied from the cache."
14011 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14013 cancel_lru_locks osc
14014 cat $file >/dev/null
14016 if ! let "AFTER - BEFORE == CPAGES"; then
14017 error "NOT IN CACHE (6): before: $BEFORE, after: $AFTER"
14019 log "cache hits:: before: $BEFORE, after: $AFTER"
14022 if [ $OST1_VERSION -lt $(version_code 2.12.55) ]; then
14023 # > 2.12.56 uses pagecache if cached
14024 log "Read again; it should not be satisfied from the cache."
14026 cancel_lru_locks osc
14027 cat $file >/dev/null
14029 if ! let "AFTER - BEFORE == 0"; then
14030 error "IN CACHE (7): before: $BEFORE, after: $AFTER"
14032 log "cache hits:: before: $BEFORE, after: $AFTER"
14036 log "Turn off read and write cache"
14038 set_cache writethrough off
14040 log "Write data and read it back"
14041 log "It should not be satisfied from the cache."
14043 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14044 cancel_lru_locks osc
14046 cat $file >/dev/null
14048 if ! let "AFTER - BEFORE == 0"; then
14049 error_ignore bz20762 "IN CACHE (8):before:$BEFORE,after:$AFTER"
14051 log "cache hits:: before: $BEFORE, after: $AFTER"
14054 log "Turn on the read cache and turn off the write cache"
14056 set_cache writethrough off
14058 log "Write data and read it back"
14059 log "It should not be satisfied from the cache."
14061 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
14063 cancel_lru_locks osc
14064 cat $file >/dev/null
14066 if ! let "AFTER - BEFORE == 0"; then
14067 error_ignore bz20762 "IN CACHE (9):before:$BEFORE,after:$AFTER"
14069 log "cache hits:: before: $BEFORE, after: $AFTER"
14072 log "Read again; it should be satisfied from the cache."
14074 cancel_lru_locks osc
14075 cat $file >/dev/null
14077 if ! let "AFTER - BEFORE == CPAGES"; then
14078 error "NOT IN CACHE (1): before: $BEFORE, after: $AFTER"
14080 log "cache hits:: before: $BEFORE, after: $AFTER"
14083 restore_lustre_params < $p
14086 run_test 156 "Verification of tunables"
14089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14090 remote_mds_nodsh && skip "remote MDS with nodsh"
14091 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
14092 skip "Need MDS version at least 2.2.0"
14094 changelog_register || error "changelog_register failed"
14095 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14096 changelog_users $SINGLEMDS | grep -q $cl_user ||
14097 error "User $cl_user not found in changelog_users"
14100 test_mkdir -p $DIR/$tdir/pics/2008/zachy
14101 changelog_clear 0 || error "changelog_clear failed"
14102 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
14103 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
14104 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
14105 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
14106 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
14107 rm $DIR/$tdir/pics/desktop.jpg
14109 changelog_dump | tail -10
14111 echo "verifying changelog mask"
14112 changelog_chmask "-MKDIR"
14113 changelog_chmask "-CLOSE"
14115 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
14116 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
14118 changelog_chmask "+MKDIR"
14119 changelog_chmask "+CLOSE"
14121 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
14122 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
14124 changelog_dump | tail -10
14125 MKDIRS=$(changelog_dump | grep -c "MKDIR")
14126 CLOSES=$(changelog_dump | grep -c "CLOSE")
14127 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
14128 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
14131 echo "verifying target fid"
14132 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
14133 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
14134 [ "$fidc" == "$fidf" ] ||
14135 error "changelog '$tfile' fid $fidc != file fid $fidf"
14136 echo "verifying parent fid"
14137 # The FID returned from the Changelog may be the directory shard on
14138 # a different MDT, and not the FID returned by path2fid on the parent.
14139 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
14140 # since this is what will matter when recreating this file in the tree.
14141 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
14142 local pathp=$($LFS fid2path $MOUNT "$fidp")
14143 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
14144 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
14146 echo "getting records for $cl_user"
14147 changelog_users $SINGLEMDS
14148 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
14150 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
14151 error "changelog_clear failed"
14152 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
14153 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
14154 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
14155 error "user index expect $user_rec1 + $nclr != $user_rec2"
14157 local min0_rec=$(changelog_users $SINGLEMDS |
14158 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
14159 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
14160 awk '{ print $1; exit; }')
14162 changelog_dump | tail -n 5
14163 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
14164 [ $first_rec == $((min0_rec + 1)) ] ||
14165 error "first index should be $min0_rec + 1 not $first_rec"
14167 # LU-3446 changelog index reset on MDT restart
14168 local cur_rec1=$(changelog_users $SINGLEMDS |
14169 awk '/^current.index:/ { print $NF }')
14170 changelog_clear 0 ||
14171 error "clear all changelog records for $cl_user failed"
14172 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
14173 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
14174 error "Fail to start $SINGLEMDS"
14175 local cur_rec2=$(changelog_users $SINGLEMDS |
14176 awk '/^current.index:/ { print $NF }')
14177 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
14178 [ $cur_rec1 == $cur_rec2 ] ||
14179 error "current index should be $cur_rec1 not $cur_rec2"
14181 echo "verifying users from this test are deregistered"
14182 changelog_deregister || error "changelog_deregister failed"
14183 changelog_users $SINGLEMDS | grep -q $cl_user &&
14184 error "User '$cl_user' still in changelog_users"
14186 # lctl get_param -n mdd.*.changelog_users
14187 # current index: 144
14188 # ID index (idle seconds)
14190 if ! changelog_users $SINGLEMDS | grep "^cl"; then
14191 # this is the normal case where all users were deregistered
14192 # make sure no new records are added when no users are present
14193 local last_rec1=$(changelog_users $SINGLEMDS |
14194 awk '/^current.index:/ { print $NF }')
14195 touch $DIR/$tdir/chloe
14196 local last_rec2=$(changelog_users $SINGLEMDS |
14197 awk '/^current.index:/ { print $NF }')
14198 echo "verify changelogs are off: $last_rec1 == $last_rec2"
14199 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
14201 # any changelog users must be leftovers from a previous test
14202 changelog_users $SINGLEMDS
14203 echo "other changelog users; can't verify off"
14206 run_test 160a "changelog sanity"
14208 test_160b() { # LU-3587
14209 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14210 remote_mds_nodsh && skip "remote MDS with nodsh"
14211 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
14212 skip "Need MDS version at least 2.2.0"
14214 changelog_register || error "changelog_register failed"
14215 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14216 changelog_users $SINGLEMDS | grep -q $cl_user ||
14217 error "User '$cl_user' not found in changelog_users"
14219 local longname1=$(str_repeat a 255)
14220 local longname2=$(str_repeat b 255)
14223 echo "creating very long named file"
14224 touch $longname1 || error "create of '$longname1' failed"
14225 echo "renaming very long named file"
14226 mv $longname1 $longname2
14228 changelog_dump | grep RENME | tail -n 5
14231 run_test 160b "Verify that very long rename doesn't crash in changelog"
14234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14235 remote_mds_nodsh && skip "remote MDS with nodsh"
14237 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
14238 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
14239 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
14240 skip "Need MDS version at least 2.5.58 or 2.5.2+"
14244 # Registration step
14245 changelog_register || error "changelog_register failed"
14248 mkdir -p $DIR/$tdir
14249 $MCREATE $DIR/$tdir/foo_160c
14250 changelog_chmask "-TRUNC"
14251 $TRUNCATE $DIR/$tdir/foo_160c 200
14252 changelog_chmask "+TRUNC"
14253 $TRUNCATE $DIR/$tdir/foo_160c 199
14254 changelog_dump | tail -n 5
14255 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
14256 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
14258 run_test 160c "verify that changelog log catch the truncate event"
14261 remote_mds_nodsh && skip "remote MDS with nodsh"
14262 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14264 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
14265 skip "Need MDS version at least 2.7.60"
14267 # Registration step
14268 changelog_register || error "changelog_register failed"
14270 mkdir -p $DIR/$tdir/migrate_dir
14271 changelog_clear 0 || error "changelog_clear failed"
14273 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
14274 changelog_dump | tail -n 5
14275 local migrates=$(changelog_dump | grep -c "MIGRT")
14276 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
14278 run_test 160d "verify that changelog log catch the migrate event"
14281 remote_mds_nodsh && skip "remote MDS with nodsh"
14284 changelog_register || error "changelog_register failed"
14286 # Delete a future user (expect fail)
14287 local MDT0=$(facet_svc $SINGLEMDS)
14288 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
14291 if [ $rc -eq 0 ]; then
14292 error "Deleted non-existant user cl77"
14293 elif [ $rc -ne 2 ]; then
14294 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
14297 # Clear to a bad index (1 billion should be safe)
14298 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
14301 if [ $rc -eq 0 ]; then
14302 error "Successfully cleared to invalid CL index"
14303 elif [ $rc -ne 22 ]; then
14304 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
14307 run_test 160e "changelog negative testing (should return errors)"
14310 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14311 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14312 skip "Need MDS version at least 2.10.56"
14314 local mdts=$(comma_list $(mdts_nodes))
14317 changelog_register || error "first changelog_register failed"
14318 changelog_register || error "second changelog_register failed"
14320 declare -A cl_user1
14321 declare -A cl_user2
14326 # generate some changelog records to accumulate on each MDT
14327 # use fnv1a because created files should be evenly distributed
14328 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14329 error "test_mkdir $tdir failed"
14330 log "$(date +%s): creating first files"
14331 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14332 error "create $DIR/$tdir/$tfile failed"
14334 # check changelogs have been generated
14335 local start=$SECONDS
14336 local idle_time=$((MDSCOUNT * 5 + 5))
14337 local nbcl=$(changelog_dump | wc -l)
14338 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14340 for param in "changelog_max_idle_time=$idle_time" \
14342 "changelog_min_gc_interval=2" \
14343 "changelog_min_free_cat_entries=3"; do
14344 local MDT0=$(facet_svc $SINGLEMDS)
14345 local var="${param%=*}"
14346 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14348 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14349 do_nodes $mdts $LCTL set_param mdd.*.$param
14352 # force cl_user2 to be idle (1st part), but also cancel the
14353 # cl_user1 records so that it is not evicted later in the test.
14354 local sleep1=$((idle_time / 2))
14355 echo "$(date +%s): sleep1 $sleep1/${idle_time}s"
14358 # simulate changelog catalog almost full
14359 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14360 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14362 for i in $(seq $MDSCOUNT); do
14363 cl_users=(${CL_USERS[mds$i]})
14364 cl_user1[mds$i]="${cl_users[0]}"
14365 cl_user2[mds$i]="${cl_users[1]}"
14367 [ -n "${cl_user1[mds$i]}" ] ||
14368 error "mds$i: no user registered"
14369 [ -n "${cl_user2[mds$i]}" ] ||
14370 error "mds$i: only ${cl_user2[mds$i]} is registered"
14372 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14373 [ -n "$user_rec1" ] ||
14374 error "mds$i: User ${cl_user1[mds$i]} not registered"
14375 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14376 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14377 [ -n "$user_rec2" ] ||
14378 error "mds$i: User ${cl_user1[mds$i]} not registered"
14379 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14380 "$user_rec1 + 2 == $user_rec2"
14381 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14382 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14383 "$user_rec1 + 2, but is $user_rec2"
14384 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14385 [ -n "$user_rec2" ] ||
14386 error "mds$i: User ${cl_user2[mds$i]} not registered"
14387 [ $user_rec1 == $user_rec2 ] ||
14388 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14389 "$user_rec1, but is $user_rec2"
14392 # force cl_user2 idle (2nd part) to just exceed changelog_max_idle_time
14393 local sleep2=$((idle_time - (SECONDS - start) + 1))
14394 echo "$(date +%s): sleep2 $sleep2/${idle_time}s"
14397 # Generate one more changelog to trigger GC at fail_loc for cl_user2.
14398 # cl_user1 should be OK because it recently processed records.
14399 echo "$(date +%s): creating $((MDSCOUNT * 2)) files"
14400 createmany -m $DIR/$tdir/${tfile}b $((MDSCOUNT * 2)) ||
14401 error "create $DIR/$tdir/${tfile}b failed"
14403 # ensure gc thread is done
14404 for i in $(mdts_nodes); do
14406 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14407 error "$i: GC-thread not done"
14411 for i in $(seq $MDSCOUNT); do
14412 # check cl_user1 still registered
14413 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14414 error "mds$i: User ${cl_user1[mds$i]} not registered"
14415 # check cl_user2 unregistered
14416 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14417 error "mds$i: User ${cl_user2[mds$i]} still registered"
14419 # check changelogs are present and starting at $user_rec1 + 1
14420 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14421 [ -n "$user_rec1" ] ||
14422 error "mds$i: User ${cl_user1[mds$i]} not registered"
14423 first_rec=$($LFS changelog $(facet_svc mds$i) |
14424 awk '{ print $1; exit; }')
14426 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14427 [ $((user_rec1 + 1)) == $first_rec ] ||
14428 error "mds$i: first index should be $user_rec1 + 1, " \
14429 "but is $first_rec"
14432 run_test 160f "changelog garbage collect (timestamped users)"
14435 remote_mds_nodsh && skip "remote MDS with nodsh"
14436 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14437 skip "Need MDS version at least 2.10.56"
14439 local mdts=$(comma_list $(mdts_nodes))
14441 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
14442 do_nodes $mdts $LCTL set_param fail_loc=0x1314
14445 changelog_register || error "first changelog_register failed"
14446 changelog_register || error "second changelog_register failed"
14448 declare -A cl_user1
14449 declare -A cl_user2
14454 # generate some changelog records to accumulate on each MDT
14455 # use fnv1a because created files should be evenly distributed
14456 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14457 error "mkdir $tdir failed"
14458 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14459 error "create $DIR/$tdir/$tfile failed"
14461 # check changelogs have been generated
14462 local nbcl=$(changelog_dump | wc -l)
14463 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14465 # reduce the max_idle_indexes value to make sure we exceed it
14466 max_ndx=$((nbcl / 2 - 1))
14468 for param in "changelog_max_idle_indexes=$max_ndx" \
14470 "changelog_min_gc_interval=2" \
14471 "changelog_min_free_cat_entries=3"; do
14472 local MDT0=$(facet_svc $SINGLEMDS)
14473 local var="${param%=*}"
14474 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14476 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14477 do_nodes $mdts $LCTL set_param mdd.*.$param ||
14478 error "unable to set mdd.*.$param"
14481 # simulate changelog catalog almost full
14482 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
14483 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
14485 for i in $(seq $MDSCOUNT); do
14486 cl_users=(${CL_USERS[mds$i]})
14487 cl_user1[mds$i]="${cl_users[0]}"
14488 cl_user2[mds$i]="${cl_users[1]}"
14490 [ -n "${cl_user1[mds$i]}" ] ||
14491 error "mds$i: no user registered"
14492 [ -n "${cl_user2[mds$i]}" ] ||
14493 error "mds$i: only ${cl_user1[mds$i]} is registered"
14495 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14496 [ -n "$user_rec1" ] ||
14497 error "mds$i: User ${cl_user1[mds$i]} not registered"
14498 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14499 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14500 [ -n "$user_rec2" ] ||
14501 error "mds$i: User ${cl_user1[mds$i]} not registered"
14502 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14503 "$user_rec1 + 2 == $user_rec2"
14504 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14505 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14506 "$user_rec1 + 2, but is $user_rec2"
14507 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14508 [ -n "$user_rec2" ] ||
14509 error "mds$i: User ${cl_user2[mds$i]} not registered"
14510 [ $user_rec1 == $user_rec2 ] ||
14511 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14512 "$user_rec1, but is $user_rec2"
14515 # ensure we are past the previous changelog_min_gc_interval set above
14518 # generate one more changelog to trigger fail_loc
14519 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14520 error "create $DIR/$tdir/${tfile}bis failed"
14522 # ensure gc thread is done
14523 for i in $(mdts_nodes); do
14525 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
14526 error "$i: GC-thread not done"
14530 for i in $(seq $MDSCOUNT); do
14531 # check cl_user1 still registered
14532 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14533 error "mds$i: User ${cl_user1[mds$i]} not registered"
14534 # check cl_user2 unregistered
14535 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14536 error "mds$i: User ${cl_user2[mds$i]} still registered"
14538 # check changelogs are present and starting at $user_rec1 + 1
14539 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14540 [ -n "$user_rec1" ] ||
14541 error "mds$i: User ${cl_user1[mds$i]} not registered"
14542 first_rec=$($LFS changelog $(facet_svc mds$i) |
14543 awk '{ print $1; exit; }')
14545 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14546 [ $((user_rec1 + 1)) == $first_rec ] ||
14547 error "mds$i: first index should be $user_rec1 + 1, " \
14548 "but is $first_rec"
14551 run_test 160g "changelog garbage collect (old users)"
14554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
14555 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
14556 skip "Need MDS version at least 2.10.56"
14558 local mdts=$(comma_list $(mdts_nodes))
14561 changelog_register || error "first changelog_register failed"
14562 changelog_register || error "second changelog_register failed"
14564 declare -A cl_user1
14565 declare -A cl_user2
14570 # generate some changelog records to accumulate on each MDT
14571 # use fnv1a because created files should be evenly distributed
14572 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14573 error "test_mkdir $tdir failed"
14574 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14575 error "create $DIR/$tdir/$tfile failed"
14577 # check changelogs have been generated
14578 local nbcl=$(changelog_dump | wc -l)
14579 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14581 for param in "changelog_max_idle_time=10" \
14583 "changelog_min_gc_interval=2"; do
14584 local MDT0=$(facet_svc $SINGLEMDS)
14585 local var="${param%=*}"
14586 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
14588 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
14589 do_nodes $mdts $LCTL set_param mdd.*.$param
14592 # force cl_user2 to be idle (1st part)
14595 for i in $(seq $MDSCOUNT); do
14596 cl_users=(${CL_USERS[mds$i]})
14597 cl_user1[mds$i]="${cl_users[0]}"
14598 cl_user2[mds$i]="${cl_users[1]}"
14600 [ -n "${cl_user1[mds$i]}" ] ||
14601 error "mds$i: no user registered"
14602 [ -n "${cl_user2[mds$i]}" ] ||
14603 error "mds$i: only ${cl_user2[mds$i]} is registered"
14605 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14606 [ -n "$user_rec1" ] ||
14607 error "mds$i: User ${cl_user1[mds$i]} not registered"
14608 __changelog_clear mds$i ${cl_user1[mds$i]} +2
14609 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14610 [ -n "$user_rec2" ] ||
14611 error "mds$i: User ${cl_user1[mds$i]} not registered"
14612 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
14613 "$user_rec1 + 2 == $user_rec2"
14614 [ $((user_rec1 + 2)) == $user_rec2 ] ||
14615 error "mds$i: user ${cl_user1[mds$i]} index expected " \
14616 "$user_rec1 + 2, but is $user_rec2"
14617 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
14618 [ -n "$user_rec2" ] ||
14619 error "mds$i: User ${cl_user2[mds$i]} not registered"
14620 [ $user_rec1 == $user_rec2 ] ||
14621 error "mds$i: user ${cl_user2[mds$i]} index expected " \
14622 "$user_rec1, but is $user_rec2"
14625 # force cl_user2 to be idle (2nd part) and to reach
14626 # changelog_max_idle_time
14629 # force each GC-thread start and block then
14630 # one per MDT/MDD, set fail_val accordingly
14631 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
14632 do_nodes $mdts $LCTL set_param fail_loc=0x1316
14634 # generate more changelogs to trigger fail_loc
14635 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14636 error "create $DIR/$tdir/${tfile}bis failed"
14638 # stop MDT to stop GC-thread, should be done in back-ground as it will
14639 # block waiting for the thread to be released and exit
14640 declare -A stop_pids
14641 for i in $(seq $MDSCOUNT); do
14643 stop_pids[mds$i]=$!
14646 for i in $(mdts_nodes); do
14649 local facets=$(facets_up_on_host $i)
14651 for facet in ${facets//,/ }; do
14652 if [[ $facet == mds* ]]; then
14656 # ensure each MDS's gc threads are still present and all in "R"
14657 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
14658 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
14659 error "$i: expected $nb GC-thread"
14661 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
14663 error "$i: GC-thread not found in R-state"
14664 # check umounts of each MDT on MDS have reached kthread_stop()
14665 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
14666 error "$i: expected $nb umount"
14668 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
14669 error "$i: umount not found in D-state"
14672 # release all GC-threads
14673 do_nodes $mdts $LCTL set_param fail_loc=0
14675 # wait for MDT stop to complete
14676 for i in $(seq $MDSCOUNT); do
14677 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
14681 # may try to check if any orphan changelog records are present
14682 # via ldiskfs/zfs and llog_reader...
14684 # re-start/mount MDTs
14685 for i in $(seq $MDSCOUNT); do
14686 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
14687 error "Fail to start mds$i"
14691 for i in $(seq $MDSCOUNT); do
14692 # check cl_user1 still registered
14693 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
14694 error "mds$i: User ${cl_user1[mds$i]} not registered"
14695 # check cl_user2 unregistered
14696 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
14697 error "mds$i: User ${cl_user2[mds$i]} still registered"
14699 # check changelogs are present and starting at $user_rec1 + 1
14700 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
14701 [ -n "$user_rec1" ] ||
14702 error "mds$i: User ${cl_user1[mds$i]} not registered"
14703 first_rec=$($LFS changelog $(facet_svc mds$i) |
14704 awk '{ print $1; exit; }')
14706 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
14707 [ $((user_rec1 + 1)) == $first_rec ] ||
14708 error "mds$i: first index should be $user_rec1 + 1, " \
14709 "but is $first_rec"
14712 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
14717 local mdts=$(comma_list $(mdts_nodes))
14719 changelog_register || error "first changelog_register failed"
14721 # generate some changelog records to accumulate on each MDT
14722 # use fnv1a because created files should be evenly distributed
14723 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14724 error "mkdir $tdir failed"
14725 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
14726 error "create $DIR/$tdir/$tfile failed"
14728 # check changelogs have been generated
14729 local nbcl=$(changelog_dump | wc -l)
14730 [[ $nbcl -eq 0 ]] && error "no changelogs found"
14732 # simulate race between register and unregister
14733 # XXX as fail_loc is set per-MDS, with DNE configs the race
14734 # simulation will only occur for one MDT per MDS and for the
14735 # others the normal race scenario will take place
14736 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
14737 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
14738 do_nodes $mdts $LCTL set_param fail_val=1
14740 # unregister 1st user
14741 changelog_deregister &
14743 # wait some time for deregister work to reach race rdv
14745 # register 2nd user
14746 changelog_register || error "2nd user register failed"
14748 wait $pid1 || error "1st user deregister failed"
14752 declare -A LAST_REC
14753 for i in $(seq $MDSCOUNT); do
14754 if changelog_users mds$i | grep "^cl"; then
14755 # make sure new records are added with one user present
14756 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
14757 awk '/^current.index:/ { print $NF }')
14759 error "mds$i has no user registered"
14763 # generate more changelog records to accumulate on each MDT
14764 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14765 error "create $DIR/$tdir/${tfile}bis failed"
14767 for i in $(seq $MDSCOUNT); do
14768 last_rec=$(changelog_users $SINGLEMDS |
14769 awk '/^current.index:/ { print $NF }')
14770 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
14771 [ $last_rec != ${LAST_REC[mds$i]} ] ||
14772 error "changelogs are off on mds$i"
14775 run_test 160i "changelog user register/unregister race"
14778 remote_mds_nodsh && skip "remote MDS with nodsh"
14779 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
14780 skip "Need MDS version at least 2.12.56"
14782 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
14783 stack_trap "umount $MOUNT2" EXIT
14785 changelog_register || error "first changelog_register failed"
14786 stack_trap "changelog_deregister" EXIT
14788 # generate some changelog
14789 # use fnv1a because created files should be evenly distributed
14790 test_mkdir -c $MDSCOUNT -H fnv_1a_64 $DIR/$tdir ||
14791 error "mkdir $tdir failed"
14792 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
14793 error "create $DIR/$tdir/${tfile}bis failed"
14795 # open the changelog device
14796 exec 3>/dev/changelog-$FSNAME-MDT0000
14797 stack_trap "exec 3>&-" EXIT
14798 exec 4</dev/changelog-$FSNAME-MDT0000
14799 stack_trap "exec 4<&-" EXIT
14801 # umount the first lustre mount
14803 stack_trap "mount_client $MOUNT" EXIT
14806 cat <&4 >/dev/null || error "read changelog failed"
14809 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14810 changelog_users $SINGLEMDS | grep -q $cl_user ||
14811 error "User $cl_user not found in changelog_users"
14813 printf 'clear:'$cl_user':0' >&3
14815 run_test 160j "client can be umounted while its chanangelog is being used"
14818 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14819 remote_mds_nodsh && skip "remote MDS with nodsh"
14821 mkdir -p $DIR/$tdir/1/1
14823 changelog_register || error "changelog_register failed"
14824 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
14826 changelog_users $SINGLEMDS | grep -q $cl_user ||
14827 error "User '$cl_user' not found in changelog_users"
14828 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
14829 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
14830 rmdir $DIR/$tdir/1/1 & sleep 1
14832 touch $DIR/$tdir/2/2
14833 rm -rf $DIR/$tdir/2
14838 changelog_dump | grep rmdir || error "rmdir not recorded"
14841 changelog_deregister
14843 run_test 160k "Verify that changelog records are not lost"
14846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14848 test_mkdir -c1 $DIR/$tdir
14849 cp /etc/hosts $DIR/$tdir/$tfile
14850 test_mkdir -c1 $DIR/$tdir/foo1
14851 test_mkdir -c1 $DIR/$tdir/foo2
14852 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
14853 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
14854 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
14855 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
14856 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
14857 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14858 $LFS fid2path $DIR $FID
14859 error "bad link ea"
14862 rm $DIR/$tdir/foo2/zachary
14864 rm $DIR/$tdir/foo2/thor
14866 rm $DIR/$tdir/$tfile
14868 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
14869 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
14870 { $LFS fid2path $DIR $FID; error "bad link rename"; }
14871 rm $DIR/$tdir/foo2/maggie
14874 local longname=$tfile.avg_len_is_thirty_two_
14875 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
14876 error_noexit 'failed to unlink many hardlinks'" EXIT
14877 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
14878 error "failed to hardlink many files"
14879 links=$($LFS fid2path $DIR $FID | wc -l)
14880 echo -n "${links}/1000 links in link EA"
14881 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
14883 run_test 161a "link ea sanity"
14886 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14887 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
14890 local remote_dir=$DIR/$tdir/remote_dir
14892 mkdir -p $DIR/$tdir
14893 $LFS mkdir -i $MDTIDX $remote_dir ||
14894 error "create remote directory failed"
14896 cp /etc/hosts $remote_dir/$tfile
14897 mkdir -p $remote_dir/foo1
14898 mkdir -p $remote_dir/foo2
14899 ln $remote_dir/$tfile $remote_dir/foo1/sofia
14900 ln $remote_dir/$tfile $remote_dir/foo2/zachary
14901 ln $remote_dir/$tfile $remote_dir/foo1/luna
14902 ln $remote_dir/$tfile $remote_dir/foo2/thor
14904 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
14906 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
14907 $LFS fid2path $DIR $FID
14908 error "bad link ea"
14911 rm $remote_dir/foo2/zachary
14913 rm $remote_dir/foo2/thor
14915 rm $remote_dir/$tfile
14917 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
14918 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
14919 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
14920 $LFS fid2path $DIR $FID
14921 error "bad link rename"
14923 rm $remote_dir/foo2/maggie
14926 local longname=filename_avg_len_is_thirty_two_
14927 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
14928 error "failed to hardlink many files"
14929 links=$($LFS fid2path $DIR $FID | wc -l)
14930 echo -n "${links}/1000 links in link EA"
14931 [[ ${links} -gt 60 ]] ||
14932 error "expected at least 60 links in link EA"
14933 unlinkmany $remote_dir/foo2/$longname 1000 ||
14934 error "failed to unlink many hardlinks"
14936 run_test 161b "link ea sanity under remote directory"
14939 remote_mds_nodsh && skip "remote MDS with nodsh"
14940 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14941 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
14942 skip "Need MDS version at least 2.1.5"
14944 # define CLF_RENAME_LAST 0x0001
14945 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
14946 changelog_register || error "changelog_register failed"
14949 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
14950 touch $DIR/$tdir/foo_161c
14951 touch $DIR/$tdir/bar_161c
14952 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14953 changelog_dump | grep RENME | tail -n 5
14954 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14955 changelog_clear 0 || error "changelog_clear failed"
14956 if [ x$flags != "x0x1" ]; then
14957 error "flag $flags is not 0x1"
14960 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
14961 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
14962 touch $DIR/$tdir/foo_161c
14963 touch $DIR/$tdir/bar_161c
14964 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
14965 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
14966 changelog_dump | grep RENME | tail -n 5
14967 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
14968 changelog_clear 0 || error "changelog_clear failed"
14969 if [ x$flags != "x0x0" ]; then
14970 error "flag $flags is not 0x0"
14972 echo "rename overwrite a target having nlink > 1," \
14973 "changelog record has flags of $flags"
14975 # rename doesn't overwrite a target (changelog flag 0x0)
14976 touch $DIR/$tdir/foo_161c
14977 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
14978 changelog_dump | grep RENME | tail -n 5
14979 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
14980 changelog_clear 0 || error "changelog_clear failed"
14981 if [ x$flags != "x0x0" ]; then
14982 error "flag $flags is not 0x0"
14984 echo "rename doesn't overwrite a target," \
14985 "changelog record has flags of $flags"
14987 # define CLF_UNLINK_LAST 0x0001
14988 # unlink a file having nlink = 1 (changelog flag 0x1)
14989 rm -f $DIR/$tdir/foo2_161c
14990 changelog_dump | grep UNLNK | tail -n 5
14991 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
14992 changelog_clear 0 || error "changelog_clear failed"
14993 if [ x$flags != "x0x1" ]; then
14994 error "flag $flags is not 0x1"
14996 echo "unlink a file having nlink = 1," \
14997 "changelog record has flags of $flags"
14999 # unlink a file having nlink > 1 (changelog flag 0x0)
15000 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
15001 rm -f $DIR/$tdir/foobar_161c
15002 changelog_dump | grep UNLNK | tail -n 5
15003 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
15004 changelog_clear 0 || error "changelog_clear failed"
15005 if [ x$flags != "x0x0" ]; then
15006 error "flag $flags is not 0x0"
15008 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
15010 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
15013 remote_mds_nodsh && skip "remote MDS with nodsh"
15014 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
15019 changelog_register || error "changelog_register failed"
15021 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
15022 # interfer with $MOUNT/.lustre/fid/ access
15024 [[ $? -eq 0 ]] || error "mkdir failed"
15026 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
15027 $LCTL set_param fail_loc=0x8000140c
15029 $LCTL set_param fail_val=5
15032 echo foofoo > $DIR/$tdir/$tfile &
15035 # wait for create to be delayed
15039 [[ $? -eq 0 ]] || error "create should be blocked"
15041 local tempfile="$(mktemp --tmpdir $tfile.XXXXXX)"
15042 stack_trap "rm -f $tempfile"
15043 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
15044 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
15045 # some delay may occur during ChangeLog publishing and file read just
15046 # above, that could allow file write to happen finally
15047 [[ -s $tempfile ]] && echo "file should be empty"
15049 $LCTL set_param fail_loc=0
15052 [[ $? -eq 0 ]] || error "create failed"
15054 run_test 161d "create with concurrent .lustre/fid access"
15057 local expected="$1"
15062 path=$($LFS fid2path "$@")
15065 if [ $rc -ne 0 ]; then
15066 error "path looked up of '$expected' failed: rc=$rc"
15067 elif [ "$path" != "$expected" ]; then
15068 error "path looked up '$path' instead of '$expected'"
15070 echo "FID '$fid' resolves to path '$path' as expected"
15074 test_162a() { # was test_162
15075 test_mkdir -p -c1 $DIR/$tdir/d2
15076 touch $DIR/$tdir/d2/$tfile
15077 touch $DIR/$tdir/d2/x1
15078 touch $DIR/$tdir/d2/x2
15079 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
15080 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
15082 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
15083 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
15086 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
15087 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
15088 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
15090 # softlink to wrong file
15091 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
15092 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
15093 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
15096 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
15097 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
15098 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
15099 # fid2path dir/fsname should both work
15100 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
15101 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
15103 # hardlink count: check that there are 2 links
15104 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
15105 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
15107 # hardlink indexing: remove the first link
15108 rm $DIR/$tdir/d2/p/q/r/hlink
15109 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
15111 run_test 162a "path lookup sanity"
15114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15115 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15118 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
15119 error "create striped dir failed"
15121 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
15122 tail -n 1 | awk '{print $2}')
15123 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
15125 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
15126 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
15129 for ((i=0;i<5;i++)); do
15130 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
15131 error "get fid for f$i failed"
15132 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
15134 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
15135 error "get fid for d$i failed"
15136 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
15141 run_test 162b "striped directory path lookup sanity"
15143 # LU-4239: Verify fid2path works with paths 100 or more directories deep
15145 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
15146 skip "Need MDS version at least 2.7.51"
15148 local lpath=$tdir.local
15149 local rpath=$tdir.remote
15151 test_mkdir $DIR/$lpath
15152 test_mkdir $DIR/$rpath
15154 for ((i = 0; i <= 101; i++)); do
15157 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
15158 error "get fid for local directory $DIR/$lpath failed"
15159 check_path "$DIR/$lpath" $MOUNT $FID --link 0
15162 test_mkdir $DIR/$rpath
15163 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
15164 error "get fid for remote directory $DIR/$rpath failed"
15165 check_path "$DIR/$rpath" $MOUNT $FID --link 0
15170 run_test 162c "fid2path works with paths 100 or more directories deep"
15172 oalr_event_count() {
15176 awk -v name="${FSNAME}-OST0000" \
15177 -v event="${event}" \
15178 '$1 == "TRACE" && $2 == event && $3 == name' \
15183 oalr_expect_event_count() {
15186 local expect="${3}"
15189 count=$(oalr_event_count "${event}" "${trace}")
15190 if ((count == expect)); then
15194 error_noexit "${event} event count was '${count}', expected ${expect}"
15200 do_facet ost1 killall --quiet -KILL ofd_access_log_reader || true
15202 start ost1 "$(ostdevname 1)" $OST_MOUNT_OPTS
15206 sync # Flush previous IOs so we can count log entries.
15207 do_facet ost1 $LCTL set_param "obdfilter.${FSNAME}-OST0000.access_log_size=4096"
15208 stack_trap cleanup_165 EXIT
15212 local trace="/tmp/${tfile}.trace"
15216 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15220 do_facet ost1 ofd_access_log_reader --list
15223 do_facet ost1 killall -TERM ofd_access_log_reader
15227 if ((rc != 0)); then
15228 error "ofd_access_log_reader exited with rc = '${rc}'"
15231 # Parse trace file for discovery events:
15232 oalr_expect_event_count alr_log_add "${trace}" 1
15233 oalr_expect_event_count alr_log_eof "${trace}" 1
15234 oalr_expect_event_count alr_log_free "${trace}" 1
15236 run_test 165a "ofd access log discovery"
15239 local trace="/tmp/${tfile}.trace"
15240 local file="${DIR}/${tfile}"
15251 lfs setstripe -c 1 -i 0 "${file}"
15252 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15253 do_facet ost1 ofd_access_log_reader --list
15255 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15257 do_facet ost1 killall -TERM ofd_access_log_reader
15261 if ((rc != 0)); then
15262 error "ofd_access_log_reader exited with rc = '${rc}'"
15265 oalr_expect_event_count alr_log_entry "${trace}" 1
15267 pfid1=$($LFS path2fid "${file}")
15269 # 1 2 3 4 5 6 7 8 9 10
15270 # TRACE alr_log_entry OST PFID BEGIN END TIME SIZE COUNT FLAGS
15271 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
15273 echo "entry = '${entry[*]}'" >&2
15276 if [[ "${pfid1}" != "${pfid2}" ]]; then
15277 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
15281 if ((size != 1048576)); then
15282 error "entry '${entry[*]}' has invalid io size '${size}', expected 1048576"
15286 if [[ "${flags}" != "w" ]]; then
15287 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'w'"
15290 do_facet ost1 ofd_access_log_reader --debug=- --trace=- > "${trace}" &
15291 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r524288c || error "cannot read '${file}'"
15293 do_facet ost1 killall -TERM ofd_access_log_reader
15297 if ((rc != 0)); then
15298 error "ofd_access_log_reader exited with rc = '${rc}'"
15301 oalr_expect_event_count alr_log_entry "${trace}" 1
15303 entry=( - $(awk -v pfid="${pfid}" '$1 == "TRACE" && $2 == "alr_log_entry"' "${trace}" ) )
15304 echo "entry = '${entry[*]}'" >&2
15307 if [[ "${pfid1}" != "${pfid2}" ]]; then
15308 error "entry '${entry[*]}' has invalid PFID '${pfid2}', expected ${pfid1}"
15312 if ((size != 524288)); then
15313 error "entry '${entry[*]}' has invalid io size '${size}', 524288"
15317 if [[ "${flags}" != "r" ]]; then
15318 error "entry '${entry[*]}' has invalid io flags '${flags}', expected 'r'"
15321 run_test 165b "ofd access log entries are produced and consumed"
15324 local file="${DIR}/${tdir}/${tfile}"
15325 test_mkdir "${DIR}/${tdir}"
15329 lfs setstripe -c 1 -i 0 "${DIR}/${tdir}"
15331 # 4096 / 64 = 64. Create twice as many entries.
15332 for ((i = 0; i < 128; i++)); do
15333 $MULTIOP "${file}-${i}" oO_CREAT:O_WRONLY:w512c || error "cannot create file"
15337 do_facet ost1 ofd_access_log_reader --list
15338 unlinkmany "${file}-%d" 128
15340 run_test 165c "full ofd access logs do not block IOs"
15342 oal_peek_entry_count() {
15343 do_facet ost1 ofd_access_log_reader --list | awk '$1 == "_entry_count:" { print $2; }'
15346 oal_expect_entry_count() {
15347 local entry_count=$(oal_peek_entry_count)
15350 if ((entry_count == expect)); then
15354 error_noexit "bad entry count, got ${entry_count}, expected ${expect}"
15355 do_facet ost1 ofd_access_log_reader --list >&2
15360 local trace="/tmp/${tfile}.trace"
15361 local file="${DIR}/${tdir}/${tfile}"
15362 local param="obdfilter.${FSNAME}-OST0000.access_log_mask"
15364 test_mkdir "${DIR}/${tdir}"
15367 lfs setstripe -c 1 -i 0 "${file}"
15369 do_facet ost1 lctl set_param "${param}=rw"
15370 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15371 oal_expect_entry_count 1
15373 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15374 oal_expect_entry_count 2
15376 do_facet ost1 lctl set_param "${param}=r"
15377 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15378 oal_expect_entry_count 2
15380 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15381 oal_expect_entry_count 3
15383 do_facet ost1 lctl set_param "${param}=w"
15384 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15385 oal_expect_entry_count 4
15387 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15388 oal_expect_entry_count 4
15390 do_facet ost1 lctl set_param "${param}=0"
15391 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_WRONLY:w1048576c || error "cannot create '${file}'"
15392 oal_expect_entry_count 4
15394 $MULTIOP "${file}" oO_CREAT:O_DIRECT:O_RDONLY:r1048576c || error "cannot read '${file}'"
15395 oal_expect_entry_count 4
15397 run_test 165d "ofd_access_log mask works"
15400 # do directio so as not to populate the page cache
15401 log "creating a 10 Mb file"
15402 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15403 log "starting reads"
15404 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15405 log "truncating the file"
15406 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15408 kill %+ || true # reads might have finished
15409 echo "wait until dd is finished"
15411 log "removing the temporary file"
15412 rm -rf $DIR/$tfile || error "tmp file removal failed"
15414 run_test 169 "parallel read and truncate should not deadlock"
15417 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15419 $LCTL clear # bug 18514
15420 $LCTL debug_daemon start $TMP/${tfile}_log_good
15422 $LCTL debug_daemon stop
15423 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
15424 error "sed failed to read log_good"
15426 $LCTL debug_daemon start $TMP/${tfile}_log_good
15428 $LCTL debug_daemon stop
15430 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
15431 error "lctl df log_bad failed"
15433 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
15434 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
15436 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
15437 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
15439 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
15440 error "bad_line good_line1 good_line2 are empty"
15442 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
15443 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
15444 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
15446 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
15447 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
15448 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
15450 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
15451 error "bad_line_new good_line_new are empty"
15453 local expected_good=$((good_line1 + good_line2*2))
15455 rm -f $TMP/${tfile}*
15456 # LU-231, short malformed line may not be counted into bad lines
15457 if [ $bad_line -ne $bad_line_new ] &&
15458 [ $bad_line -ne $((bad_line_new - 1)) ]; then
15459 error "expected $bad_line bad lines, but got $bad_line_new"
15463 if [ $expected_good -ne $good_line_new ]; then
15464 error "expected $expected_good good lines, but got $good_line_new"
15469 run_test 170 "test lctl df to handle corrupted log ====================="
15471 test_171() { # bug20592
15472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15474 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
15475 $LCTL set_param fail_loc=0x50e
15476 $LCTL set_param fail_val=3000
15477 multiop_bg_pause $DIR/$tfile O_s || true
15479 kill -USR1 $MULTIPID
15483 if dmesg | grep "recursive fault"; then
15484 error "caught a recursive fault"
15486 $LCTL set_param fail_loc=0
15489 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
15491 # it would be good to share it with obdfilter-survey/iokit-libecho code
15492 setup_obdecho_osc () {
15495 local obdfilter_name=$2
15496 echo "Creating new osc for $obdfilter_name on $ost_nid"
15497 # make sure we can find loopback nid
15498 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
15500 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
15501 ${obdfilter_name}_osc_UUID || rc=2; }
15502 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
15503 ${obdfilter_name}_UUID $ost_nid || rc=3; }
15507 cleanup_obdecho_osc () {
15508 local obdfilter_name=$1
15509 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
15510 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
15517 local pages=${3:-64}
15522 local obd_size=$(get_obd_size $node $OBD)
15523 local page_size=$(get_page_size $node)
15524 if [[ -n "$obd_size" ]]; then
15525 local new_count=$((obd_size / (pages * page_size / 1024)))
15526 [[ $new_count -ge $count ]] || count=$new_count
15529 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
15530 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
15532 if [ $rc -eq 0 ]; then
15533 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
15534 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
15536 echo "New object id is $id"
15537 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
15539 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
15540 "test_brw $count w v $pages $id" || rc=4; }
15541 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
15543 [ $rc -eq 0 ] || [ $rc -gt 2 ] &&
15544 { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
15545 [ $rc -eq 0 ] || [ $rc -gt 1 ] &&
15546 { do_facet $node "$LCTL --device ec detach" || rc=6; }
15547 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
15552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15554 if ! module_loaded obdecho; then
15555 load_module obdecho/obdecho &&
15556 stack_trap "rmmod obdecho" EXIT ||
15557 error "unable to load obdecho on client"
15560 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
15561 local host=$($LCTL get_param -n osc.$osc.import |
15562 awk '/current_connection:/ { print $2 }' )
15563 local target=$($LCTL get_param -n osc.$osc.import |
15564 awk '/target:/ { print $2 }' )
15565 target=${target%_UUID}
15567 if [ -n "$target" ]; then
15568 setup_obdecho_osc $host $target &&
15569 stack_trap "cleanup_obdecho_osc $target" EXIT ||
15570 { error "obdecho setup failed with $?"; return; }
15572 obdecho_test ${target}_osc client ||
15573 error "obdecho_test failed on ${target}_osc"
15575 $LCTL get_param osc.$osc.import
15576 error "there is no osc.$osc.import target"
15579 run_test 180a "test obdecho on osc"
15582 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15583 remote_ost_nodsh && skip "remote OST with nodsh"
15585 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15586 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15587 error "failed to load module obdecho"
15589 local target=$(do_facet ost1 $LCTL dl |
15590 awk '/obdfilter/ { print $4; exit; }')
15592 if [ -n "$target" ]; then
15593 obdecho_test $target ost1 || error "obdecho_test failed with $?"
15595 do_facet ost1 $LCTL dl
15596 error "there is no obdfilter target on ost1"
15599 run_test 180b "test obdecho directly on obdfilter"
15601 test_180c() { # LU-2598
15602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15603 remote_ost_nodsh && skip "remote OST with nodsh"
15604 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
15605 skip "Need MDS version at least 2.4.0"
15607 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
15608 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
15609 error "failed to load module obdecho"
15611 local target=$(do_facet ost1 $LCTL dl |
15612 awk '/obdfilter/ { print $4; exit; }')
15614 if [ -n "$target" ]; then
15615 local pages=16384 # 64MB bulk I/O RPC size
15617 obdecho_test "$target" ost1 "$pages" ||
15618 error "obdecho_test with pages=$pages failed with $?"
15620 do_facet ost1 $LCTL dl
15621 error "there is no obdfilter target on ost1"
15624 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
15626 test_181() { # bug 22177
15627 test_mkdir $DIR/$tdir
15628 # create enough files to index the directory
15629 createmany -o $DIR/$tdir/foobar 4000
15630 # print attributes for debug purpose
15633 multiop_bg_pause $DIR/$tdir D_Sc || return 1
15635 # remove the files & current working dir
15636 unlinkmany $DIR/$tdir/foobar 4000
15638 kill -USR1 $MULTIPID
15640 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
15643 run_test 181 "Test open-unlinked dir ========================"
15649 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15651 $LCTL set_param mdc.*.rpc_stats=clear
15653 for (( i = 0; i < $tcount; i++ )) ; do
15654 mkdir $DIR/$tdir/$i
15657 for (( i = 0; i < $tcount; i++ )) ; do
15658 createmany -o $DIR/$tdir/$i/f- $fcount &
15662 for (( i = 0; i < $tcount; i++ )) ; do
15663 unlinkmany $DIR/$tdir/$i/f- $fcount &
15667 $LCTL get_param mdc.*.rpc_stats
15671 run_test 182 "Test parallel modify metadata operations ================"
15673 test_183() { # LU-2275
15674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15675 remote_mds_nodsh && skip "remote MDS with nodsh"
15676 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
15677 skip "Need MDS version at least 2.3.56"
15679 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15680 echo aaa > $DIR/$tdir/$tfile
15682 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
15683 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
15685 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
15686 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
15688 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15690 # Flush negative dentry cache
15691 touch $DIR/$tdir/$tfile
15693 # We are not checking for any leaked references here, they'll
15694 # become evident next time we do cleanup with module unload.
15697 run_test 183 "No crash or request leak in case of strange dispositions ========"
15699 # test suite 184 is for LU-2016, LU-2017
15701 check_swap_layouts_support
15703 dir0=$DIR/$tdir/$testnum
15704 test_mkdir -p -c1 $dir0
15709 $LFS setstripe -c1 $file1
15711 $LFS setstripe -c2 $file2
15713 gen1=$($LFS getstripe -g $file1)
15714 gen2=$($LFS getstripe -g $file2)
15716 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
15717 gen=$($LFS getstripe -g $file1)
15718 [[ $gen1 != $gen ]] ||
15719 "Layout generation on $file1 does not change"
15720 gen=$($LFS getstripe -g $file2)
15721 [[ $gen2 != $gen ]] ||
15722 "Layout generation on $file2 does not change"
15724 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
15725 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15727 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
15729 run_test 184a "Basic layout swap"
15732 check_swap_layouts_support
15734 dir0=$DIR/$tdir/$testnum
15735 mkdir -p $dir0 || error "creating dir $dir0"
15742 $LFS setstripe -c1 $file1
15743 $LFS setstripe -c2 $file2
15744 $LFS setstripe -c1 $file3
15745 chown $RUNAS_ID $file3
15746 gen1=$($LFS getstripe -g $file1)
15747 gen2=$($LFS getstripe -g $file2)
15749 $LFS swap_layouts $dir1 $dir2 &&
15750 error "swap of directories layouts should fail"
15751 $LFS swap_layouts $dir1 $file1 &&
15752 error "swap of directory and file layouts should fail"
15753 $RUNAS $LFS swap_layouts $file1 $file2 &&
15754 error "swap of file we cannot write should fail"
15755 $LFS swap_layouts $file1 $file3 &&
15756 error "swap of file with different owner should fail"
15757 /bin/true # to clear error code
15759 run_test 184b "Forbidden layout swap (will generate errors)"
15762 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
15763 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
15764 check_swap_layouts_support
15766 local dir0=$DIR/$tdir/$testnum
15767 mkdir -p $dir0 || error "creating dir $dir0"
15769 local ref1=$dir0/ref1
15770 local ref2=$dir0/ref2
15771 local file1=$dir0/file1
15772 local file2=$dir0/file2
15773 # create a file large enough for the concurrent test
15774 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
15775 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
15776 echo "ref file size: ref1($(stat -c %s $ref1))," \
15777 "ref2($(stat -c %s $ref2))"
15780 dd if=$ref1 of=$file1 bs=16k &
15783 # Make sure dd starts to copy file
15784 while [ ! -f $file1 ]; do sleep 0.1; done
15786 $LFS swap_layouts $file1 $file2
15789 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
15790 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
15792 # how many bytes copied before swapping layout
15793 local copied=$(stat -c %s $file2)
15794 local remaining=$(stat -c %s $ref1)
15795 remaining=$((remaining - copied))
15796 echo "Copied $copied bytes before swapping layout..."
15798 cmp -n $copied $file1 $ref2 | grep differ &&
15799 error "Content mismatch [0, $copied) of ref2 and file1"
15800 cmp -n $copied $file2 $ref1 ||
15801 error "Content mismatch [0, $copied) of ref1 and file2"
15802 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
15803 error "Content mismatch [$copied, EOF) of ref1 and file1"
15806 rm -f $ref1 $ref2 $file1 $file2
15808 run_test 184c "Concurrent write and layout swap"
15811 check_swap_layouts_support
15812 [ -z "$(which getfattr 2>/dev/null)" ] &&
15813 skip_env "no getfattr command"
15815 local file1=$DIR/$tdir/$tfile-1
15816 local file2=$DIR/$tdir/$tfile-2
15817 local file3=$DIR/$tdir/$tfile-3
15821 mkdir -p $DIR/$tdir
15822 touch $file1 || error "create $file1 failed"
15823 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15824 error "create $file2 failed"
15825 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15826 error "create $file3 failed"
15827 lovea1=$(get_layout_param $file1)
15829 $LFS swap_layouts $file2 $file3 ||
15830 error "swap $file2 $file3 layouts failed"
15831 $LFS swap_layouts $file1 $file2 ||
15832 error "swap $file1 $file2 layouts failed"
15834 lovea2=$(get_layout_param $file2)
15837 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
15839 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15840 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
15842 run_test 184d "allow stripeless layouts swap"
15845 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
15846 skip "Need MDS version at least 2.6.94"
15847 check_swap_layouts_support
15848 [ -z "$(which getfattr 2>/dev/null)" ] &&
15849 skip_env "no getfattr command"
15851 local file1=$DIR/$tdir/$tfile-1
15852 local file2=$DIR/$tdir/$tfile-2
15853 local file3=$DIR/$tdir/$tfile-3
15856 mkdir -p $DIR/$tdir
15857 touch $file1 || error "create $file1 failed"
15858 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
15859 error "create $file2 failed"
15860 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
15861 error "create $file3 failed"
15863 $LFS swap_layouts $file1 $file2 ||
15864 error "swap $file1 $file2 layouts failed"
15866 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
15867 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
15869 echo 123 > $file1 || error "Should be able to write into $file1"
15871 $LFS swap_layouts $file1 $file3 ||
15872 error "swap $file1 $file3 layouts failed"
15874 echo 123 > $file1 || error "Should be able to write into $file1"
15876 rm -rf $file1 $file2 $file3
15878 run_test 184e "Recreate layout after stripeless layout swaps"
15881 # Create a file with name longer than sizeof(struct stat) ==
15882 # 144 to see if we can get chars from the file name to appear
15883 # in the returned striping. Note that 'f' == 0x66.
15884 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
15886 mkdir -p $DIR/$tdir
15887 mcreate $DIR/$tdir/$file
15888 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
15889 error "IOC_MDC_GETFILEINFO returned garbage striping"
15892 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
15894 test_185() { # LU-2441
15895 # LU-3553 - no volatile file support in old servers
15896 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
15897 skip "Need MDS version at least 2.3.60"
15899 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
15900 touch $DIR/$tdir/spoo
15901 local mtime1=$(stat -c "%Y" $DIR/$tdir)
15902 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
15903 error "cannot create/write a volatile file"
15904 [ "$FILESET" == "" ] &&
15905 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
15906 error "FID is still valid after close"
15908 multiop_bg_pause $DIR/$tdir vVw4096_c
15915 # assume that the next FID for this client is sequential, since stdout
15916 # is unfortunately eaten by multiop_bg_pause
15917 local n=$((${fidv[1]} + 1))
15918 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
15919 if [ "$FILESET" == "" ]; then
15920 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
15921 error "FID is missing before close"
15923 kill -USR1 $multi_pid
15924 # 1 second delay, so if mtime change we will see it
15926 local mtime2=$(stat -c "%Y" $DIR/$tdir)
15927 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
15929 run_test 185 "Volatile file support"
15931 function create_check_volatile() {
15935 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
15938 local FID=$(cat /tmp/${tfile}.fid)
15939 [ "$FID" == "" ] && error "can't get FID for volatile"
15940 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
15941 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
15942 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
15946 cancel_lru_locks mdc # flush opencache
15947 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
15952 # LU-12516 - volatile creation via .lustre
15953 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
15954 skip "Need MDS version at least 2.3.55"
15956 create_check_volatile 0
15957 [ $MDSCOUNT -lt 2 ] && return 0
15960 create_check_volatile 1
15964 run_test 185a "Volatile file creation in .lustre/fid/"
15967 remote_mds_nodsh && skip "remote MDS with nodsh"
15968 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15969 skip "Need MDS version at least 2.3.0"
15971 local dir0=$DIR/$tdir/$testnum
15972 mkdir -p $dir0 || error "creating dir $dir0"
15974 local file=$dir0/file1
15975 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
15976 local dv1=$($LFS data_version $file)
15977 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
15978 local dv2=$($LFS data_version $file)
15979 [[ $dv1 != $dv2 ]] ||
15980 error "data version did not change on write $dv1 == $dv2"
15985 run_test 187a "Test data version change"
15988 remote_mds_nodsh && skip "remote MDS with nodsh"
15989 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
15990 skip "Need MDS version at least 2.3.0"
15992 local dir0=$DIR/$tdir/$testnum
15993 mkdir -p $dir0 || error "creating dir $dir0"
15995 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
15996 [[ ${DV[0]} != ${DV[1]} ]] ||
15997 error "data version did not change on write"\
15998 " ${DV[0]} == ${DV[1]}"
16003 run_test 187b "Test data version change on volatile file"
16006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16007 remote_mgs_nodsh && skip "remote MGS with nodsh"
16008 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
16010 local POOL=${POOL:-cea1}
16011 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
16012 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
16015 local last_ost=$(($OSTCOUNT - 1))
16017 local ost_list=$(seq $first_ost $ost_step $last_ost)
16018 local ost_range="$first_ost $last_ost $ost_step"
16019 local test_path=$POOL_ROOT/$POOL_DIR_NAME
16020 local file_dir=$POOL_ROOT/file_tst
16021 local subdir=$test_path/subdir
16025 # former test_200a test_200b
16026 pool_add $POOL || { rc=$? ; break; }
16027 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
16028 # former test_200c test_200d
16029 mkdir -p $test_path
16030 pool_set_dir $POOL $test_path || { rc=$? ; break; }
16031 pool_check_dir $POOL $test_path || { rc=$? ; break; }
16033 pool_check_dir $POOL $subdir || { rc=$? ; break; }
16034 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
16035 || { rc=$? ; break; }
16036 # former test_200e test_200f
16037 local files=$((OSTCOUNT*3))
16038 pool_alloc_files $POOL $test_path $files "$ost_list" \
16039 || { rc=$? ; break; }
16040 pool_create_files $POOL $file_dir $files "$ost_list" \
16041 || { rc=$? ; break; }
16042 # former test_200g test_200h
16043 pool_lfs_df $POOL || { rc=$? ; break; }
16044 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
16046 # former test_201a test_201b test_201c
16047 pool_remove_first_target $POOL || { rc=$? ; break; }
16049 local f=$test_path/$tfile
16050 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
16051 pool_remove $POOL $f || { rc=$? ; break; }
16059 run_test 200 "OST pools"
16061 # usage: default_attr <count | size | offset>
16063 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
16066 # usage: check_default_stripe_attr
16067 check_default_stripe_attr() {
16068 ACTUAL=$($LFS getstripe $* $DIR/$tdir)
16071 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
16073 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
16077 error "unknown getstripe attr '$1'"
16080 [ $ACTUAL == $EXPECTED ] ||
16081 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
16085 test_mkdir $DIR/$tdir
16086 $LFS setstripe --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
16088 check_default_stripe_attr --stripe-count
16089 check_default_stripe_attr --stripe-size
16090 check_default_stripe_attr --stripe-index
16092 run_test 204a "Print default stripe attributes"
16095 test_mkdir $DIR/$tdir
16096 $LFS setstripe --stripe-count 1 $DIR/$tdir
16098 check_default_stripe_attr --stripe-size
16099 check_default_stripe_attr --stripe-index
16101 run_test 204b "Print default stripe size and offset"
16104 test_mkdir $DIR/$tdir
16105 $LFS setstripe --stripe-size 65536 $DIR/$tdir
16107 check_default_stripe_attr --stripe-count
16108 check_default_stripe_attr --stripe-index
16110 run_test 204c "Print default stripe count and offset"
16113 test_mkdir $DIR/$tdir
16114 $LFS setstripe --stripe-index 0 $DIR/$tdir
16116 check_default_stripe_attr --stripe-count
16117 check_default_stripe_attr --stripe-size
16119 run_test 204d "Print default stripe count and size"
16122 test_mkdir $DIR/$tdir
16123 $LFS setstripe -d $DIR/$tdir
16125 check_default_stripe_attr --stripe-count --raw
16126 check_default_stripe_attr --stripe-size --raw
16127 check_default_stripe_attr --stripe-index --raw
16129 run_test 204e "Print raw stripe attributes"
16132 test_mkdir $DIR/$tdir
16133 $LFS setstripe --stripe-count 1 $DIR/$tdir
16135 check_default_stripe_attr --stripe-size --raw
16136 check_default_stripe_attr --stripe-index --raw
16138 run_test 204f "Print raw stripe size and offset"
16141 test_mkdir $DIR/$tdir
16142 $LFS setstripe --stripe-size 65536 $DIR/$tdir
16144 check_default_stripe_attr --stripe-count --raw
16145 check_default_stripe_attr --stripe-index --raw
16147 run_test 204g "Print raw stripe count and offset"
16150 test_mkdir $DIR/$tdir
16151 $LFS setstripe --stripe-index 0 $DIR/$tdir
16153 check_default_stripe_attr --stripe-count --raw
16154 check_default_stripe_attr --stripe-size --raw
16156 run_test 204h "Print raw stripe count and size"
16158 # Figure out which job scheduler is being used, if any,
16159 # or use a fake one
16160 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
16161 JOBENV=SLURM_JOB_ID
16162 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
16164 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
16166 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
16167 JOBENV=LOADL_STEP_ID
16168 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
16171 $LCTL list_param jobid_name > /dev/null 2>&1
16172 if [ $? -eq 0 ]; then
16178 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
16180 verify_jobstats() {
16185 # we don't really need to clear the stats for this test to work, since each
16186 # command has a unique jobid, but it makes debugging easier if needed.
16187 # for facet in $facets; do
16188 # local dev=$(convert_facet2label $facet)
16189 # # clear old jobstats
16190 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
16193 # use a new JobID for each test, or we might see an old one
16194 [ "$JOBENV" = "FAKE_JOBID" ] &&
16195 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
16197 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
16199 [ "$JOBENV" = "nodelocal" ] && {
16200 FAKE_JOBID=id.$testnum.%e.$RANDOM
16201 $LCTL set_param jobid_name=$FAKE_JOBID
16202 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
16205 log "Test: ${cmd[*]}"
16206 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
16208 if [ $JOBENV = "FAKE_JOBID" ]; then
16209 FAKE_JOBID=$JOBVAL ${cmd[*]}
16214 # all files are created on OST0000
16215 for facet in $facets; do
16216 local stats="*.$(convert_facet2label $facet).job_stats"
16218 # strip out libtool wrappers for in-tree executables
16219 if [ $(do_facet $facet lctl get_param $stats |
16220 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
16221 do_facet $facet lctl get_param $stats
16222 error "No jobstats for $JOBVAL found on $facet::$stats"
16228 local new_jobenv=$1
16230 set_persistent_param_and_check client "jobid_var" \
16231 "$FSNAME.sys.jobid_var" $new_jobenv
16234 test_205a() { # Job stats
16235 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16236 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
16237 skip "Need MDS version with at least 2.7.1"
16238 remote_mgs_nodsh && skip "remote MGS with nodsh"
16239 remote_mds_nodsh && skip "remote MDS with nodsh"
16240 remote_ost_nodsh && skip "remote OST with nodsh"
16241 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
16242 skip "Server doesn't support jobstats"
16243 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
16245 local old_jobenv=$($LCTL get_param -n jobid_var)
16246 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
16248 if [[ $PERM_CMD == *"set_param -P"* ]]; then
16249 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
16251 stack_trap "do_facet mgs $PERM_CMD \
16252 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
16256 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
16257 mdt.*.job_cleanup_interval | head -n 1)
16258 local new_interval=5
16259 do_facet $SINGLEMDS \
16260 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
16261 stack_trap "do_facet $SINGLEMDS \
16262 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
16263 local start=$SECONDS
16267 cmd="mkdir $DIR/$tdir"
16268 verify_jobstats "$cmd" "$SINGLEMDS"
16270 cmd="rmdir $DIR/$tdir"
16271 verify_jobstats "$cmd" "$SINGLEMDS"
16272 # mkdir on secondary MDT
16273 if [ $MDSCOUNT -gt 1 ]; then
16274 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
16275 verify_jobstats "$cmd" "mds2"
16278 cmd="mknod $DIR/$tfile c 1 3"
16279 verify_jobstats "$cmd" "$SINGLEMDS"
16281 cmd="rm -f $DIR/$tfile"
16282 verify_jobstats "$cmd" "$SINGLEMDS"
16283 # create all files on OST0000 so verify_jobstats can find OST stats
16285 cmd="$LFS setstripe -i 0 -c 1 $DIR/$tfile"
16286 verify_jobstats "$cmd" "$SINGLEMDS"
16288 cmd="touch $DIR/$tfile"
16289 verify_jobstats "$cmd" "$SINGLEMDS ost1"
16291 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
16292 verify_jobstats "$cmd" "ost1"
16294 cancel_lru_locks osc
16295 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
16296 verify_jobstats "$cmd" "ost1"
16298 cmd="$TRUNCATE $DIR/$tfile 0"
16299 verify_jobstats "$cmd" "$SINGLEMDS ost1"
16301 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
16302 verify_jobstats "$cmd" "$SINGLEMDS"
16303 # jobstats expiry - sleep until old stats should be expired
16304 local left=$((new_interval + 5 - (SECONDS - start)))
16305 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
16306 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
16308 cmd="mkdir $DIR/$tdir.expire"
16309 verify_jobstats "$cmd" "$SINGLEMDS"
16310 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
16311 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
16313 # Ensure that jobid are present in changelog (if supported by MDS)
16314 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
16315 changelog_dump | tail -10
16316 jobids=$(changelog_dump | tail -9 | grep -c "j=")
16317 [ $jobids -eq 9 ] ||
16318 error "Wrong changelog jobid count $jobids != 9"
16322 jobstats_set $JOBENV
16324 changelog_dump | grep $tfile
16325 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
16326 [ $jobids -eq 0 ] ||
16327 error "Unexpected jobids when jobid_var=$JOBENV"
16330 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
16331 JOBENV="JOBCOMPLEX"
16332 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
16334 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
16336 run_test 205a "Verify job stats"
16340 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
16341 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
16342 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
16343 grep job_id: | grep foolish &&
16344 error "Unexpected jobid found"
16347 run_test 205b "Verify job stats jobid parsing"
16349 # LU-1480, LU-1773 and LU-1657
16351 mkdir -p $DIR/$tdir
16352 $LFS setstripe -c -1 $DIR/$tdir
16353 #define OBD_FAIL_LOV_INIT 0x1403
16354 $LCTL set_param fail_loc=0xa0001403
16355 $LCTL set_param fail_val=1
16356 touch $DIR/$tdir/$tfile || true
16358 run_test 206 "fail lov_init_raid0() doesn't lbug"
16361 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
16362 local fsz=`stat -c %s $DIR/$tfile`
16363 cancel_lru_locks mdc
16365 # do not return layout in getattr intent
16366 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
16367 $LCTL set_param fail_loc=0x170
16368 local sz=`stat -c %s $DIR/$tfile`
16370 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
16374 run_test 207a "can refresh layout at glimpse"
16377 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
16378 local cksum=`md5sum $DIR/$tfile`
16379 local fsz=`stat -c %s $DIR/$tfile`
16380 cancel_lru_locks mdc
16381 cancel_lru_locks osc
16383 # do not return layout in getattr intent
16384 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
16385 $LCTL set_param fail_loc=0x171
16387 # it will refresh layout after the file is opened but before read issues
16388 echo checksum is "$cksum"
16389 echo "$cksum" |md5sum -c --quiet || error "file differs"
16393 run_test 207b "can refresh layout at open"
16396 # FIXME: in this test suite, only RD lease is used. This is okay
16397 # for now as only exclusive open is supported. After generic lease
16398 # is done, this test suite should be revised. - Jinshan
16400 remote_mds_nodsh && skip "remote MDS with nodsh"
16401 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
16402 skip "Need MDS version at least 2.4.52"
16404 echo "==== test 1: verify get lease work"
16405 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
16407 echo "==== test 2: verify lease can be broken by upcoming open"
16408 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
16412 $MULTIOP $DIR/$tfile oO_RDONLY:c
16413 kill -USR1 $PID && wait $PID || error "break lease error"
16415 echo "==== test 3: verify lease can't be granted if an open already exists"
16416 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
16420 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
16421 kill -USR1 $PID && wait $PID || error "open file error"
16423 echo "==== test 4: lease can sustain over recovery"
16424 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
16430 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
16432 echo "==== test 5: lease broken can't be regained by replay"
16433 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
16437 # open file to break lease and then recovery
16438 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
16441 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
16445 run_test 208 "Exclusive open"
16448 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
16449 skip_env "must have disp_stripe"
16452 sync; sleep 5; sync;
16454 echo 3 > /proc/sys/vm/drop_caches
16455 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
16457 # open/close 500 times
16458 for i in $(seq 500); do
16462 echo 3 > /proc/sys/vm/drop_caches
16463 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
16465 echo "before: $req_before, after: $req_after"
16466 [ $((req_after - req_before)) -ge 300 ] &&
16467 error "open/close requests are not freed"
16470 run_test 209 "read-only open/close requests should be freed promptly"
16474 size=$((size % 8192 + 1))
16475 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
16476 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
16477 rm -f $DIR/f212 $DIR/f212.xyz
16479 run_test 212 "Sendfile test ============================================"
16482 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
16483 cancel_lru_locks osc
16484 lctl set_param fail_loc=0x8000040f
16485 # generate a read lock
16486 cat $DIR/$tfile > /dev/null
16487 # write to the file, it will try to cancel the above read lock.
16488 cat /etc/hosts >> $DIR/$tfile
16490 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
16492 test_214() { # for bug 20133
16493 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
16494 for (( i=0; i < 340; i++ )) ; do
16495 touch $DIR/$tdir/d214c/a$i
16498 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
16499 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
16500 ls $DIR/d214c || error "ls $DIR/d214c failed"
16501 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
16502 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
16504 run_test 214 "hash-indexed directory test - bug 20133"
16506 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
16507 create_lnet_proc_files() {
16508 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
16511 # counterpart of create_lnet_proc_files
16512 remove_lnet_proc_files() {
16513 rm -f $TMP/lnet_$1.sys
16516 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
16517 # 3rd arg as regexp for body
16518 check_lnet_proc_stats() {
16519 local l=$(cat "$TMP/lnet_$1" |wc -l)
16520 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
16522 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
16525 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
16526 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
16527 # optional and can be regexp for 2nd line (lnet.routes case)
16528 check_lnet_proc_entry() {
16529 local blp=2 # blp stands for 'position of 1st line of body'
16530 [ -z "$5" ] || blp=3 # lnet.routes case
16532 local l=$(cat "$TMP/lnet_$1" |wc -l)
16533 # subtracting one from $blp because the body can be empty
16534 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
16536 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
16537 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
16539 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
16540 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
16542 # bail out if any unexpected line happened
16543 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
16544 [ "$?" != 0 ] || error "$2 misformatted"
16547 test_215() { # for bugs 18102, 21079, 21517
16548 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16550 local N='(0|[1-9][0-9]*)' # non-negative numeric
16551 local P='[1-9][0-9]*' # positive numeric
16552 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
16553 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
16554 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
16555 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
16557 local L1 # regexp for 1st line
16558 local L2 # regexp for 2nd line (optional)
16559 local BR # regexp for the rest (body)
16561 # lnet.stats should look as 11 space-separated non-negative numerics
16562 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
16563 create_lnet_proc_files "stats"
16564 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
16565 remove_lnet_proc_files "stats"
16567 # lnet.routes should look like this:
16568 # Routing disabled/enabled
16569 # net hops priority state router
16570 # where net is a string like tcp0, hops > 0, priority >= 0,
16571 # state is up/down,
16572 # router is a string like 192.168.1.1@tcp2
16573 L1="^Routing (disabled|enabled)$"
16574 L2="^net +hops +priority +state +router$"
16575 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
16576 create_lnet_proc_files "routes"
16577 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
16578 remove_lnet_proc_files "routes"
16580 # lnet.routers should look like this:
16581 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
16582 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
16583 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
16584 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
16585 L1="^ref +rtr_ref +alive +router$"
16586 BR="^$P +$P +(up|down) +$NID$"
16587 create_lnet_proc_files "routers"
16588 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
16589 remove_lnet_proc_files "routers"
16591 # lnet.peers should look like this:
16592 # nid refs state last max rtr min tx min queue
16593 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
16594 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
16595 # numeric (0 or >0 or <0), queue >= 0.
16596 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
16597 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
16598 create_lnet_proc_files "peers"
16599 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
16600 remove_lnet_proc_files "peers"
16602 # lnet.buffers should look like this:
16603 # pages count credits min
16604 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
16605 L1="^pages +count +credits +min$"
16606 BR="^ +$N +$N +$I +$I$"
16607 create_lnet_proc_files "buffers"
16608 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
16609 remove_lnet_proc_files "buffers"
16611 # lnet.nis should look like this:
16612 # nid status alive refs peer rtr max tx min
16613 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
16614 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
16615 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
16616 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
16617 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
16618 create_lnet_proc_files "nis"
16619 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
16620 remove_lnet_proc_files "nis"
16622 # can we successfully write to lnet.stats?
16623 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
16625 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
16627 test_216() { # bug 20317
16628 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16629 remote_ost_nodsh && skip "remote OST with nodsh"
16632 local facets=$(get_facets OST)
16633 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16635 save_lustre_params client "osc.*.contention_seconds" > $p
16636 save_lustre_params $facets \
16637 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
16638 save_lustre_params $facets \
16639 "ldlm.namespaces.filter-*.contended_locks" >> $p
16640 save_lustre_params $facets \
16641 "ldlm.namespaces.filter-*.contention_seconds" >> $p
16642 clear_stats osc.*.osc_stats
16644 # agressive lockless i/o settings
16645 do_nodes $(comma_list $(osts_nodes)) \
16646 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
16647 ldlm.namespaces.filter-*.contended_locks=0 \
16648 ldlm.namespaces.filter-*.contention_seconds=60"
16649 lctl set_param -n osc.*.contention_seconds=60
16651 $DIRECTIO write $DIR/$tfile 0 10 4096
16652 $CHECKSTAT -s 40960 $DIR/$tfile
16654 # disable lockless i/o
16655 do_nodes $(comma_list $(osts_nodes)) \
16656 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
16657 ldlm.namespaces.filter-*.contended_locks=32 \
16658 ldlm.namespaces.filter-*.contention_seconds=0"
16659 lctl set_param -n osc.*.contention_seconds=0
16660 clear_stats osc.*.osc_stats
16662 dd if=/dev/zero of=$DIR/$tfile count=0
16663 $CHECKSTAT -s 0 $DIR/$tfile
16665 restore_lustre_params <$p
16669 run_test 216 "check lockless direct write updates file size and kms correctly"
16671 test_217() { # bug 22430
16672 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16677 for node in $(nodes_list); do
16678 nid=$(host_nids_address $node $NETTYPE)
16679 if [[ $nid = *-* ]] ; then
16680 echo "lctl ping $(h2nettype $nid)"
16681 lctl ping $(h2nettype $nid)
16683 echo "skipping $node (no hyphen detected)"
16687 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
16690 # do directio so as not to populate the page cache
16691 log "creating a 10 Mb file"
16692 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
16693 log "starting reads"
16694 dd if=$DIR/$tfile of=/dev/null bs=4096 &
16695 log "truncating the file"
16696 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
16698 kill %+ || true # reads might have finished
16699 echo "wait until dd is finished"
16701 log "removing the temporary file"
16702 rm -rf $DIR/$tfile || error "tmp file removal failed"
16704 run_test 218 "parallel read and truncate should not deadlock"
16707 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16709 # write one partial page
16710 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
16711 # set no grant so vvp_io_commit_write will do sync write
16712 $LCTL set_param fail_loc=0x411
16713 # write a full page at the end of file
16714 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
16716 $LCTL set_param fail_loc=0
16717 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
16718 $LCTL set_param fail_loc=0x411
16719 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
16722 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
16723 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
16725 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
16727 test_220() { #LU-325
16728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16729 remote_ost_nodsh && skip "remote OST with nodsh"
16730 remote_mds_nodsh && skip "remote MDS with nodsh"
16731 remote_mgs_nodsh && skip "remote MGS with nodsh"
16735 # create on MDT0000 so the last_id and next_id are correct
16737 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
16741 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
16742 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
16743 osp.$mdtosc_proc1.prealloc_last_id)
16744 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
16745 osp.$mdtosc_proc1.prealloc_next_id)
16749 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
16750 #define OBD_FAIL_OST_ENOINO 0x229
16751 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
16752 create_pool $FSNAME.$TESTNAME || return 1
16753 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
16755 $LFS setstripe $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
16757 MDSOBJS=$((last_id - next_id))
16758 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
16760 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
16761 echo "OST still has $count kbytes free"
16763 echo "create $MDSOBJS files @next_id..."
16764 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
16766 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16767 osp.$mdtosc_proc1.prealloc_last_id)
16768 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
16769 osp.$mdtosc_proc1.prealloc_next_id)
16771 echo "after creation, last_id=$last_id2, next_id=$next_id2"
16776 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
16777 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
16779 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
16780 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
16781 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16782 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
16783 echo "unlink $MDSOBJS files @$next_id..."
16784 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
16786 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
16789 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16791 dd if=`which date` of=$MOUNT/date oflag=sync
16792 chmod +x $MOUNT/date
16794 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
16795 $LCTL set_param fail_loc=0x80001401
16797 $MOUNT/date > /dev/null
16800 run_test 221 "make sure fault and truncate race to not cause OOM"
16803 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16806 test_mkdir $DIR/$tdir
16807 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16808 createmany -o $DIR/$tdir/$tfile 10
16809 cancel_lru_locks mdc
16810 cancel_lru_locks osc
16811 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16812 $LCTL set_param fail_loc=0x31a
16813 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
16814 $LCTL set_param fail_loc=0
16817 run_test 222a "AGL for ls should not trigger CLIO lock failure"
16820 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16823 test_mkdir $DIR/$tdir
16824 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16825 createmany -o $DIR/$tdir/$tfile 10
16826 cancel_lru_locks mdc
16827 cancel_lru_locks osc
16828 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
16829 $LCTL set_param fail_loc=0x31a
16830 rm -r $DIR/$tdir || error "AGL for rmdir failed"
16831 $LCTL set_param fail_loc=0
16833 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
16836 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16839 test_mkdir $DIR/$tdir
16840 $LFS setstripe -c 1 -i 0 $DIR/$tdir
16841 createmany -o $DIR/$tdir/$tfile 10
16842 cancel_lru_locks mdc
16843 cancel_lru_locks osc
16844 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
16845 $LCTL set_param fail_loc=0x31b
16846 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
16847 $LCTL set_param fail_loc=0
16850 run_test 223 "osc reenqueue if without AGL lock granted ======================="
16852 test_224a() { # LU-1039, MRP-303
16853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16855 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
16856 $LCTL set_param fail_loc=0x508
16857 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
16858 $LCTL set_param fail_loc=0
16861 run_test 224a "Don't panic on bulk IO failure"
16863 test_224b() { # LU-1039, MRP-303
16864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16866 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
16867 cancel_lru_locks osc
16868 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
16869 $LCTL set_param fail_loc=0x515
16870 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
16871 $LCTL set_param fail_loc=0
16874 run_test 224b "Don't panic on bulk IO failure"
16876 test_224c() { # LU-6441
16877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16878 remote_mds_nodsh && skip "remote MDS with nodsh"
16880 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
16881 save_writethrough $p
16882 set_cache writethrough on
16884 local pages_per_rpc=$($LCTL get_param osc.*.max_pages_per_rpc)
16885 local at_max=$($LCTL get_param -n at_max)
16886 local timeout=$($LCTL get_param -n timeout)
16887 local test_at="at_max"
16888 local param_at="$FSNAME.sys.at_max"
16889 local test_timeout="timeout"
16890 local param_timeout="$FSNAME.sys.timeout"
16892 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
16894 set_persistent_param_and_check client "$test_at" "$param_at" 0
16895 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
16897 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
16898 do_facet ost1 "$LCTL set_param fail_loc=0x520"
16899 $LFS setstripe -c 1 -i 0 $DIR/$tfile
16900 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
16902 do_facet ost1 "$LCTL set_param fail_loc=0"
16904 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
16905 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
16908 $LCTL set_param -n $pages_per_rpc
16909 restore_lustre_params < $p
16912 run_test 224c "Don't hang if one of md lost during large bulk RPC"
16914 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
16916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16917 if [ -z ${MDSSURVEY} ]; then
16918 skip_env "mds-survey not found"
16920 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16921 skip "Need MDS version at least 2.2.51"
16923 local mds=$(facet_host $SINGLEMDS)
16924 local target=$(do_nodes $mds 'lctl dl' |
16925 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16927 local cmd1="file_count=1000 thrhi=4"
16928 local cmd2="dir_count=2 layer=mdd stripe_count=0"
16929 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16930 local cmd="$cmd1 $cmd2 $cmd3"
16932 rm -f ${TMP}/mds_survey*
16934 eval $cmd || error "mds-survey with zero-stripe failed"
16935 cat ${TMP}/mds_survey*
16936 rm -f ${TMP}/mds_survey*
16938 run_test 225a "Metadata survey sanity with zero-stripe"
16941 if [ -z ${MDSSURVEY} ]; then
16942 skip_env "mds-survey not found"
16944 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
16945 skip "Need MDS version at least 2.2.51"
16946 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16947 remote_mds_nodsh && skip "remote MDS with nodsh"
16948 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
16949 skip_env "Need to mount OST to test"
16952 local mds=$(facet_host $SINGLEMDS)
16953 local target=$(do_nodes $mds 'lctl dl' |
16954 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
16956 local cmd1="file_count=1000 thrhi=4"
16957 local cmd2="dir_count=2 layer=mdd stripe_count=1"
16958 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
16959 local cmd="$cmd1 $cmd2 $cmd3"
16961 rm -f ${TMP}/mds_survey*
16963 eval $cmd || error "mds-survey with stripe_count failed"
16964 cat ${TMP}/mds_survey*
16965 rm -f ${TMP}/mds_survey*
16967 run_test 225b "Metadata survey sanity with stripe_count = 1"
16969 mcreate_path2fid () {
16975 local path=$DIR/$tdir/$name
16980 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
16981 error "cannot create $desc"
16983 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
16985 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
16987 fid_path=$($LFS fid2path $MOUNT $fid)
16989 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
16991 [ "$path" == "$fid_path" ] ||
16992 error "fid2path returned $fid_path, expected $path"
16994 echo "pass with $path and $fid"
16999 mkdir -p $DIR/$tdir
17001 mcreate_path2fid 0010666 0 0 fifo "FIFO"
17002 mcreate_path2fid 0020666 1 3 null "character special file (null)"
17003 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
17004 mcreate_path2fid 0040666 0 0 dir "directory"
17005 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
17006 mcreate_path2fid 0100666 0 0 file "regular file"
17007 mcreate_path2fid 0120666 0 0 link "symbolic link"
17008 mcreate_path2fid 0140666 0 0 sock "socket"
17010 run_test 226a "call path2fid and fid2path on files of all type"
17013 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17018 mkdir -p $DIR/$tdir
17019 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
17020 error "create remote directory failed"
17021 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
17022 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
17023 "character special file (null)"
17024 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
17025 "character special file (no device)"
17026 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
17027 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
17028 "block special file (loop)"
17029 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
17030 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
17031 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
17033 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
17035 # LU-1299 Executing or running ldd on a truncated executable does not
17036 # cause an out-of-memory condition.
17038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17039 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
17041 dd if=$(which date) of=$MOUNT/date bs=1k count=1
17042 chmod +x $MOUNT/date
17044 $MOUNT/date > /dev/null
17045 ldd $MOUNT/date > /dev/null
17048 run_test 227 "running truncated executable does not cause OOM"
17050 # LU-1512 try to reuse idle OI blocks
17052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17053 remote_mds_nodsh && skip "remote MDS with nodsh"
17054 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17056 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17057 local myDIR=$DIR/$tdir
17060 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17061 $LCTL set_param fail_loc=0x80001002
17062 createmany -o $myDIR/t- 10000
17063 $LCTL set_param fail_loc=0
17064 # The guard is current the largest FID holder
17066 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17068 local IDX=$(($SEQ % 64))
17070 do_facet $SINGLEMDS sync
17071 # Make sure journal flushed.
17073 local blk1=$(do_facet $SINGLEMDS \
17074 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17075 grep Blockcount | awk '{print $4}')
17077 # Remove old files, some OI blocks will become idle.
17078 unlinkmany $myDIR/t- 10000
17079 # Create new files, idle OI blocks should be reused.
17080 createmany -o $myDIR/t- 2000
17081 do_facet $SINGLEMDS sync
17082 # Make sure journal flushed.
17084 local blk2=$(do_facet $SINGLEMDS \
17085 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17086 grep Blockcount | awk '{print $4}')
17088 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17090 run_test 228a "try to reuse idle OI blocks"
17093 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17094 remote_mds_nodsh && skip "remote MDS with nodsh"
17095 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17097 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17098 local myDIR=$DIR/$tdir
17101 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17102 $LCTL set_param fail_loc=0x80001002
17103 createmany -o $myDIR/t- 10000
17104 $LCTL set_param fail_loc=0
17105 # The guard is current the largest FID holder
17107 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17109 local IDX=$(($SEQ % 64))
17111 do_facet $SINGLEMDS sync
17112 # Make sure journal flushed.
17114 local blk1=$(do_facet $SINGLEMDS \
17115 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17116 grep Blockcount | awk '{print $4}')
17118 # Remove old files, some OI blocks will become idle.
17119 unlinkmany $myDIR/t- 10000
17122 stop $SINGLEMDS || error "Fail to stop MDT."
17124 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
17126 df $MOUNT || error "Fail to df."
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 228b "idle OI blocks can be reused after MDT restart"
17142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17143 remote_mds_nodsh && skip "remote MDS with nodsh"
17144 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
17146 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
17147 local myDIR=$DIR/$tdir
17150 #define OBD_FAIL_SEQ_EXHAUST 0x1002
17151 $LCTL set_param fail_loc=0x80001002
17152 # 20000 files can guarantee there are index nodes in the OI file
17153 createmany -o $myDIR/t- 20000
17154 $LCTL set_param fail_loc=0
17155 # The guard is current the largest FID holder
17157 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
17159 local IDX=$(($SEQ % 64))
17161 do_facet $SINGLEMDS sync
17162 # Make sure journal flushed.
17164 local blk1=$(do_facet $SINGLEMDS \
17165 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17166 grep Blockcount | awk '{print $4}')
17168 # Remove old files, some OI blocks will become idle.
17169 unlinkmany $myDIR/t- 20000
17171 # The OI file should become empty now
17173 # Create new files, idle OI blocks should be reused.
17174 createmany -o $myDIR/t- 2000
17175 do_facet $SINGLEMDS sync
17176 # Make sure journal flushed.
17178 local blk2=$(do_facet $SINGLEMDS \
17179 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
17180 grep Blockcount | awk '{print $4}')
17182 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
17184 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
17186 test_229() { # LU-2482, LU-3448
17187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17188 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
17189 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
17190 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
17194 # Create a file with a released layout and stripe count 2.
17195 $MULTIOP $DIR/$tfile H2c ||
17196 error "failed to create file with released layout"
17198 $LFS getstripe -v $DIR/$tfile
17200 local pattern=$($LFS getstripe -L $DIR/$tfile)
17201 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
17203 local stripe_count=$($LFS getstripe -c $DIR/$tfile) ||
17205 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
17206 stat $DIR/$tfile || error "failed to stat released file"
17208 chown $RUNAS_ID $DIR/$tfile ||
17209 error "chown $RUNAS_ID $DIR/$tfile failed"
17211 chgrp $RUNAS_ID $DIR/$tfile ||
17212 error "chgrp $RUNAS_ID $DIR/$tfile failed"
17214 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
17215 rm $DIR/$tfile || error "failed to remove released file"
17217 run_test 229 "getstripe/stat/rm/attr changes work on released files"
17220 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17221 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17222 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17223 skip "Need MDS version at least 2.11.52"
17227 test_mkdir $DIR/$tdir
17228 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
17229 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
17230 [ $mdt_idx -ne 0 ] &&
17231 error "create local directory on wrong MDT $mdt_idx"
17233 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
17234 error "create remote directory failed"
17235 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
17236 [ $mdt_idx -ne $MDTIDX ] &&
17237 error "create remote directory on wrong MDT $mdt_idx"
17239 createmany -o $DIR/$tdir/test_230/t- 10 ||
17240 error "create files on remote directory failed"
17241 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
17242 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
17243 rm -r $DIR/$tdir || error "unlink remote directory failed"
17245 run_test 230a "Create remote directory and files under the remote directory"
17248 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17249 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17250 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17251 skip "Need MDS version at least 2.11.52"
17259 local migrate_dir=$DIR/$tdir/migrate_dir
17260 local other_dir=$DIR/$tdir/other_dir
17262 test_mkdir $DIR/$tdir
17263 test_mkdir -i0 -c1 $migrate_dir
17264 test_mkdir -i0 -c1 $other_dir
17265 for ((i=0; i<10; i++)); do
17266 mkdir -p $migrate_dir/dir_${i}
17267 createmany -o $migrate_dir/dir_${i}/f 10 ||
17268 error "create files under remote dir failed $i"
17271 cp /etc/passwd $migrate_dir/$tfile
17272 cp /etc/passwd $other_dir/$tfile
17273 chattr +SAD $migrate_dir
17274 chattr +SAD $migrate_dir/$tfile
17276 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17277 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17278 local old_dir_mode=$(stat -c%f $migrate_dir)
17279 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
17281 mkdir -p $migrate_dir/dir_default_stripe2
17282 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
17283 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
17285 mkdir -p $other_dir
17286 ln $migrate_dir/$tfile $other_dir/luna
17287 ln $migrate_dir/$tfile $migrate_dir/sofia
17288 ln $other_dir/$tfile $migrate_dir/david
17289 ln -s $migrate_dir/$tfile $other_dir/zachary
17290 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
17291 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
17297 for len in 58 59 60; do
17298 lnktgt=$(str_repeat 'l' $len)
17299 touch $migrate_dir/$lnktgt
17300 ln -s $lnktgt $migrate_dir/${len}char_ln
17304 for len in 4094 4095; do
17305 lnktgt=$(str_repeat 'l' $len)
17306 ln -s $lnktgt $migrate_dir/${len}char_ln
17310 for len in 254 255; do
17311 touch $migrate_dir/$(str_repeat 'l' $len)
17314 $LFS migrate -m $MDTIDX $migrate_dir ||
17315 error "fails on migrating remote dir to MDT1"
17317 echo "migratate to MDT1, then checking.."
17318 for ((i = 0; i < 10; i++)); do
17319 for file in $(find $migrate_dir/dir_${i}); do
17320 mdt_index=$($LFS getstripe -m $file)
17321 # broken symlink getstripe will fail
17322 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
17323 error "$file is not on MDT${MDTIDX}"
17327 # the multiple link file should still in MDT0
17328 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
17329 [ $mdt_index == 0 ] ||
17330 error "$file is not on MDT${MDTIDX}"
17332 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17333 [ "$old_dir_flag" = "$new_dir_flag" ] ||
17334 error " expect $old_dir_flag get $new_dir_flag"
17336 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17337 [ "$old_file_flag" = "$new_file_flag" ] ||
17338 error " expect $old_file_flag get $new_file_flag"
17340 local new_dir_mode=$(stat -c%f $migrate_dir)
17341 [ "$old_dir_mode" = "$new_dir_mode" ] ||
17342 error "expect mode $old_dir_mode get $new_dir_mode"
17344 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
17345 [ "$old_file_mode" = "$new_file_mode" ] ||
17346 error "expect mode $old_file_mode get $new_file_mode"
17348 diff /etc/passwd $migrate_dir/$tfile ||
17349 error "$tfile different after migration"
17351 diff /etc/passwd $other_dir/luna ||
17352 error "luna different after migration"
17354 diff /etc/passwd $migrate_dir/sofia ||
17355 error "sofia different after migration"
17357 diff /etc/passwd $migrate_dir/david ||
17358 error "david different after migration"
17360 diff /etc/passwd $other_dir/zachary ||
17361 error "zachary different after migration"
17363 diff /etc/passwd $migrate_dir/${tfile}_ln ||
17364 error "${tfile}_ln different after migration"
17366 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
17367 error "${tfile}_ln_other different after migration"
17369 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
17370 [ $stripe_count = 2 ] ||
17371 error "dir strpe_count $d != 2 after migration."
17373 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
17374 [ $stripe_count = 2 ] ||
17375 error "file strpe_count $d != 2 after migration."
17377 #migrate back to MDT0
17380 $LFS migrate -m $MDTIDX $migrate_dir ||
17381 error "fails on migrating remote dir to MDT0"
17383 echo "migrate back to MDT0, checking.."
17384 for file in $(find $migrate_dir); do
17385 mdt_index=$($LFS getstripe -m $file)
17386 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
17387 error "$file is not on MDT${MDTIDX}"
17390 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
17391 [ "$old_dir_flag" = "$new_dir_flag" ] ||
17392 error " expect $old_dir_flag get $new_dir_flag"
17394 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
17395 [ "$old_file_flag" = "$new_file_flag" ] ||
17396 error " expect $old_file_flag get $new_file_flag"
17398 local new_dir_mode=$(stat -c%f $migrate_dir)
17399 [ "$old_dir_mode" = "$new_dir_mode" ] ||
17400 error "expect mode $old_dir_mode get $new_dir_mode"
17402 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
17403 [ "$old_file_mode" = "$new_file_mode" ] ||
17404 error "expect mode $old_file_mode get $new_file_mode"
17406 diff /etc/passwd ${migrate_dir}/$tfile ||
17407 error "$tfile different after migration"
17409 diff /etc/passwd ${other_dir}/luna ||
17410 error "luna different after migration"
17412 diff /etc/passwd ${migrate_dir}/sofia ||
17413 error "sofia different after migration"
17415 diff /etc/passwd ${other_dir}/zachary ||
17416 error "zachary different after migration"
17418 diff /etc/passwd $migrate_dir/${tfile}_ln ||
17419 error "${tfile}_ln different after migration"
17421 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
17422 error "${tfile}_ln_other different after migration"
17424 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
17425 [ $stripe_count = 2 ] ||
17426 error "dir strpe_count $d != 2 after migration."
17428 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
17429 [ $stripe_count = 2 ] ||
17430 error "file strpe_count $d != 2 after migration."
17432 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17434 run_test 230b "migrate directory"
17437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17438 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17439 remote_mds_nodsh && skip "remote MDS with nodsh"
17440 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17441 skip "Need MDS version at least 2.11.52"
17447 local migrate_dir=$DIR/$tdir/migrate_dir
17449 #If migrating directory fails in the middle, all entries of
17450 #the directory is still accessiable.
17451 test_mkdir $DIR/$tdir
17452 test_mkdir -i0 -c1 $migrate_dir
17453 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
17455 createmany -o $migrate_dir/f $total ||
17456 error "create files under ${migrate_dir} failed"
17458 # fail after migrating top dir, and this will fail only once, so the
17459 # first sub file migration will fail (currently f3), others succeed.
17460 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
17461 do_facet mds1 lctl set_param fail_loc=0x1801
17462 local t=$(ls $migrate_dir | wc -l)
17463 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
17464 error "migrate should fail"
17465 local u=$(ls $migrate_dir | wc -l)
17466 [ "$u" == "$t" ] || error "$u != $t during migration"
17468 # add new dir/file should succeed
17469 mkdir $migrate_dir/dir ||
17470 error "mkdir failed under migrating directory"
17471 touch $migrate_dir/file ||
17472 error "create file failed under migrating directory"
17474 # add file with existing name should fail
17475 for file in $migrate_dir/f*; do
17476 stat $file > /dev/null || error "stat $file failed"
17477 $OPENFILE -f O_CREAT:O_EXCL $file &&
17478 error "open(O_CREAT|O_EXCL) $file should fail"
17479 $MULTIOP $file m && error "create $file should fail"
17480 touch $DIR/$tdir/remote_dir/$tfile ||
17481 error "touch $tfile failed"
17482 ln $DIR/$tdir/remote_dir/$tfile $file &&
17483 error "link $file should fail"
17484 mdt_index=$($LFS getstripe -m $file)
17485 if [ $mdt_index == 0 ]; then
17486 # file failed to migrate is not allowed to rename to
17487 mv $DIR/$tdir/remote_dir/$tfile $file &&
17488 error "rename to $file should fail"
17490 mv $DIR/$tdir/remote_dir/$tfile $file ||
17491 error "rename to $file failed"
17493 echo hello >> $file || error "write $file failed"
17496 # resume migration with different options should fail
17497 $LFS migrate -m 0 $migrate_dir &&
17498 error "migrate -m 0 $migrate_dir should fail"
17500 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
17501 error "migrate -c 2 $migrate_dir should fail"
17503 # resume migration should succeed
17504 $LFS migrate -m $MDTIDX $migrate_dir ||
17505 error "migrate $migrate_dir failed"
17507 echo "Finish migration, then checking.."
17508 for file in $(find $migrate_dir); do
17509 mdt_index=$($LFS getstripe -m $file)
17510 [ $mdt_index == $MDTIDX ] ||
17511 error "$file is not on MDT${MDTIDX}"
17514 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17516 run_test 230c "check directory accessiblity if migration failed"
17519 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17520 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17521 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17522 skip "Need MDS version at least 2.11.52"
17524 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
17526 local migrate_dir=$DIR/$tdir/migrate_dir
17536 old_index=$((RANDOM % MDSCOUNT))
17537 old_count=$((MDSCOUNT - old_index))
17538 new_index=$((RANDOM % MDSCOUNT))
17539 new_count=$((MDSCOUNT - new_index))
17540 new_hash=1 # for all_char
17542 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
17543 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
17545 test_mkdir $DIR/$tdir
17546 test_mkdir -i $old_index -c $old_count $migrate_dir
17548 for ((i=0; i<100; i++)); do
17549 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
17550 createmany -o $migrate_dir/dir_${i}/f 100 ||
17551 error "create files under remote dir failed $i"
17554 echo -n "Migrate from MDT$old_index "
17555 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
17556 echo -n "to MDT$new_index"
17557 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
17560 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
17561 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
17562 error "migrate remote dir error"
17564 echo "Finish migration, then checking.."
17565 for file in $(find $migrate_dir); do
17566 mdt_index=$($LFS getstripe -m $file)
17567 if [ $mdt_index -lt $new_index ] ||
17568 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
17569 error "$file is on MDT$mdt_index"
17573 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17575 run_test 230d "check migrate big directory"
17578 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17579 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17580 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17581 skip "Need MDS version at least 2.11.52"
17588 mkdir -p $DIR/$tdir
17589 mkdir $DIR/$tdir/migrate_dir
17590 mkdir $DIR/$tdir/other_dir
17591 touch $DIR/$tdir/migrate_dir/a
17592 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
17593 ls $DIR/$tdir/other_dir
17595 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17596 error "migrate dir fails"
17598 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17599 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17601 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17602 [ $mdt_index == 0 ] || error "a is not on MDT0"
17604 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
17605 error "migrate dir fails"
17607 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
17608 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
17610 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17611 [ $mdt_index == 1 ] || error "a is not on MDT1"
17613 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
17614 [ $mdt_index == 1 ] || error "b is not on MDT1"
17616 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17617 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
17619 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
17621 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17623 run_test 230e "migrate mulitple local link files"
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"
17634 mkdir -p $DIR/$tdir
17635 mkdir $DIR/$tdir/migrate_dir
17636 $LFS mkdir -i1 $DIR/$tdir/other_dir
17637 touch $DIR/$tdir/migrate_dir/a
17638 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
17639 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
17640 ls $DIR/$tdir/other_dir
17642 # a should be migrated to MDT1, since no other links on MDT0
17643 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17644 error "#1 migrate dir fails"
17645 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
17646 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
17647 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17648 [ $mdt_index == 1 ] || error "a is not on MDT1"
17650 # a should stay on MDT1, because it is a mulitple link file
17651 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17652 error "#2 migrate dir fails"
17653 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17654 [ $mdt_index == 1 ] || error "a is not on MDT1"
17656 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
17657 error "#3 migrate dir fails"
17659 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
17660 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
17661 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
17663 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
17664 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
17666 # a should be migrated to MDT0, since no other links on MDT1
17667 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
17668 error "#4 migrate dir fails"
17669 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
17670 [ $mdt_index == 0 ] || error "a is not on MDT0"
17672 rm -rf $DIR/$tdir || error "rm dir failed after migration"
17674 run_test 230f "migrate mulitple remote link files"
17677 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17678 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17679 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17680 skip "Need MDS version at least 2.11.52"
17682 mkdir -p $DIR/$tdir/migrate_dir
17684 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
17685 error "migrating dir to non-exist MDT succeeds"
17688 run_test 230g "migrate dir to non-exist MDT"
17691 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17692 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17693 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17694 skip "Need MDS version at least 2.11.52"
17698 mkdir -p $DIR/$tdir/migrate_dir
17700 $LFS migrate -m1 $DIR &&
17701 error "migrating mountpoint1 should fail"
17703 $LFS migrate -m1 $DIR/$tdir/.. &&
17704 error "migrating mountpoint2 should fail"
17707 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
17708 error "migrating $tdir/migrate_dir/.. should fail"
17712 run_test 230h "migrate .. and root"
17715 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17716 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17717 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
17718 skip "Need MDS version at least 2.11.52"
17720 mkdir -p $DIR/$tdir/migrate_dir
17722 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
17723 error "migration fails with a tailing slash"
17725 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
17726 error "migration fails with two tailing slashes"
17728 run_test 230i "lfs migrate -m tolerates trailing slashes"
17731 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17732 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
17733 skip "Need MDS version at least 2.11.52"
17735 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
17736 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
17737 error "create $tfile failed"
17738 cat /etc/passwd > $DIR/$tdir/$tfile
17740 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17742 cmp /etc/passwd $DIR/$tdir/$tfile ||
17743 error "DoM file mismatch after migration"
17745 run_test 230j "DoM file data not changed after dir migration"
17748 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
17749 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17750 skip "Need MDS version at least 2.11.56"
17753 local files_on_starting_mdt=0
17755 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
17756 $LFS getdirstripe $DIR/$tdir
17757 for i in $(seq $total); do
17758 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
17759 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17760 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17763 echo "$files_on_starting_mdt files on MDT0"
17765 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
17766 $LFS getdirstripe $DIR/$tdir
17768 files_on_starting_mdt=0
17769 for i in $(seq $total); do
17770 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17771 error "file $tfile.$i mismatch after migration"
17772 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
17773 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17776 echo "$files_on_starting_mdt files on MDT1 after migration"
17777 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
17779 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
17780 $LFS getdirstripe $DIR/$tdir
17782 files_on_starting_mdt=0
17783 for i in $(seq $total); do
17784 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
17785 error "file $tfile.$i mismatch after 2nd migration"
17786 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
17787 files_on_starting_mdt=$((files_on_starting_mdt + 1))
17790 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
17791 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
17795 run_test 230k "file data not changed after dir migration"
17798 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17799 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17800 skip "Need MDS version at least 2.11.56"
17802 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
17803 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
17804 error "create files under remote dir failed $i"
17805 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
17807 run_test 230l "readdir between MDTs won't crash"
17810 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17811 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
17812 skip "Need MDS version at least 2.11.56"
17815 local mig_dir=$DIR/$tdir/migrate_dir
17816 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17820 echo "Creating files and dirs with xattrs"
17821 test_mkdir $DIR/$tdir
17822 test_mkdir -i0 -c1 $mig_dir
17824 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
17825 error "cannot set xattr attr1 on dir"
17826 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
17827 error "cannot set xattr attr2 on dir"
17828 touch $mig_dir/dir/f0
17829 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
17830 error "cannot set xattr attr1 on file"
17831 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
17832 error "cannot set xattr attr2 on file"
17833 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17834 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17835 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
17836 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17837 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
17838 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17839 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
17840 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17841 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
17843 echo "Migrating to MDT1"
17844 $LFS migrate -m $MDTIDX $mig_dir ||
17845 error "fails on migrating dir to MDT1"
17847 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
17848 echo "Checking xattrs"
17849 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
17850 [ "$val" = $longstr ] ||
17851 error "expecting xattr1 $longstr on dir, found $val"
17852 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
17853 [ "$val" = $shortstr ] ||
17854 error "expecting xattr2 $shortstr on dir, found $val"
17855 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
17856 [ "$val" = $longstr ] ||
17857 error "expecting xattr1 $longstr on file, found $val"
17858 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
17859 [ "$val" = $shortstr ] ||
17860 error "expecting xattr2 $shortstr on file, found $val"
17862 run_test 230m "xattrs not changed after dir migration"
17865 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
17866 [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] ||
17867 skip "Need MDS version at least 2.13.53"
17869 $LFS mkdir -i 0 $DIR/$tdir || error "mkdir $tdir failed"
17870 cat /etc/hosts > $DIR/$tdir/$tfile
17871 $LFS mirror extend -N1 $DIR/$tdir/$tfile || error "Mirroring failed"
17872 $LFS migrate -m 1 $DIR/$tdir || error "Migration failed"
17874 cmp /etc/hosts $DIR/$tdir/$tfile ||
17875 error "File data mismatch after migration"
17877 run_test 230n "Dir migration with mirrored file"
17880 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
17881 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
17882 skip "Need MDS version at least 2.13.52"
17884 local mdts=$(comma_list $(mdts_nodes))
17886 local restripe_status
17891 # in case "crush" hash type is not set
17892 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
17894 restripe_status=$(do_facet mds1 $LCTL get_param -n \
17895 mdt.*MDT0000.enable_dir_restripe)
17896 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
17897 stack_trap "do_nodes $mdts $LCTL set_param \
17898 mdt.*.enable_dir_restripe=$restripe_status"
17901 createmany -m $DIR/$tdir/f 100 ||
17902 error "create files under remote dir failed $i"
17903 createmany -d $DIR/$tdir/d 100 ||
17904 error "create dirs under remote dir failed $i"
17906 for i in $(seq 2 $MDSCOUNT); do
17907 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
17908 $LFS setdirstripe -c $i $DIR/$tdir ||
17909 error "split -c $i $tdir failed"
17910 wait_update $HOSTNAME \
17911 "$LFS getdirstripe -H $DIR/$tdir" "crush" 100 ||
17912 error "dir split not finished"
17913 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
17914 awk '/migrate/ {sum += $2} END { print sum }')
17915 echo "$delta files migrated when dir split from $((i - 1)) to $i stripes"
17916 # delta is around total_files/stripe_count
17917 [ $delta -lt $((200 /(i - 1))) ] ||
17918 error "$delta files migrated"
17921 run_test 230o "dir split"
17924 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
17925 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
17926 skip "Need MDS version at least 2.13.52"
17928 local mdts=$(comma_list $(mdts_nodes))
17930 local restripe_status
17935 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
17937 restripe_status=$(do_facet mds1 $LCTL get_param -n \
17938 mdt.*MDT0000.enable_dir_restripe)
17939 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_restripe=1"
17940 stack_trap "do_nodes $mdts $LCTL set_param \
17941 mdt.*.enable_dir_restripe=$restripe_status"
17943 test_mkdir -c $MDSCOUNT -H crush $DIR/$tdir
17944 createmany -m $DIR/$tdir/f 100 ||
17945 error "create files under remote dir failed $i"
17946 createmany -d $DIR/$tdir/d 100 ||
17947 error "create dirs under remote dir failed $i"
17949 for i in $(seq $((MDSCOUNT - 1)) -1 1); do
17950 local mdt_hash="crush"
17952 do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
17953 $LFS setdirstripe -c $i $DIR/$tdir ||
17954 error "split -c $i $tdir failed"
17955 [ $i -eq 1 ] && mdt_hash="none"
17956 wait_update $HOSTNAME \
17957 "$LFS getdirstripe -H $DIR/$tdir" $mdt_hash 100 ||
17958 error "dir merge not finished"
17959 delta=$(do_nodes $mdts "lctl get_param -n mdt.*MDT*.md_stats" |
17960 awk '/migrate/ {sum += $2} END { print sum }')
17961 echo "$delta files migrated when dir merge from $((i + 1)) to $i stripes"
17962 # delta is around total_files/stripe_count
17963 [ $delta -lt $((200 / i)) ] ||
17964 error "$delta files migrated"
17967 run_test 230p "dir merge"
17970 [ $MDSCOUNT -ge 2 ] || skip "needs >= 2 MDTs"
17971 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
17972 skip "Need MDS version at least 2.13.52"
17974 local mdts=$(comma_list $(mdts_nodes))
17975 local saved_threshold=$(do_facet mds1 \
17976 $LCTL get_param -n mdt.*-MDT0000.dir_split_count)
17977 local saved_delta=$(do_facet mds1 \
17978 $LCTL get_param -n mdt.*-MDT0000.dir_split_delta)
17979 local threshold=100
17982 local stripe_count=0
17986 stack_trap "do_nodes $mdts $LCTL set_param \
17987 mdt.*.dir_split_count=$saved_threshold"
17988 stack_trap "do_nodes $mdts $LCTL set_param \
17989 mdt.*.dir_split_delta=$saved_delta"
17990 stack_trap "do_nodes $mdts $LCTL set_param mdt.*.dir_restripe_nsonly=1"
17991 do_nodes $mdts "$LCTL set_param mdt.*.enable_dir_auto_split=1"
17992 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_count=$threshold"
17993 do_nodes $mdts "$LCTL set_param mdt.*.dir_split_delta=$delta"
17994 do_nodes $mdts "$LCTL set_param mdt.*.dir_restripe_nsonly=0"
17995 do_nodes $mdts "$LCTL set_param lod.*.mdt_hash=crush"
17997 $LFS mkdir -i -1 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
17998 stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
18000 while [ $stripe_count -lt $MDSCOUNT ]; do
18001 createmany -m $DIR/$tdir/f $total $((threshold * 3 / 2)) ||
18002 error "create sub files failed"
18003 stat $DIR/$tdir > /dev/null
18004 total=$((total + threshold * 3 / 2))
18005 stripe_count=$((stripe_count + delta))
18006 [ $stripe_count -gt $MDSCOUNT ] && stripe_count=$MDSCOUNT
18008 wait_update $HOSTNAME \
18009 "$LFS getdirstripe -c $DIR/$tdir" "$stripe_count" 40 ||
18010 error "stripe count $($LFS getdirstripe -c $DIR/$tdir) != $stripe_count"
18012 wait_update $HOSTNAME \
18013 "$LFS getdirstripe -H $DIR/$tdir" "crush" 200 ||
18014 error "stripe hash $($LFS getdirstripe -H $DIR/$tdir) != crush"
18016 nr_files=$($LFS getstripe -m $DIR/$tdir/* |
18017 grep -w $stripe_index | wc -l)
18018 echo "$nr_files files on MDT$stripe_index after split"
18019 [ $nr_files -lt $((total / (stripe_count - 1))) ] ||
18020 error "$nr_files files on MDT$stripe_index after split"
18022 nr_files=$(ls $DIR/$tdir | wc -w)
18023 [ $nr_files -eq $total ] ||
18024 error "total sub files $nr_files != $total"
18027 run_test 230q "dir auto split"
18031 # For simplicity this test assumes that max_pages_per_rpc
18032 # is the same across all OSCs
18033 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
18034 local bulk_size=$((max_pages * PAGE_SIZE))
18035 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
18038 mkdir -p $DIR/$tdir
18039 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
18040 error "failed to set stripe with -S ${brw_size}M option"
18042 # clear the OSC stats
18043 $LCTL set_param osc.*.stats=0 &>/dev/null
18046 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
18047 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
18048 oflag=direct &>/dev/null || error "dd failed"
18050 sync; sleep 1; sync # just to be safe
18051 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
18052 if [ x$nrpcs != "x1" ]; then
18053 $LCTL get_param osc.*.stats
18054 error "found $nrpcs ost_write RPCs, not 1 as expected"
18058 # Drop the OSC cache, otherwise we will read from it
18059 cancel_lru_locks osc
18061 # clear the OSC stats
18062 $LCTL set_param osc.*.stats=0 &>/dev/null
18064 # Client reads $bulk_size.
18065 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
18066 iflag=direct &>/dev/null || error "dd failed"
18068 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
18069 if [ x$nrpcs != "x1" ]; then
18070 $LCTL get_param osc.*.stats
18071 error "found $nrpcs ost_read RPCs, not 1 as expected"
18074 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
18077 mkdir -p $DIR/$tdir
18079 for i in {0..1023}; do
18080 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
18081 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
18082 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
18086 run_test 231b "must not assert on fully utilized OST request buffer"
18089 mkdir -p $DIR/$tdir
18090 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
18092 #define OBD_FAIL_LDLM_OST_LVB 0x31c
18093 do_facet ost1 $LCTL set_param fail_loc=0x31c
18095 # ignore dd failure
18096 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
18098 do_facet ost1 $LCTL set_param fail_loc=0
18099 umount_client $MOUNT || error "umount failed"
18100 mount_client $MOUNT || error "mount failed"
18101 stop ost1 || error "cannot stop ost1"
18102 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18104 run_test 232a "failed lock should not block umount"
18107 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
18108 skip "Need MDS version at least 2.10.58"
18110 mkdir -p $DIR/$tdir
18111 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
18112 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
18114 cancel_lru_locks osc
18116 #define OBD_FAIL_LDLM_OST_LVB 0x31c
18117 do_facet ost1 $LCTL set_param fail_loc=0x31c
18120 $LFS data_version $DIR/$tdir/$tfile || true
18122 do_facet ost1 $LCTL set_param fail_loc=0
18123 umount_client $MOUNT || error "umount failed"
18124 mount_client $MOUNT || error "mount failed"
18125 stop ost1 || error "cannot stop ost1"
18126 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
18128 run_test 232b "failed data version lock should not block umount"
18131 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
18132 skip "Need MDS version at least 2.3.64"
18133 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
18135 local fid=$($LFS path2fid $MOUNT)
18137 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18138 error "cannot access $MOUNT using its FID '$fid'"
18140 run_test 233a "checking that OBF of the FS root succeeds"
18143 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
18144 skip "Need MDS version at least 2.5.90"
18145 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
18147 local fid=$($LFS path2fid $MOUNT/.lustre)
18149 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18150 error "cannot access $MOUNT/.lustre using its FID '$fid'"
18152 fid=$($LFS path2fid $MOUNT/.lustre/fid)
18153 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
18154 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
18156 run_test 233b "checking that OBF of the FS .lustre succeeds"
18159 local p="$TMP/sanityN-$TESTNAME.parameters"
18160 save_lustre_params client "llite.*.xattr_cache" > $p
18161 lctl set_param llite.*.xattr_cache 1 ||
18162 skip_env "xattr cache is not supported"
18164 mkdir -p $DIR/$tdir || error "mkdir failed"
18165 touch $DIR/$tdir/$tfile || error "touch failed"
18166 # OBD_FAIL_LLITE_XATTR_ENOMEM
18167 $LCTL set_param fail_loc=0x1405
18168 getfattr -n user.attr $DIR/$tdir/$tfile &&
18169 error "getfattr should have failed with ENOMEM"
18170 $LCTL set_param fail_loc=0x0
18173 restore_lustre_params < $p
18176 run_test 234 "xattr cache should not crash on ENOMEM"
18179 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
18180 skip "Need MDS version at least 2.4.52"
18182 flock_deadlock $DIR/$tfile
18187 124) error "process hangs on a deadlock"
18189 *) error "error executing flock_deadlock $DIR/$tfile"
18193 run_test 235 "LU-1715: flock deadlock detection does not work properly"
18197 check_swap_layouts_support
18199 local ref1=/etc/passwd
18200 local ref2=/etc/group
18201 local file1=$DIR/$tdir/f1
18202 local file2=$DIR/$tdir/f2
18204 test_mkdir -c1 $DIR/$tdir
18205 $LFS setstripe -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
18206 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
18207 $LFS setstripe -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
18208 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
18209 local fd=$(free_fd)
18210 local cmd="exec $fd<>$file2"
18213 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
18214 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
18217 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
18222 run_test 236 "Layout swap on open unlinked file"
18224 # LU-4659 linkea consistency
18226 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
18227 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
18228 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
18229 skip "Need MDS version at least 2.5.58 or 2.5.2+"
18232 ln $DIR/$tfile $DIR/$tfile.lnk
18233 touch $DIR/$tfile.new
18234 mv $DIR/$tfile.new $DIR/$tfile
18235 local fid1=$($LFS path2fid $DIR/$tfile)
18236 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
18237 local path1=$($LFS fid2path $FSNAME "$fid1")
18238 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
18239 local path2=$($LFS fid2path $FSNAME "$fid2")
18240 [ $tfile.lnk == $path2 ] ||
18241 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
18244 run_test 238 "Verify linkea consistency"
18246 test_239A() { # was test_239
18247 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
18248 skip "Need MDS version at least 2.5.60"
18250 local list=$(comma_list $(mdts_nodes))
18252 mkdir -p $DIR/$tdir
18253 createmany -o $DIR/$tdir/f- 5000
18254 unlinkmany $DIR/$tdir/f- 5000
18255 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
18256 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
18257 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
18258 osp.*MDT*.sync_in_flight" | calc_sum)
18259 [ "$changes" -eq 0 ] || error "$changes not synced"
18261 run_test 239A "osp_sync test"
18263 test_239a() { #LU-5297
18264 remote_mds_nodsh && skip "remote MDS with nodsh"
18267 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
18268 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
18269 chgrp $RUNAS_GID $DIR/$tfile
18270 wait_delete_completed
18272 run_test 239a "process invalid osp sync record correctly"
18274 test_239b() { #LU-5297
18275 remote_mds_nodsh && skip "remote MDS with nodsh"
18278 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
18279 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
18280 chgrp $RUNAS_GID $DIR/$tfile1
18281 wait_delete_completed
18282 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
18284 chgrp $RUNAS_GID $DIR/$tfile2
18285 wait_delete_completed
18287 run_test 239b "process osp sync record with ENOMEM error correctly"
18290 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18291 remote_mds_nodsh && skip "remote MDS with nodsh"
18293 mkdir -p $DIR/$tdir
18295 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
18296 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
18297 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
18298 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
18300 umount_client $MOUNT || error "umount failed"
18301 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
18302 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
18303 mount_client $MOUNT || error "failed to mount client"
18305 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
18306 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
18308 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
18314 for LOOP in $(seq $count); do
18315 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
18316 cancel_lru_locks $OSC || true
18324 for LOOP in $(seq $1); do
18325 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
18330 test_241a() { # was test_241
18331 local bsize=$PAGE_SIZE
18333 (( bsize < 40960 )) && bsize=40960
18334 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
18336 cancel_lru_locks $OSC
18337 test_241_bio 1000 $bsize &
18339 test_241_dio 1000 $bsize
18342 run_test 241a "bio vs dio"
18345 local bsize=$PAGE_SIZE
18347 (( bsize < 40960 )) && bsize=40960
18348 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
18350 test_241_dio 1000 $bsize &
18352 test_241_dio 1000 $bsize
18355 run_test 241b "dio vs dio"
18358 remote_mds_nodsh && skip "remote MDS with nodsh"
18360 mkdir -p $DIR/$tdir
18361 touch $DIR/$tdir/$tfile
18363 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
18364 do_facet mds1 lctl set_param fail_loc=0x105
18365 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
18367 do_facet mds1 lctl set_param fail_loc=0
18368 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
18370 run_test 242 "mdt_readpage failure should not cause directory unreadable"
18374 test_mkdir $DIR/$tdir
18375 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
18377 run_test 243 "various group lock tests"
18381 test_mkdir $DIR/$tdir
18382 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
18383 sendfile_grouplock $DIR/$tdir/$tfile || \
18384 error "sendfile+grouplock failed"
18387 run_test 244a "sendfile with group lock tests"
18391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
18394 local size=$((1024*1024))
18396 test_mkdir $DIR/$tdir
18397 for i in $(seq 1 $threads); do
18398 local file=$DIR/$tdir/file_$((i / 10))
18399 $MULTIOP $file OG1234w$size_$((i % 3))w$size_$((i % 4))g1234c &
18402 for i in $(seq 1 $threads); do
18406 run_test 244b "multi-threaded write with group lock"
18409 local flagname="multi_mod_rpcs"
18410 local connect_data_name="max_mod_rpcs"
18413 # check if multiple modify RPCs flag is set
18414 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
18415 grep "connect_flags:")
18418 echo "$out" | grep -qw $flagname
18419 if [ $? -ne 0 ]; then
18420 echo "connect flag $flagname is not set"
18424 # check if multiple modify RPCs data is set
18425 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
18428 echo "$out" | grep -qw $connect_data_name ||
18429 error "import should have connect data $connect_data_name"
18431 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
18437 umount_client $submount
18442 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18444 skip_env "Fileset feature is not supported"
18446 local submount=${MOUNT}_$tdir
18449 mkdir -p $submount || error "mkdir $submount failed"
18450 FILESET="$FILESET/$tdir" mount_client $submount ||
18451 error "mount $submount failed"
18452 trap "cleanup_247 $submount" EXIT
18453 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
18454 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
18455 error "read $MOUNT/$tdir/$tfile failed"
18456 cleanup_247 $submount
18458 run_test 247a "mount subdir as fileset"
18461 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18462 skip_env "Fileset feature is not supported"
18464 local submount=${MOUNT}_$tdir
18466 rm -rf $MOUNT/$tdir
18467 mkdir -p $submount || error "mkdir $submount failed"
18469 FILESET="$FILESET/$tdir" mount_client $submount &&
18470 error "mount $submount should fail"
18473 run_test 247b "mount subdir that dose not exist"
18476 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18477 skip_env "Fileset feature is not supported"
18479 local submount=${MOUNT}_$tdir
18481 mkdir -p $MOUNT/$tdir/dir1
18482 mkdir -p $submount || error "mkdir $submount failed"
18483 trap "cleanup_247 $submount" EXIT
18484 FILESET="$FILESET/$tdir" mount_client $submount ||
18485 error "mount $submount failed"
18486 local fid=$($LFS path2fid $MOUNT/)
18487 $LFS fid2path $submount $fid && error "fid2path should fail"
18488 cleanup_247 $submount
18490 run_test 247c "running fid2path outside root"
18493 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
18494 skip "Fileset feature is not supported"
18496 local submount=${MOUNT}_$tdir
18498 mkdir -p $MOUNT/$tdir/dir1
18499 mkdir -p $submount || error "mkdir $submount failed"
18500 FILESET="$FILESET/$tdir" mount_client $submount ||
18501 error "mount $submount failed"
18502 trap "cleanup_247 $submount" EXIT
18503 local fid=$($LFS path2fid $submount/dir1)
18504 $LFS fid2path $submount $fid || error "fid2path should succeed"
18505 cleanup_247 $submount
18507 run_test 247d "running fid2path inside root"
18511 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18513 skip "Fileset feature is not supported"
18515 local submount=${MOUNT}_$tdir
18518 mkdir -p $submount || error "mkdir $submount failed"
18519 FILESET="$FILESET/.." mount_client $submount &&
18520 error "mount $submount should fail"
18523 run_test 247e "mount .. as fileset"
18526 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18527 [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
18528 skip "Need at least version 2.13.52"
18529 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
18531 skip "Fileset feature is not supported"
18533 mkdir $DIR/$tdir || error "mkdir $tdir failed"
18534 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
18535 error "mkdir remote failed"
18536 mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
18537 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped ||
18538 error "mkdir striped failed"
18539 mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
18541 local submount=${MOUNT}_$tdir
18543 mkdir -p $submount || error "mkdir $submount failed"
18546 local fileset=$FILESET
18548 for dir in $tdir/remote $tdir/remote/subdir \
18549 $tdir/striped $tdir/striped/subdir $tdir/striped/. ; do
18550 FILESET="$fileset/$dir" mount_client $submount ||
18551 error "mount $dir failed"
18552 umount_client $submount
18555 run_test 247f "mount striped or remote directory as fileset"
18558 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
18559 [ -z "$fast_read_sav" ] && skip "no fast read support"
18561 # create a large file for fast read verification
18562 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
18564 # make sure the file is created correctly
18565 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
18566 { rm -f $DIR/$tfile; skip "file creation error"; }
18568 echo "Test 1: verify that fast read is 4 times faster on cache read"
18570 # small read with fast read enabled
18571 $LCTL set_param -n llite.*.fast_read=1
18572 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
18573 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18574 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18575 # small read with fast read disabled
18576 $LCTL set_param -n llite.*.fast_read=0
18577 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
18578 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18579 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18581 # verify that fast read is 4 times faster for cache read
18582 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
18583 error_not_in_vm "fast read was not 4 times faster: " \
18584 "$t_fast vs $t_slow"
18586 echo "Test 2: verify the performance between big and small read"
18587 $LCTL set_param -n llite.*.fast_read=1
18589 # 1k non-cache read
18590 cancel_lru_locks osc
18591 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
18592 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18593 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18595 # 1M non-cache read
18596 cancel_lru_locks osc
18597 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
18598 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
18599 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
18601 # verify that big IO is not 4 times faster than small IO
18602 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
18603 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
18605 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
18608 run_test 248a "fast read verification"
18611 # Default short_io_bytes=16384, try both smaller and larger sizes.
18612 # Lustre O_DIRECT read and write needs to be a multiple of PAGE_SIZE.
18613 # 6017024 = 2^12*13*113 = 47008*128 = 11752*512 = 4096*1469 = 53248*113
18614 echo "bs=53248 count=113 normal buffered write"
18615 dd if=/dev/urandom of=$TMP/$tfile.0 bs=53248 count=113 ||
18616 error "dd of initial data file failed"
18617 stack_trap "rm -f $DIR/$tfile.[0-3] $TMP/$tfile.[0-3]" EXIT
18619 echo "bs=47008 count=128 oflag=dsync normal write $tfile.0"
18620 dd if=$TMP/$tfile.0 of=$DIR/$tfile.0 bs=47008 count=128 oflag=dsync ||
18621 error "dd with sync normal writes failed"
18622 cmp $TMP/$tfile.0 $DIR/$tfile.0 || error "compare $DIR/$tfile.0 failed"
18624 echo "bs=11752 count=512 oflag=dsync small write $tfile.1"
18625 dd if=$TMP/$tfile.0 of=$DIR/$tfile.1 bs=11752 count=512 oflag=dsync ||
18626 error "dd with sync small writes failed"
18627 cmp $TMP/$tfile.0 $DIR/$tfile.1 || error "compare $DIR/$tfile.1 failed"
18629 cancel_lru_locks osc
18631 # calculate the small O_DIRECT size and count for the client PAGE_SIZE
18632 local num=$((13 * 113 / (PAGE_SIZE / 4096)))
18633 echo "bs=$PAGE_SIZE count=$num iflag=direct small read $tfile.1"
18634 dd if=$DIR/$tfile.1 of=$TMP/$tfile.1 bs=$PAGE_SIZE count=$num \
18635 iflag=direct || error "dd with O_DIRECT small read failed"
18636 # adjust bytes checked to handle larger PAGE_SIZE for ARM/PPC
18637 cmp --bytes=$((PAGE_SIZE * num)) $TMP/$tfile.0 $TMP/$tfile.1 ||
18638 error "compare $TMP/$tfile.1 failed"
18640 local save=$($LCTL get_param -n osc.*OST000*.short_io_bytes | head -n 1)
18641 stack_trap "$LCTL set_param osc.$FSNAME-*.short_io_bytes=$save" EXIT
18643 # just to see what the maximum tunable value is, and test parsing
18644 echo "test invalid parameter 2MB"
18645 $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=2M &&
18646 error "too-large short_io_bytes allowed"
18647 echo "test maximum parameter 512KB"
18648 # if we can set a larger short_io_bytes, run test regardless of version
18649 if ! $LCTL set_param osc.$FSNAME-OST0000*.short_io_bytes=512K; then
18650 # older clients may not allow setting it this large, that's OK
18651 [ $CLIENT_VERSION -ge $(version_code 2.13.50) ] ||
18652 skip "Need at least client version 2.13.50"
18653 error "medium short_io_bytes failed"
18655 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
18656 size=$($LCTL get_param -n osc.$FSNAME-OST0000*.short_io_bytes)
18658 echo "test large parameter 64KB"
18659 $LCTL set_param osc.$FSNAME-*.short_io_bytes=65536
18660 $LCTL get_param osc.$FSNAME-OST0000*.short_io_bytes
18662 echo "bs=47008 count=128 oflag=dsync large write $tfile.2"
18663 dd if=$TMP/$tfile.0 of=$DIR/$tfile.2 bs=47008 count=128 oflag=dsync ||
18664 error "dd with sync large writes failed"
18665 cmp $TMP/$tfile.0 $DIR/$tfile.2 || error "compare $DIR/$tfile.2 failed"
18667 # calculate the large O_DIRECT size and count for the client PAGE_SIZE
18668 local size=$(((4096 * 13 + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE))
18669 num=$((113 * 4096 / PAGE_SIZE))
18670 echo "bs=$size count=$num oflag=direct large write $tfile.3"
18671 dd if=$TMP/$tfile.0 of=$DIR/$tfile.3 bs=$size count=$num oflag=direct ||
18672 error "dd with O_DIRECT large writes failed"
18673 cmp --bytes=$((size * num)) $TMP/$tfile.0 $DIR/$tfile.3 ||
18674 error "compare $DIR/$tfile.3 failed"
18676 cancel_lru_locks osc
18678 echo "bs=$size count=$num iflag=direct large read $tfile.2"
18679 dd if=$DIR/$tfile.2 of=$TMP/$tfile.2 bs=$size count=$num iflag=direct ||
18680 error "dd with O_DIRECT large read failed"
18681 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.2 ||
18682 error "compare $TMP/$tfile.2 failed"
18684 echo "bs=$size count=$num iflag=direct large read $tfile.3"
18685 dd if=$DIR/$tfile.3 of=$TMP/$tfile.3 bs=$size count=$num iflag=direct ||
18686 error "dd with O_DIRECT large read failed"
18687 cmp --bytes=$((size * num)) $TMP/$tfile.0 $TMP/$tfile.3 ||
18688 error "compare $TMP/$tfile.3 failed"
18690 run_test 248b "test short_io read and write for both small and large sizes"
18692 test_249() { # LU-7890
18693 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
18694 skip "Need at least version 2.8.54"
18697 $LFS setstripe -c 1 $DIR/$tfile
18698 # Offset 2T == 4k * 512M
18699 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
18700 error "dd to 2T offset failed"
18702 run_test 249 "Write above 2T file size"
18705 [ "$(facet_fstype ost$(($($LFS getstripe -i $DIR/$tfile) + 1)))" = "zfs" ] \
18706 && skip "no 16TB file size limit on ZFS"
18708 $LFS setstripe -c 1 $DIR/$tfile
18709 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
18710 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
18711 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
18712 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
18713 conv=notrunc,fsync && error "append succeeded"
18716 run_test 250 "Write above 16T limit"
18719 $LFS setstripe -c -1 -S 1048576 $DIR/$tfile
18721 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
18722 #Skip once - writing the first stripe will succeed
18723 $LCTL set_param fail_loc=0xa0001407 fail_val=1
18724 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
18725 error "short write happened"
18727 $LCTL set_param fail_loc=0xa0001407 fail_val=1
18728 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
18729 error "short read happened"
18733 run_test 251 "Handling short read and write correctly"
18736 remote_mds_nodsh && skip "remote MDS with nodsh"
18737 remote_ost_nodsh && skip "remote OST with nodsh"
18738 if [ "$ost1_FSTYPE" != ldiskfs ] || [ "$mds1_FSTYPE" != ldiskfs ]; then
18739 skip_env "ldiskfs only test"
18749 # check lr_reader on OST0000
18751 dev=$(facet_device $tgt)
18752 out=$(do_facet $tgt $LR_READER $dev)
18753 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18755 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
18756 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
18757 error "Invalid uuid returned by $LR_READER on target $tgt"
18758 echo -e "uuid returned by $LR_READER is '$uuid'\n"
18760 # check lr_reader -c on MDT0000
18762 dev=$(facet_device $tgt)
18763 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
18764 skip "$LR_READER does not support additional options"
18766 out=$(do_facet $tgt $LR_READER -c $dev)
18767 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18769 num=$(echo "$out" | grep -c "mdtlov")
18770 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
18771 error "Invalid number of mdtlov clients returned by $LR_READER"
18772 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
18774 # check lr_reader -cr on MDT0000
18775 out=$(do_facet $tgt $LR_READER -cr $dev)
18776 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
18778 echo "$out" | grep -q "^reply_data:$" ||
18779 error "$LR_READER should have returned 'reply_data' section"
18780 num=$(echo "$out" | grep -c "client_generation")
18781 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
18783 run_test 252 "check lr_reader tool"
18786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18787 remote_mds_nodsh && skip "remote MDS with nodsh"
18788 remote_mgs_nodsh && skip "remote MGS with nodsh"
18792 local ost_name=$(ostname_from_index $ostidx)
18795 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
18796 do_facet $SINGLEMDS $LCTL get_param -n \
18797 osp.$mdtosc_proc1.reserved_mb_high ||
18798 skip "remote MDS does not support reserved_mb_high"
18802 wait_delete_completed
18805 pool_add $TESTNAME || error "Pool creation failed"
18806 pool_add_targets $TESTNAME 0 || error "Pool add targets failed"
18808 $LFS setstripe $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
18809 error "Setstripe failed"
18811 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M count=10
18813 local wms=$(ost_watermarks_set_enospc $tfile $ostidx |
18815 stack_trap "ost_watermarks_clear_enospc $tfile $ostidx $wms" EXIT
18817 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18818 osp.$mdtosc_proc1.prealloc_status)
18819 echo "prealloc_status $oa_status"
18821 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1M count=1 &&
18822 error "File creation should fail"
18824 #object allocation was stopped, but we still able to append files
18825 dd if=/dev/zero of=$DIR/$tdir/$tfile.0 bs=1M seek=6 count=5 \
18826 oflag=append || error "Append failed"
18828 rm -f $DIR/$tdir/$tfile.0
18830 # For this test, we want to delete the files we created to go out of
18831 # space but leave the watermark, so we remain nearly out of space
18832 ost_watermarks_enospc_delete_files $tfile $ostidx
18834 wait_delete_completed
18838 for i in $(seq 10 12); do
18839 dd if=/dev/zero of=$DIR/$tdir/$tfile.$i bs=1M count=1 \
18840 2>/dev/null || error "File creation failed after rm"
18843 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
18844 osp.$mdtosc_proc1.prealloc_status)
18845 echo "prealloc_status $oa_status"
18847 if (( oa_status != 0 )); then
18848 error "Object allocation still disable after rm"
18851 run_test 253 "Check object allocation limit"
18854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18855 remote_mds_nodsh && skip "remote MDS with nodsh"
18856 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
18857 skip "MDS does not support changelog_size"
18860 local MDT0=$(facet_svc $SINGLEMDS)
18862 changelog_register || error "changelog_register failed"
18864 changelog_clear 0 || error "changelog_clear failed"
18866 local size1=$(do_facet $SINGLEMDS \
18867 $LCTL get_param -n mdd.$MDT0.changelog_size)
18868 echo "Changelog size $size1"
18871 $LFS mkdir -i 0 $DIR/$tdir
18873 mkdir -p $DIR/$tdir/pics/2008/zachy
18874 touch $DIR/$tdir/pics/2008/zachy/timestamp
18875 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
18876 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
18877 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
18878 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
18879 rm $DIR/$tdir/pics/desktop.jpg
18881 local size2=$(do_facet $SINGLEMDS \
18882 $LCTL get_param -n mdd.$MDT0.changelog_size)
18883 echo "Changelog size after work $size2"
18885 (( $size2 > $size1 )) ||
18886 error "new Changelog size=$size2 less than old size=$size1"
18888 run_test 254 "Check changelog size"
18895 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
18896 awk -F: '{print $2}' | grep $type > /dev/null
18897 if [ $? -ne 0 ]; then
18907 lfs ladvise -a willread $file > /dev/null 2>&1
18908 if [ $? -eq 0 ]; then
18912 lfs ladvise -a willread $file 2>&1 |
18913 grep "Inappropriate ioctl for device" > /dev/null
18914 if [ $? -eq 0 ]; then
18921 bc <<<"scale=2; ($1 - $2) * 100 / $2"
18924 # run a random read IO workload
18925 # usage: random_read_iops <filename> <filesize> <iosize>
18926 random_read_iops() {
18929 local iosize=${3:-4096}
18931 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
18932 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
18935 drop_file_oss_cache() {
18939 $LFS ladvise -a dontneed $file 2>/dev/null ||
18940 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
18943 ladvise_willread_performance()
18946 local average_origin=0
18947 local average_cache=0
18948 local average_ladvise=0
18950 for ((i = 1; i <= $repeat; i++)); do
18951 echo "Iter $i/$repeat: reading without willread hint"
18952 cancel_lru_locks osc
18953 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18954 local speed_origin=$(random_read_iops $DIR/$tfile $size)
18955 echo "Iter $i/$repeat: uncached speed: $speed_origin"
18956 average_origin=$(bc <<<"$average_origin + $speed_origin")
18958 cancel_lru_locks osc
18959 local speed_cache=$(random_read_iops $DIR/$tfile $size)
18960 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
18961 average_cache=$(bc <<<"$average_cache + $speed_cache")
18963 cancel_lru_locks osc
18964 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
18965 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
18966 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
18967 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
18968 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
18970 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
18971 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
18972 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
18974 speedup_cache=$(percent $average_cache $average_origin)
18975 speedup_ladvise=$(percent $average_ladvise $average_origin)
18977 echo "Average uncached read: $average_origin"
18978 echo "Average speedup with OSS cached read: " \
18979 "$average_cache = +$speedup_cache%"
18980 echo "Average speedup with ladvise willread: " \
18981 "$average_ladvise = +$speedup_ladvise%"
18983 local lowest_speedup=20
18984 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
18985 echo "Speedup with OSS cached read less than $lowest_speedup%," \
18986 "got $average_cache%. Skipping ladvise willread check."
18990 # the test won't work on ZFS until it supports 'ladvise dontneed', but
18991 # it is still good to run until then to exercise 'ladvise willread'
18992 ! $LFS ladvise -a dontneed $DIR/$tfile &&
18993 [ "$ost1_FSTYPE" = "zfs" ] &&
18994 echo "osd-zfs does not support dontneed or drop_caches" &&
18997 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
18998 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
18999 error_not_in_vm "Speedup with willread is less than " \
19000 "$lowest_speedup%, got $average_ladvise%"
19004 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
19005 skip "lustre < 2.8.54 does not support ladvise "
19006 remote_ost_nodsh && skip "remote OST with nodsh"
19008 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
19010 ladvise_no_type willread $DIR/$tfile &&
19011 skip "willread ladvise is not supported"
19013 ladvise_no_ioctl $DIR/$tfile &&
19014 skip "ladvise ioctl is not supported"
19017 local size=$((size_mb * 1048576))
19018 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
19019 error "dd to $DIR/$tfile failed"
19021 lfs ladvise -a willread $DIR/$tfile ||
19022 error "Ladvise failed with no range argument"
19024 lfs ladvise -a willread -s 0 $DIR/$tfile ||
19025 error "Ladvise failed with no -l or -e argument"
19027 lfs ladvise -a willread -e 1 $DIR/$tfile ||
19028 error "Ladvise failed with only -e argument"
19030 lfs ladvise -a willread -l 1 $DIR/$tfile ||
19031 error "Ladvise failed with only -l argument"
19033 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
19034 error "End offset should not be smaller than start offset"
19036 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
19037 error "End offset should not be equal to start offset"
19039 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
19040 error "Ladvise failed with overflowing -s argument"
19042 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
19043 error "Ladvise failed with overflowing -e argument"
19045 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
19046 error "Ladvise failed with overflowing -l argument"
19048 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
19049 error "Ladvise succeeded with conflicting -l and -e arguments"
19051 echo "Synchronous ladvise should wait"
19053 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
19054 do_nodes $(comma_list $(osts_nodes)) \
19055 $LCTL set_param fail_val=$delay fail_loc=0x237
19057 local start_ts=$SECONDS
19058 lfs ladvise -a willread $DIR/$tfile ||
19059 error "Ladvise failed with no range argument"
19060 local end_ts=$SECONDS
19061 local inteval_ts=$((end_ts - start_ts))
19063 if [ $inteval_ts -lt $(($delay - 1)) ]; then
19064 error "Synchronous advice didn't wait reply"
19067 echo "Asynchronous ladvise shouldn't wait"
19068 local start_ts=$SECONDS
19069 lfs ladvise -a willread -b $DIR/$tfile ||
19070 error "Ladvise failed with no range argument"
19071 local end_ts=$SECONDS
19072 local inteval_ts=$((end_ts - start_ts))
19074 if [ $inteval_ts -gt $(($delay / 2)) ]; then
19075 error "Asynchronous advice blocked"
19078 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
19079 ladvise_willread_performance
19081 run_test 255a "check 'lfs ladvise -a willread'"
19087 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
19091 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
19092 skip "lustre < 2.8.54 does not support ladvise "
19093 remote_ost_nodsh && skip "remote OST with nodsh"
19095 lfs setstripe -c 1 -i 0 $DIR/$tfile
19097 ladvise_no_type dontneed $DIR/$tfile &&
19098 skip "dontneed ladvise is not supported"
19100 ladvise_no_ioctl $DIR/$tfile &&
19101 skip "ladvise ioctl is not supported"
19103 ! $LFS ladvise -a dontneed $DIR/$tfile &&
19104 [ "$ost1_FSTYPE" = "zfs" ] &&
19105 skip "zfs-osd does not support 'ladvise dontneed'"
19108 local size=$((size_mb * 1048576))
19109 # In order to prevent disturbance of other processes, only check 3/4
19110 # of the memory usage
19111 local kibibytes=$((size_mb * 1024 * 3 / 4))
19113 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
19114 error "dd to $DIR/$tfile failed"
19116 #force write to complete before dropping OST cache & checking memory
19119 local total=$(facet_meminfo ost1 MemTotal)
19120 echo "Total memory: $total KiB"
19122 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
19123 local before_read=$(facet_meminfo ost1 Cached)
19124 echo "Cache used before read: $before_read KiB"
19126 lfs ladvise -a willread $DIR/$tfile ||
19127 error "Ladvise willread failed"
19128 local after_read=$(facet_meminfo ost1 Cached)
19129 echo "Cache used after read: $after_read KiB"
19131 lfs ladvise -a dontneed $DIR/$tfile ||
19132 error "Ladvise dontneed again failed"
19133 local no_read=$(facet_meminfo ost1 Cached)
19134 echo "Cache used after dontneed ladvise: $no_read KiB"
19136 if [ $total -lt $((before_read + kibibytes)) ]; then
19137 echo "Memory is too small, abort checking"
19141 if [ $((before_read + kibibytes)) -gt $after_read ]; then
19142 error "Ladvise willread should use more memory" \
19143 "than $kibibytes KiB"
19146 if [ $((no_read + kibibytes)) -gt $after_read ]; then
19147 error "Ladvise dontneed should release more memory" \
19148 "than $kibibytes KiB"
19151 run_test 255b "check 'lfs ladvise -a dontneed'"
19154 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
19155 skip "lustre < 2.10.50 does not support lockahead"
19163 test_mkdir -p $DIR/$tdir
19164 $LFS setstripe -i 0 -c 1 $DIR/$tdir
19166 #test 10 returns only success/failure
19168 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19170 if [ $rc -eq 255 ]; then
19171 error "Ladvise test${i} failed, ${rc}"
19174 #test 11 counts lock enqueue requests, all others count new locks
19176 count=$(do_facet ost1 \
19177 $LCTL get_param -n ost.OSS.ost.stats)
19178 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
19180 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19182 if [ $rc -eq 255 ]; then
19183 error "Ladvise test${i} failed, ${rc}"
19186 new_count=$(do_facet ost1 \
19187 $LCTL get_param -n ost.OSS.ost.stats)
19188 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
19189 awk '{ print $2 }')
19191 difference="$((new_count - count))"
19192 if [ $difference -ne $rc ]; then
19193 error "Ladvise test${i}, bad enqueue count, returned " \
19194 "${rc}, actual ${difference}"
19197 for i in $(seq 12 21); do
19198 # If we do not do this, we run the risk of having too many
19199 # locks and starting lock cancellation while we are checking
19201 cancel_lru_locks osc
19203 count=$($LCTL get_param -n \
19204 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
19206 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19208 if [ $rc -eq 255 ]; then
19209 error "Ladvise test ${i} failed, ${rc}"
19212 new_count=$($LCTL get_param -n \
19213 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
19214 difference="$((new_count - count))"
19216 # Test 15 output is divided by 100 to map down to valid return
19217 if [ $i -eq 15 ]; then
19221 if [ $difference -ne $rc ]; then
19222 error "Ladvise test ${i}, bad lock count, returned " \
19223 "${rc}, actual ${difference}"
19227 #test 22 returns only success/failure
19229 lockahead_test -d $DIR/$tdir -t $i -f $tfile
19231 if [ $rc -eq 255 ]; then
19232 error "Ladvise test${i} failed, ${rc}"
19235 run_test 255c "suite of ladvise lockahead tests"
19238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19239 remote_mds_nodsh && skip "remote MDS with nodsh"
19240 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
19241 changelog_users $SINGLEMDS | grep "^cl" &&
19242 skip "active changelog user"
19248 mdt_dev=$(mdsdevname 1)
19251 changelog_register || error "changelog_register failed"
19254 mkdir -p $DIR/$tdir
19256 changelog_clear 0 || error "changelog_clear failed"
19259 touch $DIR/$tdir/{1..10}
19262 stop $SINGLEMDS || error "Fail to stop MDT"
19266 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
19268 #after mount new plainllog is used
19269 touch $DIR/$tdir/{11..19}
19270 local tmpfile="$(mktemp --tmpdir -u $tfile.XXXXXX)"
19271 stack_trap "rm -f $tmpfile"
19272 cat_sl=$(do_facet $SINGLEMDS "sync; \
19273 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
19274 llog_reader $tmpfile | grep -c type=1064553b")
19275 do_facet $SINGLEMDS llog_reader $tmpfile
19277 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
19279 changelog_clear 0 || error "changelog_clear failed"
19281 cat_sl=$(do_facet $SINGLEMDS "sync; \
19282 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
19283 llog_reader $tmpfile | grep -c type=1064553b")
19285 if (( cat_sl == 2 )); then
19286 error "Empty plain llog was not deleted from changelog catalog"
19287 elif (( cat_sl != 1 )); then
19288 error "Active plain llog shouldn't be deleted from catalog"
19291 run_test 256 "Check llog delete for empty and not full state"
19294 remote_mds_nodsh && skip "remote MDS with nodsh"
19295 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19296 skip "Need MDS version at least 2.8.55"
19298 test_mkdir $DIR/$tdir
19300 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
19301 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
19304 #define OBD_FAIL_MDS_XATTR_REP 0x161
19305 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19306 local facet=mds$((mdtidx + 1))
19307 set_nodes_failloc $(facet_active_host $facet) 0x80000161
19308 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
19310 stop $facet || error "stop MDS failed"
19311 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
19312 error "start MDS fail"
19313 wait_recovery_complete $facet
19315 run_test 257 "xattr locks are not lost"
19317 # Verify we take the i_mutex when security requires it
19319 #define OBD_FAIL_IMUTEX_SEC 0x141c
19320 $LCTL set_param fail_loc=0x141c
19322 chmod u+s $DIR/$tfile
19323 chmod a+rwx $DIR/$tfile
19324 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
19326 if [ $RC -ne 0 ]; then
19327 error "error, failed to take i_mutex, rc=$?"
19331 run_test 258a "verify i_mutex security behavior when suid attributes is set"
19333 # Verify we do NOT take the i_mutex in the normal case
19335 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
19336 $LCTL set_param fail_loc=0x141d
19339 chmod a+rw $DIR/$tfile
19340 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
19342 if [ $RC -ne 0 ]; then
19343 error "error, took i_mutex unnecessarily, rc=$?"
19348 run_test 258b "verify i_mutex security behavior"
19351 local file=$DIR/$tfile
19355 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
19357 stack_trap "rm -f $file" EXIT
19359 wait_delete_completed
19360 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19361 echo "before: $before"
19363 $LFS setstripe -i 0 -c 1 $file
19364 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
19366 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19367 echo "after write: $after"
19369 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
19370 do_facet ost1 $LCTL set_param fail_loc=0x2301
19372 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19373 echo "after truncate: $after"
19376 do_facet ost1 $LCTL set_param fail_loc=0
19377 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
19379 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
19380 echo "after restart: $after"
19381 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
19382 error "missing truncate?"
19386 run_test 259 "crash at delayed truncate"
19389 #define OBD_FAIL_MDC_CLOSE 0x806
19390 $LCTL set_param fail_loc=0x80000806
19394 run_test 260 "Check mdc_close fail"
19396 ### Data-on-MDT sanity tests ###
19398 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19399 skip "Need MDS version at least 2.10.55 for DoM"
19402 local dom=$DIR/$tdir/dom_file
19403 local tmp=$DIR/$tdir/tmp_file
19405 mkdir -p $DIR/$tdir
19407 # basic checks for DoM component creation
19408 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
19409 error "Can set MDT layout to non-first entry"
19411 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
19412 error "Can define multiple entries as MDT layout"
19414 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
19416 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
19417 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
19418 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
19420 local mdtidx=$($LFS getstripe -m $dom)
19421 local mdtname=MDT$(printf %04x $mdtidx)
19422 local facet=mds$((mdtidx + 1))
19423 local space_check=1
19425 # Skip free space checks with ZFS
19426 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
19430 local size_tmp=$((65536 * 3))
19431 local mdtfree1=$(do_facet $facet \
19432 lctl get_param -n osd*.*$mdtname.kbytesfree)
19434 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
19435 # check also direct IO along write
19436 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
19437 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
19439 cmp $tmp $dom || error "file data is different"
19440 [ $(stat -c%s $dom) == $size_tmp ] ||
19441 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
19442 if [ $space_check == 1 ]; then
19443 local mdtfree2=$(do_facet $facet \
19444 lctl get_param -n osd*.*$mdtname.kbytesfree)
19446 # increase in usage from by $size_tmp
19447 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
19448 error "MDT free space wrong after write: " \
19449 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
19453 local size_dom=10000
19455 $TRUNCATE $dom $size_dom
19456 [ $(stat -c%s $dom) == $size_dom ] ||
19457 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
19458 if [ $space_check == 1 ]; then
19459 mdtfree1=$(do_facet $facet \
19460 lctl get_param -n osd*.*$mdtname.kbytesfree)
19461 # decrease in usage from $size_tmp to new $size_dom
19462 [ $(($mdtfree1 - $mdtfree2)) -ge \
19463 $(((size_tmp - size_dom) / 1024)) ] ||
19464 error "MDT free space is wrong after truncate: " \
19465 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
19471 size_dom=$((size_dom + size_tmp))
19472 [ $(stat -c%s $dom) == $size_dom ] ||
19473 error "bad size after append: $(stat -c%s $dom) != $size_dom"
19474 if [ $space_check == 1 ]; then
19475 mdtfree2=$(do_facet $facet \
19476 lctl get_param -n osd*.*$mdtname.kbytesfree)
19477 # increase in usage by $size_tmp from previous
19478 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
19479 error "MDT free space is wrong after append: " \
19480 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
19485 if [ $space_check == 1 ]; then
19486 mdtfree1=$(do_facet $facet \
19487 lctl get_param -n osd*.*$mdtname.kbytesfree)
19488 # decrease in usage by $size_dom from previous
19489 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
19490 error "MDT free space is wrong after removal: " \
19491 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
19494 # combined striping
19495 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
19496 error "Can't create DoM + OST striping"
19498 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
19499 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
19500 # check also direct IO along write
19501 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
19503 cmp $tmp $dom || error "file data is different"
19504 [ $(stat -c%s $dom) == $size_tmp ] ||
19505 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
19510 run_test 270a "DoM: basic functionality tests"
19513 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19514 skip "Need MDS version at least 2.10.55"
19516 local dom=$DIR/$tdir/dom_file
19517 local max_size=1048576
19519 mkdir -p $DIR/$tdir
19520 $LFS setstripe -E $max_size -L mdt $dom
19522 # truncate over the limit
19523 $TRUNCATE $dom $(($max_size + 1)) &&
19524 error "successful truncate over the maximum size"
19525 # write over the limit
19526 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
19527 error "successful write over the maximum size"
19528 # append over the limit
19529 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
19530 echo "12345" >> $dom && error "successful append over the maximum size"
19535 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
19538 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19539 skip "Need MDS version at least 2.10.55"
19541 mkdir -p $DIR/$tdir
19542 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19544 # check files inherit DoM EA
19545 touch $DIR/$tdir/first
19546 [ $($LFS getstripe -L $DIR/$tdir/first) == "mdt" ] ||
19547 error "bad pattern"
19548 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
19549 error "bad stripe count"
19550 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
19551 error "bad stripe size"
19553 # check directory inherits DoM EA and uses it as default
19554 mkdir $DIR/$tdir/subdir
19555 touch $DIR/$tdir/subdir/second
19556 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
19557 error "bad pattern in sub-directory"
19558 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
19559 error "bad stripe count in sub-directory"
19560 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
19561 error "bad stripe size in sub-directory"
19564 run_test 270c "DoM: DoM EA inheritance tests"
19567 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19568 skip "Need MDS version at least 2.10.55"
19570 mkdir -p $DIR/$tdir
19571 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19573 # inherit default DoM striping
19574 mkdir $DIR/$tdir/subdir
19575 touch $DIR/$tdir/subdir/f1
19577 # change default directory striping
19578 $LFS setstripe -c 1 $DIR/$tdir/subdir
19579 touch $DIR/$tdir/subdir/f2
19580 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
19581 error "wrong default striping in file 2"
19582 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
19583 error "bad pattern in file 2"
19586 run_test 270d "DoM: change striping from DoM to RAID0"
19589 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19590 skip "Need MDS version at least 2.10.55"
19592 mkdir -p $DIR/$tdir/dom
19593 mkdir -p $DIR/$tdir/norm
19596 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
19597 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
19599 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
19600 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
19602 # find DoM files by layout
19603 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
19604 [ $NUM -eq $DOMFILES ] ||
19605 error "lfs find -L: found $NUM, expected $DOMFILES"
19606 echo "Test 1: lfs find 20 DOM files by layout: OK"
19608 # there should be 1 dir with default DOM striping
19609 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
19611 error "lfs find -L: found $NUM, expected 1 dir"
19612 echo "Test 2: lfs find 1 DOM dir by layout: OK"
19614 # find DoM files by stripe size
19615 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
19616 [ $NUM -eq $DOMFILES ] ||
19617 error "lfs find -S: found $NUM, expected $DOMFILES"
19618 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
19620 # find files by stripe offset except DoM files
19621 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
19622 [ $NUM -eq $NORMFILES ] ||
19623 error "lfs find -i: found $NUM, expected $NORMFILES"
19624 echo "Test 5: lfs find no DOM files by stripe index: OK"
19627 run_test 270e "DoM: lfs find with DoM files test"
19630 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19631 skip "Need MDS version at least 2.10.55"
19633 local mdtname=${FSNAME}-MDT0000-mdtlov
19634 local dom=$DIR/$tdir/dom_file
19635 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
19636 lod.$mdtname.dom_stripesize)
19637 local dom_limit=131072
19639 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
19640 local dom_current=$(do_facet mds1 $LCTL get_param -n \
19641 lod.$mdtname.dom_stripesize)
19642 [ ${dom_limit} -eq ${dom_current} ] ||
19643 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
19645 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19646 $LFS setstripe -d $DIR/$tdir
19647 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
19648 error "Can't set directory default striping"
19650 # exceed maximum stripe size
19651 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
19652 error "Can't create file with $((dom_limit * 2)) DoM stripe"
19653 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
19654 error "Able to create DoM component size more than LOD limit"
19656 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
19657 dom_current=$(do_facet mds1 $LCTL get_param -n \
19658 lod.$mdtname.dom_stripesize)
19659 [ 0 -eq ${dom_current} ] ||
19660 error "Can't set zero DoM stripe limit"
19663 # attempt to create DoM file on server with disabled DoM should
19664 # remove DoM entry from layout and be succeed
19665 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
19666 error "Can't create DoM file (DoM is disabled)"
19667 [ $($LFS getstripe -L $dom) == "mdt" ] &&
19668 error "File has DoM component while DoM is disabled"
19671 # attempt to create DoM file with only DoM stripe should return error
19672 $LFS setstripe -E $dom_limit -L mdt $dom &&
19673 error "Able to create DoM-only file while DoM is disabled"
19675 # too low values to be aligned with smallest stripe size 64K
19676 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
19677 dom_current=$(do_facet mds1 $LCTL get_param -n \
19678 lod.$mdtname.dom_stripesize)
19679 [ 30000 -eq ${dom_current} ] &&
19680 error "Can set too small DoM stripe limit"
19682 # 64K is a minimal stripe size in Lustre, expect limit of that size
19683 [ 65536 -eq ${dom_current} ] ||
19684 error "Limit is not set to 64K but ${dom_current}"
19686 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
19687 dom_current=$(do_facet mds1 $LCTL get_param -n \
19688 lod.$mdtname.dom_stripesize)
19690 [ 2147483648 -eq ${dom_current} ] &&
19691 error "Can set too large DoM stripe limit"
19693 do_facet mds1 $LCTL set_param -n \
19694 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
19695 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
19696 error "Can't create DoM component size after limit change"
19697 do_facet mds1 $LCTL set_param -n \
19698 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
19699 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
19700 error "Can't create DoM file after limit decrease"
19701 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
19702 error "Can create big DoM component after limit decrease"
19703 touch ${dom}_def ||
19704 error "Can't create file with old default layout"
19706 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
19709 run_test 270f "DoM: maximum DoM stripe size checks"
19712 [ $MDS1_VERSION -ge $(version_code 2.13.52) ] ||
19713 skip "Need MDS version at least 2.13.52"
19714 local dom=$DIR/$tdir/$tfile
19716 $LFS mkdir -i 0 -c 1 $DIR/$tdir
19717 local lodname=${FSNAME}-MDT0000-mdtlov
19719 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
19720 save_lustre_params mds1 "lod.${lodname}.dom_stripesize_max_kb" > $save
19721 save_lustre_params mds1 "lod.${lodname}.dom_threshold_free_mb" >> $save
19722 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
19724 local dom_limit=1024
19725 local dom_threshold="50%"
19727 $LFS setstripe -d $DIR/$tdir
19728 $LFS setstripe -E ${dom_limit}K -L mdt $DIR/$tdir ||
19729 error "Can't set directory default striping"
19731 do_facet mds1 $LCTL set_param -n \
19732 lod.${lodname}.dom_stripesize_max_kb=$dom_limit
19733 # set 0 threshold and create DOM file to change tunable stripesize
19734 do_facet mds1 $LCTL set_param -n lod.${lodname}.dom_threshold_free_mb=0
19735 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
19736 error "Failed to create $dom file"
19737 # now tunable dom_cur_stripesize should reach maximum
19738 local dom_current=$(do_facet mds1 $LCTL get_param -n \
19739 lod.${lodname}.dom_stripesize_cur_kb)
19740 [[ $dom_current == $dom_limit ]] ||
19741 error "Current DOM stripesize is not maximum"
19744 # set threshold for further tests
19745 do_facet mds1 $LCTL set_param -n \
19746 lod.${lodname}.dom_threshold_free_mb=$dom_threshold
19747 echo "DOM threshold is $dom_threshold free space"
19750 # Spoof bfree to exceed threshold
19751 #define OBD_FAIL_MDS_STATFS_SPOOF 0x168
19752 do_facet mds1 $LCTL set_param -n fail_loc=0x0168
19753 for spfree in 40 20 0 15 30 55; do
19754 do_facet mds1 $LCTL set_param -n fail_val=$spfree
19755 $LFS setstripe -E ${dom_limit}K -L mdt -E -1 $dom ||
19756 error "Failed to create $dom file"
19757 dom_def=$(do_facet mds1 $LCTL get_param -n \
19758 lod.${lodname}.dom_stripesize_cur_kb)
19759 echo "Free space: ${spfree}%, default DOM stripe: ${dom_def}K"
19760 [[ $dom_def != $dom_current ]] ||
19761 error "Default stripe size was not changed"
19762 if [[ $spfree > 0 ]] ; then
19763 dom_set=$($LFS getstripe -S $dom)
19764 [[ $dom_set == $((dom_def * 1024)) ]] ||
19765 error "DOM component size is still old"
19767 [[ $($LFS getstripe -L $dom) != "mdt" ]] ||
19768 error "DoM component is set with no free space"
19771 dom_current=$dom_def
19774 run_test 270g "DoM: default DoM stripe size depends on free space"
19777 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19778 skip "Need MDS version at least 2.10.55"
19780 local dom=$DIR/$tdir/dom
19782 mkdir -p $DIR/$tdir
19784 $LFS setstripe -E 1024K -L mdt $dom
19786 lctl set_param -n mdc.*.stats=clear
19787 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
19788 cat $dom > /dev/null
19789 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
19790 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
19794 run_test 271a "DoM: data is cached for read after write"
19797 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19798 skip "Need MDS version at least 2.10.55"
19800 local dom=$DIR/$tdir/dom
19802 mkdir -p $DIR/$tdir
19804 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19806 lctl set_param -n mdc.*.stats=clear
19807 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
19808 cancel_lru_locks mdc
19809 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
19810 # second stat to check size is cached on client
19811 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
19812 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19813 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
19816 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
19819 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19820 skip "Need MDS version at least 2.10.55"
19822 local dom=$DIR/$tdir/dom
19824 mkdir -p $DIR/$tdir
19826 $LFS setstripe -E 1024K -L mdt -E EOF $dom
19828 lctl set_param -n mdc.*.stats=clear
19829 lctl set_param -n osc.*.stats=clear
19830 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
19831 cancel_lru_locks mdc
19832 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19833 # second stat to check size is cached on client
19834 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
19835 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
19836 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
19837 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
19838 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
19841 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
19847 local mdt=MDT$(printf %04x $mdtidx)
19849 if [ -z $param ]; then
19850 lctl get_param -n mdc.*$mdt*.stats
19852 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
19857 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
19858 skip "Need MDS version at least 2.10.55"
19860 local dom=$DIR/$tdir/dom
19862 mkdir -p $DIR/$tdir
19864 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19866 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
19867 local facet=mds$((mdtidx + 1))
19869 cancel_lru_locks mdc
19870 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
19871 createmany -o $dom 1000
19872 lctl set_param -n mdc.*.stats=clear
19873 smalliomany -w $dom 1000 200
19874 get_mdc_stats $mdtidx
19875 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19876 # Each file has 1 open, 1 IO enqueues, total 2000
19877 # but now we have also +1 getxattr for security.capability, total 3000
19878 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
19879 unlinkmany $dom 1000
19881 cancel_lru_locks mdc
19882 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
19883 createmany -o $dom 1000
19884 lctl set_param -n mdc.*.stats=clear
19885 smalliomany -w $dom 1000 200
19886 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
19887 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
19888 # for OPEN and IO lock.
19889 [ $((enq - enq_2)) -ge 1000 ] ||
19890 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
19891 unlinkmany $dom 1000
19894 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
19896 cleanup_271def_tests() {
19902 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19903 skip "Need MDS version at least 2.10.57"
19905 local dom=$DIR/$tdir/dom
19906 local tmp=$TMP/$tfile
19907 trap "cleanup_271def_tests $tmp" EXIT
19909 mkdir -p $DIR/$tdir
19911 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19913 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19915 cancel_lru_locks mdc
19916 dd if=/dev/urandom of=$tmp bs=1000 count=1
19917 dd if=$tmp of=$dom bs=1000 count=1
19918 cancel_lru_locks mdc
19920 cat /etc/hosts >> $tmp
19921 lctl set_param -n mdc.*.stats=clear
19923 # append data to the same file it should update local page
19924 echo "Append to the same page"
19925 cat /etc/hosts >> $dom
19926 local num=$(get_mdc_stats $mdtidx ost_read)
19927 local ra=$(get_mdc_stats $mdtidx req_active)
19928 local rw=$(get_mdc_stats $mdtidx req_waittime)
19930 [ -z $num ] || error "$num READ RPC occured"
19931 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19935 cmp $tmp $dom || error "file miscompare"
19937 cancel_lru_locks mdc
19938 lctl set_param -n mdc.*.stats=clear
19940 echo "Open and read file"
19941 cat $dom > /dev/null
19942 local num=$(get_mdc_stats $mdtidx ost_read)
19943 local ra=$(get_mdc_stats $mdtidx req_active)
19944 local rw=$(get_mdc_stats $mdtidx req_waittime)
19946 [ -z $num ] || error "$num READ RPC occured"
19947 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19951 cmp $tmp $dom || error "file miscompare"
19955 run_test 271d "DoM: read on open (1K file in reply buffer)"
19958 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
19959 skip "Need MDS version at least 2.10.57"
19961 local dom=$DIR/$tdir/dom
19962 local tmp=$TMP/$tfile
19963 trap "cleanup_271def_tests $tmp" EXIT
19965 mkdir -p $DIR/$tdir
19967 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
19969 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
19971 cancel_lru_locks mdc
19972 dd if=/dev/urandom of=$tmp bs=265000 count=1
19973 dd if=$tmp of=$dom bs=265000 count=1
19974 cancel_lru_locks mdc
19975 cat /etc/hosts >> $tmp
19976 lctl set_param -n mdc.*.stats=clear
19978 echo "Append to the same page"
19979 cat /etc/hosts >> $dom
19980 local num=$(get_mdc_stats $mdtidx ost_read)
19981 local ra=$(get_mdc_stats $mdtidx req_active)
19982 local rw=$(get_mdc_stats $mdtidx req_waittime)
19984 [ -z $num ] || error "$num READ RPC occured"
19985 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
19989 cmp $tmp $dom || error "file miscompare"
19991 cancel_lru_locks mdc
19992 lctl set_param -n mdc.*.stats=clear
19994 echo "Open and read file"
19995 cat $dom > /dev/null
19996 local num=$(get_mdc_stats $mdtidx ost_read)
19997 local ra=$(get_mdc_stats $mdtidx req_active)
19998 local rw=$(get_mdc_stats $mdtidx req_waittime)
20000 [ -z $num ] && num=0
20001 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
20002 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
20006 cmp $tmp $dom || error "file miscompare"
20010 run_test 271f "DoM: read on open (200K file and read tail)"
20013 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
20014 skip "Skipping due to old client or server version"
20016 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
20018 $CHECKSTAT -t file $DIR1/$tfile
20020 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
20023 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
20024 $LCTL set_param fail_loc=0x80000314
20025 rm $DIR1/$tfile || error "Unlink fails"
20027 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
20028 [ $RC -eq 0 ] || error "Failed write to stale object"
20030 run_test 271g "Discard DoM data vs client flush race"
20033 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20034 skip "Need MDS version at least 2.11.50"
20036 local dom=$DIR/$tdir/dom
20037 mkdir -p $DIR/$tdir
20039 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
20040 dd if=/dev/urandom of=$dom bs=512K count=1 ||
20041 error "failed to write data into $dom"
20042 local old_md5=$(md5sum $dom)
20044 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
20045 error "failed to migrate to the same DoM component"
20047 local new_md5=$(md5sum $dom)
20049 [ "$old_md5" == "$new_md5" ] ||
20050 error "md5sum differ: $old_md5, $new_md5"
20052 [ $($LFS getstripe -c $dom) -eq 2 ] ||
20053 error "bad final stripe count: $($LFS getstripe -c $dom) != 2"
20055 run_test 272a "DoM migration: new layout with the same DOM component"
20058 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20059 skip "Need MDS version at least 2.11.50"
20061 local dom=$DIR/$tdir/dom
20062 mkdir -p $DIR/$tdir
20063 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20065 local mdtidx=$($LFS getstripe -m $dom)
20066 local mdtname=MDT$(printf %04x $mdtidx)
20067 local facet=mds$((mdtidx + 1))
20069 local mdtfree1=$(do_facet $facet \
20070 lctl get_param -n osd*.*$mdtname.kbytesfree)
20071 dd if=/dev/urandom of=$dom bs=2M count=1 ||
20072 error "failed to write data into $dom"
20073 local old_md5=$(md5sum $dom)
20074 cancel_lru_locks mdc
20075 local mdtfree1=$(do_facet $facet \
20076 lctl get_param -n osd*.*$mdtname.kbytesfree)
20078 $LFS migrate -c2 $dom ||
20079 error "failed to migrate to the new composite layout"
20080 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20081 error "MDT stripe was not removed"
20083 cancel_lru_locks mdc
20084 local new_md5=$(md5sum $dom)
20085 [ "$old_md5" == "$new_md5" ] ||
20086 error "$old_md5 != $new_md5"
20088 # Skip free space checks with ZFS
20089 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20090 local mdtfree2=$(do_facet $facet \
20091 lctl get_param -n osd*.*$mdtname.kbytesfree)
20092 [ $mdtfree2 -gt $mdtfree1 ] ||
20093 error "MDT space is not freed after migration"
20097 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
20100 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20101 skip "Need MDS version at least 2.11.50"
20103 local dom=$DIR/$tdir/$tfile
20104 mkdir -p $DIR/$tdir
20105 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20107 local mdtidx=$($LFS getstripe -m $dom)
20108 local mdtname=MDT$(printf %04x $mdtidx)
20109 local facet=mds$((mdtidx + 1))
20111 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
20112 error "failed to write data into $dom"
20113 local old_md5=$(md5sum $dom)
20114 cancel_lru_locks mdc
20115 local mdtfree1=$(do_facet $facet \
20116 lctl get_param -n osd*.*$mdtname.kbytesfree)
20118 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
20119 error "failed to migrate to the new composite layout"
20120 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
20121 error "MDT stripe was not removed"
20123 cancel_lru_locks mdc
20124 local new_md5=$(md5sum $dom)
20125 [ "$old_md5" == "$new_md5" ] ||
20126 error "$old_md5 != $new_md5"
20128 # Skip free space checks with ZFS
20129 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20130 local mdtfree2=$(do_facet $facet \
20131 lctl get_param -n osd*.*$mdtname.kbytesfree)
20132 [ $mdtfree2 -gt $mdtfree1 ] ||
20133 error "MDS space is not freed after migration"
20137 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
20140 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20141 skip "Need MDS version at least 2.12.55"
20143 local dom=$DIR/$tdir/$tfile
20144 mkdir -p $DIR/$tdir
20145 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
20147 local mdtidx=$($LFS getstripe -m $dom)
20148 local mdtname=MDT$(printf %04x $mdtidx)
20149 local facet=mds$((mdtidx + 1))
20151 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
20152 error "failed to write data into $dom"
20153 local old_md5=$(md5sum $dom)
20154 cancel_lru_locks mdc
20155 local mdtfree1=$(do_facet $facet \
20156 lctl get_param -n osd*.*$mdtname.kbytesfree)
20158 $LFS mirror extend -N -E 2M -c1 -E -1 -c2 $dom ||
20159 error "failed mirroring to the new composite layout"
20160 $LFS mirror resync $dom ||
20161 error "failed mirror resync"
20162 $LFS mirror split --mirror-id 1 -d $dom ||
20163 error "failed mirror split"
20165 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20166 error "MDT stripe was not removed"
20168 cancel_lru_locks mdc
20169 local new_md5=$(md5sum $dom)
20170 [ "$old_md5" == "$new_md5" ] ||
20171 error "$old_md5 != $new_md5"
20173 # Skip free space checks with ZFS
20174 if [ "$(facet_fstype $facet)" != "zfs" ]; then
20175 local mdtfree2=$(do_facet $facet \
20176 lctl get_param -n osd*.*$mdtname.kbytesfree)
20177 [ $mdtfree2 -gt $mdtfree1 ] ||
20178 error "MDS space is not freed after DOM mirror deletion"
20182 run_test 272d "DoM mirroring: OST-striped mirror to DOM file"
20185 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20186 skip "Need MDS version at least 2.12.55"
20188 local dom=$DIR/$tdir/$tfile
20189 mkdir -p $DIR/$tdir
20190 $LFS setstripe -c 2 $dom
20192 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
20193 error "failed to write data into $dom"
20194 local old_md5=$(md5sum $dom)
20195 cancel_lru_locks mdc
20197 $LFS mirror extend -N -E 1M -L mdt -E eof -c2 $dom ||
20198 error "failed mirroring to the DOM layout"
20199 $LFS mirror resync $dom ||
20200 error "failed mirror resync"
20201 $LFS mirror split --mirror-id 1 -d $dom ||
20202 error "failed mirror split"
20204 [ $($LFS getstripe -L $dom) != 'mdt' ] ||
20205 error "MDT stripe was not removed"
20207 cancel_lru_locks mdc
20208 local new_md5=$(md5sum $dom)
20209 [ "$old_md5" == "$new_md5" ] ||
20210 error "$old_md5 != $new_md5"
20214 run_test 272e "DoM mirroring: DOM mirror to the OST-striped file"
20217 [ $MDS1_VERSION -lt $(version_code 2.12.55) ] &&
20218 skip "Need MDS version at least 2.12.55"
20220 local dom=$DIR/$tdir/$tfile
20221 mkdir -p $DIR/$tdir
20222 $LFS setstripe -c 2 $dom
20224 dd if=/dev/urandom of=$dom bs=512K count=1 oflag=direct ||
20225 error "failed to write data into $dom"
20226 local old_md5=$(md5sum $dom)
20227 cancel_lru_locks mdc
20229 $LFS migrate -E 1M -L mdt -E eof -c2 -v $dom ||
20230 error "failed migrating to the DOM file"
20232 cancel_lru_locks mdc
20233 local new_md5=$(md5sum $dom)
20234 [ "$old_md5" != "$new_md5" ] &&
20235 error "$old_md5 != $new_md5"
20239 run_test 272f "DoM migration: OST-striped file to DOM file"
20242 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
20243 skip "Need MDS version at least 2.11.50"
20245 # Layout swap cannot be done if either file has DOM component,
20246 # this will never be supported, migration should be used instead
20248 local dom=$DIR/$tdir/$tfile
20249 mkdir -p $DIR/$tdir
20251 $LFS setstripe -c2 ${dom}_plain
20252 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
20253 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
20254 error "can swap layout with DoM component"
20255 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
20256 error "can swap layout with DoM component"
20258 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
20259 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
20260 error "can swap layout with DoM component"
20261 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
20262 error "can swap layout with DoM component"
20265 run_test 273a "DoM: layout swapping should fail with DOM"
20268 remote_ost_nodsh && skip "remote OST with nodsh"
20269 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
20270 skip "Need OST version >= 2.10.57"
20272 local file=$DIR/$tfile
20275 oss=$(comma_list $(osts_nodes))
20277 dd if=/dev/urandom of=$file bs=1M count=2 ||
20278 error "failed to create a file"
20279 cancel_lru_locks osc
20282 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
20283 error "failed to read a file"
20285 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
20286 $LCTL set_param fail_loc=0x8000031f
20288 cancel_lru_locks osc &
20291 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
20292 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
20293 #IO takes another lock, but matches the PENDING one
20294 #and places it to the IO RPC
20295 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
20296 error "failed to read a file with PENDING lock"
20298 run_test 275 "Read on a canceled duplicate lock"
20301 remote_ost_nodsh && skip "remote OST with nodsh"
20304 do_facet ost1 "(while true; do \
20305 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
20306 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
20309 for LOOP in $(seq 20); do
20311 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
20314 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
20315 rm $TMP/sanity_276_pid"
20317 run_test 276 "Race between mount and obd_statfs"
20320 $LCTL set_param ldlm.namespaces.*.lru_size=0
20321 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
20322 local cached_mb=$($LCTL get_param llite.*.max_cached_mb |
20323 grep ^used_mb | awk '{print $2}')
20324 [ $cached_mb -eq 1 ] || error "expected mb 1 got $cached_mb"
20325 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 \
20326 oflag=direct conv=notrunc
20327 cached_mb=$($LCTL get_param llite.*.max_cached_mb |
20328 grep ^used_mb | awk '{print $2}')
20329 [ $cached_mb -eq 0 ] || error "expected mb 0 got $cached_mb"
20331 run_test 277 "Direct IO shall drop page cache"
20334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
20335 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
20336 [[ "$(facet_host mds1)" != "$(facet_host mds2)" ]] &&
20337 skip "needs the same host for mdt1 mdt2" && return
20342 #define OBD_FAIL_OBD_STOP_MDS_RACE 0x60b
20343 do_facet mds2 $LCTL set_param fail_loc=0x8000060c
20349 echo "Starting MDTs"
20350 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20352 #For the error assertion will happen. lu_env_get_key(..., &mdt_thread_key)
20354 do_facet mds2 $LCTL set_param fail_loc=0
20356 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS
20357 wait_recovery_complete mds2
20359 run_test 278 "Race starting MDS between MDTs stop/start"
20362 [ $MGS_VERSION -lt $(version_code 2.13.52) ] &&
20363 skip "Need MGS version at least 2.13.52"
20364 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20365 combined_mgs_mds || skip "needs combined MGS/MDT"
20367 umount_client $MOUNT
20368 #define OBD_FAIL_MDS_LLOG_UMOUNT_RACE 0x15e
20369 do_facet mgs $LCTL set_param fail_loc=0x8000015e fail_val=0
20371 mount_client $MOUNT &
20373 stop mgs || error "stop mgs failed"
20374 #for a race mgs would crash
20375 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
20376 mount_client $MOUNT || error "mount client failed"
20378 run_test 280 "Race between MGS umount and client llog processing"
20380 cleanup_test_300() {
20384 test_striped_dir() {
20389 mkdir -p $DIR/$tdir
20391 SAVE_UMASK=$(umask)
20392 trap cleanup_test_300 RETURN EXIT
20394 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
20395 $DIR/$tdir/striped_dir ||
20396 error "set striped dir error"
20398 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
20399 [ "$mode" = "755" ] || error "expect 755 got $mode"
20401 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
20402 error "getdirstripe failed"
20403 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
20404 if [ "$stripe_count" != "2" ]; then
20405 error "1:stripe_count is $stripe_count, expect 2"
20407 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
20408 if [ "$stripe_count" != "2" ]; then
20409 error "2:stripe_count is $stripe_count, expect 2"
20412 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
20413 if [ "$stripe_index" != "$mdt_index" ]; then
20414 error "stripe_index is $stripe_index, expect $mdt_index"
20417 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
20418 error "nlink error after create striped dir"
20420 mkdir $DIR/$tdir/striped_dir/a
20421 mkdir $DIR/$tdir/striped_dir/b
20423 stat $DIR/$tdir/striped_dir/a ||
20424 error "create dir under striped dir failed"
20425 stat $DIR/$tdir/striped_dir/b ||
20426 error "create dir under striped dir failed"
20428 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
20429 error "nlink error after mkdir"
20431 rmdir $DIR/$tdir/striped_dir/a
20432 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
20433 error "nlink error after rmdir"
20435 rmdir $DIR/$tdir/striped_dir/b
20436 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
20437 error "nlink error after rmdir"
20439 chattr +i $DIR/$tdir/striped_dir
20440 createmany -o $DIR/$tdir/striped_dir/f 10 &&
20441 error "immutable flags not working under striped dir!"
20442 chattr -i $DIR/$tdir/striped_dir
20444 rmdir $DIR/$tdir/striped_dir ||
20445 error "rmdir striped dir error"
20453 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20454 skip "skipped for lustre < 2.7.0"
20455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20456 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20458 test_striped_dir 0 || error "failed on striped dir on MDT0"
20459 test_striped_dir 1 || error "failed on striped dir on MDT0"
20461 run_test 300a "basic striped dir sanity test"
20464 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20465 skip "skipped for lustre < 2.7.0"
20466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20467 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20474 test_mkdir $DIR/$tdir || error "mkdir fail"
20475 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20476 error "set striped dir error"
20477 for i in {0..9}; do
20478 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
20480 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
20481 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
20482 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
20484 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
20485 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
20486 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
20490 run_test 300b "check ctime/mtime for striped dir"
20493 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20494 skip "skipped for lustre < 2.7.0"
20495 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20496 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20500 mkdir -p $DIR/$tdir
20501 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
20502 error "set striped dir error"
20504 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
20505 error "chown striped dir failed"
20507 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
20508 error "create 5k files failed"
20510 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
20512 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
20516 run_test 300c "chown && check ls under striped directory"
20519 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
20520 skip "skipped for lustre < 2.7.0"
20521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20522 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20527 mkdir -p $DIR/$tdir
20528 $LFS setstripe -c 2 $DIR/$tdir
20530 #local striped directory
20531 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20532 error "set striped dir error"
20533 #look at the directories for debug purposes
20535 $LFS getdirstripe $DIR/$tdir
20536 ls -l $DIR/$tdir/striped_dir
20537 $LFS getdirstripe $DIR/$tdir/striped_dir
20538 createmany -o $DIR/$tdir/striped_dir/f 10 ||
20539 error "create 10 files failed"
20541 #remote striped directory
20542 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
20543 error "set striped dir error"
20544 #look at the directories for debug purposes
20546 $LFS getdirstripe $DIR/$tdir
20547 ls -l $DIR/$tdir/remote_striped_dir
20548 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
20549 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
20550 error "create 10 files failed"
20552 for file in $(find $DIR/$tdir); do
20553 stripe_count=$($LFS getstripe -c $file)
20554 [ $stripe_count -eq 2 ] ||
20555 error "wrong stripe $stripe_count for $file"
20560 run_test 300d "check default stripe under striped directory"
20563 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20564 skip "Need MDS version at least 2.7.55"
20565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20566 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20571 mkdir -p $DIR/$tdir
20573 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20574 error "set striped dir error"
20576 touch $DIR/$tdir/striped_dir/a
20577 touch $DIR/$tdir/striped_dir/b
20578 touch $DIR/$tdir/striped_dir/c
20580 mkdir $DIR/$tdir/striped_dir/dir_a
20581 mkdir $DIR/$tdir/striped_dir/dir_b
20582 mkdir $DIR/$tdir/striped_dir/dir_c
20584 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
20585 error "set striped adir under striped dir error"
20587 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
20588 error "set striped bdir under striped dir error"
20590 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
20591 error "set striped cdir under striped dir error"
20593 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
20594 error "rename dir under striped dir fails"
20596 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
20597 error "rename dir under different stripes fails"
20599 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
20600 error "rename file under striped dir should succeed"
20602 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
20603 error "rename dir under striped dir should succeed"
20607 run_test 300e "check rename under striped directory"
20610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20611 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20612 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20613 skip "Need MDS version at least 2.7.55"
20619 mkdir -p $DIR/$tdir
20621 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
20622 error "set striped dir error"
20624 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
20625 error "set striped dir error"
20627 touch $DIR/$tdir/striped_dir/a
20628 mkdir $DIR/$tdir/striped_dir/dir_a
20629 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
20630 error "create striped dir under striped dir fails"
20632 touch $DIR/$tdir/striped_dir1/b
20633 mkdir $DIR/$tdir/striped_dir1/dir_b
20634 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
20635 error "create striped dir under striped dir fails"
20637 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
20638 error "rename dir under different striped dir should fail"
20640 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
20641 error "rename striped dir under diff striped dir should fail"
20643 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
20644 error "rename file under diff striped dirs fails"
20648 run_test 300f "check rename cross striped directory"
20650 test_300_check_default_striped_dir()
20653 local default_count=$2
20654 local default_index=$3
20657 local dir_stripe_index
20660 echo "checking $dirname $default_count $default_index"
20661 $LFS setdirstripe -D -c $default_count -i $default_index \
20662 -t all_char $DIR/$tdir/$dirname ||
20663 error "set default stripe on striped dir error"
20664 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
20665 [ $stripe_count -eq $default_count ] ||
20666 error "expect $default_count get $stripe_count for $dirname"
20668 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
20669 [ $stripe_index -eq $default_index ] ||
20670 error "expect $default_index get $stripe_index for $dirname"
20672 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
20673 error "create dirs failed"
20675 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
20676 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
20677 for dir in $(find $DIR/$tdir/$dirname/*); do
20678 stripe_count=$($LFS getdirstripe -c $dir)
20679 [ $stripe_count -eq $default_count ] ||
20680 [ $stripe_count -eq 0 ] || [ $default_count -eq 1 ] ||
20681 error "stripe count $default_count != $stripe_count for $dir"
20683 stripe_index=$($LFS getdirstripe -i $dir)
20684 [ $default_index -eq -1 ] ||
20685 [ $stripe_index -eq $default_index ] ||
20686 error "$stripe_index != $default_index for $dir"
20688 #check default stripe
20689 stripe_count=$($LFS getdirstripe -D -c $dir)
20690 [ $stripe_count -eq $default_count ] ||
20691 error "default count $default_count != $stripe_count for $dir"
20693 stripe_index=$($LFS getdirstripe -D -i $dir)
20694 [ $stripe_index -eq $default_index ] ||
20695 error "default index $default_index != $stripe_index for $dir"
20697 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
20701 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20702 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20703 skip "Need MDS version at least 2.7.55"
20710 mkdir $DIR/$tdir/normal_dir
20712 #Checking when client cache stripe index
20713 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20714 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
20715 error "create striped_dir failed"
20717 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
20718 error "create dir0 fails"
20719 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
20720 [ $stripe_index -eq 0 ] ||
20721 error "dir0 expect index 0 got $stripe_index"
20723 mkdir $DIR/$tdir/striped_dir/dir1 ||
20724 error "create dir1 fails"
20725 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
20726 [ $stripe_index -eq 1 ] ||
20727 error "dir1 expect index 1 got $stripe_index"
20729 #check default stripe count/stripe index
20730 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
20731 test_300_check_default_striped_dir normal_dir 1 0
20732 test_300_check_default_striped_dir normal_dir 2 1
20733 test_300_check_default_striped_dir normal_dir 2 -1
20735 #delete default stripe information
20736 echo "delete default stripeEA"
20737 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
20738 error "set default stripe on striped dir error"
20740 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
20741 for dir in $(find $DIR/$tdir/normal_dir/*); do
20742 stripe_count=$($LFS getdirstripe -c $dir)
20743 [ $stripe_count -eq 0 ] ||
20744 error "expect 1 get $stripe_count for $dir"
20745 stripe_index=$($LFS getdirstripe -i $dir)
20746 [ $stripe_index -eq 0 ] ||
20747 error "expect 0 get $stripe_index for $dir"
20750 run_test 300g "check default striped directory for normal directory"
20753 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20754 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20755 skip "Need MDS version at least 2.7.55"
20761 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20762 error "set striped dir error"
20764 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
20765 test_300_check_default_striped_dir striped_dir 1 0
20766 test_300_check_default_striped_dir striped_dir 2 1
20767 test_300_check_default_striped_dir striped_dir 2 -1
20769 #delete default stripe information
20770 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
20771 error "set default stripe on striped dir error"
20773 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
20774 for dir in $(find $DIR/$tdir/striped_dir/*); do
20775 stripe_count=$($LFS getdirstripe -c $dir)
20776 [ $stripe_count -eq 0 ] ||
20777 error "expect 1 get $stripe_count for $dir"
20780 run_test 300h "check default striped directory for striped directory"
20783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20784 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20785 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20786 skip "Need MDS version at least 2.7.55"
20793 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20794 error "set striped dir error"
20796 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20797 error "create files under striped dir failed"
20799 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
20800 error "set striped hashdir error"
20802 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
20803 error "create dir0 under hash dir failed"
20804 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
20805 error "create dir1 under hash dir failed"
20807 # unfortunately, we need to umount to clear dir layout cache for now
20808 # once we fully implement dir layout, we can drop this
20809 umount_client $MOUNT || error "umount failed"
20810 mount_client $MOUNT || error "mount failed"
20812 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
20813 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
20814 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
20816 #set the stripe to be unknown hash type
20817 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
20818 $LCTL set_param fail_loc=0x1901
20819 for ((i = 0; i < 10; i++)); do
20820 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
20821 error "stat f-$i failed"
20822 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
20825 touch $DIR/$tdir/striped_dir/f0 &&
20826 error "create under striped dir with unknown hash should fail"
20828 $LCTL set_param fail_loc=0
20830 umount_client $MOUNT || error "umount failed"
20831 mount_client $MOUNT || error "mount failed"
20835 run_test 300i "client handle unknown hash type striped directory"
20838 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20840 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20841 skip "Need MDS version at least 2.7.55"
20848 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
20849 $LCTL set_param fail_loc=0x1702
20850 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
20851 error "set striped dir error"
20853 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
20854 error "create files under striped dir failed"
20856 $LCTL set_param fail_loc=0
20858 rm -rf $DIR/$tdir || error "unlink striped dir fails"
20862 run_test 300j "test large update record"
20865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20866 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20867 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20868 skip "Need MDS version at least 2.7.55"
20870 # this test needs a huge transaction
20872 kb=$(do_facet $SINGLEMDS "$LCTL get_param -n \
20873 osd*.$FSNAME-MDT0000.kbytestotal")
20874 [ $kb -lt $((1024*1024)) ] && skip "MDT0 too small: $kb"
20881 #define OBD_FAIL_LARGE_STRIPE 0x1703
20882 $LCTL set_param fail_loc=0x1703
20883 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
20884 error "set striped dir error"
20885 $LCTL set_param fail_loc=0
20887 $LFS getdirstripe $DIR/$tdir/striped_dir ||
20888 error "getstripeddir fails"
20889 rm -rf $DIR/$tdir/striped_dir ||
20890 error "unlink striped dir fails"
20894 run_test 300k "test large striped directory"
20897 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20898 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20899 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20900 skip "Need MDS version at least 2.7.55"
20904 test_mkdir -p $DIR/$tdir/striped_dir
20905 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
20906 error "chown $RUNAS_ID failed"
20907 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
20908 error "set default striped dir failed"
20910 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
20911 $LCTL set_param fail_loc=0x80000158
20912 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
20914 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
20915 [ $stripe_index -eq 1 ] ||
20916 error "expect 1 get $stripe_index for $dir"
20918 run_test 300l "non-root user to create dir under striped dir with stale layout"
20921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20922 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
20923 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20924 skip "Need MDS version at least 2.7.55"
20926 mkdir -p $DIR/$tdir/striped_dir
20927 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
20928 error "set default stripes dir error"
20930 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
20932 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
20933 [ $stripe_count -eq 0 ] ||
20934 error "expect 0 get $stripe_count for a"
20936 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
20937 error "set default stripes dir error"
20939 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
20941 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
20942 [ $stripe_count -eq 0 ] ||
20943 error "expect 0 get $stripe_count for b"
20945 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
20946 error "set default stripes dir error"
20948 mkdir $DIR/$tdir/striped_dir/c &&
20949 error "default stripe_index is invalid, mkdir c should fails"
20951 rm -rf $DIR/$tdir || error "rmdir fails"
20953 run_test 300m "setstriped directory on single MDT FS"
20956 local list=$(comma_list $(mdts_nodes))
20959 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20964 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20965 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
20966 skip "Need MDS version at least 2.7.55"
20967 remote_mds_nodsh && skip "remote MDS with nodsh"
20970 local list=$(comma_list $(mdts_nodes))
20972 trap cleanup_300n RETURN EXIT
20973 mkdir -p $DIR/$tdir
20974 chmod 777 $DIR/$tdir
20975 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
20976 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20977 error "create striped dir succeeds with gid=0"
20979 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20980 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
20981 error "create striped dir fails with gid=-1"
20983 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20984 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
20985 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
20986 error "set default striped dir succeeds with gid=0"
20989 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
20990 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
20991 error "set default striped dir fails with gid=-1"
20994 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
20995 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
20996 error "create test_dir fails"
20997 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
20998 error "create test_dir1 fails"
20999 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
21000 error "create test_dir2 fails"
21003 run_test 300n "non-root user to create dir under striped dir with default EA"
21006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21007 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21008 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
21009 skip "Need MDS version at least 2.7.55"
21014 mkdir -p $DIR/$tdir
21016 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
21017 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
21018 if [ $numfree1 -lt 66000 ] || [ $numfree2 -lt 66000 ]; then
21019 skip "not enough free inodes $numfree1 $numfree2"
21022 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
21023 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
21024 if [ $numfree1 -lt 300000 ] || [ $numfree2 -lt 300000 ]; then
21025 skip "not enough free space $numfree1 $numfree2"
21028 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
21029 error "setdirstripe fails"
21031 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
21032 error "create dirs fails"
21034 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
21035 ls $DIR/$tdir/striped_dir > /dev/null ||
21036 error "ls striped dir fails"
21037 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
21038 error "unlink big striped dir fails"
21040 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
21043 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21044 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21045 remote_mds_nodsh && skip "remote MDS with nodsh"
21047 mkdir -p $DIR/$tdir
21049 #define OBD_FAIL_OUT_ENOSPC 0x1704
21050 do_facet mds2 lctl set_param fail_loc=0x80001704
21051 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
21052 && error "create striped directory should fail"
21054 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
21056 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
21059 run_test 300p "create striped directory without space"
21062 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21063 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21065 local fd=$(free_fd)
21066 local cmd="exec $fd<$tdir"
21068 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
21071 trap "eval $cmd" EXIT
21072 cd $tdir || error "cd $tdir fails"
21073 rmdir ../$tdir || error "rmdir $tdir fails"
21074 mkdir local_dir && error "create dir succeeds"
21075 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
21079 run_test 300q "create remote directory under orphan directory"
21082 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
21083 skip "Need MDS version at least 2.7.55" && return
21084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
21088 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
21089 error "set striped dir error"
21091 $LFS getdirstripe $DIR/$tdir/striped_dir ||
21092 error "getstripeddir fails"
21095 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
21096 awk '/lmv_stripe_count:/ { print $2 }')
21098 [ $MDSCOUNT -ne $stripe_count ] &&
21099 error "wrong stripe count $stripe_count expected $MDSCOUNT"
21101 rm -rf $DIR/$tdir/striped_dir ||
21102 error "unlink striped dir fails"
21104 run_test 300r "test -1 striped directory"
21106 prepare_remote_file() {
21107 mkdir $DIR/$tdir/src_dir ||
21108 error "create remote source failed"
21110 cp /etc/hosts $DIR/$tdir/src_dir/a ||
21111 error "cp to remote source failed"
21112 touch $DIR/$tdir/src_dir/a
21114 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
21115 error "create remote target dir failed"
21117 touch $DIR/$tdir/tgt_dir/b
21119 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
21120 error "rename dir cross MDT failed!"
21122 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
21123 error "src_child still exists after rename"
21125 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
21126 error "missing file(a) after rename"
21128 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
21129 error "diff after rename"
21133 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
21134 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21136 local remote_file=$DIR/$tdir/tgt_dir/b
21138 mkdir -p $DIR/$tdir
21140 prepare_remote_file || error "prepare remote file failed"
21143 $OPENUNLINK $remote_file $remote_file ||
21144 error "openunlink $remote_file failed"
21145 $CHECKSTAT -a $remote_file || error "$remote_file exists"
21147 run_test 310a "open unlink remote file"
21150 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
21151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21153 local remote_file=$DIR/$tdir/tgt_dir/b
21155 mkdir -p $DIR/$tdir
21157 prepare_remote_file || error "prepare remote file failed"
21159 ln $remote_file $DIR/$tfile || error "link failed for remote file"
21160 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
21161 $CHECKSTAT -t file $remote_file || error "check file failed"
21163 run_test 310b "unlink remote file with multiple links while open"
21166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21167 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
21169 local remote_file=$DIR/$tdir/tgt_dir/b
21171 mkdir -p $DIR/$tdir
21173 prepare_remote_file || error "prepare remote file failed"
21175 ln $remote_file $DIR/$tfile || error "link failed for remote file"
21176 multiop_bg_pause $remote_file O_uc ||
21177 error "mulitop failed for remote file"
21179 $MULTIOP $DIR/$tfile Ouc
21180 kill -USR1 $MULTIPID
21183 run_test 310c "open-unlink remote file with multiple links"
21187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21188 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
21189 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
21190 skip "lustre < 2.8.54 does not contain LU-4825 fix"
21191 remote_mds_nodsh && skip "remote MDS with nodsh"
21193 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
21194 local mdts=$(comma_list $(mdts_nodes))
21196 mkdir -p $DIR/$tdir
21197 $LFS setstripe -i 0 -c 1 $DIR/$tdir
21198 createmany -o $DIR/$tdir/$tfile. 1000
21200 # statfs data is not real time, let's just calculate it
21201 old_iused=$((old_iused + 1000))
21203 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
21204 osp.*OST0000*MDT0000.create_count")
21205 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
21206 osp.*OST0000*MDT0000.max_create_count")
21207 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
21209 $LFS setstripe -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
21210 local index=$($LFS getstripe -i $DIR/$tdir/$tfile)
21211 [ $index -ne 0 ] || error "$tfile stripe index is 0"
21213 unlinkmany $DIR/$tdir/$tfile. 1000
21215 do_nodes $mdts "$LCTL set_param -n \
21216 osp.*OST0000*.max_create_count=$max_count"
21217 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
21218 do_nodes $mdts "$LCTL set_param -n \
21219 osp.*OST0000*.create_count=$count"
21220 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
21221 grep "=0" && error "create_count is zero"
21224 for i in $(seq 120); do
21225 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
21226 # system may be too busy to destroy all objs in time, use
21227 # a somewhat small value to not fail autotest
21228 [ $((old_iused - new_iused)) -gt 400 ] && break
21232 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
21233 [ $((old_iused - new_iused)) -gt 400 ] ||
21234 error "objs not destroyed after unlink"
21236 run_test 311 "disable OSP precreate, and unlink should destroy objs"
21243 local vdevdir=$(dirname $(facet_vdevice $ost))
21244 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
21245 local zfs_zapid=$(do_facet $ost $cmd |
21246 grep -w "/O/0/d$((objid%32))" -C 5 |
21247 awk '/Object/{getline; print $1}')
21248 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
21249 awk "/$objid = /"'{printf $3}')
21254 zfs_object_blksz() {
21258 local vdevdir=$(dirname $(facet_vdevice $ost))
21259 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
21260 local blksz=$(do_facet $ost $cmd $objid |
21261 awk '/dblk/{getline; printf $4}')
21263 case "${blksz: -1}" in
21264 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
21265 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
21272 test_312() { # LU-4856
21273 remote_ost_nodsh && skip "remote OST with nodsh"
21274 [ "$ost1_FSTYPE" = "zfs" ] ||
21275 skip_env "the test only applies to zfs"
21277 local max_blksz=$(do_facet ost1 \
21278 $ZFS get -p recordsize $(facet_device ost1) |
21279 awk '!/VALUE/{print $3}')
21281 # to make life a little bit easier
21282 $LFS mkdir -c 1 -i 0 $DIR/$tdir
21283 $LFS setstripe -c 1 -i 0 $DIR/$tdir
21285 local tf=$DIR/$tdir/$tfile
21287 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21289 # Get ZFS object id
21290 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21291 # block size change by sequential overwrite
21294 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
21295 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
21297 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
21298 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
21302 # block size change by sequential append write
21303 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
21304 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21305 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21308 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
21309 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
21310 oflag=sync conv=notrunc
21312 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21313 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
21314 error "blksz error, actual $blksz, " \
21315 "expected: 2 * $count * $PAGE_SIZE"
21321 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
21322 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
21324 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
21325 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21326 [ $blksz -eq $PAGE_SIZE ] ||
21327 error "blksz error: $blksz, expected: $PAGE_SIZE"
21329 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
21330 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21331 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
21333 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
21334 blksz=$(zfs_object_blksz ost1 $zfs_objid)
21335 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
21337 run_test 312 "make sure ZFS adjusts its block size by write pattern"
21340 remote_ost_nodsh && skip "remote OST with nodsh"
21342 local file=$DIR/$tfile
21345 $LFS setstripe -c 1 -i 0 $file || error "setstripe failed"
21347 # define OBD_FAIL_TGT_RCVD_EIO 0x720
21348 do_facet ost1 "$LCTL set_param fail_loc=0x720"
21349 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
21350 error "write should failed"
21351 do_facet ost1 "$LCTL set_param fail_loc=0"
21354 run_test 313 "io should fail after last_rcvd update fail"
21357 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
21359 $LFS setstripe -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
21360 do_facet ost1 "$LCTL set_param fail_loc=0x720"
21362 wait_delete_completed
21363 do_facet ost1 "$LCTL set_param fail_loc=0"
21365 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
21367 test_315() { # LU-618
21368 [ -f /proc/$$/io ] || skip_env "no IO accounting in kernel"
21370 local file=$DIR/$tfile
21373 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
21374 error "multiop file write failed"
21375 $MULTIOP $file oO_RDONLY:r4063232_c &
21380 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
21383 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
21386 run_test 315 "read should be accounted"
21389 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
21390 large_xattr_enabled || skip_env "ea_inode feature disabled"
21392 rm -rf $DIR/$tdir/d
21393 mkdir -p $DIR/$tdir/d
21394 chown nobody $DIR/$tdir/d
21395 touch $DIR/$tdir/d/file
21397 $LFS mv -m1 $DIR/$tdir/d || error "lfs mv failed"
21399 run_test 316 "lfs mv"
21402 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
21403 skip "Need MDS version at least 2.11.53"
21404 if [ "$ost1_FSTYPE" == "zfs" ]; then
21405 skip "LU-10370: no implementation for ZFS"
21409 local grant_blk_size
21411 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
21412 awk '/grant_block_size:/ { print $2; exit; }')
21414 # Create File of size 5M. Truncate it to below size's and verify
21417 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
21418 error "Create file $DIR/$tfile failed"
21419 stack_trap "rm -f $DIR/$tfile" EXIT
21421 for trunc_sz in 2097152 4097 4000 509 0; do
21422 $TRUNCATE $DIR/$tfile $trunc_sz ||
21423 error "truncate $tfile to $trunc_sz failed"
21424 local sz=$(stat --format=%s $DIR/$tfile)
21425 local blk=$(stat --format=%b $DIR/$tfile)
21426 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
21427 grant_blk_size) * 8))
21429 if [[ $blk -ne $trunc_blk ]]; then
21430 $(which stat) $DIR/$tfile
21431 error "Expected Block $trunc_blk got $blk for $tfile"
21434 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
21435 error "Expected Size $trunc_sz got $sz for $tfile"
21440 # Create file with a hole and write actual two blocks. Block count
21443 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
21444 conv=fsync || error "Create file : $DIR/$tfile"
21446 # Calculate the final truncate size.
21447 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
21450 # truncate to size $trunc_sz bytes. Strip the last block
21451 # The block count must drop to 8
21453 $TRUNCATE $DIR/$tfile $trunc_sz ||
21454 error "truncate $tfile to $trunc_sz failed"
21456 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
21457 sz=$(stat --format=%s $DIR/$tfile)
21458 blk=$(stat --format=%b $DIR/$tfile)
21460 if [[ $blk -ne $trunc_bsz ]]; then
21461 $(which stat) $DIR/$tfile
21462 error "Expected Block $trunc_bsz got $blk for $tfile"
21465 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
21466 error "Expected Size $trunc_sz got $sz for $tfile"
21468 run_test 317 "Verify blocks get correctly update after truncate"
21471 local old_max_active=$($LCTL get_param -n \
21472 llite.*.max_read_ahead_async_active 2>/dev/null)
21474 $LCTL set_param llite.*.max_read_ahead_async_active=256
21475 local max_active=$($LCTL get_param -n \
21476 llite.*.max_read_ahead_async_active 2>/dev/null)
21477 [ $max_active -ne 256 ] && error "expected 256 but got $max_active"
21479 $LCTL set_param llite.*.max_read_ahead_async_active=0 ||
21480 error "set max_read_ahead_async_active should succeed"
21482 $LCTL set_param llite.*.max_read_ahead_async_active=512
21483 max_active=$($LCTL get_param -n \
21484 llite.*.max_read_ahead_async_active 2>/dev/null)
21485 [ $max_active -eq 512 ] || error "expected 512 but got $max_active"
21487 # restore @max_active
21488 [ $old_max_active -ne 0 ] && $LCTL set_param \
21489 llite.*.max_read_ahead_async_active=$old_max_active
21491 local old_threshold=$($LCTL get_param -n \
21492 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
21493 local max_per_file_mb=$($LCTL get_param -n \
21494 llite.*.max_read_ahead_per_file_mb 2>/dev/null)
21496 local invalid=$(($max_per_file_mb + 1))
21498 llite.*.read_ahead_async_file_threshold_mb=$invalid\
21499 && error "set $invalid should fail"
21501 local valid=$(($invalid - 1))
21503 llite.*.read_ahead_async_file_threshold_mb=$valid ||
21504 error "set $valid should succeed"
21505 local threshold=$($LCTL get_param -n \
21506 llite.*.read_ahead_async_file_threshold_mb 2>/dev/null)
21507 [ $threshold -eq $valid ] || error \
21508 "expect threshold $valid got $threshold"
21510 llite.*.read_ahead_async_file_threshold_mb=$old_threshold
21512 run_test 318 "Verify async readahead tunables"
21515 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
21517 local before=$(date +%s)
21519 local mdir=$DIR/$tdir
21520 local file=$mdir/xxx
21522 $LFS mkdir -i0 $mdir || error "mkdir $mdir fails"
21525 #define OBD_FAIL_LDLM_LOCAL_CANCEL_PAUSE 0x32c
21526 $LCTL set_param fail_val=5 fail_loc=0x8000032c
21527 $LFS mv -m1 $file &
21530 dd if=$file of=/dev/null
21532 evict=$($LCTL get_param mdc.$FSNAME-MDT*.state |
21533 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
21535 [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened"
21537 run_test 319 "lost lease lock on migrate error"
21539 test_398a() { # LU-4198
21540 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21541 $LCTL set_param ldlm.namespaces.*.lru_size=clear
21543 # request a new lock on client
21544 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21546 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
21547 local lock_count=$($LCTL get_param -n \
21548 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
21549 [[ $lock_count -eq 0 ]] || error "lock should be cancelled by direct IO"
21551 $LCTL set_param ldlm.namespaces.*-OST0000-osc-ffff*.lru_size=clear
21553 # no lock cached, should use lockless IO and not enqueue new lock
21554 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=direct conv=notrunc
21555 lock_count=$($LCTL get_param -n \
21556 ldlm.namespaces.*-OST0000-osc-ffff*.lru_size)
21557 [[ $lock_count -eq 0 ]] || error "no lock should be held by direct IO"
21559 run_test 398a "direct IO should cancel lock otherwise lockless"
21561 test_398b() { # LU-4198
21562 which fio || skip_env "no fio installed"
21563 $LFS setstripe -c -1 $DIR/$tfile
21566 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size
21569 echo "mix direct rw ${size}M to OST0 by fio with $njobs jobs..."
21570 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
21571 --numjobs=$njobs --fallocate=none \
21572 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21573 --filename=$DIR/$tfile &
21576 echo "mix buffer rw ${size}M to OST0 by fio with $njobs jobs..."
21577 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE \
21578 --numjobs=$njobs --fallocate=none \
21579 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21580 --filename=$DIR/$tfile || true
21585 run_test 398b "DIO and buffer IO race"
21587 test_398c() { # LU-4198
21588 which fio || skip_env "no fio installed"
21590 saved_debug=$($LCTL get_param -n debug)
21591 $LCTL set_param debug=0
21593 local size=$(lctl get_param -n osc.$FSNAME-OST0000*.kbytesavail | head -1)
21594 ((size /= 1024)) # by megabytes
21595 ((size /= 2)) # write half of the OST at most
21596 [ $size -gt 40 ] && size=40 #reduce test time anyway
21598 $LFS setstripe -c 1 $DIR/$tfile
21600 # it seems like ldiskfs reserves more space than necessary if the
21601 # writing blocks are not mapped, so it extends the file firstly
21602 dd if=/dev/zero of=$DIR/$tfile bs=1M count=$size && sync
21603 cancel_lru_locks osc
21605 # clear and verify rpc_stats later
21606 $LCTL set_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats=clear
21609 echo "writing ${size}M to OST0 by fio with $njobs jobs..."
21610 fio --name=rand-write --rw=randwrite --bs=$PAGE_SIZE --direct=1 \
21611 --numjobs=$njobs --fallocate=none --ioengine=libaio \
21612 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21613 --filename=$DIR/$tfile
21614 [ $? -eq 0 ] || error "fio write error"
21616 [ $($LCTL get_param -n \
21617 ldlm.namespaces.${FSNAME}-OST0000-osc-ffff*.lock_count) -eq 0 ] ||
21618 error "Locks were requested while doing AIO"
21620 # get the percentage of 1-page I/O
21621 pct=$($LCTL get_param osc.${FSNAME}-OST0000-osc-ffff*.rpc_stats |
21622 grep -A 1 'pages per rpc' | grep -v 'pages per rpc' |
21624 [ $pct -le 50 ] || error "$pct% of I/O are 1-page"
21626 echo "mix rw ${size}M to OST0 by fio with $njobs jobs..."
21627 fio --name=rand-rw --rw=randrw --bs=$PAGE_SIZE --direct=1 \
21628 --numjobs=$njobs --fallocate=none --ioengine=libaio \
21629 --iodepth=16 --allow_file_create=0 --size=$((size/njobs))M \
21630 --filename=$DIR/$tfile
21631 [ $? -eq 0 ] || error "fio mixed read write error"
21634 $LCTL set_param debug="$saved_debug"
21636 run_test 398c "run fio to test AIO"
21639 local read_write=$1
21640 if [ "$read_write" = "write" ]; then
21641 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
21642 elif [ "$read_write" = "read" ]; then
21643 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
21645 error "argument error"
21648 # turn off debug for performance testing
21649 local saved_debug=$($LCTL get_param -n debug)
21650 $LCTL set_param debug=0
21652 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21654 # get ost1 size - $FSNAME-OST0000
21655 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
21656 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
21657 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
21659 if [ "$read_write" = "read" ]; then
21660 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
21663 local start_time=$(date +%s.%N)
21664 $dd_cmd bs=1M count=$blocks oflag=sync ||
21665 error "real dd $read_write error"
21666 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
21668 if [ "$read_write" = "write" ]; then
21672 # define OBD_FAIL_OST_FAKE_RW 0x238
21673 do_facet ost1 $LCTL set_param fail_loc=0x238
21675 local start_time=$(date +%s.%N)
21676 $dd_cmd bs=1M count=$blocks oflag=sync ||
21677 error "fake dd $read_write error"
21678 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
21680 if [ "$read_write" = "write" ]; then
21682 cancel_lru_locks osc
21683 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
21684 error "$tfile size not $blocks MB"
21686 do_facet ost1 $LCTL set_param fail_loc=0
21688 echo "fake $read_write $duration_fake vs. normal $read_write" \
21689 "$duration in seconds"
21690 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
21691 error_not_in_vm "fake write is slower"
21693 $LCTL set_param -n debug="$saved_debug"
21696 test_399a() { # LU-7655 for OST fake write
21697 remote_ost_nodsh && skip "remote OST with nodsh"
21701 run_test 399a "fake write should not be slower than normal write"
21703 test_399b() { # LU-8726 for OST fake read
21704 remote_ost_nodsh && skip "remote OST with nodsh"
21705 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
21706 skip_env "ldiskfs only test"
21711 run_test 399b "fake read should not be slower than normal read"
21713 test_400a() { # LU-1606, was conf-sanity test_74
21714 if ! which $CC > /dev/null 2>&1; then
21715 skip_env "$CC is not installed"
21718 local extra_flags=''
21719 local out=$TMP/$tfile
21720 local prefix=/usr/include/lustre
21723 # Oleg removes c files in his test rig so test if any c files exist
21724 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
21725 skip_env "Needed c test files are missing"
21727 if ! [[ -d $prefix ]]; then
21728 # Assume we're running in tree and fixup the include path.
21729 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
21730 extra_flags+=" -L$LUSTRE/utils/.lib"
21733 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
21734 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
21735 error "client api broken"
21739 run_test 400a "Lustre client api program can compile and link"
21741 test_400b() { # LU-1606, LU-5011
21743 local out=$TMP/$tfile
21744 local prefix=/usr/include/linux/lustre
21746 # We use a hard coded prefix so that this test will not fail
21747 # when run in tree. There are headers in lustre/include/lustre/
21748 # that are not packaged (like lustre_idl.h) and have more
21749 # complicated include dependencies (like config.h and lnet/types.h).
21750 # Since this test about correct packaging we just skip them when
21751 # they don't exist (see below) rather than try to fixup cppflags.
21753 if ! which $CC > /dev/null 2>&1; then
21754 skip_env "$CC is not installed"
21757 for header in $prefix/*.h; do
21758 if ! [[ -f "$header" ]]; then
21762 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
21763 continue # lustre_ioctl.h is internal header
21766 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
21767 error "cannot compile '$header'"
21771 run_test 400b "packaged headers can be compiled"
21773 test_401a() { #LU-7437
21774 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
21775 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
21777 #count the number of parameters by "list_param -R"
21778 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
21779 #count the number of parameters by listing proc files
21780 local proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
21781 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
21782 echo "proc_dirs='$proc_dirs'"
21783 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
21784 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
21787 [ $params -eq $procs ] ||
21788 error "found $params parameters vs. $procs proc files"
21790 # test the list_param -D option only returns directories
21791 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
21792 #count the number of parameters by listing proc directories
21793 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
21796 [ $params -eq $procs ] ||
21797 error "found $params parameters vs. $procs proc files"
21799 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
21802 local save=$($LCTL get_param -n jobid_var)
21805 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
21806 error "no error returned when setting bad parameters"
21808 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
21809 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
21811 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
21812 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
21813 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
21815 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
21818 local jobid_var_old=$($LCTL get_param -n jobid_var)
21819 local jobid_var_new
21821 $LCTL set_param jobid_var= &&
21822 error "no error returned for 'set_param a='"
21824 jobid_var_new=$($LCTL get_param -n jobid_var)
21825 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
21826 error "jobid_var was changed by setting without value"
21828 $LCTL set_param jobid_var &&
21829 error "no error returned for 'set_param a'"
21831 jobid_var_new=$($LCTL get_param -n jobid_var)
21832 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
21833 error "jobid_var was changed by setting without value"
21835 run_test 401c "Verify 'lctl set_param' without value fails in either format."
21838 local jobid_var_old=$($LCTL get_param -n jobid_var)
21839 local jobid_var_new
21840 local new_value="foo=bar"
21842 $LCTL set_param jobid_var=$new_value ||
21843 error "'set_param a=b' did not accept a value containing '='"
21845 jobid_var_new=$($LCTL get_param -n jobid_var)
21846 [[ "$jobid_var_new" == "$new_value" ]] ||
21847 error "'set_param a=b' failed on a value containing '='"
21849 # Reset the jobid_var to test the other format
21850 $LCTL set_param jobid_var=$jobid_var_old
21851 jobid_var_new=$($LCTL get_param -n jobid_var)
21852 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21853 error "failed to reset jobid_var"
21855 $LCTL set_param jobid_var $new_value ||
21856 error "'set_param a b' did not accept a value containing '='"
21858 jobid_var_new=$($LCTL get_param -n jobid_var)
21859 [[ "$jobid_var_new" == "$new_value" ]] ||
21860 error "'set_param a b' failed on a value containing '='"
21862 $LCTL set_param jobid_var $jobid_var_old
21863 jobid_var_new=$($LCTL get_param -n jobid_var)
21864 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
21865 error "failed to reset jobid_var"
21867 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
21870 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
21871 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
21872 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
21873 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
21874 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
21875 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
21876 remote_mds_nodsh && skip "remote MDS with nodsh"
21878 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
21879 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
21880 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
21881 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
21882 echo "Touch failed - OK"
21884 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
21887 local file1=$DIR/$tfile.1
21888 local file2=$DIR/$tfile.2
21889 local tfile=$TMP/$tfile
21891 rm -f $file1 $file2 $tfile
21896 # 30 sec OBD_TIMEOUT in ll_getattr()
21897 # right before populating st_nlink
21898 $LCTL set_param fail_loc=0x80001409
21899 stat -c %h $file1 > $tfile &
21901 # create an alias, drop all locks and reclaim the dentry
21903 cancel_lru_locks mdc
21904 cancel_lru_locks osc
21905 sysctl -w vm.drop_caches=2
21909 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
21911 rm -f $tfile $file1 $file2
21913 run_test 403 "i_nlink should not drop to zero due to aliasing"
21915 test_404() { # LU-6601
21916 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
21917 skip "Need server version newer than 2.8.52"
21918 remote_mds_nodsh && skip "remote MDS with nodsh"
21920 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
21921 awk '/osp .*-osc-MDT/ { print $4}')
21924 for osp in $mosps; do
21925 echo "Deactivate: " $osp
21926 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
21927 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21928 awk -vp=$osp '$4 == p { print $2 }')
21929 [ $stat = IN ] || {
21930 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21931 error "deactivate error"
21933 echo "Activate: " $osp
21934 do_facet $SINGLEMDS $LCTL --device %$osp activate
21935 local stat=$(do_facet $SINGLEMDS $LCTL dl |
21936 awk -vp=$osp '$4 == p { print $2 }')
21937 [ $stat = UP ] || {
21938 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
21939 error "activate error"
21943 run_test 404 "validate manual {de}activated works properly for OSPs"
21946 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
21947 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
21948 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
21949 skip "Layout swap lock is not supported"
21951 check_swap_layouts_support
21953 test_mkdir $DIR/$tdir
21954 swap_lock_test -d $DIR/$tdir ||
21955 error "One layout swap locked test failed"
21957 run_test 405 "Various layout swap lock tests"
21960 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
21961 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
21962 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
21963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21964 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
21965 skip "Need MDS version at least 2.8.50"
21967 local def_stripe_size=$($LFS getstripe -S $MOUNT)
21968 local test_pool=$TESTNAME
21970 pool_add $test_pool || error "pool_add failed"
21971 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
21972 error "pool_add_targets failed"
21974 save_layout_restore_at_exit $MOUNT
21976 # parent set default stripe count only, child will stripe from both
21977 # parent and fs default
21978 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
21979 error "setstripe $MOUNT failed"
21980 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
21981 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
21982 for i in $(seq 10); do
21983 local f=$DIR/$tdir/$tfile.$i
21984 touch $f || error "touch failed"
21985 local count=$($LFS getstripe -c $f)
21986 [ $count -eq $OSTCOUNT ] ||
21987 error "$f stripe count $count != $OSTCOUNT"
21988 local offset=$($LFS getstripe -i $f)
21989 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
21990 local size=$($LFS getstripe -S $f)
21991 [ $size -eq $((def_stripe_size * 2)) ] ||
21992 error "$f stripe size $size != $((def_stripe_size * 2))"
21993 local pool=$($LFS getstripe -p $f)
21994 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
21997 # change fs default striping, delete parent default striping, now child
21998 # will stripe from new fs default striping only
21999 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
22000 error "change $MOUNT default stripe failed"
22001 $LFS setstripe -c 0 $DIR/$tdir ||
22002 error "delete $tdir default stripe failed"
22003 for i in $(seq 11 20); do
22004 local f=$DIR/$tdir/$tfile.$i
22005 touch $f || error "touch $f failed"
22006 local count=$($LFS getstripe -c $f)
22007 [ $count -eq 1 ] || error "$f stripe count $count != 1"
22008 local offset=$($LFS getstripe -i $f)
22009 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
22010 local size=$($LFS getstripe -S $f)
22011 [ $size -eq $def_stripe_size ] ||
22012 error "$f stripe size $size != $def_stripe_size"
22013 local pool=$($LFS getstripe -p $f)
22014 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
22017 unlinkmany $DIR/$tdir/$tfile. 1 20
22019 local f=$DIR/$tdir/$tfile
22020 pool_remove_all_targets $test_pool $f
22021 pool_remove $test_pool $f
22023 run_test 406 "DNE support fs default striping"
22026 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22027 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
22028 skip "Need MDS version at least 2.8.55"
22029 remote_mds_nodsh && skip "remote MDS with nodsh"
22031 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
22032 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
22033 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
22034 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
22035 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
22037 #define OBD_FAIL_DT_TXN_STOP 0x2019
22038 for idx in $(seq $MDSCOUNT); do
22039 do_facet mds$idx "lctl set_param fail_loc=0x2019"
22041 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
22042 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
22043 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
22046 run_test 407 "transaction fail should cause operation fail"
22049 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
22051 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
22052 lctl set_param fail_loc=0x8000040a
22053 # let ll_prepare_partial_page() fail
22054 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
22058 # create at least 100 unused inodes so that
22059 # shrink_icache_memory(0) should not return 0
22060 touch $DIR/$tfile-{0..100}
22061 rm -f $DIR/$tfile-{0..100}
22064 echo 2 > /proc/sys/vm/drop_caches
22066 run_test 408 "drop_caches should not hang due to page leaks"
22070 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22072 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
22073 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
22074 touch $DIR/$tdir/guard || error "(2) Fail to create"
22076 local PREFIX=$(str_repeat 'A' 128)
22077 echo "Create 1K hard links start at $(date)"
22078 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
22079 error "(3) Fail to hard link"
22081 echo "Links count should be right although linkEA overflow"
22082 stat $DIR/$tdir/guard || error "(4) Fail to stat"
22083 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
22084 [ $linkcount -eq 1001 ] ||
22085 error "(5) Unexpected hard links count: $linkcount"
22087 echo "List all links start at $(date)"
22088 ls -l $DIR/$tdir/foo > /dev/null ||
22089 error "(6) Fail to list $DIR/$tdir/foo"
22091 echo "Unlink hard links start at $(date)"
22092 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
22093 error "(7) Fail to unlink"
22094 echo "Unlink hard links finished at $(date)"
22096 run_test 409 "Large amount of cross-MDTs hard links on the same file"
22100 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
22101 skip "Need client version at least 2.9.59"
22103 # Create a file, and stat it from the kernel
22104 local testfile=$DIR/$tfile
22107 local run_id=$RANDOM
22108 local my_ino=$(stat --format "%i" $testfile)
22110 # Try to insert the module. This will always fail as the
22111 # module is designed to not be inserted.
22112 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
22115 # Anything but success is a test failure
22117 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
22118 error "no inode match"
22120 run_test 410 "Test inode number returned from kernel thread"
22122 cleanup_test411_cgroup() {
22128 local cg_basedir=/sys/fs/cgroup/memory
22130 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
22131 skip "no setup for cgroup"
22133 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
22134 error "test file creation failed"
22135 cancel_lru_locks osc
22137 # Create a very small memory cgroup to force a slab allocation error
22138 local cgdir=$cg_basedir/osc_slab_alloc
22139 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
22140 trap "cleanup_test411_cgroup $cgdir" EXIT
22141 echo 2M > $cgdir/memory.kmem.limit_in_bytes
22142 echo 1M > $cgdir/memory.limit_in_bytes
22144 # Should not LBUG, just be killed by oom-killer
22145 # dd will return 0 even allocation failure in some environment.
22146 # So don't check return value
22147 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
22148 cleanup_test411_cgroup $cgdir
22152 run_test 411 "Slab allocation error with cgroup does not LBUG"
22155 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
22156 if [ $MDS1_VERSION -lt $(version_code 2.10.55) ]; then
22157 skip "Need server version at least 2.10.55"
22160 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
22161 error "mkdir failed"
22162 $LFS getdirstripe $DIR/$tdir
22163 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
22164 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
22165 error "expect $((MDSCOUT - 1)) get $stripe_index"
22166 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
22167 [ $stripe_count -eq 2 ] ||
22168 error "expect 2 get $stripe_count"
22170 run_test 412 "mkdir on specific MDTs"
22174 local stripe_count=$2
22175 local mdts=$(comma_list $(mdts_nodes))
22178 local lmv_qos_prio_free
22179 local lmv_qos_threshold_rr
22180 local lmv_qos_maxage
22181 local lod_qos_prio_free
22182 local lod_qos_threshold_rr
22183 local lod_qos_maxage
22187 lmv_qos_prio_free=$($LCTL get_param -n lmv.*.qos_prio_free | head -n1)
22188 lmv_qos_prio_free=${lmv_qos_prio_free%%%}
22189 lmv_qos_threshold_rr=$($LCTL get_param -n lmv.*.qos_threshold_rr |
22191 lmv_qos_threshold_rr=${lmv_qos_threshold_rr%%%}
22192 lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
22193 stack_trap "$LCTL set_param \
22194 lmv.*.qos_prio_free=$lmv_qos_prio_free > /dev/null" EXIT
22195 stack_trap "$LCTL set_param \
22196 lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null" EXIT
22197 stack_trap "$LCTL set_param \
22198 lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null" EXIT
22200 lod_qos_prio_free=$(do_facet mds1 $LCTL get_param -n \
22201 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_prio_free | head -n1)
22202 lod_qos_prio_free=${lod_qos_prio_free%%%}
22203 lod_qos_threshold_rr=$(do_facet mds1 $LCTL get_param -n \
22204 lod.$FSNAME-MDT0000-mdtlov.mdt_qos_threshold_rr | head -n1)
22205 lod_qos_threshold_rr=${lod_qos_threshold_rr%%%}
22206 lod_qos_maxage=$(do_facet mds1 $LCTL get_param -n \
22207 lod.$FSNAME-MDT0000-mdtlov.qos_maxage | awk '{ print $1 }')
22208 stack_trap "do_nodes $mdts $LCTL set_param \
22209 lod.*.mdt_qos_prio_free=$lod_qos_prio_free > /dev/null" EXIT
22210 stack_trap "do_nodes $mdts $LCTL set_param \
22211 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null" \
22213 stack_trap "do_nodes $mdts $LCTL set_param \
22214 lod.*.mdt_qos_maxage=$lod_qos_maxage > /dev/null" EXIT
22217 echo "Mkdir (stripe_count $stripe_count) roundrobin:"
22219 $LCTL set_param lmv.*.qos_threshold_rr=100 > /dev/null
22220 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_threshold_rr=100 > /dev/null
22222 testdir=$DIR/$tdir-s$stripe_count/rr
22224 for i in $(seq $((100 * MDSCOUNT))); do
22225 eval $mkdir_cmd $testdir/subdir$i ||
22226 error "$mkdir_cmd subdir$i failed"
22229 for i in $(seq $MDSCOUNT); do
22230 count=$($LFS getdirstripe -i $testdir/* |
22231 grep ^$((i - 1))$ | wc -l)
22232 echo "$count directories created on MDT$((i - 1))"
22233 [ $count -eq 100 ] || error "subdirs are not evenly distributed"
22235 if [ $stripe_count -gt 1 ]; then
22236 count=$($LFS getdirstripe $testdir/* |
22237 grep -P "^\s+$((i - 1))\t" | wc -l)
22238 echo "$count stripes created on MDT$((i - 1))"
22239 # deviation should < 5% of average
22240 [ $count -lt $((95 * stripe_count)) ] ||
22241 [ $count -gt $((105 * stripe_count)) ] &&
22242 error "stripes are not evenly distributed"
22246 $LCTL set_param lmv.*.qos_threshold_rr=$lmv_qos_threshold_rr > /dev/null
22247 do_nodes $mdts $LCTL set_param \
22248 lod.*.mdt_qos_threshold_rr=$lod_qos_threshold_rr > /dev/null
22251 echo "Check for uneven MDTs: "
22261 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
22262 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
22263 bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
22265 max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
22266 min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
22269 for ((i = 1; i < ${#ffree[@]}; i++)); do
22270 tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
22271 if [ $tmp -gt $max ]; then
22275 if [ $tmp -lt $min ]; then
22281 [ ${ffree[min_index]} -eq 0 ] &&
22282 skip "no free files in MDT$min_index"
22283 [ ${ffree[min_index]} -gt 100000000 ] &&
22284 skip "too much free files in MDT$min_index"
22286 # Check if we need to generate uneven MDTs
22288 local diff=$(((max - min) * 100 / min))
22289 local value="$(generate_string 1024)"
22291 while [ $diff -lt $threshold ]; do
22292 # generate uneven MDTs, create till $threshold% diff
22293 echo -n "weight diff=$diff% must be > $threshold% ..."
22294 count=$((${ffree[min_index]} / 10))
22295 # 50 sec per 10000 files in vm
22296 [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
22297 skip "$count files to create"
22298 echo "Fill MDT$min_index with $count files"
22299 [ -d $DIR/$tdir-MDT$min_index ] ||
22300 $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
22301 error "mkdir $tdir-MDT$min_index failed"
22302 for i in $(seq $count); do
22303 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
22304 $DIR/$tdir-MDT$min_index/f$j_$i > /dev/null ||
22305 error "create f$j_$i failed"
22306 setfattr -n user.413b -v $value \
22307 $DIR/$tdir-MDT$min_index/f$j_$i ||
22308 error "setfattr f$j_$i failed"
22311 ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
22312 bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
22313 max=$(((${ffree[max_index]} >> 8) * \
22314 (${bavail[max_index]} * bsize >> 16)))
22315 min=$(((${ffree[min_index]} >> 8) * \
22316 (${bavail[min_index]} * bsize >> 16)))
22317 diff=$(((max - min) * 100 / min))
22320 echo "MDT filesfree available: ${ffree[@]}"
22321 echo "MDT blocks available: ${bavail[@]}"
22322 echo "weight diff=$diff%"
22325 echo "Mkdir (stripe_count $stripe_count) with balanced space usage:"
22327 $LCTL set_param lmv.*.qos_prio_free=100 > /dev/null
22328 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_prio_free=100 > /dev/null
22329 # decrease statfs age, so that it can be updated in time
22330 $LCTL set_param lmv.*.qos_maxage=1 > /dev/null
22331 do_nodes $mdts $LCTL set_param lod.*.mdt_qos_maxage=1 > /dev/null
22335 testdir=$DIR/$tdir-s$stripe_count/qos
22337 for i in $(seq $((100 * MDSCOUNT))); do
22338 eval $mkdir_cmd $testdir/subdir$i ||
22339 error "$mkdir_cmd subdir$i failed"
22342 for i in $(seq $MDSCOUNT); do
22343 count=$($LFS getdirstripe -i $testdir/* | grep ^$((i - 1))$ |
22345 echo "$count directories created on MDT$((i - 1))"
22347 if [ $stripe_count -gt 1 ]; then
22348 count=$($LFS getdirstripe $testdir/* |
22349 grep -P "^\s+$((i - 1))\t" | wc -l)
22350 echo "$count stripes created on MDT$((i - 1))"
22354 max=$($LFS getdirstripe -i $testdir/* | grep ^$max_index$ | wc -l)
22355 min=$($LFS getdirstripe -i $testdir/* | grep ^$min_index$ | wc -l)
22357 # D-value should > 10% of averge
22358 [ $((max - min)) -lt 10 ] &&
22359 error "subdirs shouldn't be evenly distributed"
22362 if [ $stripe_count -gt 1 ]; then
22363 max=$($LFS getdirstripe $testdir/* |
22364 grep -P "^\s+$max_index\t" | wc -l)
22365 min=$($LFS getdirstripe $testdir/* |
22366 grep -P "^\s+$min_index\t" | wc -l)
22367 [ $((max - min)) -le $((10 * stripe_count)) ] &&
22368 error "stripes shouldn't be evenly distributed"|| true
22373 [ $MDSCOUNT -lt 2 ] &&
22374 skip "We need at least 2 MDTs for this test"
22376 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
22377 skip "Need server version at least 2.12.52"
22381 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
22382 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
22383 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
22384 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
22385 test_qos_mkdir "$LFS mkdir -c $stripe_count" $stripe_count
22388 run_test 413a "QoS mkdir with 'lfs mkdir -i -1'"
22391 [ $MDSCOUNT -lt 2 ] &&
22392 skip "We need at least 2 MDTs for this test"
22394 [ $MDS1_VERSION -lt $(version_code 2.12.52) ] &&
22395 skip "Need server version at least 2.12.52"
22399 for stripe_count in $(seq 1 $((MDSCOUNT - 1))); do
22400 mkdir $DIR/$tdir-s$stripe_count || error "mkdir failed"
22401 mkdir $DIR/$tdir-s$stripe_count/rr || error "mkdir failed"
22402 mkdir $DIR/$tdir-s$stripe_count/qos || error "mkdir failed"
22403 $LFS setdirstripe -D -c $stripe_count \
22404 $DIR/$tdir-s$stripe_count/rr ||
22405 error "setdirstripe failed"
22406 $LFS setdirstripe -D -c $stripe_count \
22407 $DIR/$tdir-s$stripe_count/qos ||
22408 error "setdirstripe failed"
22409 test_qos_mkdir "mkdir" $stripe_count
22412 run_test 413b "QoS mkdir under dir whose default LMV starting MDT offset is -1"
22415 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
22416 $LCTL set_param fail_loc=0x80000521
22417 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
22420 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
22423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22424 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
22425 skip "Need server version at least 2.11.52"
22435 # this test may be slow on ZFS
22436 [ "$mds1_FSTYPE" == "zfs" ] && total=100
22438 # though this test is designed for striped directory, let's test normal
22439 # directory too since lock is always saved as CoS lock.
22440 test_mkdir $DIR/$tdir || error "mkdir $tdir"
22441 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
22450 start_time=$(date +%s)
22451 for i in $(seq $total); do
22452 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
22455 end_time=$(date +%s)
22456 duration=$((end_time - start_time))
22458 kill -9 $setattr_pid
22460 echo "rename $total files took $duration sec"
22461 [ $duration -lt 100 ] || error "rename took $duration sec"
22463 run_test 415 "lock revoke is not missing"
22466 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
22467 skip "Need server version at least 2.11.55"
22469 # define OBD_FAIL_OSD_TXN_START 0x19a
22470 do_facet mds1 lctl set_param fail_loc=0x19a
22472 lfs mkdir -c $MDSCOUNT $DIR/$tdir
22476 run_test 416 "transaction start failure won't cause system hung"
22480 do_nodes $(comma_list $(mdts_nodes)) \
22481 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
22482 do_nodes $(comma_list $(mdts_nodes)) \
22483 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
22484 do_nodes $(comma_list $(mdts_nodes)) \
22485 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
22489 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22490 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
22491 skip "Need MDS version at least 2.11.56"
22493 trap cleanup_417 RETURN EXIT
22495 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
22496 do_nodes $(comma_list $(mdts_nodes)) \
22497 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
22498 $LFS migrate -m 0 $DIR/$tdir.1 &&
22499 error "migrate dir $tdir.1 should fail"
22501 do_nodes $(comma_list $(mdts_nodes)) \
22502 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
22503 $LFS mkdir -i 1 $DIR/$tdir.2 &&
22504 error "create remote dir $tdir.2 should fail"
22506 do_nodes $(comma_list $(mdts_nodes)) \
22507 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
22508 $LFS mkdir -c 2 $DIR/$tdir.3 &&
22509 error "create striped dir $tdir.3 should fail"
22512 run_test 417 "disable remote dir, striped dir and dir migration"
22514 # Checks that the outputs of df [-i] and lfs df [-i] match
22516 # usage: check_lfs_df <blocks | inodes> <mountpoint>
22526 [ "$1" == "blocks" ] && inodes= || inodes="-i"
22528 for count in {1..100}; do
22532 # read the lines of interest
22533 df_out=($(df -P $inodes $dir | tail -n +2)) ||
22534 error "df $inodes $dir | tail -n +2 failed"
22535 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
22536 error "lfs df $inodes $dir | grep summary: failed"
22538 # skip first substrings of each output as they are different
22539 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
22540 # compare the two outputs
22542 for i in {1..5}; do
22543 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
22551 lfs df $inodes $dir
22552 error "df and lfs df $1 output mismatch: " \
22553 "df ${inodes}: ${df_out[*]}, " \
22554 "lfs df ${inodes}: ${lfs_df_out[*]}"
22559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
22561 local dir=$DIR/$tdir
22562 local numfiles=$((RANDOM % 4096 + 2))
22563 local numblocks=$((RANDOM % 256 + 1))
22565 wait_delete_completed
22568 # check block output
22569 check_lfs_df blocks $dir
22570 # check inode output
22571 check_lfs_df inodes $dir
22573 # create a single file and retest
22574 echo "Creating a single file and testing"
22575 createmany -o $dir/$tfile- 1 &>/dev/null ||
22576 error "creating 1 file in $dir failed"
22577 check_lfs_df blocks $dir
22578 check_lfs_df inodes $dir
22580 # create a random number of files
22581 echo "Creating $((numfiles - 1)) files and testing"
22582 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
22583 error "creating $((numfiles - 1)) files in $dir failed"
22585 # write a random number of blocks to the first test file
22586 echo "Writing $numblocks 4K blocks and testing"
22587 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
22588 count=$numblocks &>/dev/null ||
22589 error "dd to $dir/${tfile}-0 failed"
22592 check_lfs_df blocks $dir
22593 check_lfs_df inodes $dir
22595 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
22596 error "unlinking $numfiles files in $dir failed"
22598 run_test 418 "df and lfs df outputs match"
22602 local dir=$DIR/$tdir
22607 cancel_lru_locks mdc
22609 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
22610 $LCTL set_param fail_loc=0x1410
22612 $LCTL set_param fail_loc=0
22615 run_test 419 "Verify open file by name doesn't crash kernel"
22619 [[ $MDS1_VERSION -ge $(version_code 2.12.53) ]] ||
22620 skip "Need MDS version at least 2.12.53"
22622 local SAVE_UMASK=$(umask)
22623 local dir=$DIR/$tdir
22624 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
22628 mkdir -m03777 $dir/testdir
22629 ls -dn $dir/testdir
22630 # Need to remove trailing '.' when SELinux is enabled
22631 local dirperms=$(ls -dn $dir/testdir |
22632 awk '{ sub(/\.$/, "", $1); print $1}')
22633 [ $dirperms == "drwxrwsrwt" ] ||
22634 error "incorrect perms on $dir/testdir"
22636 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
22637 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
22638 ls -n $dir/testdir/testfile
22639 local fileperms=$(ls -n $dir/testdir/testfile |
22640 awk '{ sub(/\.$/, "", $1); print $1}')
22641 [ $fileperms == "-rwxr-xr-x" ] ||
22642 error "incorrect perms on $dir/testdir/testfile"
22646 run_test 420 "clear SGID bit on non-directories for non-members"
22653 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22654 skip "Need MDS version at least 2.12.54"
22656 test_mkdir $DIR/$tdir
22657 createmany -o $DIR/$tdir/f 3
22658 cnt=$(ls -1 $DIR/$tdir | wc -l)
22659 [ $cnt != 3 ] && error "unexpected #files: $cnt"
22661 fid1=$(lfs path2fid $DIR/$tdir/f1)
22662 fid2=$(lfs path2fid $DIR/$tdir/f2)
22663 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
22665 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
22666 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
22668 cnt=$(ls -1 $DIR/$tdir | wc -l)
22669 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
22671 rm -f $DIR/$tdir/f3 || error "can't remove f3"
22672 createmany -o $DIR/$tdir/f 3
22673 cnt=$(ls -1 $DIR/$tdir | wc -l)
22674 [ $cnt != 3 ] && error "unexpected #files: $cnt"
22676 fid1=$(lfs path2fid $DIR/$tdir/f1)
22677 fid2=$(lfs path2fid $DIR/$tdir/f2)
22678 echo "remove using fsname $FSNAME"
22679 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
22681 cnt=$(ls -1 $DIR/$tdir | wc -l)
22682 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
22684 run_test 421a "simple rm by fid"
22691 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22692 skip "Need MDS version at least 2.12.54"
22694 test_mkdir $DIR/$tdir
22695 createmany -o $DIR/$tdir/f 3
22696 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
22699 FID1=$(lfs path2fid $DIR/$tdir/f1)
22700 FID2=$(lfs path2fid $DIR/$tdir/f2)
22701 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
22703 kill -USR1 $MULTIPID
22706 cnt=$(ls $DIR/$tdir | wc -l)
22707 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
22709 run_test 421b "rm by fid on open file"
22715 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22716 skip "Need MDS version at least 2.12.54"
22718 test_mkdir $DIR/$tdir
22719 createmany -o $DIR/$tdir/f 3
22720 touch $DIR/$tdir/$tfile
22721 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
22722 cnt=$(ls -1 $DIR/$tdir | wc -l)
22723 [ $cnt != 184 ] && error "unexpected #files: $cnt"
22725 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
22726 $LFS rmfid $DIR $FID1 || error "rmfid failed"
22728 cnt=$(ls $DIR/$tdir | wc -l)
22729 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
22731 run_test 421c "rm by fid against hardlinked files"
22737 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22738 skip "Need MDS version at least 2.12.54"
22740 test_mkdir $DIR/$tdir
22741 createmany -o $DIR/$tdir/f 4097
22742 cnt=$(ls -1 $DIR/$tdir | wc -l)
22743 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
22745 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
22746 $LFS rmfid $DIR $FIDS || error "rmfid failed"
22748 cnt=$(ls $DIR/$tdir | wc -l)
22750 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22752 run_test 421d "rmfid en masse"
22758 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22759 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22760 skip "Need MDS version at least 2.12.54"
22762 mkdir -p $DIR/$tdir
22763 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22764 createmany -o $DIR/$tdir/striped_dir/f 512
22765 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22766 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22768 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22769 sed "s/[/][^:]*://g")
22770 $LFS rmfid $DIR $FIDS || error "rmfid failed"
22772 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22774 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22776 run_test 421e "rmfid in DNE"
22782 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22783 skip "Need MDS version at least 2.12.54"
22785 test_mkdir $DIR/$tdir
22787 cnt=$(ls -1 $DIR/$tdir | wc -l)
22788 [ $cnt != 1 ] && error "unexpected #files: $cnt"
22790 FID=$(lfs path2fid $DIR/$tdir/f)
22791 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
22792 # rmfid should fail
22793 cnt=$(ls -1 $DIR/$tdir | wc -l)
22794 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
22796 chmod a+rw $DIR/$tdir
22798 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
22799 # rmfid should fail
22800 cnt=$(ls -1 $DIR/$tdir | wc -l)
22801 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
22804 $RUNAS touch $DIR/$tdir/f
22805 FID=$(lfs path2fid $DIR/$tdir/f)
22806 echo "rmfid as root"
22807 $LFS rmfid $DIR $FID || error "rmfid as root failed"
22808 cnt=$(ls -1 $DIR/$tdir | wc -l)
22809 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
22812 $RUNAS touch $DIR/$tdir/f
22813 cnt=$(ls -1 $DIR/$tdir | wc -l)
22814 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
22815 FID=$(lfs path2fid $DIR/$tdir/f)
22816 # rmfid w/o user_fid2path mount option should fail
22817 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
22818 cnt=$(ls -1 $DIR/$tdir | wc -l)
22819 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
22821 umount_client $MOUNT || error "failed to umount client"
22822 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
22823 error "failed to mount client'"
22825 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
22826 # rmfid should succeed
22827 cnt=$(ls -1 $DIR/$tdir | wc -l)
22828 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
22830 # rmfid shouldn't allow to remove files due to dir's permission
22831 chmod a+rwx $DIR/$tdir
22834 FID=$(lfs path2fid $DIR/$tdir/f)
22835 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
22837 umount_client $MOUNT || error "failed to umount client"
22838 mount_client $MOUNT "$MOUNT_OPTS" ||
22839 error "failed to mount client'"
22842 run_test 421f "rmfid checks permissions"
22848 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
22849 [ $MDS1_VERSION -lt $(version_code 2.12.54) ] &&
22850 skip "Need MDS version at least 2.12.54"
22852 mkdir -p $DIR/$tdir
22853 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
22854 createmany -o $DIR/$tdir/striped_dir/f 512
22855 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22856 [ $cnt != 512 ] && error "unexpected #files: $cnt"
22858 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
22859 sed "s/[/][^:]*://g")
22861 rm -f $DIR/$tdir/striped_dir/f1*
22862 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
22863 removed=$((512 - cnt))
22865 # few files have been just removed, so we expect
22866 # rmfid to fail on their fids
22867 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
22868 [ $removed != $errors ] && error "$errors != $removed"
22870 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
22872 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
22874 run_test 421g "rmfid to return errors properly"
22877 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
22878 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
22879 test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
22880 dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
22881 dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
22883 local amc=$(at_max_get client)
22884 local amo=$(at_max_get mds1)
22885 local timeout=`lctl get_param -n timeout`
22887 at_max_set 0 client
22890 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
22891 do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
22892 fail_val=$(((2*timeout + 10)*1000))
22893 touch $DIR/$tdir/d3/file &
22895 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
22896 do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
22897 fail_val=$((2*timeout + 5))
22898 mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
22902 sleep $((2 * timeout))
22906 touch $DIR/$tdir/d2/file3
22907 touch $DIR/$tdir/d2/file4
22908 touch $DIR/$tdir/d2/file5
22911 at_max_set $amc client
22912 at_max_set $amo mds1
22914 # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
22915 do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
22916 error "Watchdog is always throttled"
22918 run_test 422 "kill a process with RPC in progress"
22931 # ensure statfs cache is expired
22934 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
22935 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
22939 run_test 423 "statfs should return a right data"
22942 #define OBD_FAIL_PTLRPC_BULK_REPLY_ATTACH 0x522 | OBD_FAIL_ONCE
22943 $LCTL set_param fail_loc=0x80000522
22944 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
22947 run_test 424 "simulate ENOMEM in ptl_send_rpc bulk reply ME attach"
22950 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
22951 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
22952 skip "Need server version at least 2.9.55"
22954 start_full_debug_logging
22958 stop_full_debug_logging
22962 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22963 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22964 awk '/The barrier for/ { print $7 }')
22967 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
22972 barrier_expired() {
22975 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
22976 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
22977 awk '/will be expired/ { print $7 }')
22979 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
22988 echo "Start barrier_freeze at: $(date)"
22989 #define OBD_FAIL_BARRIER_DELAY 0x2202
22990 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
22991 # Do not reduce barrier time - See LU-11873
22992 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
22995 local b_status=$(barrier_stat)
22996 echo "Got barrier status at: $(date)"
22997 [ "$b_status" = "'freezing_p1'" ] ||
22998 error "(1) unexpected barrier status $b_status"
23000 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
23002 b_status=$(barrier_stat)
23003 [ "$b_status" = "'frozen'" ] ||
23004 error "(2) unexpected barrier status $b_status"
23006 local expired=$(barrier_expired)
23007 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
23008 sleep $((expired + 3))
23010 b_status=$(barrier_stat)
23011 [ "$b_status" = "'expired'" ] ||
23012 error "(3) unexpected barrier status $b_status"
23014 # Do not reduce barrier time - See LU-11873
23015 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
23016 error "(4) fail to freeze barrier"
23018 b_status=$(barrier_stat)
23019 [ "$b_status" = "'frozen'" ] ||
23020 error "(5) unexpected barrier status $b_status"
23022 echo "Start barrier_thaw at: $(date)"
23023 #define OBD_FAIL_BARRIER_DELAY 0x2202
23024 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
23025 do_facet mgs $LCTL barrier_thaw $FSNAME &
23028 b_status=$(barrier_stat)
23029 echo "Got barrier status at: $(date)"
23030 [ "$b_status" = "'thawing'" ] ||
23031 error "(6) unexpected barrier status $b_status"
23033 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
23035 b_status=$(barrier_stat)
23036 [ "$b_status" = "'thawed'" ] ||
23037 error "(7) unexpected barrier status $b_status"
23039 #define OBD_FAIL_BARRIER_FAILURE 0x2203
23040 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
23041 do_facet mgs $LCTL barrier_freeze $FSNAME
23043 b_status=$(barrier_stat)
23044 [ "$b_status" = "'failed'" ] ||
23045 error "(8) unexpected barrier status $b_status"
23047 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
23048 do_facet mgs $LCTL barrier_thaw $FSNAME
23052 run_test 801a "write barrier user interfaces and stat machine"
23057 mkdir $DIR/$tdir || error "(1) fail to mkdir"
23058 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
23059 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
23060 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
23061 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
23063 cancel_lru_locks mdc
23065 # 180 seconds should be long enough
23066 do_facet mgs $LCTL barrier_freeze $FSNAME 180
23068 local b_status=$(barrier_stat)
23069 [ "$b_status" = "'frozen'" ] ||
23070 error "(6) unexpected barrier status $b_status"
23072 mkdir $DIR/$tdir/d0/d10 &
23075 touch $DIR/$tdir/d1/f13 &
23078 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
23081 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
23084 rm -f $DIR/$tdir/d4/f12 &
23087 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
23089 # To guarantee taht the 'stat' is not blocked
23090 b_status=$(barrier_stat)
23091 [ "$b_status" = "'frozen'" ] ||
23092 error "(8) unexpected barrier status $b_status"
23094 # let above commands to run at background
23097 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
23098 ps -p $touch_pid || error "(10) touch should be blocked"
23099 ps -p $ln_pid || error "(11) link should be blocked"
23100 ps -p $mv_pid || error "(12) rename should be blocked"
23101 ps -p $rm_pid || error "(13) unlink should be blocked"
23103 b_status=$(barrier_stat)
23104 [ "$b_status" = "'frozen'" ] ||
23105 error "(14) unexpected barrier status $b_status"
23107 do_facet mgs $LCTL barrier_thaw $FSNAME
23108 b_status=$(barrier_stat)
23109 [ "$b_status" = "'thawed'" ] ||
23110 error "(15) unexpected barrier status $b_status"
23112 wait $mkdir_pid || error "(16) mkdir should succeed"
23113 wait $touch_pid || error "(17) touch should succeed"
23114 wait $ln_pid || error "(18) link should succeed"
23115 wait $mv_pid || error "(19) rename should succeed"
23116 wait $rm_pid || error "(20) unlink should succeed"
23120 run_test 801b "modification will be blocked by write barrier"
23123 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23127 stop mds2 || error "(1) Fail to stop mds2"
23129 do_facet mgs $LCTL barrier_freeze $FSNAME 30
23131 local b_status=$(barrier_stat)
23132 [ "$b_status" = "'expired'" ] || [ "$b_status" = "'failed'" ] || {
23133 do_facet mgs $LCTL barrier_thaw $FSNAME
23134 error "(2) unexpected barrier status $b_status"
23137 do_facet mgs $LCTL barrier_rescan $FSNAME ||
23138 error "(3) Fail to rescan barrier bitmap"
23140 # Do not reduce barrier time - See LU-11873
23141 do_facet mgs $LCTL barrier_freeze $FSNAME 20
23143 b_status=$(barrier_stat)
23144 [ "$b_status" = "'frozen'" ] ||
23145 error "(4) unexpected barrier status $b_status"
23147 do_facet mgs $LCTL barrier_thaw $FSNAME
23148 b_status=$(barrier_stat)
23149 [ "$b_status" = "'thawed'" ] ||
23150 error "(5) unexpected barrier status $b_status"
23152 local devname=$(mdsdevname 2)
23154 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
23156 do_facet mgs $LCTL barrier_rescan $FSNAME ||
23157 error "(7) Fail to rescan barrier bitmap"
23161 run_test 801c "rescan barrier bitmap"
23163 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
23164 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
23165 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
23166 saved_MOUNT_OPTS=$MOUNT_OPTS
23172 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
23173 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
23174 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
23175 MOUNT_OPTS=$saved_MOUNT_OPTS
23180 [[ $mds1_FSTYPE = zfs ]] || skip "ZFS specific test"
23181 [[ $MDS1_VERSION -lt $(version_code 2.9.55) ]] ||
23182 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
23183 skip "Need server version at least 2.9.55"
23185 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
23187 mkdir $DIR/$tdir || error "(1) fail to mkdir"
23189 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
23190 error "(2) Fail to copy"
23192 trap cleanup_802a EXIT
23194 # sync by force before remount as readonly
23195 sync; sync_all_data; sleep 3; sync_all_data
23199 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
23200 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
23201 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
23203 echo "Mount the server as read only"
23204 setupall server_only || error "(3) Fail to start servers"
23206 echo "Mount client without ro should fail"
23207 mount_client $MOUNT &&
23208 error "(4) Mount client without 'ro' should fail"
23210 echo "Mount client with ro should succeed"
23211 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
23212 mount_client $MOUNT ||
23213 error "(5) Mount client with 'ro' should succeed"
23215 echo "Modify should be refused"
23216 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
23218 echo "Read should be allowed"
23219 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
23220 error "(7) Read should succeed under ro mode"
23224 run_test 802a "simulate readonly device"
23227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23228 remote_mds_nodsh && skip "remote MDS with nodsh"
23230 do_facet $SINGLEMDS $LCTL get_param mdt.*.readonly ||
23231 skip "readonly option not available"
23233 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "(1) fail to mkdir"
23235 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
23236 error "(2) Fail to copy"
23238 # write back all cached data before setting MDT to readonly
23242 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=1
23243 stack_trap "do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0" EXIT
23245 echo "Modify should be refused"
23246 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
23248 echo "Read should be allowed"
23249 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
23250 error "(7) Read should succeed under ro mode"
23253 do_facet $SINGLEMDS $LCTL set_param mdt.*.readonly=0
23255 run_test 802b "be able to set MDTs to readonly"
23258 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23259 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
23260 skip "MDS needs to be newer than 2.10.54"
23262 mkdir -p $DIR/$tdir
23263 # Create some objects on all MDTs to trigger related logs objects
23264 for idx in $(seq $MDSCOUNT); do
23265 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
23266 $DIR/$tdir/dir${idx} ||
23267 error "Fail to create $DIR/$tdir/dir${idx}"
23271 wait_delete_completed # ensure old test cleanups are finished
23272 echo "before create:"
23274 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23276 for i in {1..10}; do
23277 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
23278 error "Fail to create $DIR/$tdir/foo$i"
23282 echo "after create:"
23284 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23286 # allow for an llog to be cleaned up during the test
23287 [ $after_used -ge $((before_used + 10 - 1)) ] ||
23288 error "before ($before_used) + 10 > after ($after_used)"
23290 for i in {1..10}; do
23291 rm -rf $DIR/$tdir/foo$i ||
23292 error "Fail to remove $DIR/$tdir/foo$i"
23295 sleep 3 # avoid MDT return cached statfs
23296 wait_delete_completed
23297 echo "after unlink:"
23299 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
23301 # allow for an llog to be created during the test
23302 [ $after_used -le $((before_used + 1)) ] ||
23303 error "after ($after_used) > before ($before_used) + 1"
23305 run_test 803 "verify agent object for remote object"
23308 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
23309 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
23310 skip "MDS needs to be newer than 2.10.54"
23311 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
23313 mkdir -p $DIR/$tdir
23314 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
23315 error "Fail to create $DIR/$tdir/dir0"
23317 local fid=$($LFS path2fid $DIR/$tdir/dir0)
23318 local dev=$(mdsdevname 2)
23320 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23321 grep ${fid} || error "NOT found agent entry for dir0"
23323 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
23324 error "Fail to create $DIR/$tdir/dir1"
23326 touch $DIR/$tdir/dir1/foo0 ||
23327 error "Fail to create $DIR/$tdir/dir1/foo0"
23328 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
23331 for idx in $(seq $MDSCOUNT); do
23332 dev=$(mdsdevname $idx)
23333 do_facet mds${idx} \
23334 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23335 grep ${fid} && rc=$idx
23338 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
23339 error "Fail to rename foo0 to foo1"
23340 if [ $rc -eq 0 ]; then
23341 for idx in $(seq $MDSCOUNT); do
23342 dev=$(mdsdevname $idx)
23343 do_facet mds${idx} \
23344 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23345 grep ${fid} && rc=$idx
23349 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
23350 error "Fail to rename foo1 to foo2"
23351 if [ $rc -eq 0 ]; then
23352 for idx in $(seq $MDSCOUNT); do
23353 dev=$(mdsdevname $idx)
23354 do_facet mds${idx} \
23355 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
23356 grep ${fid} && rc=$idx
23360 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
23362 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
23363 error "Fail to link to $DIR/$tdir/dir1/foo2"
23364 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
23365 error "Fail to rename foo2 to foo0"
23366 unlink $DIR/$tdir/dir1/foo0 ||
23367 error "Fail to unlink $DIR/$tdir/dir1/foo0"
23368 rm -rf $DIR/$tdir/dir0 ||
23369 error "Fail to rm $DIR/$tdir/dir0"
23371 for idx in $(seq $MDSCOUNT); do
23372 dev=$(mdsdevname $idx)
23376 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
23378 start mds${idx} $dev $MDS_MOUNT_OPTS ||
23379 error "mount mds$idx failed"
23380 df $MOUNT > /dev/null 2>&1
23382 # e2fsck should not return error
23384 error "e2fsck detected error on MDT${idx}: rc=$rc"
23387 run_test 804 "verify agent entry for remote entry"
23390 do_facet $SINGLEMDS zfs set quota=$old $fsset
23391 unlinkmany $DIR/$tdir/f- 1000000
23396 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
23397 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
23398 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
23399 skip "netfree not implemented before 0.7"
23400 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
23401 skip "Need MDS version at least 2.10.57"
23408 local pref="osd-zfs.$FSNAME-MDT0000."
23410 # limit available space on MDS dataset to meet nospace issue
23411 # quickly. then ZFS 0.7.2 can use reserved space if asked
23412 # properly (using netfree flag in osd_declare_destroy()
23413 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
23414 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
23416 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
23417 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
23418 let "usedkb=usedkb-freekb"
23419 let "freekb=freekb/2"
23420 if let "freekb > 5000"; then
23423 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
23424 trap cleanup_805 EXIT
23426 $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
23427 error "Can't set PFL layout"
23428 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
23429 rm -rf $DIR/$tdir || error "not able to remove"
23430 do_facet $SINGLEMDS zfs set quota=$old $fsset
23433 run_test 805 "ZFS can remove from full fs"
23439 local size=$($LFS getsom -s $file)
23440 local expect=$(stat -c %s $file)
23442 [[ $size == $expect ]] ||
23443 error "$file expected size: $expect, got: $size"
23445 local blocks=$($LFS getsom -b $file)
23446 expect=$(stat -c %b $file)
23447 [[ $blocks == $expect ]] ||
23448 error "$file expected blocks: $expect, got: $blocks"
23453 local size=$($LFS getsom -s $1)
23456 [[ $size == $expect ]] ||
23457 error "$file expected size: $expect, got: $size"
23461 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
23462 skip "Need MDS version at least 2.11.52"
23466 touch $DIR/$tfile || error "touch $tfile failed"
23468 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23469 save_lustre_params client "llite.*.xattr_cache" > $save
23470 lctl set_param llite.*.xattr_cache=0
23471 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23473 # single-threaded write
23474 echo "Test SOM for single-threaded write"
23475 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
23476 error "write $tfile failed"
23477 check_lsom_size $DIR/$tfile $bs
23480 local size=$(($num * $bs))
23484 echo "Test SOM for single client multi-threaded($num) write"
23485 $TRUNCATE $DIR/$tfile 0
23486 for ((i = 0; i < $num; i++)); do
23487 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23489 offset=$((offset + $bs))
23491 for (( i=0; i < $num; i++ )); do
23494 check_lsom_size $DIR/$tfile $size
23496 $TRUNCATE $DIR/$tfile 0
23497 for ((i = 0; i < $num; i++)); do
23498 offset=$((offset - $bs))
23499 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23502 for (( i=0; i < $num; i++ )); do
23505 check_lsom_size $DIR/$tfile $size
23507 # multi-client writes
23508 num=$(get_node_count ${CLIENTS//,/ })
23509 size=$(($num * $bs))
23513 echo "Test SOM for multi-client ($num) writes"
23514 $TRUNCATE $DIR/$tfile 0
23515 for client in ${CLIENTS//,/ }; do
23516 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23519 offset=$((offset + $bs))
23521 for (( i=0; i < $num; i++ )); do
23524 check_lsom_size $DIR/$tfile $offset
23527 $TRUNCATE $DIR/$tfile 0
23528 for client in ${CLIENTS//,/ }; do
23529 offset=$((offset - $bs))
23530 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23534 for (( i=0; i < $num; i++ )); do
23537 check_lsom_size $DIR/$tfile $size
23540 echo "Test SOM for truncate"
23541 $TRUNCATE $DIR/$tfile 1048576
23542 check_lsom_size $DIR/$tfile 1048576
23543 $TRUNCATE $DIR/$tfile 1234
23544 check_lsom_size $DIR/$tfile 1234
23546 # verify SOM blocks count
23547 echo "Verify SOM block count"
23548 $TRUNCATE $DIR/$tfile 0
23549 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
23550 error "failed to write file $tfile"
23551 check_lsom_data $DIR/$tfile
23553 run_test 806 "Verify Lazy Size on MDS"
23556 [ -n "$FILESET" ] && skip "Not functional for FILESET set"
23557 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
23558 skip "Need MDS version at least 2.11.52"
23560 # Registration step
23561 changelog_register || error "changelog_register failed"
23562 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
23563 changelog_users $SINGLEMDS | grep -q $cl_user ||
23564 error "User $cl_user not found in changelog_users"
23566 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
23567 save_lustre_params client "llite.*.xattr_cache" > $save
23568 lctl set_param llite.*.xattr_cache=0
23569 stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
23571 rm -rf $DIR/$tdir || error "rm $tdir failed"
23572 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
23573 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
23574 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
23575 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
23576 error "truncate $tdir/trunc failed"
23579 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 conv=fsync ||
23580 error "write $tfile failed"
23582 # multi-client wirtes
23583 local num=$(get_node_count ${CLIENTS//,/ })
23587 echo "Test SOM for multi-client ($num) writes"
23588 touch $DIR/$tfile || error "touch $tfile failed"
23589 $TRUNCATE $DIR/$tfile 0
23590 for client in ${CLIENTS//,/ }; do
23591 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
23594 offset=$((offset + $bs))
23596 for (( i=0; i < $num; i++ )); do
23600 do_rpc_nodes "$CLIENTS" cancel_lru_locks osc
23601 do_nodes "$CLIENTS" "sync ; sleep 5 ; sync"
23602 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
23603 check_lsom_data $DIR/$tdir/trunc
23604 check_lsom_data $DIR/$tdir/single_dd
23605 check_lsom_data $DIR/$tfile
23608 # Deregistration step
23609 changelog_deregister || error "changelog_deregister failed"
23611 run_test 807 "verify LSOM syncing tool"
23613 check_som_nologged()
23615 local lines=$($LFS changelog $FSNAME-MDT0000 |
23616 grep 'x=trusted.som' | wc -l)
23617 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
23621 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
23622 skip "Need MDS version at least 2.11.55"
23624 # Registration step
23625 changelog_register || error "changelog_register failed"
23627 touch $DIR/$tfile || error "touch $tfile failed"
23630 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
23631 error "write $tfile failed"
23634 $TRUNCATE $DIR/$tfile 1234
23637 $TRUNCATE $DIR/$tfile 1048576
23640 # Deregistration step
23641 changelog_deregister || error "changelog_deregister failed"
23643 run_test 808 "Check trusted.som xattr not logged in Changelogs"
23648 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
23652 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
23653 skip "Need MDS version at least 2.11.56"
23655 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
23656 error "failed to create DoM-only file $DIR/$tfile"
23657 touch $DIR/$tfile || error "touch $tfile failed"
23658 check_som_nodata $DIR/$tfile
23660 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
23661 error "write $tfile failed"
23662 check_som_nodata $DIR/$tfile
23664 $TRUNCATE $DIR/$tfile 1234
23665 check_som_nodata $DIR/$tfile
23667 $TRUNCATE $DIR/$tfile 4097
23668 check_som_nodata $DIR/$file
23670 run_test 809 "Verify no SOM xattr store for DoM-only files"
23673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
23674 $GSS && skip_env "could not run with gss"
23675 [[ $OST1_VERSION -gt $(version_code 2.12.58) ]] ||
23676 skip "OST < 2.12.58 doesn't align checksum"
23679 stack_trap "set_checksums $ORIG_CSUM" EXIT
23680 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
23685 for csum in $CKSUM_TYPES; do
23686 #define OBD_FAIL_OSC_NO_GRANT 0x411
23687 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
23688 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
23690 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
23691 before=$(md5sum $DIR/$tfile)
23692 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
23693 after=$(md5sum $DIR/$tfile)
23694 [ "$before" == "$after" ] ||
23695 error "$csum: $before != $after bs=$1 seek=$2"
23699 run_test 810 "partial page writes on ZFS (LU-11663)"
23702 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
23703 skip "OST < 2.12.51 doesn't support this fail_loc"
23704 [ "$SHARED_KEY" = true ] &&
23705 skip "OSC connections never go IDLE with Shared-Keys enabled"
23707 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23708 # ensure ost1 is connected
23709 stat $DIR/$tfile >/dev/null || error "can't stat"
23710 wait_osc_import_state client ost1 FULL
23711 # no locks, no reqs to let the connection idle
23712 cancel_lru_locks osc
23714 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
23715 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
23716 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
23717 wait_osc_import_state client ost1 CONNECTING
23718 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
23720 stat $DIR/$tfile >/dev/null || error "can't stat file"
23722 run_test 812a "do not drop reqs generated when imp is going to idle (LU-11951)"
23724 test_812b() { # LU-12378
23725 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
23726 skip "OST < 2.12.51 doesn't support this fail_loc"
23727 [ "$SHARED_KEY" = true ] &&
23728 skip "OSC connections never go IDLE with Shared-Keys enabled"
23730 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
23731 # ensure ost1 is connected
23732 stat $DIR/$tfile >/dev/null || error "can't stat"
23733 wait_osc_import_state client ost1 FULL
23734 # no locks, no reqs to let the connection idle
23735 cancel_lru_locks osc
23737 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
23738 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
23739 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
23740 wait_osc_import_state client ost1 CONNECTING
23741 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
23743 $LFS quota -u 0 $DIR/ || error "lfs quota should succeed"
23744 wait_osc_import_state client ost1 IDLE
23746 run_test 812b "do not drop no resend request for idle connect"
23749 local file_heat_sav=$($LCTL get_param -n llite.*.file_heat 2>/dev/null)
23750 [ -z "$file_heat_sav" ] && skip "no file heat support"
23761 local period_second=$($LCTL get_param -n llite.*.heat_period_second)
23762 local decay_pct=$($LCTL get_param -n llite.*.heat_decay_percentage)
23764 $LCTL set_param -n llite.*.file_heat=1
23765 echo "Turn on file heat"
23766 echo "Period second: $period_second, Decay percentage: $decay_pct"
23768 echo "QQQQ" > $DIR/$tfile
23769 echo "QQQQ" > $DIR/$tfile
23770 echo "QQQQ" > $DIR/$tfile
23771 cat $DIR/$tfile > /dev/null
23772 cat $DIR/$tfile > /dev/null
23773 cat $DIR/$tfile > /dev/null
23774 cat $DIR/$tfile > /dev/null
23776 local out=$($LFS heat_get $DIR/$tfile)
23778 $LFS heat_get $DIR/$tfile
23779 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23780 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23781 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23782 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23784 [ $readsample -le 4 ] || error "read sample ($readsample) is wrong"
23785 [ $writesample -le 3 ] || error "write sample ($writesample) is wrong"
23786 [ $readbyte -le 20 ] || error "read bytes ($readbyte) is wrong"
23787 [ $writebyte -le 15 ] || error "write bytes ($writebyte) is wrong"
23789 sleep $((period_second + 3))
23790 echo "Sleep $((period_second + 3)) seconds..."
23791 # The recursion formula to calculate the heat of the file f is as
23793 # Hi+1(f) = (1-P)*Hi(f)+ P*Ci
23794 # Where Hi is the heat value in the period between time points i*I and
23795 # (i+1)*I; Ci is the access count in the period; the symbol P refers
23796 # to the weight of Ci.
23797 out=$($LFS heat_get $DIR/$tfile)
23798 $LFS heat_get $DIR/$tfile
23799 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23800 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23801 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23802 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23804 [ $(bc <<< "$readsample <= 4 * $decay_pct / 100") -eq 1 ] ||
23805 error "read sample ($readsample) is wrong"
23806 [ $(bc <<< "$writesample <= 3 * $decay_pct / 100") -eq 1 ] ||
23807 error "write sample ($writesample) is wrong"
23808 [ $(bc <<< "$readbyte <= 20 * $decay_pct / 100") -eq 1 ] ||
23809 error "read bytes ($readbyte) is wrong"
23810 [ $(bc <<< "$writebyte <= 15 * $decay_pct / 100") -eq 1 ] ||
23811 error "write bytes ($writebyte) is wrong"
23813 echo "QQQQ" > $DIR/$tfile
23814 echo "QQQQ" > $DIR/$tfile
23815 echo "QQQQ" > $DIR/$tfile
23816 cat $DIR/$tfile > /dev/null
23817 cat $DIR/$tfile > /dev/null
23818 cat $DIR/$tfile > /dev/null
23819 cat $DIR/$tfile > /dev/null
23821 sleep $((period_second + 3))
23822 echo "Sleep $((period_second + 3)) seconds..."
23824 out=$($LFS heat_get $DIR/$tfile)
23825 $LFS heat_get $DIR/$tfile
23826 readsample1=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23827 writesample1=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23828 readbyte1=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23829 writebyte1=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23831 [ $(bc <<< "$readsample1 <= ($readsample * (100 - $decay_pct) + \
23832 4 * $decay_pct) / 100") -eq 1 ] ||
23833 error "read sample ($readsample1) is wrong"
23834 [ $(bc <<< "$writesample1 <= ($writesample * (100 - $decay_pct) + \
23835 3 * $decay_pct) / 100") -eq 1 ] ||
23836 error "write sample ($writesample1) is wrong"
23837 [ $(bc <<< "$readbyte1 <= ($readbyte * (100 - $decay_pct) + \
23838 20 * $decay_pct) / 100") -eq 1 ] ||
23839 error "read bytes ($readbyte1) is wrong"
23840 [ $(bc <<< "$writebyte1 <= ($writebyte * (100 - $decay_pct) + \
23841 15 * $decay_pct) / 100") -eq 1 ] ||
23842 error "write bytes ($writebyte1) is wrong"
23844 echo "Turn off file heat for the file $DIR/$tfile"
23845 $LFS heat_set -o $DIR/$tfile
23847 echo "QQQQ" > $DIR/$tfile
23848 echo "QQQQ" > $DIR/$tfile
23849 echo "QQQQ" > $DIR/$tfile
23850 cat $DIR/$tfile > /dev/null
23851 cat $DIR/$tfile > /dev/null
23852 cat $DIR/$tfile > /dev/null
23853 cat $DIR/$tfile > /dev/null
23855 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 -eq 0 ] || error "read sample ($readsample) is wrong"
23863 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23864 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23865 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23867 echo "Trun on file heat for the file $DIR/$tfile"
23868 $LFS heat_set -O $DIR/$tfile
23870 echo "QQQQ" > $DIR/$tfile
23871 echo "QQQQ" > $DIR/$tfile
23872 echo "QQQQ" > $DIR/$tfile
23873 cat $DIR/$tfile > /dev/null
23874 cat $DIR/$tfile > /dev/null
23875 cat $DIR/$tfile > /dev/null
23876 cat $DIR/$tfile > /dev/null
23878 out=$($LFS heat_get $DIR/$tfile)
23879 $LFS heat_get $DIR/$tfile
23880 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23881 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23882 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23883 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23885 [ $readsample -gt 0 ] || error "read sample ($readsample) is wrong"
23886 [ $writesample -gt 0 ] || error "write sample ($writesample) is wrong"
23887 [ $readbyte -gt 0 ] || error "read bytes ($readbyte) is wrong"
23888 [ $writebyte -gt 0 ] || error "write bytes ($writebyte) is wrong"
23890 $LFS heat_set -c $DIR/$tfile
23891 $LCTL set_param -n llite.*.file_heat=0
23892 echo "Turn off file heat support for the Lustre filesystem"
23894 echo "QQQQ" > $DIR/$tfile
23895 echo "QQQQ" > $DIR/$tfile
23896 echo "QQQQ" > $DIR/$tfile
23897 cat $DIR/$tfile > /dev/null
23898 cat $DIR/$tfile > /dev/null
23899 cat $DIR/$tfile > /dev/null
23900 cat $DIR/$tfile > /dev/null
23902 out=$($LFS heat_get $DIR/$tfile)
23903 $LFS heat_get $DIR/$tfile
23904 readsample=$(echo "$out" | grep 'readsample' | awk '{ print $2 }')
23905 writesample=$(echo "$out" | grep 'writesample' | awk '{ print $2 }')
23906 readbyte=$(echo "$out" | grep 'readbyte' | awk '{ print $2 }')
23907 writebyte=$(echo "$out" | grep 'writebyte' | awk '{ print $2 }')
23909 [ $readsample -eq 0 ] || error "read sample ($readsample) is wrong"
23910 [ $writesample -eq 0 ] || error "write sample ($writesample) is wrong"
23911 [ $readbyte -eq 0 ] || error "read bytes ($readbyte) is wrong"
23912 [ $writebyte -eq 0 ] || error "write bytes ($writebyte) is wrong"
23914 $LCTL set_param -n llite.*.file_heat=$file_heat_sav
23917 run_test 813 "File heat verfication"
23921 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
23922 echo -n y >> $DIR/$tfile
23923 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
23924 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
23926 run_test 814 "sparse cp works as expected (LU-12361)"
23930 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
23931 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
23933 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
23936 [ "$SHARED_KEY" = true ] &&
23937 skip "OSC connections never go IDLE with Shared-Keys enabled"
23939 $LFS setstripe -c 1 -i 0 $DIR/$tfile
23940 # ensure ost1 is connected
23941 stat $DIR/$tfile >/dev/null || error "can't stat"
23942 wait_osc_import_state client ost1 FULL
23943 # no locks, no reqs to let the connection idle
23944 cancel_lru_locks osc
23945 lru_resize_disable osc
23948 before=$($LCTL get_param -n \
23949 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23951 wait_osc_import_state client ost1 IDLE
23952 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
23953 now=$($LCTL get_param -n \
23954 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
23955 [ $before == $now ] || error "lru_size changed $before != $now"
23957 run_test 816 "do not reset lru_resize on idle reconnect"
23961 exportfs -u localhost:$DIR/nfsexp
23966 systemctl restart nfs-server.service || skip "failed to restart nfsd"
23968 mkdir -p $DIR/nfsexp
23969 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
23970 error "failed to export nfs"
23972 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
23973 stack_trap cleanup_817 EXIT
23975 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
23976 error "failed to mount nfs to $tmpdir"
23978 cp /bin/true $tmpdir
23979 $DIR/nfsexp/true || error "failed to execute 'true' command"
23981 run_test 817 "nfsd won't cache write lock for exec file"
23985 $LFS setstripe -c1 -i0 $DIR/$tfile
23986 $LFS setstripe -c1 -i1 $DIR/$tfile
23988 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
23989 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
23990 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
23991 error "start $SINGLEMDS failed"
23994 run_test 818 "unlink with failed llog"
23997 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
23998 cancel_lru_locks osc
23999 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
24000 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
24001 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
24004 run_test 819a "too big niobuf in read"
24007 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
24008 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
24009 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24010 cancel_lru_locks osc
24014 run_test 819b "too big niobuf in write"
24017 function test_820_start_ost() {
24020 for num in $(seq $OSTCOUNT); do
24021 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS
24026 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
24029 umount_client $MOUNT || error "umount failed"
24030 for num in $(seq $OSTCOUNT); do
24034 # mount client with no active OSTs
24035 # so that the client can't initialize max LOV EA size
24036 # from OSC notifications
24037 mount_client $MOUNT || error "mount failed"
24038 # delay OST starting to keep this 0 max EA size for a while
24039 test_820_start_ost &
24041 # create a directory on MDS2
24042 test_mkdir -i 1 -c1 $DIR/$tdir/mds2 ||
24043 error "Failed to create directory"
24044 # open intent should update default EA size
24045 # see mdc_update_max_ea_from_body()
24046 # notice this is the very first RPC to MDS2
24047 cp /etc/services $DIR/$tdir/mds2 ||
24048 error "Failed to copy files to mds$n"
24050 run_test 820 "update max EA from open intent"
24053 # tests that do cleanup/setup should be run at the end
24057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24060 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
24061 $LCTL set_param fail_loc=0x903
24063 cancel_lru_locks MGC
24065 FAIL_ON_ERROR=true cleanup
24066 FAIL_ON_ERROR=true setup
24068 run_test 900 "umount should not race with any mgc requeue thread"
24070 # LUS-6253/LU-11185
24076 [ $PARALLEL == "yes" ] && skip "skip parallel run"
24078 # some get_param have a bug to handle dot in param name
24079 cancel_lru_locks MGC
24080 oldc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
24081 olds=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
24082 umount_client $MOUNT || error "umount failed"
24083 mount_client $MOUNT || error "mount failed"
24084 cancel_lru_locks MGC
24085 newc=$($LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
24086 news=$(do_facet mgs $LCTL get_param -n 'ldlm.namespaces.MGS*.lock_count')
24088 [ $oldc -lt $newc ] && error "mgc lock leak ($oldc != $newc)"
24089 [ $olds -lt $news ] && error "mgs lock leak ($olds != $news)"
24093 run_test 901 "don't leak a mgc lock on client umount"
24097 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
24098 skip "client does not have LU-13377 fix"
24099 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
24100 $LCTL set_param fail_loc=0x1415
24101 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
24102 cancel_lru_locks osc
24105 run_test 902 "test short write doesn't hang lustre"
24108 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
24109 check_and_cleanup_lustre
24110 if [ "$I_MOUNTED" != "yes" ]; then
24111 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true