2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693 LU-11058
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c 77k"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 ..
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
19 # bug number for skipped tests: LU-9795 (all below)
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 17n 60a 133g 300f"
23 if [[ $(uname -m) = aarch64 ]]; then
24 # bug number: LU-11596 (all below)
25 ALWAYS_EXCEPT+=" 42d 42e 63a 63b 64a 64b 64c"
26 # bug number: LU-11671 LU-11665 LU-11594 LU-11667 LU-11729
27 ALWAYS_EXCEPT+=" 45 101c 103a 317 810"
30 # Check Grants after these tests
31 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
32 SRCDIR=$(cd $(dirname $0); echo $PWD)
33 export PATH=$PATH:/sbin
39 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
40 CREATETEST=${CREATETEST:-createtest}
42 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
44 OPENFILE=${OPENFILE:-openfile}
45 OPENUNLINK=${OPENUNLINK:-openunlink}
46 export MULTIOP=${MULTIOP:-multiop}
47 READS=${READS:-"reads"}
48 MUNLINK=${MUNLINK:-munlink}
49 SOCKETSERVER=${SOCKETSERVER:-socketserver}
50 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
51 MEMHOG=${MEMHOG:-memhog}
52 DIRECTIO=${DIRECTIO:-directio}
53 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
55 CHECK_GRANT=${CHECK_GRANT:-"yes"}
56 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
57 export PARALLEL=${PARALLEL:-"no"}
59 export NAME=${NAME:-local}
66 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
67 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
68 . $LUSTRE/tests/test-framework.sh
70 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
74 # skip nfs tests on kernels >= 4.14.0 until they are fixed
75 if [ $LINUX_VERSION_CODE -ge $(version_code 4.14.0) ];then
76 # bug number: LU-12661
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
83 if [ "$mds1_FSTYPE" = "zfs" ]; then
84 # bug number for skipped test:
85 ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
87 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
90 # Get the SLES distro version
92 # Returns a version string that should only be used in comparing
93 # strings returned by version_code()
96 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
98 # All SuSE Linux versions have one decimal. version_code expects two
99 local sles_version=$version.0
100 version_code $sles_version
103 # Check if we are running on Ubuntu or SLES so we can make decisions on
105 if [ -r /etc/SuSE-release ]; then
106 sles_version=$(sles_version_code)
107 [ $sles_version -lt $(version_code 11.4.0) ] &&
108 # bug number for skipped test: LU-4341
109 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
110 [ $sles_version -lt $(version_code 12.0.0) ] &&
111 # bug number for skipped test: LU-3703
112 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
113 elif [ -r /etc/os-release ]; then
114 if grep -qi ubuntu /etc/os-release; then
115 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
116 -e 's/^VERSION=//p' \
120 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
121 # bug number for skipped test:
123 ALWAYS_EXCEPT+=" 103a 410"
132 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
133 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
142 check_swap_layouts_support()
144 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
145 skip "Does not support layout lock."
148 check_and_setup_lustre
152 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
154 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
155 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
156 rm -rf $DIR/[Rdfs][0-9]*
158 # $RUNAS_ID may get set incorrectly somewhere else
159 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
160 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
162 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
166 if [ "${ONLY}" = "MOUNT" ] ; then
167 echo "Lustre is up, please go on"
171 echo "preparing for tests involving mounts"
172 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
174 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
175 echo # add a newline after mke2fs.
179 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
180 lctl set_param debug=-1 2> /dev/null || true
183 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
185 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
187 run_test 0a "touch; rm ====================="
190 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
191 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
193 run_test 0b "chmod 0755 $DIR ============================="
196 $LCTL get_param mdc.*.import | grep "state: FULL" ||
197 error "import not FULL"
198 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
201 run_test 0c "check import proc"
203 test_0d() { # LU-3397
204 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
205 skip "proc exports not supported before 2.10.57"
207 local mgs_exp="mgs.MGS.exports"
208 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
210 local exp_client_version
213 local temp_imp=$DIR/$tfile.import
214 local temp_exp=$DIR/$tfile.export
216 # save mgc import file to $temp_imp
217 $LCTL get_param mgc.*.import | tee $temp_imp
218 # Check if client uuid is found in MGS export
219 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
220 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
224 # save mgs export file to $temp_exp
225 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
227 # Compare the value of field "connect_flags"
228 imp_val=$(grep "connect_flags" $temp_imp)
229 exp_val=$(grep "connect_flags" $temp_exp)
230 [ "$exp_val" == "$imp_val" ] ||
231 error "export flags '$exp_val' != import flags '$imp_val'"
233 # Compare the value of client version
234 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
235 exp_val=$(version_code $exp_client_version)
236 imp_val=$CLIENT_VERSION
237 [ "$exp_val" == "$imp_val" ] ||
238 error "export client version '$exp_val' != '$imp_val'"
240 run_test 0d "check export proc ============================="
243 test_mkdir $DIR/$tdir
244 test_mkdir $DIR/$tdir/d2
245 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
246 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
249 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
251 run_test 1 "mkdir; remkdir; rmdir"
254 test_mkdir $DIR/$tdir
255 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
256 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
258 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
260 run_test 2 "mkdir; touch; rmdir; check file"
263 test_mkdir $DIR/$tdir
264 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
265 touch $DIR/$tdir/$tfile
266 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
268 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
270 run_test 3 "mkdir; touch; rmdir; check dir"
272 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
274 test_mkdir -i 1 $DIR/$tdir
276 touch $DIR/$tdir/$tfile ||
277 error "Create file under remote directory failed"
280 error "Expect error removing in-use dir $DIR/$tdir"
282 test -d $DIR/$tdir || error "Remote directory disappeared"
284 rm -rf $DIR/$tdir || error "remove remote dir error"
286 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
289 test_mkdir $DIR/$tdir
290 test_mkdir $DIR/$tdir/d2
291 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
292 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
293 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
295 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
298 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
299 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
300 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
301 error "$tfile does not have perm 0666 or UID $UID"
302 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
303 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
304 error "$tfile should be 0666 and owned by UID $UID"
306 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
309 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
312 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
314 error "$tfile should be owned by UID $RUNAS_ID"
315 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
316 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
317 error "$tfile should be owned by UID $RUNAS_ID"
319 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
322 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
325 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
326 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
327 error "$tfile should be owned by GID $UID"
328 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
329 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
330 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
332 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
335 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
337 test_mkdir $DIR/$tdir
338 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
339 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
340 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
341 test_mkdir $DIR/$tdir/d/subdir
342 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
343 error "$tdir/d/subdir should be GID $RUNAS_GID"
344 if [[ $MDSCOUNT -gt 1 ]]; then
345 # check remote dir sgid inherite
346 $LFS mkdir -i 0 $DIR/$tdir.local ||
347 error "mkdir $tdir.local failed"
348 chmod g+s $DIR/$tdir.local ||
349 error "chmod $tdir.local failed"
350 chgrp $RUNAS_GID $DIR/$tdir.local ||
351 error "chgrp $tdir.local failed"
352 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
353 error "mkdir $tdir.remote failed"
354 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
355 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
356 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
357 error "$tdir.remote should be mode 02755"
360 run_test 6g "verify new dir in sgid dir inherits group"
362 test_6h() { # bug 7331
363 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
365 touch $DIR/$tfile || error "touch failed"
366 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
367 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
368 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
369 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
370 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
372 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
375 test_mkdir $DIR/$tdir
376 $MCREATE $DIR/$tdir/$tfile
377 chmod 0666 $DIR/$tdir/$tfile
378 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
379 error "$tdir/$tfile should be mode 0666"
381 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
384 if [ ! -d $DIR/$tdir ]; then
385 test_mkdir $DIR/$tdir
387 $MCREATE $DIR/$tdir/$tfile
388 echo -n foo > $DIR/$tdir/$tfile
389 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
390 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
392 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
395 test_mkdir $DIR/$tdir
396 touch $DIR/$tdir/$tfile
397 chmod 0666 $DIR/$tdir/$tfile
398 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
399 error "$tfile mode not 0666"
401 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
404 test_mkdir $DIR/$tdir
405 test_mkdir $DIR/$tdir/d2
406 test_mkdir $DIR/$tdir/d2/d3
407 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
409 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
412 test_mkdir $DIR/$tdir
413 test_mkdir $DIR/$tdir/d2
414 touch $DIR/$tdir/d2/$tfile
415 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
416 error "$tdir/d2/$tfile not a file"
418 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
421 test_mkdir $DIR/$tdir
422 test_mkdir $DIR/$tdir/d2
423 chmod 0666 $DIR/$tdir/d2
424 chmod 0705 $DIR/$tdir/d2
425 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
426 error "$tdir/d2 mode not 0705"
428 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
431 test_mkdir $DIR/$tdir
432 touch $DIR/$tdir/$tfile
433 chmod 0666 $DIR/$tdir/$tfile
434 chmod 0654 $DIR/$tdir/$tfile
435 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
436 error "$tdir/d2 mode not 0654"
438 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
441 test_mkdir $DIR/$tdir
442 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
444 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
445 error "$tdir/$tfile size not 0 after truncate"
447 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
450 test_mkdir $DIR/$tdir
451 touch $DIR/$tdir/$tfile
453 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
455 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
458 test_mkdir $DIR/$tdir
459 touch $DIR/$tdir/$tfile
460 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
461 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
462 error "$tdir/${tfile_2} not a file after rename"
463 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
465 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
468 test_mkdir $DIR/$tdir
469 touch $DIR/$tdir/$tfile
470 rm -rf $DIR/$tdir/$tfile
471 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
473 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
476 test_mkdir $DIR/$tdir
477 touch $DIR/$tdir/$tfile
478 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
480 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
481 error "$tdir/l-exist not a symlink"
482 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
483 error "$tdir/l-exist not referencing a file"
484 rm -f $DIR/$tdir/l-exist
485 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
487 run_test 17a "symlinks: create, remove (real)"
490 test_mkdir $DIR/$tdir
491 ln -s no-such-file $DIR/$tdir/l-dangle
493 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
494 error "$tdir/l-dangle not referencing no-such-file"
495 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
496 error "$tdir/l-dangle not referencing non-existent file"
497 rm -f $DIR/$tdir/l-dangle
498 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
500 run_test 17b "symlinks: create, remove (dangling)"
502 test_17c() { # bug 3440 - don't save failed open RPC for replay
503 test_mkdir $DIR/$tdir
504 ln -s foo $DIR/$tdir/$tfile
505 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
507 run_test 17c "symlinks: open dangling (should return error)"
510 test_mkdir $DIR/$tdir
511 ln -s foo $DIR/$tdir/$tfile
512 touch $DIR/$tdir/$tfile || error "creating to new symlink"
514 run_test 17d "symlinks: create dangling"
517 test_mkdir $DIR/$tdir
518 local foo=$DIR/$tdir/$tfile
519 ln -s $foo $foo || error "create symlink failed"
520 ls -l $foo || error "ls -l failed"
521 ls $foo && error "ls not failed" || true
523 run_test 17e "symlinks: create recursive symlink (should return error)"
526 test_mkdir $DIR/$tdir
527 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
528 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
529 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
530 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
531 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
532 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
535 run_test 17f "symlinks: long and very long symlink name"
537 # str_repeat(S, N) generate a string that is string S repeated N times
542 while [ $((n -= 1)) -ge 0 ]; do
548 # Long symlinks and LU-2241
550 test_mkdir $DIR/$tdir
551 local TESTS="59 60 61 4094 4095"
553 # Fix for inode size boundary in 2.1.4
554 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
557 # Patch not applied to 2.2 or 2.3 branches
558 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
559 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
562 # skip long symlink name for rhel6.5.
563 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
564 grep -q '6.5' /etc/redhat-release &>/dev/null &&
565 TESTS="59 60 61 4062 4063"
568 local SYMNAME=$(str_repeat 'x' $i)
569 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
570 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
573 run_test 17g "symlinks: really long symlink name and inode boundaries"
575 test_17h() { #bug 17378
576 [ $PARALLEL == "yes" ] && skip "skip parallel run"
577 remote_mds_nodsh && skip "remote MDS with nodsh"
581 test_mkdir $DIR/$tdir
582 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
583 $LFS setstripe -c -1 $DIR/$tdir
584 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
585 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
586 touch $DIR/$tdir/$tfile || true
588 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
590 test_17i() { #bug 20018
591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
592 remote_mds_nodsh && skip "remote MDS with nodsh"
594 local foo=$DIR/$tdir/$tfile
597 test_mkdir -c1 $DIR/$tdir
598 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
599 ln -s $foo $foo || error "create symlink failed"
600 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
601 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
602 ls -l $foo && error "error not detected"
605 run_test 17i "don't panic on short symlink (should return error)"
607 test_17k() { #bug 22301
608 [ $PARALLEL == "yes" ] && skip "skip parallel run"
609 [[ -z "$(which rsync 2>/dev/null)" ]] &&
610 skip "no rsync command"
611 rsync --help | grep -q xattr ||
612 skip_env "$(rsync --version | head -n1) does not support xattrs"
613 test_mkdir $DIR/$tdir
614 test_mkdir $DIR/$tdir.new
615 touch $DIR/$tdir/$tfile
616 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
617 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
618 error "rsync failed with xattrs enabled"
620 run_test 17k "symlinks: rsync with xattrs enabled"
622 test_17l() { # LU-279
623 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
624 skip "no getfattr command"
626 test_mkdir $DIR/$tdir
627 touch $DIR/$tdir/$tfile
628 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
629 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
630 # -h to not follow symlinks. -m '' to list all the xattrs.
631 # grep to remove first line: '# file: $path'.
632 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
634 lgetxattr_size_check $path $xattr ||
635 error "lgetxattr_size_check $path $xattr failed"
639 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
643 [ $PARALLEL == "yes" ] && skip "skip parallel run"
644 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
645 remote_mds_nodsh && skip "remote MDS with nodsh"
646 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
647 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
648 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
650 local short_sym="0123456789"
651 local wdir=$DIR/$tdir
656 # create a long symlink file
657 for ((i = 0; i < 4; ++i)); do
658 long_sym=${long_sym}${long_sym}
661 echo "create 512 short and long symlink files under $wdir"
662 for ((i = 0; i < 256; ++i)); do
663 ln -sf ${long_sym}"a5a5" $wdir/long-$i
664 ln -sf ${short_sym}"a5a5" $wdir/short-$i
670 wait_delete_completed
672 echo "recreate the 512 symlink files with a shorter string"
673 for ((i = 0; i < 512; ++i)); do
674 # rewrite the symlink file with a shorter string
675 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
676 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
679 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
680 local devname=$(mdsdevname $mds_index)
682 echo "stop and checking mds${mds_index}:"
683 # e2fsck should not return error
685 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
688 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
689 error "start mds${mds_index} failed"
690 df $MOUNT > /dev/null 2>&1
692 error "e2fsck detected error for short/long symlink: rc=$rc"
695 run_test 17m "run e2fsck against MDT which contains short/long symlink"
697 check_fs_consistency_17n() {
701 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
702 # so it only check MDT1/MDT2 instead of all of MDTs.
703 for mdt_index in 1 2; do
704 local devname=$(mdsdevname $mdt_index)
705 # e2fsck should not return error
707 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
710 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
711 error "mount mds$mdt_index failed"
712 df $MOUNT > /dev/null 2>&1
718 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
720 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
721 remote_mds_nodsh && skip "remote MDS with nodsh"
722 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
723 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
724 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
728 test_mkdir $DIR/$tdir
729 for ((i=0; i<10; i++)); do
730 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
731 error "create remote dir error $i"
732 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
733 error "create files under remote dir failed $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after create files under remote dir"
739 for ((i = 0; i < 10; i++)); do
740 rm -rf $DIR/$tdir/remote_dir_${i} ||
741 error "destroy remote dir error $i"
744 check_fs_consistency_17n ||
745 error "e2fsck report error after unlink files under remote dir"
747 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
748 skip "lustre < 2.4.50 does not support migrate mv"
750 for ((i = 0; i < 10; i++)); do
751 mkdir -p $DIR/$tdir/remote_dir_${i}
752 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
753 error "create files under remote dir failed $i"
754 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
755 error "migrate remote dir error $i"
757 check_fs_consistency_17n || error "e2fsck report error after migration"
759 for ((i = 0; i < 10; i++)); do
760 rm -rf $DIR/$tdir/remote_dir_${i} ||
761 error "destroy remote dir error $i"
764 check_fs_consistency_17n || error "e2fsck report error after unlink"
766 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
769 remote_mds_nodsh && skip "remote MDS with nodsh"
770 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
771 skip "Need MDS version at least 2.3.64"
773 local wdir=$DIR/${tdir}o
779 mdt_index=$($LFS getstripe -m $wdir/$tfile)
780 mdt_index=$((mdt_index + 1))
783 #fail mds will wait the failover finish then set
784 #following fail_loc to avoid interfer the recovery process.
787 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
788 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
789 ls -l $wdir/$tfile && rc=1
790 do_facet mds${mdt_index} lctl set_param fail_loc=0
791 [[ $rc -eq 0 ]] || error "stat file should fail"
793 run_test 17o "stat file with incompat LMA feature"
796 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
797 ls $DIR || error "Failed to ls $DIR: $?"
799 run_test 18 "touch .../f ; ls ... =============================="
805 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
807 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
810 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
812 run_test 19b "ls -l .../f19 (should return error) =============="
815 [ $RUNAS_ID -eq $UID ] &&
816 skip_env "RUNAS_ID = UID = $UID -- skipping"
818 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
820 run_test 19c "$RUNAS touch .../f19 (should return error) =="
823 cat $DIR/f19 && error || true
825 run_test 19d "cat .../f19 (should return error) =============="
834 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
836 run_test 20 "touch .../f ; ls -l ..."
839 test_mkdir $DIR/$tdir
840 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
841 ln -s dangle $DIR/$tdir/link
842 echo foo >> $DIR/$tdir/link
843 cat $DIR/$tdir/dangle
844 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
845 $CHECKSTAT -f -t file $DIR/$tdir/link ||
846 error "$tdir/link not linked to a file"
848 run_test 21 "write to dangling link"
851 local wdir=$DIR/$tdir
853 chown $RUNAS_ID:$RUNAS_GID $wdir
854 (cd $wdir || error "cd $wdir failed";
855 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
857 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
858 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
859 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
860 error "checkstat -u failed"
862 run_test 22 "unpack tar archive as non-root user"
866 test_mkdir $DIR/$tdir
867 local file=$DIR/$tdir/$tfile
869 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
870 openfile -f O_CREAT:O_EXCL $file &&
871 error "$file recreate succeeded" || true
873 run_test 23a "O_CREAT|O_EXCL in subdir"
875 test_23b() { # bug 18988
876 test_mkdir $DIR/$tdir
877 local file=$DIR/$tdir/$tfile
880 echo foo > $file || error "write filed"
881 echo bar >> $file || error "append filed"
882 $CHECKSTAT -s 8 $file || error "wrong size"
885 run_test 23b "O_APPEND check"
887 # LU-9409, size with O_APPEND and tiny writes
889 local file=$DIR/$tfile
892 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
893 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
898 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
900 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
903 #racing tiny & normal writes
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
905 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
907 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
910 #racing tiny & normal writes 2, ugly numbers
911 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
912 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
914 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
917 run_test 23c "O_APPEND size checks for tiny writes"
919 # LU-11069 file offset is correct after appending writes
921 local file=$DIR/$tfile
924 echo CentaurHauls > $file
925 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
926 if ((offset != 26)); then
927 error "wrong offset, expected 26, got '$offset'"
930 run_test 23d "file offset is correct after appending writes"
934 echo '-- same directory rename'
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.1
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
940 run_test 24a "rename file to non-existent target"
943 test_mkdir $DIR/$tdir
944 touch $DIR/$tdir/$tfile.{1,2}
945 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
946 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
947 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
949 run_test 24b "rename file to existing target"
952 test_mkdir $DIR/$tdir
953 test_mkdir $DIR/$tdir/d$testnum.1
954 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
955 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
956 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
958 run_test 24c "rename directory to non-existent target"
961 test_mkdir -c1 $DIR/$tdir
962 test_mkdir -c1 $DIR/$tdir/d$testnum.1
963 test_mkdir -c1 $DIR/$tdir/d$testnum.2
964 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
965 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
966 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
968 run_test 24d "rename directory to existing target"
971 echo '-- cross directory renames --'
975 mv $DIR/R5a/f $DIR/R5b/g
976 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
977 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
979 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
984 touch $DIR/R6a/f $DIR/R6b/g
985 mv $DIR/R6a/f $DIR/R6b/g
986 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
987 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
989 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
994 test_mkdir $DIR/R7a/d
995 mv $DIR/R7a/d $DIR/R7b/e
996 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
997 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
999 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1002 test_mkdir -c1 $DIR/R8a
1003 test_mkdir -c1 $DIR/R8b
1004 test_mkdir -c1 $DIR/R8a/d
1005 test_mkdir -c1 $DIR/R8b/e
1006 mrename $DIR/R8a/d $DIR/R8b/e
1007 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1008 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1010 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1013 echo "-- rename error cases"
1015 test_mkdir $DIR/R9/a
1017 mrename $DIR/R9/f $DIR/R9/a
1018 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1019 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1020 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1022 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1026 mrename $DIR/R10/f $DIR/R10/g
1027 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1028 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1029 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1031 run_test 24j "source does not exist ============================"
1034 test_mkdir $DIR/R11a
1035 test_mkdir $DIR/R11a/d
1037 mv $DIR/R11a/f $DIR/R11a/d
1038 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1039 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1041 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1043 # bug 2429 - rename foo foo foo creates invalid file
1046 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1048 run_test 24l "Renaming a file to itself ========================"
1052 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1053 # on ext3 this does not remove either the source or target files
1054 # though the "expected" operation would be to remove the source
1055 $CHECKSTAT -t file ${f} || error "${f} missing"
1056 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1058 run_test 24m "Renaming a file to a hard link to itself ========="
1062 # this stats the old file after it was renamed, so it should fail
1064 $CHECKSTAT ${f} || error "${f} missing"
1066 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1067 $CHECKSTAT -a ${f} || error "${f} exists"
1069 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1072 test_mkdir $DIR/$tdir
1073 rename_many -s random -v -n 10 $DIR/$tdir
1075 run_test 24o "rename of files during htree split"
1078 test_mkdir $DIR/R12a
1079 test_mkdir $DIR/R12b
1080 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1081 mrename $DIR/R12a $DIR/R12b
1082 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1083 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1084 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1085 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1087 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1089 cleanup_multiop_pause() {
1091 kill -USR1 $MULTIPID
1095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1097 test_mkdir $DIR/R13a
1098 test_mkdir $DIR/R13b
1099 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1100 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1103 trap cleanup_multiop_pause EXIT
1104 mrename $DIR/R13a $DIR/R13b
1105 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1106 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1107 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1108 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1109 cleanup_multiop_pause
1110 wait $MULTIPID || error "multiop close failed"
1112 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1114 test_24r() { #bug 3789
1115 test_mkdir $DIR/R14a
1116 test_mkdir $DIR/R14a/b
1117 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1118 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1119 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1121 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1124 test_mkdir $DIR/R15a
1125 test_mkdir $DIR/R15a/b
1126 test_mkdir $DIR/R15a/b/c
1127 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1128 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1129 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1131 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1133 test_mkdir $DIR/R16a
1134 test_mkdir $DIR/R16a/b
1135 test_mkdir $DIR/R16a/b/c
1136 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1137 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1138 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1140 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1142 test_24u() { # bug12192
1143 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1144 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1146 run_test 24u "create stripe file"
1148 simple_cleanup_common() {
1151 [ -z "$DIR" -o -z "$tdir" ] && return 0
1153 local start=$SECONDS
1156 wait_delete_completed
1157 echo "cleanup time $((SECONDS - start))"
1161 max_pages_per_rpc() {
1162 local mdtname="$(printf "MDT%04x" ${1:-0})"
1163 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1167 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1169 local nrfiles=${COUNT:-100000}
1170 local fname="$DIR/$tdir/$tfile"
1172 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1173 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1175 test_mkdir "$(dirname $fname)"
1176 # assume MDT0000 has the fewest inodes
1177 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1178 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1179 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1181 trap simple_cleanup_common EXIT
1183 createmany -m "$fname" $nrfiles
1185 cancel_lru_locks mdc
1186 lctl set_param mdc.*.stats clear
1188 # was previously test_24D: LU-6101
1189 # readdir() returns correct number of entries after cursor reload
1190 local num_ls=$(ls $DIR/$tdir | wc -l)
1191 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1192 local num_all=$(ls -a $DIR/$tdir | wc -l)
1193 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1194 $num_all -ne $((nrfiles + 2)) ]; then
1195 error "Expected $nrfiles files, got $num_ls " \
1196 "($num_uniq unique $num_all .&..)"
1198 # LU-5 large readdir
1199 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1200 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1201 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1202 # take into account of overhead in lu_dirpage header and end mark in
1203 # each page, plus one in rpc_num calculation.
1204 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1205 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1206 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1207 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1208 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1209 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1210 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1211 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1212 error "large readdir doesn't take effect: " \
1213 "$mds_readpage should be about $rpc_max"
1215 simple_cleanup_common
1217 run_test 24v "list large directory (test hash collision, b=17560)"
1219 test_24w() { # bug21506
1221 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1222 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1223 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1224 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1225 [[ "$SZ1" -eq "$SZ2" ]] ||
1226 error "Error reading at the end of the file $tfile"
1228 run_test 24w "Reading a file larger than 4Gb"
1231 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1233 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1234 skip "Need MDS version at least 2.7.56"
1237 local remote_dir=$DIR/$tdir/remote_dir
1239 test_mkdir $DIR/$tdir
1240 $LFS mkdir -i $MDTIDX $remote_dir ||
1241 error "create remote directory failed"
1243 test_mkdir $DIR/$tdir/src_dir
1244 touch $DIR/$tdir/src_file
1245 test_mkdir $remote_dir/tgt_dir
1246 touch $remote_dir/tgt_file
1248 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1249 error "rename dir cross MDT failed!"
1251 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1252 error "rename file cross MDT failed!"
1254 touch $DIR/$tdir/ln_file
1255 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1256 error "ln file cross MDT failed"
1258 rm -rf $DIR/$tdir || error "Can not delete directories"
1260 run_test 24x "cross MDT rename/link"
1263 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1264 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1266 local remote_dir=$DIR/$tdir/remote_dir
1269 test_mkdir $DIR/$tdir
1270 $LFS mkdir -i $mdtidx $remote_dir ||
1271 error "create remote directory failed"
1273 test_mkdir $remote_dir/src_dir
1274 touch $remote_dir/src_file
1275 test_mkdir $remote_dir/tgt_dir
1276 touch $remote_dir/tgt_file
1278 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1279 error "rename subdir in the same remote dir failed!"
1281 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1282 error "rename files in the same remote dir failed!"
1284 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1285 error "link files in the same remote dir failed!"
1287 rm -rf $DIR/$tdir || error "Can not delete directories"
1289 run_test 24y "rename/link on the same dir should succeed"
1292 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1293 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1294 skip "Need MDS version at least 2.12.51"
1298 for index in 0 1; do
1299 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1300 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1303 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1305 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1306 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1308 local mdts=$(comma_list $(mdts_nodes))
1310 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1311 stack_trap "do_nodes $mdts $LCTL \
1312 set_param mdt.*.enable_remote_rename=1" EXIT
1314 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1316 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1317 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1319 run_test 24z "cross-MDT rename is done as cp"
1321 test_24A() { # LU-3182
1325 test_mkdir $DIR/$tdir
1326 trap simple_cleanup_common EXIT
1327 createmany -m $DIR/$tdir/$tfile $NFILES
1328 local t=$(ls $DIR/$tdir | wc -l)
1329 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1330 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1331 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1332 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1335 simple_cleanup_common || error "Can not delete directories"
1337 run_test 24A "readdir() returns correct number of entries."
1339 test_24B() { # LU-4805
1340 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1344 test_mkdir $DIR/$tdir
1345 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1346 error "create striped dir failed"
1348 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1349 [ $count -eq 2 ] || error "Expected 2, got $count"
1351 touch $DIR/$tdir/striped_dir/a
1353 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1354 [ $count -eq 3 ] || error "Expected 3, got $count"
1356 touch $DIR/$tdir/striped_dir/.f
1358 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1359 [ $count -eq 4 ] || error "Expected 4, got $count"
1361 rm -rf $DIR/$tdir || error "Can not delete directories"
1363 run_test 24B "readdir for striped dir return correct number of entries"
1366 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1372 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1373 error "create striped dir failed"
1375 cd $DIR/$tdir/d0/striped_dir
1377 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1378 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1379 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1381 [ "$d0_ino" = "$parent_ino" ] ||
1382 error ".. wrong, expect $d0_ino, get $parent_ino"
1384 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1385 error "mv striped dir failed"
1387 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1389 [ "$d1_ino" = "$parent_ino" ] ||
1390 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1392 run_test 24C "check .. in striped dir"
1395 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1399 mkdir $DIR/$tdir/src_dir
1400 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1401 error "create remote source failed"
1403 touch $DIR/$tdir/src_dir/src_child/a
1405 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1406 error "create remote target dir failed"
1408 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1409 error "create remote target child failed"
1411 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1412 error "rename dir cross MDT failed!"
1416 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1417 error "src_child still exists after rename"
1419 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1420 error "missing file(a) after rename"
1422 rm -rf $DIR/$tdir || error "Can not delete directories"
1424 run_test 24E "cross MDT rename/link"
1427 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1430 [ "$SLOW" = "no" ] && repeats=100
1434 echo "$repeats repeats"
1435 for ((i = 0; i < repeats; i++)); do
1436 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1437 touch $DIR/$tdir/test/a || error "touch fails"
1438 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1439 rm -rf $DIR/$tdir/test || error "rmdir fails"
1444 run_test 24F "hash order vs readdir (LU-11330)"
1447 echo '== symlink sanity ============================================='
1451 touch $DIR/s25/foo ||
1452 error "File creation in symlinked directory failed"
1454 run_test 25a "create file in symlinked directory ==============="
1457 [ ! -d $DIR/d25 ] && test_25a
1458 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1460 run_test 25b "lookup file in symlinked directory ==============="
1464 test_mkdir $DIR/d26/d26-2
1465 ln -s d26/d26-2 $DIR/s26
1466 touch $DIR/s26/foo || error "File creation failed"
1468 run_test 26a "multiple component symlink ======================="
1471 test_mkdir -p $DIR/$tdir/d26-2
1472 ln -s $tdir/d26-2/foo $DIR/s26-2
1473 touch $DIR/s26-2 || error "File creation failed"
1475 run_test 26b "multiple component symlink at end of lookup ======"
1478 test_mkdir $DIR/d26.2
1479 touch $DIR/d26.2/foo
1480 ln -s d26.2 $DIR/s26.2-1
1481 ln -s s26.2-1 $DIR/s26.2-2
1482 ln -s s26.2-2 $DIR/s26.2-3
1483 chmod 0666 $DIR/s26.2-3/foo
1485 run_test 26c "chain of symlinks"
1487 # recursive symlinks (bug 439)
1489 ln -s d26-3/foo $DIR/d26-3
1491 run_test 26d "create multiple component recursive symlink"
1494 [ ! -h $DIR/d26-3 ] && test_26d
1497 run_test 26e "unlink multiple component recursive symlink"
1499 # recursive symlinks (bug 7022)
1501 test_mkdir $DIR/$tdir
1502 test_mkdir $DIR/$tdir/$tfile
1503 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1504 test_mkdir -p lndir/bar1
1505 test_mkdir $DIR/$tdir/$tfile/$tfile
1506 cd $tfile || error "cd $tfile failed"
1507 ln -s .. dotdot || error "ln dotdot failed"
1508 ln -s dotdot/lndir lndir || error "ln lndir failed"
1509 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1510 output=`ls $tfile/$tfile/lndir/bar1`
1511 [ "$output" = bar1 ] && error "unexpected output"
1512 rm -r $tfile || error "rm $tfile failed"
1513 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1515 run_test 26f "rm -r of a directory which has recursive symlink"
1518 test_mkdir $DIR/$tdir
1519 $LFS getstripe $DIR/$tdir
1520 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1521 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1522 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1524 run_test 27a "one stripe file"
1527 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1529 test_mkdir $DIR/$tdir
1530 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1531 $LFS getstripe -c $DIR/$tdir/$tfile
1532 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1533 error "two-stripe file doesn't have two stripes"
1535 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1537 run_test 27b "create and write to two stripe file"
1540 test_mkdir $DIR/$tdir
1541 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1542 error "setstripe failed"
1543 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1544 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1546 run_test 27d "create file with default settings"
1549 # LU-5839 adds check for existed layout before setting it
1550 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1551 skip "Need MDS version at least 2.7.56"
1553 test_mkdir $DIR/$tdir
1554 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1555 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1556 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1558 run_test 27e "setstripe existing file (should return error)"
1561 test_mkdir $DIR/$tdir
1562 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1563 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1564 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1565 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1566 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1567 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1569 run_test 27f "setstripe with bad stripe size (should return error)"
1572 test_mkdir $DIR/$tdir
1573 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1574 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1575 error "$DIR/$tdir/$tfile has object"
1577 run_test 27g "$LFS getstripe with no objects"
1580 test_mkdir $DIR/$tdir
1581 touch $DIR/$tdir/$tfile || error "touch failed"
1582 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1583 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1585 (( rc == 2 )) || error "getstripe did not return ENOENT"
1587 run_test 27ga "$LFS getstripe with missing file (should return error)"
1590 test_mkdir $DIR/$tdir
1591 touch $DIR/$tdir/$tfile || error "touch failed"
1592 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1593 error "missing objects"
1595 run_test 27i "$LFS getstripe with some objects"
1598 test_mkdir $DIR/$tdir
1599 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1600 error "setstripe failed" || true
1602 run_test 27j "setstripe with bad stripe offset (should return error)"
1604 test_27k() { # bug 2844
1605 test_mkdir $DIR/$tdir
1606 local file=$DIR/$tdir/$tfile
1607 local ll_max_blksize=$((4 * 1024 * 1024))
1608 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1609 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1610 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1611 dd if=/dev/zero of=$file bs=4k count=1
1612 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1613 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1615 run_test 27k "limit i_blksize for broken user apps"
1618 mcreate $DIR/$tfile || error "creating file"
1619 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1620 error "setstripe should have failed" || true
1622 run_test 27l "check setstripe permissions (should return error)"
1625 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1627 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1629 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1630 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1632 trap simple_cleanup_common EXIT
1633 test_mkdir $DIR/$tdir
1634 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1635 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1636 error "dd should fill OST0"
1638 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1640 [ $i -gt 256 ] && break
1643 touch $DIR/$tdir/$tfile.$i
1644 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1645 awk '{print $1}'| grep -w "0") ] &&
1646 error "OST0 was full but new created file still use it"
1648 touch $DIR/$tdir/$tfile.$i
1649 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1650 awk '{print $1}'| grep -w "0") ] &&
1651 error "OST0 was full but new created file still use it"
1652 simple_cleanup_common
1654 run_test 27m "create file while OST0 was full"
1657 local delay=$(do_facet $SINGLEMDS lctl get_param -n lo[vd].*.qos_maxage |
1658 awk '{ print $1 * 2; exit; }')
1662 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1663 # if the OST isn't full anymore.
1665 local OSTIDX=${1:-""}
1667 local list=$(comma_list $(osts_nodes))
1668 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1670 do_nodes $list lctl set_param fail_loc=0
1671 sync # initiate all OST_DESTROYs from MDS to OST
1675 exhaust_precreations() {
1678 local FAILIDX=${3:-$OSTIDX}
1679 local ofacet=ost$((OSTIDX + 1))
1681 test_mkdir -p -c1 $DIR/$tdir
1682 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1683 local mfacet=mds$((mdtidx + 1))
1684 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1686 local OST=$(ostname_from_index $OSTIDX)
1689 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1690 local last_id=$(do_facet $mfacet lctl get_param -n \
1691 osp.$mdtosc_proc1.prealloc_last_id)
1692 local next_id=$(do_facet $mfacet lctl get_param -n \
1693 osp.$mdtosc_proc1.prealloc_next_id)
1695 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1696 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1698 test_mkdir -p $DIR/$tdir/${OST}
1699 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1700 #define OBD_FAIL_OST_ENOSPC 0x215
1701 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1702 echo "Creating to objid $last_id on ost $OST..."
1703 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1704 do_facet $mfacet lctl get_param osp.$mdtosc_proc2.prealloc*
1705 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1709 exhaust_all_precreations() {
1711 for (( i=0; i < OSTCOUNT; i++ )) ; do
1712 exhaust_precreations $i $1 -1
1717 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1718 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1719 remote_mds_nodsh && skip "remote MDS with nodsh"
1720 remote_ost_nodsh && skip "remote OST with nodsh"
1723 rm -f $DIR/$tdir/$tfile
1724 exhaust_precreations 0 0x80000215
1725 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1726 touch $DIR/$tdir/$tfile || error "touch failed"
1727 $LFS getstripe $DIR/$tdir/$tfile
1730 run_test 27n "create file with some full OSTs"
1733 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1735 remote_mds_nodsh && skip "remote MDS with nodsh"
1736 remote_ost_nodsh && skip "remote OST with nodsh"
1739 rm -f $DIR/$tdir/$tfile
1740 exhaust_all_precreations 0x215
1742 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1747 run_test 27o "create file with all full OSTs (should error)"
1750 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1751 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1752 remote_mds_nodsh && skip "remote MDS with nodsh"
1753 remote_ost_nodsh && skip "remote OST with nodsh"
1756 rm -f $DIR/$tdir/$tfile
1757 test_mkdir $DIR/$tdir
1759 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1760 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1761 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1763 exhaust_precreations 0 0x80000215
1764 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1765 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1766 $LFS getstripe $DIR/$tdir/$tfile
1770 run_test 27p "append to a truncated file with some full OSTs"
1773 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1774 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1775 remote_mds_nodsh && skip "remote MDS with nodsh"
1776 remote_ost_nodsh && skip "remote OST with nodsh"
1779 rm -f $DIR/$tdir/$tfile
1781 test_mkdir $DIR/$tdir
1782 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1783 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1784 error "truncate $DIR/$tdir/$tfile failed"
1785 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1787 exhaust_all_precreations 0x215
1789 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1790 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1794 run_test 27q "append to truncated file with all OSTs full (should error)"
1797 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1798 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1799 remote_mds_nodsh && skip "remote MDS with nodsh"
1800 remote_ost_nodsh && skip "remote OST with nodsh"
1803 rm -f $DIR/$tdir/$tfile
1804 exhaust_precreations 0 0x80000215
1806 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1810 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1812 test_27s() { # bug 10725
1813 test_mkdir $DIR/$tdir
1814 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1815 local stripe_count=0
1816 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1817 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1818 error "stripe width >= 2^32 succeeded" || true
1821 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1823 test_27t() { # bug 10864
1828 $WLFS getstripe $tfile
1831 run_test 27t "check that utils parse path correctly"
1833 test_27u() { # bug 4900
1834 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1835 remote_mds_nodsh && skip "remote MDS with nodsh"
1838 local list=$(comma_list $(mdts_nodes))
1840 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1841 do_nodes $list $LCTL set_param fail_loc=0x139
1842 test_mkdir -p $DIR/$tdir
1843 trap simple_cleanup_common EXIT
1844 createmany -o $DIR/$tdir/t- 1000
1845 do_nodes $list $LCTL set_param fail_loc=0
1847 TLOG=$TMP/$tfile.getstripe
1848 $LFS getstripe $DIR/$tdir > $TLOG
1849 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1850 unlinkmany $DIR/$tdir/t- 1000
1852 [[ $OBJS -gt 0 ]] &&
1853 error "$OBJS objects created on OST-0. See $TLOG" ||
1856 run_test 27u "skip object creation on OSC w/o objects"
1858 test_27v() { # bug 4900
1859 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1860 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1861 remote_mds_nodsh && skip "remote MDS with nodsh"
1862 remote_ost_nodsh && skip "remote OST with nodsh"
1864 exhaust_all_precreations 0x215
1867 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1869 touch $DIR/$tdir/$tfile
1870 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1872 for (( i=1; i < OSTCOUNT; i++ )); do
1873 do_facet ost$i lctl set_param fail_loc=0x705
1875 local START=`date +%s`
1876 createmany -o $DIR/$tdir/$tfile 32
1878 local FINISH=`date +%s`
1879 local TIMEOUT=`lctl get_param -n timeout`
1880 local PROCESS=$((FINISH - START))
1881 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1882 error "$FINISH - $START >= $TIMEOUT / 2"
1883 sleep $((TIMEOUT / 2 - PROCESS))
1886 run_test 27v "skip object creation on slow OST"
1888 test_27w() { # bug 10997
1889 test_mkdir $DIR/$tdir
1890 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1891 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1892 error "stripe size $size != 65536" || true
1893 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1894 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1896 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1899 [[ $OSTCOUNT -lt 2 ]] &&
1900 skip_env "skipping multiple stripe count/offset test"
1902 test_mkdir $DIR/$tdir
1903 for i in $(seq 1 $OSTCOUNT); do
1905 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1906 error "setstripe -c $i -i $offset failed"
1907 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1908 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1909 [ $count -ne $i ] && error "stripe count $count != $i" || true
1910 [ $index -ne $offset ] &&
1911 error "stripe offset $index != $offset" || true
1914 run_test 27wa "check $LFS setstripe -c -i options"
1917 remote_ost_nodsh && skip "remote OST with nodsh"
1918 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1919 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1921 OFFSET=$(($OSTCOUNT - 1))
1923 local OST=$(ostname_from_index $OSTIDX)
1925 test_mkdir $DIR/$tdir
1926 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1927 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1929 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1930 for i in $(seq 0 $OFFSET); do
1931 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1932 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1933 error "OST0 was degraded but new created file still use it"
1935 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1937 run_test 27x "create files while OST0 is degraded"
1940 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1941 remote_mds_nodsh && skip "remote MDS with nodsh"
1942 remote_ost_nodsh && skip "remote OST with nodsh"
1943 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1945 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1946 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1947 osp.$mdtosc.prealloc_last_id)
1948 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1949 osp.$mdtosc.prealloc_next_id)
1950 local fcount=$((last_id - next_id))
1951 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1952 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1954 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1955 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1956 local OST_DEACTIVE_IDX=-1
1961 for OSC in $MDS_OSCS; do
1962 OST=$(osc_to_ost $OSC)
1963 OSTIDX=$(index_from_ostuuid $OST)
1964 if [ $OST_DEACTIVE_IDX == -1 ]; then
1965 OST_DEACTIVE_IDX=$OSTIDX
1967 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1968 echo $OSC "is Deactivated:"
1969 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1973 OSTIDX=$(index_from_ostuuid $OST)
1974 test_mkdir $DIR/$tdir
1975 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1977 for OSC in $MDS_OSCS; do
1978 OST=$(osc_to_ost $OSC)
1979 OSTIDX=$(index_from_ostuuid $OST)
1980 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1981 echo $OST "is degraded:"
1982 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1983 obdfilter.$OST.degraded=1
1988 createmany -o $DIR/$tdir/$tfile $fcount
1990 for OSC in $MDS_OSCS; do
1991 OST=$(osc_to_ost $OSC)
1992 OSTIDX=$(index_from_ostuuid $OST)
1993 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1994 echo $OST "is recovered from degraded:"
1995 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1996 obdfilter.$OST.degraded=0
1998 do_facet $SINGLEMDS lctl --device %$OSC activate
2002 # all osp devices get activated, hence -1 stripe count restored
2003 local stripe_count=0
2005 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2006 # devices get activated.
2008 $LFS setstripe -c -1 $DIR/$tfile
2009 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2011 [ $stripe_count -ne $OSTCOUNT ] &&
2012 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2015 run_test 27y "create files while OST0 is degraded and the rest inactive"
2021 lmm_count=$($GETSTRIPE -c $1)
2022 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
2023 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
2025 local old_ifs="$IFS"
2027 fid=($($LFS path2fid $1))
2030 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2031 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2033 # compare lmm_seq and lu_fid->f_seq
2034 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2035 # compare lmm_object_id and lu_fid->oid
2036 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2038 # check the trusted.fid attribute of the OST objects of the file
2039 local have_obdidx=false
2041 $GETSTRIPE $1 | while read obdidx oid hex seq; do
2042 # skip lines up to and including "obdidx"
2043 [ -z "$obdidx" ] && break
2044 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2045 $have_obdidx || continue
2047 local ost=$((obdidx + 1))
2048 local dev=$(ostdevname $ost)
2051 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2053 seq=$(echo $seq | sed -e "s/^0x//g")
2054 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2055 oid_hex=$(echo $oid)
2057 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2059 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2063 # Don't unmount/remount the OSTs if we don't need to do that.
2064 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2065 # update too, until that use mount/ll_decode_filter_fid/mount.
2066 # Re-enable when debugfs will understand new filter_fid.
2068 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2069 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2070 $dev 2>/dev/null" | grep "parent=")
2072 if [ -z "$ff" ]; then
2074 mount_fstype ost$ost
2075 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2076 $(facet_mntpt ost$ost)/$obj_file)
2077 unmount_fstype ost$ost
2078 start ost$ost $dev $OST_MOUNT_OPTS
2082 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2084 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2086 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2087 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2089 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2090 # stripe_size=1048576 component_id=1 component_start=0 \
2091 # component_end=33554432
2092 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2093 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2094 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2096 if grep -q 'stripe=' <<<$ff; then
2097 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2099 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2100 # into f_ver in this case. See comment on ff_parent.
2101 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2104 # compare lmm_seq and filter_fid->ff_parent.f_seq
2105 [ $ff_pseq = $lmm_seq ] ||
2106 error "FF parent SEQ $ff_pseq != $lmm_seq"
2107 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2108 [ $ff_poid = $lmm_oid ] ||
2109 error "FF parent OID $ff_poid != $lmm_oid"
2110 (($ff_pstripe == $stripe_nr)) ||
2111 error "FF stripe $ff_pstripe != $stripe_nr"
2113 stripe_nr=$((stripe_nr + 1))
2114 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2116 if grep -q 'stripe_count=' <<<$ff; then
2117 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2118 -e 's/ .*//' <<<$ff)
2119 [ $lmm_count = $ff_scnt ] ||
2120 error "FF stripe count $lmm_count != $ff_scnt"
2126 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2127 remote_ost_nodsh && skip "remote OST with nodsh"
2129 test_mkdir $DIR/$tdir
2130 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2131 { error "setstripe -c -1 failed"; return 1; }
2132 # We need to send a write to every object to get parent FID info set.
2133 # This _should_ also work for setattr, but does not currently.
2134 # touch $DIR/$tdir/$tfile-1 ||
2135 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2136 { error "dd $tfile-1 failed"; return 2; }
2137 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2138 { error "setstripe -c -1 failed"; return 3; }
2139 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2140 { error "dd $tfile-2 failed"; return 4; }
2142 # make sure write RPCs have been sent to OSTs
2145 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2146 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2148 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2150 test_27A() { # b=19102
2151 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2153 save_layout_restore_at_exit $MOUNT
2154 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2155 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2156 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2157 local default_size=$($GETSTRIPE -S $MOUNT)
2158 local default_offset=$($GETSTRIPE -i $MOUNT)
2159 local dsize=$(do_facet $SINGLEMDS \
2160 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2161 [ $default_size -eq $dsize ] ||
2162 error "stripe size $default_size != $dsize"
2163 [ $default_offset -eq -1 ] ||
2164 error "stripe offset $default_offset != -1"
2166 run_test 27A "check filesystem-wide default LOV EA values"
2168 test_27B() { # LU-2523
2169 test_mkdir $DIR/$tdir
2170 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2172 # open f1 with O_LOV_DELAY_CREATE
2174 # call setstripe ioctl on open file descriptor for f1
2176 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2180 # open f1 with O_LOV_DELAY_CREATE
2182 # call setstripe ioctl on open file descriptor for f1
2184 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2186 # Allow multiop to fail in imitation of NFS's busted semantics.
2189 run_test 27B "call setstripe on open unlinked file/rename victim"
2191 test_27C() { #LU-2871
2192 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2200 test_mkdir $DIR/$tdir
2202 for i in $(seq 0 $((OSTCOUNT - 1))); do
2203 # set stripe across all OSTs starting from OST$i
2204 $SETSTRIPE -i $i -c -1 $tfile$i
2205 # get striping information
2206 ost_idx=($($GETSTRIPE $tfile$i |
2207 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2211 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2212 error "${#ost_idx[@]} != $OSTCOUNT"
2214 for index in $(seq 0 $((OSTCOUNT - 1))); do
2216 for j in $(echo ${ost_idx[@]}); do
2217 if [ $index -eq $j ]; then
2223 error "Can not find $index in ${ost_idx[@]}"
2227 run_test 27C "check full striping across all OSTs"
2230 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2231 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2232 remote_mds_nodsh && skip "remote MDS with nodsh"
2234 local POOL=${POOL:-testpool}
2236 local last_ost=$(($OSTCOUNT - 1))
2238 local ost_list=$(seq $first_ost $ost_step $last_ost)
2239 local ost_range="$first_ost $last_ost $ost_step"
2241 test_mkdir $DIR/$tdir
2242 pool_add $POOL || error "pool_add failed"
2243 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2246 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2248 [ $MDS1_VERSION -lt $(version_code 2.9.55) -o \
2249 $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2250 skip27D+=" -s 30,31"
2251 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2252 error "llapi_layout_test failed"
2254 destroy_test_pools || error "destroy test pools failed"
2256 run_test 27D "validate llapi_layout API"
2258 # Verify that default_easize is increased from its initial value after
2259 # accessing a widely striped file.
2261 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2262 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2263 skip "client does not have LU-3338 fix"
2265 # 72 bytes is the minimum space required to store striping
2266 # information for a file striped across one OST:
2267 # (sizeof(struct lov_user_md_v3) +
2268 # sizeof(struct lov_user_ost_data_v1))
2270 $LCTL set_param -n llite.*.default_easize $min_easize ||
2271 error "lctl set_param failed"
2272 local easize=$($LCTL get_param -n llite.*.default_easize)
2274 [ $easize -eq $min_easize ] ||
2275 error "failed to set default_easize"
2277 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2278 error "setstripe failed"
2282 easize=$($LCTL get_param -n llite.*.default_easize)
2284 [ $easize -gt $min_easize ] ||
2285 error "default_easize not updated"
2287 run_test 27E "check that default extended attribute size properly increases"
2289 test_27F() { # LU-5346/LU-7975
2290 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2291 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2292 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2293 skip "Need MDS version at least 2.8.51"
2294 remote_ost_nodsh && skip "remote OST with nodsh"
2296 test_mkdir $DIR/$tdir
2298 $SETSTRIPE -c 2 $DIR/$tdir
2300 # stop all OSTs to reproduce situation for LU-7975 ticket
2301 for num in $(seq $OSTCOUNT); do
2305 # open/create f0 with O_LOV_DELAY_CREATE
2306 # truncate f0 to a non-0 size
2308 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2310 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2311 # open/write it again to force delayed layout creation
2312 cat /etc/hosts > $DIR/$tdir/f0 &
2316 for num in $(seq $OSTCOUNT); do
2317 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2318 error "ost$num failed to start"
2321 wait $catpid || error "cat failed"
2323 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2324 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2327 run_test 27F "Client resend delayed layout creation with non-zero size"
2329 test_27G() { #LU-10629
2330 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2331 skip "Need MDS version at least 2.11.51"
2332 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2333 remote_mds_nodsh && skip "remote MDS with nodsh"
2334 local POOL=${POOL:-testpool}
2335 local ostrange="0 0 1"
2337 test_mkdir $DIR/$tdir
2338 pool_add $POOL || error "pool_add failed"
2339 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2340 $LFS setstripe -p $POOL $DIR/$tdir
2342 local pool=$($LFS getstripe -p $DIR/$tdir)
2344 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2346 $LFS setstripe -d $DIR/$tdir
2348 pool=$($LFS getstripe -p $DIR/$tdir)
2352 [ -z "$pool" ] || error "'$pool' is not empty"
2354 run_test 27G "Clear OST pool from stripe"
2357 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2358 skip "Need MDS version newer than 2.11.54"
2359 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2360 test_mkdir $DIR/$tdir
2361 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2362 touch $DIR/$tdir/$tfile
2363 $LFS getstripe -c $DIR/$tdir/$tfile
2364 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2365 error "two-stripe file doesn't have two stripes"
2367 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2368 $LFS getstripe -y $DIR/$tdir/$tfile
2369 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2370 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2371 error "expected l_ost_idx: [02]$ not matched"
2373 # make sure ost list have been cleared
2374 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2375 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2376 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2378 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2380 run_test 27H "Set specific OSTs stripe"
2383 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.57) ]] &&
2384 skip "Need MDS version >= than 2.12.57"
2385 remote_mds_nodsh && skip "remote MDS with nodsh"
2386 [[ $OSTCOUNT -lt 2 ]] && skip_env "need > 1 OST"
2388 test_mkdir $DIR/$tdir
2390 # Set default striping on directory
2391 $LFS setstripe -C 4 $DIR/$tdir
2393 echo 1 > $DIR/$tdir/${tfile}.1
2394 local count=$($LFS getstripe -c $DIR/$tdir/${tfile}.1)
2396 [ $count -eq $setcount ] ||
2397 error "(1) stripe count $count, should be $setcount"
2399 # Capture existing append_stripe_count setting for restore
2400 local orig_count=$(do_facet mds1 $LCTL get_param -n mdd.$FSNAME-MDT0000.append_stripe_count)
2401 local mdts=$(comma_list $(mdts_nodes))
2402 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=$orig_count" EXIT
2404 local appendcount=$orig_count
2405 echo 1 >> $DIR/$tdir/${tfile}.2_append
2406 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.2_append)
2407 [ $count -eq $appendcount ] ||
2408 error "(2)stripe count $count, should be $appendcount for append"
2410 # Disable O_APPEND striping, verify it works
2411 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2413 # Should now get the default striping, which is 4
2415 echo 1 >> $DIR/$tdir/${tfile}.3_append
2416 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.3_append)
2417 [ $count -eq $setcount ] ||
2418 error "(3) stripe count $count, should be $setcount"
2420 # Try changing the stripe count for append files
2421 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=2
2423 # Append striping is now 2 (directory default is still 4)
2425 echo 1 >> $DIR/$tdir/${tfile}.4_append
2426 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.4_append)
2427 [ $count -eq $appendcount ] ||
2428 error "(4) stripe count $count, should be $appendcount for append"
2430 # Test append stripe count of -1
2431 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=-1
2432 appendcount=$OSTCOUNT
2433 echo 1 >> $DIR/$tdir/${tfile}.5
2434 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.5)
2435 [ $count -eq $appendcount ] ||
2436 error "(5) stripe count $count, should be $appendcount for append"
2438 # Set append striping back to default of 1
2439 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=1
2441 # Try a new default striping, PFL + DOM
2442 $LFS setstripe -L mdt -E 1M -E -1 -c 2 $DIR/$tdir
2444 # Create normal DOM file, DOM returns stripe count == 0
2446 touch $DIR/$tdir/${tfile}.6
2447 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.6)
2448 [ $count -eq $setcount ] ||
2449 error "(6) stripe count $count, should be $setcount"
2453 echo 1 >> $DIR/$tdir/${tfile}.7_append
2454 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.7_append)
2455 [ $count -eq $appendcount ] ||
2456 error "(7) stripe count $count, should be $appendcount for append"
2458 # Clean up DOM layout
2459 $LFS setstripe -d $DIR/$tdir
2461 # Now test that append striping works when layout is from root
2462 $LFS setstripe -c 2 $MOUNT
2463 # Make a special directory for this
2464 mkdir $DIR/${tdir}/${tdir}.2
2465 stack_trap "$LFS setstripe -d $MOUNT" EXIT
2467 # Verify for normal file
2469 echo 1 > $DIR/${tdir}/${tdir}.2/${tfile}.8
2470 count=$($LFS getstripe -c $DIR/$tdir/${tdir}.2/${tfile}.8)
2471 [ $count -eq $setcount ] ||
2472 error "(8) stripe count $count, should be $setcount"
2475 echo 1 >> $DIR/${tdir}/${tdir}.2/${tfile}.9_append
2476 count=$($LFS getstripe -c $DIR/${tdir}/${tdir}.2/${tfile}.9_append)
2477 [ $count -eq $appendcount ] ||
2478 error "(9) stripe count $count, should be $appendcount for append"
2480 # Now test O_APPEND striping with pools
2481 do_nodes $mdts $LCTL set_param mdd.*.append_pool="$TESTNAME"
2482 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'" EXIT
2485 pool_add $TESTNAME || error "pool creation failed"
2486 pool_add_targets $TESTNAME 0 1 || error "Pool add targets failed"
2488 echo 1 >> $DIR/$tdir/${tfile}.10_append
2490 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.10_append)
2491 [ "$pool" = "$TESTNAME" ] || error "(10) incorrect pool: $pool"
2493 # Check that count is still correct
2495 echo 1 >> $DIR/$tdir/${tfile}.11_append
2496 count=$($LFS getstripe -c $DIR/$tdir/${tfile}.11_append)
2497 [ $count -eq $appendcount ] ||
2498 error "(11) stripe count $count, should be $appendcount for append"
2500 # Disable O_APPEND stripe count, verify pool works separately
2501 do_nodes $mdts $LCTL set_param mdd.*.append_stripe_count=0
2503 echo 1 >> $DIR/$tdir/${tfile}.12_append
2505 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.12_append)
2506 [ "$pool" = "$TESTNAME" ] || error "(12) incorrect pool: $pool"
2508 # Remove pool setting, verify it's not applied
2509 do_nodes $mdts $LCTL set_param mdd.*.append_pool='none'
2511 echo 1 >> $DIR/$tdir/${tfile}.13_append
2513 pool=$($LFS getstripe -p $DIR/$tdir/${tfile}.13_append)
2514 [ "$pool" = "" ] || error "(13) pool found: $pool"
2516 run_test 27M "test O_APPEND striping"
2518 # createtest also checks that device nodes are created and
2519 # then visible correctly (#2091)
2520 test_28() { # bug 2091
2522 $CREATETEST $DIR/d28/ct || error "createtest failed"
2524 run_test 28 "create/mknod/mkdir with bad file types ============"
2527 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2529 sync; sleep 1; sync # flush out any dirty pages from previous tests
2536 declare -i LOCKCOUNTORIG=0
2537 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2538 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2540 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2542 declare -i LOCKUNUSEDCOUNTORIG=0
2543 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2544 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2551 declare -i LOCKCOUNTCURRENT=0
2552 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2553 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2556 declare -i LOCKUNUSEDCOUNTCURRENT=0
2557 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2558 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2561 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2562 $LCTL set_param -n ldlm.dump_namespaces ""
2563 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2564 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2565 log "dumped log to $TMP/test_29.dk (bug 5793)"
2568 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2569 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2570 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2571 log "dumped log to $TMP/test_29.dk (bug 5793)"
2575 run_test 29 "IT_GETATTR regression ============================"
2577 test_30a() { # was test_30
2578 cp $(which ls) $DIR || cp /bin/ls $DIR
2579 $DIR/ls / || error "Can't execute binary from lustre"
2582 run_test 30a "execute binary from Lustre (execve) =============="
2585 cp `which ls` $DIR || cp /bin/ls $DIR
2587 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2590 run_test 30b "execute binary from Lustre as non-root ==========="
2592 test_30c() { # b=22376
2593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2595 cp `which ls` $DIR || cp /bin/ls $DIR
2597 cancel_lru_locks mdc
2598 cancel_lru_locks osc
2599 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2602 run_test 30c "execute binary from Lustre without read perms ===="
2605 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2606 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2608 run_test 31a "open-unlink file =================================="
2611 touch $DIR/f31 || error "touch $DIR/f31 failed"
2612 ln $DIR/f31 $DIR/f31b || error "ln failed"
2613 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2614 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2616 run_test 31b "unlink file with multiple links while open ======="
2619 touch $DIR/f31 || error "touch $DIR/f31 failed"
2620 ln $DIR/f31 $DIR/f31c || error "ln failed"
2621 multiop_bg_pause $DIR/f31 O_uc ||
2622 error "multiop_bg_pause for $DIR/f31 failed"
2624 $MULTIOP $DIR/f31c Ouc
2625 kill -USR1 $MULTIPID
2628 run_test 31c "open-unlink file with multiple links ============="
2631 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2632 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2634 run_test 31d "remove of open directory ========================="
2636 test_31e() { # bug 2904
2637 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2639 run_test 31e "remove of open non-empty directory ==============="
2641 test_31f() { # bug 4554
2642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2645 test_mkdir $DIR/d31f
2646 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2647 cp /etc/hosts $DIR/d31f
2649 $GETSTRIPE $DIR/d31f/hosts
2650 multiop_bg_pause $DIR/d31f D_c || return 1
2653 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2654 test_mkdir $DIR/d31f
2655 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2656 cp /etc/hosts $DIR/d31f
2658 $GETSTRIPE $DIR/d31f/hosts
2659 multiop_bg_pause $DIR/d31f D_c || return 1
2662 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2663 wait $MULTIPID || error "first opendir $MULTIPID failed"
2667 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2668 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2671 run_test 31f "remove of open directory with open-unlink file ==="
2674 echo "-- cross directory link --"
2675 test_mkdir -c1 $DIR/${tdir}ga
2676 test_mkdir -c1 $DIR/${tdir}gb
2677 touch $DIR/${tdir}ga/f
2678 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2679 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2680 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2681 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2682 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2684 run_test 31g "cross directory link==============="
2687 echo "-- cross directory link --"
2688 test_mkdir -c1 $DIR/${tdir}
2689 test_mkdir -c1 $DIR/${tdir}/dir
2690 touch $DIR/${tdir}/f
2691 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2692 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2693 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2694 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2695 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2697 run_test 31h "cross directory link under child==============="
2700 echo "-- cross directory link --"
2701 test_mkdir -c1 $DIR/$tdir
2702 test_mkdir -c1 $DIR/$tdir/dir
2703 touch $DIR/$tdir/dir/f
2704 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2705 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2706 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2707 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2708 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2710 run_test 31i "cross directory link under parent==============="
2713 test_mkdir -c1 -p $DIR/$tdir
2714 test_mkdir -c1 -p $DIR/$tdir/dir1
2715 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2716 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2717 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2718 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2721 run_test 31j "link for directory==============="
2724 test_mkdir -c1 -p $DIR/$tdir
2726 touch $DIR/$tdir/exist
2727 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2728 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2729 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2730 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2731 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2732 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2733 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2736 run_test 31k "link to file: the same, non-existing, dir==============="
2742 touch $DIR/d31m2/exist
2743 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2744 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2745 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2746 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2747 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2748 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2751 run_test 31m "link to file: the same, non-existing, dir==============="
2754 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2755 nlink=$(stat --format=%h $DIR/$tfile)
2756 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2758 local cmd="exec $fd<$DIR/$tfile"
2761 trap "eval $cmd" EXIT
2762 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2763 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2764 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2765 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2766 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2769 run_test 31n "check link count of unlinked file"
2772 local TEMPNAME=$(mktemp $1_XXXXXX)
2773 mlink $TEMPNAME $1 2> /dev/null &&
2774 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2778 test_31o() { # LU-2901
2779 test_mkdir $DIR/$tdir
2780 for LOOP in $(seq 100); do
2781 rm -f $DIR/$tdir/$tfile*
2782 for THREAD in $(seq 8); do
2783 link_one $DIR/$tdir/$tfile.$LOOP &
2786 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2787 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2788 error "$LINKS duplicate links to $tfile.$LOOP" &&
2792 run_test 31o "duplicate hard links with same filename"
2795 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2797 test_mkdir $DIR/$tdir
2798 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2799 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2801 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2802 error "open unlink test1 failed"
2803 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2804 error "open unlink test2 failed"
2806 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2807 error "test1 still exists"
2808 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2809 error "test2 still exists"
2811 run_test 31p "remove of open striped directory"
2813 cleanup_test32_mount() {
2816 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2817 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2818 losetup -d $loopdev || true
2824 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2826 echo "== more mountpoints and symlinks ================="
2827 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2828 trap cleanup_test32_mount EXIT
2829 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2830 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2831 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2832 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2833 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2834 cleanup_test32_mount
2836 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2839 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2841 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2842 trap cleanup_test32_mount EXIT
2843 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2844 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2845 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2846 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2847 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2848 cleanup_test32_mount
2850 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2855 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2856 trap cleanup_test32_mount EXIT
2857 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2858 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2859 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2860 test_mkdir -p $DIR/$tdir/d2/test_dir
2861 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2862 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2863 cleanup_test32_mount
2865 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2868 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2870 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2871 trap cleanup_test32_mount EXIT
2872 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2873 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2874 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2875 test_mkdir -p $DIR/$tdir/d2/test_dir
2876 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2877 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2878 cleanup_test32_mount
2880 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2884 test_mkdir -p $DIR/$tdir/tmp
2885 local tmp_dir=$DIR/$tdir/tmp
2886 ln -s $DIR/$tdir $tmp_dir/symlink11
2887 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2888 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2889 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2891 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2895 test_mkdir -p $DIR/$tdir/tmp
2896 local tmp_dir=$DIR/$tdir/tmp
2897 ln -s $DIR/$tdir $tmp_dir/symlink11
2898 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2899 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2900 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2902 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2905 local tmp_dir=$DIR/$tdir/tmp
2906 test_mkdir -p $tmp_dir
2907 test_mkdir $DIR/${tdir}2
2908 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2909 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2910 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2911 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2912 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2913 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2915 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2918 rm -fr $DIR/$tdir $DIR/${tdir}2
2919 tmp_dir=$DIR/$tdir/tmp
2920 test_mkdir -p $tmp_dir
2921 test_mkdir $DIR/${tdir}2
2922 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2923 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2924 ls $tmp_dir/symlink12 || error "listing symlink12"
2925 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2927 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2932 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2933 trap cleanup_test32_mount EXIT
2934 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2935 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2936 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2937 touch $DIR/$tdir/test_file
2938 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2939 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2940 cleanup_test32_mount
2942 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2945 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2947 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2948 trap cleanup_test32_mount EXIT
2949 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2950 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2951 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2952 touch $DIR/$tdir/test_file
2953 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2954 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2955 cleanup_test32_mount
2957 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2963 trap cleanup_test32_mount EXIT
2964 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2965 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2966 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2967 test_mkdir -p $DIR/$tdir/d2
2968 touch $DIR/$tdir/d2/test_file || error "touch failed"
2969 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2970 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2971 cleanup_test32_mount
2973 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2979 trap cleanup_test32_mount EXIT
2980 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2981 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2982 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2983 test_mkdir -p $DIR/$tdir/d2
2984 touch $DIR/$tdir/d2/test_file || error "touch failed"
2985 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2986 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2987 cleanup_test32_mount
2989 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2993 test_mkdir -p $DIR/d32m/tmp
2994 TMP_DIR=$DIR/d32m/tmp
2995 ln -s $DIR $TMP_DIR/symlink11
2996 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2997 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2998 error "symlink11 not a link"
2999 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
3000 error "symlink01 not a link"
3002 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
3006 test_mkdir -p $DIR/d32n/tmp
3007 TMP_DIR=$DIR/d32n/tmp
3008 ln -s $DIR $TMP_DIR/symlink11
3009 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
3010 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
3011 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
3013 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
3017 test_mkdir -p $DIR/d32o/tmp
3018 TMP_DIR=$DIR/d32o/tmp
3019 ln -s $DIR/$tfile $TMP_DIR/symlink12
3020 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3021 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
3022 error "symlink12 not a link"
3023 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
3024 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
3025 error "$DIR/d32o/tmp/symlink12 not file type"
3026 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
3027 error "$DIR/d32o/symlink02 not file type"
3029 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
3039 test_mkdir -p $DIR/d32p/tmp
3041 TMP_DIR=$DIR/d32p/tmp
3043 ln -s $DIR/$tfile $TMP_DIR/symlink12
3045 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
3047 cat $DIR/d32p/tmp/symlink12 ||
3048 error "Can't open $DIR/d32p/tmp/symlink12"
3050 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
3053 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
3056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3058 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3059 trap cleanup_test32_mount EXIT
3060 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3061 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3062 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3063 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3064 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
3065 cleanup_test32_mount
3067 run_test 32q "stat follows mountpoints in Lustre (should return error)"
3070 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3072 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
3073 trap cleanup_test32_mount EXIT
3074 test_mkdir -p $DIR/$tdir/ext2-mountpoint
3075 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
3076 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
3077 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
3078 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
3079 cleanup_test32_mount
3081 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
3086 chmod 444 $DIR/$tfile
3087 chown $RUNAS_ID $DIR/$tfile
3089 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3092 run_test 33aa "write file with mode 444 (should return error)"
3096 test_mkdir $DIR/$tdir
3097 chown $RUNAS_ID $DIR/$tdir
3098 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
3099 error "$RUNAS create $tdir/$tfile failed"
3100 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
3101 error "open RDWR" || true
3103 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
3107 test_mkdir $DIR/$tdir
3108 chown $RUNAS_ID $DIR/$tdir
3109 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
3111 run_test 33b "test open file with malformed flags (No panic)"
3114 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3115 remote_ost_nodsh && skip "remote OST with nodsh"
3124 test_mkdir $DIR/$tdir
3125 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
3128 for ostnum in $(seq $OSTCOUNT); do
3129 # test-framework's OST numbering is one-based, while Lustre's
3131 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3132 # Parsing llobdstat's output sucks; we could grep the /proc
3133 # path, but that's likely to not be as portable as using the
3134 # llobdstat utility. So we parse lctl output instead.
3135 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3136 obdfilter/$ostname/stats |
3137 awk '/^write_bytes/ {print $7}' )
3138 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3139 if (( ${write_bytes:-0} > 0 ))
3146 $all_zeros || return 0
3149 echo foo > $DIR/$tdir/bar
3153 # Total up write_bytes after writing. We'd better find non-zeros.
3154 for ostnum in $(seq $OSTCOUNT); do
3155 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3156 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3157 obdfilter/$ostname/stats |
3158 awk '/^write_bytes/ {print $7}' )
3159 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3160 if (( ${write_bytes:-0} > 0 ))
3169 for ostnum in $(seq $OSTCOUNT); do
3170 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3171 echo "Check that write_bytes is present in obdfilter/*/stats:"
3172 do_facet ost$ostnum lctl get_param -n \
3173 obdfilter/$ostname/stats
3175 error "OST not keeping write_bytes stats (b22312)"
3178 run_test 33c "test llobdstat and write_bytes"
3181 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3182 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3185 local remote_dir=$DIR/$tdir/remote_dir
3187 test_mkdir $DIR/$tdir
3188 $LFS mkdir -i $MDTIDX $remote_dir ||
3189 error "create remote directory failed"
3191 touch $remote_dir/$tfile
3192 chmod 444 $remote_dir/$tfile
3193 chown $RUNAS_ID $remote_dir/$tfile
3195 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3197 chown $RUNAS_ID $remote_dir
3198 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3199 error "create" || true
3200 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3201 error "open RDWR" || true
3202 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3204 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3207 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3211 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3212 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3213 mkdir $DIR/$tdir/local_dir
3215 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3216 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3217 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3219 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3220 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3222 rmdir $DIR/$tdir/* || error "rmdir failed"
3225 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3226 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3227 mkdir $DIR/$tdir/local_dir
3229 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3230 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3231 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3233 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3234 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3236 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3239 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3240 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3241 mkdir $DIR/$tdir/local_dir
3243 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3244 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3245 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3247 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3248 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3250 run_test 33e "mkdir and striped directory should have same mode"
3254 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3258 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3259 remote_mds_nodsh && skip "remote MDS with nodsh"
3262 chmod go+rwx $DIR/$tdir
3263 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3264 trap cleanup_33f EXIT
3266 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3267 error "cannot create striped directory"
3269 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3270 error "cannot create files in striped directory"
3272 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3273 error "cannot remove files in striped directory"
3275 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3276 error "cannot remove striped directory"
3280 run_test 33f "nonroot user can create, access, and remove a striped directory"
3283 mkdir -p $DIR/$tdir/dir2
3285 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3287 [[ $err =~ "exists" ]] || error "Not exists error"
3289 run_test 33g "nonroot user create already existing root created file"
3291 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3294 $MCREATE $DIR/f34 || error "mcreate failed"
3295 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3296 error "getstripe failed"
3297 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3298 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3299 error "getstripe failed"
3300 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3301 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3303 run_test 34a "truncate file that has not been opened ==========="
3306 [ ! -f $DIR/f34 ] && test_34a
3307 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3308 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3309 $OPENFILE -f O_RDONLY $DIR/f34
3310 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3311 error "getstripe failed"
3312 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3313 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3315 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3318 [ ! -f $DIR/f34 ] && test_34a
3319 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3320 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3321 $OPENFILE -f O_RDWR $DIR/f34
3322 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3323 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3324 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3326 run_test 34c "O_RDWR opening file-with-size works =============="
3329 [ ! -f $DIR/f34 ] && test_34a
3330 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3332 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3333 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3336 run_test 34d "write to sparse file ============================="
3340 $MCREATE $DIR/f34e || error "mcreate failed"
3341 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3342 $CHECKSTAT -s 1000 $DIR/f34e ||
3343 error "Size of $DIR/f34e not equal to 1000 bytes"
3344 $OPENFILE -f O_RDWR $DIR/f34e
3345 $CHECKSTAT -s 1000 $DIR/f34e ||
3346 error "Size of $DIR/f34e not equal to 1000 bytes"
3348 run_test 34e "create objects, some with size and some without =="
3350 test_34f() { # bug 6242, 6243
3351 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3355 $MCREATE $DIR/f34f || error "mcreate failed"
3356 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3357 dd if=$DIR/f34f of=$TMP/f34f
3358 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3359 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3360 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3361 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3362 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3364 run_test 34f "read from a file with no objects until EOF ======="
3367 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3369 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3371 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3372 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3373 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3374 cancel_lru_locks osc
3375 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3376 error "wrong size after lock cancel"
3378 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3379 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3380 error "expanding truncate failed"
3381 cancel_lru_locks osc
3382 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3383 error "wrong expanded size after lock cancel"
3385 run_test 34g "truncate long file ==============================="
3388 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3393 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3394 sync # Flush the cache so that multiop below does not block on cache
3395 # flush when getting the group lock
3396 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3399 # Since just timed wait is not good enough, let's do a sync write
3400 # that way we are sure enough time for a roundtrip + processing
3401 # passed + 2 seconds of extra margin.
3402 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3406 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3407 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3411 local nsz=`stat -c %s $DIR/$tfile`
3412 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3414 run_test 34h "ftruncate file under grouplock should not block"
3417 cp /bin/sh $DIR/f35a
3419 chown $RUNAS_ID $DIR/f35a
3420 $RUNAS $DIR/f35a && error || true
3423 run_test 35a "exec file with mode 444 (should return and not leak)"
3427 utime $DIR/f36 || error "utime failed for MDS"
3429 run_test 36a "MDS utime check (mknod, utime)"
3433 utime $DIR/f36 || error "utime failed for OST"
3435 run_test 36b "OST utime check (open, utime)"
3440 chown $RUNAS_ID $DIR/d36
3441 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3443 run_test 36c "non-root MDS utime check (mknod, utime)"
3446 [ ! -d $DIR/d36 ] && test_36c
3447 echo "" > $DIR/d36/f36
3448 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3450 run_test 36d "non-root OST utime check (open, utime)"
3453 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3455 test_mkdir $DIR/$tdir
3456 touch $DIR/$tdir/$tfile
3457 $RUNAS utime $DIR/$tdir/$tfile &&
3458 error "utime worked, expected failure" || true
3460 run_test 36e "utime on non-owned file (should return error)"
3464 local LANG_SAVE=$LANG
3465 local LC_LANG_SAVE=$LC_LANG
3466 export LANG=C LC_LANG=C # for date language
3468 DATESTR="Dec 20 2000"
3469 test_mkdir $DIR/$tdir
3470 lctl set_param fail_loc=$fl
3472 cp /etc/hosts $DIR/$tdir/$tfile
3473 sync & # write RPC generated with "current" inode timestamp, but delayed
3475 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3476 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3477 cancel_lru_locks $OSC
3478 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3480 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3481 echo "BEFORE: $LS_BEFORE" && \
3482 echo "AFTER : $LS_AFTER" && \
3483 echo "WANT : $DATESTR" && \
3484 error "$DIR/$tdir/$tfile timestamps changed" || true
3486 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3490 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3492 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3493 subr_36fh "0x80000214"
3495 run_test 36f "utime on file racing with OST BRW write =========="
3498 remote_ost_nodsh && skip "remote OST with nodsh"
3499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3500 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3501 skip "Need MDS version at least 2.12.51"
3506 local tgt="obdfilter"
3508 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3510 test_mkdir $DIR/$tdir
3511 fmd_max_age=$(do_facet $facet \
3512 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3515 echo "FMD max age: ${fmd_max_age}s"
3516 touch $DIR/$tdir/$tfile
3517 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3518 gawk '{cnt=cnt+$1} END{print cnt}')
3519 echo "FMD before: $fmd"
3521 error "FMD wasn't create by touch"
3522 sleep $((fmd_max_age + 12))
3523 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3524 gawk '{cnt=cnt+$1} END{print cnt}')
3525 echo "FMD after: $fmd"
3527 error "FMD wasn't expired by ping"
3529 run_test 36g "FMD cache expiry ====================="
3532 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3534 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3535 subr_36fh "0x80000227"
3537 run_test 36h "utime on file racing with OST BRW write =========="
3540 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3542 test_mkdir $DIR/$tdir
3543 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3545 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3546 local new_mtime=$((mtime + 200))
3548 #change Modify time of striped dir
3549 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3550 error "change mtime failed"
3552 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3554 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3556 run_test 36i "change mtime on striped directory"
3558 # test_37 - duplicate with tests 32q 32r
3561 local file=$DIR/$tfile
3563 openfile -f O_DIRECTORY $file
3566 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3567 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3569 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3571 test_39a() { # was test_39
3573 touch $DIR/${tfile}2
3574 # ls -l $DIR/$tfile $DIR/${tfile}2
3575 # ls -lu $DIR/$tfile $DIR/${tfile}2
3576 # ls -lc $DIR/$tfile $DIR/${tfile}2
3578 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3579 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3581 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3583 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3585 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3586 error "O_TRUNC didn't change timestamps"
3589 run_test 39a "mtime changed on create"
3592 test_mkdir -c1 $DIR/$tdir
3593 cp -p /etc/passwd $DIR/$tdir/fopen
3594 cp -p /etc/passwd $DIR/$tdir/flink
3595 cp -p /etc/passwd $DIR/$tdir/funlink
3596 cp -p /etc/passwd $DIR/$tdir/frename
3597 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3600 echo "aaaaaa" >> $DIR/$tdir/fopen
3601 echo "aaaaaa" >> $DIR/$tdir/flink
3602 echo "aaaaaa" >> $DIR/$tdir/funlink
3603 echo "aaaaaa" >> $DIR/$tdir/frename
3605 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3606 local link_new=`stat -c %Y $DIR/$tdir/flink`
3607 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3608 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3610 cat $DIR/$tdir/fopen > /dev/null
3611 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3612 rm -f $DIR/$tdir/funlink2
3613 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3615 for (( i=0; i < 2; i++ )) ; do
3616 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3617 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3618 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3619 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3621 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3622 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3623 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3624 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3626 cancel_lru_locks $OSC
3627 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3630 run_test 39b "mtime change on open, link, unlink, rename ======"
3632 # this should be set to past
3633 TEST_39_MTIME=`date -d "1 year ago" +%s`
3639 local mtime0=`stat -c %Y $DIR1/$tfile`
3641 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3642 local mtime1=`stat -c %Y $DIR1/$tfile`
3643 [ "$mtime1" = $TEST_39_MTIME ] || \
3644 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3647 echo hello >> $DIR1/$tfile
3649 local mtime2=`stat -c %Y $DIR1/$tfile`
3650 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3651 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3653 mv $DIR1/$tfile $DIR1/$tfile-1
3655 for (( i=0; i < 2; i++ )) ; do
3656 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3657 [ "$mtime2" = "$mtime3" ] || \
3658 error "mtime ($mtime2) changed (to $mtime3) on rename"
3660 cancel_lru_locks $OSC
3661 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3664 run_test 39c "mtime change on rename ==========================="
3668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3671 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3673 for (( i=0; i < 2; i++ )) ; do
3674 local mtime=`stat -c %Y $DIR1/$tfile`
3675 [ $mtime = $TEST_39_MTIME ] || \
3676 error "mtime($mtime) is not set to $TEST_39_MTIME"
3678 cancel_lru_locks $OSC
3679 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3682 run_test 39d "create, utime, stat =============================="
3686 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3689 local mtime1=`stat -c %Y $DIR1/$tfile`
3691 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3693 for (( i=0; i < 2; i++ )) ; do
3694 local mtime2=`stat -c %Y $DIR1/$tfile`
3695 [ $mtime2 = $TEST_39_MTIME ] || \
3696 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3698 cancel_lru_locks $OSC
3699 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3702 run_test 39e "create, stat, utime, stat ========================"
3706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3709 mtime1=`stat -c %Y $DIR1/$tfile`
3712 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3714 for (( i=0; i < 2; i++ )) ; do
3715 local mtime2=`stat -c %Y $DIR1/$tfile`
3716 [ $mtime2 = $TEST_39_MTIME ] || \
3717 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3719 cancel_lru_locks $OSC
3720 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3723 run_test 39f "create, stat, sleep, utime, stat ================="
3727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3729 echo hello >> $DIR1/$tfile
3730 local mtime1=`stat -c %Y $DIR1/$tfile`
3733 chmod o+r $DIR1/$tfile
3735 for (( i=0; i < 2; i++ )) ; do
3736 local mtime2=`stat -c %Y $DIR1/$tfile`
3737 [ "$mtime1" = "$mtime2" ] || \
3738 error "lost mtime: $mtime2, should be $mtime1"
3740 cancel_lru_locks $OSC
3741 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3744 run_test 39g "write, chmod, stat ==============================="
3748 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3754 echo hello >> $DIR1/$tfile
3755 local mtime1=`stat -c %Y $DIR1/$tfile`
3757 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3759 if [ "$d1" != "$d2" ]; then
3760 echo "write and touch not within one second"
3762 for (( i=0; i < 2; i++ )) ; do
3763 local mtime2=`stat -c %Y $DIR1/$tfile`
3764 [ "$mtime2" = $TEST_39_MTIME ] || \
3765 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3767 cancel_lru_locks $OSC
3768 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3772 run_test 39h "write, utime within one second, stat ============="
3775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3780 echo hello >> $DIR1/$tfile
3781 local mtime1=`stat -c %Y $DIR1/$tfile`
3783 mv $DIR1/$tfile $DIR1/$tfile-1
3785 for (( i=0; i < 2; i++ )) ; do
3786 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3788 [ "$mtime1" = "$mtime2" ] || \
3789 error "lost mtime: $mtime2, should be $mtime1"
3791 cancel_lru_locks $OSC
3792 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3795 run_test 39i "write, rename, stat =============================="
3798 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3800 start_full_debug_logging
3804 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3805 lctl set_param fail_loc=0x80000412
3806 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3807 error "multiop failed"
3809 local mtime1=`stat -c %Y $DIR1/$tfile`
3811 mv $DIR1/$tfile $DIR1/$tfile-1
3813 kill -USR1 $multipid
3814 wait $multipid || error "multiop close failed"
3816 for (( i=0; i < 2; i++ )) ; do
3817 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3818 [ "$mtime1" = "$mtime2" ] ||
3819 error "mtime is lost on close: $mtime2, " \
3822 cancel_lru_locks $OSC
3823 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3825 lctl set_param fail_loc=0
3826 stop_full_debug_logging
3828 run_test 39j "write, rename, close, stat ======================="
3831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3836 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3838 local mtime1=`stat -c %Y $DIR1/$tfile`
3840 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3842 kill -USR1 $multipid
3843 wait $multipid || error "multiop close failed"
3845 for (( i=0; i < 2; i++ )) ; do
3846 local mtime2=`stat -c %Y $DIR1/$tfile`
3848 [ "$mtime2" = $TEST_39_MTIME ] || \
3849 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3851 cancel_lru_locks osc
3852 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3855 run_test 39k "write, utime, close, stat ========================"
3857 # this should be set to future
3858 TEST_39_ATIME=`date -d "1 year" +%s`
3861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3862 remote_mds_nodsh && skip "remote MDS with nodsh"
3864 local atime_diff=$(do_facet $SINGLEMDS \
3865 lctl get_param -n mdd.*MDT0000*.atime_diff)
3869 # test setting directory atime to future
3870 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3871 local atime=$(stat -c %X $DIR/$tdir)
3872 [ "$atime" = $TEST_39_ATIME ] ||
3873 error "atime is not set to future: $atime, $TEST_39_ATIME"
3875 # test setting directory atime from future to now
3876 local now=$(date +%s)
3877 touch -a -d @$now $DIR/$tdir
3879 atime=$(stat -c %X $DIR/$tdir)
3880 [ "$atime" -eq "$now" ] ||
3881 error "atime is not updated from future: $atime, $now"
3883 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3886 # test setting directory atime when now > dir atime + atime_diff
3887 local d1=$(date +%s)
3889 local d2=$(date +%s)
3890 cancel_lru_locks mdc
3891 atime=$(stat -c %X $DIR/$tdir)
3892 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3893 error "atime is not updated : $atime, should be $d2"
3895 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3898 # test not setting directory atime when now < dir atime + atime_diff
3900 cancel_lru_locks mdc
3901 atime=$(stat -c %X $DIR/$tdir)
3902 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3903 error "atime is updated to $atime, should remain $d1<atime<$d2"
3905 do_facet $SINGLEMDS \
3906 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3908 run_test 39l "directory atime update ==========================="
3911 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3915 local far_past_mtime=$(date -d "May 29 1953" +%s)
3916 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3918 touch -m -d @$far_past_mtime $DIR1/$tfile
3919 touch -a -d @$far_past_atime $DIR1/$tfile
3921 for (( i=0; i < 2; i++ )) ; do
3922 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3923 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3924 error "atime or mtime set incorrectly"
3926 cancel_lru_locks $OSC
3927 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3930 run_test 39m "test atime and mtime before 1970"
3932 test_39n() { # LU-3832
3933 remote_mds_nodsh && skip "remote MDS with nodsh"
3935 local atime_diff=$(do_facet $SINGLEMDS \
3936 lctl get_param -n mdd.*MDT0000*.atime_diff)
3941 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3944 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3945 atime0=$(stat -c %X $DIR/$tfile)
3948 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3949 atime1=$(stat -c %X $DIR/$tfile)
3952 cancel_lru_locks mdc
3953 cancel_lru_locks osc
3954 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3955 atime2=$(stat -c %X $DIR/$tfile)
3957 do_facet $SINGLEMDS \
3958 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3960 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3961 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3963 run_test 39n "check that O_NOATIME is honored"
3966 TESTDIR=$DIR/$tdir/$tfile
3967 [ -e $TESTDIR ] && rm -rf $TESTDIR
3974 links2=$(stat -c %h .)
3975 [ $(($links1 + 2)) != $links2 ] &&
3976 error "wrong links count $(($links1 + 2)) != $links2"
3978 links3=$(stat -c %h .)
3979 [ $(($links1 + 1)) != $links3 ] &&
3980 error "wrong links count $links1 != $links3"
3983 run_test 39o "directory cached attributes updated after create"
3986 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3989 TESTDIR=$DIR/$tdir/$tdir
3990 [ -e $TESTDIR ] && rm -rf $TESTDIR
3991 test_mkdir -p $TESTDIR
3995 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3996 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3998 links2=$(stat -c %h .)
3999 [ $(($links1 + 2)) != $links2 ] &&
4000 error "wrong links count $(($links1 + 2)) != $links2"
4002 links3=$(stat -c %h .)
4003 [ $(($links1 + 1)) != $links3 ] &&
4004 error "wrong links count $links1 != $links3"
4007 run_test 39p "remote directory cached attributes updated after create ========"
4010 test_39q() { # LU-8041
4011 local testdir=$DIR/$tdir
4013 multiop_bg_pause $testdir D_c || error "multiop failed"
4015 cancel_lru_locks mdc
4016 kill -USR1 $multipid
4017 local atime=$(stat -c %X $testdir)
4018 [ "$atime" -ne 0 ] || error "atime is zero"
4020 run_test 39q "close won't zero out atime"
4023 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
4024 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
4025 error "openfile O_WRONLY:O_TRUNC $tfile failed"
4026 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
4027 error "$tfile is not 4096 bytes in size"
4029 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
4033 small_write $DIR/f41 18
4035 run_test 41 "test small file write + fstat ====================="
4037 count_ost_writes() {
4038 lctl get_param -n ${OSC}.*.stats |
4039 awk -vwrites=0 '/ost_write/ { writes += $2 } \
4040 END { printf("%0.0f", writes) }'
4047 BG_DIRTY_RATIO_SAVE=10
4048 MAX_BG_DIRTY_RATIO=25
4052 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
4053 # dirty_ratio, dirty_background_ratio
4054 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4055 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
4056 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
4057 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
4059 # if file not here, we are a 2.4 kernel
4060 kill -CONT `pidof kupdated`
4065 # setup the trap first, so someone cannot exit the test at the
4066 # exact wrong time and mess up a machine
4067 trap start_writeback EXIT
4068 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
4069 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
4070 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
4071 sysctl -w vm.dirty_writeback_centisecs=0
4072 sysctl -w vm.dirty_writeback_centisecs=0
4073 # save and increase /proc/sys/vm/dirty_ratio
4074 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
4075 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
4076 # save and increase /proc/sys/vm/dirty_background_ratio
4077 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
4078 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
4080 # if file not here, we are a 2.4 kernel
4081 kill -STOP `pidof kupdated`
4085 # ensure that all stripes have some grant before we test client-side cache
4087 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
4088 dd if=/dev/zero of=$i bs=4k count=1
4093 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
4094 # file truncation, and file removal.
4096 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4099 cancel_lru_locks $OSC
4101 sync; sleep 1; sync # just to be safe
4102 BEFOREWRITES=`count_ost_writes`
4103 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
4104 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
4105 AFTERWRITES=`count_ost_writes`
4106 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
4107 error "$BEFOREWRITES < $AFTERWRITES"
4110 run_test 42a "ensure that we don't flush on close"
4113 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4116 cancel_lru_locks $OSC
4119 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
4120 BEFOREWRITES=$(count_ost_writes)
4121 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
4122 AFTERWRITES=$(count_ost_writes)
4123 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4124 error "$BEFOREWRITES < $AFTERWRITES on unlink"
4126 BEFOREWRITES=$(count_ost_writes)
4127 sync || error "sync: $?"
4128 AFTERWRITES=$(count_ost_writes)
4129 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
4130 error "$BEFOREWRITES < $AFTERWRITES on sync"
4132 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4136 run_test 42b "test destroy of file with cached dirty data ======"
4138 # if these tests just want to test the effect of truncation,
4139 # they have to be very careful. consider:
4140 # - the first open gets a {0,EOF}PR lock
4141 # - the first write conflicts and gets a {0, count-1}PW
4142 # - the rest of the writes are under {count,EOF}PW
4143 # - the open for truncate tries to match a {0,EOF}PR
4144 # for the filesize and cancels the PWs.
4145 # any number of fixes (don't get {0,EOF} on open, match
4146 # composite locks, do smarter file size management) fix
4147 # this, but for now we want these tests to verify that
4148 # the cancellation with truncate intent works, so we
4149 # start the file with a full-file pw lock to match against
4150 # until the truncate.
4155 cancel_lru_locks $OSC
4157 # prime the file with 0,EOF PW to match
4161 # now the real test..
4162 dd if=/dev/zero of=$file bs=1024 count=100
4163 BEFOREWRITES=`count_ost_writes`
4164 $TRUNCATE $file $offset
4165 cancel_lru_locks $OSC
4166 AFTERWRITES=`count_ost_writes`
4171 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4174 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4175 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4178 run_test 42c "test partial truncate of file with cached dirty data"
4181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4184 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4185 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4188 run_test 42d "test complete truncate of file with cached dirty data"
4190 test_42e() { # bug22074
4191 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4193 local TDIR=$DIR/${tdir}e
4194 local pages=16 # hardcoded 16 pages, don't change it.
4195 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4196 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4200 test_mkdir $DIR/${tdir}e
4201 $SETSTRIPE -c 1 $TDIR
4202 createmany -o $TDIR/f $files
4204 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4206 # we assume that with $OSTCOUNT files, at least one of them will
4207 # be allocated on OST0.
4208 warmup_files=$((OSTCOUNT * max_dirty_mb))
4209 createmany -o $TDIR/w $warmup_files
4211 # write a large amount of data into one file and sync, to get good
4212 # avail_grant number from OST.
4213 for ((i=0; i<$warmup_files; i++)); do
4214 idx=$($GETSTRIPE -i $TDIR/w$i)
4215 [ $idx -ne 0 ] && continue
4216 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4219 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4221 $LCTL get_param $proc_osc0/cur_dirty_bytes
4222 $LCTL get_param $proc_osc0/cur_grant_bytes
4224 # create as much dirty pages as we can while not to trigger the actual
4225 # RPCs directly. but depends on the env, VFS may trigger flush during this
4226 # period, hopefully we are good.
4227 for ((i=0; i<$warmup_files; i++)); do
4228 idx=$($GETSTRIPE -i $TDIR/w$i)
4229 [ $idx -ne 0 ] && continue
4230 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4232 $LCTL get_param $proc_osc0/cur_dirty_bytes
4233 $LCTL get_param $proc_osc0/cur_grant_bytes
4235 # perform the real test
4236 $LCTL set_param $proc_osc0/rpc_stats 0
4237 for ((;i<$files; i++)); do
4238 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4239 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4242 $LCTL get_param $proc_osc0/rpc_stats
4245 local have_ppr=false
4246 $LCTL get_param $proc_osc0/rpc_stats |
4247 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4248 # skip lines until we are at the RPC histogram data
4249 [ "$PPR" == "pages" ] && have_ppr=true && continue
4250 $have_ppr || continue
4252 # we only want the percent stat for < 16 pages
4253 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4255 percent=$((percent + WPCT))
4256 if [[ $percent -gt 15 ]]; then
4257 error "less than 16-pages write RPCs" \
4264 run_test 42e "verify sub-RPC writes are not done synchronously"
4266 test_43A() { # was test_43
4267 test_mkdir $DIR/$tdir
4268 cp -p /bin/ls $DIR/$tdir/$tfile
4269 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4271 # give multiop a chance to open
4274 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4277 run_test 43A "execution of file opened for write should return -ETXTBSY"
4280 test_mkdir $DIR/$tdir
4281 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4282 $DIR/$tdir/sleep 60 &
4284 # Make sure exec of $tdir/sleep wins race with truncate
4286 $MULTIOP $DIR/$tdir/sleep Oc && error "expected error, got success"
4289 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4294 test_mkdir $DIR/$tdir
4295 cp -p $(which sleep) $DIR/$tdir/sleep || error "can't copy"
4296 $DIR/$tdir/sleep 60 &
4298 # Make sure exec of $tdir/sleep wins race with truncate
4300 $TRUNCATE $DIR/$tdir/sleep 0 && error "expected error, got success"
4303 run_test 43b "truncate of file being executed should return -ETXTBSY"
4306 local testdir="$DIR/$tdir"
4309 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4310 ( cd $testdir && md5sum -c )
4312 run_test 43c "md5sum of copy into lustre"
4314 test_44A() { # was test_44
4315 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4317 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4318 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4320 run_test 44A "zero length read from a sparse stripe"
4323 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4325 [ -z "$nstripe" ] && skip "can't get stripe info"
4326 [[ $nstripe -gt $OSTCOUNT ]] &&
4327 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4329 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4331 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4332 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4336 OFFSETS="0 $((stride/2)) $((stride-1))"
4337 for offset in $OFFSETS; do
4338 for i in $(seq 0 $((nstripe-1))); do
4339 local GLOBALOFFSETS=""
4341 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4342 local myfn=$DIR/d44a-$size
4343 echo "--------writing $myfn at $size"
4344 ll_sparseness_write $myfn $size ||
4345 error "ll_sparseness_write"
4346 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4347 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4348 error "ll_sparseness_verify $GLOBALOFFSETS"
4350 for j in $(seq 0 $((nstripe-1))); do
4352 size=$((((j + $nstripe )*$stride + $offset)))
4353 ll_sparseness_write $myfn $size ||
4354 error "ll_sparseness_write"
4355 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4357 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4358 error "ll_sparseness_verify $GLOBALOFFSETS"
4363 run_test 44a "test sparse pwrite ==============================="
4367 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4373 before=`dirty_osc_total`
4374 echo executing "\"$*\""
4376 after=`dirty_osc_total`
4377 echo before $before, after $after
4380 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4383 # Obtain grants from OST if it supports it
4384 echo blah > ${f}_grant
4387 do_dirty_record "echo blah > $f"
4388 [[ $before -eq $after ]] && error "write wasn't cached"
4389 do_dirty_record "> $f"
4390 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4391 do_dirty_record "echo blah > $f"
4392 [[ $before -eq $after ]] && error "write wasn't cached"
4393 do_dirty_record "sync"
4394 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4395 do_dirty_record "echo blah > $f"
4396 [[ $before -eq $after ]] && error "write wasn't cached"
4397 do_dirty_record "cancel_lru_locks osc"
4398 [[ $before -gt $after ]] ||
4399 error "lock cancellation didn't lower dirty count"
4402 run_test 45 "osc io page accounting ============================"
4404 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4405 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4406 # objects offset and an assert hit when an rpc was built with 1023's mapped
4407 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4409 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4414 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4416 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4417 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4421 run_test 46 "dirtying a previously written page ================"
4423 # test_47 is removed "Device nodes check" is moved to test_28
4425 test_48a() { # bug 2399
4426 [ "$mds1_FSTYPE" = "zfs" ] &&
4427 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4428 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4430 test_mkdir $DIR/$tdir
4432 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4433 test_mkdir $DIR/$tdir
4434 touch foo || error "'touch foo' failed after recreating cwd"
4436 touch .foo || error "'touch .foo' failed after recreating cwd"
4438 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4439 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4440 cd . || error "'cd .' failed after recreating cwd"
4441 mkdir . && error "'mkdir .' worked after recreating cwd"
4442 rmdir . && error "'rmdir .' worked after recreating cwd"
4443 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4444 cd .. || error "'cd ..' failed after recreating cwd"
4446 run_test 48a "Access renamed working dir (should return errors)="
4448 test_48b() { # bug 2399
4450 test_mkdir $DIR/$tdir
4452 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4453 touch foo && error "'touch foo' worked after removing cwd"
4454 mkdir foo && error "'mkdir foo' worked after removing cwd"
4455 touch .foo && error "'touch .foo' worked after removing cwd"
4456 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4457 ls . > /dev/null && error "'ls .' worked after removing cwd"
4458 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4459 mkdir . && error "'mkdir .' worked after removing cwd"
4460 rmdir . && error "'rmdir .' worked after removing cwd"
4461 ln -s . foo && error "'ln -s .' worked after removing cwd"
4462 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4464 run_test 48b "Access removed working dir (should return errors)="
4466 test_48c() { # bug 2350
4467 #lctl set_param debug=-1
4470 test_mkdir -p $DIR/$tdir/dir
4472 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4473 $TRACE touch foo && error "touch foo worked after removing cwd"
4474 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4475 touch .foo && error "touch .foo worked after removing cwd"
4476 mkdir .foo && error "mkdir .foo worked after removing cwd"
4477 $TRACE ls . && error "'ls .' worked after removing cwd"
4478 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4479 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4480 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4481 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4482 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4484 run_test 48c "Access removed working subdir (should return errors)"
4486 test_48d() { # bug 2350
4487 #lctl set_param debug=-1
4490 test_mkdir -p $DIR/$tdir/dir
4492 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4493 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4494 $TRACE touch foo && error "'touch foo' worked after removing parent"
4495 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4496 touch .foo && error "'touch .foo' worked after removing parent"
4497 mkdir .foo && error "mkdir .foo worked after removing parent"
4498 $TRACE ls . && error "'ls .' worked after removing parent"
4499 $TRACE ls .. && error "'ls ..' worked after removing parent"
4500 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4501 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4502 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4505 run_test 48d "Access removed parent subdir (should return errors)"
4507 test_48e() { # bug 4134
4508 #lctl set_param debug=-1
4511 test_mkdir -p $DIR/$tdir/dir
4513 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4514 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4515 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4516 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4517 # On a buggy kernel addition of "touch foo" after cd .. will
4518 # produce kernel oops in lookup_hash_it
4519 touch ../foo && error "'cd ..' worked after recreate parent"
4521 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4523 run_test 48e "Access to recreated parent subdir (should return errors)"
4525 test_49() { # LU-1030
4526 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4527 remote_ost_nodsh && skip "remote OST with nodsh"
4529 # get ost1 size - lustre-OST0000
4530 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4532 # write 800M at maximum
4533 [[ $ost1_size -lt 2 ]] && ost1_size=2
4534 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4536 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4537 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4540 # change max_pages_per_rpc while writing the file
4541 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4542 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4543 # loop until dd process exits
4544 while ps ax -opid | grep -wq $dd_pid; do
4545 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4546 sleep $((RANDOM % 5 + 1))
4548 # restore original max_pages_per_rpc
4549 $LCTL set_param $osc1_mppc=$orig_mppc
4550 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4552 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4556 test_mkdir $DIR/$tdir
4558 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4560 run_test 50 "special situations: /proc symlinks ==============="
4562 test_51a() { # was test_51
4563 # bug 1516 - create an empty entry right after ".." then split dir
4564 test_mkdir -c1 $DIR/$tdir
4565 touch $DIR/$tdir/foo
4566 $MCREATE $DIR/$tdir/bar
4568 createmany -m $DIR/$tdir/longfile 201
4570 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4571 $MCREATE $DIR/$tdir/longfile$FNUM
4576 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4578 run_test 51a "special situations: split htree with empty entry =="
4580 cleanup_print_lfs_df () {
4587 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4589 local dir=$DIR/$tdir
4590 local nrdirs=$((65536 + 100))
4592 # cleanup the directory
4599 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4600 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4601 [[ $numfree -lt $nrdirs ]] &&
4602 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4604 # need to check free space for the directories as well
4605 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4606 numfree=$(( blkfree / $(fs_inode_ksize) ))
4607 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4609 trap cleanup_print_lfs_df EXIT
4612 createmany -d $dir/d $nrdirs || {
4613 unlinkmany $dir/d $nrdirs
4614 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4618 nrdirs=$(ls -U $dir | wc -l)
4620 # unlink all but 100 subdirectories, then check it still works
4622 local delete=$((nrdirs - left))
4627 # for ldiskfs the nlink count should be 1, but this is OSD specific
4628 # and so this is listed for informational purposes only
4629 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4630 unlinkmany -d $dir/d $delete ||
4631 error "unlink of first $delete subdirs failed"
4633 echo "nlink between: $(stat -c %h $dir)"
4634 local found=$(ls -U $dir | wc -l)
4635 [ $found -ne $left ] &&
4636 error "can't find subdirs: found only $found, expected $left"
4638 unlinkmany -d $dir/d $delete $left ||
4639 error "unlink of second $left subdirs failed"
4640 # regardless of whether the backing filesystem tracks nlink accurately
4641 # or not, the nlink count shouldn't be more than "." and ".." here
4642 local after=$(stat -c %h $dir)
4643 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4644 echo "nlink after: $after"
4646 cleanup_print_lfs_df
4648 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4651 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4652 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4654 test_mkdir $DIR/$tdir
4655 createmany -o $DIR/$tdir/t- 1000
4656 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4657 for N in $(seq 0 $((OSTCOUNT - 1))); do
4658 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4659 END { printf("%0.0f", objs) }' $TMP/$tfile)
4660 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4661 '($1 == '$N') { objs += 1 } \
4662 END { printf("%0.0f", objs) }')
4663 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4665 unlinkmany $DIR/$tdir/t- 1000
4668 for N in $(seq 1 $((OSTCOUNT - 1))); do
4669 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4670 error "OST $N has less objects vs OST $NLAST" \
4671 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4672 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4673 error "OST $N has less objects vs OST $NLAST" \
4674 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4676 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4677 error "OST $N has less #0 objects vs OST $NLAST" \
4678 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4679 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4680 error "OST $N has less #0 objects vs OST $NLAST" \
4681 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4686 run_test 51d "check object distribution"
4689 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4690 skip_env "ldiskfs only test"
4693 test_mkdir -c1 $DIR/$tdir
4694 test_mkdir -c1 $DIR/$tdir/d0
4696 touch $DIR/$tdir/d0/foo
4697 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4698 error "file exceed 65000 nlink limit!"
4699 unlinkmany $DIR/$tdir/d0/f- 65001
4702 run_test 51e "check file nlink limit"
4705 test_mkdir $DIR/$tdir
4708 local ulimit_old=$(ulimit -n)
4709 local spare=20 # number of spare fd's for scripts/libraries, etc.
4710 local mdt=$($LFS getstripe -m $DIR/$tdir)
4711 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4713 echo "MDT$mdt numfree=$numfree, max=$max"
4714 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4715 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4716 while ! ulimit -n $((numfree + spare)); do
4717 numfree=$((numfree * 3 / 4))
4719 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4721 echo "left ulimit at $ulimit_old"
4724 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4725 unlinkmany $DIR/$tdir/f $numfree
4726 error "create+open $numfree files in $DIR/$tdir failed"
4728 ulimit -n $ulimit_old
4730 # if createmany exits at 120s there will be fewer than $numfree files
4731 unlinkmany $DIR/$tdir/f $numfree || true
4733 run_test 51f "check many open files limit"
4736 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4737 test_mkdir $DIR/$tdir
4738 touch $DIR/$tdir/foo
4739 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4740 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4741 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4742 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4743 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4745 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4746 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4747 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4749 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4750 cp -r $DIR/$tdir $TMP/
4751 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4753 run_test 52a "append-only flag test (should return errors)"
4756 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4757 test_mkdir $DIR/$tdir
4758 touch $DIR/$tdir/foo
4759 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4760 cat test > $DIR/$tdir/foo && error "cat test worked"
4761 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4762 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4763 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4765 echo foo >> $DIR/$tdir/foo && error "echo worked"
4766 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4767 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4768 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4769 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4771 chattr -i $DIR/$tdir/foo || error "chattr failed"
4773 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4775 run_test 52b "immutable flag test (should return errors) ======="
4778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4779 remote_mds_nodsh && skip "remote MDS with nodsh"
4780 remote_ost_nodsh && skip "remote OST with nodsh"
4793 local support_last_seq=true
4795 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4796 support_last_seq=false
4799 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4801 for value in $(do_facet $SINGLEMDS \
4802 $LCTL get_param osp.$mdtosc.prealloc_last_id) ; do
4803 param=$(echo ${value[0]} | cut -d "=" -f1)
4804 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4806 if $support_last_seq; then
4807 param_seq=$(echo $param |
4808 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4809 mds_last_seq=$(do_facet $SINGLEMDS \
4810 $LCTL get_param -n $param_seq)
4812 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4814 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4815 node=$(facet_active_host ost$((ostnum+1)))
4816 param="obdfilter.$ostname.last_id"
4817 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4818 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4819 ost_last_id=$ost_last
4821 if $support_last_seq; then
4822 ost_last_id=$(echo $ost_last |
4823 awk -F':' '{print $2}' |
4825 ost_last_seq=$(echo $ost_last |
4826 awk -F':' '{print $1}')
4827 [[ $ost_last_seq = $mds_last_seq ]] || continue
4830 if [[ $ost_last_id != $mds_last ]]; then
4831 error "$ost_last_id != $mds_last"
4838 $found || error "can not match last_seq/last_id for $mdtosc"
4841 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4844 perl -MSocket -e ';' || skip "no Socket perl module installed"
4846 $SOCKETSERVER $DIR/socket ||
4847 error "$SOCKETSERVER $DIR/socket failed: $?"
4848 $SOCKETCLIENT $DIR/socket ||
4849 error "$SOCKETCLIENT $DIR/socket failed: $?"
4850 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4852 run_test 54a "unix domain socket test =========================="
4858 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4860 run_test 54b "char device works in lustre ======================"
4863 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4864 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4865 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4867 for i in $(seq 3 7); do
4868 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4877 loopdev="$DIR/loop54c"
4880 $UMOUNT $DIR/$tdir || rc=$?
4881 losetup -d $loopdev || true
4882 losetup -d $LOOPDEV || true
4883 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4888 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4890 loopdev="$DIR/loop54c"
4893 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4894 trap cleanup_54c EXIT
4895 mknod $loopdev b 7 $LOOPNUM
4896 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4897 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4898 losetup $loopdev $DIR/$tfile ||
4899 error "can't set up $loopdev for $DIR/$tfile"
4900 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4901 test_mkdir $DIR/$tdir
4902 mount -t ext2 $loopdev $DIR/$tdir ||
4903 error "error mounting $loopdev on $DIR/$tdir"
4904 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4907 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4911 run_test 54c "block device works in lustre ====================="
4917 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4919 run_test 54d "fifo device works in lustre ======================"
4924 cp -aL /dev/console $f
4925 echo $string > $f || error "echo $string to $f failed"
4927 run_test 54e "console/tty device works in lustre ======================"
4931 local dir=$DIR/$tdir
4934 test_mkdir -p $dir/dir
4935 for i in $(seq $numfiles); do
4937 touch $dir/dir/file$i
4940 local numcomp=$($LFS getstripe --component-count $dir)
4942 [[ $numcomp == 0 ]] && numcomp=1
4944 # test lfs getstripe with --recursive
4945 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4947 [[ $filenum -eq $((numfiles * 2)) ]] ||
4948 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4949 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4950 [[ $filenum -eq $numfiles ]] ||
4951 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4952 echo "$LFS getstripe showed obdidx or l_ost_idx"
4954 # test lfs getstripe with file instead of dir
4955 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4956 [[ $filenum -eq 1 ]] ||
4957 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4958 echo "$LFS getstripe file1 passed"
4960 #test lfs getstripe with --verbose
4961 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4962 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4963 error "$LFS getstripe --verbose $dir: "\
4964 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4965 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4966 error "$LFS getstripe $dir: showed lmm_magic"
4968 #test lfs getstripe with -v prints lmm_fid
4969 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4970 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4971 error "$LFS getstripe -v $dir: "\
4972 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4973 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4974 error "$LFS getstripe $dir: showed lmm_fid by default"
4975 echo "$LFS getstripe --verbose passed"
4977 #check for FID information
4978 local fid1=$($LFS getstripe --fid $dir/file1)
4979 local fid2=$($LFS getstripe --verbose $dir/file1 |
4980 awk '/lmm_fid: / { print $2; exit; }')
4981 local fid3=$($LFS path2fid $dir/file1)
4983 [ "$fid1" != "$fid2" ] &&
4984 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4985 [ "$fid1" != "$fid3" ] &&
4986 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4987 echo "$LFS getstripe --fid passed"
4989 #test lfs getstripe with --obd
4990 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4991 error "$LFS getstripe --obd wrong_uuid: should return error"
4993 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4996 local obduuid=$(ostuuid_from_index $ostidx)
4997 local found=$($LFS getstripe -r --obd $obduuid $dir |
4998 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
5000 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
5001 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
5003 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
5006 [[ $found -eq $filenum ]] ||
5007 error "$LFS getstripe --obd: found $found expect $filenum"
5008 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
5009 sed '/^[ ]*'${ostidx}'[ ]/d' |
5010 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
5011 error "$LFS getstripe --obd: should not show file on other obd"
5012 echo "$LFS getstripe --obd passed"
5014 run_test 56a "check $LFS getstripe"
5017 local dir=$DIR/$tdir
5021 for i in $(seq $numdirs); do
5022 test_mkdir $dir/dir$i
5025 # test lfs getdirstripe default mode is non-recursion, which is
5026 # different from lfs getstripe
5027 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
5029 [[ $dircnt -eq 1 ]] ||
5030 error "$LFS getdirstripe: found $dircnt, not 1"
5031 dircnt=$($LFS getdirstripe --recursive $dir |
5032 grep -c lmv_stripe_count)
5033 [[ $dircnt -eq $((numdirs + 1)) ]] ||
5034 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
5036 run_test 56b "check $LFS getdirstripe"
5039 remote_ost_nodsh && skip "remote OST with nodsh"
5042 local ost_name=$(ostname_from_index $ost_idx)
5043 local old_status=$(ost_dev_status $ost_idx)
5045 [[ -z "$old_status" ]] ||
5046 skip_env "OST $ost_name is in $old_status status"
5048 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
5049 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5050 $LCTL set_param -n obdfilter.$ost_name.no_precreate=1
5053 local new_status=$(ost_dev_status $ost_idx)
5055 [[ "$new_status" =~ "D" ]] ||
5056 error "$ost_name status is '$new_status', missing 'D'"
5057 if [[ $OST1_VERSION -ge $(version_code 2.12.3) ]]; then
5058 [[ "$new_status" =~ "N" ]] ||
5059 error "$ost_name status is '$new_status', missing 'N'"
5062 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
5063 [[ $OST1_VERSION -ge $(version_code 2.12.3) ]] && do_facet ost1 \
5064 $LCTL set_param -n obdfilter.$ost_name.no_precreate=0
5067 new_status=$(ost_dev_status $ost_idx)
5068 [[ ! "$new_status" =~ "D" && ! "$new_status" =~ "N" ]] ||
5069 error "$ost_name status is '$new_status', has 'D' and/or 'N'"
5071 run_test 56c "check 'lfs df' showing device status"
5076 local local_tdir="$1"
5077 local local_numfiles="$2"
5078 local local_numdirs="$3"
5079 local dir_params="$4"
5080 local dir_stripe_params="$5"
5082 if [ ! -d "$local_tdir" ] ; then
5083 test_mkdir -p $dir_stripe_params $local_tdir
5084 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
5085 for i in $(seq $local_numfiles) ; do
5086 touch $local_tdir/file$i
5088 for i in $(seq $local_numdirs) ; do
5089 test_mkdir $dir_stripe_params $local_tdir/dir$i
5090 for j in $(seq $local_numfiles) ; do
5091 touch $local_tdir/dir$i/file$j
5097 setup_56_special() {
5099 local local_numfiles=$2
5100 local local_numdirs=$3
5102 setup_56 $local_tdir $local_numfiles $local_numdirs
5104 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
5105 for i in $(seq $local_numfiles) ; do
5106 mknod $local_tdir/loop${i}b b 7 $i
5107 mknod $local_tdir/null${i}c c 1 3
5108 ln -s $local_tdir/file1 $local_tdir/link${i}
5110 for i in $(seq $local_numdirs) ; do
5111 mknod $local_tdir/dir$i/loop${i}b b 7 $i
5112 mknod $local_tdir/dir$i/null${i}c c 1 3
5113 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
5119 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5120 local expected=$(($NUMDIRS + 2))
5122 setup_56 $dir $NUMFILES $NUMDIRS
5124 # test lfs find with -name
5125 for i in $(seq $NUMFILES) ; do
5126 local nums=$($LFS find -name "*$i" $dir | wc -l)
5128 [ $nums -eq $expected ] ||
5129 error "lfs find -name '*$i' $dir wrong: "\
5130 "found $nums, expected $expected"
5133 run_test 56g "check lfs find -name"
5136 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5137 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5139 setup_56 $dir $NUMFILES $NUMDIRS
5141 # test lfs find with ! -name
5142 for i in $(seq $NUMFILES) ; do
5143 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5145 [ $nums -eq $expected ] ||
5146 error "lfs find ! -name '*$i' $dir wrong: "\
5147 "found $nums, expected $expected"
5150 run_test 56h "check lfs find ! -name"
5153 local dir=$DIR/$tdir
5157 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5160 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5162 run_test 56i "check 'lfs find -ost UUID' skips directories"
5165 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5167 setup_56_special $dir $NUMFILES $NUMDIRS
5169 local expected=$((NUMDIRS + 1))
5170 local cmd="$LFS find -type d $dir"
5171 local nums=$($cmd | wc -l)
5173 [ $nums -eq $expected ] ||
5174 error "'$cmd' wrong: found $nums, expected $expected"
5176 run_test 56j "check lfs find -type d"
5179 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5181 setup_56_special $dir $NUMFILES $NUMDIRS
5183 local expected=$(((NUMDIRS + 1) * NUMFILES))
5184 local cmd="$LFS find -type f $dir"
5185 local nums=$($cmd | wc -l)
5187 [ $nums -eq $expected ] ||
5188 error "'$cmd' wrong: found $nums, expected $expected"
5190 run_test 56k "check lfs find -type f"
5193 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5195 setup_56_special $dir $NUMFILES $NUMDIRS
5197 local expected=$((NUMDIRS + NUMFILES))
5198 local cmd="$LFS find -type b $dir"
5199 local nums=$($cmd | wc -l)
5201 [ $nums -eq $expected ] ||
5202 error "'$cmd' wrong: found $nums, expected $expected"
5204 run_test 56l "check lfs find -type b"
5207 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5209 setup_56_special $dir $NUMFILES $NUMDIRS
5211 local expected=$((NUMDIRS + NUMFILES))
5212 local cmd="$LFS find -type c $dir"
5213 local nums=$($cmd | wc -l)
5214 [ $nums -eq $expected ] ||
5215 error "'$cmd' wrong: found $nums, expected $expected"
5217 run_test 56m "check lfs find -type c"
5220 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5221 setup_56_special $dir $NUMFILES $NUMDIRS
5223 local expected=$((NUMDIRS + NUMFILES))
5224 local cmd="$LFS find -type l $dir"
5225 local nums=$($cmd | wc -l)
5227 [ $nums -eq $expected ] ||
5228 error "'$cmd' wrong: found $nums, expected $expected"
5230 run_test 56n "check lfs find -type l"
5233 local dir=$DIR/$tdir
5235 setup_56 $dir $NUMFILES $NUMDIRS
5236 utime $dir/file1 > /dev/null || error "utime (1)"
5237 utime $dir/file2 > /dev/null || error "utime (2)"
5238 utime $dir/dir1 > /dev/null || error "utime (3)"
5239 utime $dir/dir2 > /dev/null || error "utime (4)"
5240 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5241 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5244 local nums=$($LFS find -mtime +0 $dir | wc -l)
5246 [ $nums -eq $expected ] ||
5247 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5250 cmd="$LFS find -mtime 0 $dir"
5251 nums=$($cmd | wc -l)
5252 [ $nums -eq $expected ] ||
5253 error "'$cmd' wrong: found $nums, expected $expected"
5255 run_test 56o "check lfs find -mtime for old files"
5258 [ $RUNAS_ID -eq $UID ] &&
5259 skip_env "RUNAS_ID = UID = $UID -- skipping"
5261 local dir=$DIR/$tdir
5263 setup_56 $dir $NUMFILES $NUMDIRS
5264 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5266 local expected=$NUMFILES
5267 local cmd="$LFS find -uid $RUNAS_ID $dir"
5268 local nums=$($cmd | wc -l)
5270 [ $nums -eq $expected ] ||
5271 error "'$cmd' wrong: found $nums, expected $expected"
5273 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5274 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5275 nums=$($cmd | wc -l)
5276 [ $nums -eq $expected ] ||
5277 error "'$cmd' wrong: found $nums, expected $expected"
5279 run_test 56p "check lfs find -uid and ! -uid"
5282 [ $RUNAS_ID -eq $UID ] &&
5283 skip_env "RUNAS_ID = UID = $UID -- skipping"
5285 local dir=$DIR/$tdir
5287 setup_56 $dir $NUMFILES $NUMDIRS
5288 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5290 local expected=$NUMFILES
5291 local cmd="$LFS find -gid $RUNAS_GID $dir"
5292 local nums=$($cmd | wc -l)
5294 [ $nums -eq $expected ] ||
5295 error "'$cmd' wrong: found $nums, expected $expected"
5297 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5298 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5299 nums=$($cmd | wc -l)
5300 [ $nums -eq $expected ] ||
5301 error "'$cmd' wrong: found $nums, expected $expected"
5303 run_test 56q "check lfs find -gid and ! -gid"
5306 local dir=$DIR/$tdir
5308 setup_56 $dir $NUMFILES $NUMDIRS
5311 local cmd="$LFS find -size 0 -type f -lazy $dir"
5312 local nums=$($cmd | wc -l)
5314 [ $nums -eq $expected ] ||
5315 error "'$cmd' wrong: found $nums, expected $expected"
5316 cmd="$LFS find -size 0 -type f $dir"
5317 nums=$($cmd | wc -l)
5318 [ $nums -eq $expected ] ||
5319 error "'$cmd' wrong: found $nums, expected $expected"
5322 cmd="$LFS find ! -size 0 -type f -lazy $dir"
5323 nums=$($cmd | wc -l)
5324 [ $nums -eq $expected ] ||
5325 error "'$cmd' wrong: found $nums, expected $expected"
5326 cmd="$LFS find ! -size 0 -type f $dir"
5327 nums=$($cmd | wc -l)
5328 [ $nums -eq $expected ] ||
5329 error "'$cmd' wrong: found $nums, expected $expected"
5331 echo "test" > $dir/$tfile
5332 echo "test2" > $dir/$tfile.2 && sync
5334 cmd="$LFS find -size 5 -type f -lazy $dir"
5335 nums=$($cmd | wc -l)
5336 [ $nums -eq $expected ] ||
5337 error "'$cmd' wrong: found $nums, expected $expected"
5338 cmd="$LFS find -size 5 -type f $dir"
5339 nums=$($cmd | wc -l)
5340 [ $nums -eq $expected ] ||
5341 error "'$cmd' wrong: found $nums, expected $expected"
5344 cmd="$LFS find -size +5 -type f -lazy $dir"
5345 nums=$($cmd | wc -l)
5346 [ $nums -eq $expected ] ||
5347 error "'$cmd' wrong: found $nums, expected $expected"
5348 cmd="$LFS find -size +5 -type f $dir"
5349 nums=$($cmd | wc -l)
5350 [ $nums -eq $expected ] ||
5351 error "'$cmd' wrong: found $nums, expected $expected"
5354 cmd="$LFS find -size +0 -type f -lazy $dir"
5355 nums=$($cmd | wc -l)
5356 [ $nums -eq $expected ] ||
5357 error "'$cmd' wrong: found $nums, expected $expected"
5358 cmd="$LFS find -size +0 -type f $dir"
5359 nums=$($cmd | wc -l)
5360 [ $nums -eq $expected ] ||
5361 error "'$cmd' wrong: found $nums, expected $expected"
5364 cmd="$LFS find ! -size -5 -type f -lazy $dir"
5365 nums=$($cmd | wc -l)
5366 [ $nums -eq $expected ] ||
5367 error "'$cmd' wrong: found $nums, expected $expected"
5368 cmd="$LFS find ! -size -5 -type f $dir"
5369 nums=$($cmd | wc -l)
5370 [ $nums -eq $expected ] ||
5371 error "'$cmd' wrong: found $nums, expected $expected"
5374 cmd="$LFS find -size -5 -type f -lazy $dir"
5375 nums=$($cmd | wc -l)
5376 [ $nums -eq $expected ] ||
5377 error "'$cmd' wrong: found $nums, expected $expected"
5378 cmd="$LFS find -size -5 -type f $dir"
5379 nums=$($cmd | wc -l)
5380 [ $nums -eq $expected ] ||
5381 error "'$cmd' wrong: found $nums, expected $expected"
5383 run_test 56r "check lfs find -size works"
5390 cancel_lru_locks $OSC
5392 local rpcs_before=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5393 local nums=$($cmd | wc -l)
5395 [ $nums -eq $expected ] ||
5396 error "'$cmd' wrong: found $nums, expected $expected"
5398 local rpcs_after=$(calc_stats $OSC.*$OSC*.stats ldlm_glimpse_enqueue)
5400 if (( rpcs_before + glimpses != rpcs_after )); then
5401 echo "Before: $rpcs_before After: $rpcs_after $NUMFILES"
5402 $LCTL get_param osc.*.stats | grep ldlm_glimpse_enqueue
5404 if [[ $glimpses == 0 ]]; then
5405 error "'$cmd' should not send glimpse RPCs to OST"
5407 error "'$cmd' should send $glimpses glimpse RPCs to OST"
5413 [[ $MDS1_VERSION -ge $(version_code 2.12.4) ]] ||
5414 skip "MDS < 2.12.4 doesn't return LSOM data"
5415 local dir=$DIR/$tdir
5417 [[ $OSC == "mdc" ]] && skip "DoM files"
5419 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5420 # open and close all files to ensure LSOM is updated
5421 cancel_lru_locks $OSC
5422 find $dir -type f | xargs cat > /dev/null
5424 # expect_found glimpse_rpcs command_to_run
5425 test_56ra_sub 12 0 "$LFS find -size 0 -type f -lazy $dir"
5426 test_56ra_sub 12 12 "$LFS find -size 0 -type f $dir"
5427 test_56ra_sub 0 0 "$LFS find ! -size 0 -type f -lazy $dir"
5428 test_56ra_sub 0 12 "$LFS find ! -size 0 -type f $dir"
5430 echo "test" > $dir/$tfile
5431 echo "test2" > $dir/$tfile.2 && sync
5432 cancel_lru_locks $OSC
5433 cat $dir/$tfile $dir/$tfile.2 > /dev/null
5435 test_56ra_sub 1 0 "$LFS find -size 5 -type f -lazy $dir"
5436 test_56ra_sub 1 14 "$LFS find -size 5 -type f $dir"
5437 test_56ra_sub 1 0 "$LFS find -size +5 -type f -lazy $dir"
5438 test_56ra_sub 1 14 "$LFS find -size +5 -type f $dir"
5440 test_56ra_sub 2 0 "$LFS find -size +0 -type f -lazy $dir"
5441 test_56ra_sub 2 14 "$LFS find -size +0 -type f $dir"
5442 test_56ra_sub 2 0 "$LFS find ! -size -5 -type f -lazy $dir"
5443 test_56ra_sub 2 14 "$LFS find ! -size -5 -type f $dir"
5444 test_56ra_sub 12 0 "$LFS find -size -5 -type f -lazy $dir"
5445 test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
5447 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
5449 test_56s() { # LU-611 #LU-9369
5450 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5452 local dir=$DIR/$tdir
5453 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5455 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5456 for i in $(seq $NUMDIRS); do
5457 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5460 local expected=$NUMDIRS
5461 local cmd="$LFS find -c $OSTCOUNT $dir"
5462 local nums=$($cmd | wc -l)
5464 [ $nums -eq $expected ] || {
5465 $LFS getstripe -R $dir
5466 error "'$cmd' wrong: found $nums, expected $expected"
5469 expected=$((NUMDIRS + onestripe))
5470 cmd="$LFS find -stripe-count +0 -type f $dir"
5471 nums=$($cmd | wc -l)
5472 [ $nums -eq $expected ] || {
5473 $LFS getstripe -R $dir
5474 error "'$cmd' wrong: found $nums, expected $expected"
5478 cmd="$LFS find -stripe-count 1 -type f $dir"
5479 nums=$($cmd | wc -l)
5480 [ $nums -eq $expected ] || {
5481 $LFS getstripe -R $dir
5482 error "'$cmd' wrong: found $nums, expected $expected"
5485 cmd="$LFS find -stripe-count -2 -type f $dir"
5486 nums=$($cmd | wc -l)
5487 [ $nums -eq $expected ] || {
5488 $LFS getstripe -R $dir
5489 error "'$cmd' wrong: found $nums, expected $expected"
5493 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5494 nums=$($cmd | wc -l)
5495 [ $nums -eq $expected ] || {
5496 $LFS getstripe -R $dir
5497 error "'$cmd' wrong: found $nums, expected $expected"
5500 run_test 56s "check lfs find -stripe-count works"
5502 test_56t() { # LU-611 #LU-9369
5503 local dir=$DIR/$tdir
5505 setup_56 $dir 0 $NUMDIRS
5506 for i in $(seq $NUMDIRS); do
5507 $LFS setstripe -S 8M $dir/dir$i/$tfile
5510 local expected=$NUMDIRS
5511 local cmd="$LFS find -S 8M $dir"
5512 local nums=$($cmd | wc -l)
5514 [ $nums -eq $expected ] || {
5515 $LFS getstripe -R $dir
5516 error "'$cmd' wrong: found $nums, expected $expected"
5520 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5522 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5524 expected=$(((NUMDIRS + 1) * NUMFILES))
5525 cmd="$LFS find -stripe-size 512k -type f $dir"
5526 nums=$($cmd | wc -l)
5527 [ $nums -eq $expected ] ||
5528 error "'$cmd' wrong: found $nums, expected $expected"
5530 cmd="$LFS find -stripe-size +320k -type f $dir"
5531 nums=$($cmd | wc -l)
5532 [ $nums -eq $expected ] ||
5533 error "'$cmd' wrong: found $nums, expected $expected"
5535 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5536 cmd="$LFS find -stripe-size +200k -type f $dir"
5537 nums=$($cmd | wc -l)
5538 [ $nums -eq $expected ] ||
5539 error "'$cmd' wrong: found $nums, expected $expected"
5541 cmd="$LFS find -stripe-size -640k -type f $dir"
5542 nums=$($cmd | wc -l)
5543 [ $nums -eq $expected ] ||
5544 error "'$cmd' wrong: found $nums, expected $expected"
5547 cmd="$LFS find -stripe-size 256k -type f $dir"
5548 nums=$($cmd | wc -l)
5549 [ $nums -eq $expected ] ||
5550 error "'$cmd' wrong: found $nums, expected $expected"
5552 cmd="$LFS find -stripe-size -320k -type f $dir"
5553 nums=$($cmd | wc -l)
5554 [ $nums -eq $expected ] ||
5555 error "'$cmd' wrong: found $nums, expected $expected"
5558 cmd="$LFS find -stripe-size 1024k -type f $dir"
5559 nums=$($cmd | wc -l)
5560 [ $nums -eq $expected ] ||
5561 error "'$cmd' wrong: found $nums, expected $expected"
5563 run_test 56t "check lfs find -stripe-size works"
5565 test_56u() { # LU-611
5566 local dir=$DIR/$tdir
5568 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5570 if [[ $OSTCOUNT -gt 1 ]]; then
5571 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5577 local expected=$(((NUMDIRS + 1) * NUMFILES))
5578 local cmd="$LFS find -stripe-index 0 -type f $dir"
5579 local nums=$($cmd | wc -l)
5581 [ $nums -eq $expected ] ||
5582 error "'$cmd' wrong: found $nums, expected $expected"
5585 cmd="$LFS find -stripe-index 1 -type f $dir"
5586 nums=$($cmd | wc -l)
5587 [ $nums -eq $expected ] ||
5588 error "'$cmd' wrong: found $nums, expected $expected"
5590 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5591 nums=$($cmd | wc -l)
5592 [ $nums -eq $expected ] ||
5593 error "'$cmd' wrong: found $nums, expected $expected"
5596 # This should produce an error and not return any files
5597 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5598 nums=$($cmd 2>/dev/null | wc -l)
5599 [ $nums -eq $expected ] ||
5600 error "'$cmd' wrong: found $nums, expected $expected"
5602 if [[ $OSTCOUNT -gt 1 ]]; then
5603 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5604 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5605 nums=$($cmd | wc -l)
5606 [ $nums -eq $expected ] ||
5607 error "'$cmd' wrong: found $nums, expected $expected"
5610 run_test 56u "check lfs find -stripe-index works"
5614 local dir=$DIR/$tdir
5616 setup_56 $dir $NUMFILES $NUMDIRS
5618 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5619 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5621 for file in $($LFS find -m $UUID $dir); do
5622 file_midx=$($LFS getstripe -m $file)
5623 [ $file_midx -eq $mdt_idx ] ||
5624 error "lfs find -m $UUID != getstripe -m $file_midx"
5627 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5630 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5633 local dir=$DIR/$tdir
5635 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5637 local stripe_size=$($LFS getstripe -S -d $dir) ||
5638 error "$LFS getstripe -S -d $dir failed"
5639 stripe_size=${stripe_size%% *}
5641 local file_size=$((stripe_size * OSTCOUNT))
5642 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5643 local required_space=$((file_num * file_size))
5644 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5646 [[ $free_space -le $((required_space / 1024)) ]] &&
5647 skip_env "need $required_space, have $free_space kbytes"
5650 local dd_count=$((file_size / dd_bs))
5652 # write data into the files
5657 for i in $(seq $NUMFILES); do
5659 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5660 error "write data into $file failed"
5662 for i in $(seq $NUMDIRS); do
5663 for j in $(seq $NUMFILES); do
5664 file=$dir/dir$i/file$j
5665 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5666 error "write data into $file failed"
5670 # $LFS_MIGRATE will fail if hard link migration is unsupported
5671 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5672 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5673 error "creating links to $dir/dir1/file1 failed"
5678 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5681 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5684 eval $cmd || error "$cmd failed"
5686 check_stripe_count $dir/file1 $expected
5688 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5690 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5691 # OST 1 if it is on OST 0. This file is small enough to
5692 # be on only one stripe.
5693 file=$dir/migr_1_ost
5694 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5695 error "write data into $file failed"
5696 local obdidx=$($LFS getstripe -i $file)
5697 local oldmd5=$(md5sum $file)
5700 [[ $obdidx -eq 0 ]] && newobdidx=1
5701 cmd="$LFS migrate -i $newobdidx $file"
5703 eval $cmd || error "$cmd failed"
5705 local realobdix=$($LFS getstripe -i $file)
5706 local newmd5=$(md5sum $file)
5708 [[ $newobdidx -ne $realobdix ]] &&
5709 error "new OST is different (was=$obdidx, "\
5710 "wanted=$newobdidx, got=$realobdix)"
5711 [[ "$oldmd5" != "$newmd5" ]] &&
5712 error "md5sum differ: $oldmd5, $newmd5"
5716 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5718 eval $cmd || error "$cmd failed"
5720 for j in $(seq $NUMFILES); do
5721 check_stripe_count $dir/dir1/file$j $expected
5724 # lfs_migrate works with lfs find
5725 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5726 $LFS_MIGRATE -y -c $expected"
5728 eval $cmd || error "$cmd failed"
5730 for i in $(seq 2 $NUMFILES); do
5731 check_stripe_count $dir/file$i $expected
5733 for i in $(seq 2 $NUMDIRS); do
5734 for j in $(seq $NUMFILES); do
5735 check_stripe_count $dir/dir$i/file$j $expected
5739 run_test 56w "check lfs_migrate -c stripe_count works"
5742 local file1=$DIR/$tdir/file1
5743 local create_pool=false
5744 local initial_pool=$($LFS getstripe -p $DIR)
5748 echo -n "Creating test dir..."
5749 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5752 echo -n "Creating test file..."
5753 touch $file1 || error "cannot create file"
5756 echo -n "Detecting existing pools..."
5757 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5759 if [ ${#pool_list[@]} -gt 0 ]; then
5760 echo "${pool_list[@]}"
5761 for thispool in "${pool_list[@]}"; do
5762 if [[ -z "$initial_pool" ||
5763 "$initial_pool" != "$thispool" ]]; then
5765 echo "Using existing pool '$pool'"
5770 echo "none detected."
5772 if [ -z "$pool" ]; then
5773 pool=${POOL:-testpool}
5774 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5775 echo -n "Creating pool '$pool'..."
5777 pool_add $pool &> /dev/null ||
5778 error "pool_add failed"
5781 echo -n "Adding target to pool..."
5782 pool_add_targets $pool 0 0 1 &> /dev/null ||
5783 error "pool_add_targets failed"
5787 echo -n "Setting pool using -p option..."
5788 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5789 error "migrate failed rc = $?"
5792 echo -n "Verifying test file is in pool after migrating..."
5793 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5794 error "file was not migrated to pool $pool"
5797 echo -n "Removing test file from pool '$pool'..."
5798 # "lfs migrate $file" won't remove the file from the pool
5799 # until some striping information is changed.
5800 $LFS migrate -c 1 $file1 &> /dev/null ||
5801 error "cannot remove from pool"
5802 [ "$($LFS getstripe -p $file1)" ] &&
5803 error "pool still set"
5806 echo -n "Setting pool using --pool option..."
5807 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5808 error "migrate failed rc = $?"
5813 if $create_pool; then
5814 destroy_test_pools 2> /dev/null ||
5815 error "destroy test pools failed"
5818 run_test 56wb "check lfs_migrate pool support"
5821 local file1="$DIR/$tdir/file1"
5828 echo -n "Creating test dir..."
5829 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5830 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5831 error "cannot set stripe by '-S 1M -c 1'"
5834 echo -n "Setting initial stripe for test file..."
5835 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5836 error "cannot set stripe"
5837 cur_ssize=$($LFS getstripe -S "$file1")
5838 [ $cur_ssize -eq 524288 ] || error "setstripe -S $cur_ssize != 524288"
5841 # File currently set to -S 512K -c 1
5843 # Ensure -c and -S options are rejected when -R is set
5844 echo -n "Verifying incompatible options are detected..."
5845 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5846 error "incompatible -c and -R options not detected"
5847 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5848 error "incompatible -S and -R options not detected"
5851 # Ensure unrecognized options are passed through to 'lfs migrate'
5852 echo -n "Verifying -S option is passed through to lfs migrate..."
5853 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5854 error "migration failed"
5855 cur_ssize=$($LFS getstripe -S "$file1")
5856 [ $cur_ssize -eq 1048576 ] || error "migrate -S $cur_ssize != 1048576"
5859 # File currently set to -S 1M -c 1
5861 # Ensure long options are supported
5862 echo -n "Verifying long options supported..."
5863 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5864 error "long option without argument not supported"
5865 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5866 error "long option with argument not supported"
5867 cur_ssize=$($LFS getstripe -S "$file1")
5868 [ $cur_ssize -eq 524288 ] ||
5869 error "migrate --stripe-size $cur_ssize != 524288"
5872 # File currently set to -S 512K -c 1
5874 if [ "$OSTCOUNT" -gt 1 ]; then
5875 echo -n "Verifying explicit stripe count can be set..."
5876 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5877 error "migrate failed"
5878 cur_scount=$($LFS getstripe -c "$file1")
5879 [ $cur_scount -eq 2 ] || error "migrate -c $cur_scount != 2"
5883 # File currently set to -S 512K -c 1 or -S 512K -c 2
5885 # Ensure parent striping is used if -R is set, and no stripe
5886 # count or size is specified
5887 echo -n "Setting stripe for parent directory..."
5888 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5889 error "cannot set stripe '-S 2M -c 1'"
5892 echo -n "Verifying restripe option uses parent stripe settings..."
5893 parent_ssize=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5894 parent_scount=$($LFS getstripe -c $DIR/$tdir 2>/dev/null)
5895 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5896 error "migrate failed"
5897 cur_ssize=$($LFS getstripe -S "$file1")
5898 [ $cur_ssize -eq $parent_ssize ] ||
5899 error "migrate -R stripe_size $cur_ssize != $parent_ssize"
5900 cur_scount=$($LFS getstripe -c "$file1")
5901 [ $cur_scount -eq $parent_scount ] ||
5902 error "migrate -R stripe_count $cur_scount != $parent_scount"
5905 # File currently set to -S 1M -c 1
5907 # Ensure striping is preserved if -R is not set, and no stripe
5908 # count or size is specified
5909 echo -n "Verifying striping size preserved when not specified..."
5910 orig_ssize=$($LFS getstripe -S "$file1" 2>/dev/null)
5911 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5912 error "cannot set stripe on parent directory"
5913 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5914 error "migrate failed"
5915 cur_ssize=$($LFS getstripe -S "$file1")
5916 [ $cur_ssize -eq $orig_ssize ] ||
5917 error "migrate by default $cur_ssize != $orig_ssize"
5920 # Ensure file name properly detected when final option has no argument
5921 echo -n "Verifying file name properly detected..."
5922 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5923 error "file name interpreted as option argument"
5929 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5932 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5934 local file1=$DIR/$tdir/file1
5936 echo -n "Creating test dir..."
5937 test_mkdir $DIR/$tdir || error "cannot create dir"
5940 echo -n "Creating test file..."
5944 # Ensure 'lfs migrate' will fail by using a non-existent option,
5945 # and make sure rsync is not called to recover
5946 echo -n "Make sure --no-rsync option works..."
5947 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5948 grep -q 'refusing to fall back to rsync' ||
5949 error "rsync was called with --no-rsync set"
5952 # Ensure rsync is called without trying 'lfs migrate' first
5953 echo -n "Make sure --rsync option works..."
5954 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5955 grep -q 'falling back to rsync' &&
5956 error "lfs migrate was called with --rsync set"
5959 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5960 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5961 grep -q 'at the same time' ||
5962 error "--rsync and --no-rsync accepted concurrently"
5968 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5971 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5972 check_swap_layouts_support
5974 local dir=$DIR/$tdir
5975 local ref1=/etc/passwd
5976 local file1=$dir/file1
5978 test_mkdir $dir || error "creating dir $dir"
5979 $LFS setstripe -c 2 $file1
5981 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5982 stripe=$($LFS getstripe -c $file1)
5983 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5984 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5989 run_test 56x "lfs migration support"
5992 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5993 check_swap_layouts_support
5995 local dir=$DIR/$tdir/$testnum
5999 local ref1=/etc/passwd
6000 local file1=$dir/file1
6002 $LFS setstripe -c 2 $file1
6004 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
6006 local stripe=$($LFS getstripe -c $file1)
6008 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
6009 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
6014 run_test 56xa "lfs migration --block support"
6016 check_migrate_links() {
6018 local file1="$dir/file1"
6021 local total_count=$(($begin + $count - 1))
6022 local symlink_count=10
6025 if [ ! -f "$file1" ]; then
6026 echo -n "creating initial file..."
6027 $LFS setstripe -c 1 -S "512k" "$file1" ||
6028 error "cannot setstripe initial file"
6031 echo -n "creating symlinks..."
6032 for s in $(seq 1 $symlink_count); do
6033 ln -s "$file1" "$dir/slink$s" ||
6034 error "cannot create symlinks"
6038 echo -n "creating nonlinked files..."
6039 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
6040 error "cannot create nonlinked files"
6045 if [ ! -f "$dir/file$total_count" ]; then
6046 echo -n "creating hard links $begin:$total_count..."
6047 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
6048 /dev/null || error "cannot create hard links"
6052 echo -n "checking number of hard links listed in xattrs..."
6053 local fid=$($LFS getstripe -F "$file1")
6054 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
6057 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
6058 skip "hard link list has unexpected size, skipping test"
6060 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
6061 error "link names should exceed xattrs size"
6064 echo -n "migrating files..."
6065 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
6067 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
6070 # make sure all links have been properly migrated
6071 echo -n "verifying files..."
6072 fid=$($LFS getstripe -F "$file1") ||
6073 error "cannot get fid for file $file1"
6074 for i in $(seq 2 $total_count); do
6075 local fid2=$($LFS getstripe -F $dir/file$i)
6077 [ "$fid2" == "$fid" ] ||
6078 error "migrated hard link has mismatched FID"
6081 # make sure hard links were properly detected, and migration was
6082 # performed only once for the entire link set; nonlinked files should
6084 local actual=$(grep -c 'done' <<< "$migrate_out")
6085 local expected=$(($uniq_count + 1))
6087 [ "$actual" -eq "$expected" ] ||
6088 error "hard links individually migrated ($actual != $expected)"
6090 # make sure the correct number of hard links are present
6091 local hardlinks=$(stat -c '%h' "$file1")
6093 [ $hardlinks -eq $total_count ] ||
6094 error "num hard links $hardlinks != $total_count"
6101 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
6102 skip "Need MDS version at least 2.10.55"
6104 local dir="$DIR/$tdir"
6106 test_mkdir "$dir" || error "cannot create dir $dir"
6108 echo "testing lfs migrate mode when all links fit within xattrs"
6109 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 2 99
6111 echo "testing rsync mode when all links fit within xattrs"
6112 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 2 99
6114 echo "testing lfs migrate mode when all links do not fit within xattrs"
6115 LFS_MIGRATE_RSYNC_MODE=false check_migrate_links "$dir" 101 100
6117 echo "testing rsync mode when all links do not fit within xattrs"
6118 LFS_MIGRATE_RSYNC_MODE=true check_migrate_links "$dir" 101 100
6124 run_test 56xb "lfs migration hard link support"
6127 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6129 local dir="$DIR/$tdir"
6131 test_mkdir "$dir" || error "cannot create dir $dir"
6133 # Test 1: ensure file < 1 GB is always migrated with 1 stripe
6134 echo -n "Setting initial stripe for 20MB test file..."
6135 $LFS setstripe -c 2 -i 0 "$dir/20mb" ||
6136 error "cannot setstripe 20MB file"
6138 echo -n "Sizing 20MB test file..."
6139 truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file"
6141 echo -n "Verifying small file autostripe count is 1..."
6142 $LFS_MIGRATE -y -A -C 1 "$dir/20mb" ||
6143 error "cannot migrate 20MB file"
6144 local stripe_count=$($LFS getstripe -c "$dir/20mb") ||
6145 error "cannot get stripe for $dir/20mb"
6146 [ $stripe_count -eq 1 ] ||
6147 error "unexpected stripe count $stripe_count for 20MB file"
6151 # Test 2: File is small enough to fit within the available space on
6152 # sqrt(size_in_gb) + 1 OSTs but is larger than 1GB. The file must
6153 # have at least an additional 1KB for each desired stripe for test 3
6154 echo -n "Setting stripe for 1GB test file..."
6155 $LFS setstripe -c 1 -i 0 "$dir/1gb" || error "cannot setstripe 1GB file"
6157 echo -n "Sizing 1GB test file..."
6158 # File size is 1GB + 3KB
6159 truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file"
6162 # need at least 512MB per OST for 1GB file to fit in 2 stripes
6163 local avail=$($LCTL get_param -n llite.$FSNAME*.kbytesavail)
6164 if (( avail > 524288 * OSTCOUNT )); then
6165 echo -n "Migrating 1GB file..."
6166 $LFS_MIGRATE -y -A -C 1 "$dir/1gb" ||
6167 error "cannot migrate 1GB file"
6169 echo -n "Verifying autostripe count is sqrt(n) + 1..."
6170 stripe_count=$($LFS getstripe -c "$dir/1gb") ||
6171 error "cannot getstripe for 1GB file"
6172 [ $stripe_count -eq 2 ] ||
6173 error "unexpected stripe count $stripe_count != 2"
6177 # Test 3: File is too large to fit within the available space on
6178 # sqrt(n) + 1 OSTs. Simulate limited available space with -X
6179 if [ $OSTCOUNT -ge 3 ]; then
6180 # The required available space is calculated as
6181 # file size (1GB + 3KB) / OST count (3).
6182 local kb_per_ost=349526
6184 echo -n "Migrating 1GB file with limit..."
6185 $LFS_MIGRATE -y -A -C 1 -X $kb_per_ost "$dir/1gb" ||
6186 error "cannot migrate 1GB file with limit"
6189 stripe_count=$($LFS getstripe -c "$dir/1gb")
6190 echo -n "Verifying 1GB autostripe count with limited space..."
6191 [ "$stripe_count" -a $stripe_count -ge 3 ] ||
6192 error "unexpected stripe count $stripe_count (min 3)"
6199 run_test 56xc "lfs migration autostripe"
6202 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6204 local dir=$DIR/$tdir
6205 local f_mgrt=$dir/$tfile.mgrt
6206 local f_yaml=$dir/$tfile.yaml
6207 local f_copy=$dir/$tfile.copy
6208 local layout_yaml="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6209 local layout_copy="-c 2 -S 2M -i 1"
6210 local yamlfile=$dir/yamlfile
6211 local layout_before;
6214 test_mkdir "$dir" || error "cannot create dir $dir"
6215 $LFS setstripe $layout_yaml $f_yaml ||
6216 error "cannot setstripe $f_yaml with layout $layout_yaml"
6217 $LFS getstripe --yaml $f_yaml > $yamlfile
6218 $LFS setstripe $layout_copy $f_copy ||
6219 error "cannot setstripe $f_copy with layout $layout_copy"
6221 dd if=/dev/zero of=$f_mgrt bs=1M count=4
6223 # 1. test option --yaml
6224 $LFS_MIGRATE -y --yaml $yamlfile $f_mgrt ||
6225 error "cannot migrate $f_mgrt with --yaml $yamlfile"
6226 layout_before=$(get_layout_param $f_yaml)
6227 layout_after=$(get_layout_param $f_mgrt)
6228 [ "$layout_after" == "$layout_before" ] ||
6229 error "lfs_migrate --yaml: $layout_after != $layout_before"
6231 # 2. test option --copy
6232 $LFS_MIGRATE -y --copy $f_copy $f_mgrt ||
6233 error "cannot migrate $f_mgrt with --copy $f_copy"
6234 layout_before=$(get_layout_param $f_copy)
6235 layout_after=$(get_layout_param $f_mgrt)
6236 [ "$layout_after" == "$layout_before" ] ||
6237 error "lfs_migrate --copy: $layout_after != $layout_before"
6239 run_test 56xd "check lfs_migrate --yaml and --copy support"
6242 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6244 local dir=$DIR/$tdir
6245 local f_comp=$dir/$tfile
6246 local layout="-E 1M -S 512K -c 1 -E -1 -S 1M -c 2 -i 0"
6247 local layout_before=""
6248 local layout_after=""
6250 test_mkdir "$dir" || error "cannot create dir $dir"
6251 $LFS setstripe $layout $f_comp ||
6252 error "cannot setstripe $f_comp with layout $layout"
6253 layout_before=$(get_layout_param $f_comp)
6254 dd if=/dev/zero of=$f_comp bs=1M count=4
6256 # 1. migrate a comp layout file by lfs_migrate
6257 $LFS_MIGRATE -y $f_comp || error "cannot migrate $f_comp by lfs_migrate"
6258 layout_after=$(get_layout_param $f_comp)
6259 [ "$layout_before" == "$layout_after" ] ||
6260 error "lfs_migrate: $layout_before != $layout_after"
6262 # 2. migrate a comp layout file by lfs migrate
6263 $LFS migrate $f_comp || error "cannot migrate $f_comp by lfs migrate"
6264 layout_after=$(get_layout_param $f_comp)
6265 [ "$layout_before" == "$layout_after" ] ||
6266 error "lfs migrate: $layout_before != $layout_after"
6268 run_test 56xe "migrate a composite layout file"
6271 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
6272 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
6275 local dir=$DIR/$tdir
6279 test_mkdir -p $dir || error "creating dir $dir"
6280 touch $f1 || error "creating std file $f1"
6281 $MULTIOP $f2 H2c || error "creating released file $f2"
6283 # a directory can be raid0, so ask only for files
6284 res=$($LFS find $dir -L raid0 -type f | wc -l)
6285 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
6287 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
6288 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
6290 # only files can be released, so no need to force file search
6291 res=$($LFS find $dir -L released)
6292 [[ $res == $f2 ]] || error "search released: found $res != $f2"
6294 res=$($LFS find $dir -type f \! -L released)
6295 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
6297 run_test 56y "lfs find -L raid0|released"
6299 test_56z() { # LU-4824
6300 # This checks to make sure 'lfs find' continues after errors
6301 # There are two classes of errors that should be caught:
6302 # - If multiple paths are provided, all should be searched even if one
6304 # - If errors are encountered during the search, it should not terminate
6306 local dir=$DIR/$tdir
6310 for i in d{0..9}; do
6312 touch $dir/$i/$tfile
6314 $LFS find $DIR/non_existent_dir $dir &&
6315 error "$LFS find did not return an error"
6316 # Make a directory unsearchable. This should NOT be the last entry in
6317 # directory order. Arbitrarily pick the 6th entry
6318 chmod 700 $($LFS find $dir -type d | sed '6!d')
6320 $RUNAS $LFS find $DIR/non_existent $dir
6321 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
6323 # The user should be able to see 10 directories and 9 files
6324 (( count == 19 )) ||
6325 error "$LFS find found $count != 19 entries after error"
6327 run_test 56z "lfs find should continue after an error"
6329 test_56aa() { # LU-5937
6330 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
6332 local dir=$DIR/$tdir
6335 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
6337 createmany -o $dir/striped_dir/${tfile}- 1024
6338 local dirs=$($LFS find --size +8k $dir/)
6340 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
6342 run_test 56aa "lfs find --size under striped dir"
6344 test_56ab() { # LU-10705
6345 test_mkdir $DIR/$tdir
6346 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
6347 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
6348 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
6349 # Flush writes to ensure valid blocks. Need to be more thorough for
6350 # ZFS, since blocks are not allocated/returned to client immediately.
6352 wait_zfs_commit ost1 2
6353 cancel_lru_locks osc
6356 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
6358 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
6360 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
6361 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
6363 rm -f $DIR/$tdir/$tfile.[123]
6365 run_test 56ab "lfs find --blocks"
6368 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
6369 skip "Need MDS version at least 2.10.50"
6371 # Create composite files with one component
6372 local dir=$DIR/$tdir
6374 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
6375 # Create composite files with three components
6376 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
6377 # Create non-composite files
6378 createmany -o $dir/${tfile}- 10
6380 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
6382 [[ $nfiles == 10 ]] ||
6383 error "lfs find -E 1M found $nfiles != 10 files"
6385 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
6386 [[ $nfiles == 25 ]] ||
6387 error "lfs find ! -E 1M found $nfiles != 25 files"
6389 # All files have a component that starts at 0
6390 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
6391 [[ $nfiles == 35 ]] ||
6392 error "lfs find --component-start 0 - $nfiles != 35 files"
6394 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6395 [[ $nfiles == 15 ]] ||
6396 error "lfs find --component-start 2M - $nfiles != 15 files"
6398 # All files created here have a componenet that does not starts at 2M
6399 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6400 [[ $nfiles == 35 ]] ||
6401 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6403 # Find files with a specified number of components
6404 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6405 [[ $nfiles == 15 ]] ||
6406 error "lfs find --component-count 3 - $nfiles != 15 files"
6408 # Remember non-composite files have a component count of zero
6409 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6410 [[ $nfiles == 10 ]] ||
6411 error "lfs find --component-count 0 - $nfiles != 10 files"
6413 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6414 [[ $nfiles == 20 ]] ||
6415 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6417 # All files have a flag called "init"
6418 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6419 [[ $nfiles == 35 ]] ||
6420 error "lfs find --component-flags init - $nfiles != 35 files"
6422 # Multi-component files will have a component not initialized
6423 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6424 [[ $nfiles == 15 ]] ||
6425 error "lfs find !--component-flags init - $nfiles != 15 files"
6430 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6433 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6434 skip "Need MDS version at least 2.10.57"
6444 # create mirrored directories and mirrored files
6445 mkdir $td || error "mkdir $td failed"
6446 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6447 createmany -o $tf- 10 || error "create $tf- failed"
6449 for i in $(seq 2); do
6451 mkdir $dir || error "mkdir $dir failed"
6452 $LFS mirror create -N$((3 + i)) $dir ||
6453 error "create mirrored dir $dir failed"
6454 createmany -o $dir/$tfile- 10 ||
6455 error "create $dir/$tfile- failed"
6458 # change the states of some mirrored files
6460 for i in $(seq 2); do
6462 for j in $(seq 4 9); do
6463 echo foo > $dir/$tfile-$j
6467 # find mirrored files with specific mirror count
6468 cmd="$LFS find --mirror-count 3 --type f $td"
6469 nfiles=$($cmd | wc -l)
6470 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6472 cmd="$LFS find ! --mirror-count 3 --type f $td"
6473 nfiles=$($cmd | wc -l)
6474 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6476 cmd="$LFS find --mirror-count +2 --type f $td"
6477 nfiles=$($cmd | wc -l)
6478 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6480 cmd="$LFS find --mirror-count -6 --type f $td"
6481 nfiles=$($cmd | wc -l)
6482 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6484 # find mirrored files with specific file state
6485 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6486 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6488 cmd="$LFS find --mirror-state=ro --type f $td"
6489 nfiles=$($cmd | wc -l)
6490 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6492 cmd="$LFS find ! --mirror-state=ro --type f $td"
6493 nfiles=$($cmd | wc -l)
6494 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6496 cmd="$LFS find --mirror-state=wp --type f $td"
6497 nfiles=$($cmd | wc -l)
6498 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6500 cmd="$LFS find ! --mirror-state=sp --type f $td"
6501 nfiles=$($cmd | wc -l)
6502 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6504 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6507 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6508 # note test will not do anything if MDS is not local
6509 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6510 skip_env "ldiskfs only test"
6512 remote_mds_nodsh && skip "remote MDS with nodsh"
6514 local MNTDEV="osd*.*MDT*.mntdev"
6515 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6516 [ -z "$DEV" ] && error "can't access $MNTDEV"
6517 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6518 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6519 error "can't access $DEV"
6520 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6521 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6525 run_test 57a "verify MDS filesystem created with large inodes =="
6528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6529 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6530 skip_env "ldiskfs only test"
6532 remote_mds_nodsh && skip "remote MDS with nodsh"
6534 local dir=$DIR/$tdir
6537 local fileN=$dir/f$filecount
6539 rm -rf $dir || error "removing $dir"
6541 local mdtidx=$($LFS getstripe -m $dir)
6542 local mdtname=MDT$(printf %04x $mdtidx)
6543 local facet=mds$((mdtidx + 1))
6545 echo "mcreating $filecount files"
6546 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6548 # verify that files do not have EAs yet
6549 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6550 error "$file1 has an EA"
6551 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6552 error "$fileN has an EA"
6556 df $dir #make sure we get new statfs data
6557 local mdsfree=$(do_facet $facet \
6558 lctl get_param -n osd*.*$mdtname.kbytesfree)
6559 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6562 echo "opening files to create objects/EAs"
6563 for file in $(seq -f $dir/f%g 1 $filecount); do
6564 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6565 error "opening $file"
6568 # verify that files have EAs now
6569 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6570 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6572 sleep 1 #make sure we get new statfs data
6574 local mdsfree2=$(do_facet $facet \
6575 lctl get_param -n osd*.*$mdtname.kbytesfree)
6576 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6578 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6579 if [ "$mdsfree" != "$mdsfree2" ]; then
6580 error "MDC before $mdcfree != after $mdcfree2"
6582 echo "MDC before $mdcfree != after $mdcfree2"
6583 echo "unable to confirm if MDS has large inodes"
6588 run_test 57b "default LOV EAs are stored inside large inodes ==="
6591 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6592 [ -z "$(which wiretest 2>/dev/null)" ] &&
6593 skip_env "could not find wiretest"
6597 run_test 58 "verify cross-platform wire constants =============="
6600 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6602 echo "touch 130 files"
6603 createmany -o $DIR/f59- 130
6605 unlinkmany $DIR/f59- 130
6607 # wait for commitment of removal
6608 wait_delete_completed
6610 run_test 59 "verify cancellation of llog records async ========="
6612 TEST60_HEAD="test_60 run $RANDOM"
6614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6615 remote_mgs_nodsh && skip "remote MGS with nodsh"
6616 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6617 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6618 skip_env "missing subtest run-llog.sh"
6620 log "$TEST60_HEAD - from kernel mode"
6621 do_facet mgs "$LCTL dk > /dev/null"
6622 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6623 do_facet mgs $LCTL dk > $TMP/$tfile
6625 # LU-6388: test llog_reader
6626 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6627 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6628 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6629 skip_env "missing llog_reader"
6630 local fstype=$(facet_fstype mgs)
6631 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6632 skip_env "Only for ldiskfs or zfs type mgs"
6634 local mntpt=$(facet_mntpt mgs)
6635 local mgsdev=$(mgsdevname 1)
6647 #get fid and record list
6648 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6650 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6652 #remount mgs as ldiskfs or zfs type
6653 stop mgs || error "stop mgs failed"
6654 mount_fstype mgs || error "remount mgs failed"
6655 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6658 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6659 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6664 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6666 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6668 echo "obj_file is $obj_file"
6669 do_facet mgs $llog_reader $obj_file
6671 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6672 awk '{ print $3 }' | sed -e "s/^type=//g")
6673 if [ $rec_type != $rec ]; then
6674 echo "FAILED test_60a wrong record type $rec_type," \
6680 #check obj path if record type is LLOG_LOGID_MAGIC
6681 if [ "$rec" == "1064553b" ]; then
6682 path=$(do_facet mgs $llog_reader $obj_file |
6683 grep "path=" | awk '{ print $NF }' |
6684 sed -e "s/^path=//g")
6685 if [ $obj_file != $mntpt/$path ]; then
6686 echo "FAILED test_60a wrong obj path" \
6687 "$montpt/$path, should be $obj_file"
6694 #restart mgs before "error", otherwise it will block the next test
6695 stop mgs || error "stop mgs failed"
6696 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6697 $pass || error "test failed, see FAILED test_60a messages for specifics"
6699 run_test 60a "llog_test run from kernel module and test llog_reader"
6701 test_60b() { # bug 6411
6702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6705 LLOG_COUNT=$(do_facet mgs dmesg |
6706 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6707 /llog_[a-z]*.c:[0-9]/ {
6719 [[ $LLOG_COUNT -gt 120 ]] &&
6720 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6722 run_test 60b "limit repeated messages from CERROR/CWARN"
6725 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6727 echo "create 5000 files"
6728 createmany -o $DIR/f60c- 5000
6729 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6730 lctl set_param fail_loc=0x80000137
6731 unlinkmany $DIR/f60c- 5000
6732 lctl set_param fail_loc=0
6734 run_test 60c "unlink file when mds full"
6737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6739 SAVEPRINTK=$(lctl get_param -n printk)
6740 # verify "lctl mark" is even working"
6741 MESSAGE="test message ID $RANDOM $$"
6742 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6743 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6745 lctl set_param printk=0 || error "set lnet.printk failed"
6746 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6747 MESSAGE="new test message ID $RANDOM $$"
6748 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6749 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6750 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6752 lctl set_param -n printk="$SAVEPRINTK"
6754 run_test 60d "test printk console message masking"
6757 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6758 remote_mds_nodsh && skip "remote MDS with nodsh"
6761 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6762 do_facet mds1 lctl set_param fail_loc=0x15b
6765 run_test 60e "no space while new llog is being created"
6770 test_mkdir -c $MDSCOUNT $DIR/$tdir
6771 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6776 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6777 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6778 index=$((index + 1))
6784 for i in $(seq 100); do
6785 # define OBD_FAIL_OSD_TXN_START 0x19a
6786 do_facet mds1 lctl set_param fail_loc=0x8000019a
6792 mkdir $DIR/$tdir/new || error "mkdir failed"
6793 rmdir $DIR/$tdir/new || error "rmdir failed"
6795 run_test 60g "transaction abort won't cause MDT hung"
6798 [ $MDS1_VERSION -le $(version_code 2.12.52) ] ||
6799 skip "Need MDS version at least 2.12.52"
6800 [ $MDSCOUNT -le 2 ] && skip "Need >= 2 MDTs"
6804 #define OBD_FAIL_MDS_STRIPE_CREATE 0x188
6805 #define OBD_FAIL_MDS_STRIPE_FID 0x189
6806 for fail_loc in 0x80000188 0x80000189; do
6807 do_facet mds1 "$LCTL set_param fail_loc=$fail_loc"
6808 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir-$fail_loc ||
6809 error "mkdir $dir-$fail_loc failed"
6810 for i in {0..10}; do
6811 # create may fail on missing stripe
6812 echo $i > $DIR/$tdir-$fail_loc/$i
6814 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6815 error "getdirstripe $tdir-$fail_loc failed"
6816 $LFS migrate -m 1 $DIR/$tdir-$fail_loc ||
6817 error "migrate $tdir-$fail_loc failed"
6818 $LFS getdirstripe $DIR/$tdir-$fail_loc ||
6819 error "getdirstripe $tdir-$fail_loc failed"
6820 pushd $DIR/$tdir-$fail_loc
6822 echo $f | cmp $f - || error "$f data mismatch"
6825 rm -rf $DIR/$tdir-$fail_loc
6828 run_test 60h "striped directory with missing stripes can be accessed"
6831 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6834 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6835 cancel_lru_locks osc
6836 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6839 run_test 61a "mmap() writes don't make sync hang ================"
6842 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6844 run_test 61b "mmap() of unstriped file is successful"
6846 # bug 2330 - insufficient obd_match error checking causes LBUG
6848 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6852 cancel_lru_locks osc
6853 lctl set_param fail_loc=0x405
6854 cat $f && error "cat succeeded, expect -EIO"
6855 lctl set_param fail_loc=0
6857 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6858 # match every page all of the time.
6859 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6861 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6862 # Though this test is irrelevant anymore, it helped to reveal some
6863 # other grant bugs (LU-4482), let's keep it.
6864 test_63a() { # was test_63
6865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6867 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6869 for i in `seq 10` ; do
6870 dd if=/dev/zero of=$DIR/f63 bs=8k &
6876 rm -f $DIR/f63 || true
6878 run_test 63a "Verify oig_wait interruption does not crash ======="
6880 # bug 2248 - async write errors didn't return to application on sync
6881 # bug 3677 - async write errors left page locked
6883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6886 lctl set_param debug=-1
6888 # ensure we have a grant to do async writes
6889 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6892 sync # sync lest earlier test intercept the fail_loc
6894 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6895 lctl set_param fail_loc=0x80000406
6896 $MULTIOP $DIR/$tfile Owy && \
6897 error "sync didn't return ENOMEM"
6898 sync; sleep 2; sync # do a real sync this time to flush page
6899 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6900 error "locked page left in cache after async error" || true
6903 run_test 63b "async write errors should be returned to fsync ==="
6906 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6909 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6911 run_test 64a "verify filter grant calculations (in kernel) ====="
6914 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6916 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6918 run_test 64b "check out-of-space detection on client"
6921 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6923 run_test 64c "verify grant shrink"
6925 # this does exactly what osc_request.c:osc_announce_cached() does in
6926 # order to calculate max amount of grants to ask from server
6930 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6931 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6933 ((rpc_in_flight ++));
6934 nrpages=$((nrpages * rpc_in_flight))
6936 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6938 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
6940 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6941 local undirty=$((nrpages * PAGE_SIZE))
6943 local max_extent_pages
6944 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6945 grep grant_max_extent_size | awk '{print $2}')
6946 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
6947 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6948 local grant_extent_tax
6949 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6950 grep grant_extent_tax | awk '{print $2}')
6952 undirty=$((undirty + nrextents * grant_extent_tax))
6957 # this is size of unit for grant allocation. It should be equal to
6958 # what tgt_grant.c:tgt_grant_chunk() calculates
6962 local grant_extent_tax
6964 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6965 grep max_brw_size | awk '{print $2}')
6967 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6968 grep grant_extent_tax | awk '{print $2}')
6970 echo $(((max_brw_size + grant_extent_tax) * 2))
6974 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
6975 skip "OST < 2.10.55 doesn't limit grants enough"
6977 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6978 local file=$DIR/$tfile
6980 [[ $($LCTL get_param osc.${tgt}.import |
6981 grep "connect_flags:.*grant_param") ]] ||
6982 skip "no grant_param connect flag"
6984 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6986 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6988 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6989 stack_trap "rm -f $file" EXIT
6991 $SETSTRIPE $file -i 0 -c 1
6992 dd if=/dev/zero of=$file bs=1M count=1000 &
6997 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6998 if [[ $cur_grant -gt $max_cur_granted ]]
7001 error "cur_grant $cur_grant > $max_cur_granted"
7004 [[ $? -ne 0 ]] && break;
7009 wait_delete_completed
7010 $LCTL set_param debug="$olddebug" 2> /dev/null || true
7012 run_test 64d "check grant limit exceed"
7014 # bug 1414 - set/get directories' stripe info
7016 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7018 test_mkdir $DIR/$tdir
7020 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
7022 run_test 65a "directory with no stripe info"
7025 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7027 test_mkdir $DIR/$tdir
7028 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7030 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7033 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
7035 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
7038 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7039 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
7041 test_mkdir $DIR/$tdir
7042 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
7044 $LFS setstripe -S $((stripesize * 4)) -i 1 \
7045 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
7047 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
7049 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
7052 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7054 test_mkdir $DIR/$tdir
7055 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
7056 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7058 if [[ $STRIPECOUNT -le 0 ]]; then
7060 elif [[ $STRIPECOUNT -gt 2000 ]]; then
7061 #LOV_MAX_STRIPE_COUNT is 2000
7062 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
7064 sc=$(($STRIPECOUNT - 1))
7066 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
7067 touch $DIR/$tdir/f4 $DIR/$tdir/f5
7068 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
7069 error "lverify failed"
7071 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
7074 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7076 test_mkdir $DIR/$tdir
7078 $SETSTRIPE $DIR/$tdir || error "setstripe"
7079 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
7080 error "no stripe info failed"
7082 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
7084 run_test 65e "directory setstripe defaults"
7087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7089 test_mkdir $DIR/${tdir}f
7090 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
7092 run_test 65f "dir setstripe permission (should return error) ==="
7095 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7097 test_mkdir $DIR/$tdir
7098 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7100 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7101 error "setstripe -S failed"
7102 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
7103 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
7104 error "delete default stripe failed"
7106 run_test 65g "directory setstripe -d"
7109 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7111 test_mkdir $DIR/$tdir
7112 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
7114 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
7115 error "setstripe -S failed"
7116 test_mkdir $DIR/$tdir/dd1
7117 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
7118 error "stripe info inherit failed"
7120 run_test 65h "directory stripe info inherit ===================="
7123 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7125 save_layout_restore_at_exit $MOUNT
7127 # bug6367: set non-default striping on root directory
7128 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
7130 # bug12836: getstripe on -1 default directory striping
7131 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
7133 # bug12836: getstripe -v on -1 default directory striping
7134 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
7136 # bug12836: new find on -1 default directory striping
7137 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
7139 run_test 65i "various tests to set root directory striping"
7141 test_65j() { # bug6367
7142 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7146 # if we aren't already remounting for each test, do so for this test
7147 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
7148 cleanup || error "failed to unmount"
7152 save_layout_restore_at_exit $MOUNT
7154 $SETSTRIPE -d $MOUNT || error "setstripe failed"
7156 run_test 65j "set default striping on root directory (bug 6367)="
7160 wait_delete_completed
7161 do_facet $SINGLEMDS "lctl set_param -n \
7162 osp.$ost*MDT0000.max_create_count=$max_count"
7163 do_facet $SINGLEMDS "lctl set_param -n \
7164 osp.$ost*MDT0000.create_count=$count"
7165 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7166 echo $INACTIVE_OSC "is Activate"
7168 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7171 test_65k() { # bug11679
7172 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7173 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7174 remote_mds_nodsh && skip "remote MDS with nodsh"
7176 local disable_precreate=true
7177 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
7178 disable_precreate=false
7180 echo "Check OST status: "
7181 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
7182 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
7184 for OSC in $MDS_OSCS; do
7185 echo $OSC "is active"
7186 do_facet $SINGLEMDS lctl --device %$OSC activate
7189 for INACTIVE_OSC in $MDS_OSCS; do
7190 local ost=$(osc_to_ost $INACTIVE_OSC)
7191 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
7192 lov.*md*.target_obd |
7193 awk -F: /$ost/'{ print $1 }' | head -n 1)
7196 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
7197 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
7199 echo "Deactivate: " $INACTIVE_OSC
7200 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
7202 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
7203 osp.$ost*MDT0000.create_count")
7204 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
7205 osp.$ost*MDT0000.max_create_count")
7206 $disable_precreate &&
7207 do_facet $SINGLEMDS "lctl set_param -n \
7208 osp.$ost*MDT0000.max_create_count=0"
7210 for idx in $(seq 0 $((OSTCOUNT - 1))); do
7211 [ -f $DIR/$tdir/$idx ] && continue
7212 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
7213 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
7215 error "setstripe $idx should succeed"; }
7216 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
7218 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
7221 do_facet $SINGLEMDS "lctl set_param -n \
7222 osp.$ost*MDT0000.max_create_count=$max_count"
7223 do_facet $SINGLEMDS "lctl set_param -n \
7224 osp.$ost*MDT0000.create_count=$count"
7225 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
7226 echo $INACTIVE_OSC "is Activate"
7228 wait_osc_import_state mds ost$(( ostnum + 1 )) FULL
7231 run_test 65k "validate manual striping works properly with deactivated OSCs"
7233 test_65l() { # bug 12836
7234 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7236 test_mkdir -p $DIR/$tdir/test_dir
7237 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
7238 $LFS find -mtime -1 $DIR/$tdir >/dev/null
7240 run_test 65l "lfs find on -1 stripe dir ========================"
7243 local layout=$(save_layout $MOUNT)
7244 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
7245 restore_layout $MOUNT $layout
7246 error "setstripe should fail by non-root users"
7250 run_test 65m "normal user can't set filesystem default stripe"
7253 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.0) ]] ||
7254 skip "Need MDS version at least 2.12.0"
7255 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
7257 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
7258 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
7259 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
7261 local root_layout=$(save_layout $MOUNT)
7262 stack_trap "restore_layout $MOUNT $root_layout" EXIT
7264 # new subdirectory under root directory should not inherit
7265 # the default layout from root
7266 local dir1=$MOUNT/$tdir-1
7267 mkdir $dir1 || error "mkdir $dir1 failed"
7268 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
7269 error "$dir1 shouldn't have LOV EA"
7271 # delete the default layout on root directory
7272 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
7274 local dir2=$MOUNT/$tdir-2
7275 mkdir $dir2 || error "mkdir $dir2 failed"
7276 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
7277 error "$dir2 shouldn't have LOV EA"
7279 # set a new striping pattern on root directory
7280 local def_stripe_size=$($LFS getstripe -S $MOUNT)
7281 local new_def_stripe_size=$((def_stripe_size * 2))
7282 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
7283 error "set stripe size on $MOUNT failed"
7285 # new file created in $dir2 should inherit the new stripe size from
7286 # the filesystem default
7287 local file2=$dir2/$tfile-2
7288 touch $file2 || error "touch $file2 failed"
7290 local file2_stripe_size=$($LFS getstripe -S $file2)
7291 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
7292 error "$file2 didn't inherit stripe size $new_def_stripe_size"
7294 local dir3=$MOUNT/$tdir-3
7295 mkdir $dir3 || error "mkdir $dir3 failed"
7296 # $dir3 shouldn't have LOV EA, but "lfs getstripe -d $dir3" should show
7297 # the root layout, which is the actual default layout that will be used
7298 # when new files are created in $dir3.
7299 local dir3_layout=$(get_layout_param $dir3)
7300 local root_dir_layout=$(get_layout_param $MOUNT)
7301 [[ "$dir3_layout" = "$root_dir_layout" ]] ||
7302 error "$dir3 should show the default layout from $MOUNT"
7304 # set OST pool on root directory
7305 local pool=$TESTNAME
7306 pool_add $pool || error "add $pool failed"
7307 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
7308 error "add targets to $pool failed"
7310 $LFS setstripe -p $pool $MOUNT ||
7311 error "set OST pool on $MOUNT failed"
7313 # new file created in $dir3 should inherit the pool from
7314 # the filesystem default
7315 local file3=$dir3/$tfile-3
7316 touch $file3 || error "touch $file3 failed"
7318 local file3_pool=$($LFS getstripe -p $file3)
7319 [[ "$file3_pool" = "$pool" ]] ||
7320 error "$file3 didn't inherit OST pool $pool"
7322 local dir4=$MOUNT/$tdir-4
7323 mkdir $dir4 || error "mkdir $dir4 failed"
7324 local dir4_layout=$(get_layout_param $dir4)
7325 root_dir_layout=$(get_layout_param $MOUNT)
7326 echo "$LFS getstripe -d $dir4"
7327 $LFS getstripe -d $dir4
7328 echo "$LFS getstripe -d $MOUNT"
7329 $LFS getstripe -d $MOUNT
7330 [[ "$dir4_layout" = "$root_dir_layout" ]] ||
7331 error "$dir4 should show the default layout from $MOUNT"
7333 # new file created in $dir4 should inherit the pool from
7334 # the filesystem default
7335 local file4=$dir4/$tfile-4
7336 touch $file4 || error "touch $file4 failed"
7338 local file4_pool=$($LFS getstripe -p $file4)
7339 [[ "$file4_pool" = "$pool" ]] ||
7340 error "$file4 didn't inherit OST pool $pool"
7342 # new subdirectory under non-root directory should inherit
7343 # the default layout from its parent directory
7344 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
7345 error "set directory layout on $dir4 failed"
7347 local dir5=$dir4/$tdir-5
7348 mkdir $dir5 || error "mkdir $dir5 failed"
7350 dir4_layout=$(get_layout_param $dir4)
7351 local dir5_layout=$(get_layout_param $dir5)
7352 [[ "$dir4_layout" = "$dir5_layout" ]] ||
7353 error "$dir5 should inherit the default layout from $dir4"
7355 # though subdir under ROOT doesn't inherit default layout, but
7356 # its sub dir/file should be created with default layout.
7357 [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
7358 [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
7359 [[ $MDS1_VERSION -ge $(version_code 2.12.3) &&
7360 $MDS1_VERSION -lt $(version_code 2.12.50) ]] ||
7361 skip "Need MDS version at least 2.12.3 or 2.12.59"
7363 local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
7364 local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
7365 local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
7367 if [ $default_lmv_hash == "none" ]; then
7368 stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
7370 stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
7371 -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
7374 $LFS setdirstripe -D -c 2 $MOUNT ||
7375 error "setdirstripe -D -c 2 failed"
7376 mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
7377 local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
7378 [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
7380 run_test 65n "don't inherit default layout from root for new subdirectories"
7382 # bug 2543 - update blocks count on client
7384 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7387 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
7388 sync; sync_all_data; sync; sync_all_data
7389 cancel_lru_locks osc
7390 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
7391 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
7393 run_test 66 "update inode blocks count on client ==============="
7396 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
7400 swapon -s | awk '($1 == "'$1'") { print $4 }'
7403 # bug5265, obdfilter oa2dentry return -ENOENT
7404 # #define OBD_FAIL_SRV_ENOENT 0x217
7406 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7407 remote_ost_nodsh && skip "remote OST with nodsh"
7410 $SETSTRIPE -c 1 -i 0 $f
7412 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
7414 do_facet ost1 lctl set_param fail_loc=0x217
7415 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
7416 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
7418 do_facet ost1 lctl set_param fail_loc=0
7419 $DIRECTIO write $f 0 2 || error "write error"
7421 cancel_lru_locks osc
7422 $DIRECTIO read $f 0 1 || error "read error"
7424 do_facet ost1 lctl set_param fail_loc=0x217
7425 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
7427 do_facet ost1 lctl set_param fail_loc=0
7430 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
7433 test_mkdir $DIR/$tdir
7434 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
7435 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
7437 run_test 71 "Running dbench on lustre (don't segment fault) ===="
7439 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
7440 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7441 [ "$RUNAS_ID" = "$UID" ] &&
7442 skip_env "RUNAS_ID = UID = $UID -- skipping"
7443 # Check that testing environment is properly set up. Skip if not
7444 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
7445 skip_env "User $RUNAS_ID does not exist - skipping"
7448 chmod 777 $DIR/$tfile
7449 chmod ug+s $DIR/$tfile
7450 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
7451 error "$RUNAS dd $DIR/$tfile failed"
7452 # See if we are still setuid/sgid
7453 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7454 error "S/gid is not dropped on write"
7455 # Now test that MDS is updated too
7456 cancel_lru_locks mdc
7457 test -u $DIR/$tfile -o -g $DIR/$tfile &&
7458 error "S/gid is not dropped on MDS"
7461 run_test 72a "Test that remove suid works properly (bug5695) ===="
7463 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7466 [ "$RUNAS_ID" = "$UID" ] &&
7467 skip_env "RUNAS_ID = UID = $UID -- skipping"
7468 [ "$RUNAS_ID" -eq 0 ] &&
7469 skip_env "RUNAS_ID = 0 -- skipping"
7470 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7471 # Check that testing environment is properly set up. Skip if not
7472 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7473 skip_env "User $RUNAS_ID does not exist - skipping"
7475 touch $DIR/${tfile}-f{g,u}
7476 test_mkdir $DIR/${tfile}-dg
7477 test_mkdir $DIR/${tfile}-du
7478 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7479 chmod g+s $DIR/${tfile}-{f,d}g
7480 chmod u+s $DIR/${tfile}-{f,d}u
7481 for perm in 777 2777 4777; do
7482 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7483 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7484 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7485 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7489 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7491 # bug 3462 - multiple simultaneous MDC requests
7493 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7495 test_mkdir $DIR/d73-1
7496 test_mkdir $DIR/d73-2
7497 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7500 lctl set_param fail_loc=0x80000129
7501 $MULTIOP $DIR/d73-1/f73-2 Oc &
7503 lctl set_param fail_loc=0
7505 $MULTIOP $DIR/d73-2/f73-3 Oc &
7509 wait $pid1 || return 1
7513 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7514 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7515 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7519 run_test 73 "multiple MDC requests (should not deadlock)"
7521 test_74a() { # bug 6149, 6184
7522 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7525 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7527 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7528 # will spin in a tight reconnection loop
7529 $LCTL set_param fail_loc=0x8000030e
7530 # get any lock that won't be difficult - lookup works.
7532 $LCTL set_param fail_loc=0
7536 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7538 test_74b() { # bug 13310
7539 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7541 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7543 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7544 # will spin in a tight reconnection loop
7545 $LCTL set_param fail_loc=0x8000030e
7546 # get a "difficult" lock
7548 $LCTL set_param fail_loc=0
7552 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7555 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7557 #define OBD_FAIL_LDLM_NEW_LOCK
7558 $LCTL set_param fail_loc=0x319
7559 touch $DIR/$tfile && error "touch successful"
7560 $LCTL set_param fail_loc=0
7563 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7566 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7569 test_76() { # Now for bug 20433, added originally in bug 1443
7570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7572 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7574 cancel_lru_locks osc
7575 BEFORE_INODES=$(num_inodes)
7576 echo "before inodes: $BEFORE_INODES"
7578 [ "$SLOW" = "no" ] && COUNT=100
7579 for i in $(seq $COUNT); do
7583 cancel_lru_locks osc
7584 AFTER_INODES=$(num_inodes)
7585 echo "after inodes: $AFTER_INODES"
7587 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7589 AFTER_INODES=$(num_inodes)
7591 echo "wait $wait seconds inodes: $AFTER_INODES"
7592 if [ $wait -gt 30 ]; then
7593 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7597 run_test 76 "confirm clients recycle inodes properly ===="
7603 # Note: in sptlrpc modes which enable its own bulk checksum, the
7604 # original crc32_le bulk checksum will be automatically disabled,
7605 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7606 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7607 # In this case set_checksums() will not be no-op, because sptlrpc
7608 # bulk checksum will be enabled all through the test.
7610 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7611 lctl set_param -n osc.*.checksums $1
7615 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7616 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7617 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7618 tr -d [] | head -n1)}
7621 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7622 log "set checksum type to $1"
7625 F77_TMP=$TMP/f77-temp
7628 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7629 error "error writing to $F77_TMP"
7632 test_77a() { # bug 10889
7633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7634 $GSS && skip_env "could not run with gss"
7636 [ ! -f $F77_TMP ] && setup_f77
7638 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7642 run_test 77a "normal checksum read/write operation"
7644 test_77b() { # bug 10889
7645 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7646 $GSS && skip_env "could not run with gss"
7648 [ ! -f $F77_TMP ] && setup_f77
7649 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7650 $LCTL set_param fail_loc=0x80000409
7653 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7654 error "dd error: $?"
7655 $LCTL set_param fail_loc=0
7657 for algo in $CKSUM_TYPES; do
7658 cancel_lru_locks osc
7659 set_checksum_type $algo
7660 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7661 $LCTL set_param fail_loc=0x80000408
7662 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7663 $LCTL set_param fail_loc=0
7666 set_checksum_type $ORIG_CSUM_TYPE
7669 run_test 77b "checksum error on client write, read"
7674 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7676 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7677 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7678 $check_ost && [ -n "$ost_file_prefix" ] &&
7679 do_facet ost1 rm -f ${ost_file_prefix}\*
7683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7684 $GSS && skip_env "could not run with gss"
7685 remote_ost_nodsh && skip "remote OST with nodsh"
7688 local osc_file_prefix
7690 local check_ost=false
7691 local ost_file_prefix
7697 # ensure corruption will occur on first OSS/OST
7698 $LFS setstripe -i 0 $DIR/$tfile
7700 [ ! -f $F77_TMP ] && setup_f77
7701 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7702 error "dd write error: $?"
7703 fid=$($LFS path2fid $DIR/$tfile)
7705 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7708 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7709 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7711 echo "OSS do not support bulk pages dump upon error"
7714 osc_file_prefix=$($LCTL get_param -n debug_path)
7715 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7717 trap cleanup_77c EXIT
7720 # enable bulk pages dump upon error on Client
7721 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7722 # enable bulk pages dump upon error on OSS
7724 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7726 # flush Client cache to allow next read to reach OSS
7727 cancel_lru_locks osc
7729 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7730 $LCTL set_param fail_loc=0x80000408
7731 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7732 $LCTL set_param fail_loc=0
7736 # check cksum dump on Client
7737 osc_file=$(ls ${osc_file_prefix}*)
7738 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7739 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7740 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7741 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7742 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7744 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7745 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7746 error "dump content does not match on Client"
7748 $check_ost || skip "No need to check cksum dump on OSS"
7750 # check cksum dump on OSS
7751 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7752 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7753 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7754 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7755 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7756 error "dump content does not match on OSS"
7760 run_test 77c "checksum error on client read with debug"
7762 test_77d() { # bug 10889
7763 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7764 $GSS && skip_env "could not run with gss"
7766 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7767 $LCTL set_param fail_loc=0x80000409
7769 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7770 error "direct write: rc=$?"
7771 $LCTL set_param fail_loc=0
7774 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7775 $LCTL set_param fail_loc=0x80000408
7777 cancel_lru_locks osc
7778 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7779 error "direct read: rc=$?"
7780 $LCTL set_param fail_loc=0
7783 run_test 77d "checksum error on OST direct write, read"
7785 test_77f() { # bug 10889
7786 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7787 $GSS && skip_env "could not run with gss"
7790 for algo in $CKSUM_TYPES; do
7791 cancel_lru_locks osc
7792 set_checksum_type $algo
7793 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7794 $LCTL set_param fail_loc=0x409
7795 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7796 error "direct write succeeded"
7797 $LCTL set_param fail_loc=0
7799 set_checksum_type $ORIG_CSUM_TYPE
7802 run_test 77f "repeat checksum error on write (expect error)"
7804 test_77g() { # bug 10889
7805 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7806 $GSS && skip_env "could not run with gss"
7807 remote_ost_nodsh && skip "remote OST with nodsh"
7809 [ ! -f $F77_TMP ] && setup_f77
7811 local file=$DIR/$tfile
7812 stack_trap "rm -f $file" EXIT
7814 $SETSTRIPE -c 1 -i 0 $file
7815 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7816 do_facet ost1 lctl set_param fail_loc=0x8000021a
7818 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7819 error "write error: rc=$?"
7820 do_facet ost1 lctl set_param fail_loc=0
7823 cancel_lru_locks osc
7824 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7825 do_facet ost1 lctl set_param fail_loc=0x8000021b
7827 cmp $F77_TMP $file || error "file compare failed"
7828 do_facet ost1 lctl set_param fail_loc=0
7831 run_test 77g "checksum error on OST write, read"
7833 test_77k() { # LU-10906
7834 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7835 $GSS && skip_env "could not run with gss"
7837 local cksum_param="osc.$FSNAME*.checksums"
7838 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7842 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7843 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7844 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7848 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7849 error "failed to set checksum=$i on MGS"
7850 wait_update $HOSTNAME "$get_checksum" $i
7852 echo "remount client, checksum should be $i"
7853 remount_client $MOUNT || "failed to remount client"
7854 checksum=$(eval $get_checksum)
7855 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7858 for opt in "checksum" "nochecksum"; do
7859 #remount with mount option
7860 echo "remount client with option $opt, checksum should be $i"
7861 umount_client $MOUNT || "failed to umount client"
7862 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7863 "failed to mount client with option '$opt'"
7864 checksum=$(eval $get_checksum)
7865 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7869 remount_client $MOUNT || "failed to remount client"
7871 run_test 77k "enable/disable checksum correctly"
7873 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7882 test_78() { # bug 10901
7883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7884 remote_ost || skip_env "local OST"
7887 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7888 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7889 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7890 echo "MemTotal: $MEMTOTAL"
7892 # reserve 256MB of memory for the kernel and other running processes,
7893 # and then take 1/2 of the remaining memory for the read/write buffers.
7894 if [ $MEMTOTAL -gt 512 ] ;then
7895 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7897 # for those poor memory-starved high-end clusters...
7898 MEMTOTAL=$((MEMTOTAL / 2))
7900 echo "Mem to use for directio: $MEMTOTAL"
7902 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7903 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7904 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7905 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7907 echo "Smallest OST: $SMALLESTOST"
7908 [[ $SMALLESTOST -lt 10240 ]] &&
7909 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7911 trap cleanup_test_78 EXIT
7913 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7914 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7916 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7917 echo "File size: $F78SIZE"
7918 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7919 for i in $(seq 1 $NSEQ); do
7920 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7921 echo directIO rdwr round $i of $NSEQ
7922 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7927 run_test 78 "handle large O_DIRECT writes correctly ============"
7929 test_79() { # bug 12743
7930 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7932 wait_delete_completed
7934 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7935 BKFREE=$(calc_osc_kbytes kbytesfree)
7936 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7938 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7939 DFTOTAL=`echo $STRING | cut -d, -f1`
7940 DFUSED=`echo $STRING | cut -d, -f2`
7941 DFAVAIL=`echo $STRING | cut -d, -f3`
7942 DFFREE=$(($DFTOTAL - $DFUSED))
7944 ALLOWANCE=$((64 * $OSTCOUNT))
7946 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7947 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7948 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7950 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7951 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7952 error "df free($DFFREE) mismatch OST free($BKFREE)"
7954 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7955 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7956 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7959 run_test 79 "df report consistency check ======================="
7961 test_80() { # bug 10718
7962 remote_ost_nodsh && skip "remote OST with nodsh"
7963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7965 # relax strong synchronous semantics for slow backends like ZFS
7966 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
7967 local soc="obdfilter.*.sync_lock_cancel"
7968 local save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
7970 # "sync_on_lock_cancel" was broken by v2_11_55_0-26-g7059644e9a
7971 if [ -z "$save" ]; then
7972 soc="obdfilter.*.sync_on_lock_cancel"
7973 save=$(do_facet ost1 $LCTL get_param -n $soc | head -n1)
7976 if [ "$save" != "never" ]; then
7977 local hosts=$(comma_list $(osts_nodes))
7979 do_nodes $hosts $LCTL set_param $soc=never
7980 stack_trap "do_nodes $hosts $LCTL set_param $soc=$save"
7984 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7986 local before=$(date +%s)
7987 cancel_lru_locks osc
7988 local after=$(date +%s)
7989 local diff=$((after - before))
7990 [ $diff -le 1 ] || error "elapsed for 1M@1T = $diff"
7994 run_test 80 "Page eviction is equally fast at high offsets too"
7996 test_81a() { # LU-456
7997 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7998 remote_ost_nodsh && skip "remote OST with nodsh"
8000 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8001 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
8002 do_facet ost1 lctl set_param fail_loc=0x80000228
8004 # write should trigger a retry and success
8005 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8006 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8008 if [ $RC -ne 0 ] ; then
8009 error "write should success, but failed for $RC"
8012 run_test 81a "OST should retry write when get -ENOSPC ==============="
8014 test_81b() { # LU-456
8015 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8016 remote_ost_nodsh && skip "remote OST with nodsh"
8018 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
8019 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
8020 do_facet ost1 lctl set_param fail_loc=0x228
8022 # write should retry several times and return -ENOSPC finally
8023 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
8024 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
8027 if [ $RC -ne $ENOSPC ] ; then
8028 error "dd should fail for -ENOSPC, but succeed."
8031 run_test 81b "OST should return -ENOSPC when retry still fails ======="
8033 test_82() { # LU-1031
8034 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
8038 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
8040 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
8042 kill -USR1 $MULTIPID2
8044 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
8045 error "First grouplock does not block second one"
8047 echo "Second grouplock blocks first one"
8049 kill -USR1 $MULTIPID1
8053 run_test 82 "Basic grouplock test"
8056 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
8058 test_mkdir $DIR/$tdir.cvsroot
8059 chown $RUNAS_ID $DIR/$tdir.cvsroot
8062 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
8065 # some versions of cvs import exit(1) when asked to import links or
8066 # files they can't read. ignore those files.
8067 local toignore=$(find . -type l -printf '-I %f\n' -o \
8068 ! -perm /4 -printf '-I %f\n')
8069 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
8070 $tdir.reposname vtag rtag
8073 test_mkdir $DIR/$tdir.reposname
8074 chown $RUNAS_ID $DIR/$tdir.reposname
8075 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
8077 cd $DIR/$tdir.reposname
8079 $RUNAS cvs add -m 'addmsg' foo99
8081 $RUNAS cvs commit -m 'nomsg' foo99
8082 rm -fr $DIR/$tdir.cvsroot
8084 run_test 99 "cvs strange file/directory operations"
8087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8088 [[ "$NETTYPE" =~ tcp ]] ||
8089 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
8090 remote_ost_nodsh && skip "remote OST with nodsh"
8091 remote_mds_nodsh && skip "remote MDS with nodsh"
8093 skip "useless for local single node setup"
8095 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
8096 [ "$PROT" != "tcp" ] && continue
8097 RPORT=$(echo $REMOTE | cut -d: -f2)
8098 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
8101 LPORT=`echo $LOCAL | cut -d: -f2`
8102 if [ $LPORT -ge 1024 ]; then
8103 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
8105 error_exit "local: $LPORT > 1024, remote: $RPORT"
8108 [ "$rc" = 0 ] || error_exit "privileged port not found" )
8110 run_test 100 "check local port using privileged port ==========="
8112 function get_named_value()
8121 echo $line | sed "s/^$tag[ ]*//"
8128 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
8129 awk '/^max_cached_mb/ { print $2 }')
8132 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
8137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8138 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
8143 local cache_limit=32
8145 $LCTL set_param -n osc.*-osc*.rpc_stats 0
8146 trap cleanup_101a EXIT
8147 $LCTL set_param -n llite.*.read_ahead_stats 0
8148 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
8151 # randomly read 10000 of 64K chunks from file 3x 32MB in size
8153 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
8154 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
8157 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
8158 get_named_value 'read but discarded' | cut -d" " -f1); do
8159 discard=$(($discard + $s))
8163 if [[ $(($discard * 10)) -gt $nreads ]]; then
8164 $LCTL get_param osc.*-osc*.rpc_stats
8165 $LCTL get_param llite.*.read_ahead_stats
8166 error "too many ($discard) discarded pages"
8168 rm -f $DIR/$tfile || true
8170 run_test 101a "check read-ahead for random reads"
8173 test_mkdir $DIR/$tdir
8174 local STRIPE_SIZE=$1
8175 local FILE_LENGTH=$2
8178 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
8180 local list=$(comma_list $(osts_nodes))
8181 set_osd_param $list '' read_cache_enable 0
8182 set_osd_param $list '' writethrough_cache_enable 0
8184 trap cleanup_test101bc EXIT
8185 # prepare the read-ahead file
8186 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
8188 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
8189 count=$FILE_SIZE_MB 2> /dev/null
8193 cleanup_test101bc() {
8198 local list=$(comma_list $(osts_nodes))
8199 set_osd_param $list '' read_cache_enable 1
8200 set_osd_param $list '' writethrough_cache_enable 1
8204 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
8209 local STRIPE_SIZE=$2
8210 local FILE_LENGTH=$3
8211 local RA_INC=1048576
8212 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
8213 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
8214 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
8215 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
8216 get_named_value 'read but discarded' |
8217 cut -d" " -f1 | calc_total)
8218 if [[ $DISCARD -gt $discard_limit ]]; then
8219 $LCTL get_param llite.*.read_ahead_stats
8220 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
8222 echo "Read-ahead success for size ${READ_SIZE}"
8227 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8228 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8230 local STRIPE_SIZE=1048576
8231 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
8233 if [ $SLOW == "yes" ]; then
8234 local FILE_LENGTH=$((STRIDE_SIZE * 64))
8236 local FILE_LENGTH=$((STRIDE_SIZE * 8))
8239 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
8241 # prepare the read-ahead file
8242 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8243 cancel_lru_locks osc
8244 for BIDX in 2 4 8 16 32 64 128 256
8246 local BSIZE=$((BIDX*4096))
8247 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
8248 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
8249 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
8250 $LCTL set_param -n llite.*.read_ahead_stats 0
8251 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
8252 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
8253 cancel_lru_locks osc
8254 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
8259 run_test 101b "check stride-io mode read-ahead ================="
8262 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8264 local STRIPE_SIZE=1048576
8265 local FILE_LENGTH=$((STRIPE_SIZE*100))
8269 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
8271 cancel_lru_locks osc
8272 $LCTL set_param osc.*.rpc_stats 0
8273 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
8274 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
8275 local stats=$($LCTL get_param -n $osc_rpc_stats)
8276 local lines=$(echo "$stats" | awk 'END {print NR;}')
8279 if [ $lines -le 20 ]; then
8282 for size in 1 2 4 8; do
8283 local rpc=$(echo "$stats" |
8284 awk '($1 == "'$size':") {print $2; exit; }')
8286 error "Small $((size*4))k read IO $rpc !"
8288 echo "$osc_rpc_stats check passed!"
8293 run_test 101c "check stripe_size aligned read-ahead ================="
8296 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
8297 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
8301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8303 local file=$DIR/$tfile
8304 local sz_MB=${FILESIZE_101d:-500}
8305 local ra_MB=${READAHEAD_MB:-40}
8307 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
8308 [ $free_MB -lt $sz_MB ] &&
8309 skip "Need free space ${sz_MB}M, have ${free_MB}M"
8311 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
8312 $SETSTRIPE -c -1 $file || error "setstripe failed"
8314 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
8315 echo Cancel LRU locks on lustre client to flush the client cache
8316 cancel_lru_locks osc
8318 echo Disable read-ahead
8319 local old_READAHEAD=$(set_read_ahead 0)
8321 echo Reading the test file $file with read-ahead disabled
8322 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8324 echo Cancel LRU locks on lustre client to flush the client cache
8325 cancel_lru_locks osc
8326 echo Enable read-ahead with ${ra_MB}MB
8327 set_read_ahead $ra_MB
8329 echo Reading the test file $file with read-ahead enabled
8330 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
8332 echo "read-ahead disabled time read $raOFF"
8333 echo "read-ahead enabled time read $raON"
8335 set_read_ahead $old_READAHEAD
8337 wait_delete_completed
8339 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
8340 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
8342 run_test 101d "file read with and without read-ahead enabled"
8345 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8347 local file=$DIR/$tfile
8348 local size_KB=500 #KB
8352 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
8353 local need_KB=$((count * size_KB))
8354 [[ $free_KB -le $need_KB ]] &&
8355 skip_env "Need free space $need_KB, have $free_KB"
8357 echo "Creating $count ${size_KB}K test files"
8358 for ((i = 0; i < $count; i++)); do
8359 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
8362 echo "Cancel LRU locks on lustre client to flush the client cache"
8363 cancel_lru_locks $OSC
8365 echo "Reset readahead stats"
8366 $LCTL set_param -n llite.*.read_ahead_stats 0
8368 for ((i = 0; i < $count; i++)); do
8369 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
8372 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8373 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8375 for ((i = 0; i < $count; i++)); do
8376 rm -rf $file.$i 2>/dev/null
8379 #10000 means 20% reads are missing in readahead
8380 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
8382 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
8385 which iozone || skip_env "no iozone installed"
8387 local old_debug=$($LCTL get_param debug)
8388 old_debug=${old_debug#*=}
8389 $LCTL set_param debug="reada mmap"
8391 # create a test file
8392 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
8394 echo Cancel LRU locks on lustre client to flush the client cache
8395 cancel_lru_locks osc
8397 echo Reset readahead stats
8398 $LCTL set_param -n llite.*.read_ahead_stats 0
8400 echo mmap read the file with small block size
8401 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
8404 echo checking missing pages
8405 $LCTL get_param llite.*.read_ahead_stats
8406 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
8407 get_named_value 'misses' | cut -d" " -f1 | calc_total)
8409 $LCTL set_param debug="$old_debug"
8410 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
8413 run_test 101f "check mmap read performance"
8415 test_101g_brw_size_test() {
8417 local pages=$((mb * 1048576 / PAGE_SIZE))
8418 local file=$DIR/$tfile
8420 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
8421 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
8422 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
8423 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
8427 stack_trap "rm -f $file" EXIT
8428 $LCTL set_param -n osc.*.rpc_stats=0
8430 # 10 RPCs should be enough for the test
8432 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
8433 { error "dd write ${mb} MB blocks failed"; return 3; }
8434 cancel_lru_locks osc
8435 dd of=/dev/null if=$file bs=${mb}M count=$count ||
8436 { error "dd write ${mb} MB blocks failed"; return 4; }
8438 # calculate number of full-sized read and write RPCs
8439 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
8440 sed -n '/pages per rpc/,/^$/p' |
8441 awk '/'$pages':/ { reads += $2; writes += $6 }; \
8442 END { print reads,writes }'))
8443 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
8445 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
8452 remote_ost_nodsh && skip "remote OST with nodsh"
8455 local osts=$(get_facets OST)
8456 local list=$(comma_list $(osts_nodes))
8457 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
8458 local brw_size="obdfilter.*.brw_size"
8460 $LFS setstripe -i 0 -c 1 $DIR/$tfile
8462 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
8463 if [ $OST1_VERSION -ge $(version_code 2.8.52) -o \
8464 \( $OST1_VERSION -ge $(version_code 2.7.17) -a \
8465 $OST1_VERSION -lt $(version_code 2.7.50) \) ] &&
8466 [ $CLIENT_VERSION -ge $(version_code 2.8.52) -o \
8467 \( $CLIENT_VERSION -ge $(version_code 2.7.17) -a \
8468 $CLIENT_VERSION -lt $(version_code 2.7.50) \) ]; then
8469 [ $OST1_VERSION -ge $(version_code 2.9.52) ] && suffix="M"
8470 if [[ $orig_mb -lt 16 ]]; then
8471 save_lustre_params $osts "$brw_size" > $p
8472 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8473 error "set 16MB RPC size failed"
8475 echo "remount client to enable new RPC size"
8476 remount_client $MOUNT || error "remount_client failed"
8479 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8480 # should be able to set brw_size=12, but no rpc_stats for that
8481 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8484 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8486 if [[ $orig_mb -lt 16 ]]; then
8487 restore_lustre_params < $p
8488 remount_client $MOUNT || error "remount_client restore failed"
8491 rm -f $p $DIR/$tfile
8493 run_test 101g "Big bulk(4/16 MiB) readahead"
8496 test_mkdir $DIR/$tdir
8497 chown $RUNAS_ID $DIR/$tdir
8500 STRIPE_COUNT=$OSTCOUNT
8501 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8503 trap cleanup_test102 EXIT
8505 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8507 for num in 1 2 3 4; do
8508 for count in $(seq 1 $STRIPE_COUNT); do
8509 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8510 local size=`expr $STRIPE_SIZE \* $num`
8511 local file=file"$num-$idx-$count"
8512 $1 $SETSTRIPE -S $size -i $idx -c $count $file
8518 $1 tar cf $TMP/f102.tar $tdir --xattrs
8524 rm -rf $DIR/d0.sanity/d102
8528 [ "$UID" != 0 ] && skip "must run as root"
8529 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8530 skip_env "must have user_xattr"
8532 [ -z "$(which setfattr 2>/dev/null)" ] &&
8533 skip_env "could not find setfattr"
8535 local testfile=$DIR/$tfile
8538 echo "set/get xattr..."
8539 setfattr -n trusted.name1 -v value1 $testfile ||
8540 error "setfattr -n trusted.name1=value1 $testfile failed"
8541 getfattr -n trusted.name1 $testfile 2> /dev/null |
8542 grep "trusted.name1=.value1" ||
8543 error "$testfile missing trusted.name1=value1"
8545 setfattr -n user.author1 -v author1 $testfile ||
8546 error "setfattr -n user.author1=author1 $testfile failed"
8547 getfattr -n user.author1 $testfile 2> /dev/null |
8548 grep "user.author1=.author1" ||
8549 error "$testfile missing trusted.author1=author1"
8552 setfattr -n trusted.name2 -v value2 $testfile ||
8553 error "$testfile unable to set trusted.name2"
8554 setfattr -n trusted.name3 -v value3 $testfile ||
8555 error "$testfile unable to set trusted.name3"
8556 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8557 grep "trusted.name" | wc -l) -eq 3 ] ||
8558 error "$testfile missing 3 trusted.name xattrs"
8560 setfattr -n user.author2 -v author2 $testfile ||
8561 error "$testfile unable to set user.author2"
8562 setfattr -n user.author3 -v author3 $testfile ||
8563 error "$testfile unable to set user.author3"
8564 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8565 grep "user.author" | wc -l) -eq 3 ] ||
8566 error "$testfile missing 3 user.author xattrs"
8568 echo "remove xattr..."
8569 setfattr -x trusted.name1 $testfile ||
8570 error "$testfile error deleting trusted.name1"
8571 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8572 error "$testfile did not delete trusted.name1 xattr"
8574 setfattr -x user.author1 $testfile ||
8575 error "$testfile error deleting user.author1"
8576 echo "set lustre special xattr ..."
8577 $LFS setstripe -c1 $testfile
8578 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8579 awk -F "=" '/trusted.lov/ { print $2 }' )
8580 setfattr -n "trusted.lov" -v $lovea $testfile ||
8581 error "$testfile doesn't ignore setting trusted.lov again"
8582 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8583 error "$testfile allow setting invalid trusted.lov"
8586 run_test 102a "user xattr test =================================="
8589 [ -z "$(which setfattr 2>/dev/null)" ] &&
8590 skip_env "could not find setfattr"
8591 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8593 # b10930: get/set/list trusted.lov xattr
8594 echo "get/set/list trusted.lov xattr ..."
8595 local testfile=$DIR/$tfile
8596 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8597 error "setstripe failed"
8598 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
8599 error "getstripe failed"
8600 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
8601 error "can't get trusted.lov from $testfile"
8603 local testfile2=${testfile}2
8604 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
8605 grep "trusted.lov" | sed -e 's/[^=]\+=//')
8608 setfattr -n trusted.lov -v $value $testfile2
8609 local stripe_size=$($GETSTRIPE -S $testfile2)
8610 local stripe_count=$($GETSTRIPE -c $testfile2)
8611 [[ $stripe_size -eq 65536 ]] ||
8612 error "stripe size $stripe_size != 65536"
8613 [[ $stripe_count -eq $STRIPECOUNT ]] ||
8614 error "stripe count $stripe_count != $STRIPECOUNT"
8617 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
8620 [ -z "$(which setfattr 2>/dev/null)" ] &&
8621 skip_env "could not find setfattr"
8622 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8624 # b10930: get/set/list lustre.lov xattr
8625 echo "get/set/list lustre.lov xattr ..."
8626 test_mkdir $DIR/$tdir
8627 chown $RUNAS_ID $DIR/$tdir
8628 local testfile=$DIR/$tdir/$tfile
8629 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8630 error "setstripe failed"
8631 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
8632 error "getstripe failed"
8633 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8634 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8636 local testfile2=${testfile}2
8637 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8638 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8640 $RUNAS $MCREATE $testfile2
8641 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8642 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8643 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8644 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8645 [ $stripe_count -eq $STRIPECOUNT ] ||
8646 error "stripe count $stripe_count != $STRIPECOUNT"
8648 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8650 compare_stripe_info1() {
8651 local stripe_index_all_zero=true
8653 for num in 1 2 3 4; do
8654 for count in $(seq 1 $STRIPE_COUNT); do
8655 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8656 local size=$((STRIPE_SIZE * num))
8657 local file=file"$num-$offset-$count"
8658 stripe_size=$($LFS getstripe -S $PWD/$file)
8659 [[ $stripe_size -ne $size ]] &&
8660 error "$file: size $stripe_size != $size"
8661 stripe_count=$($LFS getstripe -c $PWD/$file)
8662 # allow fewer stripes to be created, ORI-601
8663 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8664 error "$file: count $stripe_count != $count"
8665 stripe_index=$($LFS getstripe -i $PWD/$file)
8666 [[ $stripe_index -ne 0 ]] &&
8667 stripe_index_all_zero=false
8671 $stripe_index_all_zero &&
8672 error "all files are being extracted starting from OST index 0"
8676 have_xattrs_include() {
8677 tar --help | grep -q xattrs-include &&
8678 echo --xattrs-include="lustre.*"
8682 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8683 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8685 XINC=$(have_xattrs_include)
8687 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8689 compare_stripe_info1
8691 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8694 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8695 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8697 XINC=$(have_xattrs_include)
8699 test_mkdir $DIR/$tdir.restore
8701 tar cf - --xattrs $tdir | tar xf - \
8702 -C $DIR/$tdir.restore --xattrs $XINC
8703 cd $DIR/$tdir.restore/$tdir
8704 compare_stripe_info1
8706 run_test 102f "tar copy files, not keep osts"
8709 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8710 skip "must have user_xattr"
8711 [ -z "$(which setfattr 2>/dev/null)" ] &&
8712 skip_env "could not find setfattr"
8713 [ -z "$(which getfattr 2>/dev/null)" ] &&
8714 skip_env "could not find getfattr"
8716 local xsize=${1:-1024} # in bytes
8717 local file=$DIR/$tfile
8718 local value="$(generate_string $xsize)"
8719 local xbig=trusted.big
8722 log "save $xbig on $file"
8723 setfattr -n $xbig -v $value $file ||
8724 error "saving $xbig on $file failed"
8726 local orig=$(get_xattr_value $xbig $file)
8727 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8729 local xsml=trusted.sml
8730 log "save $xsml on $file"
8731 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8733 local new=$(get_xattr_value $xbig $file)
8734 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8736 log "grow $xsml on $file"
8737 setfattr -n $xsml -v "$value" $file ||
8738 error "growing $xsml on $file failed"
8740 new=$(get_xattr_value $xbig $file)
8741 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8742 log "$xbig still valid after growing $xsml"
8747 test_102h() { # bug 15777
8750 run_test 102h "grow xattr from inside inode to external block"
8753 large_xattr_enabled || skip_env "ea_inode feature disabled"
8755 grow_xattr $(max_xattr_size)
8757 run_test 102ha "grow xattr from inside inode to external inode"
8759 test_102i() { # bug 17038
8760 [ -z "$(which getfattr 2>/dev/null)" ] &&
8761 skip "could not find getfattr"
8764 ln -s $DIR/$tfile $DIR/${tfile}link
8765 getfattr -n trusted.lov $DIR/$tfile ||
8766 error "lgetxattr on $DIR/$tfile failed"
8767 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8768 grep -i "no such attr" ||
8769 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8770 rm -f $DIR/$tfile $DIR/${tfile}link
8772 run_test 102i "lgetxattr test on symbolic link ============"
8775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8776 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8778 XINC=$(have_xattrs_include)
8779 setup_test102 "$RUNAS"
8780 chown $RUNAS_ID $DIR/$tdir
8781 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8783 compare_stripe_info1 "$RUNAS"
8785 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8788 [ -z "$(which setfattr 2>/dev/null)" ] &&
8789 skip "could not find setfattr"
8792 # b22187 just check that does not crash for regular file.
8793 setfattr -n trusted.lov $DIR/$tfile
8794 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8795 local test_kdir=$DIR/$tdir
8796 test_mkdir $test_kdir
8797 local default_size=$($LFS getstripe -S $test_kdir)
8798 local default_count=$($LFS getstripe -c $test_kdir)
8799 local default_offset=$($LFS getstripe -i $test_kdir)
8800 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8801 error 'dir setstripe failed'
8802 setfattr -n trusted.lov $test_kdir
8803 local stripe_size=$($LFS getstripe -S $test_kdir)
8804 local stripe_count=$($LFS getstripe -c $test_kdir)
8805 local stripe_offset=$($LFS getstripe -i $test_kdir)
8806 [ $stripe_size -eq $default_size ] ||
8807 error "stripe size $stripe_size != $default_size"
8808 [ $stripe_count -eq $default_count ] ||
8809 error "stripe count $stripe_count != $default_count"
8810 [ $stripe_offset -eq $default_offset ] ||
8811 error "stripe offset $stripe_offset != $default_offset"
8812 rm -rf $DIR/$tfile $test_kdir
8814 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8817 [ -z "$(which getfattr 2>/dev/null)" ] &&
8818 skip "could not find getfattr"
8820 # LU-532 trusted. xattr is invisible to non-root
8821 local testfile=$DIR/$tfile
8825 echo "listxattr as user..."
8826 chown $RUNAS_ID $testfile
8827 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8828 grep -q "trusted" &&
8829 error "$testfile trusted xattrs are user visible"
8833 run_test 102l "listxattr size test =================================="
8835 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8836 local path=$DIR/$tfile
8839 listxattr_size_check $path || error "listattr_size_check $path failed"
8841 run_test 102m "Ensure listxattr fails on small bufffer ========"
8845 getxattr() { # getxattr path name
8846 # Return the base64 encoding of the value of xattr name on path.
8850 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8852 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8854 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8856 getfattr --absolute-names --encoding=base64 --name=$name $path |
8857 awk -F= -v name=$name '$1 == name {
8858 print substr($0, index($0, "=") + 1);
8862 test_102n() { # LU-4101 mdt: protect internal xattrs
8863 [ -z "$(which setfattr 2>/dev/null)" ] &&
8864 skip "could not find setfattr"
8865 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
8867 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8870 local file0=$DIR/$tfile.0
8871 local file1=$DIR/$tfile.1
8872 local xattr0=$TMP/$tfile.0
8873 local xattr1=$TMP/$tfile.1
8874 local namelist="lov lma lmv link fid version som hsm"
8878 rm -rf $file0 $file1 $xattr0 $xattr1
8881 # Get 'before' xattrs of $file1.
8882 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8884 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
8885 namelist+=" lfsck_namespace"
8886 for name in $namelist; do
8887 # Try to copy xattr from $file0 to $file1.
8888 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8890 setfattr --name=trusted.$name --value="$value" $file1 ||
8891 error "setxattr 'trusted.$name' failed"
8893 # Try to set a garbage xattr.
8894 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8896 if [[ x$name == "xlov" ]]; then
8897 setfattr --name=trusted.lov --value="$value" $file1 &&
8898 error "setxattr invalid 'trusted.lov' success"
8900 setfattr --name=trusted.$name --value="$value" $file1 ||
8901 error "setxattr invalid 'trusted.$name' failed"
8904 # Try to remove the xattr from $file1. We don't care if this
8905 # appears to succeed or fail, we just don't want there to be
8906 # any changes or crashes.
8907 setfattr --remove=$trusted.$name $file1 2> /dev/null
8910 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
8913 # Try to copy xattr from $file0 to $file1.
8914 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8916 setfattr --name=trusted.$name --value="$value" $file1 ||
8917 error "setxattr 'trusted.$name' failed"
8919 # Try to set a garbage xattr.
8920 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8922 setfattr --name=trusted.$name --value="$value" $file1 ||
8923 error "setxattr 'trusted.$name' failed"
8925 # Try to remove the xattr from $file1. We don't care if this
8926 # appears to succeed or fail, we just don't want there to be
8927 # any changes or crashes.
8928 setfattr --remove=$trusted.$name $file1 2> /dev/null
8931 # Get 'after' xattrs of file1.
8932 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8934 if ! diff $xattr0 $xattr1; then
8935 error "before and after xattrs of '$file1' differ"
8938 rm -rf $file0 $file1 $xattr0 $xattr1
8942 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8944 test_102p() { # LU-4703 setxattr did not check ownership
8945 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
8946 skip "MDS needs to be at least 2.5.56"
8948 local testfile=$DIR/$tfile
8952 echo "setfacl as user..."
8953 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8954 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8956 echo "setfattr as user..."
8957 setfacl -m "u:$RUNAS_ID:---" $testfile
8958 $RUNAS setfattr -x system.posix_acl_access $testfile
8959 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8961 run_test 102p "check setxattr(2) correctly fails without permission"
8964 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
8965 skip "MDS needs to be at least 2.6.92"
8967 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8969 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8972 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
8973 skip "MDS needs to be at least 2.6.93"
8975 touch $DIR/$tfile || error "touch"
8976 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8977 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8978 rm $DIR/$tfile || error "rm"
8981 mkdir -p $DIR/$tdir || error "mkdir"
8982 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8983 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8984 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8985 error "$testfile error deleting user.author1"
8986 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8987 grep "user.$(basename $tdir)" &&
8988 error "$tdir did not delete user.$(basename $tdir)"
8989 rmdir $DIR/$tdir || error "rmdir"
8992 test_mkdir $DIR/$tdir
8993 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8994 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8995 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8996 error "$testfile error deleting user.author1"
8997 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8998 grep "user.$(basename $tdir)" &&
8999 error "$tdir did not delete user.$(basename $tdir)"
9000 rmdir $DIR/$tdir || error "rm striped dir"
9002 run_test 102r "set EAs with empty values"
9005 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9006 skip "MDS needs to be at least 2.11.52"
9008 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9010 save_lustre_params client "llite.*.xattr_cache" > $save
9012 for cache in 0 1; do
9013 lctl set_param llite.*.xattr_cache=$cache
9016 touch $DIR/$tfile || error "touch"
9017 for prefix in lustre security system trusted user; do
9018 # Note getxattr() may fail with 'Operation not
9019 # supported' or 'No such attribute' depending
9020 # on prefix and cache.
9021 getfattr -n $prefix.n102s $DIR/$tfile &&
9022 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
9026 restore_lustre_params < $save
9028 run_test 102s "getting nonexistent xattrs should fail"
9031 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
9032 skip "MDS needs to be at least 2.11.52"
9034 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9036 save_lustre_params client "llite.*.xattr_cache" > $save
9038 for cache in 0 1; do
9039 lctl set_param llite.*.xattr_cache=$cache
9041 for buf_size in 0 256; do
9043 touch $DIR/$tfile || error "touch"
9044 setfattr -n user.multiop $DIR/$tfile
9045 $MULTIOP $DIR/$tfile oa$buf_size ||
9046 error "cannot get zero length xattr value (buf_size = $buf_size)"
9050 restore_lustre_params < $save
9052 run_test 102t "zero length xattr values handled correctly"
9056 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
9061 [ "$UID" != 0 ] && skip "must run as root"
9062 $GSS && skip_env "could not run under gss"
9063 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
9064 skip_env "must have acl enabled"
9065 [ -z "$(which setfacl 2>/dev/null)" ] &&
9066 skip_env "could not find setfacl"
9067 remote_mds_nodsh && skip "remote MDS with nodsh"
9069 gpasswd -a daemon bin # LU-5641
9070 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
9072 declare -a identity_old
9074 for num in $(seq $MDSCOUNT); do
9075 switch_identity $num true || identity_old[$num]=$?
9083 echo "performing cp ..."
9084 run_acl_subtest cp || error "run_acl_subtest cp failed"
9085 echo "performing getfacl-noacl..."
9086 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
9087 echo "performing misc..."
9088 run_acl_subtest misc || error "misc test failed"
9089 echo "performing permissions..."
9090 run_acl_subtest permissions || error "permissions failed"
9091 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
9092 if [ $MDS1_VERSION -gt $(version_code 2.8.55) ] ||
9093 { [ $MDS1_VERSION -lt $(version_code 2.6) ] &&
9094 [ $MDS1_VERSION -ge $(version_code 2.5.29) ]; }
9096 echo "performing permissions xattr..."
9097 run_acl_subtest permissions_xattr ||
9098 error "permissions_xattr failed"
9100 echo "performing setfacl..."
9101 run_acl_subtest setfacl || error "setfacl test failed"
9103 # inheritance test got from HP
9104 echo "performing inheritance..."
9105 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
9106 chmod +x make-tree || error "chmod +x failed"
9107 run_acl_subtest inheritance || error "inheritance test failed"
9110 echo "LU-974 ignore umask when acl is enabled..."
9111 run_acl_subtest 974 || error "LU-974 umask test failed"
9112 if [ $MDSCOUNT -ge 2 ]; then
9113 run_acl_subtest 974_remote ||
9114 error "LU-974 umask test failed under remote dir"
9117 echo "LU-2561 newly created file is same size as directory..."
9118 if [ "$mds1_FSTYPE" != "zfs" ]; then
9119 run_acl_subtest 2561 || error "LU-2561 test failed"
9121 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
9124 run_acl_subtest 4924 || error "LU-4924 test failed"
9129 for num in $(seq $MDSCOUNT); do
9130 if [ "${identity_old[$num]}" = 1 ]; then
9131 switch_identity $num false || identity_old[$num]=$?
9135 run_test 103a "acl test"
9141 for U in {0..511}; do
9143 local O=$(printf "%04o" $U)
9145 umask $(printf "%04o" $((511 ^ $O)))
9146 $LFS setstripe -c 1 $DIR/$tfile.s$O
9147 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
9149 (( $S == ($O & 0666) )) ||
9150 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
9152 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
9153 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
9154 (( $S == ($O & 0666) )) ||
9155 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
9157 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
9158 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
9159 (( $S == ($O & 0666) )) ||
9160 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
9161 rm -f $DIR/$tfile.[smp]$0
9165 # limit the concurrently running threads to 64. LU-11878
9166 local idx=$((U % 64))
9167 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
9172 run_test 103b "umask lfs setstripe"
9176 cp -rp $DIR/$tdir $DIR/$tdir.bak
9178 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
9179 error "$DIR/$tdir shouldn't contain default ACL"
9180 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
9181 error "$DIR/$tdir.bak shouldn't contain default ACL"
9184 run_test 103c "'cp -rp' won't set empty acl"
9187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9190 lfs df || error "lfs df failed"
9191 lfs df -ih || error "lfs df -ih failed"
9192 lfs df -h $DIR || error "lfs df -h $DIR failed"
9193 lfs df -i $DIR || error "lfs df -i $DIR failed"
9194 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
9195 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
9197 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
9198 lctl --device %$OSC deactivate
9199 lfs df || error "lfs df with deactivated OSC failed"
9200 lctl --device %$OSC activate
9201 # wait the osc back to normal
9202 wait_osc_import_ready client ost
9204 lfs df || error "lfs df with reactivated OSC failed"
9207 run_test 104a "lfs df [-ih] [path] test ========================="
9210 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9211 [ $RUNAS_ID -eq $UID ] &&
9212 skip_env "RUNAS_ID = UID = $UID -- skipping"
9214 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
9215 grep "Permission denied" | wc -l)))
9216 if [ $denied_cnt -ne 0 ]; then
9217 error "lfs check servers test failed"
9220 run_test 104b "$RUNAS lfs check servers test ===================="
9223 # doesn't work on 2.4 kernels
9225 if $(flock_is_enabled); then
9226 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
9228 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
9232 run_test 105a "flock when mounted without -o flock test ========"
9236 if $(flock_is_enabled); then
9237 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
9239 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
9243 run_test 105b "fcntl when mounted without -o flock test ========"
9247 if $(flock_is_enabled); then
9248 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
9250 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
9254 run_test 105c "lockf when mounted without -o flock test"
9256 test_105d() { # bug 15924
9257 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9259 test_mkdir $DIR/$tdir
9260 flock_is_enabled || skip_env "mount w/o flock enabled"
9261 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
9262 $LCTL set_param fail_loc=0x80000315
9263 flocks_test 2 $DIR/$tdir
9265 run_test 105d "flock race (should not freeze) ========"
9267 test_105e() { # bug 22660 && 22040
9268 flock_is_enabled || skip_env "mount w/o flock enabled"
9271 flocks_test 3 $DIR/$tfile
9273 run_test 105e "Two conflicting flocks from same process"
9275 test_106() { #bug 10921
9276 test_mkdir $DIR/$tdir
9277 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
9278 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
9280 run_test 106 "attempt exec of dir followed by chown of that dir"
9283 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9291 local save_pattern=$(sysctl -n kernel.core_pattern)
9292 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
9293 sysctl -w kernel.core_pattern=$file
9294 sysctl -w kernel.core_uses_pid=0
9302 kill -s 11 $SLEEPPID
9304 if [ -e $file ]; then
9305 size=`stat -c%s $file`
9306 [ $size -eq 0 ] && error "Fail to create core file $file"
9308 error "Fail to create core file $file"
9311 sysctl -w kernel.core_pattern=$save_pattern
9312 sysctl -w kernel.core_uses_pid=$save_uses_pid
9315 run_test 107 "Coredump on SIG"
9318 test_mkdir $DIR/$tdir
9319 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
9320 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
9321 error "mkdir with 256 char should fail, but did not"
9322 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
9323 error "create with 255 char failed"
9324 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
9325 error "create with 256 char should fail, but did not"
9330 run_test 110 "filename length checking"
9333 # Purpose: To verify dynamic thread (OSS) creation.
9336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9337 remote_ost_nodsh && skip "remote OST with nodsh"
9339 # Lustre does not stop service threads once they are started.
9340 # Reset number of running threads to default.
9345 local save_params="$TMP/sanity-$TESTNAME.parameters"
9347 # Get ll_ost_io count before I/O
9348 OSTIO_pre=$(do_facet ost1 \
9349 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
9350 # Exit if lustre is not running (ll_ost_io not running).
9351 [ -z "$OSTIO_pre" ] && error "no OSS threads"
9353 echo "Starting with $OSTIO_pre threads"
9354 local thread_max=$((OSTIO_pre * 2))
9355 local rpc_in_flight=$((thread_max * 2))
9356 # Number of I/O Process proposed to be started.
9358 local facets=$(get_facets OST)
9360 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
9361 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
9363 # Set in_flight to $rpc_in_flight
9364 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
9365 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
9366 nfiles=${rpc_in_flight}
9367 # Set ost thread_max to $thread_max
9368 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
9370 # 5 Minutes should be sufficient for max number of OSS
9371 # threads(thread_max) to be created.
9375 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
9376 test_mkdir $DIR/$tdir
9377 for i in $(seq $nfiles); do
9378 local file=$DIR/$tdir/${tfile}-$i
9379 $LFS setstripe -c -1 -i 0 $file
9380 ($WTL $file $timeout)&
9383 # I/O Started - Wait for thread_started to reach thread_max or report
9384 # error if thread_started is more than thread_max.
9385 echo "Waiting for thread_started to reach thread_max"
9386 local thread_started=0
9387 local end_time=$((SECONDS + timeout))
9389 while [ $SECONDS -le $end_time ] ; do
9391 # Get ost i/o thread_started count.
9392 thread_started=$(do_facet ost1 \
9394 ost.OSS.ost_io.threads_started | cut -d= -f2")
9395 # Break out if thread_started is equal/greater than thread_max
9396 if [[ $thread_started -ge $thread_max ]]; then
9397 echo ll_ost_io thread_started $thread_started, \
9398 equal/greater than thread_max $thread_max
9404 # Cleanup - We have the numbers, Kill i/o jobs if running.
9405 jobcount=($(jobs -p))
9406 for i in $(seq 0 $((${#jobcount[@]}-1)))
9408 kill -9 ${jobcount[$i]}
9409 if [ $? -ne 0 ] ; then
9411 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
9415 # Cleanup files left by WTL binary.
9416 for i in $(seq $nfiles); do
9417 local file=$DIR/$tdir/${tfile}-$i
9419 if [ $? -ne 0 ] ; then
9420 echo "Warning: Failed to delete file $file"
9424 restore_lustre_params <$save_params
9425 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
9427 # Error out if no new thread has started or Thread started is greater
9429 if [[ $thread_started -le $OSTIO_pre ||
9430 $thread_started -gt $thread_max ]]; then
9431 error "ll_ost_io: thread_started $thread_started" \
9432 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
9433 "No new thread started or thread started greater " \
9437 run_test 115 "verify dynamic thread creation===================="
9440 wait_delete_completed
9441 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
9442 echo "OST kbytes available: ${AVAIL[@]}"
9447 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
9448 #echo OST $i: ${AVAIL[i]}kb
9449 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
9453 if [[ ${AVAIL[i]} -lt $MINV ]]; then
9458 echo "Min free space: OST $MINI: $MINV"
9459 echo "Max free space: OST $MAXI: $MAXV"
9462 test_116a() { # was previously test_116()
9463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9464 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9465 remote_mds_nodsh && skip "remote MDS with nodsh"
9467 echo -n "Free space priority "
9468 do_facet $SINGLEMDS lctl get_param -n lo[vd].*-mdtlov.qos_prio_free |
9473 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9474 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9475 trap simple_cleanup_common EXIT
9477 # Check if we need to generate uneven OSTs
9478 test_mkdir -p $DIR/$tdir/OST${MINI}
9479 local FILL=$((MINV / 4))
9480 local DIFF=$((MAXV - MINV))
9481 local DIFF2=$((DIFF * 100 / MINV))
9483 local threshold=$(do_facet $SINGLEMDS \
9484 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9485 threshold=${threshold%%%}
9486 echo -n "Check for uneven OSTs: "
9487 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9489 if [[ $DIFF2 -gt $threshold ]]; then
9491 echo "Don't need to fill OST$MINI"
9493 # generate uneven OSTs. Write 2% over the QOS threshold value
9495 DIFF=$((threshold - DIFF2 + 2))
9496 DIFF2=$((MINV * DIFF / 100))
9497 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9498 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9499 error "setstripe failed"
9500 DIFF=$((DIFF2 / 2048))
9502 while [ $i -lt $DIFF ]; do
9504 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9505 bs=2M count=1 2>/dev/null
9514 DIFF=$((MAXV - MINV))
9515 DIFF2=$((DIFF * 100 / MINV))
9516 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9517 if [ $DIFF2 -gt $threshold ]; then
9520 echo "failed - QOS mode won't be used"
9521 simple_cleanup_common
9522 skip "QOS imbalance criteria not met"
9530 # now fill using QOS
9531 $SETSTRIPE -c 1 $DIR/$tdir
9532 FILL=$((FILL / 200))
9533 if [ $FILL -gt 600 ]; then
9536 echo "writing $FILL files to QOS-assigned OSTs"
9538 while [ $i -lt $FILL ]; do
9540 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9544 echo "wrote $i 200k files"
9548 echo "Note: free space may not be updated, so measurements might be off"
9550 DIFF2=$((MAXV - MINV))
9551 echo "free space delta: orig $DIFF final $DIFF2"
9552 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9553 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9554 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9555 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9556 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9557 if [[ $DIFF -gt 0 ]]; then
9558 FILL=$((DIFF2 * 100 / DIFF - 100))
9559 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9562 # Figure out which files were written where
9563 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9564 awk '/'$MINI1': / {print $2; exit}')
9566 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9567 echo "$MINC files created on smaller OST $MINI1"
9568 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9569 awk '/'$MAXI1': / {print $2; exit}')
9571 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9572 echo "$MAXC files created on larger OST $MAXI1"
9573 if [[ $MINC -gt 0 ]]; then
9574 FILL=$((MAXC * 100 / MINC - 100))
9575 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9577 [[ $MAXC -gt $MINC ]] ||
9578 error_ignore LU-9 "stripe QOS didn't balance free space"
9579 simple_cleanup_common
9581 run_test 116a "stripe QOS: free space balance ==================="
9583 test_116b() { # LU-2093
9584 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9585 remote_mds_nodsh && skip "remote MDS with nodsh"
9587 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9588 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9589 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9590 [ -z "$old_rr" ] && skip "no QOS"
9591 do_facet $SINGLEMDS lctl set_param \
9592 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9594 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9595 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9596 do_facet $SINGLEMDS lctl set_param fail_loc=0
9598 do_facet $SINGLEMDS lctl set_param \
9599 lo[vd].$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9601 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9603 test_117() # bug 10891
9605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9607 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9608 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9609 lctl set_param fail_loc=0x21e
9610 > $DIR/$tfile || error "truncate failed"
9611 lctl set_param fail_loc=0
9612 echo "Truncate succeeded."
9615 run_test 117 "verify osd extend =========="
9617 NO_SLOW_RESENDCOUNT=4
9618 export OLD_RESENDCOUNT=""
9619 set_resend_count () {
9620 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9621 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9622 lctl set_param -n $PROC_RESENDCOUNT $1
9623 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9626 # for reduce test_118* time (b=14842)
9627 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9629 # Reset async IO behavior after error case
9631 FILE=$DIR/reset_async
9633 # Ensure all OSCs are cleared
9634 $SETSTRIPE -c -1 $FILE
9635 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9640 test_118a() #bug 11710
9642 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9646 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9647 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9648 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9650 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9651 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9656 run_test 118a "verify O_SYNC works =========="
9660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9661 remote_ost_nodsh && skip "remote OST with nodsh"
9665 #define OBD_FAIL_SRV_ENOENT 0x217
9666 set_nodes_failloc "$(osts_nodes)" 0x217
9667 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9669 set_nodes_failloc "$(osts_nodes)" 0
9670 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9671 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9674 if [[ $RC -eq 0 ]]; then
9675 error "Must return error due to dropped pages, rc=$RC"
9679 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9680 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9684 echo "Dirty pages not leaked on ENOENT"
9686 # Due to the above error the OSC will issue all RPCs syncronously
9687 # until a subsequent RPC completes successfully without error.
9688 $MULTIOP $DIR/$tfile Ow4096yc
9693 run_test 118b "Reclaim dirty pages on fatal error =========="
9697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9699 # for 118c, restore the original resend count, LU-1940
9700 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9701 set_resend_count $OLD_RESENDCOUNT
9702 remote_ost_nodsh && skip "remote OST with nodsh"
9706 #define OBD_FAIL_OST_EROFS 0x216
9707 set_nodes_failloc "$(osts_nodes)" 0x216
9709 # multiop should block due to fsync until pages are written
9710 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9714 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9715 error "Multiop failed to block on fsync, pid=$MULTIPID"
9718 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9720 if [[ $WRITEBACK -eq 0 ]]; then
9721 error "No page in writeback, writeback=$WRITEBACK"
9724 set_nodes_failloc "$(osts_nodes)" 0
9727 if [[ $RC -ne 0 ]]; then
9728 error "Multiop fsync failed, rc=$RC"
9731 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9732 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9734 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9735 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9739 echo "Dirty pages flushed via fsync on EROFS"
9742 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9744 # continue to use small resend count to reduce test_118* time (b=14842)
9745 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9749 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9750 remote_ost_nodsh && skip "remote OST with nodsh"
9754 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9755 set_nodes_failloc "$(osts_nodes)" 0x214
9756 # multiop should block due to fsync until pages are written
9757 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9761 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9762 error "Multiop failed to block on fsync, pid=$MULTIPID"
9765 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9767 if [[ $WRITEBACK -eq 0 ]]; then
9768 error "No page in writeback, writeback=$WRITEBACK"
9771 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9772 set_nodes_failloc "$(osts_nodes)" 0
9774 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9775 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9777 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9778 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9782 echo "Dirty pages gaurenteed flushed via fsync"
9785 run_test 118d "Fsync validation inject a delay of the bulk =========="
9788 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9792 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9793 lctl set_param fail_loc=0x8000040a
9795 # Should simulate EINVAL error which is fatal
9796 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9798 if [[ $RC -eq 0 ]]; then
9799 error "Must return error due to dropped pages, rc=$RC"
9802 lctl set_param fail_loc=0x0
9804 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9805 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9806 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9808 if [[ $LOCKED -ne 0 ]]; then
9809 error "Locked pages remain in cache, locked=$LOCKED"
9812 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9813 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9817 echo "No pages locked after fsync"
9822 run_test 118f "Simulate unrecoverable OSC side error =========="
9825 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9829 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9830 lctl set_param fail_loc=0x406
9832 # simulate local -ENOMEM
9833 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9836 lctl set_param fail_loc=0
9837 if [[ $RC -eq 0 ]]; then
9838 error "Must return error due to dropped pages, rc=$RC"
9841 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9842 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9843 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9845 if [[ $LOCKED -ne 0 ]]; then
9846 error "Locked pages remain in cache, locked=$LOCKED"
9849 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9850 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9854 echo "No pages locked after fsync"
9859 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9862 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9863 remote_ost_nodsh && skip "remote OST with nodsh"
9867 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9868 set_nodes_failloc "$(osts_nodes)" 0x20e
9869 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9870 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9873 set_nodes_failloc "$(osts_nodes)" 0
9874 if [[ $RC -eq 0 ]]; then
9875 error "Must return error due to dropped pages, rc=$RC"
9878 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9879 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9880 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9882 if [[ $LOCKED -ne 0 ]]; then
9883 error "Locked pages remain in cache, locked=$LOCKED"
9886 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9887 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9891 echo "No pages locked after fsync"
9895 run_test 118h "Verify timeout in handling recoverables errors =========="
9897 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9900 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9901 remote_ost_nodsh && skip "remote OST with nodsh"
9905 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9906 set_nodes_failloc "$(osts_nodes)" 0x20e
9908 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9909 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9912 set_nodes_failloc "$(osts_nodes)" 0
9916 if [[ $RC -ne 0 ]]; then
9917 error "got error, but should be not, rc=$RC"
9920 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9921 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9922 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9923 if [[ $LOCKED -ne 0 ]]; then
9924 error "Locked pages remain in cache, locked=$LOCKED"
9927 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9928 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9932 echo "No pages locked after fsync"
9936 run_test 118i "Fix error before timeout in recoverable error =========="
9938 [ "$SLOW" = "no" ] && set_resend_count 4
9941 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9942 remote_ost_nodsh && skip "remote OST with nodsh"
9946 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9947 set_nodes_failloc "$(osts_nodes)" 0x220
9949 # return -EIO from OST
9950 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9952 set_nodes_failloc "$(osts_nodes)" 0x0
9953 if [[ $RC -eq 0 ]]; then
9954 error "Must return error due to dropped pages, rc=$RC"
9957 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9958 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9959 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9960 if [[ $LOCKED -ne 0 ]]; then
9961 error "Locked pages remain in cache, locked=$LOCKED"
9964 # in recoverable error on OST we want resend and stay until it finished
9965 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9966 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9970 echo "No pages locked after fsync"
9974 run_test 118j "Simulate unrecoverable OST side error =========="
9978 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9979 remote_ost_nodsh && skip "remote OSTs with nodsh"
9981 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9982 set_nodes_failloc "$(osts_nodes)" 0x20e
9983 test_mkdir $DIR/$tdir
9985 for ((i=0;i<10;i++)); do
9986 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9987 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9994 set_nodes_failloc "$(osts_nodes)" 0
9997 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9999 test_118l() # LU-646
10001 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10003 test_mkdir $DIR/$tdir
10004 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
10007 run_test 118l "fsync dir"
10009 test_118m() # LU-3066
10011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10013 test_mkdir $DIR/$tdir
10014 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
10017 run_test 118m "fdatasync dir ========="
10019 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
10026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10027 remote_ost_nodsh && skip "remote OSTs with nodsh"
10029 # Sleep to avoid a cached response.
10030 #define OBD_STATFS_CACHE_SECONDS 1
10033 # Inject a 10 second delay in the OST_STATFS handler.
10034 #define OBD_FAIL_OST_STATFS_DELAY 0x242
10035 set_nodes_failloc "$(osts_nodes)" 0x242
10038 stat --file-system $MOUNT > /dev/null
10041 set_nodes_failloc "$(osts_nodes)" 0
10043 if ((end - begin > 20)); then
10044 error "statfs took $((end - begin)) seconds, expected 10"
10047 run_test 118n "statfs() sends OST_STATFS requests in parallel"
10049 test_119a() # bug 11737
10051 BSIZE=$((512 * 1024))
10052 directio write $DIR/$tfile 0 1 $BSIZE
10053 # We ask to read two blocks, which is more than a file size.
10054 # directio will indicate an error when requested and actual
10055 # sizes aren't equeal (a normal situation in this case) and
10056 # print actual read amount.
10057 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
10058 if [ "$NOB" != "$BSIZE" ]; then
10059 error "read $NOB bytes instead of $BSIZE"
10063 run_test 119a "Short directIO read must return actual read amount"
10065 test_119b() # bug 11737
10067 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10069 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
10070 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
10072 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
10073 error "direct read failed"
10076 run_test 119b "Sparse directIO read must return actual read amount"
10078 test_119c() # bug 13099
10081 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
10082 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
10085 run_test 119c "Testing for direct read hitting hole"
10087 test_119d() # bug 15950
10089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10091 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
10092 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
10094 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
10095 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
10096 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
10097 lctl set_param fail_loc=0x40d
10098 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
10101 cat $DIR/$tfile > /dev/null &
10102 lctl set_param fail_loc=0
10105 log "the DIO writes have completed, now wait for the reads (should not block very long)"
10107 [ -n "`ps h -p $pid_reads -o comm`" ] && \
10108 error "the read rpcs have not completed in 2s"
10110 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
10112 run_test 119d "The DIO path should try to send a new rpc once one is completed"
10115 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10116 remote_mds_nodsh && skip "remote MDS with nodsh"
10117 test_mkdir $DIR/$tdir
10118 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10119 skip_env "no early lock cancel on server"
10121 lru_resize_disable mdc
10122 lru_resize_disable osc
10123 cancel_lru_locks mdc
10124 # asynchronous object destroy at MDT could cause bl ast to client
10125 cancel_lru_locks osc
10127 stat $DIR/$tdir > /dev/null
10128 can1=$(do_facet $SINGLEMDS \
10129 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10130 awk '/ldlm_cancel/ {print $2}')
10131 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10132 awk '/ldlm_bl_callback/ {print $2}')
10133 test_mkdir -c1 $DIR/$tdir/d1
10134 can2=$(do_facet $SINGLEMDS \
10135 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10136 awk '/ldlm_cancel/ {print $2}')
10137 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10138 awk '/ldlm_bl_callback/ {print $2}')
10139 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10140 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10141 lru_resize_enable mdc
10142 lru_resize_enable osc
10144 run_test 120a "Early Lock Cancel: mkdir test"
10147 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10148 remote_mds_nodsh && skip "remote MDS with nodsh"
10149 test_mkdir $DIR/$tdir
10150 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10151 skip_env "no early lock cancel on server"
10153 lru_resize_disable mdc
10154 lru_resize_disable osc
10155 cancel_lru_locks mdc
10156 stat $DIR/$tdir > /dev/null
10157 can1=$(do_facet $SINGLEMDS \
10158 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10159 awk '/ldlm_cancel/ {print $2}')
10160 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10161 awk '/ldlm_bl_callback/ {print $2}')
10162 touch $DIR/$tdir/f1
10163 can2=$(do_facet $SINGLEMDS \
10164 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10165 awk '/ldlm_cancel/ {print $2}')
10166 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10167 awk '/ldlm_bl_callback/ {print $2}')
10168 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10169 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10170 lru_resize_enable mdc
10171 lru_resize_enable osc
10173 run_test 120b "Early Lock Cancel: create test"
10176 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10177 remote_mds_nodsh && skip "remote MDS with nodsh"
10178 test_mkdir -c1 $DIR/$tdir
10179 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10180 skip "no early lock cancel on server"
10182 lru_resize_disable mdc
10183 lru_resize_disable osc
10184 test_mkdir -c1 $DIR/$tdir/d1
10185 test_mkdir -c1 $DIR/$tdir/d2
10186 touch $DIR/$tdir/d1/f1
10187 cancel_lru_locks mdc
10188 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
10189 can1=$(do_facet $SINGLEMDS \
10190 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10191 awk '/ldlm_cancel/ {print $2}')
10192 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10193 awk '/ldlm_bl_callback/ {print $2}')
10194 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10195 can2=$(do_facet $SINGLEMDS \
10196 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10197 awk '/ldlm_cancel/ {print $2}')
10198 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10199 awk '/ldlm_bl_callback/ {print $2}')
10200 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10201 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10202 lru_resize_enable mdc
10203 lru_resize_enable osc
10205 run_test 120c "Early Lock Cancel: link test"
10208 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10209 remote_mds_nodsh && skip "remote MDS with nodsh"
10210 test_mkdir -c1 $DIR/$tdir
10211 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10212 skip_env "no early lock cancel on server"
10214 lru_resize_disable mdc
10215 lru_resize_disable osc
10217 cancel_lru_locks mdc
10218 stat $DIR/$tdir > /dev/null
10219 can1=$(do_facet $SINGLEMDS \
10220 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10221 awk '/ldlm_cancel/ {print $2}')
10222 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10223 awk '/ldlm_bl_callback/ {print $2}')
10224 chmod a+x $DIR/$tdir
10225 can2=$(do_facet $SINGLEMDS \
10226 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10227 awk '/ldlm_cancel/ {print $2}')
10228 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10229 awk '/ldlm_bl_callback/ {print $2}')
10230 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10231 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10232 lru_resize_enable mdc
10233 lru_resize_enable osc
10235 run_test 120d "Early Lock Cancel: setattr test"
10238 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10239 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10240 skip_env "no early lock cancel on server"
10241 remote_mds_nodsh && skip "remote MDS with nodsh"
10243 local dlmtrace_set=false
10245 test_mkdir -c1 $DIR/$tdir
10246 lru_resize_disable mdc
10247 lru_resize_disable osc
10248 ! $LCTL get_param debug | grep -q dlmtrace &&
10249 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
10250 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
10251 cancel_lru_locks mdc
10252 cancel_lru_locks osc
10253 dd if=$DIR/$tdir/f1 of=/dev/null
10254 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
10255 # XXX client can not do early lock cancel of OST lock
10256 # during unlink (LU-4206), so cancel osc lock now.
10258 cancel_lru_locks osc
10259 can1=$(do_facet $SINGLEMDS \
10260 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10261 awk '/ldlm_cancel/ {print $2}')
10262 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10263 awk '/ldlm_bl_callback/ {print $2}')
10264 unlink $DIR/$tdir/f1
10266 can2=$(do_facet $SINGLEMDS \
10267 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10268 awk '/ldlm_cancel/ {print $2}')
10269 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10270 awk '/ldlm_bl_callback/ {print $2}')
10271 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
10272 $LCTL dk $TMP/cancel.debug.txt
10273 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
10274 $LCTL dk $TMP/blocking.debug.txt
10275 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
10276 lru_resize_enable mdc
10277 lru_resize_enable osc
10279 run_test 120e "Early Lock Cancel: unlink test"
10282 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10283 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10284 skip_env "no early lock cancel on server"
10285 remote_mds_nodsh && skip "remote MDS with nodsh"
10287 test_mkdir -c1 $DIR/$tdir
10288 lru_resize_disable mdc
10289 lru_resize_disable osc
10290 test_mkdir -c1 $DIR/$tdir/d1
10291 test_mkdir -c1 $DIR/$tdir/d2
10292 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
10293 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
10294 cancel_lru_locks mdc
10295 cancel_lru_locks osc
10296 dd if=$DIR/$tdir/d1/f1 of=/dev/null
10297 dd if=$DIR/$tdir/d2/f2 of=/dev/null
10298 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
10299 # XXX client can not do early lock cancel of OST lock
10300 # during rename (LU-4206), so cancel osc lock now.
10302 cancel_lru_locks osc
10303 can1=$(do_facet $SINGLEMDS \
10304 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10305 awk '/ldlm_cancel/ {print $2}')
10306 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10307 awk '/ldlm_bl_callback/ {print $2}')
10308 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
10310 can2=$(do_facet $SINGLEMDS \
10311 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10312 awk '/ldlm_cancel/ {print $2}')
10313 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10314 awk '/ldlm_bl_callback/ {print $2}')
10315 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
10316 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
10317 lru_resize_enable mdc
10318 lru_resize_enable osc
10320 run_test 120f "Early Lock Cancel: rename test"
10323 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10324 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
10325 skip_env "no early lock cancel on server"
10326 remote_mds_nodsh && skip "remote MDS with nodsh"
10328 lru_resize_disable mdc
10329 lru_resize_disable osc
10331 echo create $count files
10332 test_mkdir $DIR/$tdir
10333 cancel_lru_locks mdc
10334 cancel_lru_locks osc
10337 can0=$(do_facet $SINGLEMDS \
10338 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10339 awk '/ldlm_cancel/ {print $2}')
10340 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10341 awk '/ldlm_bl_callback/ {print $2}')
10342 createmany -o $DIR/$tdir/f $count
10344 can1=$(do_facet $SINGLEMDS \
10345 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10346 awk '/ldlm_cancel/ {print $2}')
10347 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10348 awk '/ldlm_bl_callback/ {print $2}')
10350 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
10351 echo rm $count files
10354 can2=$(do_facet $SINGLEMDS \
10355 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
10356 awk '/ldlm_cancel/ {print $2}')
10357 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
10358 awk '/ldlm_bl_callback/ {print $2}')
10360 echo total: $count removes in $((t2-t1))
10361 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
10363 # wait for commitment of removal
10364 lru_resize_enable mdc
10365 lru_resize_enable osc
10367 run_test 120g "Early Lock Cancel: performance test"
10369 test_121() { #bug #10589
10370 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10373 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
10374 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
10375 lctl set_param fail_loc=0x310
10376 cancel_lru_locks osc > /dev/null
10377 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
10378 lctl set_param fail_loc=0
10379 [[ $reads -eq $writes ]] ||
10380 error "read $reads blocks, must be $writes blocks"
10382 run_test 121 "read cancel race ========="
10384 test_123a() { # was test 123, statahead(bug 11401)
10385 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10388 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
10389 log "testing UP system. Performance may be lower than expected."
10394 test_mkdir $DIR/$tdir
10395 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
10396 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
10398 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
10399 createmany -o $DIR/$tdir/$tfile $j $((i - j))
10401 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10402 lctl set_param -n llite.*.statahead_max 0
10403 lctl get_param llite.*.statahead_max
10404 cancel_lru_locks mdc
10405 cancel_lru_locks osc
10407 time ls -l $DIR/$tdir | wc -l
10409 delta=$((etime - stime))
10410 log "ls $i files without statahead: $delta sec"
10411 lctl set_param llite.*.statahead_max=$max
10413 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10414 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
10415 cancel_lru_locks mdc
10416 cancel_lru_locks osc
10418 time ls -l $DIR/$tdir | wc -l
10420 delta_sa=$((etime - stime))
10421 log "ls $i files with statahead: $delta_sa sec"
10422 lctl get_param -n llite.*.statahead_stats
10423 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
10425 [[ $swrong -lt $ewrong ]] &&
10426 log "statahead was stopped, maybe too many locks held!"
10427 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
10429 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10430 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
10431 lctl set_param -n llite.*.statahead_max 0
10432 lctl get_param llite.*.statahead_max
10433 cancel_lru_locks mdc
10434 cancel_lru_locks osc
10436 time ls -l $DIR/$tdir | wc -l
10438 delta=$((etime - stime))
10439 log "ls $i files again without statahead: $delta sec"
10440 lctl set_param llite.*.statahead_max=$max
10441 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
10442 if [ $SLOWOK -eq 0 ]; then
10443 error "ls $i files is slower with statahead!"
10445 log "ls $i files is slower with statahead!"
10451 [ $delta -gt 20 ] && break
10452 [ $delta -gt 8 ] && MULT=$((50 / delta))
10453 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
10461 delta=$((etime - stime))
10462 log "rm -r $DIR/$tdir/: $delta seconds"
10464 lctl get_param -n llite.*.statahead_stats
10466 run_test 123a "verify statahead work"
10468 test_123b () { # statahead(bug 15027)
10469 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10471 test_mkdir $DIR/$tdir
10472 createmany -o $DIR/$tdir/$tfile-%d 1000
10474 cancel_lru_locks mdc
10475 cancel_lru_locks osc
10477 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10478 lctl set_param fail_loc=0x80000803
10479 ls -lR $DIR/$tdir > /dev/null
10481 lctl set_param fail_loc=0x0
10482 lctl get_param -n llite.*.statahead_stats
10487 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10490 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
10492 test_mkdir -i 0 -c 1 $DIR/$tdir.0
10493 test_mkdir -i 1 -c 1 $DIR/$tdir.1
10494 touch $DIR/$tdir.1/{1..3}
10495 mv $DIR/$tdir.1/{1..3} $DIR/$tdir.0
10497 remount_client $MOUNT
10499 $MULTIOP $DIR/$tdir.0 Q
10501 # let statahead to complete
10502 ls -l $DIR/$tdir.0 > /dev/null
10504 testid=$(echo $TESTNAME | tr '_' ' ')
10505 dmesg | tac | sed "/$testid/,$ d" | grep "Can not initialize inode" &&
10506 error "statahead warning" || true
10508 run_test 123c "Can not initialize inode warning on DNE statahead"
10511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10512 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10513 skip_env "no lru resize on server"
10517 test_mkdir $DIR/$tdir
10519 log "create $NR files at $DIR/$tdir"
10520 createmany -o $DIR/$tdir/f $NR ||
10521 error "failed to create $NR files in $DIR/$tdir"
10523 cancel_lru_locks mdc
10524 ls -l $DIR/$tdir > /dev/null
10528 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10529 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10530 LRU_SIZE=$($LCTL get_param -n $PARAM)
10531 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10532 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10534 log "NS=$(basename $NSDIR)"
10539 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10540 skip "Not enough cached locks created!"
10542 log "LRU=$LRU_SIZE"
10546 # We know that lru resize allows one client to hold $LIMIT locks
10547 # for 10h. After that locks begin to be killed by client.
10549 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10551 if [ $LIMIT -lt $LRU_SIZE ]; then
10552 skip "Limit is too small $LIMIT"
10555 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10556 # killing locks. Some time was spent for creating locks. This means
10557 # that up to the moment of sleep finish we must have killed some of
10558 # them (10-100 locks). This depends on how fast ther were created.
10559 # Many of them were touched in almost the same moment and thus will
10560 # be killed in groups.
10561 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10563 # Use $LRU_SIZE_B here to take into account real number of locks
10564 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10565 local LRU_SIZE_B=$LRU_SIZE
10567 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10568 log "OLD_LVF=$OLD_LVF"
10569 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10571 # Let's make sure that we really have some margin. Client checks
10572 # cached locks every 10 sec.
10573 SLEEP=$((SLEEP+20))
10574 log "Sleep ${SLEEP} sec"
10576 while ((SEC<$SLEEP)); do
10580 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10581 echo -n "$LRU_SIZE"
10584 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10585 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10587 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10588 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10589 unlinkmany $DIR/$tdir/f $NR
10593 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10594 log "unlink $NR files at $DIR/$tdir"
10595 unlinkmany $DIR/$tdir/f $NR
10597 run_test 124a "lru resize ======================================="
10599 get_max_pool_limit()
10601 local limit=$($LCTL get_param \
10602 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10604 for l in $limit; do
10605 if [[ $l -gt $max ]]; then
10613 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10614 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10615 skip_env "no lru resize on server"
10617 LIMIT=$(get_max_pool_limit)
10619 NR=$(($(default_lru_size)*20))
10620 if [[ $NR -gt $LIMIT ]]; then
10621 log "Limit lock number by $LIMIT locks"
10625 IFree=$(mdsrate_inodes_available)
10626 if [ $IFree -lt $NR ]; then
10627 log "Limit lock number by $IFree inodes"
10631 lru_resize_disable mdc
10632 test_mkdir -p $DIR/$tdir/disable_lru_resize
10634 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10635 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10636 cancel_lru_locks mdc
10639 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10642 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10645 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10649 nolruresize_delta=$((etime-stime))
10650 log "ls -la time: $nolruresize_delta seconds"
10651 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10652 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10654 lru_resize_enable mdc
10655 test_mkdir -p $DIR/$tdir/enable_lru_resize
10657 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10658 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10659 cancel_lru_locks mdc
10662 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10665 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10668 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10672 lruresize_delta=$((etime-stime))
10673 log "ls -la time: $lruresize_delta seconds"
10674 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10676 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10677 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10678 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10679 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10681 log "lru resize performs the same with no lru resize"
10683 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10685 run_test 124b "lru resize (performance test) ======================="
10688 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10689 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10690 skip_env "no lru resize on server"
10692 # cache ununsed locks on client
10694 cancel_lru_locks mdc
10695 test_mkdir $DIR/$tdir
10696 createmany -o $DIR/$tdir/f $nr ||
10697 error "failed to create $nr files in $DIR/$tdir"
10698 ls -l $DIR/$tdir > /dev/null
10700 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10701 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10702 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10703 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10704 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10706 # set lru_max_age to 1 sec
10707 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10708 echo "sleep $((recalc_p * 2)) seconds..."
10709 sleep $((recalc_p * 2))
10711 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10712 # restore lru_max_age
10713 $LCTL set_param -n $nsdir.lru_max_age $max_age
10714 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10715 unlinkmany $DIR/$tdir/f $nr
10717 run_test 124c "LRUR cancel very aged locks"
10720 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10721 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10722 skip_env "no lru resize on server"
10724 # cache ununsed locks on client
10727 lru_resize_disable mdc
10728 stack_trap "lru_resize_enable mdc" EXIT
10730 cancel_lru_locks mdc
10732 # asynchronous object destroy at MDT could cause bl ast to client
10733 test_mkdir $DIR/$tdir
10734 createmany -o $DIR/$tdir/f $nr ||
10735 error "failed to create $nr files in $DIR/$tdir"
10736 stack_trap "unlinkmany $DIR/$tdir/f $nr" EXIT
10738 ls -l $DIR/$tdir > /dev/null
10740 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10741 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10742 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10743 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10745 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10747 # set lru_max_age to 1 sec
10748 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10749 stack_trap "$LCTL set_param -n $nsdir.lru_max_age $max_age" EXIT
10751 echo "sleep $((recalc_p * 2)) seconds..."
10752 sleep $((recalc_p * 2))
10754 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10756 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10758 run_test 124d "cancel very aged locks if lru-resize diasbaled"
10760 test_125() { # 13358
10761 $LCTL get_param -n llite.*.client_type | grep -q local ||
10762 skip "must run as local client"
10763 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10764 skip_env "must have acl enabled"
10765 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10767 test_mkdir $DIR/$tdir
10768 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10769 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10770 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10772 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10774 test_126() { # bug 12829/13455
10775 $GSS && skip_env "must run as gss disabled"
10776 $LCTL get_param -n llite.*.client_type | grep -q local ||
10777 skip "must run as local client"
10778 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10780 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10781 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10783 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10785 run_test 126 "check that the fsgid provided by the client is taken into account"
10787 test_127a() { # bug 15521
10788 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10790 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10791 $LCTL set_param osc.*.stats=0
10792 FSIZE=$((2048 * 1024))
10793 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10794 cancel_lru_locks osc
10795 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10797 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10798 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10799 echo "got $COUNT $NAME"
10800 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10801 eval $NAME=$COUNT || error "Wrong proc format"
10804 read_bytes|write_bytes)
10805 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10806 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10807 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10808 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10809 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10810 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10811 error "sumsquare is too small: $SUMSQ"
10812 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10813 error "sumsquare is too big: $SUMSQ"
10817 done < $DIR/${tfile}.tmp
10819 #check that we actually got some stats
10820 [ "$read_bytes" ] || error "Missing read_bytes stats"
10821 [ "$write_bytes" ] || error "Missing write_bytes stats"
10822 [ "$read_bytes" != 0 ] || error "no read done"
10823 [ "$write_bytes" != 0 ] || error "no write done"
10825 run_test 127a "verify the client stats are sane"
10827 test_127b() { # bug LU-333
10828 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10829 local name count samp unit min max sum sumsq
10831 $LCTL set_param llite.*.stats=0
10833 # perform 2 reads and writes so MAX is different from SUM.
10834 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10835 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10836 cancel_lru_locks osc
10837 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10838 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10840 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
10841 while read name count samp unit min max sum sumsq; do
10842 echo "got $count $name"
10843 eval $name=$count || error "Wrong proc format"
10847 [ $count -ne 2 ] && error "count is not 2: $count"
10848 [ $min -ne $PAGE_SIZE ] &&
10849 error "min is not $PAGE_SIZE: $min"
10850 [ $max -ne $PAGE_SIZE ] &&
10851 error "max is incorrect: $max"
10852 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10853 error "sum is wrong: $sum"
10856 [ $count -ne 2 ] && error "count is not 2: $count"
10857 [ $min -ne $PAGE_SIZE ] &&
10858 error "min is not $PAGE_SIZE: $min"
10859 [ $max -ne $PAGE_SIZE ] &&
10860 error "max is incorrect: $max"
10861 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10862 error "sum is wrong: $sum"
10866 done < $TMP/$tfile.tmp
10868 #check that we actually got some stats
10869 [ "$read_bytes" ] || error "Missing read_bytes stats"
10870 [ "$write_bytes" ] || error "Missing write_bytes stats"
10871 [ "$read_bytes" != 0 ] || error "no read done"
10872 [ "$write_bytes" != 0 ] || error "no write done"
10874 rm -f $TMP/${tfile}.tmp
10876 run_test 127b "verify the llite client stats are sane"
10878 test_127c() { # LU-12394
10879 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10886 $LCTL set_param llite.*.extents_stats=1
10887 stack_trap "$LCTL set_param llite.*.extents_stats=0" EXIT
10889 # Use two stripes so there is enough space in default config
10890 $LFS setstripe -c 2 $DIR/$tfile
10892 # Extent stats start at 0-4K and go in power of two buckets
10893 # LL_HIST_START = 12 --> 2^12 = 4K
10894 # We do 3K*2^i, so 3K, 6K, 12K, 24K... hitting each bucket.
10895 # We do not do buckets larger than 64 MiB to avoid ENOSPC issues on
10897 for size in 3K 6K 12K 24K 48K 96K 192K 384K 768K 1536K 3M 6M 12M 24M 48M;
10899 # Write and read, 2x each, second time at a non-zero offset
10900 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1
10901 dd if=/dev/zero of=$DIR/$tfile bs=$size count=1 seek=10
10902 dd if=$DIR/$tfile of=/dev/null bs=$size count=1
10903 dd if=$DIR/$tfile of=/dev/null bs=$size count=1 seek=10
10907 $LCTL get_param llite.*.extents_stats
10910 for bsize in 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M 8M 16M 32M 64M;
10912 local bucket=$($LCTL get_param -n llite.*.extents_stats |
10914 reads=$(echo $bucket | awk '{print $5}')
10915 writes=$(echo $bucket | awk '{print $9}')
10916 [ "$reads" -eq $count ] ||
10917 error "$reads reads in < $bsize bucket, expect $count"
10918 [ "$writes" -eq $count ] ||
10919 error "$writes writes in < $bsize bucket, expect $count"
10922 # Test mmap write and read
10923 $LCTL set_param llite.*.extents_stats=c
10925 dd if=/dev/zero of=$DIR/$tfile bs=${size}K count=1
10926 $MULTIOP $DIR/$tfile OSMRUc || error "$MULTIOP $DIR/$tfile failed"
10927 $MULTIOP $DIR/$tfile OSMWUc || error "$MULTIOP $DIR/$tfile failed"
10929 $LCTL get_param llite.*.extents_stats
10931 count=$(((size*1024) / PAGE_SIZE))
10933 bsize=$((2 * PAGE_SIZE / 1024))K
10935 bucket=$($LCTL get_param -n llite.*.extents_stats |
10937 reads=$(echo $bucket | awk '{print $5}')
10938 writes=$(echo $bucket | awk '{print $9}')
10939 # mmap writes fault in the page first, creating an additonal read
10940 [ "$reads" -eq $((2 * count)) ] ||
10941 error "$reads reads in < $bsize bucket, expect $count"
10942 [ "$writes" -eq $count ] ||
10943 error "$writes writes in < $bsize bucket, expect $count"
10945 run_test 127c "test llite extent stats with regular & mmap i/o"
10947 test_128() { # bug 15212
10949 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10954 result=$(grep error $TMP/$tfile.log)
10955 rm -f $DIR/$tfile $TMP/$tfile.log
10956 [ -z "$result" ] ||
10957 error "consecutive find's under interactive lfs failed"
10959 run_test 128 "interactive lfs for 2 consecutive find's"
10961 set_dir_limits () {
10966 local ldproc=/proc/fs/ldiskfs
10967 local facets=$(get_facets MDS)
10969 for facet in ${facets//,/ }; do
10970 canondev=$(ldiskfs_canon \
10971 *.$(convert_facet2label $facet).mntdev $facet)
10972 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10973 ldproc=/sys/fs/ldiskfs
10974 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10975 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10979 check_mds_dmesg() {
10980 local facets=$(get_facets MDS)
10981 for facet in ${facets//,/ }; do
10982 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10988 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10989 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
10990 skip "Need MDS version with at least 2.5.56"
10991 if [ "$mds1_FSTYPE" != ldiskfs ]; then
10992 skip_env "ldiskfs only test"
10994 remote_mds_nodsh && skip "remote MDS with nodsh"
10998 local has_warning=false
11001 mkdir -p $DIR/$tdir
11003 # block size of mds1
11004 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
11005 set_dir_limits $maxsize $maxsize
11006 local dirsize=$(stat -c%s "$DIR/$tdir")
11008 while [[ $dirsize -le $maxsize ]]; do
11009 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
11011 if ! $has_warning; then
11012 check_mds_dmesg '"is approaching"' && has_warning=true
11014 # check two errors:
11015 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
11016 # EFBIG for previous versions included in ldiskfs series
11017 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
11019 echo "return code $rc received as expected"
11021 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
11022 error_exit "create failed w/o dir size limit"
11024 check_mds_dmesg '"has reached"' ||
11025 error_exit "reached message should be output"
11027 [ $has_warning = "false" ] &&
11028 error_exit "warning message should be output"
11030 dirsize=$(stat -c%s "$DIR/$tdir")
11032 [[ $dirsize -ge $maxsize ]] && return 0
11033 error_exit "current dir size $dirsize, " \
11034 "previous limit $maxsize"
11035 elif [ $rc -ne 0 ]; then
11037 error_exit "return $rc received instead of expected " \
11038 "$EFBIG or $ENOSPC, files in dir $dirsize"
11040 nfiles=$((nfiles + 1))
11041 dirsize=$(stat -c%s "$DIR/$tdir")
11045 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
11047 run_test 129 "test directory size limit ========================"
11056 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11057 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11059 trap cleanup_130 EXIT RETURN
11061 local fm_file=$DIR/$tfile
11062 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
11063 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
11064 error "dd failed for $fm_file"
11066 # LU-1795: test filefrag/FIEMAP once, even if unsupported
11067 filefrag -ves $fm_file
11069 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11070 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11071 [ $RC != 0 ] && error "filefrag $fm_file failed"
11073 filefrag_op=$(filefrag -ve -k $fm_file |
11074 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11075 lun=$($GETSTRIPE -i $fm_file)
11077 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
11080 for line in $filefrag_op
11082 frag_lun=`echo $line | cut -d: -f5`
11083 ext_len=`echo $line | cut -d: -f4`
11084 if (( $frag_lun != $lun )); then
11086 error "FIEMAP on 1-stripe file($fm_file) failed"
11089 (( tot_len += ext_len ))
11092 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
11094 error "FIEMAP on 1-stripe file($fm_file) failed;"
11100 echo "FIEMAP on single striped file succeeded"
11102 run_test 130a "FIEMAP (1-stripe file)"
11105 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
11107 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11108 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11110 trap cleanup_130 EXIT RETURN
11112 local fm_file=$DIR/$tfile
11113 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11114 error "setstripe on $fm_file"
11115 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11116 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11118 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
11119 error "dd failed on $fm_file"
11121 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11122 filefrag_op=$(filefrag -ve -k $fm_file |
11123 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11125 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11126 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11131 for line in $filefrag_op
11133 frag_lun=$(echo $line | cut -d: -f5 |
11134 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11135 ext_len=$(echo $line | cut -d: -f4)
11136 if (( $frag_lun != $last_lun )); then
11137 if (( tot_len != 1024 )); then
11139 error "FIEMAP on $fm_file failed; returned " \
11140 "len $tot_len for OST $last_lun instead of 1024"
11143 (( num_luns += 1 ))
11147 (( tot_len += ext_len ))
11150 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
11152 error "FIEMAP on $fm_file failed; returned wrong number of " \
11153 "luns or wrong len for OST $last_lun"
11159 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
11161 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
11164 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11166 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11167 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11169 trap cleanup_130 EXIT RETURN
11171 local fm_file=$DIR/$tfile
11172 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
11173 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11174 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11176 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
11177 error "dd failed on $fm_file"
11179 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11180 filefrag_op=$(filefrag -ve -k $fm_file |
11181 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11183 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11184 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11189 for line in $filefrag_op
11191 frag_lun=$(echo $line | cut -d: -f5 |
11192 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11193 ext_len=$(echo $line | cut -d: -f4)
11194 if (( $frag_lun != $last_lun )); then
11195 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
11196 if (( logical != 512 )); then
11198 error "FIEMAP on $fm_file failed; returned " \
11199 "logical start for lun $logical instead of 512"
11202 if (( tot_len != 512 )); then
11204 error "FIEMAP on $fm_file failed; returned " \
11205 "len $tot_len for OST $last_lun instead of 1024"
11208 (( num_luns += 1 ))
11212 (( tot_len += ext_len ))
11215 if (( num_luns != 2 || tot_len != 512 )); then
11217 error "FIEMAP on $fm_file failed; returned wrong number of " \
11218 "luns or wrong len for OST $last_lun"
11224 echo "FIEMAP on 2-stripe file with hole succeeded"
11226 run_test 130c "FIEMAP (2-stripe file with hole)"
11229 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
11231 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11232 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11234 trap cleanup_130 EXIT RETURN
11236 local fm_file=$DIR/$tfile
11237 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
11238 error "setstripe on $fm_file"
11239 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11240 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11242 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
11243 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
11244 error "dd failed on $fm_file"
11246 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11247 filefrag_op=$(filefrag -ve -k $fm_file |
11248 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11250 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11251 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11256 for line in $filefrag_op
11258 frag_lun=$(echo $line | cut -d: -f5 |
11259 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11260 ext_len=$(echo $line | cut -d: -f4)
11261 if (( $frag_lun != $last_lun )); then
11262 if (( tot_len != 1024 )); then
11264 error "FIEMAP on $fm_file failed; returned " \
11265 "len $tot_len for OST $last_lun instead of 1024"
11268 (( num_luns += 1 ))
11272 (( tot_len += ext_len ))
11275 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
11277 error "FIEMAP on $fm_file failed; returned wrong number of " \
11278 "luns or wrong len for OST $last_lun"
11284 echo "FIEMAP on N-stripe file succeeded"
11286 run_test 130d "FIEMAP (N-stripe file)"
11289 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
11291 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11292 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
11294 trap cleanup_130 EXIT RETURN
11296 local fm_file=$DIR/$tfile
11297 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
11298 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
11299 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
11302 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
11303 for ((i = 0; i < $NUM_BLKS; i++))
11305 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
11308 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11309 filefrag_op=$(filefrag -ve -k $fm_file |
11310 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
11312 last_lun=$(echo $filefrag_op | cut -d: -f5 |
11313 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11318 for line in $filefrag_op
11320 frag_lun=$(echo $line | cut -d: -f5 |
11321 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
11322 ext_len=$(echo $line | cut -d: -f4)
11323 if (( $frag_lun != $last_lun )); then
11324 if (( tot_len != $EXPECTED_LEN )); then
11326 error "FIEMAP on $fm_file failed; returned " \
11327 "len $tot_len for OST $last_lun instead " \
11331 (( num_luns += 1 ))
11335 (( tot_len += ext_len ))
11338 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
11340 error "FIEMAP on $fm_file failed; returned wrong number " \
11341 "of luns or wrong len for OST $last_lun"
11347 echo "FIEMAP with continuation calls succeeded"
11349 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
11352 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
11353 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
11355 local fm_file=$DIR/$tfile
11356 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
11357 error "multiop create with lov_delay_create on $fm_file"
11359 filefrag -ves $fm_file || error "filefrag $fm_file failed"
11360 filefrag_extents=$(filefrag -vek $fm_file |
11361 awk '/extents? found/ { print $2 }')
11362 if [[ "$filefrag_extents" != "0" ]]; then
11363 error "FIEMAP on $fm_file failed; " \
11364 "returned $filefrag_extents expected 0"
11369 run_test 130f "FIEMAP (unstriped file)"
11371 # Test for writev/readv
11373 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
11374 error "writev test failed"
11375 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
11376 error "readv failed"
11379 run_test 131a "test iov's crossing stripe boundary for writev/readv"
11382 local fsize=$((524288 + 1048576 + 1572864))
11383 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
11384 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11385 error "append writev test failed"
11387 ((fsize += 1572864 + 1048576))
11388 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
11389 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
11390 error "append writev test failed"
11393 run_test 131b "test append writev"
11396 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
11399 run_test 131c "test read/write on file w/o objects"
11402 rwv -f $DIR/$tfile -w -n 1 1572864
11403 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
11404 if [ "$NOB" != 1572864 ]; then
11405 error "Short read filed: read $NOB bytes instead of 1572864"
11409 run_test 131d "test short read"
11412 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
11413 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
11414 error "read hitting hole failed"
11417 run_test 131e "test read hitting hole"
11426 mds*) res=$(do_facet $facet \
11427 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
11429 ost*) res=$(do_facet $facet \
11430 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
11432 *) error "Wrong facet '$facet'" ;;
11434 [ "$res" ] || error "The counter for $op on $facet was not incremented"
11435 # if the argument $3 is zero, it means any stat increment is ok.
11436 if [[ $want -gt 0 ]]; then
11437 local count=$(echo $res | awk '{ print $2 }')
11438 [[ $count -ne $want ]] &&
11439 error "The $op counter on $facet is $count, not $want"
11444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11445 remote_ost_nodsh && skip "remote OST with nodsh"
11446 remote_mds_nodsh && skip "remote MDS with nodsh"
11447 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11448 skip_env "MDS doesn't support rename stats"
11450 local testdir=$DIR/${tdir}/stats_testdir
11452 mkdir -p $DIR/${tdir}
11455 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11456 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11458 # verify mdt stats first.
11459 mkdir ${testdir} || error "mkdir failed"
11460 check_stats $SINGLEMDS "mkdir" 1
11461 touch ${testdir}/${tfile} || error "touch failed"
11462 check_stats $SINGLEMDS "open" 1
11463 check_stats $SINGLEMDS "close" 1
11464 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
11465 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
11466 check_stats $SINGLEMDS "mknod" 2
11468 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
11469 check_stats $SINGLEMDS "unlink" 1
11470 rm -f ${testdir}/${tfile} || error "file remove failed"
11471 check_stats $SINGLEMDS "unlink" 2
11473 # remove working dir and check mdt stats again.
11474 rmdir ${testdir} || error "rmdir failed"
11475 check_stats $SINGLEMDS "rmdir" 1
11477 local testdir1=$DIR/${tdir}/stats_testdir1
11478 mkdir -p ${testdir}
11479 mkdir -p ${testdir1}
11480 touch ${testdir1}/test1
11481 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
11482 check_stats $SINGLEMDS "crossdir_rename" 1
11484 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
11485 check_stats $SINGLEMDS "samedir_rename" 1
11487 rm -rf $DIR/${tdir}
11489 run_test 133a "Verifying MDT stats ========================================"
11494 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11495 remote_ost_nodsh && skip "remote OST with nodsh"
11496 remote_mds_nodsh && skip "remote MDS with nodsh"
11498 local testdir=$DIR/${tdir}/stats_testdir
11500 mkdir -p ${testdir} || error "mkdir failed"
11501 touch ${testdir}/${tfile} || error "touch failed"
11502 cancel_lru_locks mdc
11505 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11506 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11508 # extra mdt stats verification.
11509 chmod 444 ${testdir}/${tfile} || error "chmod failed"
11510 check_stats $SINGLEMDS "setattr" 1
11511 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11512 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
11514 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
11515 check_stats $SINGLEMDS "getattr" 1
11517 rm -rf $DIR/${tdir}
11519 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
11520 # so the check below is not reliable
11521 [ $MDSCOUNT -eq 1 ] || return 0
11523 # Sleep to avoid a cached response.
11524 #define OBD_STATFS_CACHE_SECONDS 1
11526 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11527 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11528 $LFS df || error "lfs failed"
11529 check_stats $SINGLEMDS "statfs" 1
11531 # check aggregated statfs (LU-10018)
11532 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
11534 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
11537 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11538 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
11540 check_stats $SINGLEMDS "statfs" 1
11542 # We want to check that the client didn't send OST_STATFS to
11543 # ost1 but the MDT also uses OST_STATFS for precreate. So some
11544 # extra care is needed here.
11545 if remote_mds; then
11546 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
11547 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
11549 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
11550 [ "$res" ] && error "OST got STATFS"
11555 run_test 133b "Verifying extra MDT stats =================================="
11558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11559 remote_ost_nodsh && skip "remote OST with nodsh"
11560 remote_mds_nodsh && skip "remote MDS with nodsh"
11562 local testdir=$DIR/$tdir/stats_testdir
11564 test_mkdir -p $testdir
11566 # verify obdfilter stats.
11567 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
11569 cancel_lru_locks osc
11570 wait_delete_completed
11573 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
11574 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
11576 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
11579 cancel_lru_locks osc
11580 check_stats ost1 "write" 1
11582 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
11583 check_stats ost1 "read" 1
11585 > $testdir/$tfile || error "truncate failed"
11586 check_stats ost1 "punch" 1
11588 rm -f $testdir/$tfile || error "file remove failed"
11589 wait_delete_completed
11590 check_stats ost1 "destroy" 1
11594 run_test 133c "Verifying OST stats ========================================"
11601 while [ $value -ge 2 ]; do
11606 if [ $orig -gt $order ]; then
11614 local size=('K' 'M' 'G' 'T');
11616 local size_string=$value
11618 while [ $value -ge 1024 ]; do
11619 if [ $i -gt 3 ]; then
11620 #T is the biggest unit we get here, if that is bigger,
11622 size_string=${value}T
11625 value=$((value >> 10))
11626 if [ $value -lt 1024 ]; then
11627 size_string=${value}${size[$i]}
11636 get_rename_size() {
11638 local context=${2:-.}
11639 local sample=$(do_facet $SINGLEMDS $LCTL \
11640 get_param mdt.$FSNAME-MDT0000.rename_stats |
11641 grep -A1 $context |
11642 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11647 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11648 remote_ost_nodsh && skip "remote OST with nodsh"
11649 remote_mds_nodsh && skip "remote MDS with nodsh"
11650 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11651 skip_env "MDS doesn't support rename stats"
11653 local testdir1=$DIR/${tdir}/stats_testdir1
11654 local testdir2=$DIR/${tdir}/stats_testdir2
11655 mkdir -p $DIR/${tdir}
11657 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11659 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11660 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11662 createmany -o $testdir1/test 512 || error "createmany failed"
11664 # check samedir rename size
11665 mv ${testdir1}/test0 ${testdir1}/test_0
11667 local testdir1_size=$(ls -l $DIR/${tdir} |
11668 awk '/stats_testdir1/ {print $5}')
11669 local testdir2_size=$(ls -l $DIR/${tdir} |
11670 awk '/stats_testdir2/ {print $5}')
11672 testdir1_size=$(order_2 $testdir1_size)
11673 testdir2_size=$(order_2 $testdir2_size)
11675 testdir1_size=$(size_in_KMGT $testdir1_size)
11676 testdir2_size=$(size_in_KMGT $testdir2_size)
11678 echo "source rename dir size: ${testdir1_size}"
11679 echo "target rename dir size: ${testdir2_size}"
11681 local cmd="do_facet $SINGLEMDS $LCTL "
11682 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11684 eval $cmd || error "$cmd failed"
11685 local samedir=$($cmd | grep 'same_dir')
11686 local same_sample=$(get_rename_size $testdir1_size)
11687 [ -z "$samedir" ] && error "samedir_rename_size count error"
11688 [[ $same_sample -eq 1 ]] ||
11689 error "samedir_rename_size error $same_sample"
11690 echo "Check same dir rename stats success"
11692 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11694 # check crossdir rename size
11695 mv ${testdir1}/test_0 ${testdir2}/test_0
11697 testdir1_size=$(ls -l $DIR/${tdir} |
11698 awk '/stats_testdir1/ {print $5}')
11699 testdir2_size=$(ls -l $DIR/${tdir} |
11700 awk '/stats_testdir2/ {print $5}')
11702 testdir1_size=$(order_2 $testdir1_size)
11703 testdir2_size=$(order_2 $testdir2_size)
11705 testdir1_size=$(size_in_KMGT $testdir1_size)
11706 testdir2_size=$(size_in_KMGT $testdir2_size)
11708 echo "source rename dir size: ${testdir1_size}"
11709 echo "target rename dir size: ${testdir2_size}"
11711 eval $cmd || error "$cmd failed"
11712 local crossdir=$($cmd | grep 'crossdir')
11713 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11714 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11715 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11716 [[ $src_sample -eq 1 ]] ||
11717 error "crossdir_rename_size error $src_sample"
11718 [[ $tgt_sample -eq 1 ]] ||
11719 error "crossdir_rename_size error $tgt_sample"
11720 echo "Check cross dir rename stats success"
11721 rm -rf $DIR/${tdir}
11723 run_test 133d "Verifying rename_stats ========================================"
11726 remote_mds_nodsh && skip "remote MDS with nodsh"
11727 remote_ost_nodsh && skip "remote OST with nodsh"
11728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11730 local testdir=$DIR/${tdir}/stats_testdir
11731 local ctr f0 f1 bs=32768 count=42 sum
11733 mkdir -p ${testdir} || error "mkdir failed"
11735 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
11737 for ctr in {write,read}_bytes; do
11739 cancel_lru_locks osc
11741 do_facet ost1 $LCTL set_param -n \
11742 "obdfilter.*.exports.clear=clear"
11744 if [ $ctr = write_bytes ]; then
11746 f1=${testdir}/${tfile}
11748 f0=${testdir}/${tfile}
11752 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11755 cancel_lru_locks osc
11757 sum=$(do_facet ost1 $LCTL get_param \
11758 "obdfilter.*.exports.*.stats" |
11759 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11760 $1 == ctr { sum += $7 }
11761 END { printf("%0.0f", sum) }')
11763 if ((sum != bs * count)); then
11764 error "Bad $ctr sum, expected $((bs * count)), got $sum"
11768 rm -rf $DIR/${tdir}
11770 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
11772 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
11774 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
11775 # not honor the -ignore_readdir_race option correctly. So we call
11776 # error_ignore() rather than error() in these cases. See LU-11152.
11778 if (find --version; do_facet mds1 find --version) |
11779 grep -q '\b4\.5\.1[1-4]\b'; then
11780 error_ignore LU-11152 "$@"
11787 # First without trusting modes.
11788 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
11789 echo "proc_dirs='$proc_dirs'"
11790 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
11791 find $proc_dirs -exec cat '{}' \; &> /dev/null
11793 # Second verifying readability.
11794 $LCTL get_param -R '*' &> /dev/null
11796 # Verifing writability with badarea_io.
11798 -ignore_readdir_race \
11800 -not -name force_lbug \
11801 -not -name changelog_mask \
11802 -exec badarea_io '{}' \; ||
11803 error_133 "find $proc_dirs failed"
11805 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
11808 remote_mds_nodsh && skip "remote MDS with nodsh"
11809 remote_ost_nodsh && skip "remote OST with nodsh"
11811 # eventually, this can also be replaced with "lctl get_param -R",
11812 # but not until that option is always available on the server
11814 for facet in mds1 ost1; do
11815 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
11816 skip_noexit "Too old lustre on $facet"
11817 local facet_proc_dirs=$(do_facet $facet \
11818 \\\ls -d $proc_regexp 2>/dev/null)
11819 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11820 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11821 do_facet $facet find $facet_proc_dirs \
11822 ! -name req_history \
11823 -exec cat '{}' \\\; &> /dev/null
11825 do_facet $facet find $facet_proc_dirs \
11826 ! -name req_history \
11828 -exec cat '{}' \\\; &> /dev/null ||
11829 error "proc file read failed"
11831 do_facet $facet find $facet_proc_dirs \
11832 -ignore_readdir_race \
11834 -not -name force_lbug \
11835 -not -name changelog_mask \
11836 -exec badarea_io '{}' \\\; ||
11837 error_133 "$facet find $facet_proc_dirs failed"
11840 # remount the FS in case writes/reads /proc break the FS
11841 cleanup || error "failed to unmount"
11842 setup || error "failed to setup"
11845 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
11848 remote_mds_nodsh && skip "remote MDS with nodsh"
11849 remote_ost_nodsh && skip "remote OST with nodsh"
11850 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
11851 skip "Need MDS version at least 2.9.54"
11855 for facet in client mds1 ost1; do
11856 local facet_proc_dirs=$(do_facet $facet \
11857 \\\ls -d $proc_regexp 2> /dev/null)
11858 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11859 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11860 # Get the list of files that are missing the terminating newline
11861 local missing=($(do_facet $facet \
11862 find ${facet_proc_dirs} -type f \| \
11863 while read F\; do \
11864 awk -v FS='\v' -v RS='\v\v' \
11865 "'END { if(NR>0 && \
11866 \\\$NF !~ /.*\\\n\$/) \
11867 print FILENAME}'" \
11870 [ ${#missing[*]} -eq 0 ] ||
11871 error "files do not end with newline: ${missing[*]}"
11874 run_test 133h "Proc files should end with newlines"
11877 remote_mds_nodsh && skip "remote MDS with nodsh"
11878 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11879 skip "Need MDS version at least 2.7.54"
11881 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11882 cancel_lru_locks mdc
11884 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11885 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11886 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11889 createmany -o $DIR/$tdir/f $nr ||
11890 error "failed to create $nr files in $DIR/$tdir"
11891 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11893 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11894 do_facet mds1 $LCTL set_param fail_loc=0x327
11895 do_facet mds1 $LCTL set_param fail_val=500
11898 echo "sleep 10 seconds ..."
11900 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11902 do_facet mds1 $LCTL set_param fail_loc=0
11903 do_facet mds1 $LCTL set_param fail_val=0
11904 [ $lck_cnt -lt $unused ] ||
11905 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11908 unlinkmany $DIR/$tdir/f $nr
11910 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11913 remote_mds_nodsh && skip "remote MDS with nodsh"
11914 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11915 skip "Need MDS version at least 2.7.54"
11917 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11918 cancel_lru_locks mdc
11920 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11921 ldlm.lock_reclaim_threshold_mb)
11922 # disable reclaim temporarily
11923 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11925 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11926 do_facet mds1 $LCTL set_param fail_loc=0x328
11927 do_facet mds1 $LCTL set_param fail_val=500
11929 $LCTL set_param debug=+trace
11932 createmany -o $DIR/$tdir/f $nr &
11933 local create_pid=$!
11935 echo "Sleep $TIMEOUT seconds ..."
11937 if ! ps -p $create_pid > /dev/null 2>&1; then
11938 do_facet mds1 $LCTL set_param fail_loc=0
11939 do_facet mds1 $LCTL set_param fail_val=0
11940 do_facet mds1 $LCTL set_param \
11941 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11942 error "createmany finished incorrectly!"
11944 do_facet mds1 $LCTL set_param fail_loc=0
11945 do_facet mds1 $LCTL set_param fail_val=0
11946 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11947 wait $create_pid || return 1
11949 unlinkmany $DIR/$tdir/f $nr
11951 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11953 test_140() { #bug-17379
11954 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11956 test_mkdir $DIR/$tdir
11957 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11958 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11960 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11961 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11963 while i=$((i + 1)); do
11965 cd $i || error "Changing to $i"
11966 ln -s ../stat stat || error "Creating stat symlink"
11967 # Read the symlink until ELOOP present,
11968 # not LBUGing the system is considered success,
11969 # we didn't overrun the stack.
11970 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11971 if [ $ret -ne 0 ]; then
11972 if [ $ret -eq 40 ]; then
11975 error "Open stat symlink"
11981 echo "The symlink depth = $i"
11982 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
11983 error "Invalid symlink depth"
11985 # Test recursive symlink
11986 ln -s symlink_self symlink_self
11987 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11988 echo "open symlink_self returns $ret"
11989 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11991 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11994 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11996 local TF="$TMP/$tfile"
11998 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12000 cancel_lru_locks $OSC
12001 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
12002 remount_client $MOUNT
12004 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
12007 $TRUNCATE $DIR/$tfile 6000
12008 cancel_lru_locks $OSC
12009 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
12012 echo "12345" >>$DIR/$tfile
12013 cancel_lru_locks $OSC
12014 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
12017 echo "12345" >>$DIR/$tfile
12018 cancel_lru_locks $OSC
12019 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
12024 run_test 150 "truncate/append tests"
12026 #LU-2902 roc_hit was not able to read all values from lproc
12027 function roc_hit_init() {
12028 local list=$(comma_list $(osts_nodes))
12029 local dir=$DIR/$tdir-check
12030 local file=$dir/$tfile
12036 #use setstripe to do a write to every ost
12037 for i in $(seq 0 $((OSTCOUNT-1))); do
12038 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
12039 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
12040 idx=$(printf %04x $i)
12041 BEFORE=$(get_osd_param $list *OST*$idx stats |
12042 awk '$1 == "cache_access" {sum += $7}
12043 END { printf("%0.0f", sum) }')
12045 cancel_lru_locks osc
12046 cat $file >/dev/null
12048 AFTER=$(get_osd_param $list *OST*$idx stats |
12049 awk '$1 == "cache_access" {sum += $7}
12050 END { printf("%0.0f", sum) }')
12052 echo BEFORE:$BEFORE AFTER:$AFTER
12053 if ! let "AFTER - BEFORE == 4"; then
12055 error "roc_hit is not safe to use"
12063 function roc_hit() {
12064 local list=$(comma_list $(osts_nodes))
12065 echo $(get_osd_param $list '' stats |
12066 awk '$1 == "cache_hit" {sum += $7}
12067 END { printf("%0.0f", sum) }')
12070 function set_cache() {
12073 if [ "$2" == "off" ]; then
12076 local list=$(comma_list $(osts_nodes))
12077 set_osd_param $list '' $1_cache_enable $on
12079 cancel_lru_locks osc
12083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12084 remote_ost_nodsh && skip "remote OST with nodsh"
12087 local list=$(comma_list $(osts_nodes))
12089 # check whether obdfilter is cache capable at all
12090 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
12091 skip "not cache-capable obdfilter"
12094 # check cache is enabled on all obdfilters
12095 if get_osd_param $list '' read_cache_enable | grep 0; then
12096 skip "oss cache is disabled"
12099 set_osd_param $list '' writethrough_cache_enable 1
12101 # check write cache is enabled on all obdfilters
12102 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
12103 skip "oss write cache is NOT enabled"
12108 #define OBD_FAIL_OBD_NO_LRU 0x609
12109 do_nodes $list $LCTL set_param fail_loc=0x609
12111 # pages should be in the case right after write
12112 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
12115 local BEFORE=$(roc_hit)
12116 cancel_lru_locks osc
12117 cat $DIR/$tfile >/dev/null
12118 local AFTER=$(roc_hit)
12120 do_nodes $list $LCTL set_param fail_loc=0
12122 if ! let "AFTER - BEFORE == CPAGES"; then
12123 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12126 # the following read invalidates the cache
12127 cancel_lru_locks osc
12128 set_osd_param $list '' read_cache_enable 0
12129 cat $DIR/$tfile >/dev/null
12131 # now data shouldn't be found in the cache
12133 cancel_lru_locks osc
12134 cat $DIR/$tfile >/dev/null
12136 if let "AFTER - BEFORE != 0"; then
12137 error "IN CACHE: before: $BEFORE, after: $AFTER"
12140 set_osd_param $list '' read_cache_enable 1
12143 run_test 151 "test cache on oss and controls ==============================="
12146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12148 local TF="$TMP/$tfile"
12150 # simulate ENOMEM during write
12151 #define OBD_FAIL_OST_NOMEM 0x226
12152 lctl set_param fail_loc=0x80000226
12153 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
12155 sync || error "sync failed"
12156 lctl set_param fail_loc=0
12158 # discard client's cache
12159 cancel_lru_locks osc
12161 # simulate ENOMEM during read
12162 lctl set_param fail_loc=0x80000226
12163 cmp $TF $DIR/$tfile || error "cmp failed"
12164 lctl set_param fail_loc=0
12168 run_test 152 "test read/write with enomem ============================"
12171 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
12173 run_test 153 "test if fdatasync does not crash ======================="
12175 dot_lustre_fid_permission_check() {
12177 local ffid=$MOUNT/.lustre/fid/$fid
12180 echo "stat fid $fid"
12181 stat $ffid > /dev/null || error "stat $ffid failed."
12182 echo "touch fid $fid"
12183 touch $ffid || error "touch $ffid failed."
12184 echo "write to fid $fid"
12185 cat /etc/hosts > $ffid || error "write $ffid failed."
12186 echo "read fid $fid"
12187 diff /etc/hosts $ffid || error "read $ffid failed."
12188 echo "append write to fid $fid"
12189 cat /etc/hosts >> $ffid || error "append write $ffid failed."
12190 echo "rename fid $fid"
12191 mv $ffid $test_dir/$tfile.1 &&
12192 error "rename $ffid to $tfile.1 should fail."
12193 touch $test_dir/$tfile.1
12194 mv $test_dir/$tfile.1 $ffid &&
12195 error "rename $tfile.1 to $ffid should fail."
12196 rm -f $test_dir/$tfile.1
12197 echo "truncate fid $fid"
12198 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
12199 echo "link fid $fid"
12200 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
12201 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
12202 echo "setfacl fid $fid"
12203 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
12204 echo "getfacl fid $fid"
12205 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
12207 echo "unlink fid $fid"
12208 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
12209 echo "mknod fid $fid"
12210 mknod $ffid c 1 3 && error "mknod $ffid should fail."
12212 fid=[0xf00000400:0x1:0x0]
12213 ffid=$MOUNT/.lustre/fid/$fid
12215 echo "stat non-exist fid $fid"
12216 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
12217 echo "write to non-exist fid $fid"
12218 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
12219 echo "link new fid $fid"
12220 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
12222 mkdir -p $test_dir/$tdir
12223 touch $test_dir/$tdir/$tfile
12224 fid=$($LFS path2fid $test_dir/$tdir)
12227 error "error: could not get fid for $test_dir/$dir/$tfile."
12229 ffid=$MOUNT/.lustre/fid/$fid
12232 ls $ffid > /dev/null || error "ls $ffid failed."
12233 echo "touch $fid/$tfile.1"
12234 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
12236 echo "touch $MOUNT/.lustre/fid/$tfile"
12237 touch $MOUNT/.lustre/fid/$tfile && \
12238 error "touch $MOUNT/.lustre/fid/$tfile should fail."
12240 echo "setxattr to $MOUNT/.lustre/fid"
12241 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
12243 echo "listxattr for $MOUNT/.lustre/fid"
12244 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
12246 echo "delxattr from $MOUNT/.lustre/fid"
12247 setfattr -x trusted.name1 $MOUNT/.lustre/fid
12249 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
12250 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
12251 error "touch invalid fid should fail."
12253 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
12254 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
12255 error "touch non-normal fid should fail."
12257 echo "rename $tdir to $MOUNT/.lustre/fid"
12258 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
12259 error "rename to $MOUNT/.lustre/fid should fail."
12261 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
12263 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
12264 local new_obf_mode=777
12266 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
12267 chmod $new_obf_mode $DIR/.lustre/fid ||
12268 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
12270 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
12271 [ $obf_mode -eq $new_obf_mode ] ||
12272 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
12274 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
12275 chmod $old_obf_mode $DIR/.lustre/fid ||
12276 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
12279 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
12280 fid=$($LFS path2fid $test_dir/$tfile-2)
12282 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
12284 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
12285 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
12286 error "create lov data thru .lustre failed"
12288 echo "cp /etc/passwd $test_dir/$tfile-2"
12289 cp /etc/passwd $test_dir/$tfile-2 ||
12290 error "copy to $test_dir/$tfile-2 failed."
12291 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
12292 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
12293 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
12295 rm -rf $test_dir/tfile.lnk
12296 rm -rf $test_dir/$tfile-2
12300 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12301 skip "Need MDS version at least 2.4.1"
12303 local tf=$DIR/$tfile
12306 local fid=$($LFS path2fid $tf)
12307 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
12309 # check that we get the same pathname back
12310 local found=$($LFS fid2path $MOUNT "$fid")
12311 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
12312 [ "$found" == "$tf" ] ||
12313 error "fid2path($fid=path2fid($tf)) = $found != $tf"
12315 run_test 154A "lfs path2fid and fid2path basic checks"
12318 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12319 skip "Need MDS version at least 2.4.1"
12321 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
12322 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
12323 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
12324 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
12326 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
12327 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
12329 # check that we get the same pathname
12330 echo "PFID: $PFID, name: $name"
12331 local FOUND=$($LFS fid2path $MOUNT "$PFID")
12332 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
12333 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
12334 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
12336 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
12338 run_test 154B "verify the ll_decode_linkea tool"
12341 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12342 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12343 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12344 skip "Need MDS version at least 2.2.51"
12345 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
12347 cp /etc/hosts $DIR/$tfile
12349 fid=$($LFS path2fid $DIR/$tfile)
12351 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
12353 dot_lustre_fid_permission_check "$fid" $DIR ||
12354 error "dot lustre permission check $fid failed"
12356 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
12358 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
12360 touch $MOUNT/.lustre/file &&
12361 error "creation is not allowed under .lustre"
12363 mkdir $MOUNT/.lustre/dir &&
12364 error "mkdir is not allowed under .lustre"
12368 run_test 154a "Open-by-FID"
12371 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12372 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12373 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12374 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
12375 skip "Need MDS version at least 2.2.51"
12377 local remote_dir=$DIR/$tdir/remote_dir
12381 mkdir -p $DIR/$tdir
12382 $LFS mkdir -i $MDTIDX $remote_dir ||
12383 error "create remote directory failed"
12385 cp /etc/hosts $remote_dir/$tfile
12387 fid=$($LFS path2fid $remote_dir/$tfile)
12389 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
12391 dot_lustre_fid_permission_check "$fid" $remote_dir ||
12392 error "dot lustre permission check $fid failed"
12395 run_test 154b "Open-by-FID for remote directory"
12398 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
12399 skip "Need MDS version at least 2.4.1"
12401 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
12402 local FID1=$($LFS path2fid $DIR/$tfile.1)
12403 local FID2=$($LFS path2fid $DIR/$tfile.2)
12404 local FID3=$($LFS path2fid $DIR/$tfile.3)
12407 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
12408 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
12409 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
12411 [ "$FID" = "${!want}" ] ||
12412 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
12416 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
12418 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
12419 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
12423 run_test 154c "lfs path2fid and fid2path multiple arguments"
12426 remote_mds_nodsh && skip "remote MDS with nodsh"
12427 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
12428 skip "Need MDS version at least 2.5.53"
12430 if remote_mds; then
12431 nid=$($LCTL list_nids | sed "s/\./\\\./g")
12435 local proc_ofile="mdt.*.exports.'$nid'.open_files"
12442 local fid=$($LFS path2fid $DIR/$tfile)
12445 cmd="exec $fd<$DIR/$tfile"
12447 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
12448 echo "$fid_list" | grep "$fid"
12451 cmd="exec $fd>/dev/null"
12453 if [ $rc -ne 0 ]; then
12454 error "FID $fid not found in open files list $fid_list"
12457 run_test 154d "Verify open file fid"
12461 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
12462 skip "Need MDS version at least 2.6.50"
12464 if ls -a $MOUNT | grep -q '^\.lustre$'; then
12465 error ".lustre returned by readdir"
12468 run_test 154e ".lustre is not returned by readdir"
12471 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12473 # create parent directory on a single MDT to avoid cross-MDT hardlinks
12474 test_mkdir -p -c1 $DIR/$tdir/d
12475 # test dirs inherit from its stripe
12476 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
12477 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
12478 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
12479 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
12482 # get fid of parents
12483 local FID0=$($LFS path2fid $DIR/$tdir/d)
12484 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
12485 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
12486 local FID3=$($LFS path2fid $DIR)
12488 # check that path2fid --parents returns expected <parent_fid>/name
12489 # 1) test for a directory (single parent)
12490 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
12491 [ "$parent" == "$FID0/foo1" ] ||
12492 error "expected parent: $FID0/foo1, got: $parent"
12494 # 2) test for a file with nlink > 1 (multiple parents)
12495 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
12496 echo "$parent" | grep -F "$FID1/$tfile" ||
12497 error "$FID1/$tfile not returned in parent list"
12498 echo "$parent" | grep -F "$FID2/link" ||
12499 error "$FID2/link not returned in parent list"
12501 # 3) get parent by fid
12502 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
12503 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12504 echo "$parent" | grep -F "$FID1/$tfile" ||
12505 error "$FID1/$tfile not returned in parent list (by fid)"
12506 echo "$parent" | grep -F "$FID2/link" ||
12507 error "$FID2/link not returned in parent list (by fid)"
12509 # 4) test for entry in root directory
12510 parent=$($LFS path2fid --parents $DIR/f)
12511 echo "$parent" | grep -F "$FID3/f" ||
12512 error "$FID3/f not returned in parent list"
12514 # 5) test it on root directory
12515 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
12516 error "$MOUNT should not have parents"
12518 # enable xattr caching and check that linkea is correctly updated
12519 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
12520 save_lustre_params client "llite.*.xattr_cache" > $save
12521 lctl set_param llite.*.xattr_cache 1
12523 # 6.1) linkea update on rename
12524 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
12526 # get parents by fid
12527 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12528 # foo1 should no longer be returned in parent list
12529 echo "$parent" | grep -F "$FID1" &&
12530 error "$FID1 should no longer be in parent list"
12531 # the new path should appear
12532 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
12533 error "$FID2/$tfile.moved is not in parent list"
12535 # 6.2) linkea update on unlink
12536 rm -f $DIR/$tdir/d/foo2/link
12537 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
12538 # foo2/link should no longer be returned in parent list
12539 echo "$parent" | grep -F "$FID2/link" &&
12540 error "$FID2/link should no longer be in parent list"
12544 restore_lustre_params < $save
12547 run_test 154f "get parent fids by reading link ea"
12551 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
12552 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
12553 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
12554 skip "Need MDS version at least 2.6.92"
12556 mkdir -p $DIR/$tdir
12557 llapi_fid_test -d $DIR/$tdir
12559 run_test 154g "various llapi FID tests"
12561 test_155_small_load() {
12562 local temp=$TMP/$tfile
12563 local file=$DIR/$tfile
12565 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
12566 error "dd of=$temp bs=6096 count=1 failed"
12568 cancel_lru_locks $OSC
12569 cmp $temp $file || error "$temp $file differ"
12571 $TRUNCATE $temp 6000
12572 $TRUNCATE $file 6000
12573 cmp $temp $file || error "$temp $file differ (truncate1)"
12575 echo "12345" >>$temp
12576 echo "12345" >>$file
12577 cmp $temp $file || error "$temp $file differ (append1)"
12579 echo "12345" >>$temp
12580 echo "12345" >>$file
12581 cmp $temp $file || error "$temp $file differ (append2)"
12587 test_155_big_load() {
12588 remote_ost_nodsh && skip "remote OST with nodsh"
12590 local temp=$TMP/$tfile
12591 local file=$DIR/$tfile
12594 local cache_size=$(do_facet ost$((MAXI+1)) \
12595 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
12596 local large_file_size=$((cache_size * 2))
12598 echo "OSS cache size: $cache_size KB"
12599 echo "Large file size: $large_file_size KB"
12601 [ $MAXV -le $large_file_size ] &&
12602 skip_env "max available OST size needs > $large_file_size KB"
12604 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
12606 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12607 error "dd of=$temp bs=$large_file_size count=1k failed"
12610 cancel_lru_locks osc
12611 cmp $temp $file || error "$temp $file differ"
12617 save_writethrough() {
12618 local facets=$(get_facets OST)
12620 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12626 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12628 save_writethrough $p
12631 set_cache writethrough on
12632 test_155_small_load
12633 restore_lustre_params < $p
12636 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12639 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12641 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12643 save_writethrough $p
12646 set_cache writethrough off
12647 test_155_small_load
12648 restore_lustre_params < $p
12651 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12654 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12656 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12658 save_writethrough $p
12661 set_cache writethrough on
12662 test_155_small_load
12663 restore_lustre_params < $p
12666 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12671 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12673 save_writethrough $p
12676 set_cache writethrough off
12677 test_155_small_load
12678 restore_lustre_params < $p
12681 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12684 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12686 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12688 save_writethrough $p
12691 set_cache writethrough on
12693 restore_lustre_params < $p
12696 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12699 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12701 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12703 save_writethrough $p
12706 set_cache writethrough off
12708 restore_lustre_params < $p
12711 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12716 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12718 save_writethrough $p
12721 set_cache writethrough on
12723 restore_lustre_params < $p
12726 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12729 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12731 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12733 save_writethrough $p
12736 set_cache writethrough off
12738 restore_lustre_params < $p
12741 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12745 remote_ost_nodsh && skip "remote OST with nodsh"
12746 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12747 skip "stats not implemented on old servers"
12748 [ "$ost1_FSTYPE" = "zfs" ] &&
12749 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12754 local file="$DIR/$tfile"
12755 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12757 save_writethrough $p
12760 log "Turn on read and write cache"
12762 set_cache writethrough on
12764 log "Write data and read it back."
12765 log "Read should be satisfied from the cache."
12766 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12768 cancel_lru_locks osc
12769 cat $file >/dev/null
12771 if ! let "AFTER - BEFORE == CPAGES"; then
12772 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12774 log "cache hits:: before: $BEFORE, after: $AFTER"
12777 log "Read again; it should be satisfied from the cache."
12779 cancel_lru_locks osc
12780 cat $file >/dev/null
12782 if ! let "AFTER - BEFORE == CPAGES"; then
12783 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12785 log "cache hits:: before: $BEFORE, after: $AFTER"
12788 log "Turn off the read cache and turn on the write cache"
12790 set_cache writethrough on
12792 log "Read again; it should be satisfied from the cache."
12794 cancel_lru_locks osc
12795 cat $file >/dev/null
12797 if ! let "AFTER - BEFORE == CPAGES"; then
12798 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12800 log "cache hits:: before: $BEFORE, after: $AFTER"
12803 log "Read again; it should not be satisfied from the cache."
12805 cancel_lru_locks osc
12806 cat $file >/dev/null
12808 if ! let "AFTER - BEFORE == 0"; then
12809 error "IN CACHE: before: $BEFORE, after: $AFTER"
12811 log "cache hits:: before: $BEFORE, after: $AFTER"
12814 log "Write data and read it back."
12815 log "Read should be satisfied from the cache."
12816 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12818 cancel_lru_locks osc
12819 cat $file >/dev/null
12821 if ! let "AFTER - BEFORE == CPAGES"; then
12822 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12824 log "cache hits:: before: $BEFORE, after: $AFTER"
12827 log "Read again; it should not be satisfied from the cache."
12829 cancel_lru_locks osc
12830 cat $file >/dev/null
12832 if ! let "AFTER - BEFORE == 0"; then
12833 error "IN CACHE: before: $BEFORE, after: $AFTER"
12835 log "cache hits:: before: $BEFORE, after: $AFTER"
12838 log "Turn off read and write cache"
12840 set_cache writethrough off
12842 log "Write data and read it back"
12843 log "It should not be satisfied from the cache."
12845 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12846 cancel_lru_locks osc
12848 cat $file >/dev/null
12850 if ! let "AFTER - BEFORE == 0"; then
12851 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12853 log "cache hits:: before: $BEFORE, after: $AFTER"
12856 log "Turn on the read cache and turn off the write cache"
12858 set_cache writethrough off
12860 log "Write data and read it back"
12861 log "It should not be satisfied from the cache."
12863 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12865 cancel_lru_locks osc
12866 cat $file >/dev/null
12868 if ! let "AFTER - BEFORE == 0"; then
12869 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12871 log "cache hits:: before: $BEFORE, after: $AFTER"
12874 log "Read again; it should be satisfied from the cache."
12876 cancel_lru_locks osc
12877 cat $file >/dev/null
12879 if ! let "AFTER - BEFORE == CPAGES"; then
12880 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12882 log "cache hits:: before: $BEFORE, after: $AFTER"
12885 restore_lustre_params < $p
12888 run_test 156 "Verification of tunables"
12891 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12892 remote_mds_nodsh && skip "remote MDS with nodsh"
12893 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12894 skip "Need MDS version at least 2.2.0"
12896 changelog_register || error "changelog_register failed"
12897 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12898 changelog_users $SINGLEMDS | grep -q $cl_user ||
12899 error "User $cl_user not found in changelog_users"
12902 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12903 changelog_clear 0 || error "changelog_clear failed"
12904 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12905 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12906 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12907 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12908 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12909 rm $DIR/$tdir/pics/desktop.jpg
12911 changelog_dump | tail -10
12913 echo "verifying changelog mask"
12914 changelog_chmask "-MKDIR"
12915 changelog_chmask "-CLOSE"
12917 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12918 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12920 changelog_chmask "+MKDIR"
12921 changelog_chmask "+CLOSE"
12923 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12924 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12926 changelog_dump | tail -10
12927 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12928 CLOSES=$(changelog_dump | grep -c "CLOSE")
12929 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12930 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12933 echo "verifying target fid"
12934 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12935 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12936 [ "$fidc" == "$fidf" ] ||
12937 error "changelog '$tfile' fid $fidc != file fid $fidf"
12938 echo "verifying parent fid"
12939 # The FID returned from the Changelog may be the directory shard on
12940 # a different MDT, and not the FID returned by path2fid on the parent.
12941 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12942 # since this is what will matter when recreating this file in the tree.
12943 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12944 local pathp=$($LFS fid2path $MOUNT "$fidp")
12945 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12946 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12948 echo "getting records for $cl_user"
12949 changelog_users $SINGLEMDS
12950 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12952 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12953 error "changelog_clear failed"
12954 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12955 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12956 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12957 error "user index expect $user_rec1 + $nclr != $user_rec2"
12959 local min0_rec=$(changelog_users $SINGLEMDS |
12960 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12961 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12962 awk '{ print $1; exit; }')
12964 changelog_dump | tail -n 5
12965 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12966 [ $first_rec == $((min0_rec + 1)) ] ||
12967 error "first index should be $min0_rec + 1 not $first_rec"
12969 # LU-3446 changelog index reset on MDT restart
12970 local cur_rec1=$(changelog_users $SINGLEMDS |
12971 awk '/^current.index:/ { print $NF }')
12972 changelog_clear 0 ||
12973 error "clear all changelog records for $cl_user failed"
12974 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12975 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12976 error "Fail to start $SINGLEMDS"
12977 local cur_rec2=$(changelog_users $SINGLEMDS |
12978 awk '/^current.index:/ { print $NF }')
12979 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12980 [ $cur_rec1 == $cur_rec2 ] ||
12981 error "current index should be $cur_rec1 not $cur_rec2"
12983 echo "verifying users from this test are deregistered"
12984 changelog_deregister || error "changelog_deregister failed"
12985 changelog_users $SINGLEMDS | grep -q $cl_user &&
12986 error "User '$cl_user' still in changelog_users"
12988 # lctl get_param -n mdd.*.changelog_users
12989 # current index: 144
12990 # ID index (idle seconds)
12992 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12993 # this is the normal case where all users were deregistered
12994 # make sure no new records are added when no users are present
12995 local last_rec1=$(changelog_users $SINGLEMDS |
12996 awk '/^current.index:/ { print $NF }')
12997 touch $DIR/$tdir/chloe
12998 local last_rec2=$(changelog_users $SINGLEMDS |
12999 awk '/^current.index:/ { print $NF }')
13000 echo "verify changelogs are off: $last_rec1 == $last_rec2"
13001 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
13003 # any changelog users must be leftovers from a previous test
13004 changelog_users $SINGLEMDS
13005 echo "other changelog users; can't verify off"
13008 run_test 160a "changelog sanity"
13010 test_160b() { # LU-3587
13011 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13012 remote_mds_nodsh && skip "remote MDS with nodsh"
13013 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
13014 skip "Need MDS version at least 2.2.0"
13016 changelog_register || error "changelog_register failed"
13017 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13018 changelog_users $SINGLEMDS | grep -q $cl_user ||
13019 error "User '$cl_user' not found in changelog_users"
13021 local longname1=$(str_repeat a 255)
13022 local longname2=$(str_repeat b 255)
13025 echo "creating very long named file"
13026 touch $longname1 || error "create of '$longname1' failed"
13027 echo "renaming very long named file"
13028 mv $longname1 $longname2
13030 changelog_dump | grep RENME | tail -n 5
13033 run_test 160b "Verify that very long rename doesn't crash in changelog"
13036 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13037 remote_mds_nodsh && skip "remote MDS with nodsh"
13039 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
13040 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
13041 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
13042 skip "Need MDS version at least 2.5.58 or 2.5.2+"
13046 # Registration step
13047 changelog_register || error "changelog_register failed"
13050 mkdir -p $DIR/$tdir
13051 $MCREATE $DIR/$tdir/foo_160c
13052 changelog_chmask "-TRUNC"
13053 $TRUNCATE $DIR/$tdir/foo_160c 200
13054 changelog_chmask "+TRUNC"
13055 $TRUNCATE $DIR/$tdir/foo_160c 199
13056 changelog_dump | tail -n 5
13057 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
13058 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
13060 run_test 160c "verify that changelog log catch the truncate event"
13063 remote_mds_nodsh && skip "remote MDS with nodsh"
13064 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13065 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13066 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
13067 skip "Need MDS version at least 2.7.60"
13069 # Registration step
13070 changelog_register || error "changelog_register failed"
13072 mkdir -p $DIR/$tdir/migrate_dir
13073 changelog_clear 0 || error "changelog_clear failed"
13075 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
13076 changelog_dump | tail -n 5
13077 local migrates=$(changelog_dump | grep -c "MIGRT")
13078 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
13080 run_test 160d "verify that changelog log catch the migrate event"
13083 remote_mds_nodsh && skip "remote MDS with nodsh"
13086 changelog_register || error "changelog_register failed"
13088 # Delete a future user (expect fail)
13089 local MDT0=$(facet_svc $SINGLEMDS)
13090 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
13093 if [ $rc -eq 0 ]; then
13094 error "Deleted non-existant user cl77"
13095 elif [ $rc -ne 2 ]; then
13096 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
13099 # Clear to a bad index (1 billion should be safe)
13100 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
13103 if [ $rc -eq 0 ]; then
13104 error "Successfully cleared to invalid CL index"
13105 elif [ $rc -ne 22 ]; then
13106 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
13109 run_test 160e "changelog negative testing (should return errors)"
13112 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13113 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13114 skip "Need MDS version at least 2.10.56"
13116 local mdts=$(comma_list $(mdts_nodes))
13119 changelog_register || error "first changelog_register failed"
13120 changelog_register || error "second changelog_register failed"
13122 declare -A cl_user1
13123 declare -A cl_user2
13128 # generate some changelog records to accumulate on each MDT
13129 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13130 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13131 error "create $DIR/$tdir/$tfile failed"
13133 # check changelogs have been generated
13134 local nbcl=$(changelog_dump | wc -l)
13135 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13137 for param in "changelog_max_idle_time=10" \
13139 "changelog_min_gc_interval=2" \
13140 "changelog_min_free_cat_entries=3"; do
13141 local MDT0=$(facet_svc $SINGLEMDS)
13142 local var="${param%=*}"
13143 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13145 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13146 do_nodes $mdts $LCTL set_param mdd.*.$param
13149 # force cl_user2 to be idle (1st part)
13152 # simulate changelog catalog almost full
13153 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13154 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13156 for i in $(seq $MDSCOUNT); do
13157 cl_users=(${CL_USERS[mds$i]})
13158 cl_user1[mds$i]="${cl_users[0]}"
13159 cl_user2[mds$i]="${cl_users[1]}"
13161 [ -n "${cl_user1[mds$i]}" ] ||
13162 error "mds$i: no user registered"
13163 [ -n "${cl_user2[mds$i]}" ] ||
13164 error "mds$i: only ${cl_user2[mds$i]} is registered"
13166 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13167 [ -n "$user_rec1" ] ||
13168 error "mds$i: User ${cl_user1[mds$i]} not registered"
13169 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13170 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13171 [ -n "$user_rec2" ] ||
13172 error "mds$i: User ${cl_user1[mds$i]} not registered"
13173 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13174 "$user_rec1 + 2 == $user_rec2"
13175 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13176 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13177 "$user_rec1 + 2, but is $user_rec2"
13178 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13179 [ -n "$user_rec2" ] ||
13180 error "mds$i: User ${cl_user2[mds$i]} not registered"
13181 [ $user_rec1 == $user_rec2 ] ||
13182 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13183 "$user_rec1, but is $user_rec2"
13186 # force cl_user2 to be idle (2nd part) and to reach
13187 # changelog_max_idle_time
13190 # generate one more changelog to trigger fail_loc
13191 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13192 error "create $DIR/$tdir/${tfile}bis failed"
13194 # ensure gc thread is done
13195 for i in $(mdts_nodes); do
13197 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13198 error "$i: GC-thread not done"
13202 for i in $(seq $MDSCOUNT); do
13203 # check cl_user1 still registered
13204 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13205 error "mds$i: User ${cl_user1[mds$i]} not registered"
13206 # check cl_user2 unregistered
13207 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13208 error "mds$i: User ${cl_user2[mds$i]} still registered"
13210 # check changelogs are present and starting at $user_rec1 + 1
13211 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13212 [ -n "$user_rec1" ] ||
13213 error "mds$i: User ${cl_user1[mds$i]} not registered"
13214 first_rec=$($LFS changelog $(facet_svc mds$i) |
13215 awk '{ print $1; exit; }')
13217 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13218 [ $((user_rec1 + 1)) == $first_rec ] ||
13219 error "mds$i: first index should be $user_rec1 + 1, " \
13220 "but is $first_rec"
13223 run_test 160f "changelog garbage collect (timestamped users)"
13226 remote_mds_nodsh && skip "remote MDS with nodsh"
13227 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13228 skip "Need MDS version at least 2.10.56"
13230 local mdts=$(comma_list $(mdts_nodes))
13232 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
13233 do_nodes $mdts $LCTL set_param fail_loc=0x1314
13236 changelog_register || error "first changelog_register failed"
13237 changelog_register || error "second changelog_register failed"
13239 declare -A cl_user1
13240 declare -A cl_user2
13245 # generate some changelog records to accumulate on each MDT
13246 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13247 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13248 error "create $DIR/$tdir/$tfile failed"
13250 # check changelogs have been generated
13251 local nbcl=$(changelog_dump | wc -l)
13252 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13254 # reduce the max_idle_indexes value to make sure we exceed it
13255 max_ndx=$((nbcl / 2 - 1))
13257 for param in "changelog_max_idle_indexes=$max_ndx" \
13259 "changelog_min_gc_interval=2" \
13260 "changelog_min_free_cat_entries=3"; do
13261 local MDT0=$(facet_svc $SINGLEMDS)
13262 local var="${param%=*}"
13263 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13265 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13266 do_nodes $mdts $LCTL set_param mdd.*.$param ||
13267 error "unable to set mdd.*.$param"
13270 # simulate changelog catalog almost full
13271 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
13272 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
13274 for i in $(seq $MDSCOUNT); do
13275 cl_users=(${CL_USERS[mds$i]})
13276 cl_user1[mds$i]="${cl_users[0]}"
13277 cl_user2[mds$i]="${cl_users[1]}"
13279 [ -n "${cl_user1[mds$i]}" ] ||
13280 error "mds$i: no user registered"
13281 [ -n "${cl_user2[mds$i]}" ] ||
13282 error "mds$i: only ${cl_user1[mds$i]} is registered"
13284 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13285 [ -n "$user_rec1" ] ||
13286 error "mds$i: User ${cl_user1[mds$i]} not registered"
13287 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13288 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13289 [ -n "$user_rec2" ] ||
13290 error "mds$i: User ${cl_user1[mds$i]} not registered"
13291 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13292 "$user_rec1 + 2 == $user_rec2"
13293 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13294 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13295 "$user_rec1 + 2, but is $user_rec2"
13296 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13297 [ -n "$user_rec2" ] ||
13298 error "mds$i: User ${cl_user2[mds$i]} not registered"
13299 [ $user_rec1 == $user_rec2 ] ||
13300 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13301 "$user_rec1, but is $user_rec2"
13304 # ensure we are past the previous changelog_min_gc_interval set above
13307 # generate one more changelog to trigger fail_loc
13308 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13309 error "create $DIR/$tdir/${tfile}bis failed"
13311 # ensure gc thread is done
13312 for i in $(mdts_nodes); do
13314 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
13315 error "$i: GC-thread not done"
13319 for i in $(seq $MDSCOUNT); do
13320 # check cl_user1 still registered
13321 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13322 error "mds$i: User ${cl_user1[mds$i]} not registered"
13323 # check cl_user2 unregistered
13324 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13325 error "mds$i: User ${cl_user2[mds$i]} still registered"
13327 # check changelogs are present and starting at $user_rec1 + 1
13328 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13329 [ -n "$user_rec1" ] ||
13330 error "mds$i: User ${cl_user1[mds$i]} not registered"
13331 first_rec=$($LFS changelog $(facet_svc mds$i) |
13332 awk '{ print $1; exit; }')
13334 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13335 [ $((user_rec1 + 1)) == $first_rec ] ||
13336 error "mds$i: first index should be $user_rec1 + 1, " \
13337 "but is $first_rec"
13340 run_test 160g "changelog garbage collect (old users)"
13343 remote_mds_nodsh && skip "remote MDS with nodsh" && return
13344 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
13345 skip "Need MDS version at least 2.10.56"
13347 local mdts=$(comma_list $(mdts_nodes))
13350 changelog_register || error "first changelog_register failed"
13351 changelog_register || error "second changelog_register failed"
13353 declare -A cl_user1
13354 declare -A cl_user2
13359 # generate some changelog records to accumulate on each MDT
13360 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
13361 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13362 error "create $DIR/$tdir/$tfile failed"
13364 # check changelogs have been generated
13365 local nbcl=$(changelog_dump | wc -l)
13366 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13368 for param in "changelog_max_idle_time=10" \
13370 "changelog_min_gc_interval=2"; do
13371 local MDT0=$(facet_svc $SINGLEMDS)
13372 local var="${param%=*}"
13373 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
13375 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
13376 do_nodes $mdts $LCTL set_param mdd.*.$param
13379 # force cl_user2 to be idle (1st part)
13382 for i in $(seq $MDSCOUNT); do
13383 cl_users=(${CL_USERS[mds$i]})
13384 cl_user1[mds$i]="${cl_users[0]}"
13385 cl_user2[mds$i]="${cl_users[1]}"
13387 [ -n "${cl_user1[mds$i]}" ] ||
13388 error "mds$i: no user registered"
13389 [ -n "${cl_user2[mds$i]}" ] ||
13390 error "mds$i: only ${cl_user2[mds$i]} is registered"
13392 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13393 [ -n "$user_rec1" ] ||
13394 error "mds$i: User ${cl_user1[mds$i]} not registered"
13395 __changelog_clear mds$i ${cl_user1[mds$i]} +2
13396 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13397 [ -n "$user_rec2" ] ||
13398 error "mds$i: User ${cl_user1[mds$i]} not registered"
13399 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
13400 "$user_rec1 + 2 == $user_rec2"
13401 [ $((user_rec1 + 2)) == $user_rec2 ] ||
13402 error "mds$i: user ${cl_user1[mds$i]} index expected " \
13403 "$user_rec1 + 2, but is $user_rec2"
13404 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
13405 [ -n "$user_rec2" ] ||
13406 error "mds$i: User ${cl_user2[mds$i]} not registered"
13407 [ $user_rec1 == $user_rec2 ] ||
13408 error "mds$i: user ${cl_user2[mds$i]} index expected " \
13409 "$user_rec1, but is $user_rec2"
13412 # force cl_user2 to be idle (2nd part) and to reach
13413 # changelog_max_idle_time
13416 # force each GC-thread start and block then
13417 # one per MDT/MDD, set fail_val accordingly
13418 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
13419 do_nodes $mdts $LCTL set_param fail_loc=0x1316
13421 # generate more changelogs to trigger fail_loc
13422 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13423 error "create $DIR/$tdir/${tfile}bis failed"
13425 # stop MDT to stop GC-thread, should be done in back-ground as it will
13426 # block waiting for the thread to be released and exit
13427 declare -A stop_pids
13428 for i in $(seq $MDSCOUNT); do
13430 stop_pids[mds$i]=$!
13433 for i in $(mdts_nodes); do
13436 local facets=$(facets_up_on_host $i)
13438 for facet in ${facets//,/ }; do
13439 if [[ $facet == mds* ]]; then
13443 # ensure each MDS's gc threads are still present and all in "R"
13444 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
13445 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
13446 error "$i: expected $nb GC-thread"
13448 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
13450 error "$i: GC-thread not found in R-state"
13451 # check umounts of each MDT on MDS have reached kthread_stop()
13452 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
13453 error "$i: expected $nb umount"
13455 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
13456 error "$i: umount not found in D-state"
13459 # release all GC-threads
13460 do_nodes $mdts $LCTL set_param fail_loc=0
13462 # wait for MDT stop to complete
13463 for i in $(seq $MDSCOUNT); do
13464 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
13468 # may try to check if any orphan changelog records are present
13469 # via ldiskfs/zfs and llog_reader...
13471 # re-start/mount MDTs
13472 for i in $(seq $MDSCOUNT); do
13473 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
13474 error "Fail to start mds$i"
13478 for i in $(seq $MDSCOUNT); do
13479 # check cl_user1 still registered
13480 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
13481 error "mds$i: User ${cl_user1[mds$i]} not registered"
13482 # check cl_user2 unregistered
13483 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
13484 error "mds$i: User ${cl_user2[mds$i]} still registered"
13486 # check changelogs are present and starting at $user_rec1 + 1
13487 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
13488 [ -n "$user_rec1" ] ||
13489 error "mds$i: User ${cl_user1[mds$i]} not registered"
13490 first_rec=$($LFS changelog $(facet_svc mds$i) |
13491 awk '{ print $1; exit; }')
13493 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
13494 [ $((user_rec1 + 1)) == $first_rec ] ||
13495 error "mds$i: first index should be $user_rec1 + 1, " \
13496 "but is $first_rec"
13499 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
13504 local mdts=$(comma_list $(mdts_nodes))
13506 changelog_register || error "first changelog_register failed"
13508 # generate some changelog records to accumulate on each MDT
13509 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13510 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
13511 error "create $DIR/$tdir/$tfile failed"
13513 # check changelogs have been generated
13514 local nbcl=$(changelog_dump | wc -l)
13515 [[ $nbcl -eq 0 ]] && error "no changelogs found"
13517 # simulate race between register and unregister
13518 # XXX as fail_loc is set per-MDS, with DNE configs the race
13519 # simulation will only occur for one MDT per MDS and for the
13520 # others the normal race scenario will take place
13521 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
13522 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
13523 do_nodes $mdts $LCTL set_param fail_val=1
13525 # unregister 1st user
13526 changelog_deregister &
13528 # wait some time for deregister work to reach race rdv
13530 # register 2nd user
13531 changelog_register || error "2nd user register failed"
13533 wait $pid1 || error "1st user deregister failed"
13537 declare -A LAST_REC
13538 for i in $(seq $MDSCOUNT); do
13539 if changelog_users mds$i | grep "^cl"; then
13540 # make sure new records are added with one user present
13541 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
13542 awk '/^current.index:/ { print $NF }')
13544 error "mds$i has no user registered"
13548 # generate more changelog records to accumulate on each MDT
13549 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13550 error "create $DIR/$tdir/${tfile}bis failed"
13552 for i in $(seq $MDSCOUNT); do
13553 last_rec=$(changelog_users $SINGLEMDS |
13554 awk '/^current.index:/ { print $NF }')
13555 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
13556 [ $last_rec != ${LAST_REC[mds$i]} ] ||
13557 error "changelogs are off on mds$i"
13560 run_test 160i "changelog user register/unregister race"
13563 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13564 remote_mds_nodsh && skip "remote MDS with nodsh"
13566 mkdir -p $DIR/$tdir/1/1
13568 changelog_register || error "changelog_register failed"
13569 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13571 changelog_users $SINGLEMDS | grep -q $cl_user ||
13572 error "User '$cl_user' not found in changelog_users"
13573 #define OBD_FAIL_MDS_CHANGELOG_REORDER 0x15d
13574 do_facet mds1 $LCTL set_param fail_loc=0x8000015d fail_val=3
13575 rmdir $DIR/$tdir/1/1 & sleep 1
13577 touch $DIR/$tdir/2/2
13578 rm -rf $DIR/$tdir/2
13583 changelog_dump | grep rmdir || error "rmdir not recorded"
13586 changelog_deregister
13588 run_test 160k "Verify that changelog records are not lost"
13591 remote_mds_nodsh && skip "remote MDS with nodsh"
13592 [[ $MDS1_VERSION -lt $(version_code 2.12.56) ]] &&
13593 skip "Need MDS version at least 2.12.56"
13595 mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
13597 changelog_register || error "first changelog_register failed"
13599 # generate some changelog
13600 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
13601 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
13602 error "create $DIR/$tdir/${tfile}bis failed"
13604 # open the changelog device
13605 exec 3>/dev/changelog-$FSNAME-MDT0000
13606 exec 4</dev/changelog-$FSNAME-MDT0000
13608 # umount the first lustre mount
13612 cat <&4 >/dev/null || error "read changelog failed"
13615 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
13616 changelog_users $SINGLEMDS | grep -q $cl_user ||
13617 error "User $cl_user not found in changelog_users"
13619 printf 'clear:'$cl_user':0' >&3
13626 changelog_deregister || error "changelog_deregister failed"
13629 mount_client $MOUNT || error "mount_client on $MOUNT failed"
13631 run_test 160j "client can be umounted while its chanangelog is being used"
13634 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13636 test_mkdir -c1 $DIR/$tdir
13637 cp /etc/hosts $DIR/$tdir/$tfile
13638 test_mkdir -c1 $DIR/$tdir/foo1
13639 test_mkdir -c1 $DIR/$tdir/foo2
13640 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
13641 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
13642 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
13643 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
13644 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
13645 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13646 $LFS fid2path $DIR $FID
13647 error "bad link ea"
13650 rm $DIR/$tdir/foo2/zachary
13652 rm $DIR/$tdir/foo2/thor
13654 rm $DIR/$tdir/$tfile
13656 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
13657 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
13658 { $LFS fid2path $DIR $FID; error "bad link rename"; }
13659 rm $DIR/$tdir/foo2/maggie
13662 local longname=$tfile.avg_len_is_thirty_two_
13663 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
13664 error_noexit 'failed to unlink many hardlinks'" EXIT
13665 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
13666 error "failed to hardlink many files"
13667 links=$($LFS fid2path $DIR $FID | wc -l)
13668 echo -n "${links}/1000 links in link EA"
13669 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13671 run_test 161a "link ea sanity"
13674 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13675 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13678 local remote_dir=$DIR/$tdir/remote_dir
13680 mkdir -p $DIR/$tdir
13681 $LFS mkdir -i $MDTIDX $remote_dir ||
13682 error "create remote directory failed"
13684 cp /etc/hosts $remote_dir/$tfile
13685 mkdir -p $remote_dir/foo1
13686 mkdir -p $remote_dir/foo2
13687 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13688 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13689 ln $remote_dir/$tfile $remote_dir/foo1/luna
13690 ln $remote_dir/$tfile $remote_dir/foo2/thor
13692 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13694 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13695 $LFS fid2path $DIR $FID
13696 error "bad link ea"
13699 rm $remote_dir/foo2/zachary
13701 rm $remote_dir/foo2/thor
13703 rm $remote_dir/$tfile
13705 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13706 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13707 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13708 $LFS fid2path $DIR $FID
13709 error "bad link rename"
13711 rm $remote_dir/foo2/maggie
13714 local longname=filename_avg_len_is_thirty_two_
13715 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13716 error "failed to hardlink many files"
13717 links=$($LFS fid2path $DIR $FID | wc -l)
13718 echo -n "${links}/1000 links in link EA"
13719 [[ ${links} -gt 60 ]] ||
13720 error "expected at least 60 links in link EA"
13721 unlinkmany $remote_dir/foo2/$longname 1000 ||
13722 error "failed to unlink many hardlinks"
13724 run_test 161b "link ea sanity under remote directory"
13727 remote_mds_nodsh && skip "remote MDS with nodsh"
13728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13729 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13730 skip "Need MDS version at least 2.1.5"
13732 # define CLF_RENAME_LAST 0x0001
13733 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13734 changelog_register || error "changelog_register failed"
13737 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13738 touch $DIR/$tdir/foo_161c
13739 touch $DIR/$tdir/bar_161c
13740 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13741 changelog_dump | grep RENME | tail -n 5
13742 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13743 changelog_clear 0 || error "changelog_clear failed"
13744 if [ x$flags != "x0x1" ]; then
13745 error "flag $flags is not 0x1"
13748 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13749 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13750 touch $DIR/$tdir/foo_161c
13751 touch $DIR/$tdir/bar_161c
13752 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13753 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13754 changelog_dump | grep RENME | tail -n 5
13755 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13756 changelog_clear 0 || error "changelog_clear failed"
13757 if [ x$flags != "x0x0" ]; then
13758 error "flag $flags is not 0x0"
13760 echo "rename overwrite a target having nlink > 1," \
13761 "changelog record has flags of $flags"
13763 # rename doesn't overwrite a target (changelog flag 0x0)
13764 touch $DIR/$tdir/foo_161c
13765 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
13766 changelog_dump | grep RENME | tail -n 5
13767 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
13768 changelog_clear 0 || error "changelog_clear failed"
13769 if [ x$flags != "x0x0" ]; then
13770 error "flag $flags is not 0x0"
13772 echo "rename doesn't overwrite a target," \
13773 "changelog record has flags of $flags"
13775 # define CLF_UNLINK_LAST 0x0001
13776 # unlink a file having nlink = 1 (changelog flag 0x1)
13777 rm -f $DIR/$tdir/foo2_161c
13778 changelog_dump | grep UNLNK | tail -n 5
13779 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13780 changelog_clear 0 || error "changelog_clear failed"
13781 if [ x$flags != "x0x1" ]; then
13782 error "flag $flags is not 0x1"
13784 echo "unlink a file having nlink = 1," \
13785 "changelog record has flags of $flags"
13787 # unlink a file having nlink > 1 (changelog flag 0x0)
13788 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13789 rm -f $DIR/$tdir/foobar_161c
13790 changelog_dump | grep UNLNK | tail -n 5
13791 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13792 changelog_clear 0 || error "changelog_clear failed"
13793 if [ x$flags != "x0x0" ]; then
13794 error "flag $flags is not 0x0"
13796 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
13798 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
13801 remote_mds_nodsh && skip "remote MDS with nodsh"
13806 changelog_register || error "changelog_register failed"
13808 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
13809 # interfer with $MOUNT/.lustre/fid/ access
13811 [[ $? -eq 0 ]] || error "mkdir failed"
13813 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
13814 $LCTL set_param fail_loc=0x8000140c
13816 $LCTL set_param fail_val=5
13819 echo foofoo > $DIR/$tdir/$tfile &
13822 # wait for create to be delayed
13826 [[ $? -eq 0 ]] || error "create should be blocked"
13828 local tempfile=$(mktemp)
13829 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
13830 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
13831 # some delay may occur during ChangeLog publishing and file read just
13832 # above, that could allow file write to happen finally
13833 [[ -s $tempfile ]] && echo "file should be empty"
13835 $LCTL set_param fail_loc=0
13838 [[ $? -eq 0 ]] || error "create failed"
13840 run_test 161d "create with concurrent .lustre/fid access"
13843 local expected="$1"
13848 path=$($LFS fid2path "$@")
13851 if [ $rc -ne 0 ]; then
13852 error "path looked up of '$expected' failed: rc=$rc"
13853 elif [ "$path" != "$expected" ]; then
13854 error "path looked up '$path' instead of '$expected'"
13856 echo "FID '$fid' resolves to path '$path' as expected"
13860 test_162a() { # was test_162
13861 test_mkdir -p -c1 $DIR/$tdir/d2
13862 touch $DIR/$tdir/d2/$tfile
13863 touch $DIR/$tdir/d2/x1
13864 touch $DIR/$tdir/d2/x2
13865 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
13866 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
13868 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
13869 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
13872 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
13873 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
13874 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
13876 # softlink to wrong file
13877 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
13878 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
13879 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
13882 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
13883 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
13884 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
13885 # fid2path dir/fsname should both work
13886 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
13887 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
13889 # hardlink count: check that there are 2 links
13890 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
13891 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
13893 # hardlink indexing: remove the first link
13894 rm $DIR/$tdir/d2/p/q/r/hlink
13895 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
13897 run_test 162a "path lookup sanity"
13900 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13901 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13904 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
13905 error "create striped dir failed"
13907 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
13908 tail -n 1 | awk '{print $2}')
13909 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
13911 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
13912 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
13915 for ((i=0;i<5;i++)); do
13916 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
13917 error "get fid for f$i failed"
13918 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
13920 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
13921 error "get fid for d$i failed"
13922 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
13927 run_test 162b "striped directory path lookup sanity"
13929 # LU-4239: Verify fid2path works with paths 100 or more directories deep
13931 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
13932 skip "Need MDS version at least 2.7.51"
13934 local lpath=$tdir.local
13935 local rpath=$tdir.remote
13937 test_mkdir $DIR/$lpath
13938 test_mkdir $DIR/$rpath
13940 for ((i = 0; i <= 101; i++)); do
13943 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
13944 error "get fid for local directory $DIR/$lpath failed"
13945 check_path "$DIR/$lpath" $MOUNT $FID --link 0
13948 test_mkdir $DIR/$rpath
13949 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
13950 error "get fid for remote directory $DIR/$rpath failed"
13951 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13956 run_test 162c "fid2path works with paths 100 or more directories deep"
13959 # do directio so as not to populate the page cache
13960 log "creating a 10 Mb file"
13961 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13962 log "starting reads"
13963 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13964 log "truncating the file"
13965 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13967 kill %+ || true # reads might have finished
13968 echo "wait until dd is finished"
13970 log "removing the temporary file"
13971 rm -rf $DIR/$tfile || error "tmp file removal failed"
13973 run_test 169 "parallel read and truncate should not deadlock"
13976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13978 $LCTL clear # bug 18514
13979 $LCTL debug_daemon start $TMP/${tfile}_log_good
13981 $LCTL debug_daemon stop
13982 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13983 error "sed failed to read log_good"
13985 $LCTL debug_daemon start $TMP/${tfile}_log_good
13987 $LCTL debug_daemon stop
13989 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13990 error "lctl df log_bad failed"
13992 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13993 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13995 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13996 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13998 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13999 error "bad_line good_line1 good_line2 are empty"
14001 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14002 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
14003 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
14005 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
14006 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
14007 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
14009 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
14010 error "bad_line_new good_line_new are empty"
14012 local expected_good=$((good_line1 + good_line2*2))
14014 rm -f $TMP/${tfile}*
14015 # LU-231, short malformed line may not be counted into bad lines
14016 if [ $bad_line -ne $bad_line_new ] &&
14017 [ $bad_line -ne $((bad_line_new - 1)) ]; then
14018 error "expected $bad_line bad lines, but got $bad_line_new"
14022 if [ $expected_good -ne $good_line_new ]; then
14023 error "expected $expected_good good lines, but got $good_line_new"
14028 run_test 170 "test lctl df to handle corrupted log ====================="
14030 test_171() { # bug20592
14031 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14033 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
14034 $LCTL set_param fail_loc=0x50e
14035 $LCTL set_param fail_val=3000
14036 multiop_bg_pause $DIR/$tfile O_s || true
14038 kill -USR1 $MULTIPID
14042 if dmesg | grep "recursive fault"; then
14043 error "caught a recursive fault"
14045 $LCTL set_param fail_loc=0
14048 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
14050 # it would be good to share it with obdfilter-survey/iokit-libecho code
14051 setup_obdecho_osc () {
14054 local obdfilter_name=$2
14055 echo "Creating new osc for $obdfilter_name on $ost_nid"
14056 # make sure we can find loopback nid
14057 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
14059 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
14060 ${obdfilter_name}_osc_UUID || rc=2; }
14061 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
14062 ${obdfilter_name}_UUID $ost_nid || rc=3; }
14066 cleanup_obdecho_osc () {
14067 local obdfilter_name=$1
14068 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
14069 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
14076 local pages=${3:-64}
14081 local obd_size=$(get_obd_size $node $OBD)
14082 local page_size=$(get_page_size $node)
14083 if [[ -n "$obd_size" ]]; then
14084 local new_count=$((obd_size / (pages * page_size / 1024)))
14085 [[ $new_count -ge $count ]] || count=$new_count
14088 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
14089 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
14091 if [ $rc -eq 0 ]; then
14092 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
14093 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
14095 echo "New object id is $id"
14096 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
14098 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
14099 "test_brw $count w v $pages $id" || rc=4; }
14100 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
14102 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
14103 "cleanup" || rc=5; }
14104 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
14105 "detach" || rc=6; }
14106 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
14111 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14113 if ! module_loaded obdecho; then
14114 load_module obdecho/obdecho &&
14115 stack_trap "rmmod obdecho" EXIT ||
14116 error "unable to load obdecho on client"
14119 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
14120 local host=$($LCTL get_param -n osc.$osc.import |
14121 awk '/current_connection:/ { print $2 }' )
14122 local target=$($LCTL get_param -n osc.$osc.import |
14123 awk '/target:/ { print $2 }' )
14124 target=${target%_UUID}
14126 if [ -n "$target" ]; then
14127 setup_obdecho_osc $host $target &&
14128 stack_trap "cleanup_obdecho_osc $target" EXIT ||
14129 { error "obdecho setup failed with $?"; return; }
14131 obdecho_test ${target}_osc client ||
14132 error "obdecho_test failed on ${target}_osc"
14134 $LCTL get_param osc.$osc.import
14135 error "there is no osc.$osc.import target"
14138 run_test 180a "test obdecho on osc"
14141 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14142 remote_ost_nodsh && skip "remote OST with nodsh"
14144 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14145 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14146 error "failed to load module obdecho"
14148 local target=$(do_facet ost1 $LCTL dl |
14149 awk '/obdfilter/ { print $4; exit; }')
14151 if [ -n "$target" ]; then
14152 obdecho_test $target ost1 || error "obdecho_test failed with $?"
14154 do_facet ost1 $LCTL dl
14155 error "there is no obdfilter target on ost1"
14158 run_test 180b "test obdecho directly on obdfilter"
14160 test_180c() { # LU-2598
14161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14162 remote_ost_nodsh && skip "remote OST with nodsh"
14163 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
14164 skip "Need MDS version at least 2.4.0"
14166 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
14167 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
14168 error "failed to load module obdecho"
14170 local target=$(do_facet ost1 $LCTL dl |
14171 awk '/obdfilter/ { print $4; exit; }')
14173 if [ -n "$target" ]; then
14174 local pages=16384 # 64MB bulk I/O RPC size
14176 obdecho_test "$target" ost1 "$pages" ||
14177 error "obdecho_test with pages=$pages failed with $?"
14179 do_facet ost1 $LCTL dl
14180 error "there is no obdfilter target on ost1"
14183 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
14185 test_181() { # bug 22177
14186 test_mkdir $DIR/$tdir
14187 # create enough files to index the directory
14188 createmany -o $DIR/$tdir/foobar 4000
14189 # print attributes for debug purpose
14192 multiop_bg_pause $DIR/$tdir D_Sc || return 1
14194 # remove the files & current working dir
14195 unlinkmany $DIR/$tdir/foobar 4000
14197 kill -USR1 $MULTIPID
14199 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
14202 run_test 181 "Test open-unlinked dir ========================"
14208 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14210 $LCTL set_param mdc.*.rpc_stats=clear
14212 for (( i = 0; i < $tcount; i++ )) ; do
14213 mkdir $DIR/$tdir/$i
14216 for (( i = 0; i < $tcount; i++ )) ; do
14217 createmany -o $DIR/$tdir/$i/f- $fcount &
14221 for (( i = 0; i < $tcount; i++ )) ; do
14222 unlinkmany $DIR/$tdir/$i/f- $fcount &
14226 $LCTL get_param mdc.*.rpc_stats
14230 run_test 182 "Test parallel modify metadata operations ================"
14232 test_183() { # LU-2275
14233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14234 remote_mds_nodsh && skip "remote MDS with nodsh"
14235 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
14236 skip "Need MDS version at least 2.3.56"
14238 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14239 echo aaa > $DIR/$tdir/$tfile
14241 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
14242 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
14244 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
14245 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
14247 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
14249 # Flush negative dentry cache
14250 touch $DIR/$tdir/$tfile
14252 # We are not checking for any leaked references here, they'll
14253 # become evident next time we do cleanup with module unload.
14256 run_test 183 "No crash or request leak in case of strange dispositions ========"
14258 # test suite 184 is for LU-2016, LU-2017
14260 check_swap_layouts_support
14262 dir0=$DIR/$tdir/$testnum
14263 test_mkdir -p -c1 $dir0
14268 $SETSTRIPE -c1 $file1
14270 $SETSTRIPE -c2 $file2
14272 gen1=$($GETSTRIPE -g $file1)
14273 gen2=$($GETSTRIPE -g $file2)
14275 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
14276 gen=$($GETSTRIPE -g $file1)
14277 [[ $gen1 != $gen ]] ||
14278 "Layout generation on $file1 does not change"
14279 gen=$($GETSTRIPE -g $file2)
14280 [[ $gen2 != $gen ]] ||
14281 "Layout generation on $file2 does not change"
14283 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
14284 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
14286 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
14288 run_test 184a "Basic layout swap"
14291 check_swap_layouts_support
14293 dir0=$DIR/$tdir/$testnum
14294 mkdir -p $dir0 || error "creating dir $dir0"
14301 $SETSTRIPE -c1 $file1
14302 $SETSTRIPE -c2 $file2
14303 $SETSTRIPE -c1 $file3
14304 chown $RUNAS_ID $file3
14305 gen1=$($GETSTRIPE -g $file1)
14306 gen2=$($GETSTRIPE -g $file2)
14308 $LFS swap_layouts $dir1 $dir2 &&
14309 error "swap of directories layouts should fail"
14310 $LFS swap_layouts $dir1 $file1 &&
14311 error "swap of directory and file layouts should fail"
14312 $RUNAS $LFS swap_layouts $file1 $file2 &&
14313 error "swap of file we cannot write should fail"
14314 $LFS swap_layouts $file1 $file3 &&
14315 error "swap of file with different owner should fail"
14316 /bin/true # to clear error code
14318 run_test 184b "Forbidden layout swap (will generate errors)"
14321 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
14322 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
14323 check_swap_layouts_support
14325 local dir0=$DIR/$tdir/$testnum
14326 mkdir -p $dir0 || error "creating dir $dir0"
14328 local ref1=$dir0/ref1
14329 local ref2=$dir0/ref2
14330 local file1=$dir0/file1
14331 local file2=$dir0/file2
14332 # create a file large enough for the concurrent test
14333 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
14334 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
14335 echo "ref file size: ref1($(stat -c %s $ref1))," \
14336 "ref2($(stat -c %s $ref2))"
14339 dd if=$ref1 of=$file1 bs=16k &
14342 # Make sure dd starts to copy file
14343 while [ ! -f $file1 ]; do sleep 0.1; done
14345 $LFS swap_layouts $file1 $file2
14348 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
14349 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
14351 # how many bytes copied before swapping layout
14352 local copied=$(stat -c %s $file2)
14353 local remaining=$(stat -c %s $ref1)
14354 remaining=$((remaining - copied))
14355 echo "Copied $copied bytes before swapping layout..."
14357 cmp -n $copied $file1 $ref2 | grep differ &&
14358 error "Content mismatch [0, $copied) of ref2 and file1"
14359 cmp -n $copied $file2 $ref1 ||
14360 error "Content mismatch [0, $copied) of ref1 and file2"
14361 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
14362 error "Content mismatch [$copied, EOF) of ref1 and file1"
14365 rm -f $ref1 $ref2 $file1 $file2
14367 run_test 184c "Concurrent write and layout swap"
14370 check_swap_layouts_support
14371 [ -z "$(which getfattr 2>/dev/null)" ] &&
14372 skip_env "no getfattr command"
14374 local file1=$DIR/$tdir/$tfile-1
14375 local file2=$DIR/$tdir/$tfile-2
14376 local file3=$DIR/$tdir/$tfile-3
14380 mkdir -p $DIR/$tdir
14381 touch $file1 || error "create $file1 failed"
14382 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14383 error "create $file2 failed"
14384 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14385 error "create $file3 failed"
14386 lovea1=$(get_layout_param $file1)
14388 $LFS swap_layouts $file2 $file3 ||
14389 error "swap $file2 $file3 layouts failed"
14390 $LFS swap_layouts $file1 $file2 ||
14391 error "swap $file1 $file2 layouts failed"
14393 lovea2=$(get_layout_param $file2)
14396 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
14398 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14399 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
14401 run_test 184d "allow stripeless layouts swap"
14404 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
14405 skip "Need MDS version at least 2.6.94"
14406 check_swap_layouts_support
14407 [ -z "$(which getfattr 2>/dev/null)" ] &&
14408 skip_env "no getfattr command"
14410 local file1=$DIR/$tdir/$tfile-1
14411 local file2=$DIR/$tdir/$tfile-2
14412 local file3=$DIR/$tdir/$tfile-3
14415 mkdir -p $DIR/$tdir
14416 touch $file1 || error "create $file1 failed"
14417 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
14418 error "create $file2 failed"
14419 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
14420 error "create $file3 failed"
14422 $LFS swap_layouts $file1 $file2 ||
14423 error "swap $file1 $file2 layouts failed"
14425 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
14426 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
14428 echo 123 > $file1 || error "Should be able to write into $file1"
14430 $LFS swap_layouts $file1 $file3 ||
14431 error "swap $file1 $file3 layouts failed"
14433 echo 123 > $file1 || error "Should be able to write into $file1"
14435 rm -rf $file1 $file2 $file3
14437 run_test 184e "Recreate layout after stripeless layout swaps"
14440 # Create a file with name longer than sizeof(struct stat) ==
14441 # 144 to see if we can get chars from the file name to appear
14442 # in the returned striping. Note that 'f' == 0x66.
14443 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
14445 mkdir -p $DIR/$tdir
14446 mcreate $DIR/$tdir/$file
14447 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
14448 error "IOC_MDC_GETFILEINFO returned garbage striping"
14451 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
14453 test_185() { # LU-2441
14454 # LU-3553 - no volatile file support in old servers
14455 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
14456 skip "Need MDS version at least 2.3.60"
14458 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
14459 touch $DIR/$tdir/spoo
14460 local mtime1=$(stat -c "%Y" $DIR/$tdir)
14461 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
14462 error "cannot create/write a volatile file"
14463 [ "$FILESET" == "" ] &&
14464 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
14465 error "FID is still valid after close"
14467 multiop_bg_pause $DIR/$tdir vVw4096_c
14474 # assume that the next FID for this client is sequential, since stdout
14475 # is unfortunately eaten by multiop_bg_pause
14476 local n=$((${fidv[1]} + 1))
14477 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
14478 if [ "$FILESET" == "" ]; then
14479 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
14480 error "FID is missing before close"
14482 kill -USR1 $multi_pid
14483 # 1 second delay, so if mtime change we will see it
14485 local mtime2=$(stat -c "%Y" $DIR/$tdir)
14486 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
14488 run_test 185 "Volatile file support"
14490 function create_check_volatile() {
14494 $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
14497 local FID=$(cat /tmp/${tfile}.fid)
14498 [ "$FID" == "" ] && error "can't get FID for volatile"
14499 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
14500 tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
14501 [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
14505 cancel_lru_locks mdc # flush opencache
14506 $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
14511 # LU-12516 - volatile creation via .lustre
14512 [[ $MDS1_VERSION -ge $(version_code 2.12.2) ]] ||
14513 skip "Need MDS version at least 2.12.2"
14515 create_check_volatile 0
14516 [ $MDSCOUNT -lt 2 ] && return 0
14519 create_check_volatile 1
14523 run_test 185a "Volatile file creation in .lustre/fid/"
14526 remote_mds_nodsh && skip "remote MDS with nodsh"
14527 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14528 skip "Need MDS version at least 2.3.0"
14530 local dir0=$DIR/$tdir/$testnum
14531 mkdir -p $dir0 || error "creating dir $dir0"
14533 local file=$dir0/file1
14534 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
14535 local dv1=$($LFS data_version $file)
14536 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
14537 local dv2=$($LFS data_version $file)
14538 [[ $dv1 != $dv2 ]] ||
14539 error "data version did not change on write $dv1 == $dv2"
14544 run_test 187a "Test data version change"
14547 remote_mds_nodsh && skip "remote MDS with nodsh"
14548 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
14549 skip "Need MDS version at least 2.3.0"
14551 local dir0=$DIR/$tdir/$testnum
14552 mkdir -p $dir0 || error "creating dir $dir0"
14554 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
14555 [[ ${DV[0]} != ${DV[1]} ]] ||
14556 error "data version did not change on write"\
14557 " ${DV[0]} == ${DV[1]}"
14562 run_test 187b "Test data version change on volatile file"
14565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14566 remote_mgs_nodsh && skip "remote MGS with nodsh"
14567 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
14569 local POOL=${POOL:-cea1}
14570 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
14571 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
14574 local last_ost=$(($OSTCOUNT - 1))
14576 local ost_list=$(seq $first_ost $ost_step $last_ost)
14577 local ost_range="$first_ost $last_ost $ost_step"
14578 local test_path=$POOL_ROOT/$POOL_DIR_NAME
14579 local file_dir=$POOL_ROOT/file_tst
14580 local subdir=$test_path/subdir
14584 # former test_200a test_200b
14585 pool_add $POOL || { rc=$? ; break; }
14586 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
14587 # former test_200c test_200d
14588 mkdir -p $test_path
14589 pool_set_dir $POOL $test_path || { rc=$? ; break; }
14590 pool_check_dir $POOL $test_path || { rc=$? ; break; }
14592 pool_check_dir $POOL $subdir || { rc=$? ; break; }
14593 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
14594 || { rc=$? ; break; }
14595 # former test_200e test_200f
14596 local files=$((OSTCOUNT*3))
14597 pool_alloc_files $POOL $test_path $files "$ost_list" \
14598 || { rc=$? ; break; }
14599 pool_create_files $POOL $file_dir $files "$ost_list" \
14600 || { rc=$? ; break; }
14601 # former test_200g test_200h
14602 pool_lfs_df $POOL || { rc=$? ; break; }
14603 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
14605 # former test_201a test_201b test_201c
14606 pool_remove_first_target $POOL || { rc=$? ; break; }
14608 local f=$test_path/$tfile
14609 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
14610 pool_remove $POOL $f || { rc=$? ; break; }
14618 run_test 200 "OST pools"
14620 # usage: default_attr <count | size | offset>
14622 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
14625 # usage: check_default_stripe_attr
14626 check_default_stripe_attr() {
14627 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
14630 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
14632 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
14636 error "unknown getstripe attr '$1'"
14639 [ $ACTUAL == $EXPECTED ] ||
14640 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
14644 test_mkdir $DIR/$tdir
14645 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
14647 check_default_stripe_attr --stripe-count
14648 check_default_stripe_attr --stripe-size
14649 check_default_stripe_attr --stripe-index
14651 run_test 204a "Print default stripe attributes"
14654 test_mkdir $DIR/$tdir
14655 $SETSTRIPE --stripe-count 1 $DIR/$tdir
14657 check_default_stripe_attr --stripe-size
14658 check_default_stripe_attr --stripe-index
14660 run_test 204b "Print default stripe size and offset"
14663 test_mkdir $DIR/$tdir
14664 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
14666 check_default_stripe_attr --stripe-count
14667 check_default_stripe_attr --stripe-index
14669 run_test 204c "Print default stripe count and offset"
14672 test_mkdir $DIR/$tdir
14673 $SETSTRIPE --stripe-index 0 $DIR/$tdir
14675 check_default_stripe_attr --stripe-count
14676 check_default_stripe_attr --stripe-size
14678 run_test 204d "Print default stripe count and size"
14681 test_mkdir $DIR/$tdir
14682 $SETSTRIPE -d $DIR/$tdir
14684 check_default_stripe_attr --stripe-count --raw
14685 check_default_stripe_attr --stripe-size --raw
14686 check_default_stripe_attr --stripe-index --raw
14688 run_test 204e "Print raw stripe attributes"
14691 test_mkdir $DIR/$tdir
14692 $SETSTRIPE --stripe-count 1 $DIR/$tdir
14694 check_default_stripe_attr --stripe-size --raw
14695 check_default_stripe_attr --stripe-index --raw
14697 run_test 204f "Print raw stripe size and offset"
14700 test_mkdir $DIR/$tdir
14701 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
14703 check_default_stripe_attr --stripe-count --raw
14704 check_default_stripe_attr --stripe-index --raw
14706 run_test 204g "Print raw stripe count and offset"
14709 test_mkdir $DIR/$tdir
14710 $SETSTRIPE --stripe-index 0 $DIR/$tdir
14712 check_default_stripe_attr --stripe-count --raw
14713 check_default_stripe_attr --stripe-size --raw
14715 run_test 204h "Print raw stripe count and size"
14717 # Figure out which job scheduler is being used, if any,
14718 # or use a fake one
14719 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14720 JOBENV=SLURM_JOB_ID
14721 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14723 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14725 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14726 JOBENV=LOADL_STEP_ID
14727 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14730 $LCTL list_param jobid_name > /dev/null 2>&1
14731 if [ $? -eq 0 ]; then
14737 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14739 verify_jobstats() {
14744 # we don't really need to clear the stats for this test to work, since each
14745 # command has a unique jobid, but it makes debugging easier if needed.
14746 # for facet in $facets; do
14747 # local dev=$(convert_facet2label $facet)
14748 # # clear old jobstats
14749 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14752 # use a new JobID for each test, or we might see an old one
14753 [ "$JOBENV" = "FAKE_JOBID" ] &&
14754 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14756 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
14758 [ "$JOBENV" = "nodelocal" ] && {
14759 FAKE_JOBID=id.$testnum.%e.$RANDOM
14760 $LCTL set_param jobid_name=$FAKE_JOBID
14761 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
14764 log "Test: ${cmd[*]}"
14765 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
14767 if [ $JOBENV = "FAKE_JOBID" ]; then
14768 FAKE_JOBID=$JOBVAL ${cmd[*]}
14773 # all files are created on OST0000
14774 for facet in $facets; do
14775 local stats="*.$(convert_facet2label $facet).job_stats"
14777 # strip out libtool wrappers for in-tree executables
14778 if [ $(do_facet $facet lctl get_param $stats |
14779 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
14780 do_facet $facet lctl get_param $stats
14781 error "No jobstats for $JOBVAL found on $facet::$stats"
14787 local new_jobenv=$1
14789 set_persistent_param_and_check client "jobid_var" \
14790 "$FSNAME.sys.jobid_var" $new_jobenv
14793 test_205a() { # Job stats
14794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14795 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
14796 skip "Need MDS version with at least 2.7.1"
14797 remote_mgs_nodsh && skip "remote MGS with nodsh"
14798 remote_mds_nodsh && skip "remote MDS with nodsh"
14799 remote_ost_nodsh && skip "remote OST with nodsh"
14800 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
14801 skip "Server doesn't support jobstats"
14802 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
14804 local old_jobenv=$($LCTL get_param -n jobid_var)
14805 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
14807 if [[ $PERM_CMD = *"set_param -P"* ]]; then
14808 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
14810 stack_trap "do_facet mgs $PERM_CMD \
14811 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
14815 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
14816 mdt.*.job_cleanup_interval | head -n 1)
14817 local new_interval=5
14818 do_facet $SINGLEMDS \
14819 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
14820 stack_trap "do_facet $SINGLEMDS \
14821 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
14822 local start=$SECONDS
14826 cmd="mkdir $DIR/$tdir"
14827 verify_jobstats "$cmd" "$SINGLEMDS"
14829 cmd="rmdir $DIR/$tdir"
14830 verify_jobstats "$cmd" "$SINGLEMDS"
14831 # mkdir on secondary MDT
14832 if [ $MDSCOUNT -gt 1 ]; then
14833 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
14834 verify_jobstats "$cmd" "mds2"
14837 cmd="mknod $DIR/$tfile c 1 3"
14838 verify_jobstats "$cmd" "$SINGLEMDS"
14840 cmd="rm -f $DIR/$tfile"
14841 verify_jobstats "$cmd" "$SINGLEMDS"
14842 # create all files on OST0000 so verify_jobstats can find OST stats
14844 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
14845 verify_jobstats "$cmd" "$SINGLEMDS"
14847 cmd="touch $DIR/$tfile"
14848 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14850 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
14851 verify_jobstats "$cmd" "ost1"
14853 cancel_lru_locks osc
14854 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
14855 verify_jobstats "$cmd" "ost1"
14857 cmd="$TRUNCATE $DIR/$tfile 0"
14858 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14860 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
14861 verify_jobstats "$cmd" "$SINGLEMDS"
14862 # jobstats expiry - sleep until old stats should be expired
14863 local left=$((new_interval + 5 - (SECONDS - start)))
14864 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
14865 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
14867 cmd="mkdir $DIR/$tdir.expire"
14868 verify_jobstats "$cmd" "$SINGLEMDS"
14869 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
14870 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
14872 # Ensure that jobid are present in changelog (if supported by MDS)
14873 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
14874 changelog_dump | tail -10
14875 jobids=$(changelog_dump | tail -9 | grep -c "j=")
14876 [ $jobids -eq 9 ] ||
14877 error "Wrong changelog jobid count $jobids != 9"
14881 jobstats_set $JOBENV
14883 changelog_dump | grep $tfile
14884 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
14885 [ $jobids -eq 0 ] ||
14886 error "Unexpected jobids when jobid_var=$JOBENV"
14889 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
14890 JOBENV="JOBCOMPLEX"
14891 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
14893 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
14895 run_test 205a "Verify job stats"
14899 $LCTL set_param jobid_var=USER jobid_name="%e.%u"
14900 env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
14901 do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats |
14902 grep job_id: | grep foolish &&
14903 error "Unexpected jobid found"
14906 run_test 205b "Verify job stats jobid parsing"
14908 # LU-1480, LU-1773 and LU-1657
14910 mkdir -p $DIR/$tdir
14911 $SETSTRIPE -c -1 $DIR/$tdir
14912 #define OBD_FAIL_LOV_INIT 0x1403
14913 $LCTL set_param fail_loc=0xa0001403
14914 $LCTL set_param fail_val=1
14915 touch $DIR/$tdir/$tfile || true
14917 run_test 206 "fail lov_init_raid0() doesn't lbug"
14920 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14921 local fsz=`stat -c %s $DIR/$tfile`
14922 cancel_lru_locks mdc
14924 # do not return layout in getattr intent
14925 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
14926 $LCTL set_param fail_loc=0x170
14927 local sz=`stat -c %s $DIR/$tfile`
14929 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
14933 run_test 207a "can refresh layout at glimpse"
14936 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14937 local cksum=`md5sum $DIR/$tfile`
14938 local fsz=`stat -c %s $DIR/$tfile`
14939 cancel_lru_locks mdc
14940 cancel_lru_locks osc
14942 # do not return layout in getattr intent
14943 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
14944 $LCTL set_param fail_loc=0x171
14946 # it will refresh layout after the file is opened but before read issues
14947 echo checksum is "$cksum"
14948 echo "$cksum" |md5sum -c --quiet || error "file differs"
14952 run_test 207b "can refresh layout at open"
14955 # FIXME: in this test suite, only RD lease is used. This is okay
14956 # for now as only exclusive open is supported. After generic lease
14957 # is done, this test suite should be revised. - Jinshan
14959 remote_mds_nodsh && skip "remote MDS with nodsh"
14960 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
14961 skip "Need MDS version at least 2.4.52"
14963 echo "==== test 1: verify get lease work"
14964 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
14966 echo "==== test 2: verify lease can be broken by upcoming open"
14967 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14971 $MULTIOP $DIR/$tfile oO_RDONLY:c
14972 kill -USR1 $PID && wait $PID || error "break lease error"
14974 echo "==== test 3: verify lease can't be granted if an open already exists"
14975 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
14979 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
14980 kill -USR1 $PID && wait $PID || error "open file error"
14982 echo "==== test 4: lease can sustain over recovery"
14983 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
14989 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
14991 echo "==== test 5: lease broken can't be regained by replay"
14992 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14996 # open file to break lease and then recovery
14997 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
15000 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
15004 run_test 208 "Exclusive open"
15007 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
15008 skip_env "must have disp_stripe"
15011 sync; sleep 5; sync;
15013 echo 3 > /proc/sys/vm/drop_caches
15014 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15016 # open/close 500 times
15017 for i in $(seq 500); do
15021 echo 3 > /proc/sys/vm/drop_caches
15022 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
15024 echo "before: $req_before, after: $req_after"
15025 [ $((req_after - req_before)) -ge 300 ] &&
15026 error "open/close requests are not freed"
15029 run_test 209 "read-only open/close requests should be freed promptly"
15033 size=$((size % 8192 + 1))
15034 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
15035 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
15036 rm -f $DIR/f212 $DIR/f212.xyz
15038 run_test 212 "Sendfile test ============================================"
15041 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
15042 cancel_lru_locks osc
15043 lctl set_param fail_loc=0x8000040f
15044 # generate a read lock
15045 cat $DIR/$tfile > /dev/null
15046 # write to the file, it will try to cancel the above read lock.
15047 cat /etc/hosts >> $DIR/$tfile
15049 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
15051 test_214() { # for bug 20133
15052 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
15053 for (( i=0; i < 340; i++ )) ; do
15054 touch $DIR/$tdir/d214c/a$i
15057 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
15058 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
15059 ls $DIR/d214c || error "ls $DIR/d214c failed"
15060 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
15061 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
15063 run_test 214 "hash-indexed directory test - bug 20133"
15065 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
15066 create_lnet_proc_files() {
15067 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
15070 # counterpart of create_lnet_proc_files
15071 remove_lnet_proc_files() {
15072 rm -f $TMP/lnet_$1.sys
15075 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15076 # 3rd arg as regexp for body
15077 check_lnet_proc_stats() {
15078 local l=$(cat "$TMP/lnet_$1" |wc -l)
15079 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
15081 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
15084 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
15085 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
15086 # optional and can be regexp for 2nd line (lnet.routes case)
15087 check_lnet_proc_entry() {
15088 local blp=2 # blp stands for 'position of 1st line of body'
15089 [ -z "$5" ] || blp=3 # lnet.routes case
15091 local l=$(cat "$TMP/lnet_$1" |wc -l)
15092 # subtracting one from $blp because the body can be empty
15093 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
15095 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
15096 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
15098 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
15099 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
15101 # bail out if any unexpected line happened
15102 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
15103 [ "$?" != 0 ] || error "$2 misformatted"
15106 test_215() { # for bugs 18102, 21079, 21517
15107 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15109 local N='(0|[1-9][0-9]*)' # non-negative numeric
15110 local P='[1-9][0-9]*' # positive numeric
15111 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
15112 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
15113 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
15114 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
15116 local L1 # regexp for 1st line
15117 local L2 # regexp for 2nd line (optional)
15118 local BR # regexp for the rest (body)
15120 # lnet.stats should look as 11 space-separated non-negative numerics
15121 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
15122 create_lnet_proc_files "stats"
15123 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
15124 remove_lnet_proc_files "stats"
15126 # lnet.routes should look like this:
15127 # Routing disabled/enabled
15128 # net hops priority state router
15129 # where net is a string like tcp0, hops > 0, priority >= 0,
15130 # state is up/down,
15131 # router is a string like 192.168.1.1@tcp2
15132 L1="^Routing (disabled|enabled)$"
15133 L2="^net +hops +priority +state +router$"
15134 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
15135 create_lnet_proc_files "routes"
15136 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
15137 remove_lnet_proc_files "routes"
15139 # lnet.routers should look like this:
15140 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
15141 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
15142 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
15143 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
15144 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
15145 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
15146 create_lnet_proc_files "routers"
15147 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
15148 remove_lnet_proc_files "routers"
15150 # lnet.peers should look like this:
15151 # nid refs state last max rtr min tx min queue
15152 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
15153 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
15154 # numeric (0 or >0 or <0), queue >= 0.
15155 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
15156 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
15157 create_lnet_proc_files "peers"
15158 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
15159 remove_lnet_proc_files "peers"
15161 # lnet.buffers should look like this:
15162 # pages count credits min
15163 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
15164 L1="^pages +count +credits +min$"
15165 BR="^ +$N +$N +$I +$I$"
15166 create_lnet_proc_files "buffers"
15167 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
15168 remove_lnet_proc_files "buffers"
15170 # lnet.nis should look like this:
15171 # nid status alive refs peer rtr max tx min
15172 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
15173 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
15174 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
15175 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
15176 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
15177 create_lnet_proc_files "nis"
15178 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
15179 remove_lnet_proc_files "nis"
15181 # can we successfully write to lnet.stats?
15182 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
15184 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
15186 test_216() { # bug 20317
15187 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15188 remote_ost_nodsh && skip "remote OST with nodsh"
15191 local facets=$(get_facets OST)
15192 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15194 save_lustre_params client "osc.*.contention_seconds" > $p
15195 save_lustre_params $facets \
15196 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
15197 save_lustre_params $facets \
15198 "ldlm.namespaces.filter-*.contended_locks" >> $p
15199 save_lustre_params $facets \
15200 "ldlm.namespaces.filter-*.contention_seconds" >> $p
15201 clear_stats osc.*.osc_stats
15203 # agressive lockless i/o settings
15204 do_nodes $(comma_list $(osts_nodes)) \
15205 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
15206 ldlm.namespaces.filter-*.contended_locks=0 \
15207 ldlm.namespaces.filter-*.contention_seconds=60"
15208 lctl set_param -n osc.*.contention_seconds=60
15210 $DIRECTIO write $DIR/$tfile 0 10 4096
15211 $CHECKSTAT -s 40960 $DIR/$tfile
15213 # disable lockless i/o
15214 do_nodes $(comma_list $(osts_nodes)) \
15215 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
15216 ldlm.namespaces.filter-*.contended_locks=32 \
15217 ldlm.namespaces.filter-*.contention_seconds=0"
15218 lctl set_param -n osc.*.contention_seconds=0
15219 clear_stats osc.*.osc_stats
15221 dd if=/dev/zero of=$DIR/$tfile count=0
15222 $CHECKSTAT -s 0 $DIR/$tfile
15224 restore_lustre_params <$p
15228 run_test 216 "check lockless direct write updates file size and kms correctly"
15230 test_217() { # bug 22430
15231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15236 for node in $(nodes_list); do
15237 nid=$(host_nids_address $node $NETTYPE)
15238 if [[ $nid = *-* ]] ; then
15239 echo "lctl ping $(h2nettype $nid)"
15240 lctl ping $(h2nettype $nid)
15242 echo "skipping $node (no hyphen detected)"
15246 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
15249 # do directio so as not to populate the page cache
15250 log "creating a 10 Mb file"
15251 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
15252 log "starting reads"
15253 dd if=$DIR/$tfile of=/dev/null bs=4096 &
15254 log "truncating the file"
15255 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
15257 kill %+ || true # reads might have finished
15258 echo "wait until dd is finished"
15260 log "removing the temporary file"
15261 rm -rf $DIR/$tfile || error "tmp file removal failed"
15263 run_test 218 "parallel read and truncate should not deadlock"
15266 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15268 # write one partial page
15269 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
15270 # set no grant so vvp_io_commit_write will do sync write
15271 $LCTL set_param fail_loc=0x411
15272 # write a full page at the end of file
15273 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
15275 $LCTL set_param fail_loc=0
15276 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
15277 $LCTL set_param fail_loc=0x411
15278 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
15281 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
15282 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
15284 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
15286 test_220() { #LU-325
15287 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15288 remote_ost_nodsh && skip "remote OST with nodsh"
15289 remote_mds_nodsh && skip "remote MDS with nodsh"
15290 remote_mgs_nodsh && skip "remote MGS with nodsh"
15294 # create on MDT0000 so the last_id and next_id are correct
15296 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
15300 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
15301 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
15302 osp.$mdtosc_proc1.prealloc_last_id)
15303 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
15304 osp.$mdtosc_proc1.prealloc_next_id)
15308 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
15309 #define OBD_FAIL_OST_ENOINO 0x229
15310 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
15311 create_pool $FSNAME.$TESTNAME || return 1
15312 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
15314 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
15316 MDSOBJS=$((last_id - next_id))
15317 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
15319 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
15320 echo "OST still has $count kbytes free"
15322 echo "create $MDSOBJS files @next_id..."
15323 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
15325 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15326 osp.$mdtosc_proc1.prealloc_last_id)
15327 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
15328 osp.$mdtosc_proc1.prealloc_next_id)
15330 echo "after creation, last_id=$last_id2, next_id=$next_id2"
15335 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
15336 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
15338 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
15339 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
15340 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
15341 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
15342 echo "unlink $MDSOBJS files @$next_id..."
15343 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
15345 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
15348 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15350 dd if=`which date` of=$MOUNT/date oflag=sync
15351 chmod +x $MOUNT/date
15353 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
15354 $LCTL set_param fail_loc=0x80001401
15356 $MOUNT/date > /dev/null
15359 run_test 221 "make sure fault and truncate race to not cause OOM"
15362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15365 test_mkdir $DIR/$tdir
15366 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15367 createmany -o $DIR/$tdir/$tfile 10
15368 cancel_lru_locks mdc
15369 cancel_lru_locks osc
15370 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15371 $LCTL set_param fail_loc=0x31a
15372 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
15373 $LCTL set_param fail_loc=0
15376 run_test 222a "AGL for ls should not trigger CLIO lock failure"
15379 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15382 test_mkdir $DIR/$tdir
15383 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15384 createmany -o $DIR/$tdir/$tfile 10
15385 cancel_lru_locks mdc
15386 cancel_lru_locks osc
15387 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
15388 $LCTL set_param fail_loc=0x31a
15389 rm -r $DIR/$tdir || error "AGL for rmdir failed"
15390 $LCTL set_param fail_loc=0
15392 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
15395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15398 test_mkdir $DIR/$tdir
15399 $LFS setstripe -c 1 -i 0 $DIR/$tdir
15400 createmany -o $DIR/$tdir/$tfile 10
15401 cancel_lru_locks mdc
15402 cancel_lru_locks osc
15403 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
15404 $LCTL set_param fail_loc=0x31b
15405 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
15406 $LCTL set_param fail_loc=0
15409 run_test 223 "osc reenqueue if without AGL lock granted ======================="
15411 test_224a() { # LU-1039, MRP-303
15412 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15414 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
15415 $LCTL set_param fail_loc=0x508
15416 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
15417 $LCTL set_param fail_loc=0
15420 run_test 224a "Don't panic on bulk IO failure"
15422 test_224b() { # LU-1039, MRP-303
15423 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15425 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
15426 cancel_lru_locks osc
15427 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
15428 $LCTL set_param fail_loc=0x515
15429 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
15430 $LCTL set_param fail_loc=0
15433 run_test 224b "Don't panic on bulk IO failure"
15435 test_224c() { # LU-6441
15436 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15437 remote_mds_nodsh && skip "remote MDS with nodsh"
15439 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
15440 save_writethrough $p
15441 set_cache writethrough on
15443 local pages_per_rpc=$($LCTL get_param \
15444 osc.*.max_pages_per_rpc)
15445 local at_max=$($LCTL get_param -n at_max)
15446 local timeout=$($LCTL get_param -n timeout)
15447 local test_at="at_max"
15448 local param_at="$FSNAME.sys.at_max"
15449 local test_timeout="timeout"
15450 local param_timeout="$FSNAME.sys.timeout"
15452 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
15454 set_persistent_param_and_check client "$test_at" "$param_at" 0
15455 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
15457 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
15458 do_facet ost1 $LCTL set_param fail_loc=0x520
15459 $LFS setstripe -c 1 -i 0 $DIR/$tfile
15460 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
15462 do_facet ost1 $LCTL set_param fail_loc=0
15464 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
15465 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
15468 $LCTL set_param -n $pages_per_rpc
15469 restore_lustre_params < $p
15472 run_test 224c "Don't hang if one of md lost during large bulk RPC"
15474 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
15476 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15477 if [ -z ${MDSSURVEY} ]; then
15478 skip_env "mds-survey not found"
15480 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15481 skip "Need MDS version at least 2.2.51"
15483 local mds=$(facet_host $SINGLEMDS)
15484 local target=$(do_nodes $mds 'lctl dl' |
15485 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15487 local cmd1="file_count=1000 thrhi=4"
15488 local cmd2="dir_count=2 layer=mdd stripe_count=0"
15489 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15490 local cmd="$cmd1 $cmd2 $cmd3"
15492 rm -f ${TMP}/mds_survey*
15494 eval $cmd || error "mds-survey with zero-stripe failed"
15495 cat ${TMP}/mds_survey*
15496 rm -f ${TMP}/mds_survey*
15498 run_test 225a "Metadata survey sanity with zero-stripe"
15501 if [ -z ${MDSSURVEY} ]; then
15502 skip_env "mds-survey not found"
15504 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
15505 skip "Need MDS version at least 2.2.51"
15506 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15507 remote_mds_nodsh && skip "remote MDS with nodsh"
15508 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
15509 skip_env "Need to mount OST to test"
15512 local mds=$(facet_host $SINGLEMDS)
15513 local target=$(do_nodes $mds 'lctl dl' |
15514 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
15516 local cmd1="file_count=1000 thrhi=4"
15517 local cmd2="dir_count=2 layer=mdd stripe_count=1"
15518 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
15519 local cmd="$cmd1 $cmd2 $cmd3"
15521 rm -f ${TMP}/mds_survey*
15523 eval $cmd || error "mds-survey with stripe_count failed"
15524 cat ${TMP}/mds_survey*
15525 rm -f ${TMP}/mds_survey*
15527 run_test 225b "Metadata survey sanity with stripe_count = 1"
15529 mcreate_path2fid () {
15535 local path=$DIR/$tdir/$name
15540 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
15541 error "cannot create $desc"
15543 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
15545 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
15547 fid_path=$($LFS fid2path $MOUNT $fid)
15549 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
15551 [ "$path" == "$fid_path" ] ||
15552 error "fid2path returned $fid_path, expected $path"
15554 echo "pass with $path and $fid"
15559 mkdir -p $DIR/$tdir
15561 mcreate_path2fid 0010666 0 0 fifo "FIFO"
15562 mcreate_path2fid 0020666 1 3 null "character special file (null)"
15563 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
15564 mcreate_path2fid 0040666 0 0 dir "directory"
15565 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
15566 mcreate_path2fid 0100666 0 0 file "regular file"
15567 mcreate_path2fid 0120666 0 0 link "symbolic link"
15568 mcreate_path2fid 0140666 0 0 sock "socket"
15570 run_test 226a "call path2fid and fid2path on files of all type"
15573 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15578 mkdir -p $DIR/$tdir
15579 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
15580 error "create remote directory failed"
15581 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
15582 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
15583 "character special file (null)"
15584 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
15585 "character special file (no device)"
15586 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
15587 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
15588 "block special file (loop)"
15589 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
15590 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
15591 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
15593 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
15595 # LU-1299 Executing or running ldd on a truncated executable does not
15596 # cause an out-of-memory condition.
15598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15599 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
15601 dd if=$(which date) of=$MOUNT/date bs=1k count=1
15602 chmod +x $MOUNT/date
15604 $MOUNT/date > /dev/null
15605 ldd $MOUNT/date > /dev/null
15608 run_test 227 "running truncated executable does not cause OOM"
15610 # LU-1512 try to reuse idle OI blocks
15612 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15613 remote_mds_nodsh && skip "remote MDS with nodsh"
15614 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15616 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15617 local myDIR=$DIR/$tdir
15620 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15621 $LCTL set_param fail_loc=0x80001002
15622 createmany -o $myDIR/t- 10000
15623 $LCTL set_param fail_loc=0
15624 # The guard is current the largest FID holder
15626 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15628 local IDX=$(($SEQ % 64))
15630 do_facet $SINGLEMDS sync
15631 # Make sure journal flushed.
15633 local blk1=$(do_facet $SINGLEMDS \
15634 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15635 grep Blockcount | awk '{print $4}')
15637 # Remove old files, some OI blocks will become idle.
15638 unlinkmany $myDIR/t- 10000
15639 # Create new files, idle OI blocks should be reused.
15640 createmany -o $myDIR/t- 2000
15641 do_facet $SINGLEMDS sync
15642 # Make sure journal flushed.
15644 local blk2=$(do_facet $SINGLEMDS \
15645 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15646 grep Blockcount | awk '{print $4}')
15648 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15650 run_test 228a "try to reuse idle OI blocks"
15653 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15654 remote_mds_nodsh && skip "remote MDS with nodsh"
15655 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15657 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15658 local myDIR=$DIR/$tdir
15661 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15662 $LCTL set_param fail_loc=0x80001002
15663 createmany -o $myDIR/t- 10000
15664 $LCTL set_param fail_loc=0
15665 # The guard is current the largest FID holder
15667 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15669 local IDX=$(($SEQ % 64))
15671 do_facet $SINGLEMDS sync
15672 # Make sure journal flushed.
15674 local blk1=$(do_facet $SINGLEMDS \
15675 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15676 grep Blockcount | awk '{print $4}')
15678 # Remove old files, some OI blocks will become idle.
15679 unlinkmany $myDIR/t- 10000
15682 stop $SINGLEMDS || error "Fail to stop MDT."
15684 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
15686 df $MOUNT || error "Fail to df."
15687 # Create new files, idle OI blocks should be reused.
15688 createmany -o $myDIR/t- 2000
15689 do_facet $SINGLEMDS sync
15690 # Make sure journal flushed.
15692 local blk2=$(do_facet $SINGLEMDS \
15693 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15694 grep Blockcount | awk '{print $4}')
15696 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15698 run_test 228b "idle OI blocks can be reused after MDT restart"
15702 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15703 remote_mds_nodsh && skip "remote MDS with nodsh"
15704 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15706 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15707 local myDIR=$DIR/$tdir
15710 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15711 $LCTL set_param fail_loc=0x80001002
15712 # 20000 files can guarantee there are index nodes in the OI file
15713 createmany -o $myDIR/t- 20000
15714 $LCTL set_param fail_loc=0
15715 # The guard is current the largest FID holder
15717 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15719 local IDX=$(($SEQ % 64))
15721 do_facet $SINGLEMDS sync
15722 # Make sure journal flushed.
15724 local blk1=$(do_facet $SINGLEMDS \
15725 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15726 grep Blockcount | awk '{print $4}')
15728 # Remove old files, some OI blocks will become idle.
15729 unlinkmany $myDIR/t- 20000
15731 # The OI file should become empty now
15733 # Create new files, idle OI blocks should be reused.
15734 createmany -o $myDIR/t- 2000
15735 do_facet $SINGLEMDS sync
15736 # Make sure journal flushed.
15738 local blk2=$(do_facet $SINGLEMDS \
15739 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15740 grep Blockcount | awk '{print $4}')
15742 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15744 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15746 test_229() { # LU-2482, LU-3448
15747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15748 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15749 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15750 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15754 # Create a file with a released layout and stripe count 2.
15755 $MULTIOP $DIR/$tfile H2c ||
15756 error "failed to create file with released layout"
15758 $GETSTRIPE -v $DIR/$tfile
15760 local pattern=$($GETSTRIPE -L $DIR/$tfile)
15761 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
15763 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
15764 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
15765 stat $DIR/$tfile || error "failed to stat released file"
15767 chown $RUNAS_ID $DIR/$tfile ||
15768 error "chown $RUNAS_ID $DIR/$tfile failed"
15770 chgrp $RUNAS_ID $DIR/$tfile ||
15771 error "chgrp $RUNAS_ID $DIR/$tfile failed"
15773 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
15774 rm $DIR/$tfile || error "failed to remove released file"
15776 run_test 229 "getstripe/stat/rm/attr changes work on released files"
15779 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15780 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15781 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15782 skip "Need MDS version at least 2.11.52"
15786 test_mkdir $DIR/$tdir
15787 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
15788 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
15789 [ $mdt_idx -ne 0 ] &&
15790 error "create local directory on wrong MDT $mdt_idx"
15792 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
15793 error "create remote directory failed"
15794 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
15795 [ $mdt_idx -ne $MDTIDX ] &&
15796 error "create remote directory on wrong MDT $mdt_idx"
15798 createmany -o $DIR/$tdir/test_230/t- 10 ||
15799 error "create files on remote directory failed"
15800 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
15801 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
15802 rm -r $DIR/$tdir || error "unlink remote directory failed"
15804 run_test 230a "Create remote directory and files under the remote directory"
15807 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15808 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15809 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15810 skip "Need MDS version at least 2.11.52"
15818 local migrate_dir=$DIR/$tdir/migrate_dir
15819 local other_dir=$DIR/$tdir/other_dir
15821 test_mkdir $DIR/$tdir
15822 test_mkdir -i0 -c1 $migrate_dir
15823 test_mkdir -i0 -c1 $other_dir
15824 for ((i=0; i<10; i++)); do
15825 mkdir -p $migrate_dir/dir_${i}
15826 createmany -o $migrate_dir/dir_${i}/f 10 ||
15827 error "create files under remote dir failed $i"
15830 cp /etc/passwd $migrate_dir/$tfile
15831 cp /etc/passwd $other_dir/$tfile
15832 chattr +SAD $migrate_dir
15833 chattr +SAD $migrate_dir/$tfile
15835 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15836 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15837 local old_dir_mode=$(stat -c%f $migrate_dir)
15838 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
15840 mkdir -p $migrate_dir/dir_default_stripe2
15841 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
15842 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
15844 mkdir -p $other_dir
15845 ln $migrate_dir/$tfile $other_dir/luna
15846 ln $migrate_dir/$tfile $migrate_dir/sofia
15847 ln $other_dir/$tfile $migrate_dir/david
15848 ln -s $migrate_dir/$tfile $other_dir/zachary
15849 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
15850 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
15856 for len in 58 59 60; do
15857 lnktgt=$(str_repeat 'l' $len)
15858 touch $migrate_dir/$lnktgt
15859 ln -s $lnktgt $migrate_dir/${len}char_ln
15863 for len in 4094 4095; do
15864 lnktgt=$(str_repeat 'l' $len)
15865 ln -s $lnktgt $migrate_dir/${len}char_ln
15869 for len in 254 255; do
15870 touch $migrate_dir/$(str_repeat 'l' $len)
15873 $LFS migrate -m $MDTIDX $migrate_dir ||
15874 error "fails on migrating remote dir to MDT1"
15876 echo "migratate to MDT1, then checking.."
15877 for ((i = 0; i < 10; i++)); do
15878 for file in $(find $migrate_dir/dir_${i}); do
15879 mdt_index=$($LFS getstripe -m $file)
15880 # broken symlink getstripe will fail
15881 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
15882 error "$file is not on MDT${MDTIDX}"
15886 # the multiple link file should still in MDT0
15887 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
15888 [ $mdt_index == 0 ] ||
15889 error "$file is not on MDT${MDTIDX}"
15891 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15892 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15893 error " expect $old_dir_flag get $new_dir_flag"
15895 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15896 [ "$old_file_flag" = "$new_file_flag" ] ||
15897 error " expect $old_file_flag get $new_file_flag"
15899 local new_dir_mode=$(stat -c%f $migrate_dir)
15900 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15901 error "expect mode $old_dir_mode get $new_dir_mode"
15903 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15904 [ "$old_file_mode" = "$new_file_mode" ] ||
15905 error "expect mode $old_file_mode get $new_file_mode"
15907 diff /etc/passwd $migrate_dir/$tfile ||
15908 error "$tfile different after migration"
15910 diff /etc/passwd $other_dir/luna ||
15911 error "luna different after migration"
15913 diff /etc/passwd $migrate_dir/sofia ||
15914 error "sofia different after migration"
15916 diff /etc/passwd $migrate_dir/david ||
15917 error "david different after migration"
15919 diff /etc/passwd $other_dir/zachary ||
15920 error "zachary different after migration"
15922 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15923 error "${tfile}_ln different after migration"
15925 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15926 error "${tfile}_ln_other different after migration"
15928 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
15929 [ $stripe_count = 2 ] ||
15930 error "dir strpe_count $d != 2 after migration."
15932 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
15933 [ $stripe_count = 2 ] ||
15934 error "file strpe_count $d != 2 after migration."
15936 #migrate back to MDT0
15939 $LFS migrate -m $MDTIDX $migrate_dir ||
15940 error "fails on migrating remote dir to MDT0"
15942 echo "migrate back to MDT0, checking.."
15943 for file in $(find $migrate_dir); do
15944 mdt_index=$($LFS getstripe -m $file)
15945 [ $mdt_index -ne $MDTIDX ] && stat -L $file &&
15946 error "$file is not on MDT${MDTIDX}"
15949 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15950 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15951 error " expect $old_dir_flag get $new_dir_flag"
15953 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15954 [ "$old_file_flag" = "$new_file_flag" ] ||
15955 error " expect $old_file_flag get $new_file_flag"
15957 local new_dir_mode=$(stat -c%f $migrate_dir)
15958 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15959 error "expect mode $old_dir_mode get $new_dir_mode"
15961 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15962 [ "$old_file_mode" = "$new_file_mode" ] ||
15963 error "expect mode $old_file_mode get $new_file_mode"
15965 diff /etc/passwd ${migrate_dir}/$tfile ||
15966 error "$tfile different after migration"
15968 diff /etc/passwd ${other_dir}/luna ||
15969 error "luna different after migration"
15971 diff /etc/passwd ${migrate_dir}/sofia ||
15972 error "sofia different after migration"
15974 diff /etc/passwd ${other_dir}/zachary ||
15975 error "zachary different after migration"
15977 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15978 error "${tfile}_ln different after migration"
15980 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15981 error "${tfile}_ln_other different after migration"
15983 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
15984 [ $stripe_count = 2 ] ||
15985 error "dir strpe_count $d != 2 after migration."
15987 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
15988 [ $stripe_count = 2 ] ||
15989 error "file strpe_count $d != 2 after migration."
15991 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15993 run_test 230b "migrate directory"
15996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15997 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15998 remote_mds_nodsh && skip "remote MDS with nodsh"
15999 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16000 skip "Need MDS version at least 2.11.52"
16006 local migrate_dir=$DIR/$tdir/migrate_dir
16008 #If migrating directory fails in the middle, all entries of
16009 #the directory is still accessiable.
16010 test_mkdir $DIR/$tdir
16011 test_mkdir -i0 -c1 $migrate_dir
16012 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
16014 createmany -o $migrate_dir/f $total ||
16015 error "create files under ${migrate_dir} failed"
16017 # fail after migrating top dir, and this will fail only once, so the
16018 # first sub file migration will fail (currently f3), others succeed.
16019 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
16020 do_facet mds1 lctl set_param fail_loc=0x1801
16021 local t=$(ls $migrate_dir | wc -l)
16022 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
16023 error "migrate should fail"
16024 local u=$(ls $migrate_dir | wc -l)
16025 [ "$u" == "$t" ] || error "$u != $t during migration"
16027 # add new dir/file should succeed
16028 mkdir $migrate_dir/dir ||
16029 error "mkdir failed under migrating directory"
16030 touch $migrate_dir/file ||
16031 error "create file failed under migrating directory"
16033 # add file with existing name should fail
16034 for file in $migrate_dir/f*; do
16035 stat $file > /dev/null || error "stat $file failed"
16036 $OPENFILE -f O_CREAT:O_EXCL $file &&
16037 error "open(O_CREAT|O_EXCL) $file should fail"
16038 $MULTIOP $file m && error "create $file should fail"
16039 touch $DIR/$tdir/remote_dir/$tfile ||
16040 error "touch $tfile failed"
16041 ln $DIR/$tdir/remote_dir/$tfile $file &&
16042 error "link $file should fail"
16043 mdt_index=$($LFS getstripe -m $file)
16044 if [ $mdt_index == 0 ]; then
16045 # file failed to migrate is not allowed to rename to
16046 mv $DIR/$tdir/remote_dir/$tfile $file &&
16047 error "rename to $file should fail"
16049 mv $DIR/$tdir/remote_dir/$tfile $file ||
16050 error "rename to $file failed"
16052 echo hello >> $file || error "write $file failed"
16055 # resume migration with different options should fail
16056 $LFS migrate -m 0 $migrate_dir &&
16057 error "migrate -m 0 $migrate_dir should fail"
16059 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
16060 error "migrate -c 2 $migrate_dir should fail"
16062 # resume migration should succeed
16063 $LFS migrate -m $MDTIDX $migrate_dir ||
16064 error "migrate $migrate_dir failed"
16066 echo "Finish migration, then checking.."
16067 for file in $(find $migrate_dir); do
16068 mdt_index=$($LFS getstripe -m $file)
16069 [ $mdt_index == $MDTIDX ] ||
16070 error "$file is not on MDT${MDTIDX}"
16073 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16075 run_test 230c "check directory accessiblity if migration failed"
16078 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16079 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16080 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16081 skip "Need MDS version at least 2.11.52"
16083 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
16085 local migrate_dir=$DIR/$tdir/migrate_dir
16095 old_index=$((RANDOM % MDSCOUNT))
16096 old_count=$((MDSCOUNT - old_index))
16097 new_index=$((RANDOM % MDSCOUNT))
16098 new_count=$((MDSCOUNT - new_index))
16099 new_hash="all_char"
16101 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
16102 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
16104 test_mkdir $DIR/$tdir
16105 test_mkdir -i $old_index -c $old_count $migrate_dir
16107 for ((i=0; i<100; i++)); do
16108 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
16109 createmany -o $migrate_dir/dir_${i}/f 100 ||
16110 error "create files under remote dir failed $i"
16113 echo -n "Migrate from MDT$old_index "
16114 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
16115 echo -n "to MDT$new_index"
16116 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
16119 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
16120 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
16121 error "migrate remote dir error"
16123 echo "Finish migration, then checking.."
16124 for file in $(find $migrate_dir); do
16125 mdt_index=$($LFS getstripe -m $file)
16126 if [ $mdt_index -lt $new_index ] ||
16127 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
16128 error "$file is on MDT$mdt_index"
16132 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16134 run_test 230d "check migrate big directory"
16137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16138 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16139 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16140 skip "Need MDS version at least 2.11.52"
16147 mkdir -p $DIR/$tdir
16148 mkdir $DIR/$tdir/migrate_dir
16149 mkdir $DIR/$tdir/other_dir
16150 touch $DIR/$tdir/migrate_dir/a
16151 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
16152 ls $DIR/$tdir/other_dir
16154 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16155 error "migrate dir fails"
16157 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16158 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16160 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16161 [ $mdt_index == 0 ] || error "a is not on MDT0"
16163 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
16164 error "migrate dir fails"
16166 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
16167 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
16169 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16170 [ $mdt_index == 1 ] || error "a is not on MDT1"
16172 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
16173 [ $mdt_index == 1 ] || error "b is not on MDT1"
16175 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16176 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
16178 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
16180 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16182 run_test 230e "migrate mulitple local link files"
16185 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16186 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16187 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16188 skip "Need MDS version at least 2.11.52"
16193 mkdir -p $DIR/$tdir
16194 mkdir $DIR/$tdir/migrate_dir
16195 $LFS mkdir -i1 $DIR/$tdir/other_dir
16196 touch $DIR/$tdir/migrate_dir/a
16197 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
16198 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
16199 ls $DIR/$tdir/other_dir
16201 # a should be migrated to MDT1, since no other links on MDT0
16202 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16203 error "#1 migrate dir fails"
16204 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
16205 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
16206 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16207 [ $mdt_index == 1 ] || error "a is not on MDT1"
16209 # a should stay on MDT1, because it is a mulitple link file
16210 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16211 error "#2 migrate dir fails"
16212 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16213 [ $mdt_index == 1 ] || error "a is not on MDT1"
16215 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
16216 error "#3 migrate dir fails"
16218 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
16219 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
16220 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
16222 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
16223 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
16225 # a should be migrated to MDT0, since no other links on MDT1
16226 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
16227 error "#4 migrate dir fails"
16228 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
16229 [ $mdt_index == 0 ] || error "a is not on MDT0"
16231 rm -rf $DIR/$tdir || error "rm dir failed after migration"
16233 run_test 230f "migrate mulitple remote link files"
16236 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16237 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16238 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16239 skip "Need MDS version at least 2.11.52"
16241 mkdir -p $DIR/$tdir/migrate_dir
16243 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
16244 error "migrating dir to non-exist MDT succeeds"
16247 run_test 230g "migrate dir to non-exist MDT"
16250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16251 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16252 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16253 skip "Need MDS version at least 2.11.52"
16257 mkdir -p $DIR/$tdir/migrate_dir
16259 $LFS migrate -m1 $DIR &&
16260 error "migrating mountpoint1 should fail"
16262 $LFS migrate -m1 $DIR/$tdir/.. &&
16263 error "migrating mountpoint2 should fail"
16266 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
16267 error "migrating $tdir/migrate_dir/.. should fail"
16271 run_test 230h "migrate .. and root"
16274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16275 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16276 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16277 skip "Need MDS version at least 2.11.52"
16279 mkdir -p $DIR/$tdir/migrate_dir
16281 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
16282 error "migration fails with a tailing slash"
16284 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
16285 error "migration fails with two tailing slashes"
16287 run_test 230i "lfs migrate -m tolerates trailing slashes"
16290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16291 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
16292 skip "Need MDS version at least 2.11.52"
16294 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
16295 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
16296 error "create $tfile failed"
16297 cat /etc/passwd > $DIR/$tdir/$tfile
16299 $LFS migrate -m 1 $DIR/$tdir
16301 cmp /etc/passwd $DIR/$tdir/$tfile ||
16302 error "DoM file mismatch after migration"
16304 run_test 230j "DoM file data not changed after dir migration"
16307 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
16308 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16309 skip "Need MDS version at least 2.11.56"
16312 local files_on_starting_mdt=0
16314 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
16315 $LFS getdirstripe $DIR/$tdir
16316 for i in $(seq $total); do
16317 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
16318 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16319 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16322 echo "$files_on_starting_mdt files on MDT0"
16324 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
16325 $LFS getdirstripe $DIR/$tdir
16327 files_on_starting_mdt=0
16328 for i in $(seq $total); do
16329 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16330 error "file $tfile.$i mismatch after migration"
16331 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
16332 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16335 echo "$files_on_starting_mdt files on MDT1 after migration"
16336 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
16338 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
16339 $LFS getdirstripe $DIR/$tdir
16341 files_on_starting_mdt=0
16342 for i in $(seq $total); do
16343 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
16344 error "file $tfile.$i mismatch after 2nd migration"
16345 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
16346 files_on_starting_mdt=$((files_on_starting_mdt + 1))
16349 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
16350 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
16354 run_test 230k "file data not changed after dir migration"
16357 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16358 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16359 skip "Need MDS version at least 2.11.56"
16361 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
16362 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
16363 error "create files under remote dir failed $i"
16364 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
16366 run_test 230l "readdir between MDTs won't crash"
16369 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
16370 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
16371 skip "Need MDS version at least 2.11.56"
16374 local mig_dir=$DIR/$tdir/migrate_dir
16375 local longstr="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
16379 echo "Creating files and dirs with xattrs"
16380 test_mkdir $DIR/$tdir
16381 test_mkdir -i0 -c1 $mig_dir
16383 setfattr -n user.attr1 -v $longstr $mig_dir/dir ||
16384 error "cannot set xattr attr1 on dir"
16385 setfattr -n user.attr2 -v $shortstr $mig_dir/dir ||
16386 error "cannot set xattr attr2 on dir"
16387 touch $mig_dir/dir/f0
16388 setfattr -n user.attr1 -v $longstr $mig_dir/dir/f0 ||
16389 error "cannot set xattr attr1 on file"
16390 setfattr -n user.attr2 -v $shortstr $mig_dir/dir/f0 ||
16391 error "cannot set xattr attr2 on file"
16392 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16393 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16394 [ "$val" = $longstr ] || error "xattr attr1 not set properly on dir"
16395 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16396 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on dir"
16397 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16398 [ "$val" = $longstr ] || error "xattr attr1 not set properly on file"
16399 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16400 [ "$val" = $shortstr ] || error "xattr attr2 not set properly on file"
16402 echo "Migrating to MDT1"
16403 $LFS migrate -m $MDTIDX $mig_dir ||
16404 error "fails on migrating dir to MDT1"
16406 sync ; sync ; echo 3 > /proc/sys/vm/drop_caches
16407 echo "Checking xattrs"
16408 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir 2>/dev/null)
16409 [ "$val" = $longstr ] ||
16410 error "expecting xattr1 $longstr on dir, found $val"
16411 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir 2>/dev/null)
16412 [ "$val" = $shortstr ] ||
16413 error "expecting xattr2 $shortstr on dir, found $val"
16414 val=$(getfattr --only-values -n user.attr1 $mig_dir/dir/f0 2>/dev/null)
16415 [ "$val" = $longstr ] ||
16416 error "expecting xattr1 $longstr on file, found $val"
16417 val=$(getfattr --only-values -n user.attr2 $mig_dir/dir/f0 2>/dev/null)
16418 [ "$val" = $shortstr ] ||
16419 error "expecting xattr2 $shortstr on file, found $val"
16421 run_test 230m "xattrs not changed after dir migration"
16425 # For simplicity this test assumes that max_pages_per_rpc
16426 # is the same across all OSCs
16427 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
16428 local bulk_size=$((max_pages * PAGE_SIZE))
16429 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
16432 mkdir -p $DIR/$tdir
16433 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
16434 error "failed to set stripe with -S ${brw_size}M option"
16436 # clear the OSC stats
16437 $LCTL set_param osc.*.stats=0 &>/dev/null
16440 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
16441 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
16442 oflag=direct &>/dev/null || error "dd failed"
16444 sync; sleep 1; sync # just to be safe
16445 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
16446 if [ x$nrpcs != "x1" ]; then
16447 $LCTL get_param osc.*.stats
16448 error "found $nrpcs ost_write RPCs, not 1 as expected"
16452 # Drop the OSC cache, otherwise we will read from it
16453 cancel_lru_locks osc
16455 # clear the OSC stats
16456 $LCTL set_param osc.*.stats=0 &>/dev/null
16458 # Client reads $bulk_size.
16459 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
16460 iflag=direct &>/dev/null || error "dd failed"
16462 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
16463 if [ x$nrpcs != "x1" ]; then
16464 $LCTL get_param osc.*.stats
16465 error "found $nrpcs ost_read RPCs, not 1 as expected"
16468 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
16471 mkdir -p $DIR/$tdir
16473 for i in {0..1023}; do
16474 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
16475 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
16476 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
16480 run_test 231b "must not assert on fully utilized OST request buffer"
16483 mkdir -p $DIR/$tdir
16484 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16486 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16487 do_facet ost1 $LCTL set_param fail_loc=0x31c
16489 # ignore dd failure
16490 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
16492 do_facet ost1 $LCTL set_param fail_loc=0
16493 umount_client $MOUNT || error "umount failed"
16494 mount_client $MOUNT || error "mount failed"
16495 stop ost1 || error "cannot stop ost1"
16496 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16498 run_test 232a "failed lock should not block umount"
16501 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
16502 skip "Need MDS version at least 2.10.58"
16504 mkdir -p $DIR/$tdir
16505 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
16506 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
16508 cancel_lru_locks osc
16510 #define OBD_FAIL_LDLM_OST_LVB 0x31c
16511 do_facet ost1 $LCTL set_param fail_loc=0x31c
16514 $LFS data_version $DIR/$tdir/$tfile || true
16516 do_facet ost1 $LCTL set_param fail_loc=0
16517 umount_client $MOUNT || error "umount failed"
16518 mount_client $MOUNT || error "mount failed"
16519 stop ost1 || error "cannot stop ost1"
16520 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16522 run_test 232b "failed data version lock should not block umount"
16525 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
16526 skip "Need MDS version at least 2.3.64"
16527 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16529 local fid=$($LFS path2fid $MOUNT)
16531 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16532 error "cannot access $MOUNT using its FID '$fid'"
16534 run_test 233a "checking that OBF of the FS root succeeds"
16537 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
16538 skip "Need MDS version at least 2.5.90"
16539 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
16541 local fid=$($LFS path2fid $MOUNT/.lustre)
16543 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16544 error "cannot access $MOUNT/.lustre using its FID '$fid'"
16546 fid=$($LFS path2fid $MOUNT/.lustre/fid)
16547 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
16548 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
16550 run_test 233b "checking that OBF of the FS .lustre succeeds"
16553 local p="$TMP/sanityN-$TESTNAME.parameters"
16554 save_lustre_params client "llite.*.xattr_cache" > $p
16555 lctl set_param llite.*.xattr_cache 1 ||
16556 skip_env "xattr cache is not supported"
16558 mkdir -p $DIR/$tdir || error "mkdir failed"
16559 touch $DIR/$tdir/$tfile || error "touch failed"
16560 # OBD_FAIL_LLITE_XATTR_ENOMEM
16561 $LCTL set_param fail_loc=0x1405
16562 getfattr -n user.attr $DIR/$tdir/$tfile &&
16563 error "getfattr should have failed with ENOMEM"
16564 $LCTL set_param fail_loc=0x0
16567 restore_lustre_params < $p
16570 run_test 234 "xattr cache should not crash on ENOMEM"
16573 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
16574 skip "Need MDS version at least 2.4.52"
16576 flock_deadlock $DIR/$tfile
16581 124) error "process hangs on a deadlock"
16583 *) error "error executing flock_deadlock $DIR/$tfile"
16587 run_test 235 "LU-1715: flock deadlock detection does not work properly"
16591 check_swap_layouts_support
16593 local ref1=/etc/passwd
16594 local ref2=/etc/group
16595 local file1=$DIR/$tdir/f1
16596 local file2=$DIR/$tdir/f2
16598 test_mkdir -c1 $DIR/$tdir
16599 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
16600 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
16601 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
16602 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
16603 local fd=$(free_fd)
16604 local cmd="exec $fd<>$file2"
16607 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
16608 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
16611 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
16616 run_test 236 "Layout swap on open unlinked file"
16618 # LU-4659 linkea consistency
16620 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
16621 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
16622 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
16623 skip "Need MDS version at least 2.5.58 or 2.5.2+"
16626 ln $DIR/$tfile $DIR/$tfile.lnk
16627 touch $DIR/$tfile.new
16628 mv $DIR/$tfile.new $DIR/$tfile
16629 local fid1=$($LFS path2fid $DIR/$tfile)
16630 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
16631 local path1=$($LFS fid2path $FSNAME "$fid1")
16632 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
16633 local path2=$($LFS fid2path $FSNAME "$fid2")
16634 [ $tfile.lnk == $path2 ] ||
16635 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
16638 run_test 238 "Verify linkea consistency"
16640 test_239A() { # was test_239
16641 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
16642 skip "Need MDS version at least 2.5.60"
16644 local list=$(comma_list $(mdts_nodes))
16646 mkdir -p $DIR/$tdir
16647 createmany -o $DIR/$tdir/f- 5000
16648 unlinkmany $DIR/$tdir/f- 5000
16649 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
16650 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
16651 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
16652 osp.*MDT*.sync_in_flight" | calc_sum)
16653 [ "$changes" -eq 0 ] || error "$changes not synced"
16655 run_test 239A "osp_sync test"
16657 test_239a() { #LU-5297
16658 remote_mds_nodsh && skip "remote MDS with nodsh"
16661 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
16662 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
16663 chgrp $RUNAS_GID $DIR/$tfile
16664 wait_delete_completed
16666 run_test 239a "process invalid osp sync record correctly"
16668 test_239b() { #LU-5297
16669 remote_mds_nodsh && skip "remote MDS with nodsh"
16672 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
16673 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
16674 chgrp $RUNAS_GID $DIR/$tfile1
16675 wait_delete_completed
16676 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
16678 chgrp $RUNAS_GID $DIR/$tfile2
16679 wait_delete_completed
16681 run_test 239b "process osp sync record with ENOMEM error correctly"
16684 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
16685 remote_mds_nodsh && skip "remote MDS with nodsh"
16687 mkdir -p $DIR/$tdir
16689 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
16690 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
16691 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
16692 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
16694 umount_client $MOUNT || error "umount failed"
16695 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
16696 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
16697 mount_client $MOUNT || error "failed to mount client"
16699 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
16700 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
16702 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
16708 for LOOP in $(seq $count); do
16709 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
16710 cancel_lru_locks $OSC || true
16718 for LOOP in $(seq $1); do
16719 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
16724 test_241a() { # was test_241
16725 local bsize=$PAGE_SIZE
16727 (( bsize < 40960 )) && bsize=40960
16728 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16730 cancel_lru_locks $OSC
16731 test_241_bio 1000 $bsize &
16733 test_241_dio 1000 $bsize
16736 run_test 241a "bio vs dio"
16739 local bsize=$PAGE_SIZE
16741 (( bsize < 40960 )) && bsize=40960
16742 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
16744 test_241_dio 1000 $bsize &
16746 test_241_dio 1000 $bsize
16749 run_test 241b "dio vs dio"
16752 remote_mds_nodsh && skip "remote MDS with nodsh"
16754 mkdir -p $DIR/$tdir
16755 touch $DIR/$tdir/$tfile
16757 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
16758 do_facet mds1 lctl set_param fail_loc=0x105
16759 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
16761 do_facet mds1 lctl set_param fail_loc=0
16762 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
16764 run_test 242 "mdt_readpage failure should not cause directory unreadable"
16768 test_mkdir $DIR/$tdir
16769 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
16771 run_test 243 "various group lock tests"
16775 test_mkdir $DIR/$tdir
16776 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
16777 sendfile_grouplock $DIR/$tdir/$tfile || \
16778 error "sendfile+grouplock failed"
16781 run_test 244 "sendfile with group lock tests"
16784 local flagname="multi_mod_rpcs"
16785 local connect_data_name="max_mod_rpcs"
16788 # check if multiple modify RPCs flag is set
16789 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
16790 grep "connect_flags:")
16793 echo "$out" | grep -qw $flagname
16794 if [ $? -ne 0 ]; then
16795 echo "connect flag $flagname is not set"
16799 # check if multiple modify RPCs data is set
16800 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
16803 echo "$out" | grep -qw $connect_data_name ||
16804 error "import should have connect data $connect_data_name"
16806 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
16808 test_246() { # LU-7371
16809 remote_ost_nodsh && skip "remote OST with nodsh"
16810 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
16811 skip "Need OST version >= 2.7.62"
16813 do_facet ost1 $LCTL set_param fail_val=4095
16814 #define OBD_FAIL_OST_READ_SIZE 0x234
16815 do_facet ost1 $LCTL set_param fail_loc=0x234
16816 $LFS setstripe $DIR/$tfile -i 0 -c 1
16817 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
16818 cancel_lru_locks $FSNAME-OST0000
16819 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
16821 run_test 246 "Read file of size 4095 should return right length"
16827 umount_client $submount
16832 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16834 skip_env "Fileset feature is not supported"
16836 local submount=${MOUNT}_$tdir
16839 mkdir -p $submount || error "mkdir $submount failed"
16840 FILESET="$FILESET/$tdir" mount_client $submount ||
16841 error "mount $submount failed"
16842 trap "cleanup_247 $submount" EXIT
16843 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
16844 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
16845 error "read $MOUNT/$tdir/$tfile failed"
16846 cleanup_247 $submount
16848 run_test 247a "mount subdir as fileset"
16851 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16852 skip_env "Fileset feature is not supported"
16854 local submount=${MOUNT}_$tdir
16856 rm -rf $MOUNT/$tdir
16857 mkdir -p $submount || error "mkdir $submount failed"
16859 FILESET="$FILESET/$tdir" mount_client $submount &&
16860 error "mount $submount should fail"
16863 run_test 247b "mount subdir that dose not exist"
16866 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16867 skip_env "Fileset feature is not supported"
16869 local submount=${MOUNT}_$tdir
16871 mkdir -p $MOUNT/$tdir/dir1
16872 mkdir -p $submount || error "mkdir $submount failed"
16873 trap "cleanup_247 $submount" EXIT
16874 FILESET="$FILESET/$tdir" mount_client $submount ||
16875 error "mount $submount failed"
16876 local fid=$($LFS path2fid $MOUNT/)
16877 $LFS fid2path $submount $fid && error "fid2path should fail"
16878 cleanup_247 $submount
16880 run_test 247c "running fid2path outside root"
16883 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16884 skip "Fileset feature is not supported"
16886 local submount=${MOUNT}_$tdir
16888 mkdir -p $MOUNT/$tdir/dir1
16889 mkdir -p $submount || error "mkdir $submount failed"
16890 FILESET="$FILESET/$tdir" mount_client $submount ||
16891 error "mount $submount failed"
16892 trap "cleanup_247 $submount" EXIT
16893 local fid=$($LFS path2fid $submount/dir1)
16894 $LFS fid2path $submount $fid || error "fid2path should succeed"
16895 cleanup_247 $submount
16897 run_test 247d "running fid2path inside root"
16901 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16903 skip "Fileset feature is not supported"
16905 local submount=${MOUNT}_$tdir
16908 mkdir -p $submount || error "mkdir $submount failed"
16909 FILESET="$FILESET/.." mount_client $submount &&
16910 error "mount $submount should fail"
16913 run_test 247e "mount .. as fileset"
16916 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
16917 [ -z "$fast_read_sav" ] && skip "no fast read support"
16919 # create a large file for fast read verification
16920 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
16922 # make sure the file is created correctly
16923 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
16924 { rm -f $DIR/$tfile; skip "file creation error"; }
16926 echo "Test 1: verify that fast read is 4 times faster on cache read"
16928 # small read with fast read enabled
16929 $LCTL set_param -n llite.*.fast_read=1
16930 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16931 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16932 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16933 # small read with fast read disabled
16934 $LCTL set_param -n llite.*.fast_read=0
16935 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16936 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16937 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16939 # verify that fast read is 4 times faster for cache read
16940 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
16941 error_not_in_vm "fast read was not 4 times faster: " \
16942 "$t_fast vs $t_slow"
16944 echo "Test 2: verify the performance between big and small read"
16945 $LCTL set_param -n llite.*.fast_read=1
16947 # 1k non-cache read
16948 cancel_lru_locks osc
16949 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16950 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16951 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16953 # 1M non-cache read
16954 cancel_lru_locks osc
16955 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16956 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16957 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16959 # verify that big IO is not 4 times faster than small IO
16960 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
16961 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
16963 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
16966 run_test 248 "fast read verification"
16968 test_249() { # LU-7890
16969 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
16970 skip "Need at least version 2.8.54"
16973 $SETSTRIPE -c 1 $DIR/$tfile
16974 # Offset 2T == 4k * 512M
16975 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
16976 error "dd to 2T offset failed"
16978 run_test 249 "Write above 2T file size"
16981 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
16982 && skip "no 16TB file size limit on ZFS"
16984 $SETSTRIPE -c 1 $DIR/$tfile
16985 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
16986 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
16987 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
16988 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
16989 conv=notrunc,fsync && error "append succeeded"
16992 run_test 250 "Write above 16T limit"
16995 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
16997 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
16998 #Skip once - writing the first stripe will succeed
16999 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17000 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
17001 error "short write happened"
17003 $LCTL set_param fail_loc=0xa0001407 fail_val=1
17004 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
17005 error "short read happened"
17009 run_test 251 "Handling short read and write correctly"
17012 remote_mds_nodsh && skip "remote MDS with nodsh"
17013 remote_ost_nodsh && skip "remote OST with nodsh"
17014 if [ "$ost1_FSTYPE" != "ldiskfs" -o "$mds1_FSTYPE" != "ldiskfs" ]; then
17015 skip_env "ldiskfs only test"
17025 # check lr_reader on OST0000
17027 dev=$(facet_device $tgt)
17028 out=$(do_facet $tgt $LR_READER $dev)
17029 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17031 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
17032 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
17033 error "Invalid uuid returned by $LR_READER on target $tgt"
17034 echo -e "uuid returned by $LR_READER is '$uuid'\n"
17036 # check lr_reader -c on MDT0000
17038 dev=$(facet_device $tgt)
17039 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
17040 skip "$LR_READER does not support additional options"
17042 out=$(do_facet $tgt $LR_READER -c $dev)
17043 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17045 num=$(echo "$out" | grep -c "mdtlov")
17046 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
17047 error "Invalid number of mdtlov clients returned by $LR_READER"
17048 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
17050 # check lr_reader -cr on MDT0000
17051 out=$(do_facet $tgt $LR_READER -cr $dev)
17052 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
17054 echo "$out" | grep -q "^reply_data:$" ||
17055 error "$LR_READER should have returned 'reply_data' section"
17056 num=$(echo "$out" | grep -c "client_generation")
17057 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
17059 run_test 252 "check lr_reader tool"
17061 test_253_fill_ost() {
17062 local size_mb #how many MB should we write to pass watermark
17063 local lwm=$3 #low watermark
17064 local free_10mb #10% of free space
17066 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17067 size_mb=$((free_kb / 1024 - lwm))
17068 free_10mb=$((free_kb / 10240))
17069 #If 10% of free space cross low watermark use it
17070 if (( free_10mb > size_mb )); then
17073 #At least we need to store 1.1 of difference between
17074 #free space and low watermark
17075 size_mb=$((size_mb + size_mb / 10))
17077 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
17078 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
17079 oflag=append conv=notrunc
17084 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
17085 echo "OST still has $((free_kb / 1024)) mbytes free"
17089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17090 remote_mds_nodsh && skip "remote MDS with nodsh"
17091 remote_mgs_nodsh && skip "remote MGS with nodsh"
17096 local ost_name=$($LFS osts |
17097 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
17099 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
17100 do_facet $SINGLEMDS $LCTL get_param -n \
17101 osp.$mdtosc_proc1.reserved_mb_high ||
17102 skip "remote MDS does not support reserved_mb_high"
17106 wait_delete_completed
17109 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
17110 osp.$mdtosc_proc1.reserved_mb_high)
17111 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
17112 osp.$mdtosc_proc1.reserved_mb_low)
17113 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
17115 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
17116 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
17117 error "Adding $ost_name to pool failed"
17119 # Wait for client to see a OST at pool
17120 wait_update $HOSTNAME "$LCTL get_param -n
17121 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
17122 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
17123 error "Client can not see the pool"
17124 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
17125 error "Setstripe failed"
17127 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
17128 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
17129 echo "OST still has $((blocks/1024)) mbytes free"
17131 local new_lwm=$((blocks/1024-10))
17132 do_facet $SINGLEMDS $LCTL set_param \
17133 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
17134 do_facet $SINGLEMDS $LCTL set_param \
17135 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
17137 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17139 #First enospc could execute orphan deletion so repeat.
17140 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
17142 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17143 osp.$mdtosc_proc1.prealloc_status)
17144 echo "prealloc_status $oa_status"
17146 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
17147 error "File creation should fail"
17148 #object allocation was stopped, but we still able to append files
17149 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
17150 error "Append failed"
17151 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
17153 wait_delete_completed
17157 for i in $(seq 10 12); do
17158 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
17159 error "File creation failed after rm";
17162 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
17163 osp.$mdtosc_proc1.prealloc_status)
17164 echo "prealloc_status $oa_status"
17166 if (( oa_status != 0 )); then
17167 error "Object allocation still disable after rm"
17169 do_facet $SINGLEMDS $LCTL set_param \
17170 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
17171 do_facet $SINGLEMDS $LCTL set_param \
17172 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
17175 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
17176 error "Remove $ost_name from pool failed"
17177 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
17178 error "Pool destroy fialed"
17180 run_test 253 "Check object allocation limit"
17183 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17184 remote_mds_nodsh && skip "remote MDS with nodsh"
17185 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
17186 skip "MDS does not support changelog_size"
17189 local MDT0=$(facet_svc $SINGLEMDS)
17191 changelog_register || error "changelog_register failed"
17193 changelog_clear 0 || error "changelog_clear failed"
17195 local size1=$(do_facet $SINGLEMDS \
17196 $LCTL get_param -n mdd.$MDT0.changelog_size)
17197 echo "Changelog size $size1"
17200 $LFS mkdir -i 0 $DIR/$tdir
17202 mkdir -p $DIR/$tdir/pics/2008/zachy
17203 touch $DIR/$tdir/pics/2008/zachy/timestamp
17204 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
17205 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
17206 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
17207 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
17208 rm $DIR/$tdir/pics/desktop.jpg
17210 local size2=$(do_facet $SINGLEMDS \
17211 $LCTL get_param -n mdd.$MDT0.changelog_size)
17212 echo "Changelog size after work $size2"
17214 (( $size2 > $size1 )) ||
17215 error "new Changelog size=$size2 less than old size=$size1"
17217 run_test 254 "Check changelog size"
17224 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
17225 awk -F: '{print $2}' | grep $type > /dev/null
17226 if [ $? -ne 0 ]; then
17236 lfs ladvise -a willread $file > /dev/null 2>&1
17237 if [ $? -eq 0 ]; then
17241 lfs ladvise -a willread $file 2>&1 |
17242 grep "Inappropriate ioctl for device" > /dev/null
17243 if [ $? -eq 0 ]; then
17250 bc <<<"scale=2; ($1 - $2) * 100 / $2"
17253 # run a random read IO workload
17254 # usage: random_read_iops <filename> <filesize> <iosize>
17255 random_read_iops() {
17258 local iosize=${3:-4096}
17260 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
17261 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
17264 drop_file_oss_cache() {
17268 $LFS ladvise -a dontneed $file 2>/dev/null ||
17269 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
17272 ladvise_willread_performance()
17275 local average_origin=0
17276 local average_cache=0
17277 local average_ladvise=0
17279 for ((i = 1; i <= $repeat; i++)); do
17280 echo "Iter $i/$repeat: reading without willread hint"
17281 cancel_lru_locks osc
17282 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17283 local speed_origin=$(random_read_iops $DIR/$tfile $size)
17284 echo "Iter $i/$repeat: uncached speed: $speed_origin"
17285 average_origin=$(bc <<<"$average_origin + $speed_origin")
17287 cancel_lru_locks osc
17288 local speed_cache=$(random_read_iops $DIR/$tfile $size)
17289 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
17290 average_cache=$(bc <<<"$average_cache + $speed_cache")
17292 cancel_lru_locks osc
17293 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
17294 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
17295 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
17296 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
17297 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
17299 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
17300 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
17301 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
17303 speedup_cache=$(percent $average_cache $average_origin)
17304 speedup_ladvise=$(percent $average_ladvise $average_origin)
17306 echo "Average uncached read: $average_origin"
17307 echo "Average speedup with OSS cached read: " \
17308 "$average_cache = +$speedup_cache%"
17309 echo "Average speedup with ladvise willread: " \
17310 "$average_ladvise = +$speedup_ladvise%"
17312 local lowest_speedup=20
17313 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
17314 echo "Speedup with OSS cached read less than $lowest_speedup%," \
17315 "got $average_cache%. Skipping ladvise willread check."
17319 # the test won't work on ZFS until it supports 'ladvise dontneed', but
17320 # it is still good to run until then to exercise 'ladvise willread'
17321 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17322 [ "$ost1_FSTYPE" = "zfs" ] &&
17323 echo "osd-zfs does not support dontneed or drop_caches" &&
17326 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
17327 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
17328 error_not_in_vm "Speedup with willread is less than " \
17329 "$lowest_speedup%, got $average_ladvise%"
17333 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17334 skip "lustre < 2.8.54 does not support ladvise "
17335 remote_ost_nodsh && skip "remote OST with nodsh"
17337 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
17339 ladvise_no_type willread $DIR/$tfile &&
17340 skip "willread ladvise is not supported"
17342 ladvise_no_ioctl $DIR/$tfile &&
17343 skip "ladvise ioctl is not supported"
17346 local size=$((size_mb * 1048576))
17347 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17348 error "dd to $DIR/$tfile failed"
17350 lfs ladvise -a willread $DIR/$tfile ||
17351 error "Ladvise failed with no range argument"
17353 lfs ladvise -a willread -s 0 $DIR/$tfile ||
17354 error "Ladvise failed with no -l or -e argument"
17356 lfs ladvise -a willread -e 1 $DIR/$tfile ||
17357 error "Ladvise failed with only -e argument"
17359 lfs ladvise -a willread -l 1 $DIR/$tfile ||
17360 error "Ladvise failed with only -l argument"
17362 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
17363 error "End offset should not be smaller than start offset"
17365 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
17366 error "End offset should not be equal to start offset"
17368 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
17369 error "Ladvise failed with overflowing -s argument"
17371 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
17372 error "Ladvise failed with overflowing -e argument"
17374 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
17375 error "Ladvise failed with overflowing -l argument"
17377 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
17378 error "Ladvise succeeded with conflicting -l and -e arguments"
17380 echo "Synchronous ladvise should wait"
17382 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
17383 do_nodes $(comma_list $(osts_nodes)) \
17384 $LCTL set_param fail_val=$delay fail_loc=0x237
17386 local start_ts=$SECONDS
17387 lfs ladvise -a willread $DIR/$tfile ||
17388 error "Ladvise failed with no range argument"
17389 local end_ts=$SECONDS
17390 local inteval_ts=$((end_ts - start_ts))
17392 if [ $inteval_ts -lt $(($delay - 1)) ]; then
17393 error "Synchronous advice didn't wait reply"
17396 echo "Asynchronous ladvise shouldn't wait"
17397 local start_ts=$SECONDS
17398 lfs ladvise -a willread -b $DIR/$tfile ||
17399 error "Ladvise failed with no range argument"
17400 local end_ts=$SECONDS
17401 local inteval_ts=$((end_ts - start_ts))
17403 if [ $inteval_ts -gt $(($delay / 2)) ]; then
17404 error "Asynchronous advice blocked"
17407 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
17408 ladvise_willread_performance
17410 run_test 255a "check 'lfs ladvise -a willread'"
17416 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
17420 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
17421 skip "lustre < 2.8.54 does not support ladvise "
17422 remote_ost_nodsh && skip "remote OST with nodsh"
17424 lfs setstripe -c 1 -i 0 $DIR/$tfile
17426 ladvise_no_type dontneed $DIR/$tfile &&
17427 skip "dontneed ladvise is not supported"
17429 ladvise_no_ioctl $DIR/$tfile &&
17430 skip "ladvise ioctl is not supported"
17432 ! $LFS ladvise -a dontneed $DIR/$tfile &&
17433 [ "$ost1_FSTYPE" = "zfs" ] &&
17434 skip "zfs-osd does not support 'ladvise dontneed'"
17437 local size=$((size_mb * 1048576))
17438 # In order to prevent disturbance of other processes, only check 3/4
17439 # of the memory usage
17440 local kibibytes=$((size_mb * 1024 * 3 / 4))
17442 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
17443 error "dd to $DIR/$tfile failed"
17445 #force write to complete before dropping OST cache & checking memory
17448 local total=$(facet_meminfo ost1 MemTotal)
17449 echo "Total memory: $total KiB"
17451 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
17452 local before_read=$(facet_meminfo ost1 Cached)
17453 echo "Cache used before read: $before_read KiB"
17455 lfs ladvise -a willread $DIR/$tfile ||
17456 error "Ladvise willread failed"
17457 local after_read=$(facet_meminfo ost1 Cached)
17458 echo "Cache used after read: $after_read KiB"
17460 lfs ladvise -a dontneed $DIR/$tfile ||
17461 error "Ladvise dontneed again failed"
17462 local no_read=$(facet_meminfo ost1 Cached)
17463 echo "Cache used after dontneed ladvise: $no_read KiB"
17465 if [ $total -lt $((before_read + kibibytes)) ]; then
17466 echo "Memory is too small, abort checking"
17470 if [ $((before_read + kibibytes)) -gt $after_read ]; then
17471 error "Ladvise willread should use more memory" \
17472 "than $kibibytes KiB"
17475 if [ $((no_read + kibibytes)) -gt $after_read ]; then
17476 error "Ladvise dontneed should release more memory" \
17477 "than $kibibytes KiB"
17480 run_test 255b "check 'lfs ladvise -a dontneed'"
17483 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
17484 skip "lustre < 2.10.50 does not support lockahead"
17492 test_mkdir -p $DIR/$tdir
17493 $SETSTRIPE -i 0 $DIR/$tdir
17495 #test 10 returns only success/failure
17497 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17499 if [ $rc -eq 255 ]; then
17500 error "Ladvise test${i} failed, ${rc}"
17503 #test 11 counts lock enqueue requests, all others count new locks
17505 count=$(do_facet ost1 \
17506 $LCTL get_param -n ost.OSS.ost.stats)
17507 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
17509 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17511 if [ $rc -eq 255 ]; then
17512 error "Ladvise test${i} failed, ${rc}"
17515 new_count=$(do_facet ost1 \
17516 $LCTL get_param -n ost.OSS.ost.stats)
17517 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
17518 awk '{ print $2 }')
17520 difference="$((new_count - count))"
17521 if [ $difference -ne $rc ]; then
17522 error "Ladvise test${i}, bad enqueue count, returned " \
17523 "${rc}, actual ${difference}"
17526 for i in $(seq 12 21); do
17527 # If we do not do this, we run the risk of having too many
17528 # locks and starting lock cancellation while we are checking
17530 cancel_lru_locks osc
17532 count=$($LCTL get_param -n \
17533 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17535 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17537 if [ $rc -eq 255 ]; then
17538 error "Ladvise test ${i} failed, ${rc}"
17541 new_count=$($LCTL get_param -n \
17542 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
17543 difference="$((new_count - count))"
17545 # Test 15 output is divided by 100 to map down to valid return
17546 if [ $i -eq 15 ]; then
17550 if [ $difference -ne $rc ]; then
17551 error "Ladvise test ${i}, bad lock count, returned " \
17552 "${rc}, actual ${difference}"
17556 #test 22 returns only success/failure
17558 lockahead_test -d $DIR/$tdir -t $i -f $tfile
17560 if [ $rc -eq 255 ]; then
17561 error "Ladvise test${i} failed, ${rc}"
17564 run_test 255c "suite of ladvise lockahead tests"
17567 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17568 remote_mds_nodsh && skip "remote MDS with nodsh"
17569 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17570 changelog_users $SINGLEMDS | grep "^cl" &&
17571 skip "active changelog user"
17577 mdt_dev=$(mdsdevname 1)
17580 changelog_register || error "changelog_register failed"
17583 mkdir -p $DIR/$tdir
17585 changelog_clear 0 || error "changelog_clear failed"
17588 touch $DIR/$tdir/{1..10}
17591 stop $SINGLEMDS || error "Fail to stop MDT"
17595 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
17597 #after mount new plainllog is used
17598 touch $DIR/$tdir/{11..19}
17599 local tmpfile=$(mktemp -u $tfile.XXXXXX)
17600 cat_sl=$(do_facet $SINGLEMDS "sync; \
17601 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17602 llog_reader $tmpfile | grep -c type=1064553b")
17603 do_facet $SINGLEMDS llog_reader $tmpfile
17605 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
17607 changelog_clear 0 || error "changelog_clear failed"
17609 cat_sl=$(do_facet $SINGLEMDS "sync; \
17610 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
17611 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
17613 if (( cat_sl == 2 )); then
17614 error "Empty plain llog was not deleted from changelog catalog"
17615 elif (( cat_sl != 1 )); then
17616 error "Active plain llog shouldn't be deleted from catalog"
17619 run_test 256 "Check llog delete for empty and not full state"
17622 remote_mds_nodsh && skip "remote MDS with nodsh"
17623 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
17624 skip "Need MDS version at least 2.8.55"
17626 test_mkdir $DIR/$tdir
17628 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
17629 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
17632 #define OBD_FAIL_MDS_XATTR_REP 0x161
17633 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17634 local facet=mds$((mdtidx + 1))
17635 set_nodes_failloc $(facet_active_host $facet) 0x80000161
17636 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
17638 stop $facet || error "stop MDS failed"
17639 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
17640 error "start MDS fail"
17642 run_test 257 "xattr locks are not lost"
17644 # Verify we take the i_mutex when security requires it
17646 #define OBD_FAIL_IMUTEX_SEC 0x141c
17647 $LCTL set_param fail_loc=0x141c
17649 chmod u+s $DIR/$tfile
17650 chmod a+rwx $DIR/$tfile
17651 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17653 if [ $RC -ne 0 ]; then
17654 error "error, failed to take i_mutex, rc=$?"
17658 run_test 258a "verify i_mutex security behavior when suid attributes is set"
17660 # Verify we do NOT take the i_mutex in the normal case
17662 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
17663 $LCTL set_param fail_loc=0x141d
17666 chmod a+rw $DIR/$tfile
17667 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
17669 if [ $RC -ne 0 ]; then
17670 error "error, took i_mutex unnecessarily, rc=$?"
17675 run_test 258b "verify i_mutex security behavior"
17678 local file=$DIR/$tfile
17682 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
17684 stack_trap "rm -f $file" EXIT
17686 wait_delete_completed
17687 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17688 echo "before: $before"
17690 $LFS setstripe -i 0 -c 1 $file
17691 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
17693 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17694 echo "after write: $after"
17696 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
17697 do_facet ost1 $LCTL set_param fail_loc=0x2301
17699 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17700 echo "after truncate: $after"
17703 do_facet ost1 $LCTL set_param fail_loc=0
17704 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
17706 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
17707 echo "after restart: $after"
17708 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
17709 error "missing truncate?"
17713 run_test 259 "crash at delayed truncate"
17716 #define OBD_FAIL_MDC_CLOSE 0x806
17717 $LCTL set_param fail_loc=0x80000806
17721 run_test 260 "Check mdc_close fail"
17723 ### Data-on-MDT sanity tests ###
17725 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17726 skip "Need MDS version at least 2.10.55 for DoM"
17729 local dom=$DIR/$tdir/dom_file
17730 local tmp=$DIR/$tdir/tmp_file
17732 mkdir -p $DIR/$tdir
17734 # basic checks for DoM component creation
17735 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
17736 error "Can set MDT layout to non-first entry"
17738 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
17739 error "Can define multiple entries as MDT layout"
17741 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
17743 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
17744 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
17745 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
17747 local mdtidx=$($LFS getstripe -m $dom)
17748 local mdtname=MDT$(printf %04x $mdtidx)
17749 local facet=mds$((mdtidx + 1))
17750 local space_check=1
17752 # Skip free space checks with ZFS
17753 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
17757 local size_tmp=$((65536 * 3))
17758 local mdtfree1=$(do_facet $facet \
17759 lctl get_param -n osd*.*$mdtname.kbytesfree)
17761 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17762 # check also direct IO along write
17763 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
17764 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17766 cmp $tmp $dom || error "file data is different"
17767 [ $(stat -c%s $dom) == $size_tmp ] ||
17768 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17769 if [ $space_check == 1 ]; then
17770 local mdtfree2=$(do_facet $facet \
17771 lctl get_param -n osd*.*$mdtname.kbytesfree)
17773 # increase in usage from by $size_tmp
17774 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17775 error "MDT free space wrong after write: " \
17776 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17780 local size_dom=10000
17782 $TRUNCATE $dom $size_dom
17783 [ $(stat -c%s $dom) == $size_dom ] ||
17784 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
17785 if [ $space_check == 1 ]; then
17786 mdtfree1=$(do_facet $facet \
17787 lctl get_param -n osd*.*$mdtname.kbytesfree)
17788 # decrease in usage from $size_tmp to new $size_dom
17789 [ $(($mdtfree1 - $mdtfree2)) -ge \
17790 $(((size_tmp - size_dom) / 1024)) ] ||
17791 error "MDT free space is wrong after truncate: " \
17792 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
17798 size_dom=$((size_dom + size_tmp))
17799 [ $(stat -c%s $dom) == $size_dom ] ||
17800 error "bad size after append: $(stat -c%s $dom) != $size_dom"
17801 if [ $space_check == 1 ]; then
17802 mdtfree2=$(do_facet $facet \
17803 lctl get_param -n osd*.*$mdtname.kbytesfree)
17804 # increase in usage by $size_tmp from previous
17805 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17806 error "MDT free space is wrong after append: " \
17807 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17812 if [ $space_check == 1 ]; then
17813 mdtfree1=$(do_facet $facet \
17814 lctl get_param -n osd*.*$mdtname.kbytesfree)
17815 # decrease in usage by $size_dom from previous
17816 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
17817 error "MDT free space is wrong after removal: " \
17818 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
17821 # combined striping
17822 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
17823 error "Can't create DoM + OST striping"
17825 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
17826 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17827 # check also direct IO along write
17828 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17830 cmp $tmp $dom || error "file data is different"
17831 [ $(stat -c%s $dom) == $size_tmp ] ||
17832 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17837 run_test 270a "DoM: basic functionality tests"
17840 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17841 skip "Need MDS version at least 2.10.55"
17843 local dom=$DIR/$tdir/dom_file
17844 local max_size=1048576
17846 mkdir -p $DIR/$tdir
17847 $LFS setstripe -E $max_size -L mdt $dom
17849 # truncate over the limit
17850 $TRUNCATE $dom $(($max_size + 1)) &&
17851 error "successful truncate over the maximum size"
17852 # write over the limit
17853 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
17854 error "successful write over the maximum size"
17855 # append over the limit
17856 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
17857 echo "12345" >> $dom && error "successful append over the maximum size"
17862 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
17865 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17866 skip "Need MDS version at least 2.10.55"
17868 mkdir -p $DIR/$tdir
17869 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17871 # check files inherit DoM EA
17872 touch $DIR/$tdir/first
17873 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
17874 error "bad pattern"
17875 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
17876 error "bad stripe count"
17877 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
17878 error "bad stripe size"
17880 # check directory inherits DoM EA and uses it as default
17881 mkdir $DIR/$tdir/subdir
17882 touch $DIR/$tdir/subdir/second
17883 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
17884 error "bad pattern in sub-directory"
17885 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
17886 error "bad stripe count in sub-directory"
17887 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
17888 error "bad stripe size in sub-directory"
17891 run_test 270c "DoM: DoM EA inheritance tests"
17894 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17895 skip "Need MDS version at least 2.10.55"
17897 mkdir -p $DIR/$tdir
17898 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17900 # inherit default DoM striping
17901 mkdir $DIR/$tdir/subdir
17902 touch $DIR/$tdir/subdir/f1
17904 # change default directory striping
17905 $LFS setstripe -c 1 $DIR/$tdir/subdir
17906 touch $DIR/$tdir/subdir/f2
17907 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
17908 error "wrong default striping in file 2"
17909 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
17910 error "bad pattern in file 2"
17913 run_test 270d "DoM: change striping from DoM to RAID0"
17916 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17917 skip "Need MDS version at least 2.10.55"
17919 mkdir -p $DIR/$tdir/dom
17920 mkdir -p $DIR/$tdir/norm
17923 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
17924 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
17926 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
17927 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
17929 # find DoM files by layout
17930 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
17931 [ $NUM -eq $DOMFILES ] ||
17932 error "lfs find -L: found $NUM, expected $DOMFILES"
17933 echo "Test 1: lfs find 20 DOM files by layout: OK"
17935 # there should be 1 dir with default DOM striping
17936 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
17938 error "lfs find -L: found $NUM, expected 1 dir"
17939 echo "Test 2: lfs find 1 DOM dir by layout: OK"
17941 # find DoM files by stripe size
17942 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
17943 [ $NUM -eq $DOMFILES ] ||
17944 error "lfs find -S: found $NUM, expected $DOMFILES"
17945 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
17947 # find files by stripe offset except DoM files
17948 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
17949 [ $NUM -eq $NORMFILES ] ||
17950 error "lfs find -i: found $NUM, expected $NORMFILES"
17951 echo "Test 5: lfs find no DOM files by stripe index: OK"
17954 run_test 270e "DoM: lfs find with DoM files test"
17957 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17958 skip "Need MDS version at least 2.10.55"
17960 local mdtname=${FSNAME}-MDT0000-mdtlov
17961 local dom=$DIR/$tdir/dom_file
17962 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
17963 lod.$mdtname.dom_stripesize)
17964 local dom_limit=131072
17966 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
17967 local dom_current=$(do_facet mds1 $LCTL get_param -n \
17968 lod.$mdtname.dom_stripesize)
17969 [ ${dom_limit} -eq ${dom_current} ] ||
17970 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
17972 $LFS mkdir -i 0 -c 1 $DIR/$tdir
17973 $LFS setstripe -d $DIR/$tdir
17974 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
17975 error "Can't set directory default striping"
17977 # exceed maximum stripe size
17978 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17979 error "Can't create file with $((dom_limit * 2)) DoM stripe"
17980 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
17981 error "Able to create DoM component size more than LOD limit"
17983 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
17984 dom_current=$(do_facet mds1 $LCTL get_param -n \
17985 lod.$mdtname.dom_stripesize)
17986 [ 0 -eq ${dom_current} ] ||
17987 error "Can't set zero DoM stripe limit"
17990 # attempt to create DoM file on server with disabled DoM should
17991 # remove DoM entry from layout and be succeed
17992 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
17993 error "Can't create DoM file (DoM is disabled)"
17994 [ $($LFS getstripe -L $dom) == "mdt" ] &&
17995 error "File has DoM component while DoM is disabled"
17998 # attempt to create DoM file with only DoM stripe should return error
17999 $LFS setstripe -E $dom_limit -L mdt $dom &&
18000 error "Able to create DoM-only file while DoM is disabled"
18002 # too low values to be aligned with smallest stripe size 64K
18003 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
18004 dom_current=$(do_facet mds1 $LCTL get_param -n \
18005 lod.$mdtname.dom_stripesize)
18006 [ 30000 -eq ${dom_current} ] &&
18007 error "Can set too small DoM stripe limit"
18009 # 64K is a minimal stripe size in Lustre, expect limit of that size
18010 [ 65536 -eq ${dom_current} ] ||
18011 error "Limit is not set to 64K but ${dom_current}"
18013 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
18014 dom_current=$(do_facet mds1 $LCTL get_param -n \
18015 lod.$mdtname.dom_stripesize)
18017 [ 2147483648 -eq ${dom_current} ] &&
18018 error "Can set too large DoM stripe limit"
18020 do_facet mds1 $LCTL set_param -n \
18021 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
18022 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
18023 error "Can't create DoM component size after limit change"
18024 do_facet mds1 $LCTL set_param -n \
18025 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
18026 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
18027 error "Can't create DoM file after limit decrease"
18028 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
18029 error "Can create big DoM component after limit decrease"
18030 touch ${dom}_def ||
18031 error "Can't create file with old default layout"
18033 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
18036 run_test 270f "DoM: maximum DoM stripe size checks"
18039 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18040 skip "Need MDS version at least 2.10.55"
18042 local dom=$DIR/$tdir/dom
18044 mkdir -p $DIR/$tdir
18046 $LFS setstripe -E 1024K -L mdt $dom
18048 lctl set_param -n mdc.*.stats=clear
18049 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18050 cat $dom > /dev/null
18051 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
18052 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
18056 run_test 271a "DoM: data is cached for read after write"
18059 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18060 skip "Need MDS version at least 2.10.55"
18062 local dom=$DIR/$tdir/dom
18064 mkdir -p $DIR/$tdir
18066 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18068 lctl set_param -n mdc.*.stats=clear
18069 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
18070 cancel_lru_locks mdc
18071 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
18072 # second stat to check size is cached on client
18073 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
18074 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18075 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
18078 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
18081 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18082 skip "Need MDS version at least 2.10.55"
18084 local dom=$DIR/$tdir/dom
18086 mkdir -p $DIR/$tdir
18088 $LFS setstripe -E 1024K -L mdt -E EOF $dom
18090 lctl set_param -n mdc.*.stats=clear
18091 lctl set_param -n osc.*.stats=clear
18092 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
18093 cancel_lru_locks mdc
18094 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18095 # second stat to check size is cached on client
18096 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
18097 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
18098 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
18099 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
18100 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
18103 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
18109 local mdt=MDT$(printf %04x $mdtidx)
18111 if [ -z $param ]; then
18112 lctl get_param -n mdc.*$mdt*.stats
18114 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
18119 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
18120 skip "Need MDS version at least 2.10.55"
18122 local dom=$DIR/$tdir/dom
18124 mkdir -p $DIR/$tdir
18126 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18128 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
18129 local facet=mds$((mdtidx + 1))
18131 cancel_lru_locks mdc
18132 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
18133 createmany -o $dom 1000
18134 lctl set_param -n mdc.*.stats=clear
18135 smalliomany -w $dom 1000 200
18136 get_mdc_stats $mdtidx
18137 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18138 # Each file has 1 open, 1 IO enqueues, total 2000
18139 # but now we have also +1 getxattr for security.capability, total 3000
18140 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
18141 unlinkmany $dom 1000
18143 cancel_lru_locks mdc
18144 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
18145 createmany -o $dom 1000
18146 lctl set_param -n mdc.*.stats=clear
18147 smalliomany -w $dom 1000 200
18148 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
18149 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
18150 # for OPEN and IO lock.
18151 [ $((enq - enq_2)) -ge 1000 ] ||
18152 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
18153 unlinkmany $dom 1000
18156 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
18158 cleanup_271def_tests() {
18164 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18165 skip "Need MDS version at least 2.10.57"
18167 local dom=$DIR/$tdir/dom
18168 local tmp=$TMP/$tfile
18169 trap "cleanup_271def_tests $tmp" EXIT
18171 mkdir -p $DIR/$tdir
18173 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18175 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18177 cancel_lru_locks mdc
18178 dd if=/dev/urandom of=$tmp bs=1000 count=1
18179 dd if=$tmp of=$dom bs=1000 count=1
18180 cancel_lru_locks mdc
18182 cat /etc/hosts >> $tmp
18183 lctl set_param -n mdc.*.stats=clear
18185 # append data to the same file it should update local page
18186 echo "Append to the same page"
18187 cat /etc/hosts >> $dom
18188 local num=$(get_mdc_stats $mdtidx ost_read)
18189 local ra=$(get_mdc_stats $mdtidx req_active)
18190 local rw=$(get_mdc_stats $mdtidx req_waittime)
18192 [ -z $num ] || error "$num READ RPC occured"
18193 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18197 cmp $tmp $dom || error "file miscompare"
18199 cancel_lru_locks mdc
18200 lctl set_param -n mdc.*.stats=clear
18202 echo "Open and read file"
18203 cat $dom > /dev/null
18204 local num=$(get_mdc_stats $mdtidx ost_read)
18205 local ra=$(get_mdc_stats $mdtidx req_active)
18206 local rw=$(get_mdc_stats $mdtidx req_waittime)
18208 [ -z $num ] || error "$num READ RPC occured"
18209 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18213 cmp $tmp $dom || error "file miscompare"
18217 run_test 271d "DoM: read on open (1K file in reply buffer)"
18220 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
18221 skip "Need MDS version at least 2.10.57"
18223 local dom=$DIR/$tdir/dom
18224 local tmp=$TMP/$tfile
18225 trap "cleanup_271def_tests $tmp" EXIT
18227 mkdir -p $DIR/$tdir
18229 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
18231 local mdtidx=$($LFS getstripe --mdt-index $DIR/$tdir)
18233 cancel_lru_locks mdc
18234 dd if=/dev/urandom of=$tmp bs=200000 count=1
18235 dd if=$tmp of=$dom bs=200000 count=1
18236 cancel_lru_locks mdc
18237 cat /etc/hosts >> $tmp
18238 lctl set_param -n mdc.*.stats=clear
18240 echo "Append to the same page"
18241 cat /etc/hosts >> $dom
18242 local num=$(get_mdc_stats $mdtidx ost_read)
18243 local ra=$(get_mdc_stats $mdtidx req_active)
18244 local rw=$(get_mdc_stats $mdtidx req_waittime)
18246 [ -z $num ] || error "$num READ RPC occured"
18247 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18251 cmp $tmp $dom || error "file miscompare"
18253 cancel_lru_locks mdc
18254 lctl set_param -n mdc.*.stats=clear
18256 echo "Open and read file"
18257 cat $dom > /dev/null
18258 local num=$(get_mdc_stats $mdtidx ost_read)
18259 local ra=$(get_mdc_stats $mdtidx req_active)
18260 local rw=$(get_mdc_stats $mdtidx req_waittime)
18262 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
18263 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
18267 cmp $tmp $dom || error "file miscompare"
18271 run_test 271f "DoM: read on open (200K file and read tail)"
18274 [[ $($LCTL get_param mdc.*.import) =~ async_discard ]] ||
18275 skip "Skipping due to old client or server version"
18277 $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
18279 $CHECKSTAT -t file $DIR1/$tfile
18281 $MULTIOP $DIR1/$tfile Ow40960_w4096c &
18284 #define OBD_FAIL_LDLM_CANCEL_BL_CB_RACE
18285 $LCTL set_param fail_loc=0x80000314
18286 rm $DIR1/$tfile || error "Unlink fails"
18288 kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID || error "multiop failure"
18289 [ $RC -eq 0 ] || error "Failed write to stale object"
18291 run_test 271g "Discard DoM data vs client flush race"
18294 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18295 skip "Need MDS version at least 2.11.50"
18297 local dom=$DIR/$tdir/dom
18298 mkdir -p $DIR/$tdir
18300 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
18301 dd if=/dev/urandom of=$dom bs=512K count=1 ||
18302 error "failed to write data into $dom"
18303 local old_md5=$(md5sum $dom)
18305 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
18306 error "failed to migrate to the same DoM component"
18308 [ $($LFS getstripe -c $dom) -eq 2 ] ||
18309 error "layout was not changed silently"
18311 local new_md5=$(md5sum $dom)
18313 [ "$old_md5" != "$new_md5" ] &&
18314 error "md5sum differ: $old_md5, $new_md5"
18317 run_test 272a "DoM migration: new layout with the same DOM component"
18320 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18321 skip "Need MDS version at least 2.11.50"
18323 local dom=$DIR/$tdir/dom
18324 mkdir -p $DIR/$tdir
18325 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18327 local mdtidx=$($LFS getstripe -m $dom)
18328 local mdtname=MDT$(printf %04x $mdtidx)
18329 local facet=mds$((mdtidx + 1))
18331 local mdtfree1=$(do_facet $facet \
18332 lctl get_param -n osd*.*$mdtname.kbytesfree)
18333 dd if=/dev/urandom of=$dom bs=2M count=1 ||
18334 error "failed to write data into $dom"
18335 local old_md5=$(md5sum $dom)
18336 cancel_lru_locks mdc
18337 local mdtfree1=$(do_facet $facet \
18338 lctl get_param -n osd*.*$mdtname.kbytesfree)
18340 $LFS migrate -c2 $dom ||
18341 error "failed to migrate to the new composite layout"
18342 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18343 error "MDT stripe was not removed"
18345 cancel_lru_locks mdc
18346 local new_md5=$(md5sum $dom)
18347 [ "$old_md5" != "$new_md5" ] &&
18348 error "$old_md5 != $new_md5"
18350 # Skip free space checks with ZFS
18351 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18352 local mdtfree2=$(do_facet $facet \
18353 lctl get_param -n osd*.*$mdtname.kbytesfree)
18354 [ $mdtfree2 -gt $mdtfree1 ] ||
18355 error "MDT space is not freed after migration"
18359 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
18362 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18363 skip "Need MDS version at least 2.11.50"
18365 local dom=$DIR/$tdir/$tfile
18366 mkdir -p $DIR/$tdir
18367 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
18369 local mdtidx=$($LFS getstripe -m $dom)
18370 local mdtname=MDT$(printf %04x $mdtidx)
18371 local facet=mds$((mdtidx + 1))
18373 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
18374 error "failed to write data into $dom"
18375 local old_md5=$(md5sum $dom)
18376 cancel_lru_locks mdc
18377 local mdtfree1=$(do_facet $facet \
18378 lctl get_param -n osd*.*$mdtname.kbytesfree)
18380 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
18381 error "failed to migrate to the new composite layout"
18382 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
18383 error "MDT stripe was not removed"
18385 cancel_lru_locks mdc
18386 local new_md5=$(md5sum $dom)
18387 [ "$old_md5" != "$new_md5" ] &&
18388 error "$old_md5 != $new_md5"
18390 # Skip free space checks with ZFS
18391 if [ "$(facet_fstype $facet)" != "zfs" ]; then
18392 local mdtfree2=$(do_facet $facet \
18393 lctl get_param -n osd*.*$mdtname.kbytesfree)
18394 [ $mdtfree2 -gt $mdtfree1 ] ||
18395 error "MDS space is not freed after migration"
18399 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
18402 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
18403 skip "Need MDS version at least 2.11.50"
18405 # Layout swap cannot be done if either file has DOM component,
18406 # this will never be supported, migration should be used instead
18408 local dom=$DIR/$tdir/$tfile
18409 mkdir -p $DIR/$tdir
18411 $LFS setstripe -c2 ${dom}_plain
18412 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
18413 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
18414 error "can swap layout with DoM component"
18415 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
18416 error "can swap layout with DoM component"
18418 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
18419 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
18420 error "can swap layout with DoM component"
18421 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
18422 error "can swap layout with DoM component"
18425 run_test 273a "DoM: layout swapping should fail with DOM"
18428 remote_ost_nodsh && skip "remote OST with nodsh"
18429 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
18430 skip "Need OST version >= 2.10.57"
18432 local file=$DIR/$tfile
18435 oss=$(comma_list $(osts_nodes))
18437 dd if=/dev/urandom of=$file bs=1M count=2 ||
18438 error "failed to create a file"
18439 cancel_lru_locks osc
18442 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18443 error "failed to read a file"
18445 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
18446 $LCTL set_param fail_loc=0x8000031f
18448 cancel_lru_locks osc &
18451 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
18452 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
18453 #IO takes another lock, but matches the PENDING one
18454 #and places it to the IO RPC
18455 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
18456 error "failed to read a file with PENDING lock"
18458 run_test 275 "Read on a canceled duplicate lock"
18461 remote_ost_nodsh && skip "remote OST with nodsh"
18464 do_facet ost1 "(while true; do \
18465 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
18466 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
18469 for LOOP in $(seq 20); do
18471 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
18474 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
18475 rm $TMP/sanity_276_pid"
18477 run_test 276 "Race between mount and obd_statfs"
18479 cleanup_test_300() {
18483 test_striped_dir() {
18488 mkdir -p $DIR/$tdir
18490 SAVE_UMASK=$(umask)
18491 trap cleanup_test_300 RETURN EXIT
18493 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
18494 $DIR/$tdir/striped_dir ||
18495 error "set striped dir error"
18497 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
18498 [ "$mode" = "755" ] || error "expect 755 got $mode"
18500 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
18501 error "getdirstripe failed"
18502 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
18503 if [ "$stripe_count" != "2" ]; then
18504 error "1:stripe_count is $stripe_count, expect 2"
18506 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
18507 if [ "$stripe_count" != "2" ]; then
18508 error "2:stripe_count is $stripe_count, expect 2"
18511 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
18512 if [ "$stripe_index" != "$mdt_index" ]; then
18513 error "stripe_index is $stripe_index, expect $mdt_index"
18516 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18517 error "nlink error after create striped dir"
18519 mkdir $DIR/$tdir/striped_dir/a
18520 mkdir $DIR/$tdir/striped_dir/b
18522 stat $DIR/$tdir/striped_dir/a ||
18523 error "create dir under striped dir failed"
18524 stat $DIR/$tdir/striped_dir/b ||
18525 error "create dir under striped dir failed"
18527 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
18528 error "nlink error after mkdir"
18530 rmdir $DIR/$tdir/striped_dir/a
18531 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
18532 error "nlink error after rmdir"
18534 rmdir $DIR/$tdir/striped_dir/b
18535 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
18536 error "nlink error after rmdir"
18538 chattr +i $DIR/$tdir/striped_dir
18539 createmany -o $DIR/$tdir/striped_dir/f 10 &&
18540 error "immutable flags not working under striped dir!"
18541 chattr -i $DIR/$tdir/striped_dir
18543 rmdir $DIR/$tdir/striped_dir ||
18544 error "rmdir striped dir error"
18552 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18553 skip "skipped for lustre < 2.7.0"
18554 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18555 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18557 test_striped_dir 0 || error "failed on striped dir on MDT0"
18558 test_striped_dir 1 || error "failed on striped dir on MDT0"
18560 run_test 300a "basic striped dir sanity test"
18563 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18564 skip "skipped for lustre < 2.7.0"
18565 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18566 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18573 test_mkdir $DIR/$tdir || error "mkdir fail"
18574 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18575 error "set striped dir error"
18576 for i in {0..9}; do
18577 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
18579 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
18580 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
18581 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
18583 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
18584 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
18585 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
18589 run_test 300b "check ctime/mtime for striped dir"
18592 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18593 skip "skipped for lustre < 2.7.0"
18594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18595 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18599 mkdir -p $DIR/$tdir
18600 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
18601 error "set striped dir error"
18603 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
18604 error "chown striped dir failed"
18606 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
18607 error "create 5k files failed"
18609 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
18611 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
18615 run_test 300c "chown && check ls under striped directory"
18618 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
18619 skip "skipped for lustre < 2.7.0"
18620 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18621 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18626 mkdir -p $DIR/$tdir
18627 $SETSTRIPE -c 2 $DIR/$tdir
18629 #local striped directory
18630 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18631 error "set striped dir error"
18632 #look at the directories for debug purposes
18634 $LFS getdirstripe $DIR/$tdir
18635 ls -l $DIR/$tdir/striped_dir
18636 $LFS getdirstripe $DIR/$tdir/striped_dir
18637 createmany -o $DIR/$tdir/striped_dir/f 10 ||
18638 error "create 10 files failed"
18640 #remote striped directory
18641 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
18642 error "set striped dir error"
18643 #look at the directories for debug purposes
18645 $LFS getdirstripe $DIR/$tdir
18646 ls -l $DIR/$tdir/remote_striped_dir
18647 $LFS getdirstripe $DIR/$tdir/remote_striped_dir
18648 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
18649 error "create 10 files failed"
18651 for file in $(find $DIR/$tdir); do
18652 stripe_count=$($LFS getstripe -c $file)
18653 [ $stripe_count -eq 2 ] ||
18654 error "wrong stripe $stripe_count for $file"
18659 run_test 300d "check default stripe under striped directory"
18662 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18663 skip "Need MDS version at least 2.7.55"
18664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18665 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18670 mkdir -p $DIR/$tdir
18672 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18673 error "set striped dir error"
18675 touch $DIR/$tdir/striped_dir/a
18676 touch $DIR/$tdir/striped_dir/b
18677 touch $DIR/$tdir/striped_dir/c
18679 mkdir $DIR/$tdir/striped_dir/dir_a
18680 mkdir $DIR/$tdir/striped_dir/dir_b
18681 mkdir $DIR/$tdir/striped_dir/dir_c
18683 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
18684 error "set striped adir under striped dir error"
18686 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
18687 error "set striped bdir under striped dir error"
18689 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
18690 error "set striped cdir under striped dir error"
18692 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
18693 error "rename dir under striped dir fails"
18695 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
18696 error "rename dir under different stripes fails"
18698 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
18699 error "rename file under striped dir should succeed"
18701 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
18702 error "rename dir under striped dir should succeed"
18706 run_test 300e "check rename under striped directory"
18709 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18710 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18711 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18712 skip "Need MDS version at least 2.7.55"
18718 mkdir -p $DIR/$tdir
18720 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
18721 error "set striped dir error"
18723 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
18724 error "set striped dir error"
18726 touch $DIR/$tdir/striped_dir/a
18727 mkdir $DIR/$tdir/striped_dir/dir_a
18728 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
18729 error "create striped dir under striped dir fails"
18731 touch $DIR/$tdir/striped_dir1/b
18732 mkdir $DIR/$tdir/striped_dir1/dir_b
18733 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
18734 error "create striped dir under striped dir fails"
18736 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
18737 error "rename dir under different striped dir should fail"
18739 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
18740 error "rename striped dir under diff striped dir should fail"
18742 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
18743 error "rename file under diff striped dirs fails"
18747 run_test 300f "check rename cross striped directory"
18749 test_300_check_default_striped_dir()
18752 local default_count=$2
18753 local default_index=$3
18756 local dir_stripe_index
18759 echo "checking $dirname $default_count $default_index"
18760 $LFS setdirstripe -D -c $default_count -i $default_index \
18761 -t all_char $DIR/$tdir/$dirname ||
18762 error "set default stripe on striped dir error"
18763 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
18764 [ $stripe_count -eq $default_count ] ||
18765 error "expect $default_count get $stripe_count for $dirname"
18767 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
18768 [ $stripe_index -eq $default_index ] ||
18769 error "expect $default_index get $stripe_index for $dirname"
18771 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
18772 error "create dirs failed"
18774 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
18775 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
18776 for dir in $(find $DIR/$tdir/$dirname/*); do
18777 stripe_count=$($LFS getdirstripe -c $dir)
18778 [ $stripe_count -eq $default_count ] ||
18779 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
18780 error "stripe count $default_count != $stripe_count for $dir"
18782 stripe_index=$($LFS getdirstripe -i $dir)
18783 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
18784 error "$stripe_index != $default_index for $dir"
18786 #check default stripe
18787 stripe_count=$($LFS getdirstripe -D -c $dir)
18788 [ $stripe_count -eq $default_count ] ||
18789 error "default count $default_count != $stripe_count for $dir"
18791 stripe_index=$($LFS getdirstripe -D -i $dir)
18792 [ $stripe_index -eq $default_index ] ||
18793 error "default index $default_index != $stripe_index for $dir"
18795 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
18799 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18800 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18801 skip "Need MDS version at least 2.7.55"
18808 mkdir $DIR/$tdir/normal_dir
18810 #Checking when client cache stripe index
18811 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
18812 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
18813 error "create striped_dir failed"
18815 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
18816 error "create dir0 fails"
18817 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
18818 [ $stripe_index -eq 0 ] ||
18819 error "dir0 expect index 0 got $stripe_index"
18821 mkdir $DIR/$tdir/striped_dir/dir1 ||
18822 error "create dir1 fails"
18823 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
18824 [ $stripe_index -eq 1 ] ||
18825 error "dir1 expect index 1 got $stripe_index"
18827 #check default stripe count/stripe index
18828 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
18829 test_300_check_default_striped_dir normal_dir 1 0
18830 test_300_check_default_striped_dir normal_dir 2 1
18831 test_300_check_default_striped_dir normal_dir 2 -1
18833 #delete default stripe information
18834 echo "delete default stripeEA"
18835 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
18836 error "set default stripe on striped dir error"
18838 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
18839 for dir in $(find $DIR/$tdir/normal_dir/*); do
18840 stripe_count=$($LFS getdirstripe -c $dir)
18841 [ $stripe_count -eq 0 ] ||
18842 error "expect 1 get $stripe_count for $dir"
18843 stripe_index=$($LFS getdirstripe -i $dir)
18844 [ $stripe_index -eq 0 ] ||
18845 error "expect 0 get $stripe_index for $dir"
18848 run_test 300g "check default striped directory for normal directory"
18851 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18852 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18853 skip "Need MDS version at least 2.7.55"
18859 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18860 error "set striped dir error"
18862 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
18863 test_300_check_default_striped_dir striped_dir 1 0
18864 test_300_check_default_striped_dir striped_dir 2 1
18865 test_300_check_default_striped_dir striped_dir 2 -1
18867 #delete default stripe information
18868 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
18869 error "set default stripe on striped dir error"
18871 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
18872 for dir in $(find $DIR/$tdir/striped_dir/*); do
18873 stripe_count=$($LFS getdirstripe -c $dir)
18874 [ $stripe_count -eq 0 ] ||
18875 error "expect 1 get $stripe_count for $dir"
18878 run_test 300h "check default striped directory for striped directory"
18881 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18882 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18883 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18884 skip "Need MDS version at least 2.7.55"
18891 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18892 error "set striped dir error"
18894 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18895 error "create files under striped dir failed"
18897 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
18898 error "set striped hashdir error"
18900 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
18901 error "create dir0 under hash dir failed"
18902 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
18903 error "create dir1 under hash dir failed"
18905 # unfortunately, we need to umount to clear dir layout cache for now
18906 # once we fully implement dir layout, we can drop this
18907 umount_client $MOUNT || error "umount failed"
18908 mount_client $MOUNT || error "mount failed"
18910 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
18911 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
18912 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
18914 #set the stripe to be unknown hash type
18915 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
18916 $LCTL set_param fail_loc=0x1901
18917 for ((i = 0; i < 10; i++)); do
18918 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
18919 error "stat f-$i failed"
18920 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
18923 touch $DIR/$tdir/striped_dir/f0 &&
18924 error "create under striped dir with unknown hash should fail"
18926 $LCTL set_param fail_loc=0
18928 umount_client $MOUNT || error "umount failed"
18929 mount_client $MOUNT || error "mount failed"
18933 run_test 300i "client handle unknown hash type striped directory"
18936 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18938 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18939 skip "Need MDS version at least 2.7.55"
18946 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
18947 $LCTL set_param fail_loc=0x1702
18948 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18949 error "set striped dir error"
18951 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18952 error "create files under striped dir failed"
18954 $LCTL set_param fail_loc=0
18956 rm -rf $DIR/$tdir || error "unlink striped dir fails"
18960 run_test 300j "test large update record"
18963 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18964 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18965 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18966 skip "Need MDS version at least 2.7.55"
18973 #define OBD_FAIL_LARGE_STRIPE 0x1703
18974 $LCTL set_param fail_loc=0x1703
18975 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
18976 error "set striped dir error"
18977 $LCTL set_param fail_loc=0
18979 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18980 error "getstripeddir fails"
18981 rm -rf $DIR/$tdir/striped_dir ||
18982 error "unlink striped dir fails"
18986 run_test 300k "test large striped directory"
18989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18990 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18991 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18992 skip "Need MDS version at least 2.7.55"
18996 test_mkdir -p $DIR/$tdir/striped_dir
18997 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
18998 error "chown $RUNAS_ID failed"
18999 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
19000 error "set default striped dir failed"
19002 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
19003 $LCTL set_param fail_loc=0x80000158
19004 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
19006 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
19007 [ $stripe_index -eq 1 ] ||
19008 error "expect 1 get $stripe_index for $dir"
19010 run_test 300l "non-root user to create dir under striped dir with stale layout"
19013 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19014 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
19015 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19016 skip "Need MDS version at least 2.7.55"
19018 mkdir -p $DIR/$tdir/striped_dir
19019 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
19020 error "set default stripes dir error"
19022 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
19024 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
19025 [ $stripe_count -eq 0 ] ||
19026 error "expect 0 get $stripe_count for a"
19028 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
19029 error "set default stripes dir error"
19031 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
19033 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
19034 [ $stripe_count -eq 0 ] ||
19035 error "expect 0 get $stripe_count for b"
19037 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
19038 error "set default stripes dir error"
19040 mkdir $DIR/$tdir/striped_dir/c &&
19041 error "default stripe_index is invalid, mkdir c should fails"
19043 rm -rf $DIR/$tdir || error "rmdir fails"
19045 run_test 300m "setstriped directory on single MDT FS"
19048 local list=$(comma_list $(mdts_nodes))
19051 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19055 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19056 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19057 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19058 skip "Need MDS version at least 2.7.55"
19059 remote_mds_nodsh && skip "remote MDS with nodsh"
19062 local list=$(comma_list $(mdts_nodes))
19064 trap cleanup_300n RETURN EXIT
19065 mkdir -p $DIR/$tdir
19066 chmod 777 $DIR/$tdir
19067 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
19068 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19069 error "create striped dir succeeds with gid=0"
19071 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19072 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
19073 error "create striped dir fails with gid=-1"
19075 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19076 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
19077 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
19078 error "set default striped dir succeeds with gid=0"
19081 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
19082 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
19083 error "set default striped dir fails with gid=-1"
19086 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
19087 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
19088 error "create test_dir fails"
19089 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
19090 error "create test_dir1 fails"
19091 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
19092 error "create test_dir2 fails"
19095 run_test 300n "non-root user to create dir under striped dir with default EA"
19098 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19099 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19100 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
19101 skip "Need MDS version at least 2.7.55"
19106 mkdir -p $DIR/$tdir
19108 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
19109 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
19110 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
19111 skip "not enough free inodes $numfree1 $numfree2"
19114 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
19115 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
19116 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
19117 skip "not enough free space $numfree1 $numfree2"
19120 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
19121 error "setdirstripe fails"
19123 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
19124 error "create dirs fails"
19126 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
19127 ls $DIR/$tdir/striped_dir > /dev/null ||
19128 error "ls striped dir fails"
19129 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
19130 error "unlink big striped dir fails"
19132 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
19135 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19136 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19137 remote_mds_nodsh && skip "remote MDS with nodsh"
19139 mkdir -p $DIR/$tdir
19141 #define OBD_FAIL_OUT_ENOSPC 0x1704
19142 do_facet mds2 lctl set_param fail_loc=0x80001704
19143 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
19144 && error "create striped directory should fail"
19146 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
19148 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
19151 run_test 300p "create striped directory without space"
19154 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19155 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19157 local fd=$(free_fd)
19158 local cmd="exec $fd<$tdir"
19160 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
19163 trap "eval $cmd" EXIT
19164 cd $tdir || error "cd $tdir fails"
19165 rmdir ../$tdir || error "rmdir $tdir fails"
19166 mkdir local_dir && error "create dir succeeds"
19167 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
19171 run_test 300q "create remote directory under orphan directory"
19174 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
19175 skip "Need MDS version at least 2.7.55" && return
19176 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
19180 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
19181 error "set striped dir error"
19183 $LFS getdirstripe $DIR/$tdir/striped_dir ||
19184 error "getstripeddir fails"
19187 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
19188 awk '/lmv_stripe_count:/ { print $2 }')
19190 [ $MDSCOUNT -ne $stripe_count ] &&
19191 error "wrong stripe count $stripe_count expected $MDSCOUNT"
19193 rm -rf $DIR/$tdir/striped_dir ||
19194 error "unlink striped dir fails"
19196 run_test 300r "test -1 striped directory"
19198 prepare_remote_file() {
19199 mkdir $DIR/$tdir/src_dir ||
19200 error "create remote source failed"
19202 cp /etc/hosts $DIR/$tdir/src_dir/a ||
19203 error "cp to remote source failed"
19204 touch $DIR/$tdir/src_dir/a
19206 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
19207 error "create remote target dir failed"
19209 touch $DIR/$tdir/tgt_dir/b
19211 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
19212 error "rename dir cross MDT failed!"
19214 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
19215 error "src_child still exists after rename"
19217 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
19218 error "missing file(a) after rename"
19220 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
19221 error "diff after rename"
19225 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19228 local remote_file=$DIR/$tdir/tgt_dir/b
19230 mkdir -p $DIR/$tdir
19232 prepare_remote_file || error "prepare remote file failed"
19235 $OPENUNLINK $remote_file $remote_file ||
19236 error "openunlink $remote_file failed"
19237 $CHECKSTAT -a $remote_file || error "$remote_file exists"
19239 run_test 310a "open unlink remote file"
19242 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
19243 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19245 local remote_file=$DIR/$tdir/tgt_dir/b
19247 mkdir -p $DIR/$tdir
19249 prepare_remote_file || error "prepare remote file failed"
19251 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19252 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
19253 $CHECKSTAT -t file $remote_file || error "check file failed"
19255 run_test 310b "unlink remote file with multiple links while open"
19258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19259 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
19261 local remote_file=$DIR/$tdir/tgt_dir/b
19263 mkdir -p $DIR/$tdir
19265 prepare_remote_file || error "prepare remote file failed"
19267 ln $remote_file $DIR/$tfile || error "link failed for remote file"
19268 multiop_bg_pause $remote_file O_uc ||
19269 error "mulitop failed for remote file"
19271 $MULTIOP $DIR/$tfile Ouc
19272 kill -USR1 $MULTIPID
19275 run_test 310c "open-unlink remote file with multiple links"
19279 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19280 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19281 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
19282 skip "lustre < 2.8.54 does not contain LU-4825 fix"
19283 remote_mds_nodsh && skip "remote MDS with nodsh"
19285 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19286 local mdts=$(comma_list $(mdts_nodes))
19288 mkdir -p $DIR/$tdir
19289 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
19290 createmany -o $DIR/$tdir/$tfile. 1000
19292 # statfs data is not real time, let's just calculate it
19293 old_iused=$((old_iused + 1000))
19295 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19296 osp.*OST0000*MDT0000.create_count")
19297 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
19298 osp.*OST0000*MDT0000.max_create_count")
19299 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
19301 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
19302 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
19303 [ $index -ne 0 ] || error "$tfile stripe index is 0"
19305 unlinkmany $DIR/$tdir/$tfile. 1000
19307 do_nodes $mdts "$LCTL set_param -n \
19308 osp.*OST0000*.max_create_count=$max_count"
19309 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
19310 do_nodes $mdts "$LCTL set_param -n \
19311 osp.*OST0000*.create_count=$count"
19312 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
19313 grep "=0" && error "create_count is zero"
19316 for i in $(seq 120); do
19317 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
19318 # system may be too busy to destroy all objs in time, use
19319 # a somewhat small value to not fail autotest
19320 [ $((old_iused - new_iused)) -gt 400 ] && break
19324 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
19325 [ $((old_iused - new_iused)) -gt 400 ] ||
19326 error "objs not destroyed after unlink"
19328 run_test 311 "disable OSP precreate, and unlink should destroy objs"
19335 local vdevdir=$(dirname $(facet_vdevice $ost))
19336 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
19337 local zfs_zapid=$(do_facet $ost $cmd |
19338 grep -w "/O/0/d$((objid%32))" -C 5 |
19339 awk '/Object/{getline; print $1}')
19340 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
19341 awk "/$objid = /"'{printf $3}')
19346 zfs_object_blksz() {
19350 local vdevdir=$(dirname $(facet_vdevice $ost))
19351 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
19352 local blksz=$(do_facet $ost $cmd $objid |
19353 awk '/dblk/{getline; printf $4}')
19355 case "${blksz: -1}" in
19356 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
19357 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
19364 test_312() { # LU-4856
19365 remote_ost_nodsh && skip "remote OST with nodsh"
19366 [ "$ost1_FSTYPE" = "zfs" ] ||
19367 skip_env "the test only applies to zfs"
19369 local max_blksz=$(do_facet ost1 \
19370 $ZFS get -p recordsize $(facet_device ost1) |
19371 awk '!/VALUE/{print $3}')
19373 # to make life a little bit easier
19374 $LFS mkdir -c 1 -i 0 $DIR/$tdir
19375 $LFS setstripe -c 1 -i 0 $DIR/$tdir
19377 local tf=$DIR/$tdir/$tfile
19379 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19381 # Get ZFS object id
19382 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19383 # block size change by sequential overwrite
19386 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
19387 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
19389 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
19390 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
19394 # block size change by sequential append write
19395 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
19396 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19397 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19400 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
19401 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
19402 oflag=sync conv=notrunc
19404 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19405 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
19406 error "blksz error, actual $blksz, " \
19407 "expected: 2 * $count * $PAGE_SIZE"
19413 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
19414 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
19416 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
19417 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19418 [ $blksz -eq $PAGE_SIZE ] ||
19419 error "blksz error: $blksz, expected: $PAGE_SIZE"
19421 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
19422 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19423 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
19425 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
19426 blksz=$(zfs_object_blksz ost1 $zfs_objid)
19427 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
19429 run_test 312 "make sure ZFS adjusts its block size by write pattern"
19432 remote_ost_nodsh && skip "remote OST with nodsh"
19434 local file=$DIR/$tfile
19437 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
19439 # define OBD_FAIL_TGT_RCVD_EIO 0x720
19440 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19441 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
19442 error "write should failed"
19443 do_facet ost1 "$LCTL set_param fail_loc=0"
19446 run_test 313 "io should fail after last_rcvd update fail"
19449 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
19451 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
19452 do_facet ost1 "$LCTL set_param fail_loc=0x720"
19454 wait_delete_completed
19455 do_facet ost1 "$LCTL set_param fail_loc=0"
19457 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
19459 test_315() { # LU-618
19460 local file=$DIR/$tfile
19463 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
19464 error "multiop file write failed"
19465 $MULTIOP $file oO_RDONLY:r4063232_c &
19470 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
19473 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
19476 run_test 315 "read should be accounted"
19479 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19480 large_xattr_enabled || skip_env "ea_inode feature disabled"
19482 rm -rf $DIR/$tdir/d
19483 mkdir -p $DIR/$tdir/d
19484 chown nobody $DIR/$tdir/d
19485 touch $DIR/$tdir/d/file
19487 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
19489 run_test 316 "lfs mv"
19492 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
19493 skip "Need MDS version at least 2.11.53"
19494 if [ "$ost1_FSTYPE" == "zfs" ]; then
19495 skip "LU-10370: no implementation for ZFS"
19499 local grant_blk_size
19501 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
19502 awk '/grant_block_size:/ { print $2; exit; }')
19504 # Create File of size 5M. Truncate it to below size's and verify
19507 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
19508 error "Create file $DIR/$tfile failed"
19509 stack_trap "rm -f $DIR/$tfile" EXIT
19511 for trunc_sz in 2097152 4097 4000 509 0; do
19512 $TRUNCATE $DIR/$tfile $trunc_sz ||
19513 error "truncate $tfile to $trunc_sz failed"
19514 local sz=$(stat --format=%s $DIR/$tfile)
19515 local blk=$(stat --format=%b $DIR/$tfile)
19516 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
19517 grant_blk_size) * 8))
19519 if [[ $blk -ne $trunc_blk ]]; then
19520 $(which stat) $DIR/$tfile
19521 error "Expected Block $trunc_blk got $blk for $tfile"
19524 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19525 error "Expected Size $trunc_sz got $sz for $tfile"
19530 # Create file with a hole and write actual two blocks. Block count
19533 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
19534 conv=fsync || error "Create file : $DIR/$tfile"
19536 # Calculate the final truncate size.
19537 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
19540 # truncate to size $trunc_sz bytes. Strip the last block
19541 # The block count must drop to 8
19543 $TRUNCATE $DIR/$tfile $trunc_sz ||
19544 error "truncate $tfile to $trunc_sz failed"
19546 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
19547 sz=$(stat --format=%s $DIR/$tfile)
19548 blk=$(stat --format=%b $DIR/$tfile)
19550 if [[ $blk -ne $trunc_bsz ]]; then
19551 $(which stat) $DIR/$tfile
19552 error "Expected Block $trunc_bsz got $blk for $tfile"
19555 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
19556 error "Expected Size $trunc_sz got $sz for $tfile"
19558 run_test 317 "Verify blocks get correctly update after truncate"
19561 local read_write=$1
19562 if [ "$read_write" = "write" ]; then
19563 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
19564 elif [ "$read_write" = "read" ]; then
19565 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
19567 error "argument error"
19570 # turn off debug for performance testing
19571 local saved_debug=$($LCTL get_param -n debug)
19572 $LCTL set_param debug=0
19574 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
19576 # get ost1 size - lustre-OST0000
19577 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
19578 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
19579 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
19581 if [ "$read_write" = "read" ]; then
19582 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
19585 local start_time=$(date +%s.%N)
19586 $dd_cmd bs=1M count=$blocks oflag=sync ||
19587 error "real dd $read_write error"
19588 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
19590 if [ "$read_write" = "write" ]; then
19594 # define OBD_FAIL_OST_FAKE_RW 0x238
19595 do_facet ost1 $LCTL set_param fail_loc=0x238
19597 local start_time=$(date +%s.%N)
19598 $dd_cmd bs=1M count=$blocks oflag=sync ||
19599 error "fake dd $read_write error"
19600 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
19602 if [ "$read_write" = "write" ]; then
19604 cancel_lru_locks osc
19605 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
19606 error "$tfile size not $blocks MB"
19608 do_facet ost1 $LCTL set_param fail_loc=0
19610 echo "fake $read_write $duration_fake vs. normal $read_write" \
19611 "$duration in seconds"
19612 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
19613 error_not_in_vm "fake write is slower"
19615 $LCTL set_param -n debug="$saved_debug"
19618 test_399a() { # LU-7655 for OST fake write
19619 remote_ost_nodsh && skip "remote OST with nodsh"
19623 run_test 399a "fake write should not be slower than normal write"
19625 test_399b() { # LU-8726 for OST fake read
19626 remote_ost_nodsh && skip "remote OST with nodsh"
19627 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
19628 skip_env "ldiskfs only test"
19633 run_test 399b "fake read should not be slower than normal read"
19635 test_400a() { # LU-1606, was conf-sanity test_74
19636 if ! which $CC > /dev/null 2>&1; then
19637 skip_env "$CC is not installed"
19640 local extra_flags=''
19641 local out=$TMP/$tfile
19642 local prefix=/usr/include/lustre
19645 # Oleg removes c files in his test rig so test if any c files exist
19646 [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \
19647 skip_env "Needed c test files are missing"
19649 if ! [[ -d $prefix ]]; then
19650 # Assume we're running in tree and fixup the include path.
19651 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
19652 extra_flags+=" -L$LUSTRE/utils/.lib"
19655 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
19656 $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi ||
19657 error "client api broken"
19661 run_test 400a "Lustre client api program can compile and link"
19663 test_400b() { # LU-1606, LU-5011
19665 local out=$TMP/$tfile
19666 local prefix=/usr/include/linux/lustre
19668 # We use a hard coded prefix so that this test will not fail
19669 # when run in tree. There are headers in lustre/include/lustre/
19670 # that are not packaged (like lustre_idl.h) and have more
19671 # complicated include dependencies (like config.h and lnet/types.h).
19672 # Since this test about correct packaging we just skip them when
19673 # they don't exist (see below) rather than try to fixup cppflags.
19675 if ! which $CC > /dev/null 2>&1; then
19676 skip_env "$CC is not installed"
19679 for header in $prefix/*.h; do
19680 if ! [[ -f "$header" ]]; then
19684 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
19685 continue # lustre_ioctl.h is internal header
19688 $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out ||
19689 error "cannot compile '$header'"
19693 run_test 400b "packaged headers can be compiled"
19695 test_401a() { #LU-7437
19696 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
19697 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
19699 #count the number of parameters by "list_param -R"
19700 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
19701 #count the number of parameters by listing proc files
19702 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
19703 echo "proc_dirs='$proc_dirs'"
19704 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
19705 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
19708 [ $params -eq $procs ] ||
19709 error "found $params parameters vs. $procs proc files"
19711 # test the list_param -D option only returns directories
19712 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
19713 #count the number of parameters by listing proc directories
19714 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
19717 [ $params -eq $procs ] ||
19718 error "found $params parameters vs. $procs proc files"
19720 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
19723 local save=$($LCTL get_param -n jobid_var)
19726 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
19727 error "no error returned when setting bad parameters"
19729 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
19730 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
19732 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
19733 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
19734 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
19736 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
19739 local jobid_var_old=$($LCTL get_param -n jobid_var)
19740 local jobid_var_new
19742 $LCTL set_param jobid_var= &&
19743 error "no error returned for 'set_param a='"
19745 jobid_var_new=$($LCTL get_param -n jobid_var)
19746 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19747 error "jobid_var was changed by setting without value"
19749 $LCTL set_param jobid_var &&
19750 error "no error returned for 'set_param a'"
19752 jobid_var_new=$($LCTL get_param -n jobid_var)
19753 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
19754 error "jobid_var was changed by setting without value"
19756 run_test 401c "Verify 'lctl set_param' without value fails in either format."
19759 local jobid_var_old=$($LCTL get_param -n jobid_var)
19760 local jobid_var_new
19761 local new_value="foo=bar"
19763 $LCTL set_param jobid_var=$new_value ||
19764 error "'set_param a=b' did not accept a value containing '='"
19766 jobid_var_new=$($LCTL get_param -n jobid_var)
19767 [[ "$jobid_var_new" == "$new_value" ]] ||
19768 error "'set_param a=b' failed on a value containing '='"
19770 # Reset the jobid_var to test the other format
19771 $LCTL set_param jobid_var=$jobid_var_old
19772 jobid_var_new=$($LCTL get_param -n jobid_var)
19773 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19774 error "failed to reset jobid_var"
19776 $LCTL set_param jobid_var $new_value ||
19777 error "'set_param a b' did not accept a value containing '='"
19779 jobid_var_new=$($LCTL get_param -n jobid_var)
19780 [[ "$jobid_var_new" == "$new_value" ]] ||
19781 error "'set_param a b' failed on a value containing '='"
19783 $LCTL set_param jobid_var $jobid_var_old
19784 jobid_var_new=$($LCTL get_param -n jobid_var)
19785 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
19786 error "failed to reset jobid_var"
19788 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
19791 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
19792 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
19793 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
19794 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
19795 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
19796 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
19797 remote_mds_nodsh && skip "remote MDS with nodsh"
19799 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
19800 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
19801 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
19802 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
19803 echo "Touch failed - OK"
19805 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
19808 local file1=$DIR/$tfile.1
19809 local file2=$DIR/$tfile.2
19810 local tfile=$TMP/$tfile
19812 rm -f $file1 $file2 $tfile
19817 # 30 sec OBD_TIMEOUT in ll_getattr()
19818 # right before populating st_nlink
19819 $LCTL set_param fail_loc=0x80001409
19820 stat -c %h $file1 > $tfile &
19822 # create an alias, drop all locks and reclaim the dentry
19824 cancel_lru_locks mdc
19825 cancel_lru_locks osc
19826 sysctl -w vm.drop_caches=2
19830 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
19832 rm -f $tfile $file1 $file2
19834 run_test 403 "i_nlink should not drop to zero due to aliasing"
19836 test_404() { # LU-6601
19837 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
19838 skip "Need server version newer than 2.8.52"
19839 remote_mds_nodsh && skip "remote MDS with nodsh"
19841 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
19842 awk '/osp .*-osc-MDT/ { print $4}')
19845 for osp in $mosps; do
19846 echo "Deactivate: " $osp
19847 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
19848 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19849 awk -vp=$osp '$4 == p { print $2 }')
19850 [ $stat = IN ] || {
19851 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19852 error "deactivate error"
19854 echo "Activate: " $osp
19855 do_facet $SINGLEMDS $LCTL --device %$osp activate
19856 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19857 awk -vp=$osp '$4 == p { print $2 }')
19858 [ $stat = UP ] || {
19859 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19860 error "activate error"
19864 run_test 404 "validate manual {de}activated works properly for OSPs"
19867 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] ||
19868 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
19869 skip "Layout swap lock is not supported"
19871 check_swap_layouts_support
19873 test_mkdir $DIR/$tdir
19874 swap_lock_test -d $DIR/$tdir ||
19875 error "One layout swap locked test failed"
19877 run_test 405 "Various layout swap lock tests"
19880 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19881 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19882 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19883 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19884 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
19885 skip "Need MDS version at least 2.8.50"
19887 local def_stripe_size=$($LFS getstripe -S $MOUNT)
19888 local test_pool=$TESTNAME
19890 pool_add $test_pool || error "pool_add failed"
19891 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
19892 error "pool_add_targets failed"
19894 save_layout_restore_at_exit $MOUNT
19896 # parent set default stripe count only, child will stripe from both
19897 # parent and fs default
19898 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
19899 error "setstripe $MOUNT failed"
19900 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
19901 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
19902 for i in $(seq 10); do
19903 local f=$DIR/$tdir/$tfile.$i
19904 touch $f || error "touch failed"
19905 local count=$($LFS getstripe -c $f)
19906 [ $count -eq $OSTCOUNT ] ||
19907 error "$f stripe count $count != $OSTCOUNT"
19908 local offset=$($LFS getstripe -i $f)
19909 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
19910 local size=$($LFS getstripe -S $f)
19911 [ $size -eq $((def_stripe_size * 2)) ] ||
19912 error "$f stripe size $size != $((def_stripe_size * 2))"
19913 local pool=$($LFS getstripe -p $f)
19914 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
19917 # change fs default striping, delete parent default striping, now child
19918 # will stripe from new fs default striping only
19919 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
19920 error "change $MOUNT default stripe failed"
19921 $LFS setstripe -c 0 $DIR/$tdir ||
19922 error "delete $tdir default stripe failed"
19923 for i in $(seq 11 20); do
19924 local f=$DIR/$tdir/$tfile.$i
19925 touch $f || error "touch $f failed"
19926 local count=$($LFS getstripe -c $f)
19927 [ $count -eq 1 ] || error "$f stripe count $count != 1"
19928 local offset=$($LFS getstripe -i $f)
19929 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
19930 local size=$($LFS getstripe -S $f)
19931 [ $size -eq $def_stripe_size ] ||
19932 error "$f stripe size $size != $def_stripe_size"
19933 local pool=$($LFS getstripe -p $f)
19934 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
19937 unlinkmany $DIR/$tdir/$tfile. 1 20
19939 local f=$DIR/$tdir/$tfile
19940 pool_remove_all_targets $test_pool $f
19941 pool_remove $test_pool $f
19943 run_test 406 "DNE support fs default striping"
19946 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19947 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19948 skip "Need MDS version at least 2.8.55"
19949 remote_mds_nodsh && skip "remote MDS with nodsh"
19951 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
19952 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
19953 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
19954 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
19955 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
19957 #define OBD_FAIL_DT_TXN_STOP 0x2019
19958 for idx in $(seq $MDSCOUNT); do
19959 do_facet mds$idx "lctl set_param fail_loc=0x2019"
19961 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
19962 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
19963 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
19966 run_test 407 "transaction fail should cause operation fail"
19969 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
19971 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
19972 lctl set_param fail_loc=0x8000040a
19973 # let ll_prepare_partial_page() fail
19974 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
19978 # create at least 100 unused inodes so that
19979 # shrink_icache_memory(0) should not return 0
19980 touch $DIR/$tfile-{0..100}
19981 rm -f $DIR/$tfile-{0..100}
19984 echo 2 > /proc/sys/vm/drop_caches
19986 run_test 408 "drop_caches should not hang due to page leaks"
19990 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19991 check_mount_and_prep
19993 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
19994 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
19995 touch $DIR/$tdir/guard || error "(2) Fail to create"
19997 local PREFIX=$(str_repeat 'A' 128)
19998 echo "Create 1K hard links start at $(date)"
19999 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20000 error "(3) Fail to hard link"
20002 echo "Links count should be right although linkEA overflow"
20003 stat $DIR/$tdir/guard || error "(4) Fail to stat"
20004 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
20005 [ $linkcount -eq 1001 ] ||
20006 error "(5) Unexpected hard links count: $linkcount"
20008 echo "List all links start at $(date)"
20009 ls -l $DIR/$tdir/foo > /dev/null ||
20010 error "(6) Fail to list $DIR/$tdir/foo"
20012 echo "Unlink hard links start at $(date)"
20013 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
20014 error "(7) Fail to unlink"
20016 run_test 409 "Large amount of cross-MDTs hard links on the same file"
20020 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
20021 skip "Need client version at least 2.9.59"
20023 # Create a file, and stat it from the kernel
20024 local testfile=$DIR/$tfile
20027 local run_id=$RANDOM
20028 local my_ino=$(stat --format "%i" $testfile)
20030 # Try to insert the module. This will always fail as the
20031 # module is designed to not be inserted.
20032 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
20035 # Anything but success is a test failure
20037 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
20038 error "no inode match"
20040 run_test 410 "Test inode number returned from kernel thread"
20042 cleanup_test411_cgroup() {
20048 local cg_basedir=/sys/fs/cgroup/memory
20050 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
20051 skip "no setup for cgroup"
20053 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
20054 error "test file creation failed"
20055 cancel_lru_locks osc
20057 # Create a very small memory cgroup to force a slab allocation error
20058 local cgdir=$cg_basedir/osc_slab_alloc
20059 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
20060 trap "cleanup_test411_cgroup $cgdir" EXIT
20061 echo 2M > $cgdir/memory.kmem.limit_in_bytes
20062 echo 1M > $cgdir/memory.limit_in_bytes
20064 # Should not LBUG, just be killed by oom-killer
20065 # dd will return 0 even allocation failure in some environment.
20066 # So don't check return value
20067 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
20068 cleanup_test411_cgroup $cgdir
20072 run_test 411 "Slab allocation error with cgroup does not LBUG"
20075 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
20076 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20077 skip "Need server version at least 2.10.55"
20080 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
20081 error "mkdir failed"
20082 $LFS getdirstripe $DIR/$tdir
20083 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
20084 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
20085 error "expect $((MDSCOUT - 1)) get $stripe_index"
20086 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
20087 [ $stripe_count -eq 2 ] ||
20088 error "expect 2 get $stripe_count"
20090 run_test 412 "mkdir on specific MDTs"
20093 [ $MDSCOUNT -lt 2 ] &&
20094 skip "We need at least 2 MDTs for this test"
20096 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
20097 skip "Need server version at least 2.10.55"
20100 mkdir $DIR/$tdir || error "mkdir failed"
20102 # find MDT that is the most full
20103 local max=$($LFS df | grep MDT |
20112 END { split(b, c, ":")
20117 for i in $(seq $((MDSCOUNT - 1))); do
20118 $LFS mkdir -c $i $DIR/$tdir/d$i ||
20119 error "mkdir d$i failed"
20120 $LFS getdirstripe $DIR/$tdir/d$i
20121 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
20122 [ $stripe_index -ne $max ] ||
20123 error "don't expect $max"
20126 run_test 413 "mkdir on less full MDTs"
20129 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
20130 $LCTL set_param fail_loc=0x80000521
20131 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
20134 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
20137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20138 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
20139 skip "Need server version at least 2.11.52"
20149 # this test may be slow on ZFS
20150 [ "$mds1_FSTYPE" == "zfs" ] && total=100
20152 # though this test is designed for striped directory, let's test normal
20153 # directory too since lock is always saved as CoS lock.
20154 test_mkdir $DIR/$tdir || error "mkdir $tdir"
20155 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
20164 start_time=$(date +%s)
20165 for i in $(seq $total); do
20166 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
20169 end_time=$(date +%s)
20170 duration=$((end_time - start_time))
20172 kill -9 $setattr_pid
20174 echo "rename $total files took $duration sec"
20175 [ $duration -lt 100 ] || error "rename took $duration sec"
20177 run_test 415 "lock revoke is not missing"
20180 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
20181 skip "Need server version at least 2.11.55"
20183 # define OBD_FAIL_OSD_TXN_START 0x19a
20184 do_facet mds1 lctl set_param fail_loc=0x19a
20186 lfs mkdir -c $MDSCOUNT $DIR/$tdir
20190 run_test 416 "transaction start failure won't cause system hung"
20194 do_nodes $(comma_list $(mdts_nodes)) \
20195 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
20196 do_nodes $(comma_list $(mdts_nodes)) \
20197 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
20198 do_nodes $(comma_list $(mdts_nodes)) \
20199 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
20203 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20204 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
20205 skip "Need MDS version at least 2.11.56"
20207 trap cleanup_417 RETURN EXIT
20209 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
20210 do_nodes $(comma_list $(mdts_nodes)) \
20211 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
20212 $LFS migrate -m 0 $DIR/$tdir.1 &&
20213 error "migrate dir $tdir.1 should fail"
20215 do_nodes $(comma_list $(mdts_nodes)) \
20216 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
20217 $LFS mkdir -i 1 $DIR/$tdir.2 &&
20218 error "create remote dir $tdir.2 should fail"
20220 do_nodes $(comma_list $(mdts_nodes)) \
20221 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
20222 $LFS mkdir -c 2 $DIR/$tdir.3 &&
20223 error "create striped dir $tdir.3 should fail"
20226 run_test 417 "disable remote dir, striped dir and dir migration"
20228 # Checks that the outputs of df [-i] and lfs df [-i] match
20230 # usage: check_lfs_df <blocks | inodes> <mountpoint>
20240 [ "$1" == "blocks" ] && inodes= || inodes="-i"
20242 for count in {1..100}; do
20246 # read the lines of interest
20247 df_out=($(df -P $inodes $dir | tail -n +2)) ||
20248 error "df $inodes $dir | tail -n +2 failed"
20249 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
20250 error "lfs df $inodes $dir | grep summary: failed"
20252 # skip first substrings of each output as they are different
20253 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
20254 # compare the remaining fields of the two outputs
20256 for i in {1..5}; do
20257 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
20265 lfs df $inodes $dir
20266 error "df and lfs df $1 output mismatch: " \
20267 "df ${inodes}: ${df_out[*]}, " \
20268 "lfs df ${inodes}: ${lfs_df_out[*]}"
20273 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20275 local dir=$DIR/$tdir
20276 local numfiles=$((RANDOM % 4096 + 2))
20277 local numblocks=$((RANDOM % 256 + 1))
20279 wait_delete_completed
20282 # check block output
20283 check_lfs_df blocks $dir
20284 # check inode output
20285 check_lfs_df inodes $dir
20287 # create a single file and retest
20288 echo "Creating a single file and testing"
20289 createmany -o $dir/$tfile- 1 &>/dev/null ||
20290 error "creating 1 file in $dir failed"
20291 check_lfs_df blocks $dir
20292 check_lfs_df inodes $dir
20294 # create a random number of files
20295 echo "Creating $((numfiles - 1)) files and testing"
20296 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
20297 error "creating $((numfiles - 1)) files in $dir failed"
20299 # write a random number of blocks to the first test file
20300 echo "Writing $numblocks 4K blocks and testing"
20301 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
20302 count=$numblocks &>/dev/null ||
20303 error "dd to $dir/${tfile}-0 failed"
20306 check_lfs_df blocks $dir
20307 check_lfs_df inodes $dir
20309 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
20310 error "unlinking $numfiles files in $dir failed"
20312 run_test 418 "df and lfs df outputs match"
20316 local dir=$DIR/$tdir
20321 cancel_lru_locks mdc
20323 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
20324 $LCTL set_param fail_loc=0x1410
20326 $LCTL set_param fail_loc=0
20329 run_test 419 "Verify open file by name doesn't crash kernel"
20333 [[ $MDS1_VERSION -ge $(version_code 2.12.1) ]] ||
20334 skip "Need MDS version at least 2.12.1"
20336 local SAVE_UMASK=$(umask)
20337 local dir=$DIR/$tdir
20338 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
20342 mkdir -m03777 $dir/testdir
20343 ls -dn $dir/testdir
20344 # Need to remove trailing '.' when SELinux is enabled
20345 local dirperms=$(ls -dn $dir/testdir |
20346 awk '{ sub(/\.$/, "", $1); print $1}')
20347 [ $dirperms == "drwxrwsrwt" ] ||
20348 error "incorrect perms on $dir/testdir"
20350 su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
20351 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
20352 ls -n $dir/testdir/testfile
20353 local fileperms=$(ls -n $dir/testdir/testfile |
20354 awk '{ sub(/\.$/, "", $1); print $1}')
20355 [ $fileperms == "-rwxr-xr-x" ] ||
20356 error "incorrect perms on $dir/testdir/testfile"
20360 run_test 420 "clear SGID bit on non-directories for non-members"
20367 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20368 skip "Need MDS version at least 2.12.2"
20370 test_mkdir $DIR/$tdir
20371 createmany -o $DIR/$tdir/f 3
20372 cnt=$(ls -1 $DIR/$tdir | wc -l)
20373 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20375 fid1=$(lfs path2fid $DIR/$tdir/f1)
20376 fid2=$(lfs path2fid $DIR/$tdir/f2)
20377 $LFS rmfid $DIR $fid1 $fid2 || error "rmfid failed"
20379 stat $DIR/$tdir/f1 && error "f1 still visible on the client"
20380 stat $DIR/$tdir/f2 && error "f2 still visible on the client"
20382 cnt=$(ls -1 $DIR/$tdir | wc -l)
20383 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20385 rm -f $DIR/$tdir/f3 || error "can't remove f3"
20386 createmany -o $DIR/$tdir/f 3
20387 cnt=$(ls -1 $DIR/$tdir | wc -l)
20388 [ $cnt != 3 ] && error "unexpected #files: $cnt"
20390 fid1=$(lfs path2fid $DIR/$tdir/f1)
20391 fid2=$(lfs path2fid $DIR/$tdir/f2)
20392 echo "remove using fsname $FSNAME"
20393 $LFS rmfid $FSNAME $fid1 $fid2 || error "rmfid with fsname failed"
20395 cnt=$(ls -1 $DIR/$tdir | wc -l)
20396 [ $cnt == 1 ] || error "unexpected #files after: $cnt"
20398 run_test 421a "simple rm by fid"
20405 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20406 skip "Need MDS version at least 2.12.2"
20408 test_mkdir $DIR/$tdir
20409 createmany -o $DIR/$tdir/f 3
20410 multiop_bg_pause $DIR/$tdir/f1 o_c || error "multiop failed to start"
20413 FID1=$(lfs path2fid $DIR/$tdir/f1)
20414 FID2=$(lfs path2fid $DIR/$tdir/f2)
20415 $LFS rmfid $DIR $FID1 $FID2 && error "rmfid didn't fail"
20417 kill -USR1 $MULTIPID
20420 cnt=$(ls $DIR/$tdir | wc -l)
20421 [ $cnt == 2 ] || error "unexpected #files after: $cnt"
20423 run_test 421b "rm by fid on open file"
20429 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20430 skip "Need MDS version at least 2.12.2"
20432 test_mkdir $DIR/$tdir
20433 createmany -o $DIR/$tdir/f 3
20434 touch $DIR/$tdir/$tfile
20435 createmany -l$DIR/$tdir/$tfile $DIR/$tdir/h 180
20436 cnt=$(ls -1 $DIR/$tdir | wc -l)
20437 [ $cnt != 184 ] && error "unexpected #files: $cnt"
20439 FID1=$(lfs path2fid $DIR/$tdir/$tfile)
20440 $LFS rmfid $DIR $FID1 || error "rmfid failed"
20442 cnt=$(ls $DIR/$tdir | wc -l)
20443 [ $cnt == 3 ] || error "unexpected #files after: $cnt"
20445 run_test 421c "rm by fid against hardlinked files"
20451 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20452 skip "Need MDS version at least 2.12.2"
20454 test_mkdir $DIR/$tdir
20455 createmany -o $DIR/$tdir/f 4097
20456 cnt=$(ls -1 $DIR/$tdir | wc -l)
20457 [ $cnt != 4097 ] && error "unexpected #files: $cnt"
20459 FIDS=$(lfs path2fid $DIR/$tdir/f* | sed "s/[/][^:]*://g")
20460 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20462 cnt=$(ls $DIR/$tdir | wc -l)
20464 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20466 run_test 421d "rmfid en masse"
20472 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20473 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20474 skip "Need MDS version at least 2.12.2"
20476 mkdir -p $DIR/$tdir
20477 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20478 createmany -o $DIR/$tdir/striped_dir/f 512
20479 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20480 [ $cnt != 512 ] && error "unexpected #files: $cnt"
20482 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
20483 sed "s/[/][^:]*://g")
20484 $LFS rmfid $DIR $FIDS || error "rmfid failed"
20486 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
20488 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20490 run_test 421e "rmfid in DNE"
20496 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20497 skip "Need MDS version at least 2.12.2"
20499 test_mkdir $DIR/$tdir
20501 cnt=$(ls -1 $DIR/$tdir | wc -l)
20502 [ $cnt != 1 ] && error "unexpected #files: $cnt"
20504 FID=$(lfs path2fid $DIR/$tdir/f)
20505 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (1)"
20506 # rmfid should fail
20507 cnt=$(ls -1 $DIR/$tdir | wc -l)
20508 [ $cnt != 1 ] && error "unexpected #files after (2): $cnt"
20510 chmod a+rw $DIR/$tdir
20512 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail (2)"
20513 # rmfid should fail
20514 cnt=$(ls -1 $DIR/$tdir | wc -l)
20515 [ $cnt != 1 ] && error "unexpected #files after (3): $cnt"
20518 $RUNAS touch $DIR/$tdir/f
20519 FID=$(lfs path2fid $DIR/$tdir/f)
20520 echo "rmfid as root"
20521 $LFS rmfid $DIR $FID || error "rmfid as root failed"
20522 cnt=$(ls -1 $DIR/$tdir | wc -l)
20523 [ $cnt == 0 ] || error "unexpected #files after (4): $cnt"
20526 $RUNAS touch $DIR/$tdir/f
20527 cnt=$(ls -1 $DIR/$tdir | wc -l)
20528 [ $cnt != 1 ] && error "unexpected #files (4): $cnt"
20529 FID=$(lfs path2fid $DIR/$tdir/f)
20530 # rmfid w/o user_fid2path mount option should fail
20531 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail(3)"
20532 cnt=$(ls -1 $DIR/$tdir | wc -l)
20533 [ $cnt == 1 ] || error "unexpected #files after (5): $cnt"
20535 umount_client $MOUNT || "failed to umount client"
20536 mount_client $MOUNT "$MOUNT_OPTS,user_fid2path" ||
20537 "failed to mount client'"
20539 $RUNAS $LFS rmfid $DIR $FID || error "rmfid failed"
20540 # rmfid should succeed
20541 cnt=$(ls -1 $DIR/$tdir | wc -l)
20542 [ $cnt == 0 ] || error "unexpected #files after (6): $cnt"
20544 # rmfid shouldn't allow to remove files due to dir's permission
20545 chmod a+rwx $DIR/$tdir
20548 FID=$(lfs path2fid $DIR/$tdir/f)
20549 $RUNAS $LFS rmfid $DIR $FID && error "rmfid didn't fail"
20551 umount_client $MOUNT || "failed to umount client"
20552 mount_client $MOUNT "$MOUNT_OPTS" ||
20553 "failed to mount client'"
20556 run_test 421f "rmfid checks permissions"
20562 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
20563 [ $MDS1_VERSION -lt $(version_code 2.12.2) ] &&
20564 skip "Need MDS version at least 2.12.2"
20566 mkdir -p $DIR/$tdir
20567 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
20568 createmany -o $DIR/$tdir/striped_dir/f 512
20569 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20570 [ $cnt != 512 ] && error "unexpected #files: $cnt"
20572 FIDS=$(lfs path2fid $DIR/$tdir/striped_dir/f* |
20573 sed "s/[/][^:]*://g")
20575 rm -f $DIR/$tdir/striped_dir/f1*
20576 cnt=$(ls -1 $DIR/$tdir/striped_dir | wc -l)
20577 removed=$((512 - cnt))
20579 # few files have been just removed, so we expect
20580 # rmfid to fail on their fids
20581 errors=$($LFS rmfid $DIR $FIDS 2>&1 | wc -l)
20582 [ $removed != $errors ] && error "$errors != $removed"
20584 cnt=$(ls $DIR/$tdir/striped_dir | wc -l)
20586 [ $cnt == 0 ] || error "unexpected #files after: $cnt"
20588 run_test 421g "rmfid to return errors properly"
20601 # ensure statfs cache is expired
20604 _stats=$(stat_test | grep $MOUNT | sort -u | wc -l)
20605 [[ ${_stats} -ne 1 ]] && error "statfs wrong"
20609 run_test 423 "statfs should return a right data"
20612 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
20613 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
20614 skip "Need server version at least 2.9.55"
20616 start_full_debug_logging
20620 stop_full_debug_logging
20624 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
20625 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
20626 awk '/The barrier for/ { print $7 }')
20629 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
20634 barrier_expired() {
20637 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
20638 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
20639 awk '/will be expired/ { print $7 }')
20641 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
20650 echo "Start barrier_freeze at: $(date)"
20651 #define OBD_FAIL_BARRIER_DELAY 0x2202
20652 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
20653 # Do not reduce barrier time - See LU-11873
20654 do_facet mgs $LCTL barrier_freeze $FSNAME 20 &
20657 local b_status=$(barrier_stat)
20658 echo "Got barrier status at: $(date)"
20659 [ "$b_status" = "'freezing_p1'" ] ||
20660 error "(1) unexpected barrier status $b_status"
20662 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20664 b_status=$(barrier_stat)
20665 [ "$b_status" = "'frozen'" ] ||
20666 error "(2) unexpected barrier status $b_status"
20668 local expired=$(barrier_expired)
20669 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
20670 sleep $((expired + 3))
20672 b_status=$(barrier_stat)
20673 [ "$b_status" = "'expired'" ] ||
20674 error "(3) unexpected barrier status $b_status"
20676 # Do not reduce barrier time - See LU-11873
20677 do_facet mgs $LCTL barrier_freeze $FSNAME 20 ||
20678 error "(4) fail to freeze barrier"
20680 b_status=$(barrier_stat)
20681 [ "$b_status" = "'frozen'" ] ||
20682 error "(5) unexpected barrier status $b_status"
20684 echo "Start barrier_thaw at: $(date)"
20685 #define OBD_FAIL_BARRIER_DELAY 0x2202
20686 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
20687 do_facet mgs $LCTL barrier_thaw $FSNAME &
20690 b_status=$(barrier_stat)
20691 echo "Got barrier status at: $(date)"
20692 [ "$b_status" = "'thawing'" ] ||
20693 error "(6) unexpected barrier status $b_status"
20695 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
20697 b_status=$(barrier_stat)
20698 [ "$b_status" = "'thawed'" ] ||
20699 error "(7) unexpected barrier status $b_status"
20701 #define OBD_FAIL_BARRIER_FAILURE 0x2203
20702 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
20703 do_facet mgs $LCTL barrier_freeze $FSNAME
20705 b_status=$(barrier_stat)
20706 [ "$b_status" = "'failed'" ] ||
20707 error "(8) unexpected barrier status $b_status"
20709 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
20710 do_facet mgs $LCTL barrier_thaw $FSNAME
20714 run_test 801a "write barrier user interfaces and stat machine"
20719 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20720 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
20721 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
20722 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
20723 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
20725 cancel_lru_locks mdc
20727 # 180 seconds should be long enough
20728 do_facet mgs $LCTL barrier_freeze $FSNAME 180
20730 local b_status=$(barrier_stat)
20731 [ "$b_status" = "'frozen'" ] ||
20732 error "(6) unexpected barrier status $b_status"
20734 mkdir $DIR/$tdir/d0/d10 &
20737 touch $DIR/$tdir/d1/f13 &
20740 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
20743 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
20746 rm -f $DIR/$tdir/d4/f12 &
20749 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
20751 # To guarantee taht the 'stat' is not blocked
20752 b_status=$(barrier_stat)
20753 [ "$b_status" = "'frozen'" ] ||
20754 error "(8) unexpected barrier status $b_status"
20756 # let above commands to run at background
20759 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
20760 ps -p $touch_pid || error "(10) touch should be blocked"
20761 ps -p $ln_pid || error "(11) link should be blocked"
20762 ps -p $mv_pid || error "(12) rename should be blocked"
20763 ps -p $rm_pid || error "(13) unlink should be blocked"
20765 b_status=$(barrier_stat)
20766 [ "$b_status" = "'frozen'" ] ||
20767 error "(14) unexpected barrier status $b_status"
20769 do_facet mgs $LCTL barrier_thaw $FSNAME
20770 b_status=$(barrier_stat)
20771 [ "$b_status" = "'thawed'" ] ||
20772 error "(15) unexpected barrier status $b_status"
20774 wait $mkdir_pid || error "(16) mkdir should succeed"
20775 wait $touch_pid || error "(17) touch should succeed"
20776 wait $ln_pid || error "(18) link should succeed"
20777 wait $mv_pid || error "(19) rename should succeed"
20778 wait $rm_pid || error "(20) unlink should succeed"
20782 run_test 801b "modification will be blocked by write barrier"
20785 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20789 stop mds2 || error "(1) Fail to stop mds2"
20791 do_facet mgs $LCTL barrier_freeze $FSNAME 30
20793 local b_status=$(barrier_stat)
20794 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
20795 do_facet mgs $LCTL barrier_thaw $FSNAME
20796 error "(2) unexpected barrier status $b_status"
20799 do_facet mgs $LCTL barrier_rescan $FSNAME ||
20800 error "(3) Fail to rescan barrier bitmap"
20802 # Do not reduce barrier time - See LU-11873
20803 do_facet mgs $LCTL barrier_freeze $FSNAME 20
20805 b_status=$(barrier_stat)
20806 [ "$b_status" = "'frozen'" ] ||
20807 error "(4) unexpected barrier status $b_status"
20809 do_facet mgs $LCTL barrier_thaw $FSNAME
20810 b_status=$(barrier_stat)
20811 [ "$b_status" = "'thawed'" ] ||
20812 error "(5) unexpected barrier status $b_status"
20814 local devname=$(mdsdevname 2)
20816 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
20818 do_facet mgs $LCTL barrier_rescan $FSNAME ||
20819 error "(7) Fail to rescan barrier bitmap"
20823 run_test 801c "rescan barrier bitmap"
20825 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
20826 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
20827 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
20828 saved_MOUNT_OPTS=$MOUNT_OPTS
20834 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
20835 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
20836 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
20837 MOUNT_OPTS=$saved_MOUNT_OPTS
20843 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
20844 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
20845 skip "Need server version at least 2.9.55"
20847 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
20849 mkdir $DIR/$tdir || error "(1) fail to mkdir"
20851 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
20852 error "(2) Fail to copy"
20854 trap cleanup_802 EXIT
20856 # sync by force before remount as readonly
20857 sync; sync_all_data; sleep 3; sync_all_data
20861 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
20862 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
20863 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
20865 echo "Mount the server as read only"
20866 setupall server_only || error "(3) Fail to start servers"
20868 echo "Mount client without ro should fail"
20869 mount_client $MOUNT &&
20870 error "(4) Mount client without 'ro' should fail"
20872 echo "Mount client with ro should succeed"
20873 MOUNT_OPTS=$(csa_add "$MOUNT_OPTS" -o ro)
20874 mount_client $MOUNT ||
20875 error "(5) Mount client with 'ro' should succeed"
20877 echo "Modify should be refused"
20878 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
20880 echo "Read should be allowed"
20881 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
20882 error "(7) Read should succeed under ro mode"
20886 run_test 802 "simulate readonly device"
20889 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20890 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
20891 skip "MDS needs to be newer than 2.10.54"
20893 mkdir -p $DIR/$tdir
20894 # Create some objects on all MDTs to trigger related logs objects
20895 for idx in $(seq $MDSCOUNT); do
20896 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
20897 $DIR/$tdir/dir${idx} ||
20898 error "Fail to create $DIR/$tdir/dir${idx}"
20902 wait_delete_completed # ensure old test cleanups are finished
20903 echo "before create:"
20905 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20907 for i in {1..10}; do
20908 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
20909 error "Fail to create $DIR/$tdir/foo$i"
20913 echo "after create:"
20915 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20917 # allow for an llog to be cleaned up during the test
20918 [ $after_used -ge $((before_used + 10 - 1)) ] ||
20919 error "before ($before_used) + 10 > after ($after_used)"
20921 for i in {1..10}; do
20922 rm -rf $DIR/$tdir/foo$i ||
20923 error "Fail to remove $DIR/$tdir/foo$i"
20926 sleep 3 # avoid MDT return cached statfs
20927 wait_delete_completed
20928 echo "after unlink:"
20930 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
20932 # allow for an llog to be created during the test
20933 [ $after_used -le $((before_used + 1)) ] ||
20934 error "after ($after_used) > before ($before_used) + 1"
20936 run_test 803 "verify agent object for remote object"
20939 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
20940 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
20941 skip "MDS needs to be newer than 2.10.54"
20942 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
20944 mkdir -p $DIR/$tdir
20945 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
20946 error "Fail to create $DIR/$tdir/dir0"
20948 local fid=$($LFS path2fid $DIR/$tdir/dir0)
20949 local dev=$(mdsdevname 2)
20951 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20952 grep ${fid} || error "NOT found agent entry for dir0"
20954 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
20955 error "Fail to create $DIR/$tdir/dir1"
20957 touch $DIR/$tdir/dir1/foo0 ||
20958 error "Fail to create $DIR/$tdir/dir1/foo0"
20959 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
20962 for idx in $(seq $MDSCOUNT); do
20963 dev=$(mdsdevname $idx)
20964 do_facet mds${idx} \
20965 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20966 grep ${fid} && rc=$idx
20969 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
20970 error "Fail to rename foo0 to foo1"
20971 if [ $rc -eq 0 ]; then
20972 for idx in $(seq $MDSCOUNT); do
20973 dev=$(mdsdevname $idx)
20974 do_facet mds${idx} \
20975 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20976 grep ${fid} && rc=$idx
20980 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
20981 error "Fail to rename foo1 to foo2"
20982 if [ $rc -eq 0 ]; then
20983 for idx in $(seq $MDSCOUNT); do
20984 dev=$(mdsdevname $idx)
20985 do_facet mds${idx} \
20986 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
20987 grep ${fid} && rc=$idx
20991 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
20993 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
20994 error "Fail to link to $DIR/$tdir/dir1/foo2"
20995 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
20996 error "Fail to rename foo2 to foo0"
20997 unlink $DIR/$tdir/dir1/foo0 ||
20998 error "Fail to unlink $DIR/$tdir/dir1/foo0"
20999 rm -rf $DIR/$tdir/dir0 ||
21000 error "Fail to rm $DIR/$tdir/dir0"
21002 for idx in $(seq $MDSCOUNT); do
21003 dev=$(mdsdevname $idx)
21007 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
21009 start mds${idx} $dev $MDS_MOUNT_OPTS ||
21010 error "mount mds$idx failed"
21011 df $MOUNT > /dev/null 2>&1
21013 # e2fsck should not return error
21015 error "e2fsck detected error on MDT${idx}: rc=$rc"
21018 run_test 804 "verify agent entry for remote entry"
21021 do_facet $SINGLEMDS zfs set quota=$old $fsset
21022 unlinkmany $DIR/$tdir/f- 1000000
21027 local zfs_version=$(do_facet mds1 cat /sys/module/zfs/version)
21028 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
21029 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
21030 skip "netfree not implemented before 0.7"
21031 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
21032 skip "Need MDS version at least 2.10.57"
21039 local pref="osd-zfs.lustre-MDT0000."
21041 # limit available space on MDS dataset to meet nospace issue
21042 # quickly. then ZFS 0.7.2 can use reserved space if asked
21043 # properly (using netfree flag in osd_declare_destroy()
21044 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
21045 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
21047 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
21048 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
21049 let "usedkb=usedkb-freekb"
21050 let "freekb=freekb/2"
21051 if let "freekb > 5000"; then
21054 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
21055 trap cleanup_805 EXIT
21057 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
21058 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
21059 rm -rf $DIR/$tdir || error "not able to remove"
21060 do_facet $SINGLEMDS zfs set quota=$old $fsset
21063 run_test 805 "ZFS can remove from full fs"
21069 local size=$($LFS getsom -s $file)
21070 local expect=$(stat -c %s $file)
21072 [[ $size == $expect ]] ||
21073 error "$file expected size: $expect, got: $size"
21075 local blocks=$($LFS getsom -b $file)
21076 expect=$(stat -c %b $file)
21077 [[ $blocks == $expect ]] ||
21078 error "$file expected blocks: $expect, got: $blocks"
21083 local size=$($LFS getsom -s $1)
21086 [[ $size == $expect ]] ||
21087 error "$file expected size: $expect, got: $size"
21091 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21092 skip "Need MDS version at least 2.11.52"
21096 touch $DIR/$tfile || error "touch $tfile failed"
21098 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21099 save_lustre_params client "llite.*.xattr_cache" > $save
21100 lctl set_param llite.*.xattr_cache=0
21101 stack_trap "restore_lustre_params < $save" EXIT
21103 # single-threaded write
21104 echo "Test SOM for single-threaded write"
21105 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
21106 error "write $tfile failed"
21107 check_lsom_size $DIR/$tfile $bs
21110 local size=$(($num * $bs))
21114 echo "Test SOM for single client multi-threaded($num) write"
21115 $TRUNCATE $DIR/$tfile 0
21116 for ((i = 0; i < $num; i++)); do
21117 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21119 offset=$((offset + $bs))
21121 for (( i=0; i < $num; i++ )); do
21124 check_lsom_size $DIR/$tfile $size
21126 $TRUNCATE $DIR/$tfile 0
21127 for ((i = 0; i < $num; i++)); do
21128 offset=$((offset - $bs))
21129 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21132 for (( i=0; i < $num; i++ )); do
21135 check_lsom_size $DIR/$tfile $size
21137 # multi-client writes
21138 num=$(get_node_count ${CLIENTS//,/ })
21139 size=$(($num * $bs))
21143 echo "Test SOM for multi-client ($num) writes"
21144 $TRUNCATE $DIR/$tfile 0
21145 for client in ${CLIENTS//,/ }; do
21146 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21149 offset=$((offset + $bs))
21151 for (( i=0; i < $num; i++ )); do
21154 check_lsom_size $DIR/$tfile $offset
21157 $TRUNCATE $DIR/$tfile 0
21158 for client in ${CLIENTS//,/ }; do
21159 offset=$((offset - $bs))
21160 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21164 for (( i=0; i < $num; i++ )); do
21167 check_lsom_size $DIR/$tfile $size
21170 echo "Test SOM for truncate"
21171 $TRUNCATE $DIR/$tfile 1048576
21172 check_lsom_size $DIR/$tfile 1048576
21173 $TRUNCATE $DIR/$tfile 1234
21174 check_lsom_size $DIR/$tfile 1234
21176 # verify SOM blocks count
21177 echo "Verify SOM block count"
21178 $TRUNCATE $DIR/$tfile 0
21179 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
21180 error "failed to write file $tfile"
21181 check_lsom_data $DIR/$tfile
21183 run_test 806 "Verify Lazy Size on MDS"
21186 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
21187 skip "Need MDS version at least 2.11.52"
21189 # Registration step
21190 changelog_register || error "changelog_register failed"
21191 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
21192 changelog_users $SINGLEMDS | grep -q $cl_user ||
21193 error "User $cl_user not found in changelog_users"
21195 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
21196 save_lustre_params client "llite.*.xattr_cache" > $save
21197 lctl set_param llite.*.xattr_cache=0
21198 stack_trap "restore_lustre_params < $save" EXIT
21200 rm -rf $DIR/$tdir || error "rm $tdir failed"
21201 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
21202 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
21203 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
21204 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
21205 error "truncate $tdir/trunc failed"
21208 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
21209 error "write $tfile failed"
21211 # multi-client wirtes
21212 local num=$(get_node_count ${CLIENTS//,/ })
21216 echo "Test SOM for multi-client ($num) writes"
21217 touch $DIR/$tfile || error "touch $tfile failed"
21218 $TRUNCATE $DIR/$tfile 0
21219 for client in ${CLIENTS//,/ }; do
21220 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
21223 offset=$((offset + $bs))
21225 for (( i=0; i < $num; i++ )); do
21230 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
21231 check_lsom_data $DIR/$tdir/trunc
21232 check_lsom_data $DIR/$tdir/single_dd
21233 check_lsom_data $DIR/$tfile
21236 # Deregistration step
21237 changelog_deregister || error "changelog_deregister failed"
21239 run_test 807 "verify LSOM syncing tool"
21241 check_som_nologged()
21243 local lines=$($LFS changelog $FSNAME-MDT0000 |
21244 grep 'x=trusted.som' | wc -l)
21245 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
21249 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
21250 skip "Need MDS version at least 2.11.55"
21252 # Registration step
21253 changelog_register || error "changelog_register failed"
21255 touch $DIR/$tfile || error "touch $tfile failed"
21258 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
21259 error "write $tfile failed"
21262 $TRUNCATE $DIR/$tfile 1234
21265 $TRUNCATE $DIR/$tfile 1048576
21268 # Deregistration step
21269 changelog_deregister || error "changelog_deregister failed"
21271 run_test 808 "Check trusted.som xattr not logged in Changelogs"
21276 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
21280 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
21281 skip "Need MDS version at least 2.11.56"
21283 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
21284 error "failed to create DoM-only file $DIR/$tfile"
21285 touch $DIR/$tfile || error "touch $tfile failed"
21286 check_som_nodata $DIR/$tfile
21288 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
21289 error "write $tfile failed"
21290 check_som_nodata $DIR/$tfile
21292 $TRUNCATE $DIR/$tfile 1234
21293 check_som_nodata $DIR/$tfile
21295 $TRUNCATE $DIR/$tfile 4097
21296 check_som_nodata $DIR/$file
21298 run_test 809 "Verify no SOM xattr store for DoM-only files"
21301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21302 $GSS && skip_env "could not run with gss"
21305 stack_trap "set_checksums $ORIG_CSUM" EXIT
21306 stack_trap "set_checksum_type $ORIG_CSUM_TYPE" EXIT
21311 for csum in $CKSUM_TYPES; do
21312 #define OBD_FAIL_OSC_NO_GRANT 0x411
21313 $LCTL set_param osc.*.checksum_type=$csum fail_loc=0x411
21314 for i in "10240 0" "10000 0" "4000 1" "500 1"; do
21316 dd if=/dev/urandom of=$DIR/$tfile bs=$1 count=2 seek=$2
21317 before=$(md5sum $DIR/$tfile)
21318 $LCTL set_param ldlm.namespaces.*osc*.lru_size=clear
21319 after=$(md5sum $DIR/$tfile)
21320 [ "$before" == "$after" ] ||
21321 error "$csum: $before != $after bs=$1 seek=$2"
21325 run_test 810 "partial page writes on ZFS (LU-11663)"
21328 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
21329 skip "Need MDS version at least 2.11.56"
21331 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
21332 do_facet mds1 $LCTL set_param fail_loc=0x165
21333 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
21336 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
21339 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
21340 error "MDD orphan cleanup thread not quit"
21342 run_test 811 "orphan name stub can be cleaned up in startup"
21345 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
21346 skip "OST < 2.12.51 doesn't support this fail_loc"
21347 [ "$SHARED_KEY" = true ] &&
21348 skip "OSC connections never go IDLE with Shared-Keys enabled"
21350 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21351 # ensure ost1 is connected
21352 stat $DIR/$tfile >/dev/null || error "can't stat"
21353 wait_osc_import_state client ost1 FULL
21354 # no locks, no reqs to let the connection idle
21355 cancel_lru_locks osc
21357 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
21358 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
21359 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
21360 wait_osc_import_state client ost1 CONNECTING
21361 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
21363 stat $DIR/$tfile >/dev/null || error "can't stat file"
21365 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
21369 dd of=$DIR/$tfile seek=128 bs=1k < /dev/null
21370 echo -n y >> $DIR/$tfile
21371 cp --sparse=always $DIR/$tfile $DIR/${tfile}.cp || error "copy failed"
21372 diff $DIR/$tfile $DIR/${tfile}.cp || error "files should be same"
21374 run_test 814 "sparse cp works as expected (LU-12361)"
21378 writeme -b 100 $DIR/$tfile || error "write 100 bytes failed"
21379 writeme -b 0 $DIR/$tfile || error "write 0 byte failed"
21381 run_test 815 "zero byte tiny write doesn't hang (LU-12382)"
21384 [ "$SHARED_KEY" = true ] &&
21385 skip "OSC connections never go IDLE with Shared-Keys enabled"
21387 $LFS setstripe -c 1 -i 0 $DIR/$tfile
21388 # ensure ost1 is connected
21389 stat $DIR/$tfile >/dev/null || error "can't stat"
21390 wait_osc_import_state client ost1 FULL
21391 # no locks, no reqs to let the connection idle
21392 cancel_lru_locks osc
21393 lru_resize_disable osc
21396 before=$($LCTL get_param -n \
21397 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
21399 wait_osc_import_state client ost1 IDLE
21400 dd if=/dev/null of=$DIR/$tfile bs=1k count=1 conv=sync
21401 now=$($LCTL get_param -n \
21402 ldlm.namespaces.$FSNAME-OST0000-osc-[^M]*.lru_size)
21403 [ $before == $now ] || error "lru_size changed $before != $now"
21405 run_test 816 "do not reset lru_resize on idle reconnect"
21409 exportfs -u localhost:$DIR/nfsexp
21414 systemctl restart nfs-server.service || skip "failed to restart nfsd"
21416 mkdir -p $DIR/nfsexp
21417 exportfs -orw,no_root_squash localhost:$DIR/nfsexp ||
21418 error "failed to export nfs"
21420 tmpdir=$(mktemp -d /tmp/nfs-XXXXXX)
21421 stack_trap cleanup_817 EXIT
21423 mount -t nfs -orw localhost:$DIR/nfsexp $tmpdir ||
21424 error "failed to mount nfs to $tmpdir"
21426 cp /bin/true $tmpdir
21427 $DIR/nfsexp/true || error "failed to execute 'true' command"
21429 run_test 817 "nfsd won't cache write lock for exec file"
21432 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21433 cancel_lru_locks osc
21434 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
21435 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
21436 dd if=$DIR/$tfile of=/dev/null bs=1M count=1
21439 run_test 819a "too big niobuf in read"
21442 #define OBD_FAIL_OST_2BIG_NIOBUF 0x248
21443 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000248
21444 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21445 cancel_lru_locks osc
21449 run_test 819b "too big niobuf in write"
21453 $LFS setstripe -c1 -i0 $DIR/$tfile
21454 $LFS setstripe -c1 -i1 $DIR/$tfile
21456 #define OBD_FAIL_OSP_CANT_PROCESS_LLOG 0x2105
21457 do_facet $SINGLEMDS lctl set_param fail_loc=0x80002105
21458 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
21459 error "start $SINGLEMDS failed"
21462 run_test 818 "unlink with failed llog"
21465 # tests that do cleanup/setup should be run at the end
21469 [ $PARALLEL == "yes" ] && skip "skip parallel run"
21472 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
21473 $LCTL set_param fail_loc=0x903
21475 cancel_lru_locks MGC
21477 FAIL_ON_ERROR=true cleanup
21478 FAIL_ON_ERROR=true setup
21480 run_test 900 "umount should not race with any mgc requeue thread"
21484 [ $CLIENT_VERSION -lt $(version_code 2.13.52) ] &&
21485 skip "client does not have LU-13377 fix"
21486 #define OBD_FAIL_LLITE_SHORT_COMMIT 0x1415
21487 $LCTL set_param fail_loc=0x1415
21488 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
21489 cancel_lru_locks osc
21492 run_test 902 "test short write doesn't hang lustre"
21495 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
21496 check_and_cleanup_lustre
21497 if [ "$I_MOUNTED" != "yes" ]; then
21498 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true