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}
75 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
77 if [ "$mds1_FSTYPE" = "zfs" ]; then
78 # bug number for skipped test: LU-1957
79 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
84 # Get the SLES distro version
86 # Returns a version string that should only be used in comparing
87 # strings returned by version_code()
90 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
92 # All SuSE Linux versions have one decimal. version_code expects two
93 local sles_version=$version.0
94 version_code $sles_version
97 # Check if we are running on Ubuntu or SLES so we can make decisions on
99 if [ -r /etc/SuSE-release ]; then
100 sles_version=$(sles_version_code)
101 [ $sles_version -lt $(version_code 11.4.0) ] &&
102 # bug number for skipped test: LU-4341
103 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
104 [ $sles_version -lt $(version_code 12.0.0) ] &&
105 # bug number for skipped test: LU-3703
106 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
107 elif [ -r /etc/os-release ]; then
108 if grep -qi ubuntu /etc/os-release; then
109 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
110 -e 's/^VERSION=//p' \
114 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
115 # bug number for skipped test:
117 ALWAYS_EXCEPT+=" 103a 410"
126 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
127 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
136 check_swap_layouts_support()
138 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
139 skip "Does not support layout lock."
142 check_and_setup_lustre
146 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
148 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
149 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
150 rm -rf $DIR/[Rdfs][0-9]*
152 # $RUNAS_ID may get set incorrectly somewhere else
153 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
154 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
156 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
160 if [ "${ONLY}" = "MOUNT" ] ; then
161 echo "Lustre is up, please go on"
165 echo "preparing for tests involving mounts"
166 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
168 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
169 echo # add a newline after mke2fs.
173 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
174 lctl set_param debug=-1 2> /dev/null || true
177 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
179 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
181 run_test 0a "touch; rm ====================="
184 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
185 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
187 run_test 0b "chmod 0755 $DIR ============================="
190 $LCTL get_param mdc.*.import | grep "state: FULL" ||
191 error "import not FULL"
192 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
195 run_test 0c "check import proc"
197 test_0d() { # LU-3397
198 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
199 skip "proc exports not supported before 2.10.57"
201 local mgs_exp="mgs.MGS.exports"
202 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
204 local exp_client_version
207 local temp_imp=$DIR/$tfile.import
208 local temp_exp=$DIR/$tfile.export
210 # save mgc import file to $temp_imp
211 $LCTL get_param mgc.*.import | tee $temp_imp
212 # Check if client uuid is found in MGS export
213 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
214 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
218 # save mgs export file to $temp_exp
219 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
221 # Compare the value of field "connect_flags"
222 imp_val=$(grep "connect_flags" $temp_imp)
223 exp_val=$(grep "connect_flags" $temp_exp)
224 [ "$exp_val" == "$imp_val" ] ||
225 error "export flags '$exp_val' != import flags '$imp_val'"
227 # Compare the value of client version
228 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
229 exp_val=$(version_code $exp_client_version)
230 imp_val=$CLIENT_VERSION
231 [ "$exp_val" == "$imp_val" ] ||
232 error "export client version '$exp_val' != '$imp_val'"
234 run_test 0d "check export proc ============================="
237 test_mkdir $DIR/$tdir
238 test_mkdir $DIR/$tdir/d2
239 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
240 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
243 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
245 run_test 1 "mkdir; remkdir; rmdir"
248 test_mkdir $DIR/$tdir
249 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
250 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
252 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
254 run_test 2 "mkdir; touch; rmdir; check file"
257 test_mkdir $DIR/$tdir
258 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
259 touch $DIR/$tdir/$tfile
260 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
262 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
264 run_test 3 "mkdir; touch; rmdir; check dir"
266 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
268 test_mkdir -i 1 $DIR/$tdir
270 touch $DIR/$tdir/$tfile ||
271 error "Create file under remote directory failed"
274 error "Expect error removing in-use dir $DIR/$tdir"
276 test -d $DIR/$tdir || error "Remote directory disappeared"
278 rm -rf $DIR/$tdir || error "remove remote dir error"
280 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
283 test_mkdir $DIR/$tdir
284 test_mkdir $DIR/$tdir/d2
285 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
286 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
287 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
289 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
292 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
293 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
294 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
295 error "$tfile does not have perm 0666 or UID $UID"
296 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile should be 0666 and owned by UID $UID"
300 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
303 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
306 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
307 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
308 error "$tfile should be owned by UID $RUNAS_ID"
309 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
313 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
316 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
319 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
320 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
321 error "$tfile should be owned by GID $UID"
322 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
326 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
329 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
331 test_mkdir $DIR/$tdir
332 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
333 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
334 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
335 test_mkdir $DIR/$tdir/d/subdir
336 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
337 error "$tdir/d/subdir should be GID $RUNAS_GID"
338 if [[ $MDSCOUNT -gt 1 ]]; then
339 # check remote dir sgid inherite
340 $LFS mkdir -i 0 $DIR/$tdir.local ||
341 error "mkdir $tdir.local failed"
342 chmod g+s $DIR/$tdir.local ||
343 error "chmod $tdir.local failed"
344 chgrp $RUNAS_GID $DIR/$tdir.local ||
345 error "chgrp $tdir.local failed"
346 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
347 error "mkdir $tdir.remote failed"
348 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
349 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
350 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
351 error "$tdir.remote should be mode 02755"
354 run_test 6g "verify new dir in sgid dir inherits group"
356 test_6h() { # bug 7331
357 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
359 touch $DIR/$tfile || error "touch failed"
360 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
361 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
362 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
363 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
364 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
366 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
369 test_mkdir $DIR/$tdir
370 $MCREATE $DIR/$tdir/$tfile
371 chmod 0666 $DIR/$tdir/$tfile
372 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
373 error "$tdir/$tfile should be mode 0666"
375 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
378 if [ ! -d $DIR/$tdir ]; then
379 test_mkdir $DIR/$tdir
381 $MCREATE $DIR/$tdir/$tfile
382 echo -n foo > $DIR/$tdir/$tfile
383 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
384 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
386 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
389 test_mkdir $DIR/$tdir
390 touch $DIR/$tdir/$tfile
391 chmod 0666 $DIR/$tdir/$tfile
392 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
393 error "$tfile mode not 0666"
395 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
398 test_mkdir $DIR/$tdir
399 test_mkdir $DIR/$tdir/d2
400 test_mkdir $DIR/$tdir/d2/d3
401 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
403 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
406 test_mkdir $DIR/$tdir
407 test_mkdir $DIR/$tdir/d2
408 touch $DIR/$tdir/d2/$tfile
409 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
410 error "$tdir/d2/$tfile not a file"
412 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
415 test_mkdir $DIR/$tdir
416 test_mkdir $DIR/$tdir/d2
417 chmod 0666 $DIR/$tdir/d2
418 chmod 0705 $DIR/$tdir/d2
419 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
420 error "$tdir/d2 mode not 0705"
422 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
425 test_mkdir $DIR/$tdir
426 touch $DIR/$tdir/$tfile
427 chmod 0666 $DIR/$tdir/$tfile
428 chmod 0654 $DIR/$tdir/$tfile
429 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
430 error "$tdir/d2 mode not 0654"
432 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
435 test_mkdir $DIR/$tdir
436 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
438 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
439 error "$tdir/$tfile size not 0 after truncate"
441 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
444 test_mkdir $DIR/$tdir
445 touch $DIR/$tdir/$tfile
447 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
449 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
452 test_mkdir $DIR/$tdir
453 touch $DIR/$tdir/$tfile
454 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
455 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
456 error "$tdir/${tfile_2} not a file after rename"
457 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
459 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
462 test_mkdir $DIR/$tdir
463 touch $DIR/$tdir/$tfile
464 rm -rf $DIR/$tdir/$tfile
465 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
467 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
470 test_mkdir $DIR/$tdir
471 touch $DIR/$tdir/$tfile
472 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
474 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
475 error "$tdir/l-exist not a symlink"
476 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
477 error "$tdir/l-exist not referencing a file"
478 rm -f $DIR/$tdir/l-exist
479 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
481 run_test 17a "symlinks: create, remove (real)"
484 test_mkdir $DIR/$tdir
485 ln -s no-such-file $DIR/$tdir/l-dangle
487 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
488 error "$tdir/l-dangle not referencing no-such-file"
489 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
490 error "$tdir/l-dangle not referencing non-existent file"
491 rm -f $DIR/$tdir/l-dangle
492 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
494 run_test 17b "symlinks: create, remove (dangling)"
496 test_17c() { # bug 3440 - don't save failed open RPC for replay
497 test_mkdir $DIR/$tdir
498 ln -s foo $DIR/$tdir/$tfile
499 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
501 run_test 17c "symlinks: open dangling (should return error)"
504 test_mkdir $DIR/$tdir
505 ln -s foo $DIR/$tdir/$tfile
506 touch $DIR/$tdir/$tfile || error "creating to new symlink"
508 run_test 17d "symlinks: create dangling"
511 test_mkdir $DIR/$tdir
512 local foo=$DIR/$tdir/$tfile
513 ln -s $foo $foo || error "create symlink failed"
514 ls -l $foo || error "ls -l failed"
515 ls $foo && error "ls not failed" || true
517 run_test 17e "symlinks: create recursive symlink (should return error)"
520 test_mkdir $DIR/$tdir
521 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
522 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
523 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
524 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
526 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
529 run_test 17f "symlinks: long and very long symlink name"
531 # str_repeat(S, N) generate a string that is string S repeated N times
536 while [ $((n -= 1)) -ge 0 ]; do
542 # Long symlinks and LU-2241
544 test_mkdir $DIR/$tdir
545 local TESTS="59 60 61 4094 4095"
547 # Fix for inode size boundary in 2.1.4
548 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
551 # Patch not applied to 2.2 or 2.3 branches
552 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
553 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
556 # skip long symlink name for rhel6.5.
557 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
558 grep -q '6.5' /etc/redhat-release &>/dev/null &&
559 TESTS="59 60 61 4062 4063"
562 local SYMNAME=$(str_repeat 'x' $i)
563 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
564 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
567 run_test 17g "symlinks: really long symlink name and inode boundaries"
569 test_17h() { #bug 17378
570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
571 remote_mds_nodsh && skip "remote MDS with nodsh"
575 test_mkdir $DIR/$tdir
576 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
577 $LFS setstripe -c -1 $DIR/$tdir
578 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
579 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
580 touch $DIR/$tdir/$tfile || true
582 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
584 test_17i() { #bug 20018
585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
586 remote_mds_nodsh && skip "remote MDS with nodsh"
588 local foo=$DIR/$tdir/$tfile
591 test_mkdir -c1 $DIR/$tdir
592 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
593 ln -s $foo $foo || error "create symlink failed"
594 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
595 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
596 ls -l $foo && error "error not detected"
599 run_test 17i "don't panic on short symlink (should return error)"
601 test_17k() { #bug 22301
602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
603 [[ -z "$(which rsync 2>/dev/null)" ]] &&
604 skip "no rsync command"
605 rsync --help | grep -q xattr ||
606 skip_env "$(rsync --version | head -n1) does not support xattrs"
607 test_mkdir $DIR/$tdir
608 test_mkdir $DIR/$tdir.new
609 touch $DIR/$tdir/$tfile
610 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
611 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
612 error "rsync failed with xattrs enabled"
614 run_test 17k "symlinks: rsync with xattrs enabled"
616 test_17l() { # LU-279
617 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
618 skip "no getfattr command"
620 test_mkdir $DIR/$tdir
621 touch $DIR/$tdir/$tfile
622 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
623 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
624 # -h to not follow symlinks. -m '' to list all the xattrs.
625 # grep to remove first line: '# file: $path'.
626 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
628 lgetxattr_size_check $path $xattr ||
629 error "lgetxattr_size_check $path $xattr failed"
633 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
638 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
639 remote_mds_nodsh && skip "remote MDS with nodsh"
640 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
641 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
642 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
644 local short_sym="0123456789"
645 local wdir=$DIR/$tdir
650 # create a long symlink file
651 for ((i = 0; i < 4; ++i)); do
652 long_sym=${long_sym}${long_sym}
655 echo "create 512 short and long symlink files under $wdir"
656 for ((i = 0; i < 256; ++i)); do
657 ln -sf ${long_sym}"a5a5" $wdir/long-$i
658 ln -sf ${short_sym}"a5a5" $wdir/short-$i
664 wait_delete_completed
666 echo "recreate the 512 symlink files with a shorter string"
667 for ((i = 0; i < 512; ++i)); do
668 # rewrite the symlink file with a shorter string
669 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
670 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
673 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
674 local devname=$(mdsdevname $mds_index)
676 echo "stop and checking mds${mds_index}:"
677 # e2fsck should not return error
679 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
682 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
683 error "start mds${mds_index} failed"
684 df $MOUNT > /dev/null 2>&1
686 error "e2fsck detected error for short/long symlink: rc=$rc"
689 run_test 17m "run e2fsck against MDT which contains short/long symlink"
691 check_fs_consistency_17n() {
695 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
696 # so it only check MDT1/MDT2 instead of all of MDTs.
697 for mdt_index in 1 2; do
698 local devname=$(mdsdevname $mdt_index)
699 # e2fsck should not return error
701 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
704 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
705 error "mount mds$mdt_index failed"
706 df $MOUNT > /dev/null 2>&1
712 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
714 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
715 remote_mds_nodsh && skip "remote MDS with nodsh"
716 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
717 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
718 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
722 test_mkdir $DIR/$tdir
723 for ((i=0; i<10; i++)); do
724 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
725 error "create remote dir error $i"
726 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
727 error "create files under remote dir failed $i"
730 check_fs_consistency_17n ||
731 error "e2fsck report error after create files under remote dir"
733 for ((i = 0; i < 10; i++)); do
734 rm -rf $DIR/$tdir/remote_dir_${i} ||
735 error "destroy remote dir error $i"
738 check_fs_consistency_17n ||
739 error "e2fsck report error after unlink files under remote dir"
741 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
742 skip "lustre < 2.4.50 does not support migrate mv"
744 for ((i = 0; i < 10; i++)); do
745 mkdir -p $DIR/$tdir/remote_dir_${i}
746 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
747 error "create files under remote dir failed $i"
748 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
749 error "migrate remote dir error $i"
751 check_fs_consistency_17n || error "e2fsck report error after migration"
753 for ((i = 0; i < 10; i++)); do
754 rm -rf $DIR/$tdir/remote_dir_${i} ||
755 error "destroy remote dir error $i"
758 check_fs_consistency_17n || error "e2fsck report error after unlink"
760 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
763 remote_mds_nodsh && skip "remote MDS with nodsh"
764 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
765 skip "Need MDS version at least 2.3.64"
767 local wdir=$DIR/${tdir}o
773 mdt_index=$($LFS getstripe -m $wdir/$tfile)
774 mdt_index=$((mdt_index + 1))
777 #fail mds will wait the failover finish then set
778 #following fail_loc to avoid interfer the recovery process.
781 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
782 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
783 ls -l $wdir/$tfile && rc=1
784 do_facet mds${mdt_index} lctl set_param fail_loc=0
785 [[ $rc -eq 0 ]] || error "stat file should fail"
787 run_test 17o "stat file with incompat LMA feature"
790 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
791 ls $DIR || error "Failed to ls $DIR: $?"
793 run_test 18 "touch .../f ; ls ... =============================="
799 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
801 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
804 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
806 run_test 19b "ls -l .../f19 (should return error) =============="
809 [ $RUNAS_ID -eq $UID ] &&
810 skip_env "RUNAS_ID = UID = $UID -- skipping"
812 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
814 run_test 19c "$RUNAS touch .../f19 (should return error) =="
817 cat $DIR/f19 && error || true
819 run_test 19d "cat .../f19 (should return error) =============="
828 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
830 run_test 20 "touch .../f ; ls -l ..."
833 test_mkdir $DIR/$tdir
834 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
835 ln -s dangle $DIR/$tdir/link
836 echo foo >> $DIR/$tdir/link
837 cat $DIR/$tdir/dangle
838 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
839 $CHECKSTAT -f -t file $DIR/$tdir/link ||
840 error "$tdir/link not linked to a file"
842 run_test 21 "write to dangling link"
845 local wdir=$DIR/$tdir
847 chown $RUNAS_ID:$RUNAS_GID $wdir
848 (cd $wdir || error "cd $wdir failed";
849 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
851 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
852 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
853 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
854 error "checkstat -u failed"
856 run_test 22 "unpack tar archive as non-root user"
860 test_mkdir $DIR/$tdir
861 local file=$DIR/$tdir/$tfile
863 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
864 openfile -f O_CREAT:O_EXCL $file &&
865 error "$file recreate succeeded" || true
867 run_test 23a "O_CREAT|O_EXCL in subdir"
869 test_23b() { # bug 18988
870 test_mkdir $DIR/$tdir
871 local file=$DIR/$tdir/$tfile
874 echo foo > $file || error "write filed"
875 echo bar >> $file || error "append filed"
876 $CHECKSTAT -s 8 $file || error "wrong size"
879 run_test 23b "O_APPEND check"
881 # LU-9409, size with O_APPEND and tiny writes
883 local file=$DIR/$tfile
886 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
887 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
891 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
894 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
897 #racing tiny & normal writes
898 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
899 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
901 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
904 #racing tiny & normal writes 2, ugly numbers
905 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
906 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
908 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
911 run_test 23c "O_APPEND size checks for tiny writes"
913 # LU-11069 file offset is correct after appending writes
915 local file=$DIR/$tfile
918 echo CentaurHauls > $file
919 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
920 if ((offset != 26)); then
921 error "wrong offset, expected 26, got '$offset'"
924 run_test 23d "file offset is correct after appending writes"
928 echo '-- same directory rename'
929 test_mkdir $DIR/$tdir
930 touch $DIR/$tdir/$tfile.1
931 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
932 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
934 run_test 24a "rename file to non-existent target"
937 test_mkdir $DIR/$tdir
938 touch $DIR/$tdir/$tfile.{1,2}
939 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
940 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
941 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
943 run_test 24b "rename file to existing target"
946 test_mkdir $DIR/$tdir
947 test_mkdir $DIR/$tdir/d$testnum.1
948 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
949 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
950 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
952 run_test 24c "rename directory to non-existent target"
955 test_mkdir -c1 $DIR/$tdir
956 test_mkdir -c1 $DIR/$tdir/d$testnum.1
957 test_mkdir -c1 $DIR/$tdir/d$testnum.2
958 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
959 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
960 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
962 run_test 24d "rename directory to existing target"
965 echo '-- cross directory renames --'
969 mv $DIR/R5a/f $DIR/R5b/g
970 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
971 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
973 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
978 touch $DIR/R6a/f $DIR/R6b/g
979 mv $DIR/R6a/f $DIR/R6b/g
980 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
981 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
983 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
988 test_mkdir $DIR/R7a/d
989 mv $DIR/R7a/d $DIR/R7b/e
990 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
991 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
993 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
996 test_mkdir -c1 $DIR/R8a
997 test_mkdir -c1 $DIR/R8b
998 test_mkdir -c1 $DIR/R8a/d
999 test_mkdir -c1 $DIR/R8b/e
1000 mrename $DIR/R8a/d $DIR/R8b/e
1001 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1002 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1004 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1007 echo "-- rename error cases"
1009 test_mkdir $DIR/R9/a
1011 mrename $DIR/R9/f $DIR/R9/a
1012 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1013 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1014 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1016 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1020 mrename $DIR/R10/f $DIR/R10/g
1021 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1022 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1023 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1025 run_test 24j "source does not exist ============================"
1028 test_mkdir $DIR/R11a
1029 test_mkdir $DIR/R11a/d
1031 mv $DIR/R11a/f $DIR/R11a/d
1032 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1033 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1035 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1037 # bug 2429 - rename foo foo foo creates invalid file
1040 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1042 run_test 24l "Renaming a file to itself ========================"
1046 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1047 # on ext3 this does not remove either the source or target files
1048 # though the "expected" operation would be to remove the source
1049 $CHECKSTAT -t file ${f} || error "${f} missing"
1050 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1052 run_test 24m "Renaming a file to a hard link to itself ========="
1056 # this stats the old file after it was renamed, so it should fail
1058 $CHECKSTAT ${f} || error "${f} missing"
1060 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1061 $CHECKSTAT -a ${f} || error "${f} exists"
1063 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1066 test_mkdir $DIR/$tdir
1067 rename_many -s random -v -n 10 $DIR/$tdir
1069 run_test 24o "rename of files during htree split"
1072 test_mkdir $DIR/R12a
1073 test_mkdir $DIR/R12b
1074 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1075 mrename $DIR/R12a $DIR/R12b
1076 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1077 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1078 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1079 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1081 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1083 cleanup_multiop_pause() {
1085 kill -USR1 $MULTIPID
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1091 test_mkdir $DIR/R13a
1092 test_mkdir $DIR/R13b
1093 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1094 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1097 trap cleanup_multiop_pause EXIT
1098 mrename $DIR/R13a $DIR/R13b
1099 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1100 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1101 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1102 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1103 cleanup_multiop_pause
1104 wait $MULTIPID || error "multiop close failed"
1106 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1108 test_24r() { #bug 3789
1109 test_mkdir $DIR/R14a
1110 test_mkdir $DIR/R14a/b
1111 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1112 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1113 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1115 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1118 test_mkdir $DIR/R15a
1119 test_mkdir $DIR/R15a/b
1120 test_mkdir $DIR/R15a/b/c
1121 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1122 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1123 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1125 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1127 test_mkdir $DIR/R16a
1128 test_mkdir $DIR/R16a/b
1129 test_mkdir $DIR/R16a/b/c
1130 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1131 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1132 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1134 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1136 test_24u() { # bug12192
1137 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1138 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1140 run_test 24u "create stripe file"
1142 simple_cleanup_common() {
1145 [ -z "$DIR" -o -z "$tdir" ] && return 0
1147 local start=$SECONDS
1150 wait_delete_completed
1151 echo "cleanup time $((SECONDS - start))"
1155 max_pages_per_rpc() {
1156 local mdtname="$(printf "MDT%04x" ${1:-0})"
1157 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1163 local nrfiles=${COUNT:-100000}
1164 local fname="$DIR/$tdir/$tfile"
1166 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1167 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1169 test_mkdir "$(dirname $fname)"
1170 # assume MDT0000 has the fewest inodes
1171 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1172 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1173 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1175 trap simple_cleanup_common EXIT
1177 createmany -m "$fname" $nrfiles
1179 cancel_lru_locks mdc
1180 lctl set_param mdc.*.stats clear
1182 # was previously test_24D: LU-6101
1183 # readdir() returns correct number of entries after cursor reload
1184 local num_ls=$(ls $DIR/$tdir | wc -l)
1185 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1186 local num_all=$(ls -a $DIR/$tdir | wc -l)
1187 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1188 $num_all -ne $((nrfiles + 2)) ]; then
1189 error "Expected $nrfiles files, got $num_ls " \
1190 "($num_uniq unique $num_all .&..)"
1192 # LU-5 large readdir
1193 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1194 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1195 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1196 # take into account of overhead in lu_dirpage header and end mark in
1197 # each page, plus one in rpc_num calculation.
1198 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1199 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1200 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1201 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1202 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1203 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1204 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1205 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1206 error "large readdir doesn't take effect: " \
1207 "$mds_readpage should be about $rpc_max"
1209 simple_cleanup_common
1211 run_test 24v "list large directory (test hash collision, b=17560)"
1213 test_24w() { # bug21506
1215 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1216 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1217 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1218 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1219 [[ "$SZ1" -eq "$SZ2" ]] ||
1220 error "Error reading at the end of the file $tfile"
1222 run_test 24w "Reading a file larger than 4Gb"
1225 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1227 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1228 skip "Need MDS version at least 2.7.56"
1231 local remote_dir=$DIR/$tdir/remote_dir
1233 test_mkdir $DIR/$tdir
1234 $LFS mkdir -i $MDTIDX $remote_dir ||
1235 error "create remote directory failed"
1237 test_mkdir $DIR/$tdir/src_dir
1238 touch $DIR/$tdir/src_file
1239 test_mkdir $remote_dir/tgt_dir
1240 touch $remote_dir/tgt_file
1242 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1243 error "rename dir cross MDT failed!"
1245 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1246 error "rename file cross MDT failed!"
1248 touch $DIR/$tdir/ln_file
1249 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1250 error "ln file cross MDT failed"
1252 rm -rf $DIR/$tdir || error "Can not delete directories"
1254 run_test 24x "cross MDT rename/link"
1257 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1260 local remote_dir=$DIR/$tdir/remote_dir
1263 test_mkdir $DIR/$tdir
1264 $LFS mkdir -i $mdtidx $remote_dir ||
1265 error "create remote directory failed"
1267 test_mkdir $remote_dir/src_dir
1268 touch $remote_dir/src_file
1269 test_mkdir $remote_dir/tgt_dir
1270 touch $remote_dir/tgt_file
1272 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1273 error "rename subdir in the same remote dir failed!"
1275 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1276 error "rename files in the same remote dir failed!"
1278 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1279 error "link files in the same remote dir failed!"
1281 rm -rf $DIR/$tdir || error "Can not delete directories"
1283 run_test 24y "rename/link on the same dir should succeed"
1286 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1287 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
1288 skip "Need MDS version at least 2.12.51"
1292 for index in 0 1; do
1293 $LFS mkdir -i $index $DIR/$tdir.$index || error "mkdir failed"
1294 touch $DIR/$tdir.0/$tfile.$index || error "touch failed"
1297 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1 || error "mv $tfile.0 failed"
1299 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.0)
1300 [ $index -eq 0 ] || error "$tfile.0 is on MDT$index"
1302 local mdts=$(comma_list $(mdts_nodes))
1304 do_nodes $mdts $LCTL set_param mdt.*.enable_remote_rename=0
1305 stack_trap "do_nodes $mdts $LCTL \
1306 set_param mdt.*.enable_remote_rename=1" EXIT
1308 mv $DIR/$tdir.0/$tfile.1 $DIR/$tdir.1 || error "mv $tfile.1 failed"
1310 index=$($LFS getstripe -m $DIR/$tdir.1/$tfile.1)
1311 [ $index -eq 1 ] || error "$tfile.1 is on MDT$index"
1313 run_test 24z "cross-MDT rename is done as cp"
1315 test_24A() { # LU-3182
1319 test_mkdir $DIR/$tdir
1320 trap simple_cleanup_common EXIT
1321 createmany -m $DIR/$tdir/$tfile $NFILES
1322 local t=$(ls $DIR/$tdir | wc -l)
1323 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1324 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1325 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1326 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1329 simple_cleanup_common || error "Can not delete directories"
1331 run_test 24A "readdir() returns correct number of entries."
1333 test_24B() { # LU-4805
1334 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1338 test_mkdir $DIR/$tdir
1339 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1340 error "create striped dir failed"
1342 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1343 [ $count -eq 2 ] || error "Expected 2, got $count"
1345 touch $DIR/$tdir/striped_dir/a
1347 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1348 [ $count -eq 3 ] || error "Expected 3, got $count"
1350 touch $DIR/$tdir/striped_dir/.f
1352 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1353 [ $count -eq 4 ] || error "Expected 4, got $count"
1355 rm -rf $DIR/$tdir || error "Can not delete directories"
1357 run_test 24B "readdir for striped dir return correct number of entries"
1360 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1366 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1367 error "create striped dir failed"
1369 cd $DIR/$tdir/d0/striped_dir
1371 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1372 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1373 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1375 [ "$d0_ino" = "$parent_ino" ] ||
1376 error ".. wrong, expect $d0_ino, get $parent_ino"
1378 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1379 error "mv striped dir failed"
1381 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1383 [ "$d1_ino" = "$parent_ino" ] ||
1384 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1386 run_test 24C "check .. in striped dir"
1389 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1393 mkdir $DIR/$tdir/src_dir
1394 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1395 error "create remote source failed"
1397 touch $DIR/$tdir/src_dir/src_child/a
1399 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1400 error "create remote target dir failed"
1402 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1403 error "create remote target child failed"
1405 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1406 error "rename dir cross MDT failed!"
1410 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1411 error "src_child still exists after rename"
1413 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1414 error "missing file(a) after rename"
1416 rm -rf $DIR/$tdir || error "Can not delete directories"
1418 run_test 24E "cross MDT rename/link"
1421 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1424 [ "$SLOW" = "no" ] && repeats=100
1428 echo "$repeats repeats"
1429 for ((i = 0; i < repeats; i++)); do
1430 $LFS mkdir -i0 -c2 $DIR/$tdir/test || error "mkdir fails"
1431 touch $DIR/$tdir/test/a || error "touch fails"
1432 mkdir $DIR/$tdir/test/b || error "mkdir fails"
1433 rm -rf $DIR/$tdir/test || error "rmdir fails"
1438 run_test 24F "hash order vs readdir (LU-11330)"
1441 echo '== symlink sanity ============================================='
1445 touch $DIR/s25/foo ||
1446 error "File creation in symlinked directory failed"
1448 run_test 25a "create file in symlinked directory ==============="
1451 [ ! -d $DIR/d25 ] && test_25a
1452 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1454 run_test 25b "lookup file in symlinked directory ==============="
1458 test_mkdir $DIR/d26/d26-2
1459 ln -s d26/d26-2 $DIR/s26
1460 touch $DIR/s26/foo || error "File creation failed"
1462 run_test 26a "multiple component symlink ======================="
1465 test_mkdir -p $DIR/$tdir/d26-2
1466 ln -s $tdir/d26-2/foo $DIR/s26-2
1467 touch $DIR/s26-2 || error "File creation failed"
1469 run_test 26b "multiple component symlink at end of lookup ======"
1472 test_mkdir $DIR/d26.2
1473 touch $DIR/d26.2/foo
1474 ln -s d26.2 $DIR/s26.2-1
1475 ln -s s26.2-1 $DIR/s26.2-2
1476 ln -s s26.2-2 $DIR/s26.2-3
1477 chmod 0666 $DIR/s26.2-3/foo
1479 run_test 26c "chain of symlinks"
1481 # recursive symlinks (bug 439)
1483 ln -s d26-3/foo $DIR/d26-3
1485 run_test 26d "create multiple component recursive symlink"
1488 [ ! -h $DIR/d26-3 ] && test_26d
1491 run_test 26e "unlink multiple component recursive symlink"
1493 # recursive symlinks (bug 7022)
1495 test_mkdir $DIR/$tdir
1496 test_mkdir $DIR/$tdir/$tfile
1497 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1498 test_mkdir -p lndir/bar1
1499 test_mkdir $DIR/$tdir/$tfile/$tfile
1500 cd $tfile || error "cd $tfile failed"
1501 ln -s .. dotdot || error "ln dotdot failed"
1502 ln -s dotdot/lndir lndir || error "ln lndir failed"
1503 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1504 output=`ls $tfile/$tfile/lndir/bar1`
1505 [ "$output" = bar1 ] && error "unexpected output"
1506 rm -r $tfile || error "rm $tfile failed"
1507 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1509 run_test 26f "rm -r of a directory which has recursive symlink"
1512 test_mkdir $DIR/$tdir
1513 $LFS getstripe $DIR/$tdir
1514 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1515 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1516 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1518 run_test 27a "one stripe file"
1521 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1523 test_mkdir $DIR/$tdir
1524 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1525 $LFS getstripe -c $DIR/$tdir/$tfile
1526 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1527 error "two-stripe file doesn't have two stripes"
1529 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1531 run_test 27b "create and write to two stripe file"
1534 test_mkdir $DIR/$tdir
1535 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1536 error "setstripe failed"
1537 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1538 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1540 run_test 27d "create file with default settings"
1543 # LU-5839 adds check for existed layout before setting it
1544 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1545 skip "Need MDS version at least 2.7.56"
1547 test_mkdir $DIR/$tdir
1548 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1549 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1550 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1552 run_test 27e "setstripe existing file (should return error)"
1555 test_mkdir $DIR/$tdir
1556 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1557 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1558 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1559 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1560 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1561 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1563 run_test 27f "setstripe with bad stripe size (should return error)"
1566 test_mkdir $DIR/$tdir
1567 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1568 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1569 error "$DIR/$tdir/$tfile has object"
1571 run_test 27g "$LFS getstripe with no objects"
1574 test_mkdir $DIR/$tdir
1575 touch $DIR/$tdir/$tfile || error "touch failed"
1576 ln -s bogus $DIR/$tdir/$tfile.2 || error "ln failed"
1577 $LFS getstripe -m $DIR/$tdir/$tfile $DIR/$tdir/$tfile.2
1579 (( rc == 2 )) || error "getstripe did not return ENOENT"
1581 run_test 27ga "$LFS getstripe with missing file (should return error)"
1584 test_mkdir $DIR/$tdir
1585 touch $DIR/$tdir/$tfile || error "touch failed"
1586 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1587 error "missing objects"
1589 run_test 27i "$LFS getstripe with some objects"
1592 test_mkdir $DIR/$tdir
1593 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1594 error "setstripe failed" || true
1596 run_test 27j "setstripe with bad stripe offset (should return error)"
1598 test_27k() { # bug 2844
1599 test_mkdir $DIR/$tdir
1600 local file=$DIR/$tdir/$tfile
1601 local ll_max_blksize=$((4 * 1024 * 1024))
1602 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1603 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1604 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1605 dd if=/dev/zero of=$file bs=4k count=1
1606 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1607 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1609 run_test 27k "limit i_blksize for broken user apps"
1612 mcreate $DIR/$tfile || error "creating file"
1613 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1614 error "setstripe should have failed" || true
1616 run_test 27l "check setstripe permissions (should return error)"
1619 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1621 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1623 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1624 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1626 trap simple_cleanup_common EXIT
1627 test_mkdir $DIR/$tdir
1628 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1629 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1630 error "dd should fill OST0"
1632 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1634 [ $i -gt 256 ] && break
1637 touch $DIR/$tdir/$tfile.$i
1638 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1639 awk '{print $1}'| grep -w "0") ] &&
1640 error "OST0 was full but new created file still use it"
1642 touch $DIR/$tdir/$tfile.$i
1643 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1644 awk '{print $1}'| grep -w "0") ] &&
1645 error "OST0 was full but new created file still use it"
1646 simple_cleanup_common
1648 run_test 27m "create file while OST0 was full"
1651 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1652 awk '{ print $1 * 2; exit; }')
1656 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1657 # if the OST isn't full anymore.
1659 local OSTIDX=${1:-""}
1661 local list=$(comma_list $(osts_nodes))
1662 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1664 do_nodes $list lctl set_param fail_loc=0
1665 sync # initiate all OST_DESTROYs from MDS to OST
1669 exhaust_precreations() {
1672 local FAILIDX=${3:-$OSTIDX}
1673 local ofacet=ost$((OSTIDX + 1))
1675 test_mkdir -p -c1 $DIR/$tdir
1676 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1677 local mfacet=mds$((mdtidx + 1))
1678 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1680 local OST=$(ostname_from_index $OSTIDX)
1683 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1684 local last_id=$(do_facet $mfacet lctl get_param -n \
1685 osc.$mdtosc_proc1.prealloc_last_id)
1686 local next_id=$(do_facet $mfacet lctl get_param -n \
1687 osc.$mdtosc_proc1.prealloc_next_id)
1689 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1690 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1692 test_mkdir -p $DIR/$tdir/${OST}
1693 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1694 #define OBD_FAIL_OST_ENOSPC 0x215
1695 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1696 echo "Creating to objid $last_id on ost $OST..."
1697 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1698 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1699 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1703 exhaust_all_precreations() {
1705 for (( i=0; i < OSTCOUNT; i++ )) ; do
1706 exhaust_precreations $i $1 -1
1711 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1713 remote_mds_nodsh && skip "remote MDS with nodsh"
1714 remote_ost_nodsh && skip "remote OST with nodsh"
1717 rm -f $DIR/$tdir/$tfile
1718 exhaust_precreations 0 0x80000215
1719 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1720 touch $DIR/$tdir/$tfile || error "touch failed"
1721 $LFS getstripe $DIR/$tdir/$tfile
1724 run_test 27n "create file with some full OSTs"
1727 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1728 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1729 remote_mds_nodsh && skip "remote MDS with nodsh"
1730 remote_ost_nodsh && skip "remote OST with nodsh"
1733 rm -f $DIR/$tdir/$tfile
1734 exhaust_all_precreations 0x215
1736 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1741 run_test 27o "create file with all full OSTs (should error)"
1744 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1745 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1746 remote_mds_nodsh && skip "remote MDS with nodsh"
1747 remote_ost_nodsh && skip "remote OST with nodsh"
1750 rm -f $DIR/$tdir/$tfile
1751 test_mkdir $DIR/$tdir
1753 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1754 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1755 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1757 exhaust_precreations 0 0x80000215
1758 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1759 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1760 $LFS getstripe $DIR/$tdir/$tfile
1764 run_test 27p "append to a truncated file with some full OSTs"
1767 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1768 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1769 remote_mds_nodsh && skip "remote MDS with nodsh"
1770 remote_ost_nodsh && skip "remote OST with nodsh"
1773 rm -f $DIR/$tdir/$tfile
1775 test_mkdir $DIR/$tdir
1776 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1777 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1778 error "truncate $DIR/$tdir/$tfile failed"
1779 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1781 exhaust_all_precreations 0x215
1783 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1784 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1788 run_test 27q "append to truncated file with all OSTs full (should error)"
1791 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1793 remote_mds_nodsh && skip "remote MDS with nodsh"
1794 remote_ost_nodsh && skip "remote OST with nodsh"
1797 rm -f $DIR/$tdir/$tfile
1798 exhaust_precreations 0 0x80000215
1800 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1804 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1806 test_27s() { # bug 10725
1807 test_mkdir $DIR/$tdir
1808 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1809 local stripe_count=0
1810 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1811 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1812 error "stripe width >= 2^32 succeeded" || true
1815 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1817 test_27t() { # bug 10864
1822 $WLFS getstripe $tfile
1825 run_test 27t "check that utils parse path correctly"
1827 test_27u() { # bug 4900
1828 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1829 remote_mds_nodsh && skip "remote MDS with nodsh"
1832 local list=$(comma_list $(mdts_nodes))
1834 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1835 do_nodes $list $LCTL set_param fail_loc=0x139
1836 test_mkdir -p $DIR/$tdir
1837 trap simple_cleanup_common EXIT
1838 createmany -o $DIR/$tdir/t- 1000
1839 do_nodes $list $LCTL set_param fail_loc=0
1841 TLOG=$TMP/$tfile.getstripe
1842 $LFS getstripe $DIR/$tdir > $TLOG
1843 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1844 unlinkmany $DIR/$tdir/t- 1000
1846 [[ $OBJS -gt 0 ]] &&
1847 error "$OBJS objects created on OST-0. See $TLOG" ||
1850 run_test 27u "skip object creation on OSC w/o objects"
1852 test_27v() { # bug 4900
1853 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1854 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1855 remote_mds_nodsh && skip "remote MDS with nodsh"
1856 remote_ost_nodsh && skip "remote OST with nodsh"
1858 exhaust_all_precreations 0x215
1861 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1863 touch $DIR/$tdir/$tfile
1864 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1866 for (( i=1; i < OSTCOUNT; i++ )); do
1867 do_facet ost$i lctl set_param fail_loc=0x705
1869 local START=`date +%s`
1870 createmany -o $DIR/$tdir/$tfile 32
1872 local FINISH=`date +%s`
1873 local TIMEOUT=`lctl get_param -n timeout`
1874 local PROCESS=$((FINISH - START))
1875 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1876 error "$FINISH - $START >= $TIMEOUT / 2"
1877 sleep $((TIMEOUT / 2 - PROCESS))
1880 run_test 27v "skip object creation on slow OST"
1882 test_27w() { # bug 10997
1883 test_mkdir $DIR/$tdir
1884 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1885 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1886 error "stripe size $size != 65536" || true
1887 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1888 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1890 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1893 [[ $OSTCOUNT -lt 2 ]] &&
1894 skip_env "skipping multiple stripe count/offset test"
1896 test_mkdir $DIR/$tdir
1897 for i in $(seq 1 $OSTCOUNT); do
1899 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1900 error "setstripe -c $i -i $offset failed"
1901 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1902 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1903 [ $count -ne $i ] && error "stripe count $count != $i" || true
1904 [ $index -ne $offset ] &&
1905 error "stripe offset $index != $offset" || true
1908 run_test 27wa "check $LFS setstripe -c -i options"
1911 remote_ost_nodsh && skip "remote OST with nodsh"
1912 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1913 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1915 OFFSET=$(($OSTCOUNT - 1))
1917 local OST=$(ostname_from_index $OSTIDX)
1919 test_mkdir $DIR/$tdir
1920 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1921 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1923 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1924 for i in $(seq 0 $OFFSET); do
1925 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1926 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1927 error "OST0 was degraded but new created file still use it"
1929 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1931 run_test 27x "create files while OST0 is degraded"
1934 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1935 remote_mds_nodsh && skip "remote MDS with nodsh"
1936 remote_ost_nodsh && skip "remote OST with nodsh"
1937 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1939 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1940 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1941 osc.$mdtosc.prealloc_last_id)
1942 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1943 osc.$mdtosc.prealloc_next_id)
1944 local fcount=$((last_id - next_id))
1945 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1946 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1948 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1949 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1950 local OST_DEACTIVE_IDX=-1
1955 for OSC in $MDS_OSCS; do
1956 OST=$(osc_to_ost $OSC)
1957 OSTIDX=$(index_from_ostuuid $OST)
1958 if [ $OST_DEACTIVE_IDX == -1 ]; then
1959 OST_DEACTIVE_IDX=$OSTIDX
1961 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1962 echo $OSC "is Deactivated:"
1963 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1967 OSTIDX=$(index_from_ostuuid $OST)
1968 test_mkdir $DIR/$tdir
1969 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1971 for OSC in $MDS_OSCS; do
1972 OST=$(osc_to_ost $OSC)
1973 OSTIDX=$(index_from_ostuuid $OST)
1974 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1975 echo $OST "is degraded:"
1976 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1977 obdfilter.$OST.degraded=1
1982 createmany -o $DIR/$tdir/$tfile $fcount
1984 for OSC in $MDS_OSCS; do
1985 OST=$(osc_to_ost $OSC)
1986 OSTIDX=$(index_from_ostuuid $OST)
1987 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1988 echo $OST "is recovered from degraded:"
1989 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1990 obdfilter.$OST.degraded=0
1992 do_facet $SINGLEMDS lctl --device %$OSC activate
1996 # all osp devices get activated, hence -1 stripe count restored
1997 local stripe_count=0
1999 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
2000 # devices get activated.
2002 $LFS setstripe -c -1 $DIR/$tfile
2003 stripe_count=$($LFS getstripe -c $DIR/$tfile)
2005 [ $stripe_count -ne $OSTCOUNT ] &&
2006 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
2009 run_test 27y "create files while OST0 is degraded and the rest inactive"
2015 lmm_count=$($GETSTRIPE -c $1)
2016 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
2017 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
2019 local old_ifs="$IFS"
2021 fid=($($LFS path2fid $1))
2024 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
2025 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
2027 # compare lmm_seq and lu_fid->f_seq
2028 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
2029 # compare lmm_object_id and lu_fid->oid
2030 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
2032 # check the trusted.fid attribute of the OST objects of the file
2033 local have_obdidx=false
2035 $GETSTRIPE $1 | while read obdidx oid hex seq; do
2036 # skip lines up to and including "obdidx"
2037 [ -z "$obdidx" ] && break
2038 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
2039 $have_obdidx || continue
2041 local ost=$((obdidx + 1))
2042 local dev=$(ostdevname $ost)
2045 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
2047 seq=$(echo $seq | sed -e "s/^0x//g")
2048 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
2049 oid_hex=$(echo $oid)
2051 oid_hex=$(echo $hex | sed -e "s/^0x//g")
2053 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2057 # Don't unmount/remount the OSTs if we don't need to do that.
2058 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2059 # update too, until that use mount/ll_decode_filter_fid/mount.
2060 # Re-enable when debugfs will understand new filter_fid.
2062 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2063 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2064 $dev 2>/dev/null" | grep "parent=")
2066 if [ -z "$ff" ]; then
2068 mount_fstype ost$ost
2069 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2070 $(facet_mntpt ost$ost)/$obj_file)
2071 unmount_fstype ost$ost
2072 start ost$ost $dev $OST_MOUNT_OPTS
2076 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2078 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2080 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2081 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2083 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2084 # stripe_size=1048576 component_id=1 component_start=0 \
2085 # component_end=33554432
2086 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2087 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2088 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2090 if grep -q 'stripe=' <<<$ff; then
2091 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2093 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2094 # into f_ver in this case. See comment on ff_parent.
2095 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2098 # compare lmm_seq and filter_fid->ff_parent.f_seq
2099 [ $ff_pseq = $lmm_seq ] ||
2100 error "FF parent SEQ $ff_pseq != $lmm_seq"
2101 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2102 [ $ff_poid = $lmm_oid ] ||
2103 error "FF parent OID $ff_poid != $lmm_oid"
2104 (($ff_pstripe == $stripe_nr)) ||
2105 error "FF stripe $ff_pstripe != $stripe_nr"
2107 stripe_nr=$((stripe_nr + 1))
2108 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2110 if grep -q 'stripe_count=' <<<$ff; then
2111 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2112 -e 's/ .*//' <<<$ff)
2113 [ $lmm_count = $ff_scnt ] ||
2114 error "FF stripe count $lmm_count != $ff_scnt"
2120 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2121 remote_ost_nodsh && skip "remote OST with nodsh"
2123 test_mkdir $DIR/$tdir
2124 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2125 { error "setstripe -c -1 failed"; return 1; }
2126 # We need to send a write to every object to get parent FID info set.
2127 # This _should_ also work for setattr, but does not currently.
2128 # touch $DIR/$tdir/$tfile-1 ||
2129 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2130 { error "dd $tfile-1 failed"; return 2; }
2131 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2132 { error "setstripe -c -1 failed"; return 3; }
2133 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2134 { error "dd $tfile-2 failed"; return 4; }
2136 # make sure write RPCs have been sent to OSTs
2139 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2140 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2142 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2144 test_27A() { # b=19102
2145 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2147 save_layout_restore_at_exit $MOUNT
2148 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2149 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2150 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2151 local default_size=$($GETSTRIPE -S $MOUNT)
2152 local default_offset=$($GETSTRIPE -i $MOUNT)
2153 local dsize=$(do_facet $SINGLEMDS \
2154 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2155 [ $default_size -eq $dsize ] ||
2156 error "stripe size $default_size != $dsize"
2157 [ $default_offset -eq -1 ] ||
2158 error "stripe offset $default_offset != -1"
2160 run_test 27A "check filesystem-wide default LOV EA values"
2162 test_27B() { # LU-2523
2163 test_mkdir $DIR/$tdir
2164 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2166 # open f1 with O_LOV_DELAY_CREATE
2168 # call setstripe ioctl on open file descriptor for f1
2170 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2174 # open f1 with O_LOV_DELAY_CREATE
2176 # call setstripe ioctl on open file descriptor for f1
2178 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2180 # Allow multiop to fail in imitation of NFS's busted semantics.
2183 run_test 27B "call setstripe on open unlinked file/rename victim"
2185 test_27C() { #LU-2871
2186 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2194 test_mkdir $DIR/$tdir
2196 for i in $(seq 0 $((OSTCOUNT - 1))); do
2197 # set stripe across all OSTs starting from OST$i
2198 $SETSTRIPE -i $i -c -1 $tfile$i
2199 # get striping information
2200 ost_idx=($($GETSTRIPE $tfile$i |
2201 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2205 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2206 error "${#ost_idx[@]} != $OSTCOUNT"
2208 for index in $(seq 0 $((OSTCOUNT - 1))); do
2210 for j in $(echo ${ost_idx[@]}); do
2211 if [ $index -eq $j ]; then
2217 error "Can not find $index in ${ost_idx[@]}"
2221 run_test 27C "check full striping across all OSTs"
2224 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2225 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2226 remote_mds_nodsh && skip "remote MDS with nodsh"
2228 local POOL=${POOL:-testpool}
2230 local last_ost=$(($OSTCOUNT - 1))
2232 local ost_list=$(seq $first_ost $ost_step $last_ost)
2233 local ost_range="$first_ost $last_ost $ost_step"
2235 if ! combined_mgs_mds ; then
2239 test_mkdir $DIR/$tdir
2240 pool_add $POOL || error "pool_add failed"
2241 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2244 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2246 [ $MDS1_VERSION -lt $(version_code 2.9.55) -o \
2247 $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2248 skip27D+=" -s 30,31"
2249 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2250 error "llapi_layout_test failed"
2252 destroy_test_pools || error "destroy test pools failed"
2254 if ! combined_mgs_mds ; then
2258 run_test 27D "validate llapi_layout API"
2260 # Verify that default_easize is increased from its initial value after
2261 # accessing a widely striped file.
2263 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2264 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2265 skip "client does not have LU-3338 fix"
2267 # 72 bytes is the minimum space required to store striping
2268 # information for a file striped across one OST:
2269 # (sizeof(struct lov_user_md_v3) +
2270 # sizeof(struct lov_user_ost_data_v1))
2272 $LCTL set_param -n llite.*.default_easize $min_easize ||
2273 error "lctl set_param failed"
2274 local easize=$($LCTL get_param -n llite.*.default_easize)
2276 [ $easize -eq $min_easize ] ||
2277 error "failed to set default_easize"
2279 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2280 error "setstripe failed"
2284 easize=$($LCTL get_param -n llite.*.default_easize)
2286 [ $easize -gt $min_easize ] ||
2287 error "default_easize not updated"
2289 run_test 27E "check that default extended attribute size properly increases"
2291 test_27F() { # LU-5346/LU-7975
2292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2293 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2294 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2295 skip "Need MDS version at least 2.8.51"
2296 remote_ost_nodsh && skip "remote OST with nodsh"
2298 test_mkdir $DIR/$tdir
2300 $SETSTRIPE -c 2 $DIR/$tdir
2302 # stop all OSTs to reproduce situation for LU-7975 ticket
2303 for num in $(seq $OSTCOUNT); do
2307 # open/create f0 with O_LOV_DELAY_CREATE
2308 # truncate f0 to a non-0 size
2310 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2312 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2313 # open/write it again to force delayed layout creation
2314 cat /etc/hosts > $DIR/$tdir/f0 &
2318 for num in $(seq $OSTCOUNT); do
2319 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2320 error "ost$num failed to start"
2323 wait $catpid || error "cat failed"
2325 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2326 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2329 run_test 27F "Client resend delayed layout creation with non-zero size"
2331 test_27G() { #LU-10629
2332 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2333 skip "Need MDS version at least 2.11.51"
2334 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2335 remote_mds_nodsh && skip "remote MDS with nodsh"
2336 local POOL=${POOL:-testpool}
2337 local ostrange="0 0 1"
2339 test_mkdir $DIR/$tdir
2340 pool_add $POOL || error "pool_add failed"
2341 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2342 $LFS setstripe -p $POOL $DIR/$tdir
2344 local pool=$($LFS getstripe -p $DIR/$tdir)
2346 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2348 $LFS setstripe -d $DIR/$tdir
2350 pool=$($LFS getstripe -p $DIR/$tdir)
2354 [ -z "$pool" ] || error "'$pool' is not empty"
2356 run_test 27G "Clear OST pool from stripe"
2359 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2360 skip "Need MDS version newer than 2.11.54"
2361 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2362 test_mkdir $DIR/$tdir
2363 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2364 touch $DIR/$tdir/$tfile
2365 $LFS getstripe -c $DIR/$tdir/$tfile
2366 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2367 error "two-stripe file doesn't have two stripes"
2369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2370 $LFS getstripe -y $DIR/$tdir/$tfile
2371 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2372 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2373 error "expected l_ost_idx: [02]$ not matched"
2375 # make sure ost list have been cleared
2376 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2377 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2378 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2380 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2382 run_test 27H "Set specific OSTs stripe"
2384 # createtest also checks that device nodes are created and
2385 # then visible correctly (#2091)
2386 test_28() { # bug 2091
2388 $CREATETEST $DIR/d28/ct || error "createtest failed"
2390 run_test 28 "create/mknod/mkdir with bad file types ============"
2393 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2395 sync; sleep 1; sync # flush out any dirty pages from previous tests
2402 declare -i LOCKCOUNTORIG=0
2403 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2404 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2406 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2408 declare -i LOCKUNUSEDCOUNTORIG=0
2409 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2410 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2417 declare -i LOCKCOUNTCURRENT=0
2418 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2419 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2422 declare -i LOCKUNUSEDCOUNTCURRENT=0
2423 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2424 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2427 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2428 $LCTL set_param -n ldlm.dump_namespaces ""
2429 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2430 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2431 log "dumped log to $TMP/test_29.dk (bug 5793)"
2434 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2435 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2436 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2437 log "dumped log to $TMP/test_29.dk (bug 5793)"
2441 run_test 29 "IT_GETATTR regression ============================"
2443 test_30a() { # was test_30
2444 cp $(which ls) $DIR || cp /bin/ls $DIR
2445 $DIR/ls / || error "Can't execute binary from lustre"
2448 run_test 30a "execute binary from Lustre (execve) =============="
2451 cp `which ls` $DIR || cp /bin/ls $DIR
2453 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2456 run_test 30b "execute binary from Lustre as non-root ==========="
2458 test_30c() { # b=22376
2459 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2461 cp `which ls` $DIR || cp /bin/ls $DIR
2463 cancel_lru_locks mdc
2464 cancel_lru_locks osc
2465 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2468 run_test 30c "execute binary from Lustre without read perms ===="
2471 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2472 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2474 run_test 31a "open-unlink file =================================="
2477 touch $DIR/f31 || error "touch $DIR/f31 failed"
2478 ln $DIR/f31 $DIR/f31b || error "ln failed"
2479 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2480 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2482 run_test 31b "unlink file with multiple links while open ======="
2485 touch $DIR/f31 || error "touch $DIR/f31 failed"
2486 ln $DIR/f31 $DIR/f31c || error "ln failed"
2487 multiop_bg_pause $DIR/f31 O_uc ||
2488 error "multiop_bg_pause for $DIR/f31 failed"
2490 $MULTIOP $DIR/f31c Ouc
2491 kill -USR1 $MULTIPID
2494 run_test 31c "open-unlink file with multiple links ============="
2497 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2498 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2500 run_test 31d "remove of open directory ========================="
2502 test_31e() { # bug 2904
2503 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2505 run_test 31e "remove of open non-empty directory ==============="
2507 test_31f() { # bug 4554
2508 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2511 test_mkdir $DIR/d31f
2512 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2513 cp /etc/hosts $DIR/d31f
2515 $GETSTRIPE $DIR/d31f/hosts
2516 multiop_bg_pause $DIR/d31f D_c || return 1
2519 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2520 test_mkdir $DIR/d31f
2521 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2522 cp /etc/hosts $DIR/d31f
2524 $GETSTRIPE $DIR/d31f/hosts
2525 multiop_bg_pause $DIR/d31f D_c || return 1
2528 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2529 wait $MULTIPID || error "first opendir $MULTIPID failed"
2533 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2534 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2537 run_test 31f "remove of open directory with open-unlink file ==="
2540 echo "-- cross directory link --"
2541 test_mkdir -c1 $DIR/${tdir}ga
2542 test_mkdir -c1 $DIR/${tdir}gb
2543 touch $DIR/${tdir}ga/f
2544 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2545 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2546 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2547 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2548 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2550 run_test 31g "cross directory link==============="
2553 echo "-- cross directory link --"
2554 test_mkdir -c1 $DIR/${tdir}
2555 test_mkdir -c1 $DIR/${tdir}/dir
2556 touch $DIR/${tdir}/f
2557 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2558 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2559 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2560 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2561 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2563 run_test 31h "cross directory link under child==============="
2566 echo "-- cross directory link --"
2567 test_mkdir -c1 $DIR/$tdir
2568 test_mkdir -c1 $DIR/$tdir/dir
2569 touch $DIR/$tdir/dir/f
2570 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2571 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2572 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2573 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2574 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2576 run_test 31i "cross directory link under parent==============="
2579 test_mkdir -c1 -p $DIR/$tdir
2580 test_mkdir -c1 -p $DIR/$tdir/dir1
2581 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2582 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2583 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2584 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2587 run_test 31j "link for directory==============="
2590 test_mkdir -c1 -p $DIR/$tdir
2592 touch $DIR/$tdir/exist
2593 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2594 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2595 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2596 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2597 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2598 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2599 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2602 run_test 31k "link to file: the same, non-existing, dir==============="
2608 touch $DIR/d31m2/exist
2609 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2610 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2611 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2612 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2613 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2614 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2617 run_test 31m "link to file: the same, non-existing, dir==============="
2620 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2621 nlink=$(stat --format=%h $DIR/$tfile)
2622 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2624 local cmd="exec $fd<$DIR/$tfile"
2627 trap "eval $cmd" EXIT
2628 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2629 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2630 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2631 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2632 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2635 run_test 31n "check link count of unlinked file"
2638 local TEMPNAME=$(mktemp $1_XXXXXX)
2639 mlink $TEMPNAME $1 2> /dev/null &&
2640 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2644 test_31o() { # LU-2901
2645 test_mkdir $DIR/$tdir
2646 for LOOP in $(seq 100); do
2647 rm -f $DIR/$tdir/$tfile*
2648 for THREAD in $(seq 8); do
2649 link_one $DIR/$tdir/$tfile.$LOOP &
2652 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2653 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2654 error "$LINKS duplicate links to $tfile.$LOOP" &&
2658 run_test 31o "duplicate hard links with same filename"
2661 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2663 test_mkdir $DIR/$tdir
2664 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2665 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2667 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2668 error "open unlink test1 failed"
2669 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2670 error "open unlink test2 failed"
2672 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2673 error "test1 still exists"
2674 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2675 error "test2 still exists"
2677 run_test 31p "remove of open striped directory"
2679 cleanup_test32_mount() {
2682 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2683 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2684 losetup -d $loopdev || true
2690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2692 echo "== more mountpoints and symlinks ================="
2693 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2694 trap cleanup_test32_mount EXIT
2695 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2696 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2697 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2698 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2699 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2700 cleanup_test32_mount
2702 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2705 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2707 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2708 trap cleanup_test32_mount EXIT
2709 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2710 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2711 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2712 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2713 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2714 cleanup_test32_mount
2716 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2721 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2722 trap cleanup_test32_mount EXIT
2723 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2724 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2725 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2726 test_mkdir -p $DIR/$tdir/d2/test_dir
2727 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2728 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2729 cleanup_test32_mount
2731 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2734 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2736 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2737 trap cleanup_test32_mount EXIT
2738 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2739 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2740 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2741 test_mkdir -p $DIR/$tdir/d2/test_dir
2742 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2743 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2744 cleanup_test32_mount
2746 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2750 test_mkdir -p $DIR/$tdir/tmp
2751 local tmp_dir=$DIR/$tdir/tmp
2752 ln -s $DIR/$tdir $tmp_dir/symlink11
2753 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2754 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2755 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2757 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2761 test_mkdir -p $DIR/$tdir/tmp
2762 local tmp_dir=$DIR/$tdir/tmp
2763 ln -s $DIR/$tdir $tmp_dir/symlink11
2764 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2765 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2766 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2768 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2771 local tmp_dir=$DIR/$tdir/tmp
2772 test_mkdir -p $tmp_dir
2773 test_mkdir $DIR/${tdir}2
2774 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2775 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2776 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2777 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2778 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2779 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2781 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2784 rm -fr $DIR/$tdir $DIR/${tdir}2
2785 tmp_dir=$DIR/$tdir/tmp
2786 test_mkdir -p $tmp_dir
2787 test_mkdir $DIR/${tdir}2
2788 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2789 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2790 ls $tmp_dir/symlink12 || error "listing symlink12"
2791 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2793 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2796 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2798 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2799 trap cleanup_test32_mount EXIT
2800 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2801 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2802 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2803 touch $DIR/$tdir/test_file
2804 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2805 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2806 cleanup_test32_mount
2808 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2811 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2813 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2814 trap cleanup_test32_mount EXIT
2815 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2816 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2817 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2818 touch $DIR/$tdir/test_file
2819 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2820 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2821 cleanup_test32_mount
2823 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2826 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2829 trap cleanup_test32_mount EXIT
2830 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2831 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2832 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2833 test_mkdir -p $DIR/$tdir/d2
2834 touch $DIR/$tdir/d2/test_file || error "touch failed"
2835 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2836 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2837 cleanup_test32_mount
2839 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2842 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2845 trap cleanup_test32_mount EXIT
2846 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2847 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2848 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2849 test_mkdir -p $DIR/$tdir/d2
2850 touch $DIR/$tdir/d2/test_file || error "touch failed"
2851 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2852 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2853 cleanup_test32_mount
2855 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2859 test_mkdir -p $DIR/d32m/tmp
2860 TMP_DIR=$DIR/d32m/tmp
2861 ln -s $DIR $TMP_DIR/symlink11
2862 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2863 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2864 error "symlink11 not a link"
2865 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2866 error "symlink01 not a link"
2868 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2872 test_mkdir -p $DIR/d32n/tmp
2873 TMP_DIR=$DIR/d32n/tmp
2874 ln -s $DIR $TMP_DIR/symlink11
2875 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2876 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2877 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2879 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2883 test_mkdir -p $DIR/d32o/tmp
2884 TMP_DIR=$DIR/d32o/tmp
2885 ln -s $DIR/$tfile $TMP_DIR/symlink12
2886 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2887 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2888 error "symlink12 not a link"
2889 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2890 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2891 error "$DIR/d32o/tmp/symlink12 not file type"
2892 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2893 error "$DIR/d32o/symlink02 not file type"
2895 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2905 test_mkdir -p $DIR/d32p/tmp
2907 TMP_DIR=$DIR/d32p/tmp
2909 ln -s $DIR/$tfile $TMP_DIR/symlink12
2911 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2913 cat $DIR/d32p/tmp/symlink12 ||
2914 error "Can't open $DIR/d32p/tmp/symlink12"
2916 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2919 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2922 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2924 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2925 trap cleanup_test32_mount EXIT
2926 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2927 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2928 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2929 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2930 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2931 cleanup_test32_mount
2933 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2936 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2938 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2939 trap cleanup_test32_mount EXIT
2940 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2941 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2942 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2943 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2944 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2945 cleanup_test32_mount
2947 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2952 chmod 444 $DIR/$tfile
2953 chown $RUNAS_ID $DIR/$tfile
2955 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2958 run_test 33aa "write file with mode 444 (should return error)"
2962 test_mkdir $DIR/$tdir
2963 chown $RUNAS_ID $DIR/$tdir
2964 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2965 error "$RUNAS create $tdir/$tfile failed"
2966 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2967 error "open RDWR" || true
2969 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2973 test_mkdir $DIR/$tdir
2974 chown $RUNAS_ID $DIR/$tdir
2975 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2977 run_test 33b "test open file with malformed flags (No panic)"
2980 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2981 remote_ost_nodsh && skip "remote OST with nodsh"
2990 test_mkdir $DIR/$tdir
2991 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2994 for ostnum in $(seq $OSTCOUNT); do
2995 # test-framework's OST numbering is one-based, while Lustre's
2997 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2998 # Parsing llobdstat's output sucks; we could grep the /proc
2999 # path, but that's likely to not be as portable as using the
3000 # llobdstat utility. So we parse lctl output instead.
3001 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3002 obdfilter/$ostname/stats |
3003 awk '/^write_bytes/ {print $7}' )
3004 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
3005 if (( ${write_bytes:-0} > 0 ))
3012 $all_zeros || return 0
3015 echo foo > $DIR/$tdir/bar
3019 # Total up write_bytes after writing. We'd better find non-zeros.
3020 for ostnum in $(seq $OSTCOUNT); do
3021 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3022 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
3023 obdfilter/$ostname/stats |
3024 awk '/^write_bytes/ {print $7}' )
3025 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
3026 if (( ${write_bytes:-0} > 0 ))
3035 for ostnum in $(seq $OSTCOUNT); do
3036 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
3037 echo "Check that write_bytes is present in obdfilter/*/stats:"
3038 do_facet ost$ostnum lctl get_param -n \
3039 obdfilter/$ostname/stats
3041 error "OST not keeping write_bytes stats (b22312)"
3044 run_test 33c "test llobdstat and write_bytes"
3047 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3048 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3051 local remote_dir=$DIR/$tdir/remote_dir
3053 test_mkdir $DIR/$tdir
3054 $LFS mkdir -i $MDTIDX $remote_dir ||
3055 error "create remote directory failed"
3057 touch $remote_dir/$tfile
3058 chmod 444 $remote_dir/$tfile
3059 chown $RUNAS_ID $remote_dir/$tfile
3061 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3063 chown $RUNAS_ID $remote_dir
3064 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3065 error "create" || true
3066 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3067 error "open RDWR" || true
3068 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3070 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3073 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3077 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3078 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3079 mkdir $DIR/$tdir/local_dir
3081 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3082 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3083 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3085 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3086 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3088 rmdir $DIR/$tdir/* || error "rmdir failed"
3091 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3092 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3093 mkdir $DIR/$tdir/local_dir
3095 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3096 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3097 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3099 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3100 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3102 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3105 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3106 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3107 mkdir $DIR/$tdir/local_dir
3109 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3110 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3111 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3113 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3114 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3116 run_test 33e "mkdir and striped directory should have same mode"
3120 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3124 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3125 remote_mds_nodsh && skip "remote MDS with nodsh"
3128 chmod go+rwx $DIR/$tdir
3129 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3130 trap cleanup_33f EXIT
3132 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3133 error "cannot create striped directory"
3135 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3136 error "cannot create files in striped directory"
3138 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3139 error "cannot remove files in striped directory"
3141 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3142 error "cannot remove striped directory"
3146 run_test 33f "nonroot user can create, access, and remove a striped directory"
3149 mkdir -p $DIR/$tdir/dir2
3151 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3153 [[ $err =~ "exists" ]] || error "Not exists error"
3155 run_test 33g "nonroot user create already existing root created file"
3157 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3160 $MCREATE $DIR/f34 || error "mcreate failed"
3161 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3162 error "getstripe failed"
3163 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3164 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3165 error "getstripe failed"
3166 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3167 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3169 run_test 34a "truncate file that has not been opened ==========="
3172 [ ! -f $DIR/f34 ] && test_34a
3173 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3174 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3175 $OPENFILE -f O_RDONLY $DIR/f34
3176 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3177 error "getstripe failed"
3178 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3179 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3181 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3184 [ ! -f $DIR/f34 ] && test_34a
3185 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3186 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3187 $OPENFILE -f O_RDWR $DIR/f34
3188 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3189 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3190 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3192 run_test 34c "O_RDWR opening file-with-size works =============="
3195 [ ! -f $DIR/f34 ] && test_34a
3196 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3198 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3199 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3202 run_test 34d "write to sparse file ============================="
3206 $MCREATE $DIR/f34e || error "mcreate failed"
3207 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3208 $CHECKSTAT -s 1000 $DIR/f34e ||
3209 error "Size of $DIR/f34e not equal to 1000 bytes"
3210 $OPENFILE -f O_RDWR $DIR/f34e
3211 $CHECKSTAT -s 1000 $DIR/f34e ||
3212 error "Size of $DIR/f34e not equal to 1000 bytes"
3214 run_test 34e "create objects, some with size and some without =="
3216 test_34f() { # bug 6242, 6243
3217 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3221 $MCREATE $DIR/f34f || error "mcreate failed"
3222 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3223 dd if=$DIR/f34f of=$TMP/f34f
3224 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3225 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3226 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3227 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3228 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3230 run_test 34f "read from a file with no objects until EOF ======="
3233 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3235 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3237 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3238 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3239 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3240 cancel_lru_locks osc
3241 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3242 error "wrong size after lock cancel"
3244 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3245 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3246 error "expanding truncate failed"
3247 cancel_lru_locks osc
3248 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3249 error "wrong expanded size after lock cancel"
3251 run_test 34g "truncate long file ==============================="
3254 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3259 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3260 sync # Flush the cache so that multiop below does not block on cache
3261 # flush when getting the group lock
3262 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3265 # Since just timed wait is not good enough, let's do a sync write
3266 # that way we are sure enough time for a roundtrip + processing
3267 # passed + 2 seconds of extra margin.
3268 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3272 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3273 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3277 local nsz=`stat -c %s $DIR/$tfile`
3278 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3280 run_test 34h "ftruncate file under grouplock should not block"
3283 cp /bin/sh $DIR/f35a
3285 chown $RUNAS_ID $DIR/f35a
3286 $RUNAS $DIR/f35a && error || true
3289 run_test 35a "exec file with mode 444 (should return and not leak)"
3293 utime $DIR/f36 || error "utime failed for MDS"
3295 run_test 36a "MDS utime check (mknod, utime)"
3299 utime $DIR/f36 || error "utime failed for OST"
3301 run_test 36b "OST utime check (open, utime)"
3306 chown $RUNAS_ID $DIR/d36
3307 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3309 run_test 36c "non-root MDS utime check (mknod, utime)"
3312 [ ! -d $DIR/d36 ] && test_36c
3313 echo "" > $DIR/d36/f36
3314 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3316 run_test 36d "non-root OST utime check (open, utime)"
3319 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3321 test_mkdir $DIR/$tdir
3322 touch $DIR/$tdir/$tfile
3323 $RUNAS utime $DIR/$tdir/$tfile &&
3324 error "utime worked, expected failure" || true
3326 run_test 36e "utime on non-owned file (should return error)"
3330 local LANG_SAVE=$LANG
3331 local LC_LANG_SAVE=$LC_LANG
3332 export LANG=C LC_LANG=C # for date language
3334 DATESTR="Dec 20 2000"
3335 test_mkdir $DIR/$tdir
3336 lctl set_param fail_loc=$fl
3338 cp /etc/hosts $DIR/$tdir/$tfile
3339 sync & # write RPC generated with "current" inode timestamp, but delayed
3341 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3342 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3343 cancel_lru_locks $OSC
3344 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3346 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3347 echo "BEFORE: $LS_BEFORE" && \
3348 echo "AFTER : $LS_AFTER" && \
3349 echo "WANT : $DATESTR" && \
3350 error "$DIR/$tdir/$tfile timestamps changed" || true
3352 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3358 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3359 subr_36fh "0x80000214"
3361 run_test 36f "utime on file racing with OST BRW write =========="
3364 remote_ost_nodsh && skip "remote OST with nodsh"
3365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3366 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
3367 skip "Need MDS version at least 2.12.51"
3372 local tgt="obdfilter"
3374 [[ $OSC == "mdc" ]] && tgt="mdt" && facet="mds1"
3376 test_mkdir $DIR/$tdir
3377 fmd_max_age=$(do_facet $facet \
3378 "lctl get_param -n $tgt.*.tgt_fmd_seconds 2> /dev/null | \
3381 echo "FMD max age: ${fmd_max_age}s"
3382 touch $DIR/$tdir/$tfile
3383 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3384 gawk '{cnt=cnt+$1} END{print cnt}')
3385 echo "FMD before: $fmd"
3387 error "FMD wasn't create by touch"
3388 sleep $((fmd_max_age + 12))
3389 fmd=$(do_facet $facet "lctl get_param -n $tgt.*.exports.*.fmd_count" |
3390 gawk '{cnt=cnt+$1} END{print cnt}')
3391 echo "FMD after: $fmd"
3393 error "FMD wasn't expired by ping"
3395 run_test 36g "FMD cache expiry ====================="
3398 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3400 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3401 subr_36fh "0x80000227"
3403 run_test 36h "utime on file racing with OST BRW write =========="
3406 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3408 test_mkdir $DIR/$tdir
3409 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3411 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3412 local new_mtime=$((mtime + 200))
3414 #change Modify time of striped dir
3415 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3416 error "change mtime failed"
3418 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3420 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3422 run_test 36i "change mtime on striped directory"
3424 # test_37 - duplicate with tests 32q 32r
3427 local file=$DIR/$tfile
3429 openfile -f O_DIRECTORY $file
3432 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3433 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3435 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3437 test_39a() { # was test_39
3439 touch $DIR/${tfile}2
3440 # ls -l $DIR/$tfile $DIR/${tfile}2
3441 # ls -lu $DIR/$tfile $DIR/${tfile}2
3442 # ls -lc $DIR/$tfile $DIR/${tfile}2
3444 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3445 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3447 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3449 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3451 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3452 error "O_TRUNC didn't change timestamps"
3455 run_test 39a "mtime changed on create"
3458 test_mkdir -c1 $DIR/$tdir
3459 cp -p /etc/passwd $DIR/$tdir/fopen
3460 cp -p /etc/passwd $DIR/$tdir/flink
3461 cp -p /etc/passwd $DIR/$tdir/funlink
3462 cp -p /etc/passwd $DIR/$tdir/frename
3463 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3466 echo "aaaaaa" >> $DIR/$tdir/fopen
3467 echo "aaaaaa" >> $DIR/$tdir/flink
3468 echo "aaaaaa" >> $DIR/$tdir/funlink
3469 echo "aaaaaa" >> $DIR/$tdir/frename
3471 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3472 local link_new=`stat -c %Y $DIR/$tdir/flink`
3473 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3474 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3476 cat $DIR/$tdir/fopen > /dev/null
3477 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3478 rm -f $DIR/$tdir/funlink2
3479 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3481 for (( i=0; i < 2; i++ )) ; do
3482 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3483 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3484 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3485 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3487 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3488 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3489 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3490 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3492 cancel_lru_locks $OSC
3493 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3496 run_test 39b "mtime change on open, link, unlink, rename ======"
3498 # this should be set to past
3499 TEST_39_MTIME=`date -d "1 year ago" +%s`
3505 local mtime0=`stat -c %Y $DIR1/$tfile`
3507 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3508 local mtime1=`stat -c %Y $DIR1/$tfile`
3509 [ "$mtime1" = $TEST_39_MTIME ] || \
3510 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3513 echo hello >> $DIR1/$tfile
3515 local mtime2=`stat -c %Y $DIR1/$tfile`
3516 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3517 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3519 mv $DIR1/$tfile $DIR1/$tfile-1
3521 for (( i=0; i < 2; i++ )) ; do
3522 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3523 [ "$mtime2" = "$mtime3" ] || \
3524 error "mtime ($mtime2) changed (to $mtime3) on rename"
3526 cancel_lru_locks $OSC
3527 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3530 run_test 39c "mtime change on rename ==========================="
3534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3537 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3539 for (( i=0; i < 2; i++ )) ; do
3540 local mtime=`stat -c %Y $DIR1/$tfile`
3541 [ $mtime = $TEST_39_MTIME ] || \
3542 error "mtime($mtime) is not set to $TEST_39_MTIME"
3544 cancel_lru_locks $OSC
3545 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3548 run_test 39d "create, utime, stat =============================="
3552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3555 local mtime1=`stat -c %Y $DIR1/$tfile`
3557 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3559 for (( i=0; i < 2; i++ )) ; do
3560 local mtime2=`stat -c %Y $DIR1/$tfile`
3561 [ $mtime2 = $TEST_39_MTIME ] || \
3562 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3564 cancel_lru_locks $OSC
3565 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3568 run_test 39e "create, stat, utime, stat ========================"
3572 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3575 mtime1=`stat -c %Y $DIR1/$tfile`
3578 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3580 for (( i=0; i < 2; i++ )) ; do
3581 local mtime2=`stat -c %Y $DIR1/$tfile`
3582 [ $mtime2 = $TEST_39_MTIME ] || \
3583 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3585 cancel_lru_locks $OSC
3586 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3589 run_test 39f "create, stat, sleep, utime, stat ================="
3593 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3595 echo hello >> $DIR1/$tfile
3596 local mtime1=`stat -c %Y $DIR1/$tfile`
3599 chmod o+r $DIR1/$tfile
3601 for (( i=0; i < 2; i++ )) ; do
3602 local mtime2=`stat -c %Y $DIR1/$tfile`
3603 [ "$mtime1" = "$mtime2" ] || \
3604 error "lost mtime: $mtime2, should be $mtime1"
3606 cancel_lru_locks $OSC
3607 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3610 run_test 39g "write, chmod, stat ==============================="
3614 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3620 echo hello >> $DIR1/$tfile
3621 local mtime1=`stat -c %Y $DIR1/$tfile`
3623 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3625 if [ "$d1" != "$d2" ]; then
3626 echo "write and touch not within one second"
3628 for (( i=0; i < 2; i++ )) ; do
3629 local mtime2=`stat -c %Y $DIR1/$tfile`
3630 [ "$mtime2" = $TEST_39_MTIME ] || \
3631 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3633 cancel_lru_locks $OSC
3634 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3638 run_test 39h "write, utime within one second, stat ============="
3641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3646 echo hello >> $DIR1/$tfile
3647 local mtime1=`stat -c %Y $DIR1/$tfile`
3649 mv $DIR1/$tfile $DIR1/$tfile-1
3651 for (( i=0; i < 2; i++ )) ; do
3652 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3654 [ "$mtime1" = "$mtime2" ] || \
3655 error "lost mtime: $mtime2, should be $mtime1"
3657 cancel_lru_locks $OSC
3658 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3661 run_test 39i "write, rename, stat =============================="
3664 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3666 start_full_debug_logging
3670 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3671 lctl set_param fail_loc=0x80000412
3672 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3673 error "multiop failed"
3675 local mtime1=`stat -c %Y $DIR1/$tfile`
3677 mv $DIR1/$tfile $DIR1/$tfile-1
3679 kill -USR1 $multipid
3680 wait $multipid || error "multiop close failed"
3682 for (( i=0; i < 2; i++ )) ; do
3683 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3684 [ "$mtime1" = "$mtime2" ] ||
3685 error "mtime is lost on close: $mtime2, " \
3688 cancel_lru_locks $OSC
3689 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3691 lctl set_param fail_loc=0
3692 stop_full_debug_logging
3694 run_test 39j "write, rename, close, stat ======================="
3697 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3702 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3704 local mtime1=`stat -c %Y $DIR1/$tfile`
3706 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3708 kill -USR1 $multipid
3709 wait $multipid || error "multiop close failed"
3711 for (( i=0; i < 2; i++ )) ; do
3712 local mtime2=`stat -c %Y $DIR1/$tfile`
3714 [ "$mtime2" = $TEST_39_MTIME ] || \
3715 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3717 cancel_lru_locks osc
3718 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3721 run_test 39k "write, utime, close, stat ========================"
3723 # this should be set to future
3724 TEST_39_ATIME=`date -d "1 year" +%s`
3727 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3728 remote_mds_nodsh && skip "remote MDS with nodsh"
3730 local atime_diff=$(do_facet $SINGLEMDS \
3731 lctl get_param -n mdd.*MDT0000*.atime_diff)
3735 # test setting directory atime to future
3736 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3737 local atime=$(stat -c %X $DIR/$tdir)
3738 [ "$atime" = $TEST_39_ATIME ] ||
3739 error "atime is not set to future: $atime, $TEST_39_ATIME"
3741 # test setting directory atime from future to now
3742 local now=$(date +%s)
3743 touch -a -d @$now $DIR/$tdir
3745 atime=$(stat -c %X $DIR/$tdir)
3746 [ "$atime" -eq "$now" ] ||
3747 error "atime is not updated from future: $atime, $now"
3749 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3752 # test setting directory atime when now > dir atime + atime_diff
3753 local d1=$(date +%s)
3755 local d2=$(date +%s)
3756 cancel_lru_locks mdc
3757 atime=$(stat -c %X $DIR/$tdir)
3758 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3759 error "atime is not updated : $atime, should be $d2"
3761 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3764 # test not setting directory atime when now < dir atime + atime_diff
3766 cancel_lru_locks mdc
3767 atime=$(stat -c %X $DIR/$tdir)
3768 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3769 error "atime is updated to $atime, should remain $d1<atime<$d2"
3771 do_facet $SINGLEMDS \
3772 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3774 run_test 39l "directory atime update ==========================="
3777 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3781 local far_past_mtime=$(date -d "May 29 1953" +%s)
3782 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3784 touch -m -d @$far_past_mtime $DIR1/$tfile
3785 touch -a -d @$far_past_atime $DIR1/$tfile
3787 for (( i=0; i < 2; i++ )) ; do
3788 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3789 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3790 error "atime or mtime set incorrectly"
3792 cancel_lru_locks $OSC
3793 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3796 run_test 39m "test atime and mtime before 1970"
3798 test_39n() { # LU-3832
3799 remote_mds_nodsh && skip "remote MDS with nodsh"
3801 local atime_diff=$(do_facet $SINGLEMDS \
3802 lctl get_param -n mdd.*MDT0000*.atime_diff)
3807 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3810 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3811 atime0=$(stat -c %X $DIR/$tfile)
3814 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3815 atime1=$(stat -c %X $DIR/$tfile)
3818 cancel_lru_locks mdc
3819 cancel_lru_locks osc
3820 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3821 atime2=$(stat -c %X $DIR/$tfile)
3823 do_facet $SINGLEMDS \
3824 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3826 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3827 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3829 run_test 39n "check that O_NOATIME is honored"
3832 TESTDIR=$DIR/$tdir/$tfile
3833 [ -e $TESTDIR ] && rm -rf $TESTDIR
3840 links2=$(stat -c %h .)
3841 [ $(($links1 + 2)) != $links2 ] &&
3842 error "wrong links count $(($links1 + 2)) != $links2"
3844 links3=$(stat -c %h .)
3845 [ $(($links1 + 1)) != $links3 ] &&
3846 error "wrong links count $links1 != $links3"
3849 run_test 39o "directory cached attributes updated after create"
3852 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3855 TESTDIR=$DIR/$tdir/$tdir
3856 [ -e $TESTDIR ] && rm -rf $TESTDIR
3857 test_mkdir -p $TESTDIR
3861 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3862 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3864 links2=$(stat -c %h .)
3865 [ $(($links1 + 2)) != $links2 ] &&
3866 error "wrong links count $(($links1 + 2)) != $links2"
3868 links3=$(stat -c %h .)
3869 [ $(($links1 + 1)) != $links3 ] &&
3870 error "wrong links count $links1 != $links3"
3873 run_test 39p "remote directory cached attributes updated after create ========"
3876 test_39q() { # LU-8041
3877 local testdir=$DIR/$tdir
3879 multiop_bg_pause $testdir D_c || error "multiop failed"
3881 cancel_lru_locks mdc
3882 kill -USR1 $multipid
3883 local atime=$(stat -c %X $testdir)
3884 [ "$atime" -ne 0 ] || error "atime is zero"
3886 run_test 39q "close won't zero out atime"
3889 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3890 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3891 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3892 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3893 error "$tfile is not 4096 bytes in size"
3895 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3899 small_write $DIR/f41 18
3901 run_test 41 "test small file write + fstat ====================="
3903 count_ost_writes() {
3904 lctl get_param -n ${OSC}.*.stats |
3905 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3906 END { printf("%0.0f", writes) }'
3913 BG_DIRTY_RATIO_SAVE=10
3914 MAX_BG_DIRTY_RATIO=25
3918 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3919 # dirty_ratio, dirty_background_ratio
3920 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3921 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3922 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3923 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3925 # if file not here, we are a 2.4 kernel
3926 kill -CONT `pidof kupdated`
3931 # setup the trap first, so someone cannot exit the test at the
3932 # exact wrong time and mess up a machine
3933 trap start_writeback EXIT
3934 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3935 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3936 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3937 sysctl -w vm.dirty_writeback_centisecs=0
3938 sysctl -w vm.dirty_writeback_centisecs=0
3939 # save and increase /proc/sys/vm/dirty_ratio
3940 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3941 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3942 # save and increase /proc/sys/vm/dirty_background_ratio
3943 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3944 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3946 # if file not here, we are a 2.4 kernel
3947 kill -STOP `pidof kupdated`
3951 # ensure that all stripes have some grant before we test client-side cache
3953 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3954 dd if=/dev/zero of=$i bs=4k count=1
3959 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3960 # file truncation, and file removal.
3962 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3965 cancel_lru_locks $OSC
3967 sync; sleep 1; sync # just to be safe
3968 BEFOREWRITES=`count_ost_writes`
3969 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3970 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3971 AFTERWRITES=`count_ost_writes`
3972 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3973 error "$BEFOREWRITES < $AFTERWRITES"
3976 run_test 42a "ensure that we don't flush on close"
3979 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3982 cancel_lru_locks $OSC
3985 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3986 BEFOREWRITES=$(count_ost_writes)
3987 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3988 AFTERWRITES=$(count_ost_writes)
3989 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3990 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3992 BEFOREWRITES=$(count_ost_writes)
3993 sync || error "sync: $?"
3994 AFTERWRITES=$(count_ost_writes)
3995 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3996 error "$BEFOREWRITES < $AFTERWRITES on sync"
3998 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
4002 run_test 42b "test destroy of file with cached dirty data ======"
4004 # if these tests just want to test the effect of truncation,
4005 # they have to be very careful. consider:
4006 # - the first open gets a {0,EOF}PR lock
4007 # - the first write conflicts and gets a {0, count-1}PW
4008 # - the rest of the writes are under {count,EOF}PW
4009 # - the open for truncate tries to match a {0,EOF}PR
4010 # for the filesize and cancels the PWs.
4011 # any number of fixes (don't get {0,EOF} on open, match
4012 # composite locks, do smarter file size management) fix
4013 # this, but for now we want these tests to verify that
4014 # the cancellation with truncate intent works, so we
4015 # start the file with a full-file pw lock to match against
4016 # until the truncate.
4021 cancel_lru_locks $OSC
4023 # prime the file with 0,EOF PW to match
4027 # now the real test..
4028 dd if=/dev/zero of=$file bs=1024 count=100
4029 BEFOREWRITES=`count_ost_writes`
4030 $TRUNCATE $file $offset
4031 cancel_lru_locks $OSC
4032 AFTERWRITES=`count_ost_writes`
4037 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4040 [ $BEFOREWRITES -eq $AFTERWRITES ] &&
4041 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
4044 run_test 42c "test partial truncate of file with cached dirty data"
4047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4050 [ $BEFOREWRITES -eq $AFTERWRITES ] ||
4051 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
4054 run_test 42d "test complete truncate of file with cached dirty data"
4056 test_42e() { # bug22074
4057 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4059 local TDIR=$DIR/${tdir}e
4060 local pages=16 # hardcoded 16 pages, don't change it.
4061 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
4062 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
4066 test_mkdir $DIR/${tdir}e
4067 $SETSTRIPE -c 1 $TDIR
4068 createmany -o $TDIR/f $files
4070 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
4072 # we assume that with $OSTCOUNT files, at least one of them will
4073 # be allocated on OST0.
4074 warmup_files=$((OSTCOUNT * max_dirty_mb))
4075 createmany -o $TDIR/w $warmup_files
4077 # write a large amount of data into one file and sync, to get good
4078 # avail_grant number from OST.
4079 for ((i=0; i<$warmup_files; i++)); do
4080 idx=$($GETSTRIPE -i $TDIR/w$i)
4081 [ $idx -ne 0 ] && continue
4082 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
4085 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
4087 $LCTL get_param $proc_osc0/cur_dirty_bytes
4088 $LCTL get_param $proc_osc0/cur_grant_bytes
4090 # create as much dirty pages as we can while not to trigger the actual
4091 # RPCs directly. but depends on the env, VFS may trigger flush during this
4092 # period, hopefully we are good.
4093 for ((i=0; i<$warmup_files; i++)); do
4094 idx=$($GETSTRIPE -i $TDIR/w$i)
4095 [ $idx -ne 0 ] && continue
4096 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
4098 $LCTL get_param $proc_osc0/cur_dirty_bytes
4099 $LCTL get_param $proc_osc0/cur_grant_bytes
4101 # perform the real test
4102 $LCTL set_param $proc_osc0/rpc_stats 0
4103 for ((;i<$files; i++)); do
4104 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
4105 dd if=/dev/zero of=$TDIR/f$i bs=$PAGE_SIZE count=$pages 2>/dev/null
4108 $LCTL get_param $proc_osc0/rpc_stats
4111 local have_ppr=false
4112 $LCTL get_param $proc_osc0/rpc_stats |
4113 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
4114 # skip lines until we are at the RPC histogram data
4115 [ "$PPR" == "pages" ] && have_ppr=true && continue
4116 $have_ppr || continue
4118 # we only want the percent stat for < 16 pages
4119 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
4121 percent=$((percent + WPCT))
4122 if [[ $percent -gt 15 ]]; then
4123 error "less than 16-pages write RPCs" \
4130 run_test 42e "verify sub-RPC writes are not done synchronously"
4132 test_43A() { # was test_43
4133 test_mkdir $DIR/$tdir
4134 cp -p /bin/ls $DIR/$tdir/$tfile
4135 $MULTIOP $DIR/$tdir/$tfile Ow_c &
4137 # give multiop a chance to open
4140 $DIR/$tdir/$tfile && error "execute $DIR/$tdir/$tfile succeeded" || true
4143 run_test 43A "execution of file opened for write should return -ETXTBSY"
4146 test_mkdir $DIR/$tdir
4147 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4148 cp -p multiop $DIR/$tdir/multiop
4149 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4150 error "multiop open $TMP/$tfile.junk failed"
4151 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4153 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
4154 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4155 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4157 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
4160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4162 test_mkdir $DIR/$tdir
4163 cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
4164 cp -p multiop $DIR/$tdir/multiop
4165 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
4166 error "multiop open $TMP/$tfile.junk failed"
4167 rm $TMP/$tfile.junk # delete junk file on close (not part of test)
4169 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
4170 kill -USR1 $MULTIOP_PID || error "kill -USR1 PID $MULTIOP_PID failed"
4171 wait $MULTIOP_PID || error "wait PID $MULTIOP_PID failed"
4173 run_test 43b "truncate of file being executed should return -ETXTBSY"
4176 local testdir="$DIR/$tdir"
4179 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) |
4180 ( cd $testdir && md5sum -c )
4182 run_test 43c "md5sum of copy into lustre"
4184 test_44A() { # was test_44
4185 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4187 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
4188 dd if=$DIR/f1 bs=4k count=1 > /dev/null
4190 run_test 44A "zero length read from a sparse stripe"
4193 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
4195 [ -z "$nstripe" ] && skip "can't get stripe info"
4196 [[ $nstripe -gt $OSTCOUNT ]] &&
4197 skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
4199 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
4201 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
4202 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
4206 OFFSETS="0 $((stride/2)) $((stride-1))"
4207 for offset in $OFFSETS; do
4208 for i in $(seq 0 $((nstripe-1))); do
4209 local GLOBALOFFSETS=""
4211 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
4212 local myfn=$DIR/d44a-$size
4213 echo "--------writing $myfn at $size"
4214 ll_sparseness_write $myfn $size ||
4215 error "ll_sparseness_write"
4216 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4217 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4218 error "ll_sparseness_verify $GLOBALOFFSETS"
4220 for j in $(seq 0 $((nstripe-1))); do
4222 size=$((((j + $nstripe )*$stride + $offset)))
4223 ll_sparseness_write $myfn $size ||
4224 error "ll_sparseness_write"
4225 GLOBALOFFSETS="$GLOBALOFFSETS $size"
4227 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
4228 error "ll_sparseness_verify $GLOBALOFFSETS"
4233 run_test 44a "test sparse pwrite ==============================="
4237 for d in `lctl get_param -n ${OSC}.*.cur_dirty_bytes`; do
4243 before=`dirty_osc_total`
4244 echo executing "\"$*\""
4246 after=`dirty_osc_total`
4247 echo before $before, after $after
4250 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4253 # Obtain grants from OST if it supports it
4254 echo blah > ${f}_grant
4257 do_dirty_record "echo blah > $f"
4258 [[ $before -eq $after ]] && error "write wasn't cached"
4259 do_dirty_record "> $f"
4260 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
4261 do_dirty_record "echo blah > $f"
4262 [[ $before -eq $after ]] && error "write wasn't cached"
4263 do_dirty_record "sync"
4264 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
4265 do_dirty_record "echo blah > $f"
4266 [[ $before -eq $after ]] && error "write wasn't cached"
4267 do_dirty_record "cancel_lru_locks osc"
4268 [[ $before -gt $after ]] ||
4269 error "lock cancellation didn't lower dirty count"
4272 run_test 45 "osc io page accounting ============================"
4274 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
4275 # test tickles a bug where re-dirtying a page was failing to be mapped to the
4276 # objects offset and an assert hit when an rpc was built with 1023's mapped
4277 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
4279 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4284 dd if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4286 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=1023 count=1
4287 dd conv=notrunc if=/dev/zero of=$f bs=$PAGE_SIZE seek=511 count=1
4291 run_test 46 "dirtying a previously written page ================"
4293 # test_47 is removed "Device nodes check" is moved to test_28
4295 test_48a() { # bug 2399
4296 [ "$mds1_FSTYPE" = "zfs" ] &&
4297 [ $MDS1_VERSION -lt $(version_code 2.3.63) ] &&
4298 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
4300 test_mkdir $DIR/$tdir
4302 mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
4303 test_mkdir $DIR/$tdir
4304 touch foo || error "'touch foo' failed after recreating cwd"
4306 touch .foo || error "'touch .foo' failed after recreating cwd"
4308 ls . > /dev/null || error "'ls .' failed after recreating cwd"
4309 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4310 cd . || error "'cd .' failed after recreating cwd"
4311 mkdir . && error "'mkdir .' worked after recreating cwd"
4312 rmdir . && error "'rmdir .' worked after recreating cwd"
4313 ln -s . baz || error "'ln -s .' failed after recreating cwd"
4314 cd .. || error "'cd ..' failed after recreating cwd"
4316 run_test 48a "Access renamed working dir (should return errors)="
4318 test_48b() { # bug 2399
4320 test_mkdir $DIR/$tdir
4322 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
4323 touch foo && error "'touch foo' worked after removing cwd"
4324 mkdir foo && error "'mkdir foo' worked after removing cwd"
4325 touch .foo && error "'touch .foo' worked after removing cwd"
4326 mkdir .foo && error "'mkdir .foo' worked after removing cwd"
4327 ls . > /dev/null && error "'ls .' worked after removing cwd"
4328 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
4329 mkdir . && error "'mkdir .' worked after removing cwd"
4330 rmdir . && error "'rmdir .' worked after removing cwd"
4331 ln -s . foo && error "'ln -s .' worked after removing cwd"
4332 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
4334 run_test 48b "Access removed working dir (should return errors)="
4336 test_48c() { # bug 2350
4337 #lctl set_param debug=-1
4340 test_mkdir -p $DIR/$tdir/dir
4342 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4343 $TRACE touch foo && error "touch foo worked after removing cwd"
4344 $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
4345 touch .foo && error "touch .foo worked after removing cwd"
4346 mkdir .foo && error "mkdir .foo worked after removing cwd"
4347 $TRACE ls . && error "'ls .' worked after removing cwd"
4348 $TRACE ls .. || error "'ls ..' failed after removing cwd"
4349 $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
4350 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
4351 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
4352 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
4354 run_test 48c "Access removed working subdir (should return errors)"
4356 test_48d() { # bug 2350
4357 #lctl set_param debug=-1
4360 test_mkdir -p $DIR/$tdir/dir
4362 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4363 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4364 $TRACE touch foo && error "'touch foo' worked after removing parent"
4365 $TRACE mkdir foo && error "mkdir foo worked after removing parent"
4366 touch .foo && error "'touch .foo' worked after removing parent"
4367 mkdir .foo && error "mkdir .foo worked after removing parent"
4368 $TRACE ls . && error "'ls .' worked after removing parent"
4369 $TRACE ls .. && error "'ls ..' worked after removing parent"
4370 $TRACE mkdir . && error "'mkdir .' worked after removing parent"
4371 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
4372 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
4375 run_test 48d "Access removed parent subdir (should return errors)"
4377 test_48e() { # bug 4134
4378 #lctl set_param debug=-1
4381 test_mkdir -p $DIR/$tdir/dir
4383 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
4384 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
4385 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
4386 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
4387 # On a buggy kernel addition of "touch foo" after cd .. will
4388 # produce kernel oops in lookup_hash_it
4389 touch ../foo && error "'cd ..' worked after recreate parent"
4391 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
4393 run_test 48e "Access to recreated parent subdir (should return errors)"
4395 test_49() { # LU-1030
4396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4397 remote_ost_nodsh && skip "remote OST with nodsh"
4399 # get ost1 size - lustre-OST0000
4400 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4402 # write 800M at maximum
4403 [[ $ost1_size -lt 2 ]] && ost1_size=2
4404 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4406 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4407 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4410 # change max_pages_per_rpc while writing the file
4411 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4412 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4413 # loop until dd process exits
4414 while ps ax -opid | grep -wq $dd_pid; do
4415 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4416 sleep $((RANDOM % 5 + 1))
4418 # restore original max_pages_per_rpc
4419 $LCTL set_param $osc1_mppc=$orig_mppc
4420 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4422 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4426 test_mkdir $DIR/$tdir
4428 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4430 run_test 50 "special situations: /proc symlinks ==============="
4432 test_51a() { # was test_51
4433 # bug 1516 - create an empty entry right after ".." then split dir
4434 test_mkdir -c1 $DIR/$tdir
4435 touch $DIR/$tdir/foo
4436 $MCREATE $DIR/$tdir/bar
4438 createmany -m $DIR/$tdir/longfile 201
4440 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4441 $MCREATE $DIR/$tdir/longfile$FNUM
4446 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4448 run_test 51a "special situations: split htree with empty entry =="
4450 cleanup_print_lfs_df () {
4457 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4459 local dir=$DIR/$tdir
4460 local nrdirs=$((65536 + 100))
4462 # cleanup the directory
4469 local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
4470 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4471 [[ $numfree -lt $nrdirs ]] &&
4472 skip "not enough free inodes ($numfree) on MDT$mdtidx"
4474 # need to check free space for the directories as well
4475 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4476 numfree=$(( blkfree / $(fs_inode_ksize) ))
4477 [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
4479 trap cleanup_print_lfs_df EXIT
4482 createmany -d $dir/d $nrdirs || {
4483 unlinkmany $dir/d $nrdirs
4484 error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
4488 nrdirs=$(ls -U $dir | wc -l)
4490 # unlink all but 100 subdirectories, then check it still works
4492 local delete=$((nrdirs - left))
4497 # for ldiskfs the nlink count should be 1, but this is OSD specific
4498 # and so this is listed for informational purposes only
4499 echo "nlink before: $(stat -c %h $dir), created before: $nrdirs"
4500 unlinkmany -d $dir/d $delete ||
4501 error "unlink of first $delete subdirs failed"
4503 echo "nlink between: $(stat -c %h $dir)"
4504 local found=$(ls -U $dir | wc -l)
4505 [ $found -ne $left ] &&
4506 error "can't find subdirs: found only $found, expected $left"
4508 unlinkmany -d $dir/d $delete $left ||
4509 error "unlink of second $left subdirs failed"
4510 # regardless of whether the backing filesystem tracks nlink accurately
4511 # or not, the nlink count shouldn't be more than "." and ".." here
4512 local after=$(stat -c %h $dir)
4513 [[ $after -gt 2 ]] && error "nlink after: $after > 2" ||
4514 echo "nlink after: $after"
4516 cleanup_print_lfs_df
4518 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
4521 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4522 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
4524 test_mkdir $DIR/$tdir
4525 createmany -o $DIR/$tdir/t- 1000
4526 $LFS getstripe $DIR/$tdir > $TMP/$tfile
4527 for N in $(seq 0 $((OSTCOUNT - 1))); do
4528 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4529 END { printf("%0.0f", objs) }' $TMP/$tfile)
4530 OBJS0[$N]=$(grep -A 1 idx $TMP/$tfile | awk -vobjs=0 \
4531 '($1 == '$N') { objs += 1 } \
4532 END { printf("%0.0f", objs) }')
4533 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4535 unlinkmany $DIR/$tdir/t- 1000
4538 for N in $(seq 1 $((OSTCOUNT - 1))); do
4539 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4540 error "OST $N has less objects vs OST $NLAST" \
4541 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4542 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4543 error "OST $N has less objects vs OST $NLAST" \
4544 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4546 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4547 error "OST $N has less #0 objects vs OST $NLAST" \
4548 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4549 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4550 error "OST $N has less #0 objects vs OST $NLAST" \
4551 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4556 run_test 51d "check object distribution"
4559 if [ "$mds1_FSTYPE" != ldiskfs ]; then
4560 skip_env "ldiskfs only test"
4563 test_mkdir -c1 $DIR/$tdir
4564 test_mkdir -c1 $DIR/$tdir/d0
4566 touch $DIR/$tdir/d0/foo
4567 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4568 error "file exceed 65000 nlink limit!"
4569 unlinkmany $DIR/$tdir/d0/f- 65001
4572 run_test 51e "check file nlink limit"
4575 test_mkdir $DIR/$tdir
4578 local ulimit_old=$(ulimit -n)
4579 local spare=20 # number of spare fd's for scripts/libraries, etc.
4580 local mdt=$($LFS getstripe -m $DIR/$tdir)
4581 local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
4583 echo "MDT$mdt numfree=$numfree, max=$max"
4584 [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
4585 if [ $((numfree + spare)) -gt $ulimit_old ]; then
4586 while ! ulimit -n $((numfree + spare)); do
4587 numfree=$((numfree * 3 / 4))
4589 echo "changed ulimit from $ulimit_old to $((numfree + spare))"
4591 echo "left ulimit at $ulimit_old"
4594 createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
4595 unlinkmany $DIR/$tdir/f $numfree
4596 error "create+open $numfree files in $DIR/$tdir failed"
4598 ulimit -n $ulimit_old
4600 # if createmany exits at 120s there will be fewer than $numfree files
4601 unlinkmany $DIR/$tdir/f $numfree || true
4603 run_test 51f "check many open files limit"
4606 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4607 test_mkdir $DIR/$tdir
4608 touch $DIR/$tdir/foo
4609 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4610 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4611 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4612 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4613 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4615 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4616 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4617 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4619 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4620 cp -r $DIR/$tdir $TMP/
4621 rm -fr $DIR/$tdir $TMP/$tdir || error "cleanup rm failed"
4623 run_test 52a "append-only flag test (should return errors)"
4626 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4627 test_mkdir $DIR/$tdir
4628 touch $DIR/$tdir/foo
4629 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4630 cat test > $DIR/$tdir/foo && error "cat test worked"
4631 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4632 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4633 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4635 echo foo >> $DIR/$tdir/foo && error "echo worked"
4636 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4637 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4638 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4639 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4641 chattr -i $DIR/$tdir/foo || error "chattr failed"
4643 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4645 run_test 52b "immutable flag test (should return errors) ======="
4648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4649 remote_mds_nodsh && skip "remote MDS with nodsh"
4650 remote_ost_nodsh && skip "remote OST with nodsh"
4663 local support_last_seq=true
4665 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
4666 support_last_seq=false
4669 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4671 for value in $(do_facet $SINGLEMDS \
4672 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4673 param=$(echo ${value[0]} | cut -d "=" -f1)
4674 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4676 if $support_last_seq; then
4677 param_seq=$(echo $param |
4678 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4679 mds_last_seq=$(do_facet $SINGLEMDS \
4680 $LCTL get_param -n $param_seq)
4682 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4684 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4685 node=$(facet_active_host ost$((ostnum+1)))
4686 param="obdfilter.$ostname.last_id"
4687 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4688 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4689 ost_last_id=$ost_last
4691 if $support_last_seq; then
4692 ost_last_id=$(echo $ost_last |
4693 awk -F':' '{print $2}' |
4695 ost_last_seq=$(echo $ost_last |
4696 awk -F':' '{print $1}')
4697 [[ $ost_last_seq = $mds_last_seq ]] || continue
4700 if [[ $ost_last_id != $mds_last ]]; then
4701 error "$ost_last_id != $mds_last"
4708 $found || error "can not match last_seq/last_id for $mdtosc"
4711 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4714 perl -MSocket -e ';' || skip "no Socket perl module installed"
4716 $SOCKETSERVER $DIR/socket ||
4717 error "$SOCKETSERVER $DIR/socket failed: $?"
4718 $SOCKETCLIENT $DIR/socket ||
4719 error "$SOCKETCLIENT $DIR/socket failed: $?"
4720 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4722 run_test 54a "unix domain socket test =========================="
4728 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1
4730 run_test 54b "char device works in lustre ======================"
4733 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4734 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4735 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4737 for i in $(seq 3 7); do
4738 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4747 loopdev="$DIR/loop54c"
4750 $UMOUNT $DIR/$tdir || rc=$?
4751 losetup -d $loopdev || true
4752 losetup -d $LOOPDEV || true
4753 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4758 [ $PARALLEL == "yes" ] && skip "skip parallel run"
4760 loopdev="$DIR/loop54c"
4763 [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
4764 trap cleanup_54c EXIT
4765 mknod $loopdev b 7 $LOOPNUM
4766 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4767 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE seek=1024 count=1 > /dev/null
4768 losetup $loopdev $DIR/$tfile ||
4769 error "can't set up $loopdev for $DIR/$tfile"
4770 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4771 test_mkdir $DIR/$tdir
4772 mount -t ext2 $loopdev $DIR/$tdir ||
4773 error "error mounting $loopdev on $DIR/$tdir"
4774 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$PAGE_SIZE count=30 ||
4777 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$PAGE_SIZE count=30 ||
4781 run_test 54c "block device works in lustre ====================="
4787 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4789 run_test 54d "fifo device works in lustre ======================"
4794 cp -aL /dev/console $f
4795 echo $string > $f || error "echo $string to $f failed"
4797 run_test 54e "console/tty device works in lustre ======================"
4801 local dir=$DIR/$tdir
4804 test_mkdir -p $dir/dir
4805 for i in $(seq $numfiles); do
4807 touch $dir/dir/file$i
4810 local numcomp=$($LFS getstripe --component-count $dir)
4812 [[ $numcomp == 0 ]] && numcomp=1
4814 # test lfs getstripe with --recursive
4815 local filenum=$($LFS getstripe -r $dir | egrep -c "obdidx|l_ost_idx")
4817 [[ $filenum -eq $((numfiles * 2)) ]] ||
4818 error "$LFS getstripe -r: found $filenum != $((numfiles * 2))"
4819 filenum=$($LFS getstripe $dir | egrep -c "obdidx|l_ost_idx")
4820 [[ $filenum -eq $numfiles ]] ||
4821 error "$LFS getstripe $dir: found $filenum, not $numfiles"
4822 echo "$LFS getstripe showed obdidx or l_ost_idx"
4824 # test lfs getstripe with file instead of dir
4825 filenum=$($LFS getstripe $dir/file1 | egrep -c "obdidx|l_ost_idx")
4826 [[ $filenum -eq 1 ]] ||
4827 error "$LFS getstripe $dir/file1: found $filenum, not 1"
4828 echo "$LFS getstripe file1 passed"
4830 #test lfs getstripe with --verbose
4831 filenum=$($LFS getstripe --verbose $dir | grep -c lmm_magic)
4832 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4833 error "$LFS getstripe --verbose $dir: "\
4834 "got $filenum want $((numfiles * numcomp)) lmm_magic"
4835 [[ $($LFS getstripe $dir | grep -c lmm_magic) -eq 0 ]] ||
4836 error "$LFS getstripe $dir: showed lmm_magic"
4838 #test lfs getstripe with -v prints lmm_fid
4839 filenum=$($LFS getstripe -v $dir | grep -c lmm_fid)
4840 [[ $filenum -eq $((numfiles * numcomp)) ]] ||
4841 error "$LFS getstripe -v $dir: "\
4842 "got $filenum want $((numfiles * numcomp)) lmm_fid"
4843 [[ $($LFS getstripe $dir | grep -c lmm_fid) -eq 0 ]] ||
4844 error "$LFS getstripe $dir: showed lmm_fid by default"
4845 echo "$LFS getstripe --verbose passed"
4847 #check for FID information
4848 local fid1=$($LFS getstripe --fid $dir/file1)
4849 local fid2=$($LFS getstripe --verbose $dir/file1 |
4850 awk '/lmm_fid: / { print $2; exit; }')
4851 local fid3=$($LFS path2fid $dir/file1)
4853 [ "$fid1" != "$fid2" ] &&
4854 error "getstripe --fid '$fid1' != getstripe --verbose '$fid2'"
4855 [ "$fid1" != "$fid3" ] &&
4856 error "getstripe --fid '$fid1' != lfs path2fid '$fid3'"
4857 echo "$LFS getstripe --fid passed"
4859 #test lfs getstripe with --obd
4860 $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
4861 error "$LFS getstripe --obd wrong_uuid: should return error"
4863 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
4866 local obduuid=$(ostuuid_from_index $ostidx)
4867 local found=$($LFS getstripe -r --obd $obduuid $dir |
4868 grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
4870 filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
4871 [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
4873 [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
4876 [[ $found -eq $filenum ]] ||
4877 error "$LFS getstripe --obd: found $found expect $filenum"
4878 [[ $($LFS getstripe -r -v --obd $obduuid $dir |
4879 sed '/^[ ]*'${ostidx}'[ ]/d' |
4880 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4881 error "$LFS getstripe --obd: should not show file on other obd"
4882 echo "$LFS getstripe --obd passed"
4884 run_test 56a "check $LFS getstripe"
4887 local dir=$DIR/$tdir
4891 for i in $(seq $numdirs); do
4892 test_mkdir $dir/dir$i
4895 # test lfs getdirstripe default mode is non-recursion, which is
4896 # different from lfs getstripe
4897 local dircnt=$($LFS getdirstripe $dir | grep -c lmv_stripe_count)
4899 [[ $dircnt -eq 1 ]] ||
4900 error "$LFS getdirstripe: found $dircnt, not 1"
4901 dircnt=$($LFS getdirstripe --recursive $dir |
4902 grep -c lmv_stripe_count)
4903 [[ $dircnt -eq $((numdirs + 1)) ]] ||
4904 error "$LFS getdirstripe -r: $dircnt, != $((numdirs + 1))"
4906 run_test 56b "check $LFS getdirstripe"
4909 remote_ost_nodsh && skip "remote OST with nodsh"
4912 local ost_name=$(ostname_from_index $ost_idx)
4913 local old_status=$(ost_dev_status $ost_idx)
4915 [[ -z "$old_status" ]] ||
4916 skip_env "OST $ost_name is in $old_status status"
4918 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
4921 local new_status=$(ost_dev_status $ost_idx)
4923 [[ "$new_status" = "D" ]] ||
4924 error "OST $ost_name is in status of '$new_status', not 'D'"
4926 do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
4929 new_status=$(ost_dev_status $ost_idx)
4930 [[ -z "$new_status" ]] ||
4931 error "OST $ost_name is in status of '$new_status', not ''"
4933 run_test 56c "check 'lfs df' showing device status"
4938 local local_tdir="$1"
4939 local local_numfiles="$2"
4940 local local_numdirs="$3"
4941 local dir_params="$4"
4942 local dir_stripe_params="$5"
4944 if [ ! -d "$local_tdir" ] ; then
4945 test_mkdir -p $dir_stripe_params $local_tdir
4946 [ "$dir_params" ] && $LFS setstripe $dir_params $local_tdir
4947 for i in $(seq $local_numfiles) ; do
4948 touch $local_tdir/file$i
4950 for i in $(seq $local_numdirs) ; do
4951 test_mkdir $dir_stripe_params $local_tdir/dir$i
4952 for j in $(seq $local_numfiles) ; do
4953 touch $local_tdir/dir$i/file$j
4959 setup_56_special() {
4961 local local_numfiles=$2
4962 local local_numdirs=$3
4964 setup_56 $local_tdir $local_numfiles $local_numdirs
4966 if [ ! -e "$local_tdir/loop${local_numfiles}b" ] ; then
4967 for i in $(seq $local_numfiles) ; do
4968 mknod $local_tdir/loop${i}b b 7 $i
4969 mknod $local_tdir/null${i}c c 1 3
4970 ln -s $local_tdir/file1 $local_tdir/link${i}
4972 for i in $(seq $local_numdirs) ; do
4973 mknod $local_tdir/dir$i/loop${i}b b 7 $i
4974 mknod $local_tdir/dir$i/null${i}c c 1 3
4975 ln -s $local_tdir/dir$i/file1 $local_tdir/dir$i/link${i}
4981 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4982 local expected=$(($NUMDIRS + 2))
4984 setup_56 $dir $NUMFILES $NUMDIRS
4986 # test lfs find with -name
4987 for i in $(seq $NUMFILES) ; do
4988 local nums=$($LFS find -name "*$i" $dir | wc -l)
4990 [ $nums -eq $expected ] ||
4991 error "lfs find -name '*$i' $dir wrong: "\
4992 "found $nums, expected $expected"
4995 run_test 56g "check lfs find -name"
4998 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
4999 local expected=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
5001 setup_56 $dir $NUMFILES $NUMDIRS
5003 # test lfs find with ! -name
5004 for i in $(seq $NUMFILES) ; do
5005 local nums=$($LFS find ! -name "*$i" $dir | wc -l)
5007 [ $nums -eq $expected ] ||
5008 error "lfs find ! -name '*$i' $dir wrong: "\
5009 "found $nums, expected $expected"
5012 run_test 56h "check lfs find ! -name"
5015 local dir=$DIR/$tdir
5019 local cmd="$LFS find -ost $(ostuuid_from_index 0 $dir) $dir"
5022 [ -z "$out" ] || error "'$cmd' returned directory '$out'"
5024 run_test 56i "check 'lfs find -ost UUID' skips directories"
5027 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5029 setup_56_special $dir $NUMFILES $NUMDIRS
5031 local expected=$((NUMDIRS + 1))
5032 local cmd="$LFS find -type d $dir"
5033 local nums=$($cmd | wc -l)
5035 [ $nums -eq $expected ] ||
5036 error "'$cmd' wrong: found $nums, expected $expected"
5038 run_test 56j "check lfs find -type d"
5041 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5043 setup_56_special $dir $NUMFILES $NUMDIRS
5045 local expected=$(((NUMDIRS + 1) * NUMFILES))
5046 local cmd="$LFS find -type f $dir"
5047 local nums=$($cmd | wc -l)
5049 [ $nums -eq $expected ] ||
5050 error "'$cmd' wrong: found $nums, expected $expected"
5052 run_test 56k "check lfs find -type f"
5055 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5057 setup_56_special $dir $NUMFILES $NUMDIRS
5059 local expected=$((NUMDIRS + NUMFILES))
5060 local cmd="$LFS find -type b $dir"
5061 local nums=$($cmd | wc -l)
5063 [ $nums -eq $expected ] ||
5064 error "'$cmd' wrong: found $nums, expected $expected"
5066 run_test 56l "check lfs find -type b"
5069 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5071 setup_56_special $dir $NUMFILES $NUMDIRS
5073 local expected=$((NUMDIRS + NUMFILES))
5074 local cmd="$LFS find -type c $dir"
5075 local nums=$($cmd | wc -l)
5076 [ $nums -eq $expected ] ||
5077 error "'$cmd' wrong: found $nums, expected $expected"
5079 run_test 56m "check lfs find -type c"
5082 local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
5083 setup_56_special $dir $NUMFILES $NUMDIRS
5085 local expected=$((NUMDIRS + NUMFILES))
5086 local cmd="$LFS find -type l $dir"
5087 local nums=$($cmd | wc -l)
5089 [ $nums -eq $expected ] ||
5090 error "'$cmd' wrong: found $nums, expected $expected"
5092 run_test 56n "check lfs find -type l"
5095 local dir=$DIR/$tdir
5097 setup_56 $dir $NUMFILES $NUMDIRS
5098 utime $dir/file1 > /dev/null || error "utime (1)"
5099 utime $dir/file2 > /dev/null || error "utime (2)"
5100 utime $dir/dir1 > /dev/null || error "utime (3)"
5101 utime $dir/dir2 > /dev/null || error "utime (4)"
5102 utime $dir/dir1/file1 > /dev/null || error "utime (5)"
5103 dd if=/dev/zero count=1 >> $dir/dir1/file1 && sync
5106 local nums=$($LFS find -mtime +0 $dir | wc -l)
5108 [ $nums -eq $expected ] ||
5109 error "lfs find -mtime +0 $dir: found $nums expect $expected"
5112 cmd="$LFS find -mtime 0 $dir"
5113 nums=$($cmd | wc -l)
5114 [ $nums -eq $expected ] ||
5115 error "'$cmd' wrong: found $nums, expected $expected"
5117 run_test 56o "check lfs find -mtime for old files"
5120 [ $RUNAS_ID -eq $UID ] &&
5121 skip_env "RUNAS_ID = UID = $UID -- skipping"
5123 local dir=$DIR/$tdir
5125 setup_56 $dir $NUMFILES $NUMDIRS
5126 chown $RUNAS_ID $dir/file* || error "chown $DIR/${tdir}g/file$i failed"
5128 local expected=$NUMFILES
5129 local cmd="$LFS find -uid $RUNAS_ID $dir"
5130 local nums=$($cmd | wc -l)
5132 [ $nums -eq $expected ] ||
5133 error "'$cmd' wrong: found $nums, expected $expected"
5135 expected=$(((NUMFILES + 1) * NUMDIRS + 1))
5136 cmd="$LFS find ! -uid $RUNAS_ID $dir"
5137 nums=$($cmd | wc -l)
5138 [ $nums -eq $expected ] ||
5139 error "'$cmd' wrong: found $nums, expected $expected"
5141 run_test 56p "check lfs find -uid and ! -uid"
5144 [ $RUNAS_ID -eq $UID ] &&
5145 skip_env "RUNAS_ID = UID = $UID -- skipping"
5147 local dir=$DIR/$tdir
5149 setup_56 $dir $NUMFILES $NUMDIRS
5150 chgrp $RUNAS_GID $dir/file* || error "chown $dir/file$i failed"
5152 local expected=$NUMFILES
5153 local cmd="$LFS find -gid $RUNAS_GID $dir"
5154 local nums=$($cmd | wc -l)
5156 [ $nums -eq $expected ] ||
5157 error "'$cmd' wrong: found $nums, expected $expected"
5159 expected=$(( ($NUMFILES+1) * $NUMDIRS + 1))
5160 cmd="$LFS find ! -gid $RUNAS_GID $dir"
5161 nums=$($cmd | wc -l)
5162 [ $nums -eq $expected ] ||
5163 error "'$cmd' wrong: found $nums, expected $expected"
5165 run_test 56q "check lfs find -gid and ! -gid"
5168 local dir=$DIR/$tdir
5170 setup_56 $dir $NUMFILES $NUMDIRS
5173 local cmd="$LFS find -size 0 -type f $dir"
5174 local nums=$($cmd | wc -l)
5176 [ $nums -eq $expected ] ||
5177 error "'$cmd' wrong: found $nums, expected $expected"
5179 cmd="$LFS find ! -size 0 -type f $dir"
5180 nums=$($cmd | wc -l)
5181 [ $nums -eq $expected ] ||
5182 error "'$cmd' wrong: found $nums, expected $expected"
5183 echo "test" > $dir/$tfile
5184 echo "test2" > $dir/$tfile.2 && sync
5186 cmd="$LFS find -size 5 -type f $dir"
5187 nums=$($cmd | wc -l)
5188 [ $nums -eq $expected ] ||
5189 error "'$cmd' wrong: found $nums, expected $expected"
5191 cmd="$LFS find -size +5 -type f $dir"
5192 nums=$($cmd | wc -l)
5193 [ $nums -eq $expected ] ||
5194 error "'$cmd' wrong: found $nums, expected $expected"
5196 cmd="$LFS find -size +0 -type f $dir"
5197 nums=$($cmd | wc -l)
5198 [ $nums -eq $expected ] ||
5199 error "'$cmd' wrong: found $nums, expected $expected"
5201 cmd="$LFS find ! -size -5 -type f $dir"
5202 nums=$($cmd | wc -l)
5203 [ $nums -eq $expected ] ||
5204 error "'$cmd' wrong: found $nums, expected $expected"
5206 cmd="$LFS find -size -5 -type f $dir"
5207 nums=$($cmd | wc -l)
5208 [ $nums -eq $expected ] ||
5209 error "'$cmd' wrong: found $nums, expected $expected"
5211 run_test 56r "check lfs find -size works"
5213 test_56s() { # LU-611 #LU-9369
5214 [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
5216 local dir=$DIR/$tdir
5217 local onestripe=$(((NUMDIRS + 1) * NUMFILES))
5219 setup_56 $dir $NUMFILES $NUMDIRS "-c 1"
5220 for i in $(seq $NUMDIRS); do
5221 $LFS setstripe -c $((OSTCOUNT + 1)) $dir/dir$i/$tfile
5224 local expected=$NUMDIRS
5225 local cmd="$LFS find -c $OSTCOUNT $dir"
5226 local nums=$($cmd | wc -l)
5228 [ $nums -eq $expected ] || {
5229 $LFS getstripe -R $dir
5230 error "'$cmd' wrong: found $nums, expected $expected"
5233 expected=$((NUMDIRS + onestripe))
5234 cmd="$LFS find -stripe-count +0 -type f $dir"
5235 nums=$($cmd | wc -l)
5236 [ $nums -eq $expected ] || {
5237 $LFS getstripe -R $dir
5238 error "'$cmd' wrong: found $nums, expected $expected"
5242 cmd="$LFS find -stripe-count 1 -type f $dir"
5243 nums=$($cmd | wc -l)
5244 [ $nums -eq $expected ] || {
5245 $LFS getstripe -R $dir
5246 error "'$cmd' wrong: found $nums, expected $expected"
5249 cmd="$LFS find -stripe-count -2 -type f $dir"
5250 nums=$($cmd | wc -l)
5251 [ $nums -eq $expected ] || {
5252 $LFS getstripe -R $dir
5253 error "'$cmd' wrong: found $nums, expected $expected"
5257 cmd="$LFS find -stripe-count $((OSTCOUNT + 1)) -type f $dir"
5258 nums=$($cmd | wc -l)
5259 [ $nums -eq $expected ] || {
5260 $LFS getstripe -R $dir
5261 error "'$cmd' wrong: found $nums, expected $expected"
5264 run_test 56s "check lfs find -stripe-count works"
5266 test_56t() { # LU-611 #LU-9369
5267 local dir=$DIR/$tdir
5269 setup_56 $dir 0 $NUMDIRS
5270 for i in $(seq $NUMDIRS); do
5271 $LFS setstripe -S 8M $dir/dir$i/$tfile
5274 local expected=$NUMDIRS
5275 local cmd="$LFS find -S 8M $dir"
5276 local nums=$($cmd | wc -l)
5278 [ $nums -eq $expected ] || {
5279 $LFS getstripe -R $dir
5280 error "'$cmd' wrong: found $nums, expected $expected"
5284 setup_56 $dir $NUMFILES $NUMDIRS "--stripe-size 512k"
5286 $LFS setstripe -S 256k $dir/$tfile.{0,1,2,3}
5288 expected=$(((NUMDIRS + 1) * NUMFILES))
5289 cmd="$LFS find -stripe-size 512k -type f $dir"
5290 nums=$($cmd | wc -l)
5291 [ $nums -eq $expected ] ||
5292 error "'$cmd' wrong: found $nums, expected $expected"
5294 cmd="$LFS find -stripe-size +320k -type f $dir"
5295 nums=$($cmd | wc -l)
5296 [ $nums -eq $expected ] ||
5297 error "'$cmd' wrong: found $nums, expected $expected"
5299 expected=$(((NUMDIRS + 1) * NUMFILES + 4))
5300 cmd="$LFS find -stripe-size +200k -type f $dir"
5301 nums=$($cmd | wc -l)
5302 [ $nums -eq $expected ] ||
5303 error "'$cmd' wrong: found $nums, expected $expected"
5305 cmd="$LFS find -stripe-size -640k -type f $dir"
5306 nums=$($cmd | wc -l)
5307 [ $nums -eq $expected ] ||
5308 error "'$cmd' wrong: found $nums, expected $expected"
5311 cmd="$LFS find -stripe-size 256k -type f $dir"
5312 nums=$($cmd | wc -l)
5313 [ $nums -eq $expected ] ||
5314 error "'$cmd' wrong: found $nums, expected $expected"
5316 cmd="$LFS find -stripe-size -320k -type f $dir"
5317 nums=$($cmd | wc -l)
5318 [ $nums -eq $expected ] ||
5319 error "'$cmd' wrong: found $nums, expected $expected"
5322 cmd="$LFS find -stripe-size 1024k -type f $dir"
5323 nums=$($cmd | wc -l)
5324 [ $nums -eq $expected ] ||
5325 error "'$cmd' wrong: found $nums, expected $expected"
5327 run_test 56t "check lfs find -stripe-size works"
5329 test_56u() { # LU-611
5330 local dir=$DIR/$tdir
5332 setup_56 $dir $NUMFILES $NUMDIRS "-i 0 -c 1"
5334 if [[ $OSTCOUNT -gt 1 ]]; then
5335 $LFS setstripe -i 1 -c 1 $dir/$tfile.{0,1,2,3}
5341 local expected=$(((NUMDIRS + 1) * NUMFILES))
5342 local cmd="$LFS find -stripe-index 0 -type f $dir"
5343 local nums=$($cmd | wc -l)
5345 [ $nums -eq $expected ] ||
5346 error "'$cmd' wrong: found $nums, expected $expected"
5349 cmd="$LFS find -stripe-index 1 -type f $dir"
5350 nums=$($cmd | wc -l)
5351 [ $nums -eq $expected ] ||
5352 error "'$cmd' wrong: found $nums, expected $expected"
5354 cmd="$LFS find ! -stripe-index 0 -type f $dir"
5355 nums=$($cmd | wc -l)
5356 [ $nums -eq $expected ] ||
5357 error "'$cmd' wrong: found $nums, expected $expected"
5360 # This should produce an error and not return any files
5361 cmd="$LFS find -stripe-index $OSTCOUNT -type f $dir"
5362 nums=$($cmd 2>/dev/null | wc -l)
5363 [ $nums -eq $expected ] ||
5364 error "'$cmd' wrong: found $nums, expected $expected"
5366 if [[ $OSTCOUNT -gt 1 ]]; then
5367 expected=$(((NUMDIRS + 1) * NUMFILES + onestripe))
5368 cmd="$LFS find -stripe-index 0,1 -type f $dir"
5369 nums=$($cmd | wc -l)
5370 [ $nums -eq $expected ] ||
5371 error "'$cmd' wrong: found $nums, expected $expected"
5374 run_test 56u "check lfs find -stripe-index works"
5378 local dir=$DIR/$tdir
5380 setup_56 $dir $NUMFILES $NUMDIRS
5382 UUID=$(mdtuuid_from_index $mdt_idx $dir)
5383 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
5385 for file in $($LFS find -m $UUID $dir); do
5386 file_midx=$($LFS getstripe -m $file)
5387 [ $file_midx -eq $mdt_idx ] ||
5388 error "lfs find -m $UUID != getstripe -m $file_midx"
5391 run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
5394 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
5397 local dir=$DIR/$tdir
5399 setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
5401 local stripe_size=$($LFS getstripe -S -d $dir) ||
5402 error "$LFS getstripe -S -d $dir failed"
5403 stripe_size=${stripe_size%% *}
5405 local file_size=$((stripe_size * OSTCOUNT))
5406 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
5407 local required_space=$((file_num * file_size))
5408 local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
5410 [[ $free_space -le $((required_space / 1024)) ]] &&
5411 skip_env "need $required_space, have $free_space kbytes"
5414 local dd_count=$((file_size / dd_bs))
5416 # write data into the files
5421 for i in $(seq $NUMFILES); do
5423 yes | dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5424 error "write data into $file failed"
5426 for i in $(seq $NUMDIRS); do
5427 for j in $(seq $NUMFILES); do
5428 file=$dir/dir$i/file$j
5429 yes|dd bs=$dd_bs count=$dd_count of=$file &>/dev/null ||
5430 error "write data into $file failed"
5434 # $LFS_MIGRATE will fail if hard link migration is unsupported
5435 if [[ $(lustre_version_code mds1) -gt $(version_code 2.5.55) ]]; then
5436 createmany -l$dir/dir1/file1 $dir/dir1/link 200 ||
5437 error "creating links to $dir/dir1/file1 failed"
5442 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
5445 local cmd="$LFS_MIGRATE -y -c $expected $dir/file1"
5448 eval $cmd || error "$cmd failed"
5450 check_stripe_count $dir/file1 $expected
5452 if [ $MDS1_VERSION -ge $(version_code 2.6.90) ];
5454 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
5455 # OST 1 if it is on OST 0. This file is small enough to
5456 # be on only one stripe.
5457 file=$dir/migr_1_ost
5458 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
5459 error "write data into $file failed"
5460 local obdidx=$($LFS getstripe -i $file)
5461 local oldmd5=$(md5sum $file)
5464 [[ $obdidx -eq 0 ]] && newobdidx=1
5465 cmd="$LFS migrate -i $newobdidx $file"
5467 eval $cmd || error "$cmd failed"
5469 local realobdix=$($LFS getstripe -i $file)
5470 local newmd5=$(md5sum $file)
5472 [[ $newobdidx -ne $realobdix ]] &&
5473 error "new OST is different (was=$obdidx, "\
5474 "wanted=$newobdidx, got=$realobdix)"
5475 [[ "$oldmd5" != "$newmd5" ]] &&
5476 error "md5sum differ: $oldmd5, $newmd5"
5480 cmd="$LFS_MIGRATE -y -c $expected $dir/dir1"
5482 eval $cmd || error "$cmd failed"
5484 for j in $(seq $NUMFILES); do
5485 check_stripe_count $dir/dir1/file$j $expected
5488 # lfs_migrate works with lfs find
5489 cmd="$LFS find -stripe_count $OSTCOUNT -type f $dir |
5490 $LFS_MIGRATE -y -c $expected"
5492 eval $cmd || error "$cmd failed"
5494 for i in $(seq 2 $NUMFILES); do
5495 check_stripe_count $dir/file$i $expected
5497 for i in $(seq 2 $NUMDIRS); do
5498 for j in $(seq $NUMFILES); do
5499 check_stripe_count $dir/dir$i/file$j $expected
5503 run_test 56w "check lfs_migrate -c stripe_count works"
5506 local file1=$DIR/$tdir/file1
5507 local create_pool=false
5508 local initial_pool=$($LFS getstripe -p $DIR)
5512 echo -n "Creating test dir..."
5513 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5516 echo -n "Creating test file..."
5517 touch $file1 || error "cannot create file"
5520 echo -n "Detecting existing pools..."
5521 pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
5523 if [ ${#pool_list[@]} -gt 0 ]; then
5524 echo "${pool_list[@]}"
5525 for thispool in "${pool_list[@]}"; do
5526 if [[ -z "$initial_pool" ||
5527 "$initial_pool" != "$thispool" ]]; then
5529 echo "Using existing pool '$pool'"
5534 echo "none detected."
5536 if [ -z "$pool" ]; then
5537 pool=${POOL:-testpool}
5538 [ "$initial_pool" = "$pool" ] && pool="testpool2"
5539 echo -n "Creating pool '$pool'..."
5541 pool_add $pool &> /dev/null ||
5542 error "pool_add failed"
5545 echo -n "Adding target to pool..."
5546 pool_add_targets $pool 0 0 1 &> /dev/null ||
5547 error "pool_add_targets failed"
5551 echo -n "Setting pool using -p option..."
5552 $LFS_MIGRATE -y -q --no-rsync -p $pool $file1 &> /dev/null ||
5553 error "migrate failed rc = $?"
5556 echo -n "Verifying test file is in pool after migrating..."
5557 [ "$($LFS getstripe -p $file1)" = $pool ] ||
5558 error "file was not migrated to pool $pool"
5561 echo -n "Removing test file from pool '$pool'..."
5562 $LFS migrate $file1 &> /dev/null ||
5563 error "cannot remove from pool"
5564 [ "$($LFS getstripe -p $file1)" ] &&
5565 error "pool still set"
5568 echo -n "Setting pool using --pool option..."
5569 $LFS_MIGRATE -y -q --no-rsync --pool $pool $file1 &> /dev/null ||
5570 error "migrate failed rc = $?"
5575 if $create_pool; then
5576 destroy_test_pools 2> /dev/null ||
5577 error "destroy test pools failed"
5580 run_test 56wb "check lfs_migrate pool support"
5583 local file1="$DIR/$tdir/file1"
5585 echo -n "Creating test dir..."
5586 test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
5587 local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
5588 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5589 error "cannot set stripe"
5592 echo -n "Setting initial stripe for test file..."
5593 $LFS setstripe -S 512K -c 1 "$file1" &> /dev/null ||
5594 error "cannot set stripe"
5595 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5596 error "stripe size not set"
5599 # File currently set to -S 512K -c 1
5601 # Ensure -c and -S options are rejected when -R is set
5602 echo -n "Verifying incompatible options are detected..."
5603 $LFS_MIGRATE -y -R -c 1 "$file1" &> /dev/null &&
5604 error "incompatible -c and -R options not detected"
5605 $LFS_MIGRATE -y -R -S 1M "$file1" &> /dev/null &&
5606 error "incompatible -S and -R options not detected"
5609 # Ensure unrecognized options are passed through to 'lfs migrate'
5610 echo -n "Verifying -S option is passed through to lfs migrate..."
5611 $LFS_MIGRATE -y -S 1M "$file1" &> /dev/null ||
5612 error "migration failed"
5613 [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
5614 error "file was not restriped"
5617 # File currently set to -S 1M -c 1
5619 # Ensure long options are supported
5620 echo -n "Verifying long options supported..."
5621 $LFS_MIGRATE -y --non-block "$file1" &> /dev/null ||
5622 error "long option without argument not supported"
5623 $LFS_MIGRATE -y --stripe-size 512K "$file1" &> /dev/null ||
5624 error "long option with argument not supported"
5625 [ $($LFS getstripe -S "$file1") -eq 524288 ] ||
5626 error "file not restriped with --stripe-size option"
5629 # File currently set to -S 512K -c 1
5631 if [ "$OSTCOUNT" -gt 1 ]; then
5632 echo -n "Verifying explicit stripe count can be set..."
5633 $LFS_MIGRATE -y -c 2 "$file1" &> /dev/null ||
5634 error "migrate failed"
5635 [ $($LFS getstripe -c "$file1") -eq 2 ] ||
5636 error "file not restriped to explicit count"
5640 # File currently set to -S 512K -c 1 or -S 512K -c 2
5642 # Ensure parent striping is used if -R is set, and no stripe
5643 # count or size is specified
5644 echo -n "Setting stripe for parent directory..."
5645 $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
5646 error "cannot set stripe"
5649 echo -n "Verifying restripe option uses parent stripe settings..."
5650 $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
5651 error "migrate failed"
5652 [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
5653 error "file not restriped to parent settings"
5654 [ $($LFS getstripe -c "$file1") -eq 1 ] ||
5655 error "file not restriped to parent settings"
5658 # File currently set to -S 1M -c 1
5660 # Ensure striping is preserved if -R is not set, and no stripe
5661 # count or size is specified
5662 echo -n "Verifying striping size preserved when not specified..."
5663 local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
5664 $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
5665 error "cannot set stripe on parent directory"
5666 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5667 error "migrate failed"
5668 [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
5669 error "file was restriped"
5672 # Ensure file name properly detected when final option has no argument
5673 echo -n "Verifying file name properly detected..."
5674 $LFS_MIGRATE -y "$file1" &> /dev/null ||
5675 error "file name interpreted as option argument"
5681 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
5684 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5686 local file1=$DIR/$tdir/file1
5688 echo -n "Creating test dir..."
5689 test_mkdir $DIR/$tdir || error "cannot create dir"
5692 echo -n "Creating test file..."
5696 # Ensure 'lfs migrate' will fail by using a non-existent option,
5697 # and make sure rsync is not called to recover
5698 echo -n "Make sure --no-rsync option works..."
5699 $LFS_MIGRATE -y --no-rsync --invalid-opt $file1 2>&1 |
5700 grep -q 'refusing to fall back to rsync' ||
5701 error "rsync was called with --no-rsync set"
5704 # Ensure rsync is called without trying 'lfs migrate' first
5705 echo -n "Make sure --rsync option works..."
5706 $LFS_MIGRATE -y --rsync --invalid-opt $file1 2>&1 |
5707 grep -q 'falling back to rsync' &&
5708 error "lfs migrate was called with --rsync set"
5711 echo -n "Make sure --rsync and --no-rsync options are exclusive..."
5712 $LFS_MIGRATE -y --rsync --no-rsync $file1 2>&1 |
5713 grep -q 'at the same time' ||
5714 error "--rsync and --no-rsync accepted concurrently"
5720 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
5723 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5724 check_swap_layouts_support
5726 local dir=$DIR/$tdir
5727 local ref1=/etc/passwd
5728 local file1=$dir/file1
5730 test_mkdir $dir || error "creating dir $dir"
5731 $LFS setstripe -c 2 $file1
5733 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
5734 stripe=$($LFS getstripe -c $file1)
5735 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5736 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5741 run_test 56x "lfs migration support"
5744 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
5745 check_swap_layouts_support
5747 local dir=$DIR/$tdir/$testnum
5751 local ref1=/etc/passwd
5752 local file1=$dir/file1
5754 $LFS setstripe -c 2 $file1
5756 $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
5758 local stripe=$($LFS getstripe -c $file1)
5760 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
5761 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
5766 run_test 56xa "lfs migration --block support"
5768 check_migrate_links() {
5770 local file1="$dir/file1"
5773 local total_count=$(($begin + $count - 1))
5774 local symlink_count=10
5777 if [ ! -f "$file1" ]; then
5778 echo -n "creating initial file..."
5779 $LFS setstripe -c 1 -S "512k" "$file1" ||
5780 error "cannot setstripe initial file"
5783 echo -n "creating symlinks..."
5784 for s in $(seq 1 $symlink_count); do
5785 ln -s "$file1" "$dir/slink$s" ||
5786 error "cannot create symlinks"
5790 echo -n "creating nonlinked files..."
5791 createmany -o "$dir/uniq" 1 10 &> /dev/null ||
5792 error "cannot create nonlinked files"
5797 if [ ! -f "$dir/file$total_count" ]; then
5798 echo -n "creating hard links $begin:$total_count..."
5799 createmany -l"$file1" "$dir/file" "$begin" "$count" &> \
5800 /dev/null || error "cannot create hard links"
5804 echo -n "checking number of hard links listed in xattrs..."
5805 local fid=$($LFS getstripe -F "$file1")
5806 local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
5809 if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2 ]; then
5810 skip "hard link list has unexpected size, skipping test"
5812 if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2 ]; then
5813 error "link names should exceed xattrs size"
5816 echo -n "migrating files..."
5817 local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
5819 [ $rc -eq 0 ] || error "migrate failed rc = $rc"
5822 # make sure all links have been properly migrated
5823 echo -n "verifying files..."
5824 fid=$($LFS getstripe -F "$file1") ||
5825 error "cannot get fid for file $file1"
5826 for i in $(seq 2 $total_count); do
5827 local fid2=$($LFS getstripe -F $dir/file$i)
5829 [ "$fid2" == "$fid" ] ||
5830 error "migrated hard link has mismatched FID"
5833 # make sure hard links were properly detected, and migration was
5834 # performed only once for the entire link set; nonlinked files should
5836 local actual=$(grep -c 'done migrate' <<< "$migrate_out")
5837 local expected=$(($uniq_count + 1))
5839 [ "$actual" -eq "$expected" ] ||
5840 error "hard links individually migrated ($actual != $expected)"
5842 # make sure the correct number of hard links are present
5843 local hardlinks=$(stat -c '%h' "$file1")
5845 [ $hardlinks -eq $total_count ] ||
5846 error "num hard links $hardlinks != $total_count"
5853 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
5854 skip "Need MDS version at least 2.10.55"
5856 local dir="$DIR/$tdir"
5858 test_mkdir "$dir" || error "cannot create dir $dir"
5860 echo "testing lfs migrate mode when all links fit within xattrs"
5861 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 2 99
5863 echo "testing rsync mode when all links fit within xattrs"
5864 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 2 99
5866 echo "testing lfs migrate mode when all links do not fit within xattrs"
5867 LFS_MIGRATE_RSYNC=false check_migrate_links "$dir" 101 100
5869 echo "testing rsync mode when all links do not fit within xattrs"
5870 LFS_MIGRATE_RSYNC=true check_migrate_links "$dir" 101 100
5875 run_test 56xb "lfs migration hard link support"
5878 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
5879 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
5882 local dir=$DIR/$tdir
5886 test_mkdir -p $dir || error "creating dir $dir"
5887 touch $f1 || error "creating std file $f1"
5888 $MULTIOP $f2 H2c || error "creating released file $f2"
5890 # a directory can be raid0, so ask only for files
5891 res=$($LFS find $dir -L raid0 -type f | wc -l)
5892 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5894 res=$($LFS find $dir \! -L raid0 -type f | wc -l)
5895 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5897 # only files can be released, so no need to force file search
5898 res=$($LFS find $dir -L released)
5899 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5901 res=$($LFS find $dir -type f \! -L released)
5902 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5904 run_test 56y "lfs find -L raid0|released"
5906 test_56z() { # LU-4824
5907 # This checks to make sure 'lfs find' continues after errors
5908 # There are two classes of errors that should be caught:
5909 # - If multiple paths are provided, all should be searched even if one
5911 # - If errors are encountered during the search, it should not terminate
5913 local dir=$DIR/$tdir
5917 for i in d{0..9}; do
5920 touch $dir/d{0..9}/$tfile
5921 $LFS find $DIR/non_existent_dir $dir &&
5922 error "$LFS find did not return an error"
5923 # Make a directory unsearchable. This should NOT be the last entry in
5924 # directory order. Arbitrarily pick the 6th entry
5925 chmod 700 $($LFS find $dir -type d | sed '6!d')
5927 local count=$($RUNAS $LFS find $DIR/non_existent $dir | wc -l)
5929 # The user should be able to see 10 directories and 9 files
5930 [ $count == 19 ] || error "$LFS find did not continue after error"
5932 run_test 56z "lfs find should continue after an error"
5934 test_56aa() { # LU-5937
5935 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
5937 local dir=$DIR/$tdir
5940 $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
5942 createmany -o $dir/striped_dir/${tfile}- 1024
5943 local dirs=$($LFS find --size +8k $dir/)
5945 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5947 run_test 56aa "lfs find --size under striped dir"
5949 test_56ab() { # LU-10705
5950 test_mkdir $DIR/$tdir
5951 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
5952 dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
5953 dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
5954 # Flush writes to ensure valid blocks. Need to be more thorough for
5955 # ZFS, since blocks are not allocated/returned to client immediately.
5957 wait_zfs_commit ost1 2
5958 cancel_lru_locks osc
5961 local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
5963 [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
5965 files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
5966 [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
5968 rm -f $DIR/$tdir/$tfile.[123]
5970 run_test 56ab "lfs find --blocks"
5973 [ $MDS1_VERSION -lt $(version_code 2.10.50) ] &&
5974 skip "Need MDS version at least 2.10.50"
5976 # Create composite files with one component
5977 local dir=$DIR/$tdir
5979 setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
5980 # Create composite files with three components
5981 setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
5982 # Create non-composite files
5983 createmany -o $dir/${tfile}- 10
5985 local nfiles=$($LFS find --component-end 1M --type f $dir | wc -l)
5987 [[ $nfiles == 10 ]] ||
5988 error "lfs find -E 1M found $nfiles != 10 files"
5990 nfiles=$($LFS find ! -E 1M --type f $dir | wc -l)
5991 [[ $nfiles == 25 ]] ||
5992 error "lfs find ! -E 1M found $nfiles != 25 files"
5994 # All files have a component that starts at 0
5995 nfiles=$($LFS find --component-start 0 --type f $dir | wc -l)
5996 [[ $nfiles == 35 ]] ||
5997 error "lfs find --component-start 0 - $nfiles != 35 files"
5999 nfiles=$($LFS find --component-start 2M --type f $dir | wc -l)
6000 [[ $nfiles == 15 ]] ||
6001 error "lfs find --component-start 2M - $nfiles != 15 files"
6003 # All files created here have a componenet that does not starts at 2M
6004 nfiles=$($LFS find ! --component-start 2M --type f $dir | wc -l)
6005 [[ $nfiles == 35 ]] ||
6006 error "lfs find ! --component-start 2M - $nfiles != 35 files"
6008 # Find files with a specified number of components
6009 local nfiles=$($LFS find --component-count 3 --type f $dir | wc -l)
6010 [[ $nfiles == 15 ]] ||
6011 error "lfs find --component-count 3 - $nfiles != 15 files"
6013 # Remember non-composite files have a component count of zero
6014 local nfiles=$($LFS find --component-count 0 --type f $dir | wc -l)
6015 [[ $nfiles == 10 ]] ||
6016 error "lfs find --component-count 0 - $nfiles != 10 files"
6018 nfiles=$($LFS find ! --component-count 3 --type f $dir | wc -l)
6019 [[ $nfiles == 20 ]] ||
6020 error "lfs find ! --component-count 3 - $nfiles != 20 files"
6022 # All files have a flag called "init"
6023 local nfiles=$($LFS find --component-flags init --type f $dir | wc -l)
6024 [[ $nfiles == 35 ]] ||
6025 error "lfs find --component-flags init - $nfiles != 35 files"
6027 # Multi-component files will have a component not initialized
6028 local nfiles=$($LFS find ! --component-flags init --type f $dir | wc -l)
6029 [[ $nfiles == 15 ]] ||
6030 error "lfs find !--component-flags init - $nfiles != 15 files"
6035 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
6038 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
6039 skip "Need MDS version at least 2.10.57"
6049 # create mirrored directories and mirrored files
6050 mkdir $td || error "mkdir $td failed"
6051 $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
6052 createmany -o $tf- 10 || error "create $tf- failed"
6054 for i in $(seq 2); do
6056 mkdir $dir || error "mkdir $dir failed"
6057 $LFS mirror create -N$((3 + i)) $dir ||
6058 error "create mirrored dir $dir failed"
6059 createmany -o $dir/$tfile- 10 ||
6060 error "create $dir/$tfile- failed"
6063 # change the states of some mirrored files
6065 for i in $(seq 2); do
6067 for j in $(seq 4 9); do
6068 echo foo > $dir/$tfile-$j
6072 # find mirrored files with specific mirror count
6073 cmd="$LFS find --mirror-count 3 --type f $td"
6074 nfiles=$($cmd | wc -l)
6075 [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
6077 cmd="$LFS find ! --mirror-count 3 --type f $td"
6078 nfiles=$($cmd | wc -l)
6079 [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
6081 cmd="$LFS find --mirror-count +2 --type f $td"
6082 nfiles=$($cmd | wc -l)
6083 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6085 cmd="$LFS find --mirror-count -6 --type f $td"
6086 nfiles=$($cmd | wc -l)
6087 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6089 # find mirrored files with specific file state
6090 cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
6091 [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
6093 cmd="$LFS find --mirror-state=ro --type f $td"
6094 nfiles=$($cmd | wc -l)
6095 [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
6097 cmd="$LFS find ! --mirror-state=ro --type f $td"
6098 nfiles=$($cmd | wc -l)
6099 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6101 cmd="$LFS find --mirror-state=wp --type f $td"
6102 nfiles=$($cmd | wc -l)
6103 [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
6105 cmd="$LFS find ! --mirror-state=sp --type f $td"
6106 nfiles=$($cmd | wc -l)
6107 [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
6109 run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
6112 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6113 # note test will not do anything if MDS is not local
6114 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6115 skip_env "ldiskfs only test"
6117 remote_mds_nodsh && skip "remote MDS with nodsh"
6119 local MNTDEV="osd*.*MDT*.mntdev"
6120 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
6121 [ -z "$DEV" ] && error "can't access $MNTDEV"
6122 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
6123 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
6124 error "can't access $DEV"
6125 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
6126 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
6130 run_test 57a "verify MDS filesystem created with large inodes =="
6133 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6134 if [ "$mds1_FSTYPE" != ldiskfs ]; then
6135 skip_env "ldiskfs only test"
6137 remote_mds_nodsh && skip "remote MDS with nodsh"
6139 local dir=$DIR/$tdir
6142 local fileN=$dir/f$filecount
6144 rm -rf $dir || error "removing $dir"
6146 local mdtidx=$($LFS getstripe -m $dir)
6147 local mdtname=MDT$(printf %04x $mdtidx)
6148 local facet=mds$((mdtidx + 1))
6150 echo "mcreating $filecount files"
6151 createmany -m $dir/f 1 $filecount || error "creating files in $dir"
6153 # verify that files do not have EAs yet
6154 $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
6155 error "$file1 has an EA"
6156 $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
6157 error "$fileN has an EA"
6161 df $dir #make sure we get new statfs data
6162 local mdsfree=$(do_facet $facet \
6163 lctl get_param -n osd*.*$mdtname.kbytesfree)
6164 local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6167 echo "opening files to create objects/EAs"
6168 for file in $(seq -f $dir/f%g 1 $filecount); do
6169 $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
6170 error "opening $file"
6173 # verify that files have EAs now
6174 $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
6175 $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
6177 sleep 1 #make sure we get new statfs data
6179 local mdsfree2=$(do_facet $facet \
6180 lctl get_param -n osd*.*$mdtname.kbytesfree)
6181 local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
6183 if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
6184 if [ "$mdsfree" != "$mdsfree2" ]; then
6185 error "MDC before $mdcfree != after $mdcfree2"
6187 echo "MDC before $mdcfree != after $mdcfree2"
6188 echo "unable to confirm if MDS has large inodes"
6193 run_test 57b "default LOV EAs are stored inside large inodes ==="
6196 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6197 [ -z "$(which wiretest 2>/dev/null)" ] &&
6198 skip_env "could not find wiretest"
6202 run_test 58 "verify cross-platform wire constants =============="
6205 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6207 echo "touch 130 files"
6208 createmany -o $DIR/f59- 130
6210 unlinkmany $DIR/f59- 130
6212 # wait for commitment of removal
6213 wait_delete_completed
6215 run_test 59 "verify cancellation of llog records async ========="
6217 TEST60_HEAD="test_60 run $RANDOM"
6219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6220 remote_mgs_nodsh && skip "remote MGS with nodsh"
6221 do_facet mgs "! which run-llog.sh &> /dev/null" &&
6222 do_facet mgs "! ls run-llog.sh &> /dev/null" &&
6223 skip_env "missing subtest run-llog.sh"
6225 log "$TEST60_HEAD - from kernel mode"
6226 do_facet mgs "$LCTL dk > /dev/null"
6227 do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
6228 do_facet mgs $LCTL dk > $TMP/$tfile
6230 # LU-6388: test llog_reader
6231 local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
6232 llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
6233 [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
6234 skip_env "missing llog_reader"
6235 local fstype=$(facet_fstype mgs)
6236 [ $fstype != ldiskfs -a $fstype != zfs ] &&
6237 skip_env "Only for ldiskfs or zfs type mgs"
6239 local mntpt=$(facet_mntpt mgs)
6240 local mgsdev=$(mgsdevname 1)
6252 #get fid and record list
6253 fid_list=($(awk '/9_sub.*record/ { print $NF }' /$TMP/$tfile |
6255 rec_list=($(awk '/9_sub.*record/ { print $((NF-3)) }' /$TMP/$tfile |
6257 #remount mgs as ldiskfs or zfs type
6258 stop mgs || error "stop mgs failed"
6259 mount_fstype mgs || error "remount mgs failed"
6260 for ((i = 0; i < ${#fid_list[@]}; i++)); do
6263 seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
6264 oid=$(echo $fid | awk -F ':' '{ print $2 }' | sed -e "s/^0x//g")
6269 obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
6271 obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
6273 echo "obj_file is $obj_file"
6274 do_facet mgs $llog_reader $obj_file
6276 rec_type=$(do_facet mgs $llog_reader $obj_file | grep "type=" |
6277 awk '{ print $3 }' | sed -e "s/^type=//g")
6278 if [ $rec_type != $rec ]; then
6279 echo "FAILED test_60a wrong record type $rec_type," \
6285 #check obj path if record type is LLOG_LOGID_MAGIC
6286 if [ "$rec" == "1064553b" ]; then
6287 path=$(do_facet mgs $llog_reader $obj_file |
6288 grep "path=" | awk '{ print $NF }' |
6289 sed -e "s/^path=//g")
6290 if [ $obj_file != $mntpt/$path ]; then
6291 echo "FAILED test_60a wrong obj path" \
6292 "$montpt/$path, should be $obj_file"
6299 #restart mgs before "error", otherwise it will block the next test
6300 stop mgs || error "stop mgs failed"
6301 start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
6302 $pass || error "test failed, see FAILED test_60a messages for specifics"
6304 run_test 60a "llog_test run from kernel module and test llog_reader"
6306 test_60b() { # bug 6411
6307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6310 LLOG_COUNT=$(do_facet mgs dmesg |
6311 awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
6312 /llog_[a-z]*.c:[0-9]/ {
6324 [[ $LLOG_COUNT -gt 120 ]] &&
6325 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
6327 run_test 60b "limit repeated messages from CERROR/CWARN"
6330 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6332 echo "create 5000 files"
6333 createmany -o $DIR/f60c- 5000
6334 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
6335 lctl set_param fail_loc=0x80000137
6336 unlinkmany $DIR/f60c- 5000
6337 lctl set_param fail_loc=0
6339 run_test 60c "unlink file when mds full"
6342 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6344 SAVEPRINTK=$(lctl get_param -n printk)
6345 # verify "lctl mark" is even working"
6346 MESSAGE="test message ID $RANDOM $$"
6347 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6348 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
6350 lctl set_param printk=0 || error "set lnet.printk failed"
6351 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
6352 MESSAGE="new test message ID $RANDOM $$"
6353 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
6354 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
6355 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
6357 lctl set_param -n printk="$SAVEPRINTK"
6359 run_test 60d "test printk console message masking"
6362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6363 remote_mds_nodsh && skip "remote MDS with nodsh"
6366 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2 0x15b
6367 do_facet mds1 lctl set_param fail_loc=0x15b
6370 run_test 60e "no space while new llog is being created"
6375 test_mkdir -c $MDSCOUNT $DIR/$tdir
6376 $LFS setdirstripe -D -i -1 -c $MDSCOUNT $DIR/$tdir
6381 mkdir $DIR/$tdir/subdir$index 2>/dev/null
6382 rmdir $DIR/$tdir/subdir$index 2>/dev/null
6383 index=$((index + 1))
6389 for i in $(seq 100); do
6390 # define OBD_FAIL_OSD_TXN_START 0x19a
6391 do_facet mds1 lctl set_param fail_loc=0x8000019a
6397 mkdir $DIR/$tdir/new || error "mkdir failed"
6398 rmdir $DIR/$tdir/new || error "rmdir failed"
6400 run_test 60g "transaction abort won't cause MDT hung"
6403 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6406 dd if=/dev/zero of=$f bs=$PAGE_SIZE count=1 || error "dd $f failed"
6407 cancel_lru_locks osc
6408 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
6411 run_test 61a "mmap() writes don't make sync hang ================"
6414 mmap_mknod_test $DIR/$tfile || error "mmap_mknod_test failed"
6416 run_test 61b "mmap() of unstriped file is successful"
6418 # bug 2330 - insufficient obd_match error checking causes LBUG
6420 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6424 cancel_lru_locks osc
6425 lctl set_param fail_loc=0x405
6426 cat $f && error "cat succeeded, expect -EIO"
6427 lctl set_param fail_loc=0
6429 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
6430 # match every page all of the time.
6431 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
6433 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
6434 # Though this test is irrelevant anymore, it helped to reveal some
6435 # other grant bugs (LU-4482), let's keep it.
6436 test_63a() { # was test_63
6437 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6439 MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
6441 for i in `seq 10` ; do
6442 dd if=/dev/zero of=$DIR/f63 bs=8k &
6448 rm -f $DIR/f63 || true
6450 run_test 63a "Verify oig_wait interruption does not crash ======="
6452 # bug 2248 - async write errors didn't return to application on sync
6453 # bug 3677 - async write errors left page locked
6455 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6458 lctl set_param debug=-1
6460 # ensure we have a grant to do async writes
6461 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
6464 sync # sync lest earlier test intercept the fail_loc
6466 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6467 lctl set_param fail_loc=0x80000406
6468 $MULTIOP $DIR/$tfile Owy && \
6469 error "sync didn't return ENOMEM"
6470 sync; sleep 2; sync # do a real sync this time to flush page
6471 lctl get_param -n llite.*.dump_page_cache | grep locked && \
6472 error "locked page left in cache after async error" || true
6475 run_test 63b "async write errors should be returned to fsync ==="
6478 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6481 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
6483 run_test 64a "verify filter grant calculations (in kernel) ====="
6486 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6488 sh oos.sh $MOUNT || error "oos.sh failed: $?"
6490 run_test 64b "check out-of-space detection on client"
6493 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
6495 run_test 64c "verify grant shrink"
6497 # this does exactly what osc_request.c:osc_announce_cached() does in
6498 # order to calculate max amount of grants to ask from server
6502 local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc)
6503 local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight)
6505 ((rpc_in_flight ++));
6506 nrpages=$((nrpages * rpc_in_flight))
6508 local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb)
6510 dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE))
6512 [[ $dirty_max_pages -gt $nrpages ]] && nrpages=$dirty_max_pages
6513 local undirty=$((nrpages * PAGE_SIZE))
6515 local max_extent_pages
6516 max_extent_pages=$($LCTL get_param osc.${tgt}.import |
6517 grep grant_max_extent_size | awk '{print $2}')
6518 max_extent_pages=$((max_extent_pages / PAGE_SIZE))
6519 local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages))
6520 local grant_extent_tax
6521 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6522 grep grant_extent_tax | awk '{print $2}')
6524 undirty=$((undirty + nrextents * grant_extent_tax))
6529 # this is size of unit for grant allocation. It should be equal to
6530 # what tgt_grant.c:tgt_grant_chunk() calculates
6534 local grant_extent_tax
6536 max_brw_size=$($LCTL get_param osc.${tgt}.import |
6537 grep max_brw_size | awk '{print $2}')
6539 grant_extent_tax=$($LCTL get_param osc.${tgt}.import |
6540 grep grant_extent_tax | awk '{print $2}')
6542 echo $(((max_brw_size + grant_extent_tax) * 2))
6546 [ $OST1_VERSION -lt $(version_code 2.10.56) ] &&
6547 skip "OST < 2.10.55 doesn't limit grants enough"
6549 local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
6550 local file=$DIR/$tfile
6552 [[ $($LCTL get_param osc.${tgt}.import |
6553 grep "connect_flags:.*grant_param") ]] ||
6554 skip "no grant_param connect flag"
6556 local olddebug=$($LCTL get_param -n debug 2> /dev/null)
6558 $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
6560 local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
6561 stack_trap "rm -f $file" EXIT
6563 $SETSTRIPE $file -i 0 -c 1
6564 dd if=/dev/zero of=$file bs=1M count=1000 &
6569 local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes)
6570 if [[ $cur_grant -gt $max_cur_granted ]]
6573 error "cur_grant $cur_grant > $max_cur_granted"
6576 [[ $? -ne 0 ]] && break;
6581 wait_delete_completed
6582 $LCTL set_param debug="$olddebug" 2> /dev/null || true
6584 run_test 64d "check grant limit exceed"
6586 # bug 1414 - set/get directories' stripe info
6588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6590 test_mkdir $DIR/$tdir
6592 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
6594 run_test 65a "directory with no stripe info"
6597 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6599 test_mkdir $DIR/$tdir
6600 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6602 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6605 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
6607 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
6610 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6611 [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
6613 test_mkdir $DIR/$tdir
6614 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
6616 $LFS setstripe -S $((stripesize * 4)) -i 1 \
6617 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
6619 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
6621 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
6624 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6626 test_mkdir $DIR/$tdir
6627 local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
6628 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6630 if [[ $STRIPECOUNT -le 0 ]]; then
6632 elif [[ $STRIPECOUNT -gt 2000 ]]; then
6633 #LOV_MAX_STRIPE_COUNT is 2000
6634 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
6636 sc=$(($STRIPECOUNT - 1))
6638 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
6639 touch $DIR/$tdir/f4 $DIR/$tdir/f5
6640 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
6641 error "lverify failed"
6643 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
6646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6648 test_mkdir $DIR/$tdir
6650 $SETSTRIPE $DIR/$tdir || error "setstripe"
6651 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
6652 error "no stripe info failed"
6654 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
6656 run_test 65e "directory setstripe defaults"
6659 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6661 test_mkdir $DIR/${tdir}f
6662 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
6664 run_test 65f "dir setstripe permission (should return error) ==="
6667 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6669 test_mkdir $DIR/$tdir
6670 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6672 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6673 error "setstripe -S failed"
6674 $LFS setstripe -d $DIR/$tdir || error "setstripe -d failed"
6675 $LFS getstripe -v $DIR/$tdir | grep "Default" ||
6676 error "delete default stripe failed"
6678 run_test 65g "directory setstripe -d"
6681 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6683 test_mkdir $DIR/$tdir
6684 local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
6686 $LFS setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
6687 error "setstripe -S failed"
6688 test_mkdir $DIR/$tdir/dd1
6689 [ $($LFS getstripe -c $DIR/$tdir) = $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
6690 error "stripe info inherit failed"
6692 run_test 65h "directory stripe info inherit ===================="
6695 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6697 save_layout_restore_at_exit $MOUNT
6699 # bug6367: set non-default striping on root directory
6700 $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
6702 # bug12836: getstripe on -1 default directory striping
6703 $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
6705 # bug12836: getstripe -v on -1 default directory striping
6706 $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
6708 # bug12836: new find on -1 default directory striping
6709 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
6711 run_test 65i "various tests to set root directory striping"
6713 test_65j() { # bug6367
6714 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6718 # if we aren't already remounting for each test, do so for this test
6719 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
6720 cleanup || error "failed to unmount"
6724 save_layout_restore_at_exit $MOUNT
6726 $SETSTRIPE -d $MOUNT || error "setstripe failed"
6728 run_test 65j "set default striping on root directory (bug 6367)="
6732 wait_delete_completed
6733 do_facet $SINGLEMDS "lctl set_param -n \
6734 osp.$ost*MDT0000.max_create_count=$max_count"
6735 do_facet $SINGLEMDS "lctl set_param -n \
6736 osp.$ost*MDT0000.create_count=$count"
6737 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6738 echo $INACTIVE_OSC "is Activate"
6740 wait_osc_import_state mds ost$ostnum FULL
6743 test_65k() { # bug11679
6744 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6745 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
6746 remote_mds_nodsh && skip "remote MDS with nodsh"
6748 local disable_precreate=true
6749 [ $MDS1_VERSION -le $(version_code 2.8.54) ] &&
6750 disable_precreate=false
6752 echo "Check OST status: "
6753 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
6754 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
6756 for OSC in $MDS_OSCS; do
6757 echo $OSC "is active"
6758 do_facet $SINGLEMDS lctl --device %$OSC activate
6761 for INACTIVE_OSC in $MDS_OSCS; do
6762 local ost=$(osc_to_ost $INACTIVE_OSC)
6763 local ostnum=$(do_facet $SINGLEMDS lctl get_param -n \
6764 lov.*md*.target_obd |
6765 awk -F: /$ost/'{ print $1 }' | head -n 1)
6768 $SETSTRIPE -i $ostnum -c 1 $DIR/$tdir
6769 createmany -o $DIR/$tdir/$tfile.$ostnum. 1000
6771 echo "Deactivate: " $INACTIVE_OSC
6772 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
6774 local count=$(do_facet $SINGLEMDS "lctl get_param -n \
6775 osp.$ost*MDT0000.create_count")
6776 local max_count=$(do_facet $SINGLEMDS "lctl get_param -n \
6777 osp.$ost*MDT0000.max_create_count")
6778 $disable_precreate &&
6779 do_facet $SINGLEMDS "lctl set_param -n \
6780 osp.$ost*MDT0000.max_create_count=0"
6782 for idx in $(seq 0 $((OSTCOUNT - 1))); do
6783 [ -f $DIR/$tdir/$idx ] && continue
6784 echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
6785 $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
6787 error "setstripe $idx should succeed"; }
6788 rm -f $DIR/$tdir/$idx || error "rm $idx failed"
6790 unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
6793 do_facet $SINGLEMDS "lctl set_param -n \
6794 osp.$ost*MDT0000.max_create_count=$max_count"
6795 do_facet $SINGLEMDS "lctl set_param -n \
6796 osp.$ost*MDT0000.create_count=$count"
6797 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
6798 echo $INACTIVE_OSC "is Activate"
6800 wait_osc_import_state mds ost$ostnum FULL
6803 run_test 65k "validate manual striping works properly with deactivated OSCs"
6805 test_65l() { # bug 12836
6806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6808 test_mkdir -p $DIR/$tdir/test_dir
6809 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
6810 $LFS find -mtime -1 $DIR/$tdir >/dev/null
6812 run_test 65l "lfs find on -1 stripe dir ========================"
6815 local layout=$(save_layout $MOUNT)
6816 $RUNAS $SETSTRIPE -c 2 $MOUNT && {
6817 restore_layout $MOUNT $layout
6818 error "setstripe should fail by non-root users"
6822 run_test 65m "normal user can't set filesystem default stripe"
6825 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.12.0) ]] ||
6826 skip "Need MDS version at least 2.12.0"
6827 [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
6829 [[ $OSTCOUNT -ge 2 ]] || skip_env "needs >= 2 OSTs"
6830 which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
6831 which setfattr > /dev/null 2>&1 || skip_env "no setfattr command"
6833 local root_layout=$(save_layout $MOUNT)
6834 stack_trap "restore_layout $MOUNT $root_layout" EXIT
6836 # new subdirectory under root directory should not inherit
6837 # the default layout from root
6838 local dir1=$MOUNT/$tdir-1
6839 mkdir $dir1 || error "mkdir $dir1 failed"
6840 ! getfattr -n trusted.lov $dir1 &> /dev/null ||
6841 error "$dir1 shouldn't have LOV EA"
6843 # delete the default layout on root directory
6844 $LFS setstripe -d $MOUNT || error "delete root default layout failed"
6846 local dir2=$MOUNT/$tdir-2
6847 mkdir $dir2 || error "mkdir $dir2 failed"
6848 ! getfattr -n trusted.lov $dir2 &> /dev/null ||
6849 error "$dir2 shouldn't have LOV EA"
6851 # set a new striping pattern on root directory
6852 local def_stripe_size=$($LFS getstripe -S $MOUNT)
6853 local new_def_stripe_size=$((def_stripe_size * 2))
6854 $LFS setstripe -S $new_def_stripe_size $MOUNT ||
6855 error "set stripe size on $MOUNT failed"
6857 # new file created in $dir2 should inherit the new stripe size from
6858 # the filesystem default
6859 local file2=$dir2/$tfile-2
6860 touch $file2 || error "touch $file2 failed"
6862 local file2_stripe_size=$($LFS getstripe -S $file2)
6863 [[ $file2_stripe_size -eq $new_def_stripe_size ]] ||
6864 error "$file2 didn't inherit stripe size $new_def_stripe_size"
6866 local dir3=$MOUNT/$tdir-3
6867 mkdir $dir3 || error "mkdir $dir3 failed"
6868 ! getfattr -n trusted.lov $dir3 &> /dev/null ||
6869 error "$dir3 shouldn't have LOV EA"
6871 # set OST pool on root directory
6872 local pool=$TESTNAME
6873 pool_add $pool || error "add $pool failed"
6874 pool_add_targets $pool 0 $((OSTCOUNT - 1)) 1 ||
6875 error "add targets to $pool failed"
6877 $LFS setstripe -p $pool $MOUNT ||
6878 error "set OST pool on $MOUNT failed"
6880 # new file created in $dir3 should inherit the pool from
6881 # the filesystem default
6882 local file3=$dir3/$tfile-3
6883 touch $file3 || error "touch $file3 failed"
6885 local file3_pool=$($LFS getstripe -p $file3)
6886 [[ "$file3_pool" = "$pool" ]] ||
6887 error "$file3 didn't inherit OST pool $pool"
6889 local dir4=$MOUNT/$tdir-4
6890 mkdir $dir4 || error "mkdir $dir4 failed"
6891 ! getfattr -n trusted.lov $dir4 &> /dev/null ||
6892 error "$dir4 shouldn't have LOV EA"
6894 # new file created in $dir4 should inherit the pool from
6895 # the filesystem default
6896 local file4=$dir4/$tfile-4
6897 touch $file4 || error "touch $file4 failed"
6899 local file4_pool=$($LFS getstripe -p $file4)
6900 [[ "$file4_pool" = "$pool" ]] ||
6901 error "$file4 didn't inherit OST pool $pool"
6903 # new subdirectory under non-root directory should inherit
6904 # the default layout from its parent directory
6905 $LFS setstripe -S $new_def_stripe_size -p $pool $dir4 ||
6906 error "set directory layout on $dir4 failed"
6908 local dir5=$dir4/$tdir-5
6909 mkdir $dir5 || error "mkdir $dir5 failed"
6911 local dir4_layout=$(get_layout_param $dir4)
6912 local dir5_layout=$(get_layout_param $dir5)
6913 [[ "$dir4_layout" = "$dir5_layout" ]] ||
6914 error "$dir5 should inherit the default layout from $dir4"
6916 run_test 65n "don't inherit default layout from root for new subdirectories"
6918 # bug 2543 - update blocks count on client
6920 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6923 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
6924 sync; sync_all_data; sync; sync_all_data
6925 cancel_lru_locks osc
6926 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
6927 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
6929 run_test 66 "update inode blocks count on client ==============="
6932 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
6936 swapon -s | awk '($1 == "'$1'") { print $4 }'
6939 # bug5265, obdfilter oa2dentry return -ENOENT
6940 # #define OBD_FAIL_SRV_ENOENT 0x217
6942 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6943 remote_ost_nodsh && skip "remote OST with nodsh"
6946 $SETSTRIPE -c 1 -i 0 $f
6948 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
6950 do_facet ost1 lctl set_param fail_loc=0x217
6951 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
6952 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
6954 do_facet ost1 lctl set_param fail_loc=0
6955 $DIRECTIO write $f 0 2 || error "write error"
6957 cancel_lru_locks osc
6958 $DIRECTIO read $f 0 1 || error "read error"
6960 do_facet ost1 lctl set_param fail_loc=0x217
6961 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
6963 do_facet ost1 lctl set_param fail_loc=0
6966 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
6969 test_mkdir $DIR/$tdir
6970 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
6971 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
6973 run_test 71 "Running dbench on lustre (don't segment fault) ===="
6975 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
6976 [ $PARALLEL == "yes" ] && skip "skip parallel run"
6977 [ "$RUNAS_ID" = "$UID" ] &&
6978 skip_env "RUNAS_ID = UID = $UID -- skipping"
6979 # Check that testing environment is properly set up. Skip if not
6980 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
6981 skip_env "User $RUNAS_ID does not exist - skipping"
6984 chmod 777 $DIR/$tfile
6985 chmod ug+s $DIR/$tfile
6986 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
6987 error "$RUNAS dd $DIR/$tfile failed"
6988 # See if we are still setuid/sgid
6989 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6990 error "S/gid is not dropped on write"
6991 # Now test that MDS is updated too
6992 cancel_lru_locks mdc
6993 test -u $DIR/$tfile -o -g $DIR/$tfile &&
6994 error "S/gid is not dropped on MDS"
6997 run_test 72a "Test that remove suid works properly (bug5695) ===="
6999 test_72b() { # bug 24226 -- keep mode setting when size is not changing
7002 [ "$RUNAS_ID" = "$UID" ] &&
7003 skip_env "RUNAS_ID = UID = $UID -- skipping"
7004 [ "$RUNAS_ID" -eq 0 ] &&
7005 skip_env "RUNAS_ID = 0 -- skipping"
7006 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7007 # Check that testing environment is properly set up. Skip if not
7008 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
7009 skip_env "User $RUNAS_ID does not exist - skipping"
7011 touch $DIR/${tfile}-f{g,u}
7012 test_mkdir $DIR/${tfile}-dg
7013 test_mkdir $DIR/${tfile}-du
7014 chmod 770 $DIR/${tfile}-{f,d}{g,u}
7015 chmod g+s $DIR/${tfile}-{f,d}g
7016 chmod u+s $DIR/${tfile}-{f,d}u
7017 for perm in 777 2777 4777; do
7018 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
7019 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
7020 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
7021 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
7025 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
7027 # bug 3462 - multiple simultaneous MDC requests
7029 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7031 test_mkdir $DIR/d73-1
7032 test_mkdir $DIR/d73-2
7033 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
7036 lctl set_param fail_loc=0x80000129
7037 $MULTIOP $DIR/d73-1/f73-2 Oc &
7039 lctl set_param fail_loc=0
7041 $MULTIOP $DIR/d73-2/f73-3 Oc &
7045 wait $pid1 || return 1
7049 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
7050 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
7051 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
7055 run_test 73 "multiple MDC requests (should not deadlock)"
7057 test_74a() { # bug 6149, 6184
7058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7061 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7063 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7064 # will spin in a tight reconnection loop
7065 $LCTL set_param fail_loc=0x8000030e
7066 # get any lock that won't be difficult - lookup works.
7068 $LCTL set_param fail_loc=0
7072 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
7074 test_74b() { # bug 13310
7075 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7077 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
7079 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
7080 # will spin in a tight reconnection loop
7081 $LCTL set_param fail_loc=0x8000030e
7082 # get a "difficult" lock
7084 $LCTL set_param fail_loc=0
7088 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
7091 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7093 #define OBD_FAIL_LDLM_NEW_LOCK
7094 $LCTL set_param fail_loc=0x319
7095 touch $DIR/$tfile && error "touch successful"
7096 $LCTL set_param fail_loc=0
7099 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
7102 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
7105 test_76() { # Now for bug 20433, added originally in bug 1443
7106 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7108 local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
7110 cancel_lru_locks osc
7111 BEFORE_INODES=$(num_inodes)
7112 echo "before inodes: $BEFORE_INODES"
7114 [ "$SLOW" = "no" ] && COUNT=100
7115 for i in $(seq $COUNT); do
7119 cancel_lru_locks osc
7120 AFTER_INODES=$(num_inodes)
7121 echo "after inodes: $AFTER_INODES"
7123 while [[ $((AFTER_INODES-1*${CPUS:-1})) -gt $BEFORE_INODES ]]; do
7125 AFTER_INODES=$(num_inodes)
7127 echo "wait $wait seconds inodes: $AFTER_INODES"
7128 if [ $wait -gt 30 ]; then
7129 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
7133 run_test 76 "confirm clients recycle inodes properly ===="
7139 # Note: in sptlrpc modes which enable its own bulk checksum, the
7140 # original crc32_le bulk checksum will be automatically disabled,
7141 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
7142 # will be checked by sptlrpc code against sptlrpc bulk checksum.
7143 # In this case set_checksums() will not be no-op, because sptlrpc
7144 # bulk checksum will be enabled all through the test.
7146 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
7147 lctl set_param -n osc.*.checksums $1
7151 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7152 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
7153 CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
7154 tr -d [] | head -n1)}
7157 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
7158 log "set checksum type to $1"
7161 F77_TMP=$TMP/f77-temp
7164 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
7165 error "error writing to $F77_TMP"
7168 test_77a() { # bug 10889
7169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7170 $GSS && skip_env "could not run with gss"
7172 [ ! -f $F77_TMP ] && setup_f77
7174 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
7178 run_test 77a "normal checksum read/write operation"
7180 test_77b() { # bug 10889
7181 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7182 $GSS && skip_env "could not run with gss"
7184 [ ! -f $F77_TMP ] && setup_f77
7185 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7186 $LCTL set_param fail_loc=0x80000409
7189 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7190 error "dd error: $?"
7191 $LCTL set_param fail_loc=0
7193 for algo in $CKSUM_TYPES; do
7194 cancel_lru_locks osc
7195 set_checksum_type $algo
7196 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7197 $LCTL set_param fail_loc=0x80000408
7198 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
7199 $LCTL set_param fail_loc=0
7202 set_checksum_type $ORIG_CSUM_TYPE
7205 run_test 77b "checksum error on client write, read"
7210 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
7212 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
7213 [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
7214 $check_ost && [ -n "$ost_file_prefix" ] &&
7215 do_facet ost1 rm -f ${ost_file_prefix}\*
7219 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7220 $GSS && skip_env "could not run with gss"
7221 remote_ost_nodsh && skip "remote OST with nodsh"
7224 local osc_file_prefix
7226 local check_ost=false
7227 local ost_file_prefix
7233 # ensure corruption will occur on first OSS/OST
7234 $LFS setstripe -i 0 $DIR/$tfile
7236 [ ! -f $F77_TMP ] && setup_f77
7237 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
7238 error "dd write error: $?"
7239 fid=$($LFS path2fid $DIR/$tfile)
7241 if [ $OST1_VERSION -ge $(version_code 2.9.57) ]
7244 ost_file_prefix=$(do_facet ost1 $LCTL get_param -n debug_path)
7245 ost_file_prefix=${ost_file_prefix}-checksum_dump-ost-\\${fid}
7247 echo "OSS do not support bulk pages dump upon error"
7250 osc_file_prefix=$($LCTL get_param -n debug_path)
7251 osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
7253 trap cleanup_77c EXIT
7256 # enable bulk pages dump upon error on Client
7257 $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
7258 # enable bulk pages dump upon error on OSS
7260 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
7262 # flush Client cache to allow next read to reach OSS
7263 cancel_lru_locks osc
7265 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7266 $LCTL set_param fail_loc=0x80000408
7267 dd if=$DIR/$tfile of=/dev/null bs=1M || error "dd read error: $?"
7268 $LCTL set_param fail_loc=0
7272 # check cksum dump on Client
7273 osc_file=$(ls ${osc_file_prefix}*)
7274 [ -n "$osc_file" ] || error "no checksum dump file on Client"
7275 # OBD_FAIL_OSC_CHECKSUM_RECEIVE corrupts with "bad1" at start of file
7276 bad1=$(dd if=$osc_file bs=1 count=4 2>/dev/null) || error "dd error: $?"
7277 [ $bad1 == "bad1" ] || error "unexpected corrupt pattern"
7278 orig_cksum=$(dd if=$F77_TMP bs=1 skip=4 count=1048572 2>/dev/null |
7280 dump_cksum=$(dd if=$osc_file bs=1 skip=4 2>/dev/null | cksum)
7281 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7282 error "dump content does not match on Client"
7284 $check_ost || skip "No need to check cksum dump on OSS"
7286 # check cksum dump on OSS
7287 ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
7288 [ -n "$ost_file" ] || error "no checksum dump file on OSS"
7289 orig_cksum=$(dd if=$F77_TMP bs=1048576 count=1 2>/dev/null | cksum)
7290 dump_cksum=$(do_facet ost1 dd if=$ost_file 2>/dev/null \| cksum)
7291 [[ "$orig_cksum" == "$dump_cksum" ]] ||
7292 error "dump content does not match on OSS"
7296 run_test 77c "checksum error on client read with debug"
7298 test_77d() { # bug 10889
7299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7300 $GSS && skip_env "could not run with gss"
7302 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7303 $LCTL set_param fail_loc=0x80000409
7305 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7306 error "direct write: rc=$?"
7307 $LCTL set_param fail_loc=0
7310 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
7311 $LCTL set_param fail_loc=0x80000408
7313 cancel_lru_locks osc
7314 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
7315 error "direct read: rc=$?"
7316 $LCTL set_param fail_loc=0
7319 run_test 77d "checksum error on OST direct write, read"
7321 test_77f() { # bug 10889
7322 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7323 $GSS && skip_env "could not run with gss"
7326 for algo in $CKSUM_TYPES; do
7327 cancel_lru_locks osc
7328 set_checksum_type $algo
7329 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
7330 $LCTL set_param fail_loc=0x409
7331 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
7332 error "direct write succeeded"
7333 $LCTL set_param fail_loc=0
7335 set_checksum_type $ORIG_CSUM_TYPE
7338 run_test 77f "repeat checksum error on write (expect error)"
7340 test_77g() { # bug 10889
7341 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7342 $GSS && skip_env "could not run with gss"
7343 remote_ost_nodsh && skip "remote OST with nodsh"
7345 [ ! -f $F77_TMP ] && setup_f77
7347 local file=$DIR/$tfile
7348 stack_trap "rm -f $file" EXIT
7350 $SETSTRIPE -c 1 -i 0 $file
7351 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
7352 do_facet ost1 lctl set_param fail_loc=0x8000021a
7354 dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
7355 error "write error: rc=$?"
7356 do_facet ost1 lctl set_param fail_loc=0
7359 cancel_lru_locks osc
7360 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
7361 do_facet ost1 lctl set_param fail_loc=0x8000021b
7363 cmp $F77_TMP $file || error "file compare failed"
7364 do_facet ost1 lctl set_param fail_loc=0
7367 run_test 77g "checksum error on OST write, read"
7369 test_77k() { # LU-10906
7370 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7371 $GSS && skip_env "could not run with gss"
7373 local cksum_param="osc.$FSNAME*.checksums"
7374 local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
7378 [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
7379 stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
7380 stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
7384 do_facet mgs $LCTL set_param -P $cksum_param=$i ||
7385 error "failed to set checksum=$i on MGS"
7386 wait_update $HOSTNAME "$get_checksum" $i
7388 echo "remount client, checksum should be $i"
7389 remount_client $MOUNT || "failed to remount client"
7390 checksum=$(eval $get_checksum)
7391 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7394 for opt in "checksum" "nochecksum"; do
7395 #remount with mount option
7396 echo "remount client with option $opt, checksum should be $i"
7397 umount_client $MOUNT || "failed to umount client"
7398 mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
7399 "failed to mount client with option '$opt'"
7400 checksum=$(eval $get_checksum)
7401 [ $checksum -eq $i ] || error "checksum($checksum) != $i"
7405 remount_client $MOUNT || "failed to remount client"
7407 run_test 77k "enable/disable checksum correctly"
7409 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
7418 test_78() { # bug 10901
7419 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7420 remote_ost || skip_env "local OST"
7423 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
7424 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
7425 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
7426 echo "MemTotal: $MEMTOTAL"
7428 # reserve 256MB of memory for the kernel and other running processes,
7429 # and then take 1/2 of the remaining memory for the read/write buffers.
7430 if [ $MEMTOTAL -gt 512 ] ;then
7431 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
7433 # for those poor memory-starved high-end clusters...
7434 MEMTOTAL=$((MEMTOTAL / 2))
7436 echo "Mem to use for directio: $MEMTOTAL"
7438 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
7439 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
7440 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
7441 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
7443 echo "Smallest OST: $SMALLESTOST"
7444 [[ $SMALLESTOST -lt 10240 ]] &&
7445 skip "too small OSTSIZE, useless to run large O_DIRECT test"
7447 trap cleanup_test_78 EXIT
7449 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
7450 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
7452 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
7453 echo "File size: $F78SIZE"
7454 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
7455 for i in $(seq 1 $NSEQ); do
7456 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
7457 echo directIO rdwr round $i of $NSEQ
7458 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
7463 run_test 78 "handle large O_DIRECT writes correctly ============"
7465 test_79() { # bug 12743
7466 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7468 wait_delete_completed
7470 BKTOTAL=$(calc_osc_kbytes kbytestotal)
7471 BKFREE=$(calc_osc_kbytes kbytesfree)
7472 BKAVAIL=$(calc_osc_kbytes kbytesavail)
7474 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
7475 DFTOTAL=`echo $STRING | cut -d, -f1`
7476 DFUSED=`echo $STRING | cut -d, -f2`
7477 DFAVAIL=`echo $STRING | cut -d, -f3`
7478 DFFREE=$(($DFTOTAL - $DFUSED))
7480 ALLOWANCE=$((64 * $OSTCOUNT))
7482 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
7483 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
7484 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
7486 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
7487 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
7488 error "df free($DFFREE) mismatch OST free($BKFREE)"
7490 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
7491 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
7492 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
7495 run_test 79 "df report consistency check ======================="
7497 test_80() { # bug 10718
7498 remote_ost_nodsh && skip "remote OST with nodsh"
7499 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7501 # relax strong synchronous semantics for slow backends like ZFS
7502 local soc="obdfilter.*.sync_on_lock_cancel"
7503 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
7505 if [ "$soc_old" != "never" ] &&
7506 [ "$ost1_FSTYPE" != "ldiskfs" ]; then
7507 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
7508 facet_active_host $host; done | sort -u)
7509 do_nodes $hosts lctl set_param $soc=never
7512 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
7514 local BEFORE=`date +%s`
7515 cancel_lru_locks osc
7516 local AFTER=`date +%s`
7517 local DIFF=$((AFTER-BEFORE))
7518 if [ $DIFF -gt 1 ] ; then
7519 error "elapsed for 1M@1T = $DIFF"
7522 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
7526 run_test 80 "Page eviction is equally fast at high offsets too ===="
7528 test_81a() { # LU-456
7529 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7530 remote_ost_nodsh && skip "remote OST with nodsh"
7532 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7533 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
7534 do_facet ost1 lctl set_param fail_loc=0x80000228
7536 # write should trigger a retry and success
7537 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7538 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7540 if [ $RC -ne 0 ] ; then
7541 error "write should success, but failed for $RC"
7544 run_test 81a "OST should retry write when get -ENOSPC ==============="
7546 test_81b() { # LU-456
7547 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7548 remote_ost_nodsh && skip "remote OST with nodsh"
7550 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
7551 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
7552 do_facet ost1 lctl set_param fail_loc=0x228
7554 # write should retry several times and return -ENOSPC finally
7555 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
7556 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7559 if [ $RC -ne $ENOSPC ] ; then
7560 error "dd should fail for -ENOSPC, but succeed."
7563 run_test 81b "OST should return -ENOSPC when retry still fails ======="
7565 test_82() { # LU-1031
7566 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
7570 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
7572 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
7574 kill -USR1 $MULTIPID2
7576 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
7577 error "First grouplock does not block second one"
7579 echo "Second grouplock blocks first one"
7581 kill -USR1 $MULTIPID1
7585 run_test 82 "Basic grouplock test"
7588 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
7590 test_mkdir $DIR/$tdir.cvsroot
7591 chown $RUNAS_ID $DIR/$tdir.cvsroot
7594 $RUNAS cvs -d $DIR/$tdir.cvsroot init || error "cvs init failed"
7597 # some versions of cvs import exit(1) when asked to import links or
7598 # files they can't read. ignore those files.
7599 local toignore=$(find . -type l -printf '-I %f\n' -o \
7600 ! -perm /4 -printf '-I %f\n')
7601 $RUNAS cvs -d $DIR/$tdir.cvsroot import -m "nomesg" $toignore \
7602 $tdir.reposname vtag rtag
7605 test_mkdir $DIR/$tdir.reposname
7606 chown $RUNAS_ID $DIR/$tdir.reposname
7607 $RUNAS cvs -d $DIR/$tdir.cvsroot co $tdir.reposname
7609 cd $DIR/$tdir.reposname
7611 $RUNAS cvs add -m 'addmsg' foo99
7613 $RUNAS cvs commit -m 'nomsg' foo99
7614 rm -fr $DIR/$tdir.cvsroot
7616 run_test 99 "cvs strange file/directory operations"
7619 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7620 [[ "$NETTYPE" =~ tcp ]] ||
7621 skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
7622 remote_ost_nodsh && skip "remote OST with nodsh"
7623 remote_mds_nodsh && skip "remote MDS with nodsh"
7625 skip "useless for local single node setup"
7627 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
7628 [ "$PROT" != "tcp" ] && continue
7629 RPORT=$(echo $REMOTE | cut -d: -f2)
7630 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
7633 LPORT=`echo $LOCAL | cut -d: -f2`
7634 if [ $LPORT -ge 1024 ]; then
7635 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
7637 error_exit "local: $LPORT > 1024, remote: $RPORT"
7640 [ "$rc" = 0 ] || error_exit "privileged port not found" )
7642 run_test 100 "check local port using privileged port ==========="
7644 function get_named_value()
7653 echo $line | sed "s/^$tag[ ]*//"
7660 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
7661 awk '/^max_cached_mb/ { print $2 }')
7664 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
7669 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7670 [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
7675 local cache_limit=32
7677 $LCTL set_param -n osc.*-osc*.rpc_stats 0
7678 trap cleanup_101a EXIT
7679 $LCTL set_param -n llite.*.read_ahead_stats 0
7680 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
7683 # randomly read 10000 of 64K chunks from file 3x 32MB in size
7685 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
7686 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
7689 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
7690 get_named_value 'read but discarded' | cut -d" " -f1); do
7691 discard=$(($discard + $s))
7695 if [[ $(($discard * 10)) -gt $nreads ]]; then
7696 $LCTL get_param osc.*-osc*.rpc_stats
7697 $LCTL get_param llite.*.read_ahead_stats
7698 error "too many ($discard) discarded pages"
7700 rm -f $DIR/$tfile || true
7702 run_test 101a "check read-ahead for random reads"
7705 test_mkdir $DIR/$tdir
7706 local STRIPE_SIZE=$1
7707 local FILE_LENGTH=$2
7710 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
7712 local list=$(comma_list $(osts_nodes))
7713 set_osd_param $list '' read_cache_enable 0
7714 set_osd_param $list '' writethrough_cache_enable 0
7716 trap cleanup_test101bc EXIT
7717 # prepare the read-ahead file
7718 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
7720 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
7721 count=$FILE_SIZE_MB 2> /dev/null
7725 cleanup_test101bc() {
7730 local list=$(comma_list $(osts_nodes))
7731 set_osd_param $list '' read_cache_enable 1
7732 set_osd_param $list '' writethrough_cache_enable 1
7736 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
7741 local STRIPE_SIZE=$2
7742 local FILE_LENGTH=$3
7743 local RA_INC=1048576
7744 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
7745 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
7746 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
7747 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
7748 get_named_value 'read but discarded' |
7749 cut -d" " -f1 | calc_total)
7750 if [[ $DISCARD -gt $discard_limit ]]; then
7751 $LCTL get_param llite.*.read_ahead_stats
7752 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
7754 echo "Read-ahead success for size ${READ_SIZE}"
7759 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7760 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
7762 local STRIPE_SIZE=1048576
7763 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
7765 if [ $SLOW == "yes" ]; then
7766 local FILE_LENGTH=$((STRIDE_SIZE * 64))
7768 local FILE_LENGTH=$((STRIDE_SIZE * 8))
7771 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
7773 # prepare the read-ahead file
7774 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7775 cancel_lru_locks osc
7776 for BIDX in 2 4 8 16 32 64 128 256
7778 local BSIZE=$((BIDX*4096))
7779 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
7780 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
7781 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
7782 $LCTL set_param -n llite.*.read_ahead_stats 0
7783 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
7784 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
7785 cancel_lru_locks osc
7786 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
7791 run_test 101b "check stride-io mode read-ahead ================="
7794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7796 local STRIPE_SIZE=1048576
7797 local FILE_LENGTH=$((STRIPE_SIZE*100))
7801 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
7803 cancel_lru_locks osc
7804 $LCTL set_param osc.*.rpc_stats 0
7805 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
7806 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
7807 local stats=$($LCTL get_param -n $osc_rpc_stats)
7808 local lines=$(echo "$stats" | awk 'END {print NR;}')
7811 if [ $lines -le 20 ]; then
7814 for size in 1 2 4 8; do
7815 local rpc=$(echo "$stats" |
7816 awk '($1 == "'$size':") {print $2; exit; }')
7818 error "Small $((size*4))k read IO $rpc !"
7820 echo "$osc_rpc_stats check passed!"
7825 run_test 101c "check stripe_size aligned read-ahead ================="
7828 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
7829 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
7833 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7835 local file=$DIR/$tfile
7836 local sz_MB=${FILESIZE_101d:-500}
7837 local ra_MB=${READAHEAD_MB:-40}
7839 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
7840 [ $free_MB -lt $sz_MB ] &&
7841 skip "Need free space ${sz_MB}M, have ${free_MB}M"
7843 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
7844 $SETSTRIPE -c -1 $file || error "setstripe failed"
7846 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
7847 echo Cancel LRU locks on lustre client to flush the client cache
7848 cancel_lru_locks osc
7850 echo Disable read-ahead
7851 local old_READAHEAD=$(set_read_ahead 0)
7853 echo Reading the test file $file with read-ahead disabled
7854 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7856 echo Cancel LRU locks on lustre client to flush the client cache
7857 cancel_lru_locks osc
7858 echo Enable read-ahead with ${ra_MB}MB
7859 set_read_ahead $ra_MB
7861 echo Reading the test file $file with read-ahead enabled
7862 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
7864 echo "read-ahead disabled time read $raOFF"
7865 echo "read-ahead enabled time read $raON"
7867 set_read_ahead $old_READAHEAD
7869 wait_delete_completed
7871 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
7872 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
7874 run_test 101d "file read with and without read-ahead enabled"
7877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
7879 local file=$DIR/$tfile
7880 local size_KB=500 #KB
7884 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
7885 local need_KB=$((count * size_KB))
7886 [[ $free_KB -le $need_KB ]] &&
7887 skip_env "Need free space $need_KB, have $free_KB"
7889 echo "Creating $count ${size_KB}K test files"
7890 for ((i = 0; i < $count; i++)); do
7891 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
7894 echo "Cancel LRU locks on lustre client to flush the client cache"
7895 cancel_lru_locks $OSC
7897 echo "Reset readahead stats"
7898 $LCTL set_param -n llite.*.read_ahead_stats 0
7900 for ((i = 0; i < $count; i++)); do
7901 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
7904 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7905 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7907 for ((i = 0; i < $count; i++)); do
7908 rm -rf $file.$i 2>/dev/null
7911 #10000 means 20% reads are missing in readahead
7912 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
7914 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
7917 which iozone || skip_env "no iozone installed"
7919 local old_debug=$($LCTL get_param debug)
7920 old_debug=${old_debug#*=}
7921 $LCTL set_param debug="reada mmap"
7923 # create a test file
7924 iozone -i 0 -+n -r 1m -s 128m -w -f $DIR/$tfile > /dev/null 2>&1
7926 echo Cancel LRU locks on lustre client to flush the client cache
7927 cancel_lru_locks osc
7929 echo Reset readahead stats
7930 $LCTL set_param -n llite.*.read_ahead_stats 0
7932 echo mmap read the file with small block size
7933 iozone -i 1 -u 1 -l 1 -+n -r 32k -s 128m -B -f $DIR/$tfile \
7936 echo checking missing pages
7937 $LCTL get_param llite.*.read_ahead_stats
7938 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
7939 get_named_value 'misses' | cut -d" " -f1 | calc_total)
7941 $LCTL set_param debug="$old_debug"
7942 [ $miss -lt 3 ] || error "misses too much pages ('$miss')!"
7945 run_test 101f "check mmap read performance"
7947 test_101g_brw_size_test() {
7949 local pages=$((mb * 1048576 / PAGE_SIZE))
7950 local file=$DIR/$tfile
7952 $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
7953 { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
7954 for mp in $($LCTL get_param -n osc.*.max_pages_per_rpc); do
7955 [ $mp -ne $pages ] && error "max_pages_per_rpc $mp != $pages" &&
7959 stack_trap "rm -f $file" EXIT
7960 $LCTL set_param -n osc.*.rpc_stats=0
7962 # 10 RPCs should be enough for the test
7964 dd if=/dev/zero of=$file bs=${mb}M count=$count ||
7965 { error "dd write ${mb} MB blocks failed"; return 3; }
7966 cancel_lru_locks osc
7967 dd of=/dev/null if=$file bs=${mb}M count=$count ||
7968 { error "dd write ${mb} MB blocks failed"; return 4; }
7970 # calculate number of full-sized read and write RPCs
7971 rpcs=($($LCTL get_param -n 'osc.*.rpc_stats' |
7972 sed -n '/pages per rpc/,/^$/p' |
7973 awk '/'$pages':/ { reads += $2; writes += $6 }; \
7974 END { print reads,writes }'))
7975 [ ${rpcs[0]} -ne $count ] && error "${rpcs[0]} != $count read RPCs" &&
7977 [ ${rpcs[1]} -ne $count ] && error "${rpcs[1]} != $count write RPCs" &&
7984 remote_ost_nodsh && skip "remote OST with nodsh"
7987 local osts=$(get_facets OST)
7988 local list=$(comma_list $(osts_nodes))
7989 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
7990 local brw_size="obdfilter.*.brw_size"
7992 $LFS setstripe -i 0 -c 1 $DIR/$tfile
7994 local orig_mb=$(do_facet ost1 $LCTL get_param -n $brw_size | head -n 1)
7995 if [ $OST1_VERSION -ge $(version_code 2.8.52) -o \
7996 \( $OST1_VERSION -ge $(version_code 2.7.17) -a \
7997 $OST1_VERSION -lt $(version_code 2.7.50) \) ] &&
7998 [ $CLIENT_VERSION -ge $(version_code 2.8.52) -o \
7999 \( $CLIENT_VERSION -ge $(version_code 2.7.17) -a \
8000 $CLIENT_VERSION -lt $(version_code 2.7.50) \) ]; then
8001 [ $OST1_VERSION -ge $(version_code 2.9.52) ] && suffix="M"
8002 if [[ $orig_mb -lt 16 ]]; then
8003 save_lustre_params $osts "$brw_size" > $p
8004 do_nodes $list $LCTL set_param -n $brw_size=16$suffix ||
8005 error "set 16MB RPC size failed"
8007 echo "remount client to enable new RPC size"
8008 remount_client $MOUNT || error "remount_client failed"
8011 test_101g_brw_size_test 16 || error "16MB RPC test failed"
8012 # should be able to set brw_size=12, but no rpc_stats for that
8013 test_101g_brw_size_test 8 || error "8MB RPC test failed"
8016 test_101g_brw_size_test 4 || error "4MB RPC test failed"
8018 if [[ $orig_mb -lt 16 ]]; then
8019 restore_lustre_params < $p
8020 remount_client $MOUNT || error "remount_client restore failed"
8023 rm -f $p $DIR/$tfile
8025 run_test 101g "Big bulk(4/16 MiB) readahead"
8028 test_mkdir $DIR/$tdir
8029 chown $RUNAS_ID $DIR/$tdir
8032 STRIPE_COUNT=$OSTCOUNT
8033 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
8035 trap cleanup_test102 EXIT
8037 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
8039 for num in 1 2 3 4; do
8040 for count in $(seq 1 $STRIPE_COUNT); do
8041 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
8042 local size=`expr $STRIPE_SIZE \* $num`
8043 local file=file"$num-$idx-$count"
8044 $1 $SETSTRIPE -S $size -i $idx -c $count $file
8050 $1 tar cf $TMP/f102.tar $tdir --xattrs
8056 rm -rf $DIR/d0.sanity/d102
8060 [ "$UID" != 0 ] && skip "must run as root"
8061 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
8062 skip_env "must have user_xattr"
8064 [ -z "$(which setfattr 2>/dev/null)" ] &&
8065 skip_env "could not find setfattr"
8067 local testfile=$DIR/$tfile
8070 echo "set/get xattr..."
8071 setfattr -n trusted.name1 -v value1 $testfile ||
8072 error "setfattr -n trusted.name1=value1 $testfile failed"
8073 getfattr -n trusted.name1 $testfile 2> /dev/null |
8074 grep "trusted.name1=.value1" ||
8075 error "$testfile missing trusted.name1=value1"
8077 setfattr -n user.author1 -v author1 $testfile ||
8078 error "setfattr -n user.author1=author1 $testfile failed"
8079 getfattr -n user.author1 $testfile 2> /dev/null |
8080 grep "user.author1=.author1" ||
8081 error "$testfile missing trusted.author1=author1"
8084 setfattr -n trusted.name2 -v value2 $testfile ||
8085 error "$testfile unable to set trusted.name2"
8086 setfattr -n trusted.name3 -v value3 $testfile ||
8087 error "$testfile unable to set trusted.name3"
8088 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
8089 grep "trusted.name" | wc -l) -eq 3 ] ||
8090 error "$testfile missing 3 trusted.name xattrs"
8092 setfattr -n user.author2 -v author2 $testfile ||
8093 error "$testfile unable to set user.author2"
8094 setfattr -n user.author3 -v author3 $testfile ||
8095 error "$testfile unable to set user.author3"
8096 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
8097 grep "user.author" | wc -l) -eq 3 ] ||
8098 error "$testfile missing 3 user.author xattrs"
8100 echo "remove xattr..."
8101 setfattr -x trusted.name1 $testfile ||
8102 error "$testfile error deleting trusted.name1"
8103 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
8104 error "$testfile did not delete trusted.name1 xattr"
8106 setfattr -x user.author1 $testfile ||
8107 error "$testfile error deleting user.author1"
8108 echo "set lustre special xattr ..."
8109 $LFS setstripe -c1 $testfile
8110 local lovea=$(getfattr -n "trusted.lov" -e hex $testfile |
8111 awk -F "=" '/trusted.lov/ { print $2 }' )
8112 setfattr -n "trusted.lov" -v $lovea $testfile ||
8113 error "$testfile doesn't ignore setting trusted.lov again"
8114 setfattr -n "trusted.lov" -v "invalid_value" $testfile &&
8115 error "$testfile allow setting invalid trusted.lov"
8118 run_test 102a "user xattr test =================================="
8121 [ -z "$(which setfattr 2>/dev/null)" ] &&
8122 skip_env "could not find setfattr"
8123 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8125 # b10930: get/set/list trusted.lov xattr
8126 echo "get/set/list trusted.lov xattr ..."
8127 local testfile=$DIR/$tfile
8128 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8129 error "setstripe failed"
8130 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
8131 error "getstripe failed"
8132 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
8133 error "can't get trusted.lov from $testfile"
8135 local testfile2=${testfile}2
8136 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
8137 grep "trusted.lov" | sed -e 's/[^=]\+=//')
8140 setfattr -n trusted.lov -v $value $testfile2
8141 local stripe_size=$($GETSTRIPE -S $testfile2)
8142 local stripe_count=$($GETSTRIPE -c $testfile2)
8143 [[ $stripe_size -eq 65536 ]] ||
8144 error "stripe size $stripe_size != 65536"
8145 [[ $stripe_count -eq $STRIPECOUNT ]] ||
8146 error "stripe count $stripe_count != $STRIPECOUNT"
8149 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
8152 [ -z "$(which setfattr 2>/dev/null)" ] &&
8153 skip_env "could not find setfattr"
8154 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8156 # b10930: get/set/list lustre.lov xattr
8157 echo "get/set/list lustre.lov xattr ..."
8158 test_mkdir $DIR/$tdir
8159 chown $RUNAS_ID $DIR/$tdir
8160 local testfile=$DIR/$tdir/$tfile
8161 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
8162 error "setstripe failed"
8163 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
8164 error "getstripe failed"
8165 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
8166 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
8168 local testfile2=${testfile}2
8169 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
8170 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
8172 $RUNAS $MCREATE $testfile2
8173 $RUNAS setfattr -n lustre.lov -v $value $testfile2
8174 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
8175 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
8176 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
8177 [ $stripe_count -eq $STRIPECOUNT ] ||
8178 error "stripe count $stripe_count != $STRIPECOUNT"
8180 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
8182 compare_stripe_info1() {
8183 local stripe_index_all_zero=true
8185 for num in 1 2 3 4; do
8186 for count in $(seq 1 $STRIPE_COUNT); do
8187 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
8188 local size=$((STRIPE_SIZE * num))
8189 local file=file"$num-$offset-$count"
8190 stripe_size=$($LFS getstripe -S $PWD/$file)
8191 [[ $stripe_size -ne $size ]] &&
8192 error "$file: size $stripe_size != $size"
8193 stripe_count=$($LFS getstripe -c $PWD/$file)
8194 # allow fewer stripes to be created, ORI-601
8195 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
8196 error "$file: count $stripe_count != $count"
8197 stripe_index=$($LFS getstripe -i $PWD/$file)
8198 [[ $stripe_index -ne 0 ]] &&
8199 stripe_index_all_zero=false
8203 $stripe_index_all_zero &&
8204 error "all files are being extracted starting from OST index 0"
8208 have_xattrs_include() {
8209 tar --help | grep -q xattrs-include &&
8210 echo --xattrs-include="lustre.*"
8214 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8215 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8217 XINC=$(have_xattrs_include)
8219 tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8221 compare_stripe_info1
8223 run_test 102d "tar restore stripe info from tarfile,not keep osts"
8226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8227 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8229 XINC=$(have_xattrs_include)
8231 test_mkdir $DIR/$tdir.restore
8233 tar cf - --xattrs $tdir | tar xf - \
8234 -C $DIR/$tdir.restore --xattrs $XINC
8235 cd $DIR/$tdir.restore/$tdir
8236 compare_stripe_info1
8238 run_test 102f "tar copy files, not keep osts"
8241 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
8242 skip "must have user_xattr"
8243 [ -z "$(which setfattr 2>/dev/null)" ] &&
8244 skip_env "could not find setfattr"
8245 [ -z "$(which getfattr 2>/dev/null)" ] &&
8246 skip_env "could not find getfattr"
8248 local xsize=${1:-1024} # in bytes
8249 local file=$DIR/$tfile
8250 local value="$(generate_string $xsize)"
8251 local xbig=trusted.big
8254 log "save $xbig on $file"
8255 setfattr -n $xbig -v $value $file ||
8256 error "saving $xbig on $file failed"
8258 local orig=$(get_xattr_value $xbig $file)
8259 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
8261 local xsml=trusted.sml
8262 log "save $xsml on $file"
8263 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
8265 local new=$(get_xattr_value $xbig $file)
8266 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
8268 log "grow $xsml on $file"
8269 setfattr -n $xsml -v "$value" $file ||
8270 error "growing $xsml on $file failed"
8272 new=$(get_xattr_value $xbig $file)
8273 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
8274 log "$xbig still valid after growing $xsml"
8279 test_102h() { # bug 15777
8282 run_test 102h "grow xattr from inside inode to external block"
8285 large_xattr_enabled || skip_env "ea_inode feature disabled"
8287 grow_xattr $(max_xattr_size)
8289 run_test 102ha "grow xattr from inside inode to external inode"
8291 test_102i() { # bug 17038
8292 [ -z "$(which getfattr 2>/dev/null)" ] &&
8293 skip "could not find getfattr"
8296 ln -s $DIR/$tfile $DIR/${tfile}link
8297 getfattr -n trusted.lov $DIR/$tfile ||
8298 error "lgetxattr on $DIR/$tfile failed"
8299 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
8300 grep -i "no such attr" ||
8301 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
8302 rm -f $DIR/$tfile $DIR/${tfile}link
8304 run_test 102i "lgetxattr test on symbolic link ============"
8307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8308 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8310 XINC=$(have_xattrs_include)
8311 setup_test102 "$RUNAS"
8312 chown $RUNAS_ID $DIR/$tdir
8313 $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
8315 compare_stripe_info1 "$RUNAS"
8317 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
8320 [ -z "$(which setfattr 2>/dev/null)" ] &&
8321 skip "could not find setfattr"
8324 # b22187 just check that does not crash for regular file.
8325 setfattr -n trusted.lov $DIR/$tfile
8326 # b22187 'setfattr -n trusted.lov' should remove LOV EA for directories
8327 local test_kdir=$DIR/$tdir
8328 test_mkdir $test_kdir
8329 local default_size=$($LFS getstripe -S $test_kdir)
8330 local default_count=$($LFS getstripe -c $test_kdir)
8331 local default_offset=$($LFS getstripe -i $test_kdir)
8332 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
8333 error 'dir setstripe failed'
8334 setfattr -n trusted.lov $test_kdir
8335 local stripe_size=$($LFS getstripe -S $test_kdir)
8336 local stripe_count=$($LFS getstripe -c $test_kdir)
8337 local stripe_offset=$($LFS getstripe -i $test_kdir)
8338 [ $stripe_size -eq $default_size ] ||
8339 error "stripe size $stripe_size != $default_size"
8340 [ $stripe_count -eq $default_count ] ||
8341 error "stripe count $stripe_count != $default_count"
8342 [ $stripe_offset -eq $default_offset ] ||
8343 error "stripe offset $stripe_offset != $default_offset"
8344 rm -rf $DIR/$tfile $test_kdir
8346 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
8349 [ -z "$(which getfattr 2>/dev/null)" ] &&
8350 skip "could not find getfattr"
8352 # LU-532 trusted. xattr is invisible to non-root
8353 local testfile=$DIR/$tfile
8357 echo "listxattr as user..."
8358 chown $RUNAS_ID $testfile
8359 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
8360 grep -q "trusted" &&
8361 error "$testfile trusted xattrs are user visible"
8365 run_test 102l "listxattr size test =================================="
8367 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
8368 local path=$DIR/$tfile
8371 listxattr_size_check $path || error "listattr_size_check $path failed"
8373 run_test 102m "Ensure listxattr fails on small bufffer ========"
8377 getxattr() { # getxattr path name
8378 # Return the base64 encoding of the value of xattr name on path.
8382 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
8384 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8386 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
8388 getfattr --absolute-names --encoding=base64 --name=$name $path |
8389 awk -F= -v name=$name '$1 == name {
8390 print substr($0, index($0, "=") + 1);
8394 test_102n() { # LU-4101 mdt: protect internal xattrs
8395 [ -z "$(which setfattr 2>/dev/null)" ] &&
8396 skip "could not find setfattr"
8397 if [ $MDS1_VERSION -lt $(version_code 2.5.50) ]
8399 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
8402 local file0=$DIR/$tfile.0
8403 local file1=$DIR/$tfile.1
8404 local xattr0=$TMP/$tfile.0
8405 local xattr1=$TMP/$tfile.1
8406 local namelist="lov lma lmv link fid version som hsm"
8410 rm -rf $file0 $file1 $xattr0 $xattr1
8413 # Get 'before' xattrs of $file1.
8414 getfattr --absolute-names --dump --match=- $file1 > $xattr0
8416 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
8417 namelist+=" lfsck_namespace"
8418 for name in $namelist; do
8419 # Try to copy xattr from $file0 to $file1.
8420 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8422 setfattr --name=trusted.$name --value="$value" $file1 ||
8423 error "setxattr 'trusted.$name' failed"
8425 # Try to set a garbage xattr.
8426 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8428 if [[ x$name == "xlov" ]]; then
8429 setfattr --name=trusted.lov --value="$value" $file1 &&
8430 error "setxattr invalid 'trusted.lov' success"
8432 setfattr --name=trusted.$name --value="$value" $file1 ||
8433 error "setxattr invalid 'trusted.$name' failed"
8436 # Try to remove the xattr from $file1. We don't care if this
8437 # appears to succeed or fail, we just don't want there to be
8438 # any changes or crashes.
8439 setfattr --remove=$trusted.$name $file1 2> /dev/null
8442 if [ $MDS1_VERSION -gt $(version_code 2.6.50) ]
8445 # Try to copy xattr from $file0 to $file1.
8446 value=$(getxattr $file0 trusted.$name 2> /dev/null)
8448 setfattr --name=trusted.$name --value="$value" $file1 ||
8449 error "setxattr 'trusted.$name' failed"
8451 # Try to set a garbage xattr.
8452 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
8454 setfattr --name=trusted.$name --value="$value" $file1 ||
8455 error "setxattr 'trusted.$name' failed"
8457 # Try to remove the xattr from $file1. We don't care if this
8458 # appears to succeed or fail, we just don't want there to be
8459 # any changes or crashes.
8460 setfattr --remove=$trusted.$name $file1 2> /dev/null
8463 # Get 'after' xattrs of file1.
8464 getfattr --absolute-names --dump --match=- $file1 > $xattr1
8466 if ! diff $xattr0 $xattr1; then
8467 error "before and after xattrs of '$file1' differ"
8470 rm -rf $file0 $file1 $xattr0 $xattr1
8474 run_test 102n "silently ignore setxattr on internal trusted xattrs"
8476 test_102p() { # LU-4703 setxattr did not check ownership
8477 [ $MDS1_VERSION -lt $(version_code 2.5.56) ] &&
8478 skip "MDS needs to be at least 2.5.56"
8480 local testfile=$DIR/$tfile
8484 echo "setfacl as user..."
8485 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
8486 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
8488 echo "setfattr as user..."
8489 setfacl -m "u:$RUNAS_ID:---" $testfile
8490 $RUNAS setfattr -x system.posix_acl_access $testfile
8491 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
8493 run_test 102p "check setxattr(2) correctly fails without permission"
8496 [ $MDS1_VERSION -lt $(version_code 2.6.92) ] &&
8497 skip "MDS needs to be at least 2.6.92"
8499 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
8501 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
8504 [ $MDS1_VERSION -lt $(version_code 2.6.93) ] &&
8505 skip "MDS needs to be at least 2.6.93"
8507 touch $DIR/$tfile || error "touch"
8508 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
8509 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
8510 rm $DIR/$tfile || error "rm"
8513 mkdir -p $DIR/$tdir || error "mkdir"
8514 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8515 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8516 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8517 error "$testfile error deleting user.author1"
8518 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8519 grep "user.$(basename $tdir)" &&
8520 error "$tdir did not delete user.$(basename $tdir)"
8521 rmdir $DIR/$tdir || error "rmdir"
8524 test_mkdir $DIR/$tdir
8525 setfattr -n user.$(basename $tdir) $DIR/$tdir || error "setfattr dir"
8526 getfattr -n user.$(basename $tdir) $DIR/$tdir || error "getfattr dir"
8527 setfattr -x user.$(basename $tdir) $DIR/$tdir ||
8528 error "$testfile error deleting user.author1"
8529 getfattr -d -m user.$(basename $tdir) 2> /dev/null |
8530 grep "user.$(basename $tdir)" &&
8531 error "$tdir did not delete user.$(basename $tdir)"
8532 rmdir $DIR/$tdir || error "rm striped dir"
8534 run_test 102r "set EAs with empty values"
8537 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8538 skip "MDS needs to be at least 2.11.52"
8540 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8542 save_lustre_params client "llite.*.xattr_cache" > $save
8544 for cache in 0 1; do
8545 lctl set_param llite.*.xattr_cache=$cache
8548 touch $DIR/$tfile || error "touch"
8549 for prefix in lustre security system trusted user; do
8550 # Note getxattr() may fail with 'Operation not
8551 # supported' or 'No such attribute' depending
8552 # on prefix and cache.
8553 getfattr -n $prefix.n102s $DIR/$tfile &&
8554 error "getxattr '$prefix.n102s' should fail (cache = $cache)"
8558 restore_lustre_params < $save
8560 run_test 102s "getting nonexistent xattrs should fail"
8563 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
8564 skip "MDS needs to be at least 2.11.52"
8566 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
8568 save_lustre_params client "llite.*.xattr_cache" > $save
8570 for cache in 0 1; do
8571 lctl set_param llite.*.xattr_cache=$cache
8573 for buf_size in 0 256; do
8575 touch $DIR/$tfile || error "touch"
8576 setfattr -n user.multiop $DIR/$tfile
8577 $MULTIOP $DIR/$tfile oa$buf_size ||
8578 error "cannot get zero length xattr value (buf_size = $buf_size)"
8582 restore_lustre_params < $save
8584 run_test 102t "zero length xattr values handled correctly"
8588 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
8593 [ "$UID" != 0 ] && skip "must run as root"
8594 $GSS && skip_env "could not run under gss"
8595 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
8596 skip_env "must have acl enabled"
8597 [ -z "$(which setfacl 2>/dev/null)" ] &&
8598 skip_env "could not find setfacl"
8599 remote_mds_nodsh && skip "remote MDS with nodsh"
8601 gpasswd -a daemon bin # LU-5641
8602 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
8604 declare -a identity_old
8606 for num in $(seq $MDSCOUNT); do
8607 switch_identity $num true || identity_old[$num]=$?
8615 echo "performing cp ..."
8616 run_acl_subtest cp || error "run_acl_subtest cp failed"
8617 echo "performing getfacl-noacl..."
8618 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
8619 echo "performing misc..."
8620 run_acl_subtest misc || error "misc test failed"
8621 echo "performing permissions..."
8622 run_acl_subtest permissions || error "permissions failed"
8623 # LU-1482 mdd: Setting xattr are properly checked with and without ACLs
8624 if [ $MDS1_VERSION -gt $(version_code 2.8.55) -o \
8625 \( $MDS1_VERSION -lt $(version_code 2.6) -a \
8626 $MDS1_VERSION -ge $(version_code 2.5.29) \) ]
8628 echo "performing permissions xattr..."
8629 run_acl_subtest permissions_xattr ||
8630 error "permissions_xattr failed"
8632 echo "performing setfacl..."
8633 run_acl_subtest setfacl || error "setfacl test failed"
8635 # inheritance test got from HP
8636 echo "performing inheritance..."
8637 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
8638 chmod +x make-tree || error "chmod +x failed"
8639 run_acl_subtest inheritance || error "inheritance test failed"
8642 echo "LU-974 ignore umask when acl is enabled..."
8643 run_acl_subtest 974 || error "LU-974 umask test failed"
8644 if [ $MDSCOUNT -ge 2 ]; then
8645 run_acl_subtest 974_remote ||
8646 error "LU-974 umask test failed under remote dir"
8649 echo "LU-2561 newly created file is same size as directory..."
8650 if [ "$mds1_FSTYPE" != "zfs" ]; then
8651 run_acl_subtest 2561 || error "LU-2561 test failed"
8653 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
8656 run_acl_subtest 4924 || error "LU-4924 test failed"
8661 for num in $(seq $MDSCOUNT); do
8662 if [ "${identity_old[$num]}" = 1 ]; then
8663 switch_identity $num false || identity_old[$num]=$?
8667 run_test 103a "acl test"
8673 for U in {0..511}; do
8675 local O=$(printf "%04o" $U)
8677 umask $(printf "%04o" $((511 ^ $O)))
8678 $LFS setstripe -c 1 $DIR/$tfile.s$O
8679 local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
8681 (( $S == ($O & 0666) )) ||
8682 error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
8684 $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
8685 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
8686 (( $S == ($O & 0666) )) ||
8687 error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
8689 $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
8690 S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
8691 (( $S == ($O & 0666) )) ||
8692 error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
8693 rm -f $DIR/$tfile.[smp]$0
8697 # limit the concurrently running threads to 64. LU-11878
8698 local idx=$((U % 64))
8699 [ -z "${pids[idx]}" ] || wait ${pids[idx]}
8704 run_test 103b "umask lfs setstripe"
8708 cp -rp $DIR/$tdir $DIR/$tdir.bak
8710 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
8711 error "$DIR/$tdir shouldn't contain default ACL"
8712 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
8713 error "$DIR/$tdir.bak shouldn't contain default ACL"
8716 run_test 103c "'cp -rp' won't set empty acl"
8719 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8722 lfs df || error "lfs df failed"
8723 lfs df -ih || error "lfs df -ih failed"
8724 lfs df -h $DIR || error "lfs df -h $DIR failed"
8725 lfs df -i $DIR || error "lfs df -i $DIR failed"
8726 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
8727 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
8729 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
8730 lctl --device %$OSC deactivate
8731 lfs df || error "lfs df with deactivated OSC failed"
8732 lctl --device %$OSC activate
8733 # wait the osc back to normal
8734 wait_osc_import_ready client ost
8736 lfs df || error "lfs df with reactivated OSC failed"
8739 run_test 104a "lfs df [-ih] [path] test ========================="
8742 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8743 [ $RUNAS_ID -eq $UID ] &&
8744 skip_env "RUNAS_ID = UID = $UID -- skipping"
8747 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
8748 grep "Permission denied" | wc -l)))
8749 if [ $denied_cnt -ne 0 ]; then
8750 error "lfs check servers test failed"
8753 run_test 104b "$RUNAS lfs check servers test ===================="
8756 # doesn't work on 2.4 kernels
8758 if $(flock_is_enabled); then
8759 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
8761 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
8765 run_test 105a "flock when mounted without -o flock test ========"
8769 if $(flock_is_enabled); then
8770 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
8772 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
8776 run_test 105b "fcntl when mounted without -o flock test ========"
8780 if $(flock_is_enabled); then
8781 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
8783 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
8787 run_test 105c "lockf when mounted without -o flock test"
8789 test_105d() { # bug 15924
8790 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8792 test_mkdir $DIR/$tdir
8793 flock_is_enabled || skip_env "mount w/o flock enabled"
8794 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
8795 $LCTL set_param fail_loc=0x80000315
8796 flocks_test 2 $DIR/$tdir
8798 run_test 105d "flock race (should not freeze) ========"
8800 test_105e() { # bug 22660 && 22040
8801 flock_is_enabled || skip_env "mount w/o flock enabled"
8804 flocks_test 3 $DIR/$tfile
8806 run_test 105e "Two conflicting flocks from same process"
8808 test_106() { #bug 10921
8809 test_mkdir $DIR/$tdir
8810 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
8811 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
8813 run_test 106 "attempt exec of dir followed by chown of that dir"
8816 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8824 local save_pattern=$(sysctl -n kernel.core_pattern)
8825 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
8826 sysctl -w kernel.core_pattern=$file
8827 sysctl -w kernel.core_uses_pid=0
8835 kill -s 11 $SLEEPPID
8837 if [ -e $file ]; then
8838 size=`stat -c%s $file`
8839 [ $size -eq 0 ] && error "Fail to create core file $file"
8841 error "Fail to create core file $file"
8844 sysctl -w kernel.core_pattern=$save_pattern
8845 sysctl -w kernel.core_uses_pid=$save_uses_pid
8848 run_test 107 "Coredump on SIG"
8851 test_mkdir $DIR/$tdir
8852 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255)
8853 $LFS mkdir -c $MDSCOUNT $DIR/$tdir/$(str_repeat 'b' 256) &&
8854 error "mkdir with 256 char should fail, but did not"
8855 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
8856 error "create with 255 char failed"
8857 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
8858 error "create with 256 char should fail, but did not"
8863 run_test 110 "filename length checking"
8866 # Purpose: To verify dynamic thread (OSS) creation.
8869 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8870 remote_ost_nodsh && skip "remote OST with nodsh"
8872 # Lustre does not stop service threads once they are started.
8873 # Reset number of running threads to default.
8878 local save_params="$TMP/sanity-$TESTNAME.parameters"
8880 # Get ll_ost_io count before I/O
8881 OSTIO_pre=$(do_facet ost1 \
8882 "$LCTL get_param ost.OSS.ost_io.threads_started | cut -d= -f2")
8883 # Exit if lustre is not running (ll_ost_io not running).
8884 [ -z "$OSTIO_pre" ] && error "no OSS threads"
8886 echo "Starting with $OSTIO_pre threads"
8887 local thread_max=$((OSTIO_pre * 2))
8888 local rpc_in_flight=$((thread_max * 2))
8889 # Number of I/O Process proposed to be started.
8891 local facets=$(get_facets OST)
8893 save_lustre_params client "osc.*OST*.max_rpcs_in_flight" > $save_params
8894 save_lustre_params $facets "ost.OSS.ost_io.threads_max" >> $save_params
8896 # Set in_flight to $rpc_in_flight
8897 $LCTL set_param osc.*OST*.max_rpcs_in_flight=$rpc_in_flight ||
8898 error "Failed to set max_rpcs_in_flight to $rpc_in_flight"
8899 nfiles=${rpc_in_flight}
8900 # Set ost thread_max to $thread_max
8901 do_facet ost1 "$LCTL set_param ost.OSS.ost_io.threads_max=$thread_max"
8903 # 5 Minutes should be sufficient for max number of OSS
8904 # threads(thread_max) to be created.
8908 local WTL=${WTL:-"$LUSTRE/tests/write_time_limit"}
8909 test_mkdir $DIR/$tdir
8910 for i in $(seq $nfiles); do
8911 local file=$DIR/$tdir/${tfile}-$i
8912 $LFS setstripe -c -1 -i 0 $file
8913 ($WTL $file $timeout)&
8916 # I/O Started - Wait for thread_started to reach thread_max or report
8917 # error if thread_started is more than thread_max.
8918 echo "Waiting for thread_started to reach thread_max"
8919 local thread_started=0
8920 local end_time=$((SECONDS + timeout))
8922 while [ $SECONDS -le $end_time ] ; do
8924 # Get ost i/o thread_started count.
8925 thread_started=$(do_facet ost1 \
8927 ost.OSS.ost_io.threads_started | cut -d= -f2")
8928 # Break out if thread_started is equal/greater than thread_max
8929 if [[ $thread_started -ge $thread_max ]]; then
8930 echo ll_ost_io thread_started $thread_started, \
8931 equal/greater than thread_max $thread_max
8937 # Cleanup - We have the numbers, Kill i/o jobs if running.
8938 jobcount=($(jobs -p))
8939 for i in $(seq 0 $((${#jobcount[@]}-1)))
8941 kill -9 ${jobcount[$i]}
8942 if [ $? -ne 0 ] ; then
8944 Failed to Kill \'WTL\(I/O\)\' with pid ${jobcount[$i]}
8948 # Cleanup files left by WTL binary.
8949 for i in $(seq $nfiles); do
8950 local file=$DIR/$tdir/${tfile}-$i
8952 if [ $? -ne 0 ] ; then
8953 echo "Warning: Failed to delete file $file"
8957 restore_lustre_params <$save_params
8958 rm -f $save_params || echo "Warning: delete file '$save_params' failed"
8960 # Error out if no new thread has started or Thread started is greater
8962 if [[ $thread_started -le $OSTIO_pre ||
8963 $thread_started -gt $thread_max ]]; then
8964 error "ll_ost_io: thread_started $thread_started" \
8965 "OSTIO_pre $OSTIO_pre, thread_max $thread_max." \
8966 "No new thread started or thread started greater " \
8970 run_test 115 "verify dynamic thread creation===================="
8973 wait_delete_completed
8974 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
8975 echo "OST kbytes available: ${AVAIL[@]}"
8980 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
8981 #echo OST $i: ${AVAIL[i]}kb
8982 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
8986 if [[ ${AVAIL[i]} -lt $MINV ]]; then
8991 echo "Min free space: OST $MINI: $MINV"
8992 echo "Max free space: OST $MAXI: $MAXV"
8995 test_116a() { # was previously test_116()
8996 [ $PARALLEL == "yes" ] && skip "skip parallel run"
8997 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
8998 remote_mds_nodsh && skip "remote MDS with nodsh"
9000 echo -n "Free space priority "
9001 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
9006 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
9007 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
9008 trap simple_cleanup_common EXIT
9010 # Check if we need to generate uneven OSTs
9011 test_mkdir -p $DIR/$tdir/OST${MINI}
9012 local FILL=$((MINV / 4))
9013 local DIFF=$((MAXV - MINV))
9014 local DIFF2=$((DIFF * 100 / MINV))
9016 local threshold=$(do_facet $SINGLEMDS \
9017 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
9018 threshold=${threshold%%%}
9019 echo -n "Check for uneven OSTs: "
9020 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
9022 if [[ $DIFF2 -gt $threshold ]]; then
9024 echo "Don't need to fill OST$MINI"
9026 # generate uneven OSTs. Write 2% over the QOS threshold value
9028 DIFF=$((threshold - DIFF2 + 2))
9029 DIFF2=$((MINV * DIFF / 100))
9030 echo "Fill $DIFF% remaining space in OST$MINI with ${DIFF2}KB"
9031 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
9032 error "setstripe failed"
9033 DIFF=$((DIFF2 / 2048))
9035 while [ $i -lt $DIFF ]; do
9037 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
9038 bs=2M count=1 2>/dev/null
9047 DIFF=$((MAXV - MINV))
9048 DIFF2=$((DIFF * 100 / MINV))
9049 echo -n "diff=$DIFF=$DIFF2% must be > $threshold% for QOS mode..."
9050 if [ $DIFF2 -gt $threshold ]; then
9053 echo "failed - QOS mode won't be used"
9054 simple_cleanup_common
9055 skip "QOS imbalance criteria not met"
9063 # now fill using QOS
9064 $SETSTRIPE -c 1 $DIR/$tdir
9065 FILL=$((FILL / 200))
9066 if [ $FILL -gt 600 ]; then
9069 echo "writing $FILL files to QOS-assigned OSTs"
9071 while [ $i -lt $FILL ]; do
9073 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
9077 echo "wrote $i 200k files"
9081 echo "Note: free space may not be updated, so measurements might be off"
9083 DIFF2=$((MAXV - MINV))
9084 echo "free space delta: orig $DIFF final $DIFF2"
9085 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
9086 DIFF=$((MINV1 - ${AVAIL[$MINI1]}))
9087 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
9088 DIFF2=$((MAXV1 - ${AVAIL[$MAXI1]}))
9089 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
9090 if [[ $DIFF -gt 0 ]]; then
9091 FILL=$((DIFF2 * 100 / DIFF - 100))
9092 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
9095 # Figure out which files were written where
9096 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9097 awk '/'$MINI1': / {print $2; exit}')
9099 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9100 echo "$MINC files created on smaller OST $MINI1"
9101 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
9102 awk '/'$MAXI1': / {print $2; exit}')
9104 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
9105 echo "$MAXC files created on larger OST $MAXI1"
9106 if [[ $MINC -gt 0 ]]; then
9107 FILL=$((MAXC * 100 / MINC - 100))
9108 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
9110 [[ $MAXC -gt $MINC ]] ||
9111 error_ignore LU-9 "stripe QOS didn't balance free space"
9112 simple_cleanup_common
9114 run_test 116a "stripe QOS: free space balance ==================="
9116 test_116b() { # LU-2093
9117 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9118 remote_mds_nodsh && skip "remote MDS with nodsh"
9120 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
9121 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
9122 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
9123 [ -z "$old_rr" ] && skip "no QOS"
9124 do_facet $SINGLEMDS lctl set_param \
9125 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
9127 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
9128 createmany -o $DIR/$tdir/f- 20 || error "can't create"
9129 do_facet $SINGLEMDS lctl set_param fail_loc=0
9131 do_facet $SINGLEMDS lctl set_param \
9132 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
9134 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
9136 test_117() # bug 10891
9138 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9140 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
9141 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
9142 lctl set_param fail_loc=0x21e
9143 > $DIR/$tfile || error "truncate failed"
9144 lctl set_param fail_loc=0
9145 echo "Truncate succeeded."
9148 run_test 117 "verify osd extend =========="
9150 NO_SLOW_RESENDCOUNT=4
9151 export OLD_RESENDCOUNT=""
9152 set_resend_count () {
9153 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
9154 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
9155 lctl set_param -n $PROC_RESENDCOUNT $1
9156 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
9159 # for reduce test_118* time (b=14842)
9160 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9162 # Reset async IO behavior after error case
9164 FILE=$DIR/reset_async
9166 # Ensure all OSCs are cleared
9167 $SETSTRIPE -c -1 $FILE
9168 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
9173 test_118a() #bug 11710
9175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9179 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9180 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9181 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9183 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9184 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9189 run_test 118a "verify O_SYNC works =========="
9193 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9194 remote_ost_nodsh && skip "remote OST with nodsh"
9198 #define OBD_FAIL_SRV_ENOENT 0x217
9199 set_nodes_failloc "$(osts_nodes)" 0x217
9200 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9202 set_nodes_failloc "$(osts_nodes)" 0
9203 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9204 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9207 if [[ $RC -eq 0 ]]; then
9208 error "Must return error due to dropped pages, rc=$RC"
9212 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9213 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9217 echo "Dirty pages not leaked on ENOENT"
9219 # Due to the above error the OSC will issue all RPCs syncronously
9220 # until a subsequent RPC completes successfully without error.
9221 $MULTIOP $DIR/$tfile Ow4096yc
9226 run_test 118b "Reclaim dirty pages on fatal error =========="
9230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9232 # for 118c, restore the original resend count, LU-1940
9233 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
9234 set_resend_count $OLD_RESENDCOUNT
9235 remote_ost_nodsh && skip "remote OST with nodsh"
9239 #define OBD_FAIL_OST_EROFS 0x216
9240 set_nodes_failloc "$(osts_nodes)" 0x216
9242 # multiop should block due to fsync until pages are written
9243 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9247 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9248 error "Multiop failed to block on fsync, pid=$MULTIPID"
9251 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9253 if [[ $WRITEBACK -eq 0 ]]; then
9254 error "No page in writeback, writeback=$WRITEBACK"
9257 set_nodes_failloc "$(osts_nodes)" 0
9260 if [[ $RC -ne 0 ]]; then
9261 error "Multiop fsync failed, rc=$RC"
9264 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9265 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9267 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9268 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9272 echo "Dirty pages flushed via fsync on EROFS"
9275 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
9277 # continue to use small resend count to reduce test_118* time (b=14842)
9278 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
9282 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9283 remote_ost_nodsh && skip "remote OST with nodsh"
9287 #define OBD_FAIL_OST_BRW_PAUSE_BULK
9288 set_nodes_failloc "$(osts_nodes)" 0x214
9289 # multiop should block due to fsync until pages are written
9290 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9294 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
9295 error "Multiop failed to block on fsync, pid=$MULTIPID"
9298 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9300 if [[ $WRITEBACK -eq 0 ]]; then
9301 error "No page in writeback, writeback=$WRITEBACK"
9304 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
9305 set_nodes_failloc "$(osts_nodes)" 0
9307 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9308 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9310 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9311 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9315 echo "Dirty pages gaurenteed flushed via fsync"
9318 run_test 118d "Fsync validation inject a delay of the bulk =========="
9321 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9325 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
9326 lctl set_param fail_loc=0x8000040a
9328 # Should simulate EINVAL error which is fatal
9329 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9331 if [[ $RC -eq 0 ]]; then
9332 error "Must return error due to dropped pages, rc=$RC"
9335 lctl set_param fail_loc=0x0
9337 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9338 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9339 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9341 if [[ $LOCKED -ne 0 ]]; then
9342 error "Locked pages remain in cache, locked=$LOCKED"
9345 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9346 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9350 echo "No pages locked after fsync"
9355 run_test 118f "Simulate unrecoverable OSC side error =========="
9358 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9362 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
9363 lctl set_param fail_loc=0x406
9365 # simulate local -ENOMEM
9366 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9369 lctl set_param fail_loc=0
9370 if [[ $RC -eq 0 ]]; then
9371 error "Must return error due to dropped pages, rc=$RC"
9374 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9375 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9376 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9378 if [[ $LOCKED -ne 0 ]]; then
9379 error "Locked pages remain in cache, locked=$LOCKED"
9382 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9383 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9387 echo "No pages locked after fsync"
9392 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
9395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9396 remote_ost_nodsh && skip "remote OST with nodsh"
9400 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9401 set_nodes_failloc "$(osts_nodes)" 0x20e
9402 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9403 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9406 set_nodes_failloc "$(osts_nodes)" 0
9407 if [[ $RC -eq 0 ]]; then
9408 error "Must return error due to dropped pages, rc=$RC"
9411 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9412 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9413 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
9415 if [[ $LOCKED -ne 0 ]]; then
9416 error "Locked pages remain in cache, locked=$LOCKED"
9419 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9420 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9424 echo "No pages locked after fsync"
9428 run_test 118h "Verify timeout in handling recoverables errors =========="
9430 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9433 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9434 remote_ost_nodsh && skip "remote OST with nodsh"
9438 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9439 set_nodes_failloc "$(osts_nodes)" 0x20e
9441 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
9442 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
9445 set_nodes_failloc "$(osts_nodes)" 0
9449 if [[ $RC -ne 0 ]]; then
9450 error "got error, but should be not, rc=$RC"
9453 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9454 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9455 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9456 if [[ $LOCKED -ne 0 ]]; then
9457 error "Locked pages remain in cache, locked=$LOCKED"
9460 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9461 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9465 echo "No pages locked after fsync"
9469 run_test 118i "Fix error before timeout in recoverable error =========="
9471 [ "$SLOW" = "no" ] && set_resend_count 4
9474 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9475 remote_ost_nodsh && skip "remote OST with nodsh"
9479 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
9480 set_nodes_failloc "$(osts_nodes)" 0x220
9482 # return -EIO from OST
9483 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
9485 set_nodes_failloc "$(osts_nodes)" 0x0
9486 if [[ $RC -eq 0 ]]; then
9487 error "Must return error due to dropped pages, rc=$RC"
9490 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
9491 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
9492 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
9493 if [[ $LOCKED -ne 0 ]]; then
9494 error "Locked pages remain in cache, locked=$LOCKED"
9497 # in recoverable error on OST we want resend and stay until it finished
9498 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
9499 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
9503 echo "No pages locked after fsync"
9507 run_test 118j "Simulate unrecoverable OST side error =========="
9511 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9512 remote_ost_nodsh && skip "remote OSTs with nodsh"
9514 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
9515 set_nodes_failloc "$(osts_nodes)" 0x20e
9516 test_mkdir $DIR/$tdir
9518 for ((i=0;i<10;i++)); do
9519 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
9520 error "dd to $DIR/$tdir/$tfile-$i failed" )&
9527 set_nodes_failloc "$(osts_nodes)" 0
9530 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
9532 test_118l() # LU-646
9534 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9536 test_mkdir $DIR/$tdir
9537 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
9540 run_test 118l "fsync dir"
9542 test_118m() # LU-3066
9544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9546 test_mkdir $DIR/$tdir
9547 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
9550 run_test 118m "fdatasync dir ========="
9552 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
9559 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9560 remote_ost_nodsh && skip "remote OSTs with nodsh"
9562 # Sleep to avoid a cached response.
9563 #define OBD_STATFS_CACHE_SECONDS 1
9566 # Inject a 10 second delay in the OST_STATFS handler.
9567 #define OBD_FAIL_OST_STATFS_DELAY 0x242
9568 set_nodes_failloc "$(osts_nodes)" 0x242
9571 stat --file-system $MOUNT > /dev/null
9574 set_nodes_failloc "$(osts_nodes)" 0
9576 if ((end - begin > 20)); then
9577 error "statfs took $((end - begin)) seconds, expected 10"
9580 run_test 118n "statfs() sends OST_STATFS requests in parallel"
9582 test_119a() # bug 11737
9584 BSIZE=$((512 * 1024))
9585 directio write $DIR/$tfile 0 1 $BSIZE
9586 # We ask to read two blocks, which is more than a file size.
9587 # directio will indicate an error when requested and actual
9588 # sizes aren't equeal (a normal situation in this case) and
9589 # print actual read amount.
9590 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
9591 if [ "$NOB" != "$BSIZE" ]; then
9592 error "read $NOB bytes instead of $BSIZE"
9596 run_test 119a "Short directIO read must return actual read amount"
9598 test_119b() # bug 11737
9600 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
9602 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
9603 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
9605 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) ||
9606 error "direct read failed"
9609 run_test 119b "Sparse directIO read must return actual read amount"
9611 test_119c() # bug 13099
9614 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
9615 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
9618 run_test 119c "Testing for direct read hitting hole"
9620 test_119d() # bug 15950
9622 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9624 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
9625 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
9627 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
9628 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
9629 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
9630 lctl set_param fail_loc=0x40d
9631 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
9634 cat $DIR/$tfile > /dev/null &
9635 lctl set_param fail_loc=0
9638 log "the DIO writes have completed, now wait for the reads (should not block very long)"
9640 [ -n "`ps h -p $pid_reads -o comm`" ] && \
9641 error "the read rpcs have not completed in 2s"
9643 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
9645 run_test 119d "The DIO path should try to send a new rpc once one is completed"
9648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9649 remote_mds_nodsh && skip "remote MDS with nodsh"
9650 test_mkdir $DIR/$tdir
9651 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9652 skip_env "no early lock cancel on server"
9654 lru_resize_disable mdc
9655 lru_resize_disable osc
9656 cancel_lru_locks mdc
9657 # asynchronous object destroy at MDT could cause bl ast to client
9658 cancel_lru_locks osc
9660 stat $DIR/$tdir > /dev/null
9661 can1=$(do_facet $SINGLEMDS \
9662 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9663 awk '/ldlm_cancel/ {print $2}')
9664 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9665 awk '/ldlm_bl_callback/ {print $2}')
9666 test_mkdir -c1 $DIR/$tdir/d1
9667 can2=$(do_facet $SINGLEMDS \
9668 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9669 awk '/ldlm_cancel/ {print $2}')
9670 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9671 awk '/ldlm_bl_callback/ {print $2}')
9672 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9673 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9674 lru_resize_enable mdc
9675 lru_resize_enable osc
9677 run_test 120a "Early Lock Cancel: mkdir test"
9680 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9681 remote_mds_nodsh && skip "remote MDS with nodsh"
9682 test_mkdir $DIR/$tdir
9683 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9684 skip_env "no early lock cancel on server"
9686 lru_resize_disable mdc
9687 lru_resize_disable osc
9688 cancel_lru_locks mdc
9689 stat $DIR/$tdir > /dev/null
9690 can1=$(do_facet $SINGLEMDS \
9691 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9692 awk '/ldlm_cancel/ {print $2}')
9693 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9694 awk '/ldlm_bl_callback/ {print $2}')
9696 can2=$(do_facet $SINGLEMDS \
9697 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9698 awk '/ldlm_cancel/ {print $2}')
9699 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9700 awk '/ldlm_bl_callback/ {print $2}')
9701 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9702 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9703 lru_resize_enable mdc
9704 lru_resize_enable osc
9706 run_test 120b "Early Lock Cancel: create test"
9709 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9710 remote_mds_nodsh && skip "remote MDS with nodsh"
9711 test_mkdir -c1 $DIR/$tdir
9712 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9713 skip "no early lock cancel on server"
9715 lru_resize_disable mdc
9716 lru_resize_disable osc
9717 test_mkdir -c1 $DIR/$tdir/d1
9718 test_mkdir -c1 $DIR/$tdir/d2
9719 touch $DIR/$tdir/d1/f1
9720 cancel_lru_locks mdc
9721 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
9722 can1=$(do_facet $SINGLEMDS \
9723 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9724 awk '/ldlm_cancel/ {print $2}')
9725 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9726 awk '/ldlm_bl_callback/ {print $2}')
9727 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9728 can2=$(do_facet $SINGLEMDS \
9729 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9730 awk '/ldlm_cancel/ {print $2}')
9731 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9732 awk '/ldlm_bl_callback/ {print $2}')
9733 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9734 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9735 lru_resize_enable mdc
9736 lru_resize_enable osc
9738 run_test 120c "Early Lock Cancel: link test"
9741 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9742 remote_mds_nodsh && skip "remote MDS with nodsh"
9743 test_mkdir -c1 $DIR/$tdir
9744 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9745 skip_env "no early lock cancel on server"
9747 lru_resize_disable mdc
9748 lru_resize_disable osc
9750 cancel_lru_locks mdc
9751 stat $DIR/$tdir > /dev/null
9752 can1=$(do_facet $SINGLEMDS \
9753 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9754 awk '/ldlm_cancel/ {print $2}')
9755 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9756 awk '/ldlm_bl_callback/ {print $2}')
9757 chmod a+x $DIR/$tdir
9758 can2=$(do_facet $SINGLEMDS \
9759 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9760 awk '/ldlm_cancel/ {print $2}')
9761 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9762 awk '/ldlm_bl_callback/ {print $2}')
9763 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9764 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9765 lru_resize_enable mdc
9766 lru_resize_enable osc
9768 run_test 120d "Early Lock Cancel: setattr test"
9771 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9772 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9773 skip_env "no early lock cancel on server"
9774 remote_mds_nodsh && skip "remote MDS with nodsh"
9776 local dlmtrace_set=false
9778 test_mkdir -c1 $DIR/$tdir
9779 lru_resize_disable mdc
9780 lru_resize_disable osc
9781 ! $LCTL get_param debug | grep -q dlmtrace &&
9782 $LCTL set_param debug=+dlmtrace && dlmtrace_set=true
9783 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
9784 cancel_lru_locks mdc
9785 cancel_lru_locks osc
9786 dd if=$DIR/$tdir/f1 of=/dev/null
9787 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
9788 # XXX client can not do early lock cancel of OST lock
9789 # during unlink (LU-4206), so cancel osc lock now.
9791 cancel_lru_locks osc
9792 can1=$(do_facet $SINGLEMDS \
9793 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9794 awk '/ldlm_cancel/ {print $2}')
9795 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9796 awk '/ldlm_bl_callback/ {print $2}')
9797 unlink $DIR/$tdir/f1
9799 can2=$(do_facet $SINGLEMDS \
9800 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9801 awk '/ldlm_cancel/ {print $2}')
9802 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9803 awk '/ldlm_bl_callback/ {print $2}')
9804 [ $can1 -ne $can2 ] && error "$((can2 - can1)) cancel RPC occured" &&
9805 $LCTL dk $TMP/cancel.debug.txt
9806 [ $blk1 -ne $blk2 ] && error "$((blk2 - blk1)) blocking RPC occured" &&
9807 $LCTL dk $TMP/blocking.debug.txt
9808 $dlmtrace_set && $LCTL set_param debug=-dlmtrace
9809 lru_resize_enable mdc
9810 lru_resize_enable osc
9812 run_test 120e "Early Lock Cancel: unlink test"
9815 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9816 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9817 skip_env "no early lock cancel on server"
9818 remote_mds_nodsh && skip "remote MDS with nodsh"
9820 test_mkdir -c1 $DIR/$tdir
9821 lru_resize_disable mdc
9822 lru_resize_disable osc
9823 test_mkdir -c1 $DIR/$tdir/d1
9824 test_mkdir -c1 $DIR/$tdir/d2
9825 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
9826 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
9827 cancel_lru_locks mdc
9828 cancel_lru_locks osc
9829 dd if=$DIR/$tdir/d1/f1 of=/dev/null
9830 dd if=$DIR/$tdir/d2/f2 of=/dev/null
9831 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
9832 # XXX client can not do early lock cancel of OST lock
9833 # during rename (LU-4206), so cancel osc lock now.
9835 cancel_lru_locks osc
9836 can1=$(do_facet $SINGLEMDS \
9837 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9838 awk '/ldlm_cancel/ {print $2}')
9839 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9840 awk '/ldlm_bl_callback/ {print $2}')
9841 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
9843 can2=$(do_facet $SINGLEMDS \
9844 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9845 awk '/ldlm_cancel/ {print $2}')
9846 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9847 awk '/ldlm_bl_callback/ {print $2}')
9848 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
9849 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
9850 lru_resize_enable mdc
9851 lru_resize_enable osc
9853 run_test 120f "Early Lock Cancel: rename test"
9856 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9857 $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
9858 skip_env "no early lock cancel on server"
9859 remote_mds_nodsh && skip "remote MDS with nodsh"
9861 lru_resize_disable mdc
9862 lru_resize_disable osc
9864 echo create $count files
9865 test_mkdir $DIR/$tdir
9866 cancel_lru_locks mdc
9867 cancel_lru_locks osc
9870 can0=$(do_facet $SINGLEMDS \
9871 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9872 awk '/ldlm_cancel/ {print $2}')
9873 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9874 awk '/ldlm_bl_callback/ {print $2}')
9875 createmany -o $DIR/$tdir/f $count
9877 can1=$(do_facet $SINGLEMDS \
9878 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9879 awk '/ldlm_cancel/ {print $2}')
9880 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9881 awk '/ldlm_bl_callback/ {print $2}')
9883 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
9884 echo rm $count files
9887 can2=$(do_facet $SINGLEMDS \
9888 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
9889 awk '/ldlm_cancel/ {print $2}')
9890 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
9891 awk '/ldlm_bl_callback/ {print $2}')
9893 echo total: $count removes in $((t2-t1))
9894 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
9896 # wait for commitment of removal
9897 lru_resize_enable mdc
9898 lru_resize_enable osc
9900 run_test 120g "Early Lock Cancel: performance test"
9902 test_121() { #bug #10589
9903 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9906 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
9907 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
9908 lctl set_param fail_loc=0x310
9909 cancel_lru_locks osc > /dev/null
9910 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
9911 lctl set_param fail_loc=0
9912 [[ $reads -eq $writes ]] ||
9913 error "read $reads blocks, must be $writes blocks"
9915 run_test 121 "read cancel race ========="
9917 test_123a() { # was test 123, statahead(bug 11401)
9918 [ $PARALLEL == "yes" ] && skip "skip parallel run"
9921 if ! grep -q "processor.*: 1" /proc/cpuinfo; then
9922 log "testing UP system. Performance may be lower than expected."
9927 test_mkdir $DIR/$tdir
9928 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
9929 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
9931 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
9932 createmany -o $DIR/$tdir/$tfile $j $((i - j))
9934 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9935 lctl set_param -n llite.*.statahead_max 0
9936 lctl get_param llite.*.statahead_max
9937 cancel_lru_locks mdc
9938 cancel_lru_locks osc
9940 time ls -l $DIR/$tdir | wc -l
9942 delta=$((etime - stime))
9943 log "ls $i files without statahead: $delta sec"
9944 lctl set_param llite.*.statahead_max=$max
9946 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9947 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
9948 cancel_lru_locks mdc
9949 cancel_lru_locks osc
9951 time ls -l $DIR/$tdir | wc -l
9953 delta_sa=$((etime - stime))
9954 log "ls $i files with statahead: $delta_sa sec"
9955 lctl get_param -n llite.*.statahead_stats
9956 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
9958 [[ $swrong -lt $ewrong ]] &&
9959 log "statahead was stopped, maybe too many locks held!"
9960 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
9962 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9963 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
9964 lctl set_param -n llite.*.statahead_max 0
9965 lctl get_param llite.*.statahead_max
9966 cancel_lru_locks mdc
9967 cancel_lru_locks osc
9969 time ls -l $DIR/$tdir | wc -l
9971 delta=$((etime - stime))
9972 log "ls $i files again without statahead: $delta sec"
9973 lctl set_param llite.*.statahead_max=$max
9974 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
9975 if [ $SLOWOK -eq 0 ]; then
9976 error "ls $i files is slower with statahead!"
9978 log "ls $i files is slower with statahead!"
9984 [ $delta -gt 20 ] && break
9985 [ $delta -gt 8 ] && MULT=$((50 / delta))
9986 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
9994 delta=$((etime - stime))
9995 log "rm -r $DIR/$tdir/: $delta seconds"
9997 lctl get_param -n llite.*.statahead_stats
9999 run_test 123a "verify statahead work"
10001 test_123b () { # statahead(bug 15027)
10002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10004 test_mkdir $DIR/$tdir
10005 createmany -o $DIR/$tdir/$tfile-%d 1000
10007 cancel_lru_locks mdc
10008 cancel_lru_locks osc
10010 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
10011 lctl set_param fail_loc=0x80000803
10012 ls -lR $DIR/$tdir > /dev/null
10014 lctl set_param fail_loc=0x0
10015 lctl get_param -n llite.*.statahead_stats
10020 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
10023 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10024 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10025 skip_env "no lru resize on server"
10029 test_mkdir $DIR/$tdir
10031 log "create $NR files at $DIR/$tdir"
10032 createmany -o $DIR/$tdir/f $NR ||
10033 error "failed to create $NR files in $DIR/$tdir"
10035 cancel_lru_locks mdc
10036 ls -l $DIR/$tdir > /dev/null
10040 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
10041 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
10042 LRU_SIZE=$($LCTL get_param -n $PARAM)
10043 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
10044 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
10046 log "NS=$(basename $NSDIR)"
10051 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
10052 skip "Not enough cached locks created!"
10054 log "LRU=$LRU_SIZE"
10058 # We know that lru resize allows one client to hold $LIMIT locks
10059 # for 10h. After that locks begin to be killed by client.
10061 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
10063 if [ $LIMIT -lt $LRU_SIZE ]; then
10064 skip "Limit is too small $LIMIT"
10067 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
10068 # killing locks. Some time was spent for creating locks. This means
10069 # that up to the moment of sleep finish we must have killed some of
10070 # them (10-100 locks). This depends on how fast ther were created.
10071 # Many of them were touched in almost the same moment and thus will
10072 # be killed in groups.
10073 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
10075 # Use $LRU_SIZE_B here to take into account real number of locks
10076 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
10077 local LRU_SIZE_B=$LRU_SIZE
10079 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
10080 log "OLD_LVF=$OLD_LVF"
10081 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
10083 # Let's make sure that we really have some margin. Client checks
10084 # cached locks every 10 sec.
10085 SLEEP=$((SLEEP+20))
10086 log "Sleep ${SLEEP} sec"
10088 while ((SEC<$SLEEP)); do
10092 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
10093 echo -n "$LRU_SIZE"
10096 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
10097 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
10099 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
10100 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
10101 unlinkmany $DIR/$tdir/f $NR
10105 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
10106 log "unlink $NR files at $DIR/$tdir"
10107 unlinkmany $DIR/$tdir/f $NR
10109 run_test 124a "lru resize ======================================="
10111 get_max_pool_limit()
10113 local limit=$($LCTL get_param \
10114 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
10116 for l in $limit; do
10117 if [[ $l -gt $max ]]; then
10125 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10126 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10127 skip_env "no lru resize on server"
10129 LIMIT=$(get_max_pool_limit)
10131 NR=$(($(default_lru_size)*20))
10132 if [[ $NR -gt $LIMIT ]]; then
10133 log "Limit lock number by $LIMIT locks"
10137 IFree=$(mdsrate_inodes_available)
10138 if [ $IFree -lt $NR ]; then
10139 log "Limit lock number by $IFree inodes"
10143 lru_resize_disable mdc
10144 test_mkdir -p $DIR/$tdir/disable_lru_resize
10146 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
10147 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
10148 cancel_lru_locks mdc
10151 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10154 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10157 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
10161 nolruresize_delta=$((etime-stime))
10162 log "ls -la time: $nolruresize_delta seconds"
10163 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10164 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
10166 lru_resize_enable mdc
10167 test_mkdir -p $DIR/$tdir/enable_lru_resize
10169 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
10170 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
10171 cancel_lru_locks mdc
10174 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10177 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10180 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
10184 lruresize_delta=$((etime-stime))
10185 log "ls -la time: $lruresize_delta seconds"
10186 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
10188 if [ $lruresize_delta -gt $nolruresize_delta ]; then
10189 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
10190 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
10191 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
10193 log "lru resize performs the same with no lru resize"
10195 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
10197 run_test 124b "lru resize (performance test) ======================="
10200 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10201 $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
10202 skip_env "no lru resize on server"
10204 # cache ununsed locks on client
10206 cancel_lru_locks mdc
10207 test_mkdir $DIR/$tdir
10208 createmany -o $DIR/$tdir/f $nr ||
10209 error "failed to create $nr files in $DIR/$tdir"
10210 ls -l $DIR/$tdir > /dev/null
10212 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
10213 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
10214 local max_age=$($LCTL get_param -n $nsdir.lru_max_age)
10215 local recalc_p=$($LCTL get_param -n $nsdir.pool.recalc_period)
10216 echo "unused=$unused, max_age=$max_age, recalc_p=$recalc_p"
10218 # set lru_max_age to 1 sec
10219 $LCTL set_param $nsdir.lru_max_age=1000 # milliseconds
10220 echo "sleep $((recalc_p * 2)) seconds..."
10221 sleep $((recalc_p * 2))
10223 local remaining=$($LCTL get_param -n $nsdir.lock_unused_count)
10224 # restore lru_max_age
10225 $LCTL set_param -n $nsdir.lru_max_age $max_age
10226 [ $remaining -eq 0 ] || error "$remaining locks are not canceled"
10227 unlinkmany $DIR/$tdir/f $nr
10229 run_test 124c "LRUR cancel very aged locks"
10231 test_125() { # 13358
10232 $LCTL get_param -n llite.*.client_type | grep -q local ||
10233 skip "must run as local client"
10234 $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
10235 skip_env "must have acl enabled"
10236 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
10238 test_mkdir $DIR/$tdir
10239 $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
10240 setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
10241 ls -ld $DIR/$tdir || error "cannot access $DIR/$tdir"
10243 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
10245 test_126() { # bug 12829/13455
10246 $GSS && skip_env "must run as gss disabled"
10247 $LCTL get_param -n llite.*.client_type | grep -q local ||
10248 skip "must run as local client"
10249 [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
10251 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
10252 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
10254 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
10256 run_test 126 "check that the fsgid provided by the client is taken into account"
10258 test_127a() { # bug 15521
10259 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10261 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
10262 $LCTL set_param osc.*.stats=0
10263 FSIZE=$((2048 * 1024))
10264 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
10265 cancel_lru_locks osc
10266 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
10268 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
10269 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
10270 echo "got $COUNT $NAME"
10271 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
10272 eval $NAME=$COUNT || error "Wrong proc format"
10275 read_bytes|write_bytes)
10276 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
10277 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
10278 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
10279 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
10280 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
10281 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
10282 error "sumsquare is too small: $SUMSQ"
10283 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
10284 error "sumsquare is too big: $SUMSQ"
10288 done < $DIR/${tfile}.tmp
10290 #check that we actually got some stats
10291 [ "$read_bytes" ] || error "Missing read_bytes stats"
10292 [ "$write_bytes" ] || error "Missing write_bytes stats"
10293 [ "$read_bytes" != 0 ] || error "no read done"
10294 [ "$write_bytes" != 0 ] || error "no write done"
10296 run_test 127a "verify the client stats are sane"
10298 test_127b() { # bug LU-333
10299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10300 local name count samp unit min max sum sumsq
10302 $LCTL set_param llite.*.stats=0
10304 # perform 2 reads and writes so MAX is different from SUM.
10305 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10306 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1
10307 cancel_lru_locks osc
10308 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10309 dd if=$DIR/$tfile of=/dev/null bs=$PAGE_SIZE count=1
10311 $LCTL get_param llite.*.stats | grep samples > $TMP/$tfile.tmp
10312 while read name count samp unit min max sum sumsq; do
10313 echo "got $count $name"
10314 eval $name=$count || error "Wrong proc format"
10318 [ $count -ne 2 ] && error "count is not 2: $count"
10319 [ $min -ne $PAGE_SIZE ] &&
10320 error "min is not $PAGE_SIZE: $min"
10321 [ $max -ne $PAGE_SIZE ] &&
10322 error "max is incorrect: $max"
10323 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10324 error "sum is wrong: $sum"
10327 [ $count -ne 2 ] && error "count is not 2: $count"
10328 [ $min -ne $PAGE_SIZE ] &&
10329 error "min is not $PAGE_SIZE: $min"
10330 [ $max -ne $PAGE_SIZE ] &&
10331 error "max is incorrect: $max"
10332 [ $sum -ne $((PAGE_SIZE * 2)) ] &&
10333 error "sum is wrong: $sum"
10337 done < $TMP/$tfile.tmp
10339 #check that we actually got some stats
10340 [ "$read_bytes" ] || error "Missing read_bytes stats"
10341 [ "$write_bytes" ] || error "Missing write_bytes stats"
10342 [ "$read_bytes" != 0 ] || error "no read done"
10343 [ "$write_bytes" != 0 ] || error "no write done"
10345 rm -f $TMP/${tfile}.tmp
10347 run_test 127b "verify the llite client stats are sane"
10349 test_128() { # bug 15212
10351 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
10356 result=$(grep error $TMP/$tfile.log)
10357 rm -f $DIR/$tfile $TMP/$tfile.log
10358 [ -z "$result" ] ||
10359 error "consecutive find's under interactive lfs failed"
10361 run_test 128 "interactive lfs for 2 consecutive find's"
10363 set_dir_limits () {
10368 local ldproc=/proc/fs/ldiskfs
10369 local facets=$(get_facets MDS)
10371 for facet in ${facets//,/ }; do
10372 canondev=$(ldiskfs_canon \
10373 *.$(convert_facet2label $facet).mntdev $facet)
10374 do_facet $facet "test -e $ldproc/$canondev/max_dir_size" ||
10375 ldproc=/sys/fs/ldiskfs
10376 do_facet $facet "echo $1 >$ldproc/$canondev/max_dir_size"
10377 do_facet $facet "echo $2 >$ldproc/$canondev/warning_dir_size"
10381 check_mds_dmesg() {
10382 local facets=$(get_facets MDS)
10383 for facet in ${facets//,/ }; do
10384 do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0
10390 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10391 [[ $MDS1_VERSION -ge $(version_code 2.5.56) ]] ||
10392 skip "Need MDS version with at least 2.5.56"
10393 if [ "$mds1_FSTYPE" != ldiskfs ]; then
10394 skip_env "ldiskfs only test"
10396 remote_mds_nodsh && skip "remote MDS with nodsh"
10400 local has_warning=false
10403 mkdir -p $DIR/$tdir
10405 # block size of mds1
10406 local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5))
10407 set_dir_limits $maxsize $maxsize
10408 local dirsize=$(stat -c%s "$DIR/$tdir")
10410 while [[ $dirsize -le $maxsize ]]; do
10411 $MULTIOP $DIR/$tdir/file_base_$nfiles Oc
10413 if ! $has_warning; then
10414 check_mds_dmesg '"is approaching"' && has_warning=true
10416 # check two errors:
10417 # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee)
10418 # EFBIG for previous versions included in ldiskfs series
10419 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
10421 echo "return code $rc received as expected"
10423 createmany -o $DIR/$tdir/file_extra_$nfiles. 5 ||
10424 error_exit "create failed w/o dir size limit"
10426 check_mds_dmesg '"has reached"' ||
10427 error_exit "reached message should be output"
10429 [ $has_warning = "false" ] &&
10430 error_exit "warning message should be output"
10432 dirsize=$(stat -c%s "$DIR/$tdir")
10434 [[ $dirsize -ge $maxsize ]] && return 0
10435 error_exit "current dir size $dirsize, " \
10436 "previous limit $maxsize"
10437 elif [ $rc -ne 0 ]; then
10439 error_exit "return $rc received instead of expected " \
10440 "$EFBIG or $ENOSPC, files in dir $dirsize"
10442 nfiles=$((nfiles + 1))
10443 dirsize=$(stat -c%s "$DIR/$tdir")
10447 error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes"
10449 run_test 129 "test directory size limit ========================"
10458 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10459 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10461 trap cleanup_130 EXIT RETURN
10463 local fm_file=$DIR/$tfile
10464 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
10465 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
10466 error "dd failed for $fm_file"
10468 # LU-1795: test filefrag/FIEMAP once, even if unsupported
10469 filefrag -ves $fm_file
10471 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10472 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10473 [ $RC != 0 ] && error "filefrag $fm_file failed"
10475 filefrag_op=$(filefrag -ve -k $fm_file |
10476 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10477 lun=$($GETSTRIPE -i $fm_file)
10479 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
10482 for line in $filefrag_op
10484 frag_lun=`echo $line | cut -d: -f5`
10485 ext_len=`echo $line | cut -d: -f4`
10486 if (( $frag_lun != $lun )); then
10488 error "FIEMAP on 1-stripe file($fm_file) failed"
10491 (( tot_len += ext_len ))
10494 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
10496 error "FIEMAP on 1-stripe file($fm_file) failed;"
10502 echo "FIEMAP on single striped file succeeded"
10504 run_test 130a "FIEMAP (1-stripe file)"
10507 [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
10509 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10510 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10512 trap cleanup_130 EXIT RETURN
10514 local fm_file=$DIR/$tfile
10515 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10516 error "setstripe on $fm_file"
10517 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10518 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10520 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
10521 error "dd failed on $fm_file"
10523 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10524 filefrag_op=$(filefrag -ve -k $fm_file |
10525 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10527 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10528 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10533 for line in $filefrag_op
10535 frag_lun=$(echo $line | cut -d: -f5 |
10536 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10537 ext_len=$(echo $line | cut -d: -f4)
10538 if (( $frag_lun != $last_lun )); then
10539 if (( tot_len != 1024 )); then
10541 error "FIEMAP on $fm_file failed; returned " \
10542 "len $tot_len for OST $last_lun instead of 1024"
10545 (( num_luns += 1 ))
10549 (( tot_len += ext_len ))
10552 if (( num_luns != $OSTCOUNT || tot_len != 1024 )); then
10554 error "FIEMAP on $fm_file failed; returned wrong number of " \
10555 "luns or wrong len for OST $last_lun"
10561 echo "FIEMAP on $OSTCOUNT-stripe file succeeded"
10563 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
10566 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10568 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10569 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10571 trap cleanup_130 EXIT RETURN
10573 local fm_file=$DIR/$tfile
10574 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
10575 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10576 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10578 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
10579 error "dd failed on $fm_file"
10581 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10582 filefrag_op=$(filefrag -ve -k $fm_file |
10583 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10585 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10586 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10591 for line in $filefrag_op
10593 frag_lun=$(echo $line | cut -d: -f5 |
10594 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10595 ext_len=$(echo $line | cut -d: -f4)
10596 if (( $frag_lun != $last_lun )); then
10597 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
10598 if (( logical != 512 )); then
10600 error "FIEMAP on $fm_file failed; returned " \
10601 "logical start for lun $logical instead of 512"
10604 if (( tot_len != 512 )); then
10606 error "FIEMAP on $fm_file failed; returned " \
10607 "len $tot_len for OST $last_lun instead of 1024"
10610 (( num_luns += 1 ))
10614 (( tot_len += ext_len ))
10617 if (( num_luns != 2 || tot_len != 512 )); then
10619 error "FIEMAP on $fm_file failed; returned wrong number of " \
10620 "luns or wrong len for OST $last_lun"
10626 echo "FIEMAP on 2-stripe file with hole succeeded"
10628 run_test 130c "FIEMAP (2-stripe file with hole)"
10631 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
10633 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10634 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10636 trap cleanup_130 EXIT RETURN
10638 local fm_file=$DIR/$tfile
10639 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
10640 error "setstripe on $fm_file"
10641 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10642 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10644 local actual_stripe_count=$($GETSTRIPE -c $fm_file)
10645 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
10646 error "dd failed on $fm_file"
10648 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10649 filefrag_op=$(filefrag -ve -k $fm_file |
10650 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10652 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10653 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10658 for line in $filefrag_op
10660 frag_lun=$(echo $line | cut -d: -f5 |
10661 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10662 ext_len=$(echo $line | cut -d: -f4)
10663 if (( $frag_lun != $last_lun )); then
10664 if (( tot_len != 1024 )); then
10666 error "FIEMAP on $fm_file failed; returned " \
10667 "len $tot_len for OST $last_lun instead of 1024"
10670 (( num_luns += 1 ))
10674 (( tot_len += ext_len ))
10677 if (( num_luns != actual_stripe_count || tot_len != 1024 )); then
10679 error "FIEMAP on $fm_file failed; returned wrong number of " \
10680 "luns or wrong len for OST $last_lun"
10686 echo "FIEMAP on N-stripe file succeeded"
10688 run_test 130d "FIEMAP (N-stripe file)"
10691 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
10693 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10694 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
10696 trap cleanup_130 EXIT RETURN
10698 local fm_file=$DIR/$tfile
10699 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
10700 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
10701 skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
10704 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
10705 for ((i = 0; i < $NUM_BLKS; i++))
10707 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
10710 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10711 filefrag_op=$(filefrag -ve -k $fm_file |
10712 sed -n '/ext:/,/found/{/ext:/d; /found/d; p}')
10714 last_lun=$(echo $filefrag_op | cut -d: -f5 |
10715 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10720 for line in $filefrag_op
10722 frag_lun=$(echo $line | cut -d: -f5 |
10723 sed -e 's/^[ \t]*/0x/' | sed -e 's/0x0x/0x/')
10724 ext_len=$(echo $line | cut -d: -f4)
10725 if (( $frag_lun != $last_lun )); then
10726 if (( tot_len != $EXPECTED_LEN )); then
10728 error "FIEMAP on $fm_file failed; returned " \
10729 "len $tot_len for OST $last_lun instead " \
10733 (( num_luns += 1 ))
10737 (( tot_len += ext_len ))
10740 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
10742 error "FIEMAP on $fm_file failed; returned wrong number " \
10743 "of luns or wrong len for OST $last_lun"
10749 echo "FIEMAP with continuation calls succeeded"
10751 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
10754 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
10755 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
10757 local fm_file=$DIR/$tfile
10758 $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
10759 error "multiop create with lov_delay_create on $fm_file"
10761 filefrag -ves $fm_file || error "filefrag $fm_file failed"
10762 filefrag_extents=$(filefrag -vek $fm_file |
10763 awk '/extents? found/ { print $2 }')
10764 if [[ "$filefrag_extents" != "0" ]]; then
10765 error "FIEMAP on $fm_file failed; " \
10766 "returned $filefrag_extents expected 0"
10771 run_test 130f "FIEMAP (unstriped file)"
10773 # Test for writev/readv
10775 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 ||
10776 error "writev test failed"
10777 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 ||
10778 error "readv failed"
10781 run_test 131a "test iov's crossing stripe boundary for writev/readv"
10784 local fsize=$((524288 + 1048576 + 1572864))
10785 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 &&
10786 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10787 error "append writev test failed"
10789 ((fsize += 1572864 + 1048576))
10790 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 &&
10791 $CHECKSTAT -t file $DIR/$tfile -s $fsize ||
10792 error "append writev test failed"
10795 run_test 131b "test append writev"
10798 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
10801 run_test 131c "test read/write on file w/o objects"
10804 rwv -f $DIR/$tfile -w -n 1 1572864
10805 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
10806 if [ "$NOB" != 1572864 ]; then
10807 error "Short read filed: read $NOB bytes instead of 1572864"
10811 run_test 131d "test short read"
10814 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
10815 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
10816 error "read hitting hole failed"
10819 run_test 131e "test read hitting hole"
10828 mds*) res=$(do_facet $facet \
10829 $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$op")
10831 ost*) res=$(do_facet $facet \
10832 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$op")
10834 *) error "Wrong facet '$facet'" ;;
10836 [ "$res" ] || error "The counter for $op on $facet was not incremented"
10837 # if the argument $3 is zero, it means any stat increment is ok.
10838 if [[ $want -gt 0 ]]; then
10839 local count=$(echo $res | awk '{ print $2 }')
10840 [[ $count -ne $want ]] &&
10841 error "The $op counter on $facet is $count, not $want"
10846 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10847 remote_ost_nodsh && skip "remote OST with nodsh"
10848 remote_mds_nodsh && skip "remote MDS with nodsh"
10849 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
10850 skip_env "MDS doesn't support rename stats"
10852 local testdir=$DIR/${tdir}/stats_testdir
10854 mkdir -p $DIR/${tdir}
10857 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10858 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10860 # verify mdt stats first.
10861 mkdir ${testdir} || error "mkdir failed"
10862 check_stats $SINGLEMDS "mkdir" 1
10863 touch ${testdir}/${tfile} || error "touch failed"
10864 check_stats $SINGLEMDS "open" 1
10865 check_stats $SINGLEMDS "close" 1
10866 [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
10867 mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
10868 check_stats $SINGLEMDS "mknod" 2
10870 rm -f ${testdir}/${tfile}-pipe || error "pipe remove failed"
10871 check_stats $SINGLEMDS "unlink" 1
10872 rm -f ${testdir}/${tfile} || error "file remove failed"
10873 check_stats $SINGLEMDS "unlink" 2
10875 # remove working dir and check mdt stats again.
10876 rmdir ${testdir} || error "rmdir failed"
10877 check_stats $SINGLEMDS "rmdir" 1
10879 local testdir1=$DIR/${tdir}/stats_testdir1
10880 mkdir -p ${testdir}
10881 mkdir -p ${testdir1}
10882 touch ${testdir1}/test1
10883 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
10884 check_stats $SINGLEMDS "crossdir_rename" 1
10886 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
10887 check_stats $SINGLEMDS "samedir_rename" 1
10889 rm -rf $DIR/${tdir}
10891 run_test 133a "Verifying MDT stats ========================================"
10896 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10897 remote_ost_nodsh && skip "remote OST with nodsh"
10898 remote_mds_nodsh && skip "remote MDS with nodsh"
10900 local testdir=$DIR/${tdir}/stats_testdir
10902 mkdir -p ${testdir} || error "mkdir failed"
10903 touch ${testdir}/${tfile} || error "touch failed"
10904 cancel_lru_locks mdc
10907 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10908 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10910 # extra mdt stats verification.
10911 chmod 444 ${testdir}/${tfile} || error "chmod failed"
10912 check_stats $SINGLEMDS "setattr" 1
10913 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10914 if [ $MDS1_VERSION -ne $(version_code 2.2.0) ]
10916 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
10917 check_stats $SINGLEMDS "getattr" 1
10919 rm -rf $DIR/${tdir}
10921 # when DNE is enabled, MDT uses STATFS RPC to ping other targets
10922 # so the check below is not reliable
10923 [ $MDSCOUNT -eq 1 ] || return 0
10925 # Sleep to avoid a cached response.
10926 #define OBD_STATFS_CACHE_SECONDS 1
10928 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10929 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
10930 $LFS df || error "lfs failed"
10931 check_stats $SINGLEMDS "statfs" 1
10933 # check aggregated statfs (LU-10018)
10934 [ $MDS1_VERSION -lt $(version_code 2.11.54) ] &&
10936 [ $CLIENT_VERSION -lt $(version_code 2.11.54) ] &&
10939 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10940 do_facet ost1 $LCTL set_param obdfilter.*.exports.*.stats=clear
10942 check_stats $SINGLEMDS "statfs" 1
10944 # We want to check that the client didn't send OST_STATFS to
10945 # ost1 but the MDT also uses OST_STATFS for precreate. So some
10946 # extra care is needed here.
10947 if remote_mds; then
10948 local nid=$($LCTL list_nids | head -1 | sed "s/\./\\\./g")
10949 local param="obdfilter.$FSNAME-OST0000.exports.'$nid'.stats"
10951 res=$(do_facet ost1 $LCTL get_param $param | grep statfs)
10952 [ "$res" ] && error "OST got STATFS"
10957 run_test 133b "Verifying extra MDT stats =================================="
10960 [ $PARALLEL == "yes" ] && skip "skip parallel run"
10961 remote_ost_nodsh && skip "remote OST with nodsh"
10962 remote_mds_nodsh && skip "remote MDS with nodsh"
10964 local testdir=$DIR/$tdir/stats_testdir
10966 test_mkdir -p $testdir
10968 # verify obdfilter stats.
10969 $SETSTRIPE -c 1 -i 0 $testdir/$tfile
10971 cancel_lru_locks osc
10972 wait_delete_completed
10975 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
10976 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
10978 dd if=/dev/zero of=$testdir/$tfile conv=notrunc bs=512k count=1 ||
10981 cancel_lru_locks osc
10982 check_stats ost1 "write" 1
10984 dd if=$testdir/$tfile of=/dev/null bs=1k count=1 || error "dd failed"
10985 check_stats ost1 "read" 1
10987 > $testdir/$tfile || error "truncate failed"
10988 check_stats ost1 "punch" 1
10990 rm -f $testdir/$tfile || error "file remove failed"
10991 wait_delete_completed
10992 check_stats ost1 "destroy" 1
10996 run_test 133c "Verifying OST stats ========================================"
11003 while [ $value -ge 2 ]; do
11008 if [ $orig -gt $order ]; then
11016 local size=('K' 'M' 'G' 'T');
11018 local size_string=$value
11020 while [ $value -ge 1024 ]; do
11021 if [ $i -gt 3 ]; then
11022 #T is the biggest unit we get here, if that is bigger,
11024 size_string=${value}T
11027 value=$((value >> 10))
11028 if [ $value -lt 1024 ]; then
11029 size_string=${value}${size[$i]}
11038 get_rename_size() {
11040 local context=${2:-.}
11041 local sample=$(do_facet $SINGLEMDS $LCTL \
11042 get_param mdt.$FSNAME-MDT0000.rename_stats |
11043 grep -A1 $context |
11044 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
11049 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11050 remote_ost_nodsh && skip "remote OST with nodsh"
11051 remote_mds_nodsh && skip "remote MDS with nodsh"
11052 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
11053 skip_env "MDS doesn't support rename stats"
11055 local testdir1=$DIR/${tdir}/stats_testdir1
11056 local testdir2=$DIR/${tdir}/stats_testdir2
11057 mkdir -p $DIR/${tdir}
11059 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11061 lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
11062 lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
11064 createmany -o $testdir1/test 512 || error "createmany failed"
11066 # check samedir rename size
11067 mv ${testdir1}/test0 ${testdir1}/test_0
11069 local testdir1_size=$(ls -l $DIR/${tdir} |
11070 awk '/stats_testdir1/ {print $5}')
11071 local testdir2_size=$(ls -l $DIR/${tdir} |
11072 awk '/stats_testdir2/ {print $5}')
11074 testdir1_size=$(order_2 $testdir1_size)
11075 testdir2_size=$(order_2 $testdir2_size)
11077 testdir1_size=$(size_in_KMGT $testdir1_size)
11078 testdir2_size=$(size_in_KMGT $testdir2_size)
11080 echo "source rename dir size: ${testdir1_size}"
11081 echo "target rename dir size: ${testdir2_size}"
11083 local cmd="do_facet $SINGLEMDS $LCTL "
11084 cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
11086 eval $cmd || error "$cmd failed"
11087 local samedir=$($cmd | grep 'same_dir')
11088 local same_sample=$(get_rename_size $testdir1_size)
11089 [ -z "$samedir" ] && error "samedir_rename_size count error"
11090 [[ $same_sample -eq 1 ]] ||
11091 error "samedir_rename_size error $same_sample"
11092 echo "Check same dir rename stats success"
11094 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
11096 # check crossdir rename size
11097 mv ${testdir1}/test_0 ${testdir2}/test_0
11099 testdir1_size=$(ls -l $DIR/${tdir} |
11100 awk '/stats_testdir1/ {print $5}')
11101 testdir2_size=$(ls -l $DIR/${tdir} |
11102 awk '/stats_testdir2/ {print $5}')
11104 testdir1_size=$(order_2 $testdir1_size)
11105 testdir2_size=$(order_2 $testdir2_size)
11107 testdir1_size=$(size_in_KMGT $testdir1_size)
11108 testdir2_size=$(size_in_KMGT $testdir2_size)
11110 echo "source rename dir size: ${testdir1_size}"
11111 echo "target rename dir size: ${testdir2_size}"
11113 eval $cmd || error "$cmd failed"
11114 local crossdir=$($cmd | grep 'crossdir')
11115 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
11116 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
11117 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
11118 [[ $src_sample -eq 1 ]] ||
11119 error "crossdir_rename_size error $src_sample"
11120 [[ $tgt_sample -eq 1 ]] ||
11121 error "crossdir_rename_size error $tgt_sample"
11122 echo "Check cross dir rename stats success"
11123 rm -rf $DIR/${tdir}
11125 run_test 133d "Verifying rename_stats ========================================"
11128 remote_mds_nodsh && skip "remote MDS with nodsh"
11129 remote_ost_nodsh && skip "remote OST with nodsh"
11130 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11132 local testdir=$DIR/${tdir}/stats_testdir
11133 local ctr f0 f1 bs=32768 count=42 sum
11135 mkdir -p ${testdir} || error "mkdir failed"
11137 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
11139 for ctr in {write,read}_bytes; do
11141 cancel_lru_locks osc
11143 do_facet ost1 $LCTL set_param -n \
11144 "obdfilter.*.exports.clear=clear"
11146 if [ $ctr = write_bytes ]; then
11148 f1=${testdir}/${tfile}
11150 f0=${testdir}/${tfile}
11154 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
11157 cancel_lru_locks osc
11159 sum=$(do_facet ost1 $LCTL get_param \
11160 "obdfilter.*.exports.*.stats" |
11161 awk -v ctr=$ctr 'BEGIN { sum = 0 }
11162 $1 == ctr { sum += $7 }
11163 END { printf("%0.0f", sum) }')
11165 if ((sum != bs * count)); then
11166 error "Bad $ctr sum, expected $((bs * count)), got $sum"
11170 rm -rf $DIR/${tdir}
11172 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
11174 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
11176 # Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
11177 # not honor the -ignore_readdir_race option correctly. So we call
11178 # error_ignore() rather than error() in these cases. See LU-11152.
11180 if (find --version; do_facet mds1 find --version) |
11181 grep -q '\b4\.5\.1[1-4]\b'; then
11182 error_ignore LU-11152 "$@"
11189 # First without trusting modes.
11190 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
11191 echo "proc_dirs='$proc_dirs'"
11192 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
11193 find $proc_dirs -exec cat '{}' \; &> /dev/null
11195 # Second verifying readability.
11196 $LCTL get_param -R '*' &> /dev/null
11198 # Verifing writability with badarea_io.
11200 -ignore_readdir_race \
11202 -not -name force_lbug \
11203 -not -name changelog_mask \
11204 -exec badarea_io '{}' \; ||
11205 error_133 "find $proc_dirs failed"
11207 run_test 133f "Check reads/writes of client lustre proc files with bad area io"
11210 remote_mds_nodsh && skip "remote MDS with nodsh"
11211 remote_ost_nodsh && skip "remote OST with nodsh"
11213 # eventually, this can also be replaced with "lctl get_param -R",
11214 # but not until that option is always available on the server
11216 for facet in mds1 ost1; do
11217 [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
11218 skip_noexit "Too old lustre on $facet"
11219 local facet_proc_dirs=$(do_facet $facet \
11220 \\\ls -d $proc_regexp 2>/dev/null)
11221 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11222 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11223 do_facet $facet find $facet_proc_dirs \
11224 ! -name req_history \
11225 -exec cat '{}' \\\; &> /dev/null
11227 do_facet $facet find $facet_proc_dirs \
11228 ! -name req_history \
11230 -exec cat '{}' \\\; &> /dev/null ||
11231 error "proc file read failed"
11233 do_facet $facet find $facet_proc_dirs \
11234 -ignore_readdir_race \
11236 -not -name force_lbug \
11237 -not -name changelog_mask \
11238 -exec badarea_io '{}' \\\; ||
11239 error_133 "$facet find $facet_proc_dirs failed"
11242 # remount the FS in case writes/reads /proc break the FS
11243 cleanup || error "failed to unmount"
11244 setup || error "failed to setup"
11247 run_test 133g "Check reads/writes of server lustre proc files with bad area io"
11250 remote_mds_nodsh && skip "remote MDS with nodsh"
11251 remote_ost_nodsh && skip "remote OST with nodsh"
11252 [[ $MDS1_VERSION -lt $(version_code 2.9.54) ]] &&
11253 skip "Need MDS version at least 2.9.54"
11257 for facet in client mds1 ost1; do
11258 local facet_proc_dirs=$(do_facet $facet \
11259 \\\ls -d $proc_regexp 2> /dev/null)
11260 [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
11261 echo "${facet}_proc_dirs='$facet_proc_dirs'"
11262 # Get the list of files that are missing the terminating newline
11263 local missing=($(do_facet $facet \
11264 find ${facet_proc_dirs} -type f \| \
11265 while read F\; do \
11266 awk -v FS='\v' -v RS='\v\v' \
11267 "'END { if(NR>0 && \
11268 \\\$NF !~ /.*\\\n\$/) \
11269 print FILENAME}'" \
11272 [ ${#missing[*]} -eq 0 ] ||
11273 error "files do not end with newline: ${missing[*]}"
11276 run_test 133h "Proc files should end with newlines"
11279 remote_mds_nodsh && skip "remote MDS with nodsh"
11280 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11281 skip "Need MDS version at least 2.7.54"
11283 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11284 cancel_lru_locks mdc
11286 local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
11287 local unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11288 [ $unused -eq 0 ] || error "$unused locks are not cleared"
11291 createmany -o $DIR/$tdir/f $nr ||
11292 error "failed to create $nr files in $DIR/$tdir"
11293 unused=$($LCTL get_param -n $nsdir.lock_unused_count)
11295 #define OBD_FAIL_LDLM_WATERMARK_LOW 0x327
11296 do_facet mds1 $LCTL set_param fail_loc=0x327
11297 do_facet mds1 $LCTL set_param fail_val=500
11300 echo "sleep 10 seconds ..."
11302 local lck_cnt=$($LCTL get_param -n $nsdir.lock_unused_count)
11304 do_facet mds1 $LCTL set_param fail_loc=0
11305 do_facet mds1 $LCTL set_param fail_val=0
11306 [ $lck_cnt -lt $unused ] ||
11307 error "No locks reclaimed, before:$unused, after:$lck_cnt"
11310 unlinkmany $DIR/$tdir/f $nr
11312 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
11315 remote_mds_nodsh && skip "remote MDS with nodsh"
11316 [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
11317 skip "Need MDS version at least 2.7.54"
11319 mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
11320 cancel_lru_locks mdc
11322 local low_wm=$(do_facet mds1 $LCTL get_param -n \
11323 ldlm.lock_reclaim_threshold_mb)
11324 # disable reclaim temporarily
11325 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=0
11327 #define OBD_FAIL_LDLM_WATERMARK_HIGH 0x328
11328 do_facet mds1 $LCTL set_param fail_loc=0x328
11329 do_facet mds1 $LCTL set_param fail_val=500
11331 $LCTL set_param debug=+trace
11334 createmany -o $DIR/$tdir/f $nr &
11335 local create_pid=$!
11337 echo "Sleep $TIMEOUT seconds ..."
11339 if ! ps -p $create_pid > /dev/null 2>&1; then
11340 do_facet mds1 $LCTL set_param fail_loc=0
11341 do_facet mds1 $LCTL set_param fail_val=0
11342 do_facet mds1 $LCTL set_param \
11343 ldlm.lock_reclaim_threshold_mb=${low_wm}m
11344 error "createmany finished incorrectly!"
11346 do_facet mds1 $LCTL set_param fail_loc=0
11347 do_facet mds1 $LCTL set_param fail_val=0
11348 do_facet mds1 $LCTL set_param ldlm.lock_reclaim_threshold_mb=${low_wm}m
11349 wait $create_pid || return 1
11351 unlinkmany $DIR/$tdir/f $nr
11353 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
11355 test_140() { #bug-17379
11356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11358 test_mkdir $DIR/$tdir
11359 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
11360 cp $(which stat) . || error "Copying stat to $DIR/$tdir"
11362 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
11363 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
11365 while i=$((i + 1)); do
11367 cd $i || error "Changing to $i"
11368 ln -s ../stat stat || error "Creating stat symlink"
11369 # Read the symlink until ELOOP present,
11370 # not LBUGing the system is considered success,
11371 # we didn't overrun the stack.
11372 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
11373 if [ $ret -ne 0 ]; then
11374 if [ $ret -eq 40 ]; then
11377 error "Open stat symlink"
11383 echo "The symlink depth = $i"
11384 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
11385 error "Invalid symlink depth"
11387 # Test recursive symlink
11388 ln -s symlink_self symlink_self
11389 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
11390 echo "open symlink_self returns $ret"
11391 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
11393 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
11396 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11398 local TF="$TMP/$tfile"
11400 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11402 cancel_lru_locks $OSC
11403 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
11404 remount_client $MOUNT
11406 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
11409 $TRUNCATE $DIR/$tfile 6000
11410 cancel_lru_locks $OSC
11411 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
11414 echo "12345" >>$DIR/$tfile
11415 cancel_lru_locks $OSC
11416 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
11419 echo "12345" >>$DIR/$tfile
11420 cancel_lru_locks $OSC
11421 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
11426 run_test 150 "truncate/append tests"
11428 #LU-2902 roc_hit was not able to read all values from lproc
11429 function roc_hit_init() {
11430 local list=$(comma_list $(osts_nodes))
11431 local dir=$DIR/$tdir-check
11432 local file=$dir/$tfile
11438 #use setstripe to do a write to every ost
11439 for i in $(seq 0 $((OSTCOUNT-1))); do
11440 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
11441 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
11442 idx=$(printf %04x $i)
11443 BEFORE=$(get_osd_param $list *OST*$idx stats |
11444 awk '$1 == "cache_access" {sum += $7}
11445 END { printf("%0.0f", sum) }')
11447 cancel_lru_locks osc
11448 cat $file >/dev/null
11450 AFTER=$(get_osd_param $list *OST*$idx stats |
11451 awk '$1 == "cache_access" {sum += $7}
11452 END { printf("%0.0f", sum) }')
11454 echo BEFORE:$BEFORE AFTER:$AFTER
11455 if ! let "AFTER - BEFORE == 4"; then
11457 error "roc_hit is not safe to use"
11465 function roc_hit() {
11466 local list=$(comma_list $(osts_nodes))
11467 echo $(get_osd_param $list '' stats |
11468 awk '$1 == "cache_hit" {sum += $7}
11469 END { printf("%0.0f", sum) }')
11472 function set_cache() {
11475 if [ "$2" == "off" ]; then
11478 local list=$(comma_list $(osts_nodes))
11479 set_osd_param $list '' $1_cache_enable $on
11481 cancel_lru_locks osc
11485 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11486 remote_ost_nodsh && skip "remote OST with nodsh"
11489 local list=$(comma_list $(osts_nodes))
11491 # check whether obdfilter is cache capable at all
11492 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
11493 skip "not cache-capable obdfilter"
11496 # check cache is enabled on all obdfilters
11497 if get_osd_param $list '' read_cache_enable | grep 0; then
11498 skip "oss cache is disabled"
11501 set_osd_param $list '' writethrough_cache_enable 1
11503 # check write cache is enabled on all obdfilters
11504 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
11505 skip "oss write cache is NOT enabled"
11510 #define OBD_FAIL_OBD_NO_LRU 0x609
11511 do_nodes $list $LCTL set_param fail_loc=0x609
11513 # pages should be in the case right after write
11514 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
11517 local BEFORE=$(roc_hit)
11518 cancel_lru_locks osc
11519 cat $DIR/$tfile >/dev/null
11520 local AFTER=$(roc_hit)
11522 do_nodes $list $LCTL set_param fail_loc=0
11524 if ! let "AFTER - BEFORE == CPAGES"; then
11525 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
11528 # the following read invalidates the cache
11529 cancel_lru_locks osc
11530 set_osd_param $list '' read_cache_enable 0
11531 cat $DIR/$tfile >/dev/null
11533 # now data shouldn't be found in the cache
11535 cancel_lru_locks osc
11536 cat $DIR/$tfile >/dev/null
11538 if let "AFTER - BEFORE != 0"; then
11539 error "IN CACHE: before: $BEFORE, after: $AFTER"
11542 set_osd_param $list '' read_cache_enable 1
11545 run_test 151 "test cache on oss and controls ==============================="
11548 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11550 local TF="$TMP/$tfile"
11552 # simulate ENOMEM during write
11553 #define OBD_FAIL_OST_NOMEM 0x226
11554 lctl set_param fail_loc=0x80000226
11555 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
11557 sync || error "sync failed"
11558 lctl set_param fail_loc=0
11560 # discard client's cache
11561 cancel_lru_locks osc
11563 # simulate ENOMEM during read
11564 lctl set_param fail_loc=0x80000226
11565 cmp $TF $DIR/$tfile || error "cmp failed"
11566 lctl set_param fail_loc=0
11570 run_test 152 "test read/write with enomem ============================"
11573 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
11575 run_test 153 "test if fdatasync does not crash ======================="
11577 dot_lustre_fid_permission_check() {
11579 local ffid=$MOUNT/.lustre/fid/$fid
11582 echo "stat fid $fid"
11583 stat $ffid > /dev/null || error "stat $ffid failed."
11584 echo "touch fid $fid"
11585 touch $ffid || error "touch $ffid failed."
11586 echo "write to fid $fid"
11587 cat /etc/hosts > $ffid || error "write $ffid failed."
11588 echo "read fid $fid"
11589 diff /etc/hosts $ffid || error "read $ffid failed."
11590 echo "append write to fid $fid"
11591 cat /etc/hosts >> $ffid || error "append write $ffid failed."
11592 echo "rename fid $fid"
11593 mv $ffid $test_dir/$tfile.1 &&
11594 error "rename $ffid to $tfile.1 should fail."
11595 touch $test_dir/$tfile.1
11596 mv $test_dir/$tfile.1 $ffid &&
11597 error "rename $tfile.1 to $ffid should fail."
11598 rm -f $test_dir/$tfile.1
11599 echo "truncate fid $fid"
11600 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
11601 echo "link fid $fid"
11602 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
11603 if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
11604 echo "setfacl fid $fid"
11605 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
11606 echo "getfacl fid $fid"
11607 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
11609 echo "unlink fid $fid"
11610 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
11611 echo "mknod fid $fid"
11612 mknod $ffid c 1 3 && error "mknod $ffid should fail."
11614 fid=[0xf00000400:0x1:0x0]
11615 ffid=$MOUNT/.lustre/fid/$fid
11617 echo "stat non-exist fid $fid"
11618 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
11619 echo "write to non-exist fid $fid"
11620 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
11621 echo "link new fid $fid"
11622 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
11624 mkdir -p $test_dir/$tdir
11625 touch $test_dir/$tdir/$tfile
11626 fid=$($LFS path2fid $test_dir/$tdir)
11629 error "error: could not get fid for $test_dir/$dir/$tfile."
11631 ffid=$MOUNT/.lustre/fid/$fid
11634 ls $ffid > /dev/null || error "ls $ffid failed."
11635 echo "touch $fid/$tfile.1"
11636 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
11638 echo "touch $MOUNT/.lustre/fid/$tfile"
11639 touch $MOUNT/.lustre/fid/$tfile && \
11640 error "touch $MOUNT/.lustre/fid/$tfile should fail."
11642 echo "setxattr to $MOUNT/.lustre/fid"
11643 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
11645 echo "listxattr for $MOUNT/.lustre/fid"
11646 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
11648 echo "delxattr from $MOUNT/.lustre/fid"
11649 setfattr -x trusted.name1 $MOUNT/.lustre/fid
11651 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
11652 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
11653 error "touch invalid fid should fail."
11655 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
11656 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
11657 error "touch non-normal fid should fail."
11659 echo "rename $tdir to $MOUNT/.lustre/fid"
11660 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
11661 error "rename to $MOUNT/.lustre/fid should fail."
11663 if [ $MDS1_VERSION -ge $(version_code 2.3.51) ]
11665 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
11666 local new_obf_mode=777
11668 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
11669 chmod $new_obf_mode $DIR/.lustre/fid ||
11670 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
11672 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
11673 [ $obf_mode -eq $new_obf_mode ] ||
11674 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
11676 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
11677 chmod $old_obf_mode $DIR/.lustre/fid ||
11678 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
11681 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
11682 fid=$($LFS path2fid $test_dir/$tfile-2)
11684 if [ $MDS1_VERSION -ge $(version_code 2.6.50) ]
11686 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
11687 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
11688 error "create lov data thru .lustre failed"
11690 echo "cp /etc/passwd $test_dir/$tfile-2"
11691 cp /etc/passwd $test_dir/$tfile-2 ||
11692 error "copy to $test_dir/$tfile-2 failed."
11693 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
11694 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
11695 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
11697 rm -rf $test_dir/tfile.lnk
11698 rm -rf $test_dir/$tfile-2
11702 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
11703 skip "Need MDS version at least 2.4.1"
11705 local tf=$DIR/$tfile
11708 local fid=$($LFS path2fid $tf)
11709 [ -z "$fid" ] && error "path2fid unable to get $tf FID"
11711 # check that we get the same pathname back
11712 local found=$($LFS fid2path $MOUNT "$fid")
11713 [ -z "$found" ] && error "fid2path unable to get '$fid' path"
11714 [ "$found" == "$tf" ] ||
11715 error "fid2path($fid=path2fid($tf)) = $found != $tf"
11717 run_test 154A "lfs path2fid and fid2path basic checks"
11720 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
11721 skip "Need MDS version at least 2.4.1"
11723 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11724 touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
11725 local linkea=$($LL_DECODE_LINKEA $DIR/$tdir/$tfile | grep 'pfid')
11726 [ -z "$linkea" ] && error "decode linkea $DIR/$tdir/$tfile failed"
11728 local name=$(echo $linkea | awk '/pfid/ {print $5}' | sed -e "s/'//g")
11729 local PFID=$(echo $linkea | awk '/pfid/ {print $3}' | sed -e "s/,//g")
11731 # check that we get the same pathname
11732 echo "PFID: $PFID, name: $name"
11733 local FOUND=$($LFS fid2path $MOUNT "$PFID")
11734 [ -z "$FOUND" ] && error "fid2path unable to get $PFID path"
11735 [ "$FOUND/$name" != "$DIR/$tdir/$tfile" ] &&
11736 error "ll_decode_linkea has $FOUND/$name != $DIR/$tdir/$tfile"
11738 rm -rf $DIR/$tdir || error "Can not delete directory $DIR/$tdir"
11740 run_test 154B "verify the ll_decode_linkea tool"
11743 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11744 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11745 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
11746 skip "Need MDS version at least 2.2.51"
11747 [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
11749 cp /etc/hosts $DIR/$tfile
11751 fid=$($LFS path2fid $DIR/$tfile)
11753 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
11755 dot_lustre_fid_permission_check "$fid" $DIR ||
11756 error "dot lustre permission check $fid failed"
11758 ls -a $MOUNT | grep "\.lustre" && error ".lustre should not be listed"
11760 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
11762 touch $MOUNT/.lustre/file &&
11763 error "creation is not allowed under .lustre"
11765 mkdir $MOUNT/.lustre/dir &&
11766 error "mkdir is not allowed under .lustre"
11770 run_test 154a "Open-by-FID"
11773 [ $PARALLEL == "yes" ] && skip "skip parallel run"
11774 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11775 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
11776 [[ $MDS1_VERSION -ge $(version_code 2.2.51) ]] ||
11777 skip "Need MDS version at least 2.2.51"
11779 local remote_dir=$DIR/$tdir/remote_dir
11783 mkdir -p $DIR/$tdir
11784 $LFS mkdir -i $MDTIDX $remote_dir ||
11785 error "create remote directory failed"
11787 cp /etc/hosts $remote_dir/$tfile
11789 fid=$($LFS path2fid $remote_dir/$tfile)
11791 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
11793 dot_lustre_fid_permission_check "$fid" $remote_dir ||
11794 error "dot lustre permission check $fid failed"
11797 run_test 154b "Open-by-FID for remote directory"
11800 [[ $MDS1_VERSION -lt $(version_code 2.4.1) ]] &&
11801 skip "Need MDS version at least 2.4.1"
11803 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
11804 local FID1=$($LFS path2fid $DIR/$tfile.1)
11805 local FID2=$($LFS path2fid $DIR/$tfile.2)
11806 local FID3=$($LFS path2fid $DIR/$tfile.3)
11809 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
11810 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
11811 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
11813 [ "$FID" = "${!want}" ] ||
11814 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
11818 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
11820 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
11821 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
11825 run_test 154c "lfs path2fid and fid2path multiple arguments"
11828 remote_mds_nodsh && skip "remote MDS with nodsh"
11829 [[ $MDS1_VERSION -lt $(version_code 2.5.53) ]] &&
11830 skip "Need MDS version at least 2.5.53"
11832 if remote_mds; then
11833 nid=$($LCTL list_nids | sed "s/\./\\\./g")
11837 local proc_ofile="mdt.*.exports.'$nid'.open_files"
11844 local fid=$($LFS path2fid $DIR/$tfile)
11847 cmd="exec $fd<$DIR/$tfile"
11849 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
11850 echo "$fid_list" | grep "$fid"
11853 cmd="exec $fd>/dev/null"
11855 if [ $rc -ne 0 ]; then
11856 error "FID $fid not found in open files list $fid_list"
11859 run_test 154d "Verify open file fid"
11863 [[ $MDS1_VERSION -lt $(version_code 2.6.50) ]] &&
11864 skip "Need MDS version at least 2.6.50"
11866 if ls -a $MOUNT | grep -q '^\.lustre$'; then
11867 error ".lustre returned by readdir"
11870 run_test 154e ".lustre is not returned by readdir"
11873 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11875 # create parent directory on a single MDT to avoid cross-MDT hardlinks
11876 test_mkdir -p -c1 $DIR/$tdir/d
11877 # test dirs inherit from its stripe
11878 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
11879 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
11880 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
11881 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
11884 # get fid of parents
11885 local FID0=$($LFS path2fid $DIR/$tdir/d)
11886 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
11887 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
11888 local FID3=$($LFS path2fid $DIR)
11890 # check that path2fid --parents returns expected <parent_fid>/name
11891 # 1) test for a directory (single parent)
11892 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
11893 [ "$parent" == "$FID0/foo1" ] ||
11894 error "expected parent: $FID0/foo1, got: $parent"
11896 # 2) test for a file with nlink > 1 (multiple parents)
11897 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
11898 echo "$parent" | grep -F "$FID1/$tfile" ||
11899 error "$FID1/$tfile not returned in parent list"
11900 echo "$parent" | grep -F "$FID2/link" ||
11901 error "$FID2/link not returned in parent list"
11903 # 3) get parent by fid
11904 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
11905 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11906 echo "$parent" | grep -F "$FID1/$tfile" ||
11907 error "$FID1/$tfile not returned in parent list (by fid)"
11908 echo "$parent" | grep -F "$FID2/link" ||
11909 error "$FID2/link not returned in parent list (by fid)"
11911 # 4) test for entry in root directory
11912 parent=$($LFS path2fid --parents $DIR/f)
11913 echo "$parent" | grep -F "$FID3/f" ||
11914 error "$FID3/f not returned in parent list"
11916 # 5) test it on root directory
11917 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
11918 error "$MOUNT should not have parents"
11920 # enable xattr caching and check that linkea is correctly updated
11921 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
11922 save_lustre_params client "llite.*.xattr_cache" > $save
11923 lctl set_param llite.*.xattr_cache 1
11925 # 6.1) linkea update on rename
11926 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
11928 # get parents by fid
11929 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11930 # foo1 should no longer be returned in parent list
11931 echo "$parent" | grep -F "$FID1" &&
11932 error "$FID1 should no longer be in parent list"
11933 # the new path should appear
11934 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
11935 error "$FID2/$tfile.moved is not in parent list"
11937 # 6.2) linkea update on unlink
11938 rm -f $DIR/$tdir/d/foo2/link
11939 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
11940 # foo2/link should no longer be returned in parent list
11941 echo "$parent" | grep -F "$FID2/link" &&
11942 error "$FID2/link should no longer be in parent list"
11946 restore_lustre_params < $save
11949 run_test 154f "get parent fids by reading link ea"
11953 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
11954 [[ $MDS1_VERSION -ge $(version_code 2.6.92) &&
11955 $CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
11956 skip "Need MDS version at least 2.6.92"
11958 mkdir -p $DIR/$tdir
11959 llapi_fid_test -d $DIR/$tdir
11961 run_test 154g "various llapi FID tests"
11963 test_155_small_load() {
11964 local temp=$TMP/$tfile
11965 local file=$DIR/$tfile
11967 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
11968 error "dd of=$temp bs=6096 count=1 failed"
11970 cancel_lru_locks $OSC
11971 cmp $temp $file || error "$temp $file differ"
11973 $TRUNCATE $temp 6000
11974 $TRUNCATE $file 6000
11975 cmp $temp $file || error "$temp $file differ (truncate1)"
11977 echo "12345" >>$temp
11978 echo "12345" >>$file
11979 cmp $temp $file || error "$temp $file differ (append1)"
11981 echo "12345" >>$temp
11982 echo "12345" >>$file
11983 cmp $temp $file || error "$temp $file differ (append2)"
11989 test_155_big_load() {
11990 remote_ost_nodsh && skip "remote OST with nodsh"
11992 local temp=$TMP/$tfile
11993 local file=$DIR/$tfile
11996 local cache_size=$(do_facet ost$((MAXI+1)) \
11997 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
11998 local large_file_size=$((cache_size * 2))
12000 echo "OSS cache size: $cache_size KB"
12001 echo "Large file size: $large_file_size KB"
12003 [ $MAXV -le $large_file_size ] &&
12004 skip_env "max available OST size needs > $large_file_size KB"
12006 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
12008 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
12009 error "dd of=$temp bs=$large_file_size count=1k failed"
12012 cancel_lru_locks osc
12013 cmp $temp $file || error "$temp $file differ"
12019 save_writethrough() {
12020 local facets=$(get_facets OST)
12022 save_lustre_params $facets "osd-*.*.writethrough_cache_enable" > $1
12026 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12028 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12030 save_writethrough $p
12033 set_cache writethrough on
12034 test_155_small_load
12035 restore_lustre_params < $p
12038 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
12041 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12043 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12045 save_writethrough $p
12048 set_cache writethrough off
12049 test_155_small_load
12050 restore_lustre_params < $p
12053 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
12056 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12058 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12060 save_writethrough $p
12063 set_cache writethrough on
12064 test_155_small_load
12065 restore_lustre_params < $p
12068 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
12071 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12073 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12075 save_writethrough $p
12078 set_cache writethrough off
12079 test_155_small_load
12080 restore_lustre_params < $p
12083 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
12086 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12088 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12090 save_writethrough $p
12093 set_cache writethrough on
12095 restore_lustre_params < $p
12098 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
12101 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12103 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12105 save_writethrough $p
12108 set_cache writethrough off
12110 restore_lustre_params < $p
12113 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
12116 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12118 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12120 save_writethrough $p
12123 set_cache writethrough on
12125 restore_lustre_params < $p
12128 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
12131 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12133 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12135 save_writethrough $p
12138 set_cache writethrough off
12140 restore_lustre_params < $p
12143 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
12146 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12147 remote_ost_nodsh && skip "remote OST with nodsh"
12148 [ $OST1_VERSION -lt $(version_code 2.6.93) ] &&
12149 skip "stats not implemented on old servers"
12150 [ "$ost1_FSTYPE" = "zfs" ] &&
12151 skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
12156 local file="$DIR/$tfile"
12157 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
12159 save_writethrough $p
12162 log "Turn on read and write cache"
12164 set_cache writethrough on
12166 log "Write data and read it back."
12167 log "Read should be satisfied from the cache."
12168 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12170 cancel_lru_locks osc
12171 cat $file >/dev/null
12173 if ! let "AFTER - BEFORE == CPAGES"; then
12174 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12176 log "cache hits:: before: $BEFORE, after: $AFTER"
12179 log "Read again; it should be satisfied from the cache."
12181 cancel_lru_locks osc
12182 cat $file >/dev/null
12184 if ! let "AFTER - BEFORE == CPAGES"; then
12185 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12187 log "cache hits:: before: $BEFORE, after: $AFTER"
12190 log "Turn off the read cache and turn on the write cache"
12192 set_cache writethrough on
12194 log "Read again; it should be satisfied from the cache."
12196 cancel_lru_locks osc
12197 cat $file >/dev/null
12199 if ! let "AFTER - BEFORE == CPAGES"; then
12200 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12202 log "cache hits:: before: $BEFORE, after: $AFTER"
12205 log "Read again; it should not be satisfied from the cache."
12207 cancel_lru_locks osc
12208 cat $file >/dev/null
12210 if ! let "AFTER - BEFORE == 0"; then
12211 error "IN CACHE: before: $BEFORE, after: $AFTER"
12213 log "cache hits:: before: $BEFORE, after: $AFTER"
12216 log "Write data and read it back."
12217 log "Read should be satisfied from the cache."
12218 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12220 cancel_lru_locks osc
12221 cat $file >/dev/null
12223 if ! let "AFTER - BEFORE == CPAGES"; then
12224 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12226 log "cache hits:: before: $BEFORE, after: $AFTER"
12229 log "Read again; it should not be satisfied from the cache."
12231 cancel_lru_locks osc
12232 cat $file >/dev/null
12234 if ! let "AFTER - BEFORE == 0"; then
12235 error "IN CACHE: before: $BEFORE, after: $AFTER"
12237 log "cache hits:: before: $BEFORE, after: $AFTER"
12240 log "Turn off read and write cache"
12242 set_cache writethrough off
12244 log "Write data and read it back"
12245 log "It should not be satisfied from the cache."
12247 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12248 cancel_lru_locks osc
12250 cat $file >/dev/null
12252 if ! let "AFTER - BEFORE == 0"; then
12253 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12255 log "cache hits:: before: $BEFORE, after: $AFTER"
12258 log "Turn on the read cache and turn off the write cache"
12260 set_cache writethrough off
12262 log "Write data and read it back"
12263 log "It should not be satisfied from the cache."
12265 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
12267 cancel_lru_locks osc
12268 cat $file >/dev/null
12270 if ! let "AFTER - BEFORE == 0"; then
12271 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
12273 log "cache hits:: before: $BEFORE, after: $AFTER"
12276 log "Read again; it should be satisfied from the cache."
12278 cancel_lru_locks osc
12279 cat $file >/dev/null
12281 if ! let "AFTER - BEFORE == CPAGES"; then
12282 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
12284 log "cache hits:: before: $BEFORE, after: $AFTER"
12287 restore_lustre_params < $p
12290 run_test 156 "Verification of tunables"
12293 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12294 remote_mds_nodsh && skip "remote MDS with nodsh"
12295 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12296 skip "Need MDS version at least 2.2.0"
12298 changelog_register || error "changelog_register failed"
12299 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12300 changelog_users $SINGLEMDS | grep -q $cl_user ||
12301 error "User $cl_user not found in changelog_users"
12304 test_mkdir -p $DIR/$tdir/pics/2008/zachy
12305 changelog_clear 0 || error "changelog_clear failed"
12306 touch $DIR/$tdir/pics/2008/zachy/$tfile # open 1
12307 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg # open 2
12308 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
12309 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
12310 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
12311 rm $DIR/$tdir/pics/desktop.jpg
12313 changelog_dump | tail -10
12315 echo "verifying changelog mask"
12316 changelog_chmask "-MKDIR"
12317 changelog_chmask "-CLOSE"
12319 test_mkdir -p $DIR/$tdir/pics/zach/sofia # not logged
12320 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # not logged
12322 changelog_chmask "+MKDIR"
12323 changelog_chmask "+CLOSE"
12325 test_mkdir -p $DIR/$tdir/pics/2008/sofia # mkdir 1
12326 echo "zzzzzz" > $DIR/$tdir/pics/zach/file # open 3
12328 changelog_dump | tail -10
12329 MKDIRS=$(changelog_dump | grep -c "MKDIR")
12330 CLOSES=$(changelog_dump | grep -c "CLOSE")
12331 [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
12332 [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
12335 echo "verifying target fid"
12336 local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
12337 local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
12338 [ "$fidc" == "$fidf" ] ||
12339 error "changelog '$tfile' fid $fidc != file fid $fidf"
12340 echo "verifying parent fid"
12341 # The FID returned from the Changelog may be the directory shard on
12342 # a different MDT, and not the FID returned by path2fid on the parent.
12343 # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
12344 # since this is what will matter when recreating this file in the tree.
12345 local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
12346 local pathp=$($LFS fid2path $MOUNT "$fidp")
12347 [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
12348 error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
12350 echo "getting records for $cl_user"
12351 changelog_users $SINGLEMDS
12352 local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
12354 __changelog_clear $SINGLEMDS $cl_user +$nclr ||
12355 error "changelog_clear failed"
12356 local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
12357 echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
12358 [ $user_rec2 == $((user_rec1 + nclr)) ] ||
12359 error "user index expect $user_rec1 + $nclr != $user_rec2"
12361 local min0_rec=$(changelog_users $SINGLEMDS |
12362 awk 'min == "" || $2 < min { min = $2 }; END { print min }')
12363 local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
12364 awk '{ print $1; exit; }')
12366 changelog_dump | tail -n 5
12367 echo "verifying user min purge: $min0_rec + 1 == $first_rec"
12368 [ $first_rec == $((min0_rec + 1)) ] ||
12369 error "first index should be $min0_rec + 1 not $first_rec"
12371 # LU-3446 changelog index reset on MDT restart
12372 local cur_rec1=$(changelog_users $SINGLEMDS |
12373 awk '/^current.index:/ { print $NF }')
12374 changelog_clear 0 ||
12375 error "clear all changelog records for $cl_user failed"
12376 stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
12377 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
12378 error "Fail to start $SINGLEMDS"
12379 local cur_rec2=$(changelog_users $SINGLEMDS |
12380 awk '/^current.index:/ { print $NF }')
12381 echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
12382 [ $cur_rec1 == $cur_rec2 ] ||
12383 error "current index should be $cur_rec1 not $cur_rec2"
12385 echo "verifying users from this test are deregistered"
12386 changelog_deregister || error "changelog_deregister failed"
12387 changelog_users $SINGLEMDS | grep -q $cl_user &&
12388 error "User '$cl_user' still in changelog_users"
12390 # lctl get_param -n mdd.*.changelog_users
12391 # current index: 144
12392 # ID index (idle seconds)
12394 if ! changelog_users $SINGLEMDS | grep "^cl"; then
12395 # this is the normal case where all users were deregistered
12396 # make sure no new records are added when no users are present
12397 local last_rec1=$(changelog_users $SINGLEMDS |
12398 awk '/^current.index:/ { print $NF }')
12399 touch $DIR/$tdir/chloe
12400 local last_rec2=$(changelog_users $SINGLEMDS |
12401 awk '/^current.index:/ { print $NF }')
12402 echo "verify changelogs are off: $last_rec1 == $last_rec2"
12403 [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
12405 # any changelog users must be leftovers from a previous test
12406 changelog_users $SINGLEMDS
12407 echo "other changelog users; can't verify off"
12410 run_test 160a "changelog sanity"
12412 test_160b() { # LU-3587
12413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12414 remote_mds_nodsh && skip "remote MDS with nodsh"
12415 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] ||
12416 skip "Need MDS version at least 2.2.0"
12418 changelog_register || error "changelog_register failed"
12419 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
12420 changelog_users $SINGLEMDS | grep -q $cl_user ||
12421 error "User '$cl_user' not found in changelog_users"
12423 local longname1=$(str_repeat a 255)
12424 local longname2=$(str_repeat b 255)
12427 echo "creating very long named file"
12428 touch $longname1 || error "create of '$longname1' failed"
12429 echo "renaming very long named file"
12430 mv $longname1 $longname2
12432 changelog_dump | grep RENME | tail -n 5
12435 run_test 160b "Verify that very long rename doesn't crash in changelog"
12438 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12439 remote_mds_nodsh && skip "remote MDS with nodsh"
12441 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
12442 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
12443 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
12444 skip "Need MDS version at least 2.5.58 or 2.5.2+"
12448 # Registration step
12449 changelog_register || error "changelog_register failed"
12452 mkdir -p $DIR/$tdir
12453 $MCREATE $DIR/$tdir/foo_160c
12454 changelog_chmask "-TRUNC"
12455 $TRUNCATE $DIR/$tdir/foo_160c 200
12456 changelog_chmask "+TRUNC"
12457 $TRUNCATE $DIR/$tdir/foo_160c 199
12458 changelog_dump | tail -n 5
12459 local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
12460 [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
12462 run_test 160c "verify that changelog log catch the truncate event"
12465 remote_mds_nodsh && skip "remote MDS with nodsh"
12466 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
12467 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12468 [[ $MDS1_VERSION -ge $(version_code 2.7.60) ]] ||
12469 skip "Need MDS version at least 2.7.60"
12471 # Registration step
12472 changelog_register || error "changelog_register failed"
12474 mkdir -p $DIR/$tdir/migrate_dir
12475 changelog_clear 0 || error "changelog_clear failed"
12477 $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
12478 changelog_dump | tail -n 5
12479 local migrates=$(changelog_dump | grep -c "MIGRT")
12480 [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
12482 run_test 160d "verify that changelog log catch the migrate event"
12485 remote_mds_nodsh && skip "remote MDS with nodsh"
12488 changelog_register || error "changelog_register failed"
12490 # Delete a future user (expect fail)
12491 local MDT0=$(facet_svc $SINGLEMDS)
12492 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
12495 if [ $rc -eq 0 ]; then
12496 error "Deleted non-existant user cl77"
12497 elif [ $rc -ne 2 ]; then
12498 error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
12501 # Clear to a bad index (1 billion should be safe)
12502 $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
12505 if [ $rc -eq 0 ]; then
12506 error "Successfully cleared to invalid CL index"
12507 elif [ $rc -ne 22 ]; then
12508 error "changelog_clear failed with $rc, expected 22 (EINVAL)"
12511 run_test 160e "changelog negative testing (should return errors)"
12514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12515 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12516 skip "Need MDS version at least 2.10.56"
12518 local mdts=$(comma_list $(mdts_nodes))
12521 changelog_register || error "first changelog_register failed"
12522 changelog_register || error "second changelog_register failed"
12524 declare -A cl_user1
12525 declare -A cl_user2
12530 # generate some changelog records to accumulate on each MDT
12531 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12532 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12533 error "create $DIR/$tdir/$tfile failed"
12535 # check changelogs have been generated
12536 local nbcl=$(changelog_dump | wc -l)
12537 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12539 for param in "changelog_max_idle_time=10" \
12541 "changelog_min_gc_interval=2" \
12542 "changelog_min_free_cat_entries=3"; do
12543 local MDT0=$(facet_svc $SINGLEMDS)
12544 local var="${param%=*}"
12545 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12547 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12548 do_nodes $mdts $LCTL set_param mdd.*.$param
12551 # force cl_user2 to be idle (1st part)
12554 # simulate changelog catalog almost full
12555 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12556 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12558 for i in $(seq $MDSCOUNT); do
12559 cl_users=(${CL_USERS[mds$i]})
12560 cl_user1[mds$i]="${cl_users[0]}"
12561 cl_user2[mds$i]="${cl_users[1]}"
12563 [ -n "${cl_user1[mds$i]}" ] ||
12564 error "mds$i: no user registered"
12565 [ -n "${cl_user2[mds$i]}" ] ||
12566 error "mds$i: only ${cl_user2[mds$i]} is registered"
12568 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12569 [ -n "$user_rec1" ] ||
12570 error "mds$i: User ${cl_user1[mds$i]} not registered"
12571 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12572 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12573 [ -n "$user_rec2" ] ||
12574 error "mds$i: User ${cl_user1[mds$i]} not registered"
12575 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12576 "$user_rec1 + 2 == $user_rec2"
12577 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12578 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12579 "$user_rec1 + 2, but is $user_rec2"
12580 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12581 [ -n "$user_rec2" ] ||
12582 error "mds$i: User ${cl_user2[mds$i]} not registered"
12583 [ $user_rec1 == $user_rec2 ] ||
12584 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12585 "$user_rec1, but is $user_rec2"
12588 # force cl_user2 to be idle (2nd part) and to reach
12589 # changelog_max_idle_time
12592 # generate one more changelog to trigger fail_loc
12593 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12594 error "create $DIR/$tdir/${tfile}bis failed"
12596 # ensure gc thread is done
12597 for i in $(mdts_nodes); do
12599 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12600 error "$i: GC-thread not done"
12604 for i in $(seq $MDSCOUNT); do
12605 # check cl_user1 still registered
12606 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12607 error "mds$i: User ${cl_user1[mds$i]} not registered"
12608 # check cl_user2 unregistered
12609 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12610 error "mds$i: User ${cl_user2[mds$i]} still registered"
12612 # check changelogs are present and starting at $user_rec1 + 1
12613 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12614 [ -n "$user_rec1" ] ||
12615 error "mds$i: User ${cl_user1[mds$i]} not registered"
12616 first_rec=$($LFS changelog $(facet_svc mds$i) |
12617 awk '{ print $1; exit; }')
12619 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12620 [ $((user_rec1 + 1)) == $first_rec ] ||
12621 error "mds$i: first index should be $user_rec1 + 1, " \
12622 "but is $first_rec"
12625 run_test 160f "changelog garbage collect (timestamped users)"
12628 remote_mds_nodsh && skip "remote MDS with nodsh"
12629 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12630 skip "Need MDS version at least 2.10.56"
12632 local mdts=$(comma_list $(mdts_nodes))
12634 #define OBD_FAIL_TIME_IN_CHLOG_USER 0x1314
12635 do_nodes $mdts $LCTL set_param fail_loc=0x1314
12638 changelog_register || error "first changelog_register failed"
12639 changelog_register || error "second changelog_register failed"
12641 declare -A cl_user1
12642 declare -A cl_user2
12647 # generate some changelog records to accumulate on each MDT
12648 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12649 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12650 error "create $DIR/$tdir/$tfile failed"
12652 # check changelogs have been generated
12653 local nbcl=$(changelog_dump | wc -l)
12654 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12656 # reduce the max_idle_indexes value to make sure we exceed it
12657 max_ndx=$((nbcl / 2 - 1))
12659 for param in "changelog_max_idle_indexes=$max_ndx" \
12661 "changelog_min_gc_interval=2" \
12662 "changelog_min_free_cat_entries=3"; do
12663 local MDT0=$(facet_svc $SINGLEMDS)
12664 local var="${param%=*}"
12665 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12667 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12668 do_nodes $mdts $LCTL set_param mdd.*.$param ||
12669 error "unable to set mdd.*.$param"
12672 # simulate changelog catalog almost full
12673 #define OBD_FAIL_CAT_FREE_RECORDS 0x1313
12674 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
12676 for i in $(seq $MDSCOUNT); do
12677 cl_users=(${CL_USERS[mds$i]})
12678 cl_user1[mds$i]="${cl_users[0]}"
12679 cl_user2[mds$i]="${cl_users[1]}"
12681 [ -n "${cl_user1[mds$i]}" ] ||
12682 error "mds$i: no user registered"
12683 [ -n "${cl_user2[mds$i]}" ] ||
12684 error "mds$i: only ${cl_user1[mds$i]} is registered"
12686 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12687 [ -n "$user_rec1" ] ||
12688 error "mds$i: User ${cl_user1[mds$i]} not registered"
12689 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12690 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12691 [ -n "$user_rec2" ] ||
12692 error "mds$i: User ${cl_user1[mds$i]} not registered"
12693 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12694 "$user_rec1 + 2 == $user_rec2"
12695 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12696 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12697 "$user_rec1 + 2, but is $user_rec2"
12698 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12699 [ -n "$user_rec2" ] ||
12700 error "mds$i: User ${cl_user2[mds$i]} not registered"
12701 [ $user_rec1 == $user_rec2 ] ||
12702 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12703 "$user_rec1, but is $user_rec2"
12706 # ensure we are past the previous changelog_min_gc_interval set above
12709 # generate one more changelog to trigger fail_loc
12710 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12711 error "create $DIR/$tdir/${tfile}bis failed"
12713 # ensure gc thread is done
12714 for i in $(mdts_nodes); do
12716 "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
12717 error "$i: GC-thread not done"
12721 for i in $(seq $MDSCOUNT); do
12722 # check cl_user1 still registered
12723 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12724 error "mds$i: User ${cl_user1[mds$i]} not registered"
12725 # check cl_user2 unregistered
12726 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12727 error "mds$i: User ${cl_user2[mds$i]} still registered"
12729 # check changelogs are present and starting at $user_rec1 + 1
12730 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12731 [ -n "$user_rec1" ] ||
12732 error "mds$i: User ${cl_user1[mds$i]} not registered"
12733 first_rec=$($LFS changelog $(facet_svc mds$i) |
12734 awk '{ print $1; exit; }')
12736 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12737 [ $((user_rec1 + 1)) == $first_rec ] ||
12738 error "mds$i: first index should be $user_rec1 + 1, " \
12739 "but is $first_rec"
12742 run_test 160g "changelog garbage collect (old users)"
12745 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12746 [[ $MDS1_VERSION -ge $(version_code 2.10.56) ]] ||
12747 skip "Need MDS version at least 2.10.56"
12749 local mdts=$(comma_list $(mdts_nodes))
12752 changelog_register || error "first changelog_register failed"
12753 changelog_register || error "second changelog_register failed"
12755 declare -A cl_user1
12756 declare -A cl_user2
12761 # generate some changelog records to accumulate on each MDT
12762 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
12763 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12764 error "create $DIR/$tdir/$tfile failed"
12766 # check changelogs have been generated
12767 local nbcl=$(changelog_dump | wc -l)
12768 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12770 for param in "changelog_max_idle_time=10" \
12772 "changelog_min_gc_interval=2"; do
12773 local MDT0=$(facet_svc $SINGLEMDS)
12774 local var="${param%=*}"
12775 local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
12777 stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
12778 do_nodes $mdts $LCTL set_param mdd.*.$param
12781 # force cl_user2 to be idle (1st part)
12784 for i in $(seq $MDSCOUNT); do
12785 cl_users=(${CL_USERS[mds$i]})
12786 cl_user1[mds$i]="${cl_users[0]}"
12787 cl_user2[mds$i]="${cl_users[1]}"
12789 [ -n "${cl_user1[mds$i]}" ] ||
12790 error "mds$i: no user registered"
12791 [ -n "${cl_user2[mds$i]}" ] ||
12792 error "mds$i: only ${cl_user2[mds$i]} is registered"
12794 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12795 [ -n "$user_rec1" ] ||
12796 error "mds$i: User ${cl_user1[mds$i]} not registered"
12797 __changelog_clear mds$i ${cl_user1[mds$i]} +2
12798 user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12799 [ -n "$user_rec2" ] ||
12800 error "mds$i: User ${cl_user1[mds$i]} not registered"
12801 echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
12802 "$user_rec1 + 2 == $user_rec2"
12803 [ $((user_rec1 + 2)) == $user_rec2 ] ||
12804 error "mds$i: user ${cl_user1[mds$i]} index expected " \
12805 "$user_rec1 + 2, but is $user_rec2"
12806 user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
12807 [ -n "$user_rec2" ] ||
12808 error "mds$i: User ${cl_user2[mds$i]} not registered"
12809 [ $user_rec1 == $user_rec2 ] ||
12810 error "mds$i: user ${cl_user2[mds$i]} index expected " \
12811 "$user_rec1, but is $user_rec2"
12814 # force cl_user2 to be idle (2nd part) and to reach
12815 # changelog_max_idle_time
12818 # force each GC-thread start and block then
12819 # one per MDT/MDD, set fail_val accordingly
12820 #define OBD_FAIL_FORCE_GC_THREAD 0x1316
12821 do_nodes $mdts $LCTL set_param fail_loc=0x1316
12823 # generate more changelogs to trigger fail_loc
12824 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12825 error "create $DIR/$tdir/${tfile}bis failed"
12827 # stop MDT to stop GC-thread, should be done in back-ground as it will
12828 # block waiting for the thread to be released and exit
12829 declare -A stop_pids
12830 for i in $(seq $MDSCOUNT); do
12832 stop_pids[mds$i]=$!
12835 for i in $(mdts_nodes); do
12838 local facets=$(facets_up_on_host $i)
12840 for facet in ${facets//,/ }; do
12841 if [[ $facet == mds* ]]; then
12845 # ensure each MDS's gc threads are still present and all in "R"
12846 # state (OBD_FAIL_FORCE_GC_THREAD effect!)
12847 [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
12848 error "$i: expected $nb GC-thread"
12850 "ps -C chlg_gc_thread -o state --no-headers | uniq" \
12852 error "$i: GC-thread not found in R-state"
12853 # check umounts of each MDT on MDS have reached kthread_stop()
12854 [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
12855 error "$i: expected $nb umount"
12857 "ps -C umount -o state --no-headers | uniq" "D" 20 ||
12858 error "$i: umount not found in D-state"
12861 # release all GC-threads
12862 do_nodes $mdts $LCTL set_param fail_loc=0
12864 # wait for MDT stop to complete
12865 for i in $(seq $MDSCOUNT); do
12866 wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
12870 # may try to check if any orphan changelog records are present
12871 # via ldiskfs/zfs and llog_reader...
12873 # re-start/mount MDTs
12874 for i in $(seq $MDSCOUNT); do
12875 start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
12876 error "Fail to start mds$i"
12880 for i in $(seq $MDSCOUNT); do
12881 # check cl_user1 still registered
12882 changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
12883 error "mds$i: User ${cl_user1[mds$i]} not registered"
12884 # check cl_user2 unregistered
12885 changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
12886 error "mds$i: User ${cl_user2[mds$i]} still registered"
12888 # check changelogs are present and starting at $user_rec1 + 1
12889 user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
12890 [ -n "$user_rec1" ] ||
12891 error "mds$i: User ${cl_user1[mds$i]} not registered"
12892 first_rec=$($LFS changelog $(facet_svc mds$i) |
12893 awk '{ print $1; exit; }')
12895 echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
12896 [ $((user_rec1 + 1)) == $first_rec ] ||
12897 error "mds$i: first index should be $user_rec1 + 1, " \
12898 "but is $first_rec"
12901 run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
12906 local mdts=$(comma_list $(mdts_nodes))
12908 changelog_register || error "first changelog_register failed"
12910 # generate some changelog records to accumulate on each MDT
12911 test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
12912 createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
12913 error "create $DIR/$tdir/$tfile failed"
12915 # check changelogs have been generated
12916 local nbcl=$(changelog_dump | wc -l)
12917 [[ $nbcl -eq 0 ]] && error "no changelogs found"
12919 # simulate race between register and unregister
12920 # XXX as fail_loc is set per-MDS, with DNE configs the race
12921 # simulation will only occur for one MDT per MDS and for the
12922 # others the normal race scenario will take place
12923 #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE 0x1315
12924 do_nodes $mdts $LCTL set_param fail_loc=0x10001315
12925 do_nodes $mdts $LCTL set_param fail_val=1
12927 # unregister 1st user
12928 changelog_deregister &
12930 # wait some time for deregister work to reach race rdv
12932 # register 2nd user
12933 changelog_register || error "2nd user register failed"
12935 wait $pid1 || error "1st user deregister failed"
12939 declare -A LAST_REC
12940 for i in $(seq $MDSCOUNT); do
12941 if changelog_users mds$i | grep "^cl"; then
12942 # make sure new records are added with one user present
12943 LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
12944 awk '/^current.index:/ { print $NF }')
12946 error "mds$i has no user registered"
12950 # generate more changelog records to accumulate on each MDT
12951 createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
12952 error "create $DIR/$tdir/${tfile}bis failed"
12954 for i in $(seq $MDSCOUNT); do
12955 last_rec=$(changelog_users $SINGLEMDS |
12956 awk '/^current.index:/ { print $NF }')
12957 echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
12958 [ $last_rec != ${LAST_REC[mds$i]} ] ||
12959 error "changelogs are off on mds$i"
12962 run_test 160i "changelog user register/unregister race"
12965 [ $PARALLEL == "yes" ] && skip "skip parallel run"
12967 test_mkdir -c1 $DIR/$tdir
12968 cp /etc/hosts $DIR/$tdir/$tfile
12969 test_mkdir -c1 $DIR/$tdir/foo1
12970 test_mkdir -c1 $DIR/$tdir/foo2
12971 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
12972 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
12973 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
12974 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
12975 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
12976 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
12977 $LFS fid2path $DIR $FID
12978 error "bad link ea"
12981 rm $DIR/$tdir/foo2/zachary
12983 rm $DIR/$tdir/foo2/thor
12985 rm $DIR/$tdir/$tfile
12987 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
12988 [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
12989 { $LFS fid2path $DIR $FID; error "bad link rename"; }
12990 rm $DIR/$tdir/foo2/maggie
12993 local longname=$tfile.avg_len_is_thirty_two_
12994 stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
12995 error_noexit 'failed to unlink many hardlinks'" EXIT
12996 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
12997 error "failed to hardlink many files"
12998 links=$($LFS fid2path $DIR $FID | wc -l)
12999 echo -n "${links}/1000 links in link EA"
13000 [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
13002 run_test 161a "link ea sanity"
13005 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13006 [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
13009 local remote_dir=$DIR/$tdir/remote_dir
13011 mkdir -p $DIR/$tdir
13012 $LFS mkdir -i $MDTIDX $remote_dir ||
13013 error "create remote directory failed"
13015 cp /etc/hosts $remote_dir/$tfile
13016 mkdir -p $remote_dir/foo1
13017 mkdir -p $remote_dir/foo2
13018 ln $remote_dir/$tfile $remote_dir/foo1/sofia
13019 ln $remote_dir/$tfile $remote_dir/foo2/zachary
13020 ln $remote_dir/$tfile $remote_dir/foo1/luna
13021 ln $remote_dir/$tfile $remote_dir/foo2/thor
13023 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
13025 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
13026 $LFS fid2path $DIR $FID
13027 error "bad link ea"
13030 rm $remote_dir/foo2/zachary
13032 rm $remote_dir/foo2/thor
13034 rm $remote_dir/$tfile
13036 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
13037 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
13038 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
13039 $LFS fid2path $DIR $FID
13040 error "bad link rename"
13042 rm $remote_dir/foo2/maggie
13045 local longname=filename_avg_len_is_thirty_two_
13046 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
13047 error "failed to hardlink many files"
13048 links=$($LFS fid2path $DIR $FID | wc -l)
13049 echo -n "${links}/1000 links in link EA"
13050 [[ ${links} -gt 60 ]] ||
13051 error "expected at least 60 links in link EA"
13052 unlinkmany $remote_dir/foo2/$longname 1000 ||
13053 error "failed to unlink many hardlinks"
13055 run_test 161b "link ea sanity under remote directory"
13058 remote_mds_nodsh && skip "remote MDS with nodsh"
13059 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13060 [[ $MDS1_VERSION -lt $(version_code 2.1.5) ]] &&
13061 skip "Need MDS version at least 2.1.5"
13063 # define CLF_RENAME_LAST 0x0001
13064 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
13065 changelog_register || error "changelog_register failed"
13068 test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
13069 touch $DIR/$tdir/foo_161c
13070 touch $DIR/$tdir/bar_161c
13071 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13072 changelog_dump | grep RENME | tail -n 5
13073 local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13074 changelog_clear 0 || error "changelog_clear failed"
13075 if [ x$flags != "x0x1" ]; then
13076 error "flag $flags is not 0x1"
13079 echo "rename overwrite target with nlink = 1, changelog flags=$flags"
13080 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
13081 touch $DIR/$tdir/foo_161c
13082 touch $DIR/$tdir/bar_161c
13083 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13084 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
13085 changelog_dump | grep RENME | tail -n 5
13086 flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
13087 changelog_clear 0 || error "changelog_clear failed"
13088 if [ x$flags != "x0x0" ]; then
13089 error "flag $flags is not 0x0"
13091 echo "rename overwrite a target having nlink > 1," \
13092 "changelog record has flags of $flags"
13094 # rename doesn't overwrite a target (changelog flag 0x0)
13095 touch $DIR/$tdir/foo_161c
13096 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
13097 changelog_dump | grep RENME | tail -n 5
13098 flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
13099 changelog_clear 0 || error "changelog_clear failed"
13100 if [ x$flags != "x0x0" ]; then
13101 error "flag $flags is not 0x0"
13103 echo "rename doesn't overwrite a target," \
13104 "changelog record has flags of $flags"
13106 # define CLF_UNLINK_LAST 0x0001
13107 # unlink a file having nlink = 1 (changelog flag 0x1)
13108 rm -f $DIR/$tdir/foo2_161c
13109 changelog_dump | grep UNLNK | tail -n 5
13110 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13111 changelog_clear 0 || error "changelog_clear failed"
13112 if [ x$flags != "x0x1" ]; then
13113 error "flag $flags is not 0x1"
13115 echo "unlink a file having nlink = 1," \
13116 "changelog record has flags of $flags"
13118 # unlink a file having nlink > 1 (changelog flag 0x0)
13119 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
13120 rm -f $DIR/$tdir/foobar_161c
13121 changelog_dump | grep UNLNK | tail -n 5
13122 flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
13123 changelog_clear 0 || error "changelog_clear failed"
13124 if [ x$flags != "x0x0" ]; then
13125 error "flag $flags is not 0x0"
13127 echo "unlink a file having nlink > 1, changelog record flags '$flags'"
13129 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
13132 remote_mds_nodsh && skip "remote MDS with nodsh"
13137 changelog_register || error "changelog_register failed"
13139 # work in a standalone dir to avoid locking on $DIR/$MOUNT to
13140 # interfer with $MOUNT/.lustre/fid/ access
13142 [[ $? -eq 0 ]] || error "mkdir failed"
13144 #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
13145 $LCTL set_param fail_loc=0x8000140c
13147 $LCTL set_param fail_val=5
13150 echo foofoo > $DIR/$tdir/$tfile &
13153 # wait for create to be delayed
13157 [[ $? -eq 0 ]] || error "create should be blocked"
13159 local tempfile=$(mktemp)
13160 fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
13161 cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
13162 # some delay may occur during ChangeLog publishing and file read just
13163 # above, that could allow file write to happen finally
13164 [[ -s $tempfile ]] && echo "file should be empty"
13166 $LCTL set_param fail_loc=0
13169 [[ $? -eq 0 ]] || error "create failed"
13171 run_test 161d "create with concurrent .lustre/fid access"
13174 local expected="$1"
13179 path=$($LFS fid2path "$@")
13182 if [ $rc -ne 0 ]; then
13183 error "path looked up of '$expected' failed: rc=$rc"
13184 elif [ "$path" != "$expected" ]; then
13185 error "path looked up '$path' instead of '$expected'"
13187 echo "FID '$fid' resolves to path '$path' as expected"
13191 test_162a() { # was test_162
13192 test_mkdir -p -c1 $DIR/$tdir/d2
13193 touch $DIR/$tdir/d2/$tfile
13194 touch $DIR/$tdir/d2/x1
13195 touch $DIR/$tdir/d2/x2
13196 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
13197 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
13199 local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
13200 check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
13203 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
13204 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
13205 check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
13207 # softlink to wrong file
13208 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
13209 fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
13210 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME "$fid" --link 0
13213 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
13214 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
13215 fid=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
13216 # fid2path dir/fsname should both work
13217 check_path "$tdir/d2/a/b/c/new_file" $FSNAME "$fid" --link 1
13218 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR "$fid" --link 0
13220 # hardlink count: check that there are 2 links
13221 local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
13222 [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
13224 # hardlink indexing: remove the first link
13225 rm $DIR/$tdir/d2/p/q/r/hlink
13226 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
13228 run_test 162a "path lookup sanity"
13231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13232 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
13235 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
13236 error "create striped dir failed"
13238 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
13239 tail -n 1 | awk '{print $2}')
13240 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
13242 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
13243 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
13246 for ((i=0;i<5;i++)); do
13247 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
13248 error "get fid for f$i failed"
13249 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
13251 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
13252 error "get fid for d$i failed"
13253 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
13258 run_test 162b "striped directory path lookup sanity"
13260 # LU-4239: Verify fid2path works with paths 100 or more directories deep
13262 [[ $MDS1_VERSION -lt $(version_code 2.7.51) ]] &&
13263 skip "Need MDS version at least 2.7.51"
13265 local lpath=$tdir.local
13266 local rpath=$tdir.remote
13268 test_mkdir $DIR/$lpath
13269 test_mkdir $DIR/$rpath
13271 for ((i = 0; i <= 101; i++)); do
13274 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
13275 error "get fid for local directory $DIR/$lpath failed"
13276 check_path "$DIR/$lpath" $MOUNT $FID --link 0
13279 test_mkdir $DIR/$rpath
13280 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
13281 error "get fid for remote directory $DIR/$rpath failed"
13282 check_path "$DIR/$rpath" $MOUNT $FID --link 0
13287 run_test 162c "fid2path works with paths 100 or more directories deep"
13290 # do directio so as not to populate the page cache
13291 log "creating a 10 Mb file"
13292 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
13293 log "starting reads"
13294 dd if=$DIR/$tfile of=/dev/null bs=4096 &
13295 log "truncating the file"
13296 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
13298 kill %+ || true # reads might have finished
13299 echo "wait until dd is finished"
13301 log "removing the temporary file"
13302 rm -rf $DIR/$tfile || error "tmp file removal failed"
13304 run_test 169 "parallel read and truncate should not deadlock"
13307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13309 $LCTL clear # bug 18514
13310 $LCTL debug_daemon start $TMP/${tfile}_log_good
13312 $LCTL debug_daemon stop
13313 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
13314 error "sed failed to read log_good"
13316 $LCTL debug_daemon start $TMP/${tfile}_log_good
13318 $LCTL debug_daemon stop
13320 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
13321 error "lctl df log_bad failed"
13323 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13324 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13326 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
13327 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
13329 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
13330 error "bad_line good_line1 good_line2 are empty"
13332 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13333 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
13334 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
13336 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
13337 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
13338 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
13340 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
13341 error "bad_line_new good_line_new are empty"
13343 local expected_good=$((good_line1 + good_line2*2))
13345 rm -f $TMP/${tfile}*
13346 # LU-231, short malformed line may not be counted into bad lines
13347 if [ $bad_line -ne $bad_line_new ] &&
13348 [ $bad_line -ne $((bad_line_new - 1)) ]; then
13349 error "expected $bad_line bad lines, but got $bad_line_new"
13353 if [ $expected_good -ne $good_line_new ]; then
13354 error "expected $expected_good good lines, but got $good_line_new"
13359 run_test 170 "test lctl df to handle corrupted log ====================="
13361 test_171() { # bug20592
13362 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13364 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
13365 $LCTL set_param fail_loc=0x50e
13366 $LCTL set_param fail_val=3000
13367 multiop_bg_pause $DIR/$tfile O_s || true
13369 kill -USR1 $MULTIPID
13373 if dmesg | grep "recursive fault"; then
13374 error "caught a recursive fault"
13376 $LCTL set_param fail_loc=0
13379 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
13381 # it would be good to share it with obdfilter-survey/iokit-libecho code
13382 setup_obdecho_osc () {
13385 local obdfilter_name=$2
13386 echo "Creating new osc for $obdfilter_name on $ost_nid"
13387 # make sure we can find loopback nid
13388 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
13390 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
13391 ${obdfilter_name}_osc_UUID || rc=2; }
13392 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
13393 ${obdfilter_name}_UUID $ost_nid || rc=3; }
13397 cleanup_obdecho_osc () {
13398 local obdfilter_name=$1
13399 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
13400 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
13407 local pages=${3:-64}
13412 local obd_size=$(get_obd_size $node $OBD)
13413 local page_size=$(get_page_size $node)
13414 if [[ -n "$obd_size" ]]; then
13415 local new_count=$((obd_size / (pages * page_size / 1024)))
13416 [[ $new_count -ge $count ]] || count=$new_count
13419 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
13420 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
13422 if [ $rc -eq 0 ]; then
13423 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
13424 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
13426 echo "New object id is $id"
13427 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
13429 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
13430 "test_brw $count w v $pages $id" || rc=4; }
13431 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
13433 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
13434 "cleanup" || rc=5; }
13435 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
13436 "detach" || rc=6; }
13437 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
13442 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13444 if ! module_loaded obdecho; then
13445 load_module obdecho/obdecho &&
13446 stack_trap "rmmod obdecho" EXIT ||
13447 error "unable to load obdecho on client"
13450 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
13451 local host=$($LCTL get_param -n osc.$osc.import |
13452 awk '/current_connection:/ { print $2 }' )
13453 local target=$($LCTL get_param -n osc.$osc.import |
13454 awk '/target:/ { print $2 }' )
13455 target=${target%_UUID}
13457 if [ -n "$target" ]; then
13458 setup_obdecho_osc $host $target &&
13459 stack_trap "cleanup_obdecho_osc $target" EXIT ||
13460 { error "obdecho setup failed with $?"; return; }
13462 obdecho_test ${target}_osc client ||
13463 error "obdecho_test failed on ${target}_osc"
13465 $LCTL get_param osc.$osc.import
13466 error "there is no osc.$osc.import target"
13469 run_test 180a "test obdecho on osc"
13472 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13473 remote_ost_nodsh && skip "remote OST with nodsh"
13475 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13476 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13477 error "failed to load module obdecho"
13479 local target=$(do_facet ost1 $LCTL dl |
13480 awk '/obdfilter/ { print $4; exit; }')
13482 if [ -n "$target" ]; then
13483 obdecho_test $target ost1 || error "obdecho_test failed with $?"
13485 do_facet ost1 $LCTL dl
13486 error "there is no obdfilter target on ost1"
13489 run_test 180b "test obdecho directly on obdfilter"
13491 test_180c() { # LU-2598
13492 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13493 remote_ost_nodsh && skip "remote OST with nodsh"
13494 [[ $MDS1_VERSION -lt $(version_code 2.4.0) ]] &&
13495 skip "Need MDS version at least 2.4.0"
13497 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
13498 stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
13499 error "failed to load module obdecho"
13501 local target=$(do_facet ost1 $LCTL dl |
13502 awk '/obdfilter/ { print $4; exit; }')
13504 if [ -n "$target" ]; then
13505 local pages=16384 # 64MB bulk I/O RPC size
13507 obdecho_test "$target" ost1 "$pages" ||
13508 error "obdecho_test with pages=$pages failed with $?"
13510 do_facet ost1 $LCTL dl
13511 error "there is no obdfilter target on ost1"
13514 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
13516 test_181() { # bug 22177
13517 test_mkdir $DIR/$tdir
13518 # create enough files to index the directory
13519 createmany -o $DIR/$tdir/foobar 4000
13520 # print attributes for debug purpose
13523 multiop_bg_pause $DIR/$tdir D_Sc || return 1
13525 # remove the files & current working dir
13526 unlinkmany $DIR/$tdir/foobar 4000
13528 kill -USR1 $MULTIPID
13530 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
13533 run_test 181 "Test open-unlinked dir ========================"
13539 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13541 $LCTL set_param mdc.*.rpc_stats=clear
13543 for (( i = 0; i < $tcount; i++ )) ; do
13544 mkdir $DIR/$tdir/$i
13547 for (( i = 0; i < $tcount; i++ )) ; do
13548 createmany -o $DIR/$tdir/$i/f- $fcount &
13552 for (( i = 0; i < $tcount; i++ )) ; do
13553 unlinkmany $DIR/$tdir/$i/f- $fcount &
13557 $LCTL get_param mdc.*.rpc_stats
13561 run_test 182 "Test parallel modify metadata operations ================"
13563 test_183() { # LU-2275
13564 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13565 remote_mds_nodsh && skip "remote MDS with nodsh"
13566 [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
13567 skip "Need MDS version at least 2.3.56"
13569 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13570 echo aaa > $DIR/$tdir/$tfile
13572 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
13573 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
13575 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
13576 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
13578 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
13580 # Flush negative dentry cache
13581 touch $DIR/$tdir/$tfile
13583 # We are not checking for any leaked references here, they'll
13584 # become evident next time we do cleanup with module unload.
13587 run_test 183 "No crash or request leak in case of strange dispositions ========"
13589 # test suite 184 is for LU-2016, LU-2017
13591 check_swap_layouts_support
13593 dir0=$DIR/$tdir/$testnum
13594 test_mkdir -p -c1 $dir0
13599 $SETSTRIPE -c1 $file1
13601 $SETSTRIPE -c2 $file2
13603 gen1=$($GETSTRIPE -g $file1)
13604 gen2=$($GETSTRIPE -g $file2)
13606 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
13607 gen=$($GETSTRIPE -g $file1)
13608 [[ $gen1 != $gen ]] ||
13609 "Layout generation on $file1 does not change"
13610 gen=$($GETSTRIPE -g $file2)
13611 [[ $gen2 != $gen ]] ||
13612 "Layout generation on $file2 does not change"
13614 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
13615 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
13617 lfsck_verify_pfid $file1 $file2 || error "PFID are not transferred"
13619 run_test 184a "Basic layout swap"
13622 check_swap_layouts_support
13624 dir0=$DIR/$tdir/$testnum
13625 mkdir -p $dir0 || error "creating dir $dir0"
13632 $SETSTRIPE -c1 $file1
13633 $SETSTRIPE -c2 $file2
13634 $SETSTRIPE -c1 $file3
13635 chown $RUNAS_ID $file3
13636 gen1=$($GETSTRIPE -g $file1)
13637 gen2=$($GETSTRIPE -g $file2)
13639 $LFS swap_layouts $dir1 $dir2 &&
13640 error "swap of directories layouts should fail"
13641 $LFS swap_layouts $dir1 $file1 &&
13642 error "swap of directory and file layouts should fail"
13643 $RUNAS $LFS swap_layouts $file1 $file2 &&
13644 error "swap of file we cannot write should fail"
13645 $LFS swap_layouts $file1 $file3 &&
13646 error "swap of file with different owner should fail"
13647 /bin/true # to clear error code
13649 run_test 184b "Forbidden layout swap (will generate errors)"
13652 local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
13653 [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
13654 check_swap_layouts_support
13656 local dir0=$DIR/$tdir/$testnum
13657 mkdir -p $dir0 || error "creating dir $dir0"
13659 local ref1=$dir0/ref1
13660 local ref2=$dir0/ref2
13661 local file1=$dir0/file1
13662 local file2=$dir0/file2
13663 # create a file large enough for the concurrent test
13664 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
13665 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
13666 echo "ref file size: ref1($(stat -c %s $ref1))," \
13667 "ref2($(stat -c %s $ref2))"
13670 dd if=$ref1 of=$file1 bs=16k &
13673 # Make sure dd starts to copy file
13674 while [ ! -f $file1 ]; do sleep 0.1; done
13676 $LFS swap_layouts $file1 $file2
13679 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
13680 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
13682 # how many bytes copied before swapping layout
13683 local copied=$(stat -c %s $file2)
13684 local remaining=$(stat -c %s $ref1)
13685 remaining=$((remaining - copied))
13686 echo "Copied $copied bytes before swapping layout..."
13688 cmp -n $copied $file1 $ref2 | grep differ &&
13689 error "Content mismatch [0, $copied) of ref2 and file1"
13690 cmp -n $copied $file2 $ref1 ||
13691 error "Content mismatch [0, $copied) of ref1 and file2"
13692 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
13693 error "Content mismatch [$copied, EOF) of ref1 and file1"
13696 rm -f $ref1 $ref2 $file1 $file2
13698 run_test 184c "Concurrent write and layout swap"
13701 check_swap_layouts_support
13702 [ -z "$(which getfattr 2>/dev/null)" ] &&
13703 skip_env "no getfattr command"
13705 local file1=$DIR/$tdir/$tfile-1
13706 local file2=$DIR/$tdir/$tfile-2
13707 local file3=$DIR/$tdir/$tfile-3
13711 mkdir -p $DIR/$tdir
13712 touch $file1 || error "create $file1 failed"
13713 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13714 error "create $file2 failed"
13715 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13716 error "create $file3 failed"
13717 lovea1=$(get_layout_param $file1)
13719 $LFS swap_layouts $file2 $file3 ||
13720 error "swap $file2 $file3 layouts failed"
13721 $LFS swap_layouts $file1 $file2 ||
13722 error "swap $file1 $file2 layouts failed"
13724 lovea2=$(get_layout_param $file2)
13727 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
13729 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13730 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
13732 run_test 184d "allow stripeless layouts swap"
13735 [[ $MDS1_VERSION -ge $(version_code 2.6.94) ]] ||
13736 skip "Need MDS version at least 2.6.94"
13737 check_swap_layouts_support
13738 [ -z "$(which getfattr 2>/dev/null)" ] &&
13739 skip_env "no getfattr command"
13741 local file1=$DIR/$tdir/$tfile-1
13742 local file2=$DIR/$tdir/$tfile-2
13743 local file3=$DIR/$tdir/$tfile-3
13746 mkdir -p $DIR/$tdir
13747 touch $file1 || error "create $file1 failed"
13748 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
13749 error "create $file2 failed"
13750 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
13751 error "create $file3 failed"
13753 $LFS swap_layouts $file1 $file2 ||
13754 error "swap $file1 $file2 layouts failed"
13756 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
13757 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
13759 echo 123 > $file1 || error "Should be able to write into $file1"
13761 $LFS swap_layouts $file1 $file3 ||
13762 error "swap $file1 $file3 layouts failed"
13764 echo 123 > $file1 || error "Should be able to write into $file1"
13766 rm -rf $file1 $file2 $file3
13768 run_test 184e "Recreate layout after stripeless layout swaps"
13771 # Create a file with name longer than sizeof(struct stat) ==
13772 # 144 to see if we can get chars from the file name to appear
13773 # in the returned striping. Note that 'f' == 0x66.
13774 local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
13776 mkdir -p $DIR/$tdir
13777 mcreate $DIR/$tdir/$file
13778 if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
13779 error "IOC_MDC_GETFILEINFO returned garbage striping"
13782 run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
13784 test_185() { # LU-2441
13785 # LU-3553 - no volatile file support in old servers
13786 [[ $MDS1_VERSION -ge $(version_code 2.3.60) ]] ||
13787 skip "Need MDS version at least 2.3.60"
13789 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
13790 touch $DIR/$tdir/spoo
13791 local mtime1=$(stat -c "%Y" $DIR/$tdir)
13792 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
13793 error "cannot create/write a volatile file"
13794 [ "$FILESET" == "" ] &&
13795 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
13796 error "FID is still valid after close"
13798 multiop_bg_pause $DIR/$tdir vVw4096_c
13805 # assume that the next FID for this client is sequential, since stdout
13806 # is unfortunately eaten by multiop_bg_pause
13807 local n=$((${fidv[1]} + 1))
13808 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
13809 if [ "$FILESET" == "" ]; then
13810 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
13811 error "FID is missing before close"
13813 kill -USR1 $multi_pid
13814 # 1 second delay, so if mtime change we will see it
13816 local mtime2=$(stat -c "%Y" $DIR/$tdir)
13817 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
13819 run_test 185 "Volatile file support"
13822 remote_mds_nodsh && skip "remote MDS with nodsh"
13823 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
13824 skip "Need MDS version at least 2.3.0"
13826 local dir0=$DIR/$tdir/$testnum
13827 mkdir -p $dir0 || error "creating dir $dir0"
13829 local file=$dir0/file1
13830 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
13831 local dv1=$($LFS data_version $file)
13832 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
13833 local dv2=$($LFS data_version $file)
13834 [[ $dv1 != $dv2 ]] ||
13835 error "data version did not change on write $dv1 == $dv2"
13840 run_test 187a "Test data version change"
13843 remote_mds_nodsh && skip "remote MDS with nodsh"
13844 [ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&
13845 skip "Need MDS version at least 2.3.0"
13847 local dir0=$DIR/$tdir/$testnum
13848 mkdir -p $dir0 || error "creating dir $dir0"
13850 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
13851 [[ ${DV[0]} != ${DV[1]} ]] ||
13852 error "data version did not change on write"\
13853 " ${DV[0]} == ${DV[1]}"
13858 run_test 187b "Test data version change on volatile file"
13861 [ $PARALLEL == "yes" ] && skip "skip parallel run"
13862 remote_mgs_nodsh && skip "remote MGS with nodsh"
13863 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
13865 local POOL=${POOL:-cea1}
13866 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
13867 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
13870 local last_ost=$(($OSTCOUNT - 1))
13872 local ost_list=$(seq $first_ost $ost_step $last_ost)
13873 local ost_range="$first_ost $last_ost $ost_step"
13874 local test_path=$POOL_ROOT/$POOL_DIR_NAME
13875 local file_dir=$POOL_ROOT/file_tst
13876 local subdir=$test_path/subdir
13879 if ! combined_mgs_mds ; then
13884 # former test_200a test_200b
13885 pool_add $POOL || { rc=$? ; break; }
13886 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
13887 # former test_200c test_200d
13888 mkdir -p $test_path
13889 pool_set_dir $POOL $test_path || { rc=$? ; break; }
13890 pool_check_dir $POOL $test_path || { rc=$? ; break; }
13892 pool_check_dir $POOL $subdir || { rc=$? ; break; }
13893 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
13894 || { rc=$? ; break; }
13895 # former test_200e test_200f
13896 local files=$((OSTCOUNT*3))
13897 pool_alloc_files $POOL $test_path $files "$ost_list" \
13898 || { rc=$? ; break; }
13899 pool_create_files $POOL $file_dir $files "$ost_list" \
13900 || { rc=$? ; break; }
13901 # former test_200g test_200h
13902 pool_lfs_df $POOL || { rc=$? ; break; }
13903 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
13905 # former test_201a test_201b test_201c
13906 pool_remove_first_target $POOL || { rc=$? ; break; }
13908 local f=$test_path/$tfile
13909 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
13910 pool_remove $POOL $f || { rc=$? ; break; }
13916 if ! combined_mgs_mds ; then
13921 run_test 200 "OST pools"
13923 # usage: default_attr <count | size | offset>
13925 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
13928 # usage: check_default_stripe_attr
13929 check_default_stripe_attr() {
13930 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
13933 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
13935 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
13939 error "unknown getstripe attr '$1'"
13942 [ $ACTUAL == $EXPECTED ] ||
13943 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
13947 test_mkdir $DIR/$tdir
13948 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
13950 check_default_stripe_attr --stripe-count
13951 check_default_stripe_attr --stripe-size
13952 check_default_stripe_attr --stripe-index
13954 run_test 204a "Print default stripe attributes"
13957 test_mkdir $DIR/$tdir
13958 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13960 check_default_stripe_attr --stripe-size
13961 check_default_stripe_attr --stripe-index
13963 run_test 204b "Print default stripe size and offset"
13966 test_mkdir $DIR/$tdir
13967 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
13969 check_default_stripe_attr --stripe-count
13970 check_default_stripe_attr --stripe-index
13972 run_test 204c "Print default stripe count and offset"
13975 test_mkdir $DIR/$tdir
13976 $SETSTRIPE --stripe-index 0 $DIR/$tdir
13978 check_default_stripe_attr --stripe-count
13979 check_default_stripe_attr --stripe-size
13981 run_test 204d "Print default stripe count and size"
13984 test_mkdir $DIR/$tdir
13985 $SETSTRIPE -d $DIR/$tdir
13987 check_default_stripe_attr --stripe-count --raw
13988 check_default_stripe_attr --stripe-size --raw
13989 check_default_stripe_attr --stripe-index --raw
13991 run_test 204e "Print raw stripe attributes"
13994 test_mkdir $DIR/$tdir
13995 $SETSTRIPE --stripe-count 1 $DIR/$tdir
13997 check_default_stripe_attr --stripe-size --raw
13998 check_default_stripe_attr --stripe-index --raw
14000 run_test 204f "Print raw stripe size and offset"
14003 test_mkdir $DIR/$tdir
14004 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
14006 check_default_stripe_attr --stripe-count --raw
14007 check_default_stripe_attr --stripe-index --raw
14009 run_test 204g "Print raw stripe count and offset"
14012 test_mkdir $DIR/$tdir
14013 $SETSTRIPE --stripe-index 0 $DIR/$tdir
14015 check_default_stripe_attr --stripe-count --raw
14016 check_default_stripe_attr --stripe-size --raw
14018 run_test 204h "Print raw stripe count and size"
14020 # Figure out which job scheduler is being used, if any,
14021 # or use a fake one
14022 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
14023 JOBENV=SLURM_JOB_ID
14024 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
14026 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
14028 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
14029 JOBENV=LOADL_STEP_ID
14030 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
14033 $LCTL list_param jobid_name > /dev/null 2>&1
14034 if [ $? -eq 0 ]; then
14040 LUSTRE_JOBID_SIZE=31 # plus NUL terminator
14042 verify_jobstats() {
14047 # we don't really need to clear the stats for this test to work, since each
14048 # command has a unique jobid, but it makes debugging easier if needed.
14049 # for facet in $facets; do
14050 # local dev=$(convert_facet2label $facet)
14051 # # clear old jobstats
14052 # do_facet $facet lctl set_param *.$dev.job_stats="clear"
14055 # use a new JobID for each test, or we might see an old one
14056 [ "$JOBENV" = "FAKE_JOBID" ] &&
14057 FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
14059 JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
14061 [ "$JOBENV" = "nodelocal" ] && {
14062 FAKE_JOBID=id.$testnum.%e.$RANDOM
14063 $LCTL set_param jobid_name=$FAKE_JOBID
14064 JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
14067 log "Test: ${cmd[*]}"
14068 log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
14070 if [ $JOBENV = "FAKE_JOBID" ]; then
14071 FAKE_JOBID=$JOBVAL ${cmd[*]}
14076 # all files are created on OST0000
14077 for facet in $facets; do
14078 local stats="*.$(convert_facet2label $facet).job_stats"
14080 # strip out libtool wrappers for in-tree executables
14081 if [ $(do_facet $facet lctl get_param $stats |
14082 sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
14083 do_facet $facet lctl get_param $stats
14084 error "No jobstats for $JOBVAL found on $facet::$stats"
14090 local new_jobenv=$1
14092 set_persistent_param_and_check client "jobid_var" \
14093 "$FSNAME.sys.jobid_var" $new_jobenv
14096 test_205() { # Job stats
14097 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14098 [[ $MDS1_VERSION -ge $(version_code 2.7.1) ]] ||
14099 skip "Need MDS version with at least 2.7.1"
14100 remote_mgs_nodsh && skip "remote MGS with nodsh"
14101 remote_mds_nodsh && skip "remote MDS with nodsh"
14102 remote_ost_nodsh && skip "remote OST with nodsh"
14103 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
14104 skip "Server doesn't support jobstats"
14105 [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
14107 local old_jobenv=$($LCTL get_param -n jobid_var)
14108 [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
14110 if [[ $PERM_CMD = *"set_param -P"* ]]; then
14111 stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
14113 stack_trap "do_facet mgs $PERM_CMD \
14114 $FSNAME.sys.jobid_var=$old_jobenv" EXIT
14118 local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
14119 mdt.*.job_cleanup_interval | head -n 1)
14120 local new_interval=5
14121 do_facet $SINGLEMDS \
14122 $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
14123 stack_trap "do_facet $SINGLEMDS \
14124 $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
14125 local start=$SECONDS
14129 cmd="mkdir $DIR/$tdir"
14130 verify_jobstats "$cmd" "$SINGLEMDS"
14132 cmd="rmdir $DIR/$tdir"
14133 verify_jobstats "$cmd" "$SINGLEMDS"
14134 # mkdir on secondary MDT
14135 if [ $MDSCOUNT -gt 1 ]; then
14136 cmd="lfs mkdir -i 1 $DIR/$tdir.remote"
14137 verify_jobstats "$cmd" "mds2"
14140 cmd="mknod $DIR/$tfile c 1 3"
14141 verify_jobstats "$cmd" "$SINGLEMDS"
14143 cmd="rm -f $DIR/$tfile"
14144 verify_jobstats "$cmd" "$SINGLEMDS"
14145 # create all files on OST0000 so verify_jobstats can find OST stats
14147 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
14148 verify_jobstats "$cmd" "$SINGLEMDS"
14150 cmd="touch $DIR/$tfile"
14151 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14153 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
14154 verify_jobstats "$cmd" "ost1"
14156 cancel_lru_locks osc
14157 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
14158 verify_jobstats "$cmd" "ost1"
14160 cmd="$TRUNCATE $DIR/$tfile 0"
14161 verify_jobstats "$cmd" "$SINGLEMDS ost1"
14163 cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
14164 verify_jobstats "$cmd" "$SINGLEMDS"
14165 # jobstats expiry - sleep until old stats should be expired
14166 local left=$((new_interval + 5 - (SECONDS - start)))
14167 [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
14168 "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
14170 cmd="mkdir $DIR/$tdir.expire"
14171 verify_jobstats "$cmd" "$SINGLEMDS"
14172 [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
14173 grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
14175 # Ensure that jobid are present in changelog (if supported by MDS)
14176 if [ $MDS1_VERSION -ge $(version_code 2.6.52) ];then
14177 changelog_dump | tail -10
14178 jobids=$(changelog_dump | tail -9 | grep -c "j=")
14179 [ $jobids -eq 9 ] ||
14180 error "Wrong changelog jobid count $jobids != 9"
14184 jobstats_set $JOBENV
14186 changelog_dump | grep $tfile
14187 jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
14188 [ $jobids -eq 0 ] ||
14189 error "Unexpected jobids when jobid_var=$JOBENV"
14192 lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
14193 JOBENV="JOBCOMPLEX"
14194 JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
14196 verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
14198 run_test 205 "Verify job stats"
14200 # LU-1480, LU-1773 and LU-1657
14202 mkdir -p $DIR/$tdir
14203 $SETSTRIPE -c -1 $DIR/$tdir
14204 #define OBD_FAIL_LOV_INIT 0x1403
14205 $LCTL set_param fail_loc=0xa0001403
14206 $LCTL set_param fail_val=1
14207 touch $DIR/$tdir/$tfile || true
14209 run_test 206 "fail lov_init_raid0() doesn't lbug"
14212 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14213 local fsz=`stat -c %s $DIR/$tfile`
14214 cancel_lru_locks mdc
14216 # do not return layout in getattr intent
14217 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
14218 $LCTL set_param fail_loc=0x170
14219 local sz=`stat -c %s $DIR/$tfile`
14221 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
14225 run_test 207a "can refresh layout at glimpse"
14228 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
14229 local cksum=`md5sum $DIR/$tfile`
14230 local fsz=`stat -c %s $DIR/$tfile`
14231 cancel_lru_locks mdc
14232 cancel_lru_locks osc
14234 # do not return layout in getattr intent
14235 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
14236 $LCTL set_param fail_loc=0x171
14238 # it will refresh layout after the file is opened but before read issues
14239 echo checksum is "$cksum"
14240 echo "$cksum" |md5sum -c --quiet || error "file differs"
14244 run_test 207b "can refresh layout at open"
14247 # FIXME: in this test suite, only RD lease is used. This is okay
14248 # for now as only exclusive open is supported. After generic lease
14249 # is done, this test suite should be revised. - Jinshan
14251 remote_mds_nodsh && skip "remote MDS with nodsh"
14252 [[ $MDS1_VERSION -ge $(version_code 2.4.52) ]] ||
14253 skip "Need MDS version at least 2.4.52"
14255 echo "==== test 1: verify get lease work"
14256 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
14258 echo "==== test 2: verify lease can be broken by upcoming open"
14259 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14263 $MULTIOP $DIR/$tfile oO_RDONLY:c
14264 kill -USR1 $PID && wait $PID || error "break lease error"
14266 echo "==== test 3: verify lease can't be granted if an open already exists"
14267 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
14271 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
14272 kill -USR1 $PID && wait $PID || error "open file error"
14274 echo "==== test 4: lease can sustain over recovery"
14275 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
14281 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
14283 echo "==== test 5: lease broken can't be regained by replay"
14284 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
14288 # open file to break lease and then recovery
14289 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
14292 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
14296 run_test 208 "Exclusive open"
14299 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
14300 skip_env "must have disp_stripe"
14303 sync; sleep 5; sync;
14305 echo 3 > /proc/sys/vm/drop_caches
14306 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14308 # open/close 500 times
14309 for i in $(seq 500); do
14313 echo 3 > /proc/sys/vm/drop_caches
14314 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
14316 echo "before: $req_before, after: $req_after"
14317 [ $((req_after - req_before)) -ge 300 ] &&
14318 error "open/close requests are not freed"
14321 run_test 209 "read-only open/close requests should be freed promptly"
14325 size=$((size % 8192 + 1))
14326 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
14327 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
14328 rm -f $DIR/f212 $DIR/f212.xyz
14330 run_test 212 "Sendfile test ============================================"
14333 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
14334 cancel_lru_locks osc
14335 lctl set_param fail_loc=0x8000040f
14336 # generate a read lock
14337 cat $DIR/$tfile > /dev/null
14338 # write to the file, it will try to cancel the above read lock.
14339 cat /etc/hosts >> $DIR/$tfile
14341 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
14343 test_214() { # for bug 20133
14344 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
14345 for (( i=0; i < 340; i++ )) ; do
14346 touch $DIR/$tdir/d214c/a$i
14349 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
14350 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
14351 ls $DIR/d214c || error "ls $DIR/d214c failed"
14352 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
14353 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
14355 run_test 214 "hash-indexed directory test - bug 20133"
14357 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
14358 create_lnet_proc_files() {
14359 lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
14362 # counterpart of create_lnet_proc_files
14363 remove_lnet_proc_files() {
14364 rm -f $TMP/lnet_$1.sys
14367 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14368 # 3rd arg as regexp for body
14369 check_lnet_proc_stats() {
14370 local l=$(cat "$TMP/lnet_$1" |wc -l)
14371 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
14373 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
14376 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
14377 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
14378 # optional and can be regexp for 2nd line (lnet.routes case)
14379 check_lnet_proc_entry() {
14380 local blp=2 # blp stands for 'position of 1st line of body'
14381 [ -z "$5" ] || blp=3 # lnet.routes case
14383 local l=$(cat "$TMP/lnet_$1" |wc -l)
14384 # subtracting one from $blp because the body can be empty
14385 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
14387 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
14388 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
14390 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
14391 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
14393 # bail out if any unexpected line happened
14394 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
14395 [ "$?" != 0 ] || error "$2 misformatted"
14398 test_215() { # for bugs 18102, 21079, 21517
14399 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14401 local N='(0|[1-9][0-9]*)' # non-negative numeric
14402 local P='[1-9][0-9]*' # positive numeric
14403 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
14404 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
14405 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
14406 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
14408 local L1 # regexp for 1st line
14409 local L2 # regexp for 2nd line (optional)
14410 local BR # regexp for the rest (body)
14412 # lnet.stats should look as 11 space-separated non-negative numerics
14413 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
14414 create_lnet_proc_files "stats"
14415 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
14416 remove_lnet_proc_files "stats"
14418 # lnet.routes should look like this:
14419 # Routing disabled/enabled
14420 # net hops priority state router
14421 # where net is a string like tcp0, hops > 0, priority >= 0,
14422 # state is up/down,
14423 # router is a string like 192.168.1.1@tcp2
14424 L1="^Routing (disabled|enabled)$"
14425 L2="^net +hops +priority +state +router$"
14426 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
14427 create_lnet_proc_files "routes"
14428 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
14429 remove_lnet_proc_files "routes"
14431 # lnet.routers should look like this:
14432 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
14433 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
14434 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
14435 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
14436 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
14437 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
14438 create_lnet_proc_files "routers"
14439 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
14440 remove_lnet_proc_files "routers"
14442 # lnet.peers should look like this:
14443 # nid refs state last max rtr min tx min queue
14444 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
14445 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
14446 # numeric (0 or >0 or <0), queue >= 0.
14447 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
14448 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
14449 create_lnet_proc_files "peers"
14450 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
14451 remove_lnet_proc_files "peers"
14453 # lnet.buffers should look like this:
14454 # pages count credits min
14455 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
14456 L1="^pages +count +credits +min$"
14457 BR="^ +$N +$N +$I +$I$"
14458 create_lnet_proc_files "buffers"
14459 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
14460 remove_lnet_proc_files "buffers"
14462 # lnet.nis should look like this:
14463 # nid status alive refs peer rtr max tx min
14464 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
14465 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
14466 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
14467 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
14468 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
14469 create_lnet_proc_files "nis"
14470 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
14471 remove_lnet_proc_files "nis"
14473 # can we successfully write to lnet.stats?
14474 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
14476 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
14478 test_216() { # bug 20317
14479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14480 remote_ost_nodsh && skip "remote OST with nodsh"
14483 local facets=$(get_facets OST)
14484 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14486 save_lustre_params client "osc.*.contention_seconds" > $p
14487 save_lustre_params $facets \
14488 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
14489 save_lustre_params $facets \
14490 "ldlm.namespaces.filter-*.contended_locks" >> $p
14491 save_lustre_params $facets \
14492 "ldlm.namespaces.filter-*.contention_seconds" >> $p
14493 clear_stats osc.*.osc_stats
14495 # agressive lockless i/o settings
14496 do_nodes $(comma_list $(osts_nodes)) \
14497 "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
14498 ldlm.namespaces.filter-*.contended_locks=0 \
14499 ldlm.namespaces.filter-*.contention_seconds=60"
14500 lctl set_param -n osc.*.contention_seconds=60
14502 $DIRECTIO write $DIR/$tfile 0 10 4096
14503 $CHECKSTAT -s 40960 $DIR/$tfile
14505 # disable lockless i/o
14506 do_nodes $(comma_list $(osts_nodes)) \
14507 "lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes=0 \
14508 ldlm.namespaces.filter-*.contended_locks=32 \
14509 ldlm.namespaces.filter-*.contention_seconds=0"
14510 lctl set_param -n osc.*.contention_seconds=0
14511 clear_stats osc.*.osc_stats
14513 dd if=/dev/zero of=$DIR/$tfile count=0
14514 $CHECKSTAT -s 0 $DIR/$tfile
14516 restore_lustre_params <$p
14520 run_test 216 "check lockless direct write updates file size and kms correctly"
14522 test_217() { # bug 22430
14523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14528 for node in $(nodes_list); do
14529 nid=$(host_nids_address $node $NETTYPE)
14530 if [[ $nid = *-* ]] ; then
14531 echo "lctl ping $(h2nettype $nid)"
14532 lctl ping $(h2nettype $nid)
14534 echo "skipping $node (no hyphen detected)"
14538 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
14541 # do directio so as not to populate the page cache
14542 log "creating a 10 Mb file"
14543 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
14544 log "starting reads"
14545 dd if=$DIR/$tfile of=/dev/null bs=4096 &
14546 log "truncating the file"
14547 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
14549 kill %+ || true # reads might have finished
14550 echo "wait until dd is finished"
14552 log "removing the temporary file"
14553 rm -rf $DIR/$tfile || error "tmp file removal failed"
14555 run_test 218 "parallel read and truncate should not deadlock"
14558 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14560 # write one partial page
14561 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
14562 # set no grant so vvp_io_commit_write will do sync write
14563 $LCTL set_param fail_loc=0x411
14564 # write a full page at the end of file
14565 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
14567 $LCTL set_param fail_loc=0
14568 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
14569 $LCTL set_param fail_loc=0x411
14570 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
14573 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
14574 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
14576 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
14578 test_220() { #LU-325
14579 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14580 remote_ost_nodsh && skip "remote OST with nodsh"
14581 remote_mds_nodsh && skip "remote MDS with nodsh"
14582 remote_mgs_nodsh && skip "remote MGS with nodsh"
14586 # create on MDT0000 so the last_id and next_id are correct
14588 local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
14592 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
14593 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
14594 osc.$mdtosc_proc1.prealloc_last_id)
14595 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
14596 osc.$mdtosc_proc1.prealloc_next_id)
14600 if ! combined_mgs_mds ; then
14604 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
14605 #define OBD_FAIL_OST_ENOINO 0x229
14606 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
14607 create_pool $FSNAME.$TESTNAME || return 1
14608 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
14610 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
14612 MDSOBJS=$((last_id - next_id))
14613 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
14615 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
14616 echo "OST still has $count kbytes free"
14618 echo "create $MDSOBJS files @next_id..."
14619 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
14621 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14622 osc.$mdtosc_proc1.prealloc_last_id)
14623 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
14624 osc.$mdtosc_proc1.prealloc_next_id)
14626 echo "after creation, last_id=$last_id2, next_id=$next_id2"
14631 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
14632 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
14634 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST ||
14635 error "$LCTL pool_remove $FSNAME.$TESTNAME $OST failed"
14636 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
14637 error "$LCTL pool_destroy $FSNAME.$TESTNAME failed"
14638 echo "unlink $MDSOBJS files @$next_id..."
14639 unlinkmany $DIR/$tdir/f $MDSOBJS || error "unlinkmany failed"
14641 if ! combined_mgs_mds ; then
14645 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
14648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14650 dd if=`which date` of=$MOUNT/date oflag=sync
14651 chmod +x $MOUNT/date
14653 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
14654 $LCTL set_param fail_loc=0x80001401
14656 $MOUNT/date > /dev/null
14659 run_test 221 "make sure fault and truncate race to not cause OOM"
14662 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14665 test_mkdir $DIR/$tdir
14666 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14667 createmany -o $DIR/$tdir/$tfile 10
14668 cancel_lru_locks mdc
14669 cancel_lru_locks osc
14670 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14671 $LCTL set_param fail_loc=0x31a
14672 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
14673 $LCTL set_param fail_loc=0
14676 run_test 222a "AGL for ls should not trigger CLIO lock failure"
14679 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14682 test_mkdir $DIR/$tdir
14683 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14684 createmany -o $DIR/$tdir/$tfile 10
14685 cancel_lru_locks mdc
14686 cancel_lru_locks osc
14687 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
14688 $LCTL set_param fail_loc=0x31a
14689 rm -r $DIR/$tdir || error "AGL for rmdir failed"
14690 $LCTL set_param fail_loc=0
14692 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
14695 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14698 test_mkdir $DIR/$tdir
14699 $LFS setstripe -c 1 -i 0 $DIR/$tdir
14700 createmany -o $DIR/$tdir/$tfile 10
14701 cancel_lru_locks mdc
14702 cancel_lru_locks osc
14703 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
14704 $LCTL set_param fail_loc=0x31b
14705 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
14706 $LCTL set_param fail_loc=0
14709 run_test 223 "osc reenqueue if without AGL lock granted ======================="
14711 test_224a() { # LU-1039, MRP-303
14712 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14714 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
14715 $LCTL set_param fail_loc=0x508
14716 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
14717 $LCTL set_param fail_loc=0
14720 run_test 224a "Don't panic on bulk IO failure"
14722 test_224b() { # LU-1039, MRP-303
14723 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14725 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
14726 cancel_lru_locks osc
14727 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
14728 $LCTL set_param fail_loc=0x515
14729 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
14730 $LCTL set_param fail_loc=0
14733 run_test 224b "Don't panic on bulk IO failure"
14735 test_224c() { # LU-6441
14736 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14737 remote_mds_nodsh && skip "remote MDS with nodsh"
14739 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
14740 save_writethrough $p
14741 set_cache writethrough on
14743 local pages_per_rpc=$($LCTL get_param \
14744 osc.*.max_pages_per_rpc)
14745 local at_max=$($LCTL get_param -n at_max)
14746 local timeout=$($LCTL get_param -n timeout)
14747 local test_at="at_max"
14748 local param_at="$FSNAME.sys.at_max"
14749 local test_timeout="timeout"
14750 local param_timeout="$FSNAME.sys.timeout"
14752 $LCTL set_param -n osc.*.max_pages_per_rpc=1024
14754 set_persistent_param_and_check client "$test_at" "$param_at" 0
14755 set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
14757 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
14758 do_facet ost1 $LCTL set_param fail_loc=0x520
14759 $LFS setstripe -c 1 -i 0 $DIR/$tfile
14760 dd if=/dev/zero of=$DIR/$tfile bs=8MB count=1
14762 do_facet ost1 $LCTL set_param fail_loc=0
14764 set_persistent_param_and_check client "$test_at" "$param_at" $at_max
14765 set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
14768 $LCTL set_param -n $pages_per_rpc
14769 restore_lustre_params < $p
14772 run_test 224c "Don't hang if one of md lost during large bulk RPC"
14774 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
14776 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14777 if [ -z ${MDSSURVEY} ]; then
14778 skip_env "mds-survey not found"
14780 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
14781 skip "Need MDS version at least 2.2.51"
14783 local mds=$(facet_host $SINGLEMDS)
14784 local target=$(do_nodes $mds 'lctl dl' |
14785 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14787 local cmd1="file_count=1000 thrhi=4"
14788 local cmd2="dir_count=2 layer=mdd stripe_count=0"
14789 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14790 local cmd="$cmd1 $cmd2 $cmd3"
14792 rm -f ${TMP}/mds_survey*
14794 eval $cmd || error "mds-survey with zero-stripe failed"
14795 cat ${TMP}/mds_survey*
14796 rm -f ${TMP}/mds_survey*
14798 run_test 225a "Metadata survey sanity with zero-stripe"
14801 if [ -z ${MDSSURVEY} ]; then
14802 skip_env "mds-survey not found"
14804 [ $MDS1_VERSION -ge $(version_code 2.2.51) ] ||
14805 skip "Need MDS version at least 2.2.51"
14806 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14807 remote_mds_nodsh && skip "remote MDS with nodsh"
14808 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
14809 skip_env "Need to mount OST to test"
14812 local mds=$(facet_host $SINGLEMDS)
14813 local target=$(do_nodes $mds 'lctl dl' |
14814 awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
14816 local cmd1="file_count=1000 thrhi=4"
14817 local cmd2="dir_count=2 layer=mdd stripe_count=1"
14818 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
14819 local cmd="$cmd1 $cmd2 $cmd3"
14821 rm -f ${TMP}/mds_survey*
14823 eval $cmd || error "mds-survey with stripe_count failed"
14824 cat ${TMP}/mds_survey*
14825 rm -f ${TMP}/mds_survey*
14827 run_test 225b "Metadata survey sanity with stripe_count = 1"
14829 mcreate_path2fid () {
14835 local path=$DIR/$tdir/$name
14840 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
14841 error "cannot create $desc"
14843 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
14845 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
14847 fid_path=$($LFS fid2path $MOUNT $fid)
14849 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
14851 [ "$path" == "$fid_path" ] ||
14852 error "fid2path returned $fid_path, expected $path"
14854 echo "pass with $path and $fid"
14859 mkdir -p $DIR/$tdir
14861 mcreate_path2fid 0010666 0 0 fifo "FIFO"
14862 mcreate_path2fid 0020666 1 3 null "character special file (null)"
14863 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
14864 mcreate_path2fid 0040666 0 0 dir "directory"
14865 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
14866 mcreate_path2fid 0100666 0 0 file "regular file"
14867 mcreate_path2fid 0120666 0 0 link "symbolic link"
14868 mcreate_path2fid 0140666 0 0 sock "socket"
14870 run_test 226a "call path2fid and fid2path on files of all type"
14873 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
14878 mkdir -p $DIR/$tdir
14879 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
14880 error "create remote directory failed"
14881 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
14882 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
14883 "character special file (null)"
14884 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
14885 "character special file (no device)"
14886 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
14887 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
14888 "block special file (loop)"
14889 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
14890 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
14891 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
14893 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
14895 # LU-1299 Executing or running ldd on a truncated executable does not
14896 # cause an out-of-memory condition.
14898 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14899 [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
14901 dd if=$(which date) of=$MOUNT/date bs=1k count=1
14902 chmod +x $MOUNT/date
14904 $MOUNT/date > /dev/null
14905 ldd $MOUNT/date > /dev/null
14908 run_test 227 "running truncated executable does not cause OOM"
14910 # LU-1512 try to reuse idle OI blocks
14912 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14913 remote_mds_nodsh && skip "remote MDS with nodsh"
14914 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
14916 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14917 local myDIR=$DIR/$tdir
14920 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14921 $LCTL set_param fail_loc=0x80001002
14922 createmany -o $myDIR/t- 10000
14923 $LCTL set_param fail_loc=0
14924 # The guard is current the largest FID holder
14926 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14928 local IDX=$(($SEQ % 64))
14930 do_facet $SINGLEMDS sync
14931 # Make sure journal flushed.
14933 local blk1=$(do_facet $SINGLEMDS \
14934 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14935 grep Blockcount | awk '{print $4}')
14937 # Remove old files, some OI blocks will become idle.
14938 unlinkmany $myDIR/t- 10000
14939 # Create new files, idle OI blocks should be reused.
14940 createmany -o $myDIR/t- 2000
14941 do_facet $SINGLEMDS sync
14942 # Make sure journal flushed.
14944 local blk2=$(do_facet $SINGLEMDS \
14945 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14946 grep Blockcount | awk '{print $4}')
14948 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14950 run_test 228a "try to reuse idle OI blocks"
14953 [ $PARALLEL == "yes" ] && skip "skip parallel run"
14954 remote_mds_nodsh && skip "remote MDS with nodsh"
14955 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
14957 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
14958 local myDIR=$DIR/$tdir
14961 #define OBD_FAIL_SEQ_EXHAUST 0x1002
14962 $LCTL set_param fail_loc=0x80001002
14963 createmany -o $myDIR/t- 10000
14964 $LCTL set_param fail_loc=0
14965 # The guard is current the largest FID holder
14967 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
14969 local IDX=$(($SEQ % 64))
14971 do_facet $SINGLEMDS sync
14972 # Make sure journal flushed.
14974 local blk1=$(do_facet $SINGLEMDS \
14975 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14976 grep Blockcount | awk '{print $4}')
14978 # Remove old files, some OI blocks will become idle.
14979 unlinkmany $myDIR/t- 10000
14982 stop $SINGLEMDS || error "Fail to stop MDT."
14984 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
14986 df $MOUNT || error "Fail to df."
14987 # Create new files, idle OI blocks should be reused.
14988 createmany -o $myDIR/t- 2000
14989 do_facet $SINGLEMDS sync
14990 # Make sure journal flushed.
14992 local blk2=$(do_facet $SINGLEMDS \
14993 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
14994 grep Blockcount | awk '{print $4}')
14996 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
14998 run_test 228b "idle OI blocks can be reused after MDT restart"
15002 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15003 remote_mds_nodsh && skip "remote MDS with nodsh"
15004 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
15006 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
15007 local myDIR=$DIR/$tdir
15010 #define OBD_FAIL_SEQ_EXHAUST 0x1002
15011 $LCTL set_param fail_loc=0x80001002
15012 # 20000 files can guarantee there are index nodes in the OI file
15013 createmany -o $myDIR/t- 20000
15014 $LCTL set_param fail_loc=0
15015 # The guard is current the largest FID holder
15017 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
15019 local IDX=$(($SEQ % 64))
15021 do_facet $SINGLEMDS sync
15022 # Make sure journal flushed.
15024 local blk1=$(do_facet $SINGLEMDS \
15025 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15026 grep Blockcount | awk '{print $4}')
15028 # Remove old files, some OI blocks will become idle.
15029 unlinkmany $myDIR/t- 20000
15031 # The OI file should become empty now
15033 # Create new files, idle OI blocks should be reused.
15034 createmany -o $myDIR/t- 2000
15035 do_facet $SINGLEMDS sync
15036 # Make sure journal flushed.
15038 local blk2=$(do_facet $SINGLEMDS \
15039 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
15040 grep Blockcount | awk '{print $4}')
15042 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
15044 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
15046 test_229() { # LU-2482, LU-3448
15047 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15048 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
15049 [ $MDS1_VERSION -lt $(version_code 2.4.53) ] &&
15050 skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
15054 # Create a file with a released layout and stripe count 2.
15055 $MULTIOP $DIR/$tfile H2c ||
15056 error "failed to create file with released layout"
15058 $GETSTRIPE -v $DIR/$tfile
15060 local pattern=$($GETSTRIPE -L $DIR/$tfile)
15061 [ X"$pattern" = X"released" ] || error "pattern error ($pattern)"
15063 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
15064 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
15065 stat $DIR/$tfile || error "failed to stat released file"
15067 chown $RUNAS_ID $DIR/$tfile ||
15068 error "chown $RUNAS_ID $DIR/$tfile failed"
15070 chgrp $RUNAS_ID $DIR/$tfile ||
15071 error "chgrp $RUNAS_ID $DIR/$tfile failed"
15073 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
15074 rm $DIR/$tfile || error "failed to remove released file"
15076 run_test 229 "getstripe/stat/rm/attr changes work on released files"
15079 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15080 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15081 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15082 skip "Need MDS version at least 2.11.52"
15086 test_mkdir $DIR/$tdir
15087 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
15088 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
15089 [ $mdt_idx -ne 0 ] &&
15090 error "create local directory on wrong MDT $mdt_idx"
15092 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
15093 error "create remote directory failed"
15094 local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
15095 [ $mdt_idx -ne $MDTIDX ] &&
15096 error "create remote directory on wrong MDT $mdt_idx"
15098 createmany -o $DIR/$tdir/test_230/t- 10 ||
15099 error "create files on remote directory failed"
15100 mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
15101 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
15102 rm -r $DIR/$tdir || error "unlink remote directory failed"
15104 run_test 230a "Create remote directory and files under the remote directory"
15107 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15108 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15109 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15110 skip "Need MDS version at least 2.11.52"
15118 local migrate_dir=$DIR/$tdir/migrate_dir
15119 local other_dir=$DIR/$tdir/other_dir
15121 test_mkdir $DIR/$tdir
15122 test_mkdir -i0 -c1 $migrate_dir
15123 test_mkdir -i0 -c1 $other_dir
15124 for ((i=0; i<10; i++)); do
15125 mkdir -p $migrate_dir/dir_${i}
15126 createmany -o $migrate_dir/dir_${i}/f 10 ||
15127 error "create files under remote dir failed $i"
15130 cp /etc/passwd $migrate_dir/$tfile
15131 cp /etc/passwd $other_dir/$tfile
15132 chattr +SAD $migrate_dir
15133 chattr +SAD $migrate_dir/$tfile
15135 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15136 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15137 local old_dir_mode=$(stat -c%f $migrate_dir)
15138 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
15140 mkdir -p $migrate_dir/dir_default_stripe2
15141 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
15142 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
15144 mkdir -p $other_dir
15145 ln $migrate_dir/$tfile $other_dir/luna
15146 ln $migrate_dir/$tfile $migrate_dir/sofia
15147 ln $other_dir/$tfile $migrate_dir/david
15148 ln -s $migrate_dir/$tfile $other_dir/zachary
15149 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
15150 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
15152 $LFS migrate -m $MDTIDX $migrate_dir ||
15153 error "fails on migrating remote dir to MDT1"
15155 echo "migratate to MDT1, then checking.."
15156 for ((i = 0; i < 10; i++)); do
15157 for file in $(find $migrate_dir/dir_${i}); do
15158 mdt_index=$($LFS getstripe -m $file)
15159 [ $mdt_index == $MDTIDX ] ||
15160 error "$file is not on MDT${MDTIDX}"
15164 # the multiple link file should still in MDT0
15165 mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
15166 [ $mdt_index == 0 ] ||
15167 error "$file is not on MDT${MDTIDX}"
15169 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15170 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15171 error " expect $old_dir_flag get $new_dir_flag"
15173 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15174 [ "$old_file_flag" = "$new_file_flag" ] ||
15175 error " expect $old_file_flag get $new_file_flag"
15177 local new_dir_mode=$(stat -c%f $migrate_dir)
15178 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15179 error "expect mode $old_dir_mode get $new_dir_mode"
15181 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15182 [ "$old_file_mode" = "$new_file_mode" ] ||
15183 error "expect mode $old_file_mode get $new_file_mode"
15185 diff /etc/passwd $migrate_dir/$tfile ||
15186 error "$tfile different after migration"
15188 diff /etc/passwd $other_dir/luna ||
15189 error "luna different after migration"
15191 diff /etc/passwd $migrate_dir/sofia ||
15192 error "sofia different after migration"
15194 diff /etc/passwd $migrate_dir/david ||
15195 error "david different after migration"
15197 diff /etc/passwd $other_dir/zachary ||
15198 error "zachary different after migration"
15200 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15201 error "${tfile}_ln different after migration"
15203 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15204 error "${tfile}_ln_other different after migration"
15206 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
15207 [ $stripe_count = 2 ] ||
15208 error "dir strpe_count $d != 2 after migration."
15210 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
15211 [ $stripe_count = 2 ] ||
15212 error "file strpe_count $d != 2 after migration."
15214 #migrate back to MDT0
15217 $LFS migrate -m $MDTIDX $migrate_dir ||
15218 error "fails on migrating remote dir to MDT0"
15220 echo "migrate back to MDT0, checking.."
15221 for file in $(find $migrate_dir); do
15222 mdt_index=$($LFS getstripe -m $file)
15223 [ $mdt_index == $MDTIDX ] ||
15224 error "$file is not on MDT${MDTIDX}"
15227 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
15228 [ "$old_dir_flag" = "$new_dir_flag" ] ||
15229 error " expect $old_dir_flag get $new_dir_flag"
15231 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
15232 [ "$old_file_flag" = "$new_file_flag" ] ||
15233 error " expect $old_file_flag get $new_file_flag"
15235 local new_dir_mode=$(stat -c%f $migrate_dir)
15236 [ "$old_dir_mode" = "$new_dir_mode" ] ||
15237 error "expect mode $old_dir_mode get $new_dir_mode"
15239 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
15240 [ "$old_file_mode" = "$new_file_mode" ] ||
15241 error "expect mode $old_file_mode get $new_file_mode"
15243 diff /etc/passwd ${migrate_dir}/$tfile ||
15244 error "$tfile different after migration"
15246 diff /etc/passwd ${other_dir}/luna ||
15247 error "luna different after migration"
15249 diff /etc/passwd ${migrate_dir}/sofia ||
15250 error "sofia different after migration"
15252 diff /etc/passwd ${other_dir}/zachary ||
15253 error "zachary different after migration"
15255 diff /etc/passwd $migrate_dir/${tfile}_ln ||
15256 error "${tfile}_ln different after migration"
15258 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
15259 error "${tfile}_ln_other different after migration"
15261 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
15262 [ $stripe_count = 2 ] ||
15263 error "dir strpe_count $d != 2 after migration."
15265 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
15266 [ $stripe_count = 2 ] ||
15267 error "file strpe_count $d != 2 after migration."
15269 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15271 run_test 230b "migrate directory"
15274 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15275 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15276 remote_mds_nodsh && skip "remote MDS with nodsh"
15277 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15278 skip "Need MDS version at least 2.11.52"
15284 local migrate_dir=$DIR/$tdir/migrate_dir
15286 #If migrating directory fails in the middle, all entries of
15287 #the directory is still accessiable.
15288 test_mkdir $DIR/$tdir
15289 test_mkdir -i0 -c1 $migrate_dir
15290 test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
15292 createmany -o $migrate_dir/f $total ||
15293 error "create files under ${migrate_dir} failed"
15295 # fail after migrating top dir, and this will fail only once, so the
15296 # first sub file migration will fail (currently f3), others succeed.
15297 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
15298 do_facet mds1 lctl set_param fail_loc=0x1801
15299 local t=$(ls $migrate_dir | wc -l)
15300 $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
15301 error "migrate should fail"
15302 local u=$(ls $migrate_dir | wc -l)
15303 [ "$u" == "$t" ] || error "$u != $t during migration"
15305 # add new dir/file should succeed
15306 mkdir $migrate_dir/dir ||
15307 error "mkdir failed under migrating directory"
15308 touch $migrate_dir/file ||
15309 error "create file failed under migrating directory"
15311 # add file with existing name should fail
15312 for file in $migrate_dir/f*; do
15313 stat $file > /dev/null || error "stat $file failed"
15314 $OPENFILE -f O_CREAT:O_EXCL $file &&
15315 error "open(O_CREAT|O_EXCL) $file should fail"
15316 $MULTIOP $file m && error "create $file should fail"
15317 touch $DIR/$tdir/remote_dir/$tfile ||
15318 error "touch $tfile failed"
15319 ln $DIR/$tdir/remote_dir/$tfile $file &&
15320 error "link $file should fail"
15321 mdt_index=$($LFS getstripe -m $file)
15322 if [ $mdt_index == 0 ]; then
15323 # file failed to migrate is not allowed to rename to
15324 mv $DIR/$tdir/remote_dir/$tfile $file &&
15325 error "rename to $file should fail"
15327 mv $DIR/$tdir/remote_dir/$tfile $file ||
15328 error "rename to $file failed"
15330 echo hello >> $file || error "write $file failed"
15333 # resume migration with different options should fail
15334 $LFS migrate -m 0 $migrate_dir &&
15335 error "migrate -m 0 $migrate_dir should fail"
15337 $LFS migrate -m $MDTIDX -c 2 $migrate_dir &&
15338 error "migrate -c 2 $migrate_dir should fail"
15340 # resume migration should succeed
15341 $LFS migrate -m $MDTIDX $migrate_dir ||
15342 error "migrate $migrate_dir failed"
15344 echo "Finish migration, then checking.."
15345 for file in $(find $migrate_dir); do
15346 mdt_index=$($LFS getstripe -m $file)
15347 [ $mdt_index == $MDTIDX ] ||
15348 error "$file is not on MDT${MDTIDX}"
15351 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15353 run_test 230c "check directory accessiblity if migration failed"
15356 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15357 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15358 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15359 skip "Need MDS version at least 2.11.52"
15361 [ "$mds1_FSTYPE" == "zfs" ] && skip "skip ZFS backend"
15363 local migrate_dir=$DIR/$tdir/migrate_dir
15373 old_index=$((RANDOM % MDSCOUNT))
15374 old_count=$((MDSCOUNT - old_index))
15375 new_index=$((RANDOM % MDSCOUNT))
15376 new_count=$((MDSCOUNT - new_index))
15377 new_hash="all_char"
15379 [ $old_count -gt 1 ] && old_count=$((old_count - RANDOM % old_count))
15380 [ $new_count -gt 1 ] && new_count=$((new_count - RANDOM % new_count))
15382 test_mkdir $DIR/$tdir
15383 test_mkdir -i $old_index -c $old_count $migrate_dir
15385 for ((i=0; i<100; i++)); do
15386 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
15387 createmany -o $migrate_dir/dir_${i}/f 100 ||
15388 error "create files under remote dir failed $i"
15391 echo -n "Migrate from MDT$old_index "
15392 [ $old_count -gt 1 ] && echo -n "... MDT$((old_index + old_count - 1)) "
15393 echo -n "to MDT$new_index"
15394 [ $new_count -gt 1 ] && echo -n " ... MDT$((new_index + new_count - 1))"
15397 echo "$LFS migrate -m$new_index -c$new_count -H $new_hash $migrate_dir"
15398 $LFS migrate -m $new_index -c $new_count -H $new_hash $migrate_dir ||
15399 error "migrate remote dir error"
15401 echo "Finish migration, then checking.."
15402 for file in $(find $migrate_dir); do
15403 mdt_index=$($LFS getstripe -m $file)
15404 if [ $mdt_index -lt $new_index ] ||
15405 [ $mdt_index -gt $((new_index + new_count - 1)) ]; then
15406 error "$file is on MDT$mdt_index"
15410 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15412 run_test 230d "check migrate big directory"
15415 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15416 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15417 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15418 skip "Need MDS version at least 2.11.52"
15425 mkdir -p $DIR/$tdir
15426 mkdir $DIR/$tdir/migrate_dir
15427 mkdir $DIR/$tdir/other_dir
15428 touch $DIR/$tdir/migrate_dir/a
15429 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/b
15430 ls $DIR/$tdir/other_dir
15432 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15433 error "migrate dir fails"
15435 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15436 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15438 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15439 [ $mdt_index == 0 ] || error "a is not on MDT0"
15441 $LFS migrate -m 1 $DIR/$tdir/other_dir ||
15442 error "migrate dir fails"
15444 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
15445 [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
15447 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15448 [ $mdt_index == 1 ] || error "a is not on MDT1"
15450 mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
15451 [ $mdt_index == 1 ] || error "b is not on MDT1"
15453 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15454 b_fid=$($LFS path2fid $DIR/$tdir/other_dir/b)
15456 [ "$a_fid" = "$b_fid" ] || error "different fid after migration"
15458 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15460 run_test 230e "migrate mulitple local link files"
15463 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15464 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15465 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15466 skip "Need MDS version at least 2.11.52"
15471 mkdir -p $DIR/$tdir
15472 mkdir $DIR/$tdir/migrate_dir
15473 $LFS mkdir -i1 $DIR/$tdir/other_dir
15474 touch $DIR/$tdir/migrate_dir/a
15475 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln1
15476 ln $DIR/$tdir/migrate_dir/a $DIR/$tdir/other_dir/ln2
15477 ls $DIR/$tdir/other_dir
15479 # a should be migrated to MDT1, since no other links on MDT0
15480 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15481 error "#1 migrate dir fails"
15482 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
15483 [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
15484 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15485 [ $mdt_index == 1 ] || error "a is not on MDT1"
15487 # a should stay on MDT1, because it is a mulitple link file
15488 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15489 error "#2 migrate dir fails"
15490 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15491 [ $mdt_index == 1 ] || error "a is not on MDT1"
15493 $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
15494 error "#3 migrate dir fails"
15496 a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
15497 ln_fid=$($LFS path2fid $DIR/$tdir/other_dir/ln1)
15498 [ "$a_fid" = "$ln_fid" ] || error "different fid after migrate to MDT1"
15500 rm -rf $DIR/$tdir/other_dir/ln1 || error "unlink ln1 fails"
15501 rm -rf $DIR/$tdir/other_dir/ln2 || error "unlink ln2 fails"
15503 # a should be migrated to MDT0, since no other links on MDT1
15504 $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
15505 error "#4 migrate dir fails"
15506 mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
15507 [ $mdt_index == 0 ] || error "a is not on MDT0"
15509 rm -rf $DIR/$tdir || error "rm dir failed after migration"
15511 run_test 230f "migrate mulitple remote link files"
15514 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15515 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15516 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15517 skip "Need MDS version at least 2.11.52"
15519 mkdir -p $DIR/$tdir/migrate_dir
15521 $LFS migrate -m 1000 $DIR/$tdir/migrate_dir &&
15522 error "migrating dir to non-exist MDT succeeds"
15525 run_test 230g "migrate dir to non-exist MDT"
15528 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15529 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15530 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15531 skip "Need MDS version at least 2.11.52"
15535 mkdir -p $DIR/$tdir/migrate_dir
15537 $LFS migrate -m1 $DIR &&
15538 error "migrating mountpoint1 should fail"
15540 $LFS migrate -m1 $DIR/$tdir/.. &&
15541 error "migrating mountpoint2 should fail"
15544 $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. &&
15545 error "migrating $tdir/migrate_dir/.. should fail"
15549 run_test 230h "migrate .. and root"
15552 [ $PARALLEL == "yes" ] && skip "skip parallel run"
15553 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15554 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15555 skip "Need MDS version at least 2.11.52"
15557 mkdir -p $DIR/$tdir/migrate_dir
15559 $LFS migrate -m 1 $DIR/$tdir/migrate_dir/ ||
15560 error "migration fails with a tailing slash"
15562 $LFS migrate -m 0 $DIR/$tdir/migrate_dir// ||
15563 error "migration fails with two tailing slashes"
15565 run_test 230i "lfs migrate -m tolerates trailing slashes"
15568 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15569 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
15570 skip "Need MDS version at least 2.11.52"
15572 $LFS mkdir -m 0 -c 1 $DIR/$tdir || error "mkdir $tdir failed"
15573 $LFS setstripe -E 1M -L mdt $DIR/$tdir/$tfile ||
15574 error "create $tfile failed"
15575 cat /etc/passwd > $DIR/$tdir/$tfile
15577 $LFS migrate -m 1 $DIR/$tdir
15579 cmp /etc/passwd $DIR/$tdir/$tfile ||
15580 error "DoM file mismatch after migration"
15582 run_test 230j "DoM file data not changed after dir migration"
15585 [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
15586 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15587 skip "Need MDS version at least 2.11.56"
15590 local files_on_starting_mdt=0
15592 $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
15593 $LFS getdirstripe $DIR/$tdir
15594 for i in $(seq $total); do
15595 echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
15596 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15597 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15600 echo "$files_on_starting_mdt files on MDT0"
15602 $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
15603 $LFS getdirstripe $DIR/$tdir
15605 files_on_starting_mdt=0
15606 for i in $(seq $total); do
15607 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15608 error "file $tfile.$i mismatch after migration"
15609 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
15610 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15613 echo "$files_on_starting_mdt files on MDT1 after migration"
15614 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
15616 $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
15617 $LFS getdirstripe $DIR/$tdir
15619 files_on_starting_mdt=0
15620 for i in $(seq $total); do
15621 $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
15622 error "file $tfile.$i mismatch after 2nd migration"
15623 [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
15624 files_on_starting_mdt=$((files_on_starting_mdt + 1))
15627 echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
15628 [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
15632 run_test 230k "file data not changed after dir migration"
15635 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
15636 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
15637 skip "Need MDS version at least 2.11.56"
15639 $LFS mkdir -i 0 -c 1 $DIR/$tdir || error "mkdir failed"
15640 createmany -o $DIR/$tdir/f___________________________________ 1000 ||
15641 error "create files under remote dir failed $i"
15642 $LFS migrate -m 1 $DIR/$tdir || error "migrate failed"
15644 run_test 230l "readdir between MDTs won't crash"
15648 # For simplicity this test assumes that max_pages_per_rpc
15649 # is the same across all OSCs
15650 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
15651 local bulk_size=$((max_pages * PAGE_SIZE))
15652 local brw_size=$(do_facet ost1 $LCTL get_param -n obdfilter.*.brw_size |
15655 mkdir -p $DIR/$tdir
15656 $LFS setstripe -S ${brw_size}M $DIR/$tdir ||
15657 error "failed to set stripe with -S ${brw_size}M option"
15659 # clear the OSC stats
15660 $LCTL set_param osc.*.stats=0 &>/dev/null
15663 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
15664 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
15665 oflag=direct &>/dev/null || error "dd failed"
15667 sync; sleep 1; sync # just to be safe
15668 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
15669 if [ x$nrpcs != "x1" ]; then
15670 $LCTL get_param osc.*.stats
15671 error "found $nrpcs ost_write RPCs, not 1 as expected"
15675 # Drop the OSC cache, otherwise we will read from it
15676 cancel_lru_locks osc
15678 # clear the OSC stats
15679 $LCTL set_param osc.*.stats=0 &>/dev/null
15681 # Client reads $bulk_size.
15682 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
15683 iflag=direct &>/dev/null || error "dd failed"
15685 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
15686 if [ x$nrpcs != "x1" ]; then
15687 $LCTL get_param osc.*.stats
15688 error "found $nrpcs ost_read RPCs, not 1 as expected"
15691 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
15694 mkdir -p $DIR/$tdir
15696 for i in {0..1023}; do
15697 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
15698 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
15699 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
15703 run_test 231b "must not assert on fully utilized OST request buffer"
15706 mkdir -p $DIR/$tdir
15707 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15709 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15710 do_facet ost1 $LCTL set_param fail_loc=0x31c
15712 # ignore dd failure
15713 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
15715 do_facet ost1 $LCTL set_param fail_loc=0
15716 umount_client $MOUNT || error "umount failed"
15717 mount_client $MOUNT || error "mount failed"
15718 stop ost1 || error "cannot stop ost1"
15719 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15721 run_test 232a "failed lock should not block umount"
15724 [ $MDS1_VERSION -ge $(version_code 2.10.58) ] ||
15725 skip "Need MDS version at least 2.10.58"
15727 mkdir -p $DIR/$tdir
15728 $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
15729 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
15731 cancel_lru_locks osc
15733 #define OBD_FAIL_LDLM_OST_LVB 0x31c
15734 do_facet ost1 $LCTL set_param fail_loc=0x31c
15737 $LFS data_version $DIR/$tdir/$tfile || true
15739 do_facet ost1 $LCTL set_param fail_loc=0
15740 umount_client $MOUNT || error "umount failed"
15741 mount_client $MOUNT || error "mount failed"
15742 stop ost1 || error "cannot stop ost1"
15743 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
15745 run_test 232b "failed data version lock should not block umount"
15748 [ $MDS1_VERSION -ge $(version_code 2.3.64) ] ||
15749 skip "Need MDS version at least 2.3.64"
15750 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15752 local fid=$($LFS path2fid $MOUNT)
15754 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15755 error "cannot access $MOUNT using its FID '$fid'"
15757 run_test 233a "checking that OBF of the FS root succeeds"
15760 [ $MDS1_VERSION -ge $(version_code 2.5.90) ] ||
15761 skip "Need MDS version at least 2.5.90"
15762 [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
15764 local fid=$($LFS path2fid $MOUNT/.lustre)
15766 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15767 error "cannot access $MOUNT/.lustre using its FID '$fid'"
15769 fid=$($LFS path2fid $MOUNT/.lustre/fid)
15770 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
15771 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
15773 run_test 233b "checking that OBF of the FS .lustre succeeds"
15776 local p="$TMP/sanityN-$TESTNAME.parameters"
15777 save_lustre_params client "llite.*.xattr_cache" > $p
15778 lctl set_param llite.*.xattr_cache 1 ||
15779 skip_env "xattr cache is not supported"
15781 mkdir -p $DIR/$tdir || error "mkdir failed"
15782 touch $DIR/$tdir/$tfile || error "touch failed"
15783 # OBD_FAIL_LLITE_XATTR_ENOMEM
15784 $LCTL set_param fail_loc=0x1405
15785 getfattr -n user.attr $DIR/$tdir/$tfile &&
15786 error "getfattr should have failed with ENOMEM"
15787 $LCTL set_param fail_loc=0x0
15790 restore_lustre_params < $p
15793 run_test 234 "xattr cache should not crash on ENOMEM"
15796 [ $MDS1_VERSION -lt $(version_code 2.4.52) ] &&
15797 skip "Need MDS version at least 2.4.52"
15799 flock_deadlock $DIR/$tfile
15804 124) error "process hangs on a deadlock"
15806 *) error "error executing flock_deadlock $DIR/$tfile"
15810 run_test 235 "LU-1715: flock deadlock detection does not work properly"
15814 check_swap_layouts_support
15816 local ref1=/etc/passwd
15817 local ref2=/etc/group
15818 local file1=$DIR/$tdir/f1
15819 local file2=$DIR/$tdir/f2
15821 test_mkdir -c1 $DIR/$tdir
15822 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
15823 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
15824 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
15825 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
15826 local fd=$(free_fd)
15827 local cmd="exec $fd<>$file2"
15830 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
15831 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
15834 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
15839 run_test 236 "Layout swap on open unlinked file"
15841 # LU-4659 linkea consistency
15843 [[ $MDS1_VERSION -gt $(version_code 2.5.57) ]] ||
15844 [[ $MDS1_VERSION -gt $(version_code 2.5.1) &&
15845 $MDS1_VERSION -lt $(version_code 2.5.50) ]] ||
15846 skip "Need MDS version at least 2.5.58 or 2.5.2+"
15849 ln $DIR/$tfile $DIR/$tfile.lnk
15850 touch $DIR/$tfile.new
15851 mv $DIR/$tfile.new $DIR/$tfile
15852 local fid1=$($LFS path2fid $DIR/$tfile)
15853 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
15854 local path1=$($LFS fid2path $FSNAME "$fid1")
15855 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
15856 local path2=$($LFS fid2path $FSNAME "$fid2")
15857 [ $tfile.lnk == $path2 ] ||
15858 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
15861 run_test 238 "Verify linkea consistency"
15863 test_239A() { # was test_239
15864 [ $MDS1_VERSION -lt $(version_code 2.5.60) ] &&
15865 skip "Need MDS version at least 2.5.60"
15867 local list=$(comma_list $(mdts_nodes))
15869 mkdir -p $DIR/$tdir
15870 createmany -o $DIR/$tdir/f- 5000
15871 unlinkmany $DIR/$tdir/f- 5000
15872 [ $MDS1_VERSION -gt $(version_code 2.10.4) ] &&
15873 do_nodes $list "lctl set_param -n osp.*.force_sync=1"
15874 changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
15875 osp.*MDT*.sync_in_flight" | calc_sum)
15876 [ "$changes" -eq 0 ] || error "$changes not synced"
15878 run_test 239A "osp_sync test"
15880 test_239a() { #LU-5297
15881 remote_mds_nodsh && skip "remote MDS with nodsh"
15884 #define OBD_FAIL_OSP_CHECK_INVALID_REC 0x2100
15885 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
15886 chgrp $RUNAS_GID $DIR/$tfile
15887 wait_delete_completed
15889 run_test 239a "process invalid osp sync record correctly"
15891 test_239b() { #LU-5297
15892 remote_mds_nodsh && skip "remote MDS with nodsh"
15895 #define OBD_FAIL_OSP_CHECK_ENOMEM 0x2101
15896 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
15897 chgrp $RUNAS_GID $DIR/$tfile1
15898 wait_delete_completed
15899 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
15901 chgrp $RUNAS_GID $DIR/$tfile2
15902 wait_delete_completed
15904 run_test 239b "process osp sync record with ENOMEM error correctly"
15907 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
15908 remote_mds_nodsh && skip "remote MDS with nodsh"
15910 mkdir -p $DIR/$tdir
15912 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
15913 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
15914 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
15915 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
15917 umount_client $MOUNT || error "umount failed"
15918 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
15919 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
15920 mount_client $MOUNT || error "failed to mount client"
15922 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
15923 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
15925 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
15931 for LOOP in $(seq $count); do
15932 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 2>/dev/null
15933 cancel_lru_locks $OSC || true
15941 for LOOP in $(seq $1); do
15942 dd if=$DIR/$tfile of=/dev/null bs=$bsize count=1 iflag=direct \
15947 test_241a() { # was test_241
15948 local bsize=$PAGE_SIZE
15950 (( bsize < 40960 )) && bsize=40960
15951 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
15953 cancel_lru_locks $OSC
15954 test_241_bio 1000 $bsize &
15956 test_241_dio 1000 $bsize
15959 run_test 241a "bio vs dio"
15962 local bsize=$PAGE_SIZE
15964 (( bsize < 40960 )) && bsize=40960
15965 dd if=/dev/zero of=$DIR/$tfile count=1 bs=$bsize
15967 test_241_dio 1000 $bsize &
15969 test_241_dio 1000 $bsize
15972 run_test 241b "dio vs dio"
15975 remote_mds_nodsh && skip "remote MDS with nodsh"
15977 mkdir -p $DIR/$tdir
15978 touch $DIR/$tdir/$tfile
15980 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
15981 do_facet mds1 lctl set_param fail_loc=0x105
15982 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
15984 do_facet mds1 lctl set_param fail_loc=0
15985 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
15987 run_test 242 "mdt_readpage failure should not cause directory unreadable"
15991 test_mkdir $DIR/$tdir
15992 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
15994 run_test 243 "various group lock tests"
15998 test_mkdir $DIR/$tdir
15999 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=35
16000 sendfile_grouplock $DIR/$tdir/$tfile || \
16001 error "sendfile+grouplock failed"
16004 run_test 244 "sendfile with group lock tests"
16007 local flagname="multi_mod_rpcs"
16008 local connect_data_name="max_mod_rpcs"
16011 # check if multiple modify RPCs flag is set
16012 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import |
16013 grep "connect_flags:")
16016 echo "$out" | grep -qw $flagname
16017 if [ $? -ne 0 ]; then
16018 echo "connect flag $flagname is not set"
16022 # check if multiple modify RPCs data is set
16023 out=$($LCTL get_param mdc.$FSNAME-MDT0000-*.import)
16026 echo "$out" | grep -qw $connect_data_name ||
16027 error "import should have connect data $connect_data_name"
16029 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
16031 test_246() { # LU-7371
16032 remote_ost_nodsh && skip "remote OST with nodsh"
16033 [ $OST1_VERSION -lt $(version_code 2.7.62) ] &&
16034 skip "Need OST version >= 2.7.62"
16036 do_facet ost1 $LCTL set_param fail_val=4095
16037 #define OBD_FAIL_OST_READ_SIZE 0x234
16038 do_facet ost1 $LCTL set_param fail_loc=0x234
16039 $LFS setstripe $DIR/$tfile -i 0 -c 1
16040 dd if=/dev/zero of=$DIR/$tfile bs=4095 count=1 > /dev/null 2>&1
16041 cancel_lru_locks $FSNAME-OST0000
16042 dd if=$DIR/$tfile of=/dev/null bs=1048576 || error "Read failed"
16044 run_test 246 "Read file of size 4095 should return right length"
16050 umount_client $submount
16055 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16057 skip_env "Fileset feature is not supported"
16059 local submount=${MOUNT}_$tdir
16062 mkdir -p $submount || error "mkdir $submount failed"
16063 FILESET="$FILESET/$tdir" mount_client $submount ||
16064 error "mount $submount failed"
16065 trap "cleanup_247 $submount" EXIT
16066 echo foo > $submount/$tfile || error "write $submount/$tfile failed"
16067 [ $(cat $MOUNT/$tdir/$tfile) = "foo" ] ||
16068 error "read $MOUNT/$tdir/$tfile failed"
16069 cleanup_247 $submount
16071 run_test 247a "mount subdir as fileset"
16074 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16075 skip_env "Fileset feature is not supported"
16077 local submount=${MOUNT}_$tdir
16079 rm -rf $MOUNT/$tdir
16080 mkdir -p $submount || error "mkdir $submount failed"
16082 FILESET="$FILESET/$tdir" mount_client $submount &&
16083 error "mount $submount should fail"
16086 run_test 247b "mount subdir that dose not exist"
16089 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16090 skip_env "Fileset feature is not supported"
16092 local submount=${MOUNT}_$tdir
16094 mkdir -p $MOUNT/$tdir/dir1
16095 mkdir -p $submount || error "mkdir $submount failed"
16096 trap "cleanup_247 $submount" EXIT
16097 FILESET="$FILESET/$tdir" mount_client $submount ||
16098 error "mount $submount failed"
16099 local fid=$($LFS path2fid $MOUNT/)
16100 $LFS fid2path $submount $fid && error "fid2path should fail"
16101 cleanup_247 $submount
16103 run_test 247c "running fid2path outside root"
16106 lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
16107 skip "Fileset feature is not supported"
16109 local submount=${MOUNT}_$tdir
16111 mkdir -p $MOUNT/$tdir/dir1
16112 mkdir -p $submount || error "mkdir $submount failed"
16113 FILESET="$FILESET/$tdir" mount_client $submount ||
16114 error "mount $submount failed"
16115 trap "cleanup_247 $submount" EXIT
16116 local fid=$($LFS path2fid $submount/dir1)
16117 $LFS fid2path $submount $fid || error "fid2path should succeed"
16118 cleanup_247 $submount
16120 run_test 247d "running fid2path inside root"
16124 lctl get_param -n mdc.$FSNAME-MDT0000*.import |
16126 skip "Fileset feature is not supported"
16128 local submount=${MOUNT}_$tdir
16131 mkdir -p $submount || error "mkdir $submount failed"
16132 FILESET="$FILESET/.." mount_client $submount &&
16133 error "mount $submount should fail"
16136 run_test 247e "mount .. as fileset"
16139 local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
16140 [ -z "$fast_read_sav" ] && skip "no fast read support"
16142 # create a large file for fast read verification
16143 dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
16145 # make sure the file is created correctly
16146 $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
16147 { rm -f $DIR/$tfile; skip "file creation error"; }
16149 echo "Test 1: verify that fast read is 4 times faster on cache read"
16151 # small read with fast read enabled
16152 $LCTL set_param -n llite.*.fast_read=1
16153 local t_fast=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16154 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16155 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16156 # small read with fast read disabled
16157 $LCTL set_param -n llite.*.fast_read=0
16158 local t_slow=$(dd if=$DIR/$tfile of=/dev/null bs=4k 2>&1 |
16159 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16160 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16162 # verify that fast read is 4 times faster for cache read
16163 [ $(bc <<< "4 * $t_fast < $t_slow") -eq 1 ] ||
16164 error_not_in_vm "fast read was not 4 times faster: " \
16165 "$t_fast vs $t_slow"
16167 echo "Test 2: verify the performance between big and small read"
16168 $LCTL set_param -n llite.*.fast_read=1
16170 # 1k non-cache read
16171 cancel_lru_locks osc
16172 local t_1k=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16173 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16174 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16176 # 1M non-cache read
16177 cancel_lru_locks osc
16178 local t_1m=$(dd if=$DIR/$tfile of=/dev/null bs=1k 2>&1 |
16179 egrep -o '([[:digit:]\.\,e-]+) s' | cut -d's' -f1 |
16180 sed -e 's/,/./' -e 's/[eE]+*/\*10\^/')
16182 # verify that big IO is not 4 times faster than small IO
16183 [ $(bc <<< "4 * $t_1k >= $t_1m") -eq 1 ] ||
16184 error_not_in_vm "bigger IO is way too fast: $t_1k vs $t_1m"
16186 $LCTL set_param -n llite.*.fast_read=$fast_read_sav
16189 run_test 248 "fast read verification"
16191 test_249() { # LU-7890
16192 [ $MDS1_VERSION -lt $(version_code 2.8.53) ] &&
16193 skip "Need at least version 2.8.54"
16196 $SETSTRIPE -c 1 $DIR/$tfile
16197 # Offset 2T == 4k * 512M
16198 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
16199 error "dd to 2T offset failed"
16201 run_test 249 "Write above 2T file size"
16204 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
16205 && skip "no 16TB file size limit on ZFS"
16207 $SETSTRIPE -c 1 $DIR/$tfile
16208 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
16209 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
16210 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
16211 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
16212 conv=notrunc,fsync && error "append succeeded"
16215 run_test 250 "Write above 16T limit"
16218 $SETSTRIPE -c -1 -S 1048576 $DIR/$tfile
16220 #define OBD_FAIL_LLITE_LOST_LAYOUT 0x1407
16221 #Skip once - writing the first stripe will succeed
16222 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16223 $MULTIOP $DIR/$tfile o:O_RDWR:w2097152c 2>&1 | grep -q "short write" &&
16224 error "short write happened"
16226 $LCTL set_param fail_loc=0xa0001407 fail_val=1
16227 $MULTIOP $DIR/$tfile or2097152c 2>&1 | grep -q "short read" &&
16228 error "short read happened"
16232 run_test 251 "Handling short read and write correctly"
16235 remote_mds_nodsh && skip "remote MDS with nodsh"
16236 remote_ost_nodsh && skip "remote OST with nodsh"
16237 if [ "$ost1_FSTYPE" != "ldiskfs" -o "$mds1_FSTYPE" != "ldiskfs" ]; then
16238 skip_env "ldiskfs only test"
16248 # check lr_reader on OST0000
16250 dev=$(facet_device $tgt)
16251 out=$(do_facet $tgt $LR_READER $dev)
16252 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16254 uuid=$(echo "$out" | grep -i uuid | awk '{ print $2 }')
16255 [ "$uuid" == "$(ostuuid_from_index 0)" ] ||
16256 error "Invalid uuid returned by $LR_READER on target $tgt"
16257 echo -e "uuid returned by $LR_READER is '$uuid'\n"
16259 # check lr_reader -c on MDT0000
16261 dev=$(facet_device $tgt)
16262 if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
16263 skip "$LR_READER does not support additional options"
16265 out=$(do_facet $tgt $LR_READER -c $dev)
16266 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16268 num=$(echo "$out" | grep -c "mdtlov")
16269 [ "$num" -eq $((MDSCOUNT - 1)) ] ||
16270 error "Invalid number of mdtlov clients returned by $LR_READER"
16271 echo -e "Number of mdtlov clients returned by $LR_READER is '$num'\n"
16273 # check lr_reader -cr on MDT0000
16274 out=$(do_facet $tgt $LR_READER -cr $dev)
16275 [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
16277 echo "$out" | grep -q "^reply_data:$" ||
16278 error "$LR_READER should have returned 'reply_data' section"
16279 num=$(echo "$out" | grep -c "client_generation")
16280 echo -e "Number of reply data returned by $LR_READER is '$num'\n"
16282 run_test 252 "check lr_reader tool"
16284 test_253_fill_ost() {
16285 local size_mb #how many MB should we write to pass watermark
16286 local lwm=$3 #low watermark
16287 local free_10mb #10% of free space
16289 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16290 size_mb=$((free_kb / 1024 - lwm))
16291 free_10mb=$((free_kb / 10240))
16292 #If 10% of free space cross low watermark use it
16293 if (( free_10mb > size_mb )); then
16296 #At least we need to store 1.1 of difference between
16297 #free space and low watermark
16298 size_mb=$((size_mb + size_mb / 10))
16300 if (( lwm <= $((free_kb / 1024)) )) || [ ! -f $DIR/$tdir/1 ]; then
16301 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M count=$size_mb \
16302 oflag=append conv=notrunc
16307 free_kb=$($LFS df $MOUNT | grep $1 | awk '{ print $4 }')
16308 echo "OST still has $((free_kb / 1024)) mbytes free"
16312 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16313 remote_mds_nodsh && skip "remote MDS with nodsh"
16314 remote_mgs_nodsh && skip "remote MGS with nodsh"
16319 local ost_name=$($LFS osts |
16320 sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
16322 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
16323 do_facet $SINGLEMDS $LCTL get_param -n \
16324 osp.$mdtosc_proc1.reserved_mb_high ||
16325 skip "remote MDS does not support reserved_mb_high"
16329 wait_delete_completed
16332 local last_wm_h=$(do_facet $SINGLEMDS $LCTL get_param -n \
16333 osp.$mdtosc_proc1.reserved_mb_high)
16334 local last_wm_l=$(do_facet $SINGLEMDS $LCTL get_param -n \
16335 osp.$mdtosc_proc1.reserved_mb_low)
16336 echo "prev high watermark $last_wm_h, prev low watermark $last_wm_l"
16338 if ! combined_mgs_mds ; then
16341 create_pool $FSNAME.$TESTNAME || error "Pool creation failed"
16342 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $ost_name ||
16343 error "Adding $ost_name to pool failed"
16345 # Wait for client to see a OST at pool
16346 wait_update $HOSTNAME "$LCTL get_param -n
16347 lov.$FSNAME-*.pools.$TESTNAME | sort -u |
16348 grep $ost_name" "$ost_name""_UUID" $((TIMEOUT/2)) ||
16349 error "Client can not see the pool"
16350 $SETSTRIPE $DIR/$tdir -i $ostidx -c 1 -p $FSNAME.$TESTNAME ||
16351 error "Setstripe failed"
16353 dd if=/dev/zero of=$DIR/$tdir/0 bs=1M count=10
16354 local blocks=$($LFS df $MOUNT | grep $ost_name | awk '{ print $4 }')
16355 echo "OST still has $((blocks/1024)) mbytes free"
16357 local new_lwm=$((blocks/1024-10))
16358 do_facet $SINGLEMDS $LCTL set_param \
16359 osp.$mdtosc_proc1.reserved_mb_high=$((new_lwm+5))
16360 do_facet $SINGLEMDS $LCTL set_param \
16361 osp.$mdtosc_proc1.reserved_mb_low=$new_lwm
16363 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16365 #First enospc could execute orphan deletion so repeat.
16366 test_253_fill_ost $ost_name $mdtosc_proc1 $new_lwm
16368 local oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16369 osp.$mdtosc_proc1.prealloc_status)
16370 echo "prealloc_status $oa_status"
16372 dd if=/dev/zero of=$DIR/$tdir/2 bs=1M count=1 &&
16373 error "File creation should fail"
16374 #object allocation was stopped, but we still able to append files
16375 dd if=/dev/zero of=$DIR/$tdir/1 bs=1M seek=6 count=5 oflag=append ||
16376 error "Append failed"
16377 rm -f $DIR/$tdir/1 $DIR/$tdir/0 $DIR/$tdir/r*
16379 wait_delete_completed
16383 for i in $(seq 10 12); do
16384 dd if=/dev/zero of=$DIR/$tdir/$i bs=1M count=1 2>/dev/null ||
16385 error "File creation failed after rm";
16388 oa_status=$(do_facet $SINGLEMDS $LCTL get_param -n \
16389 osp.$mdtosc_proc1.prealloc_status)
16390 echo "prealloc_status $oa_status"
16392 if (( oa_status != 0 )); then
16393 error "Object allocation still disable after rm"
16395 do_facet $SINGLEMDS $LCTL set_param \
16396 osp.$mdtosc_proc1.reserved_mb_high=$last_wm_h
16397 do_facet $SINGLEMDS $LCTL set_param \
16398 osp.$mdtosc_proc1.reserved_mb_low=$last_wm_l
16401 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $ost_name ||
16402 error "Remove $ost_name from pool failed"
16403 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
16404 error "Pool destroy fialed"
16406 if ! combined_mgs_mds ; then
16410 run_test 253 "Check object allocation limit"
16413 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16414 remote_mds_nodsh && skip "remote MDS with nodsh"
16415 do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
16416 skip "MDS does not support changelog_size"
16419 local MDT0=$(facet_svc $SINGLEMDS)
16421 changelog_register || error "changelog_register failed"
16423 changelog_clear 0 || error "changelog_clear failed"
16425 local size1=$(do_facet $SINGLEMDS \
16426 $LCTL get_param -n mdd.$MDT0.changelog_size)
16427 echo "Changelog size $size1"
16430 $LFS mkdir -i 0 $DIR/$tdir
16432 mkdir -p $DIR/$tdir/pics/2008/zachy
16433 touch $DIR/$tdir/pics/2008/zachy/timestamp
16434 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
16435 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
16436 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
16437 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
16438 rm $DIR/$tdir/pics/desktop.jpg
16440 local size2=$(do_facet $SINGLEMDS \
16441 $LCTL get_param -n mdd.$MDT0.changelog_size)
16442 echo "Changelog size after work $size2"
16444 (( $size2 > $size1 )) ||
16445 error "new Changelog size=$size2 less than old size=$size1"
16447 run_test 254 "Check changelog size"
16454 lfs ladvise -a invalid $file 2>&1 | grep "Valid types" |
16455 awk -F: '{print $2}' | grep $type > /dev/null
16456 if [ $? -ne 0 ]; then
16466 lfs ladvise -a willread $file > /dev/null 2>&1
16467 if [ $? -eq 0 ]; then
16471 lfs ladvise -a willread $file 2>&1 |
16472 grep "Inappropriate ioctl for device" > /dev/null
16473 if [ $? -eq 0 ]; then
16480 bc <<<"scale=2; ($1 - $2) * 100 / $2"
16483 # run a random read IO workload
16484 # usage: random_read_iops <filename> <filesize> <iosize>
16485 random_read_iops() {
16488 local iosize=${3:-4096}
16490 $READS -f $file -s $fsize -b $iosize -n $((fsize / iosize)) -t 60 |
16491 sed -e '/^$/d' -e 's#.*s, ##' -e 's#MB/s##'
16494 drop_file_oss_cache() {
16498 $LFS ladvise -a dontneed $file 2>/dev/null ||
16499 do_nodes $nodes "echo 3 > /proc/sys/vm/drop_caches"
16502 ladvise_willread_performance()
16505 local average_origin=0
16506 local average_cache=0
16507 local average_ladvise=0
16509 for ((i = 1; i <= $repeat; i++)); do
16510 echo "Iter $i/$repeat: reading without willread hint"
16511 cancel_lru_locks osc
16512 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16513 local speed_origin=$(random_read_iops $DIR/$tfile $size)
16514 echo "Iter $i/$repeat: uncached speed: $speed_origin"
16515 average_origin=$(bc <<<"$average_origin + $speed_origin")
16517 cancel_lru_locks osc
16518 local speed_cache=$(random_read_iops $DIR/$tfile $size)
16519 echo "Iter $i/$repeat: OSS cache speed: $speed_cache"
16520 average_cache=$(bc <<<"$average_cache + $speed_cache")
16522 cancel_lru_locks osc
16523 drop_file_oss_cache $DIR/$tfile $(comma_list $(osts_nodes))
16524 $LFS ladvise -a willread $DIR/$tfile || error "ladvise failed"
16525 local speed_ladvise=$(random_read_iops $DIR/$tfile $size)
16526 echo "Iter $i/$repeat: ladvise speed: $speed_ladvise"
16527 average_ladvise=$(bc <<<"$average_ladvise + $speed_ladvise")
16529 average_origin=$(bc <<<"scale=2; $average_origin / $repeat")
16530 average_cache=$(bc <<<"scale=2; $average_cache / $repeat")
16531 average_ladvise=$(bc <<<"scale=2; $average_ladvise / $repeat")
16533 speedup_cache=$(percent $average_cache $average_origin)
16534 speedup_ladvise=$(percent $average_ladvise $average_origin)
16536 echo "Average uncached read: $average_origin"
16537 echo "Average speedup with OSS cached read: " \
16538 "$average_cache = +$speedup_cache%"
16539 echo "Average speedup with ladvise willread: " \
16540 "$average_ladvise = +$speedup_ladvise%"
16542 local lowest_speedup=20
16543 if [ ${average_cache%.*} -lt $lowest_speedup ]; then
16544 echo "Speedup with OSS cached read less than $lowest_speedup%," \
16545 "got $average_cache%. Skipping ladvise willread check."
16549 # the test won't work on ZFS until it supports 'ladvise dontneed', but
16550 # it is still good to run until then to exercise 'ladvise willread'
16551 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16552 [ "$ost1_FSTYPE" = "zfs" ] &&
16553 echo "osd-zfs does not support dontneed or drop_caches" &&
16556 lowest_speedup=$(bc <<<"scale=2; $average_cache / 2")
16557 [ ${average_ladvise%.*} -gt $lowest_speedup ] ||
16558 error_not_in_vm "Speedup with willread is less than " \
16559 "$lowest_speedup%, got $average_ladvise%"
16563 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16564 skip "lustre < 2.8.54 does not support ladvise "
16565 remote_ost_nodsh && skip "remote OST with nodsh"
16567 lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
16569 ladvise_no_type willread $DIR/$tfile &&
16570 skip "willread ladvise is not supported"
16572 ladvise_no_ioctl $DIR/$tfile &&
16573 skip "ladvise ioctl is not supported"
16576 local size=$((size_mb * 1048576))
16577 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16578 error "dd to $DIR/$tfile failed"
16580 lfs ladvise -a willread $DIR/$tfile ||
16581 error "Ladvise failed with no range argument"
16583 lfs ladvise -a willread -s 0 $DIR/$tfile ||
16584 error "Ladvise failed with no -l or -e argument"
16586 lfs ladvise -a willread -e 1 $DIR/$tfile ||
16587 error "Ladvise failed with only -e argument"
16589 lfs ladvise -a willread -l 1 $DIR/$tfile ||
16590 error "Ladvise failed with only -l argument"
16592 lfs ladvise -a willread -s 2 -e 1 $DIR/$tfile &&
16593 error "End offset should not be smaller than start offset"
16595 lfs ladvise -a willread -s 2 -e 2 $DIR/$tfile &&
16596 error "End offset should not be equal to start offset"
16598 lfs ladvise -a willread -s $size -l 1 $DIR/$tfile ||
16599 error "Ladvise failed with overflowing -s argument"
16601 lfs ladvise -a willread -s 1 -e $((size + 1)) $DIR/$tfile ||
16602 error "Ladvise failed with overflowing -e argument"
16604 lfs ladvise -a willread -s 1 -l $size $DIR/$tfile ||
16605 error "Ladvise failed with overflowing -l argument"
16607 lfs ladvise -a willread -l 1 -e 2 $DIR/$tfile &&
16608 error "Ladvise succeeded with conflicting -l and -e arguments"
16610 echo "Synchronous ladvise should wait"
16612 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237
16613 do_nodes $(comma_list $(osts_nodes)) \
16614 $LCTL set_param fail_val=$delay fail_loc=0x237
16616 local start_ts=$SECONDS
16617 lfs ladvise -a willread $DIR/$tfile ||
16618 error "Ladvise failed with no range argument"
16619 local end_ts=$SECONDS
16620 local inteval_ts=$((end_ts - start_ts))
16622 if [ $inteval_ts -lt $(($delay - 1)) ]; then
16623 error "Synchronous advice didn't wait reply"
16626 echo "Asynchronous ladvise shouldn't wait"
16627 local start_ts=$SECONDS
16628 lfs ladvise -a willread -b $DIR/$tfile ||
16629 error "Ladvise failed with no range argument"
16630 local end_ts=$SECONDS
16631 local inteval_ts=$((end_ts - start_ts))
16633 if [ $inteval_ts -gt $(($delay / 2)) ]; then
16634 error "Asynchronous advice blocked"
16637 do_nodes $(comma_list $(osts_nodes)) $LCTL set_param fail_loc=0
16638 ladvise_willread_performance
16640 run_test 255a "check 'lfs ladvise -a willread'"
16646 do_facet $facet "cat /proc/meminfo | grep ^${info}:" | awk '{print $2}'
16650 [ $OST1_VERSION -lt $(version_code 2.8.54) ] &&
16651 skip "lustre < 2.8.54 does not support ladvise "
16652 remote_ost_nodsh && skip "remote OST with nodsh"
16654 lfs setstripe -c 1 -i 0 $DIR/$tfile
16656 ladvise_no_type dontneed $DIR/$tfile &&
16657 skip "dontneed ladvise is not supported"
16659 ladvise_no_ioctl $DIR/$tfile &&
16660 skip "ladvise ioctl is not supported"
16662 ! $LFS ladvise -a dontneed $DIR/$tfile &&
16663 [ "$ost1_FSTYPE" = "zfs" ] &&
16664 skip "zfs-osd does not support 'ladvise dontneed'"
16667 local size=$((size_mb * 1048576))
16668 # In order to prevent disturbance of other processes, only check 3/4
16669 # of the memory usage
16670 local kibibytes=$((size_mb * 1024 * 3 / 4))
16672 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
16673 error "dd to $DIR/$tfile failed"
16675 #force write to complete before dropping OST cache & checking memory
16678 local total=$(facet_meminfo ost1 MemTotal)
16679 echo "Total memory: $total KiB"
16681 do_facet ost1 "sync && echo 3 > /proc/sys/vm/drop_caches"
16682 local before_read=$(facet_meminfo ost1 Cached)
16683 echo "Cache used before read: $before_read KiB"
16685 lfs ladvise -a willread $DIR/$tfile ||
16686 error "Ladvise willread failed"
16687 local after_read=$(facet_meminfo ost1 Cached)
16688 echo "Cache used after read: $after_read KiB"
16690 lfs ladvise -a dontneed $DIR/$tfile ||
16691 error "Ladvise dontneed again failed"
16692 local no_read=$(facet_meminfo ost1 Cached)
16693 echo "Cache used after dontneed ladvise: $no_read KiB"
16695 if [ $total -lt $((before_read + kibibytes)) ]; then
16696 echo "Memory is too small, abort checking"
16700 if [ $((before_read + kibibytes)) -gt $after_read ]; then
16701 error "Ladvise willread should use more memory" \
16702 "than $kibibytes KiB"
16705 if [ $((no_read + kibibytes)) -gt $after_read ]; then
16706 error "Ladvise dontneed should release more memory" \
16707 "than $kibibytes KiB"
16710 run_test 255b "check 'lfs ladvise -a dontneed'"
16713 [ $OST1_VERSION -lt $(version_code 2.10.50) ] &&
16714 skip "lustre < 2.10.53 does not support lockahead"
16722 test_mkdir -p $DIR/$tdir
16723 $SETSTRIPE -i 0 $DIR/$tdir
16725 #test 10 returns only success/failure
16727 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16729 if [ $rc -eq 255 ]; then
16730 error "Ladvise test${i} failed, ${rc}"
16733 #test 11 counts lock enqueue requests, all others count new locks
16735 count=$(do_facet ost1 \
16736 $LCTL get_param -n ost.OSS.ost.stats)
16737 count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
16739 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16741 if [ $rc -eq 255 ]; then
16742 error "Ladvise test${i} failed, ${rc}"
16745 new_count=$(do_facet ost1 \
16746 $LCTL get_param -n ost.OSS.ost.stats)
16747 new_count=$(echo "$new_count" | grep ldlm_extent_enqueue | \
16748 awk '{ print $2 }')
16750 difference="$((new_count - count))"
16751 if [ $difference -ne $rc ]; then
16752 error "Ladvise test${i}, bad enqueue count, returned " \
16753 "${rc}, actual ${difference}"
16756 for i in $(seq 12 21); do
16757 # If we do not do this, we run the risk of having too many
16758 # locks and starting lock cancellation while we are checking
16760 cancel_lru_locks osc
16762 count=$($LCTL get_param -n \
16763 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
16765 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16767 if [ $rc -eq 255 ]; then
16768 error "Ladvise test ${i} failed, ${rc}"
16771 new_count=$($LCTL get_param -n \
16772 ldlm.namespaces.$FSNAME-OST0000*osc-[-0-9a-f]*.lock_unused_count)
16773 difference="$((new_count - count))"
16775 # Test 15 output is divided by 100 to map down to valid return
16776 if [ $i -eq 15 ]; then
16780 if [ $difference -ne $rc ]; then
16781 error "Ladvise test ${i}, bad lock count, returned " \
16782 "${rc}, actual ${difference}"
16786 #test 22 returns only success/failure
16788 lockahead_test -d $DIR/$tdir -t $i -f $tfile
16790 if [ $rc -eq 255 ]; then
16791 error "Ladvise test${i} failed, ${rc}"
16794 run_test 255c "suite of ladvise lockahead tests"
16797 [ $PARALLEL == "yes" ] && skip "skip parallel run"
16798 remote_mds_nodsh && skip "remote MDS with nodsh"
16799 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
16800 changelog_users $SINGLEMDS | grep "^cl" &&
16801 skip "active changelog user"
16807 mdt_dev=$(mdsdevname 1)
16810 changelog_register || error "changelog_register failed"
16813 mkdir -p $DIR/$tdir
16815 changelog_clear 0 || error "changelog_clear failed"
16818 touch $DIR/$tdir/{1..10}
16821 stop $SINGLEMDS || error "Fail to stop MDT"
16825 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
16827 #after mount new plainllog is used
16828 touch $DIR/$tdir/{11..19}
16829 local tmpfile=$(mktemp -u $tfile.XXXXXX)
16830 cat_sl=$(do_facet $SINGLEMDS "sync; \
16831 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16832 llog_reader $tmpfile | grep -c type=1064553b")
16833 do_facet $SINGLEMDS llog_reader $tmpfile
16835 [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
16837 changelog_clear 0 || error "changelog_clear failed"
16839 cat_sl=$(do_facet $SINGLEMDS "sync; \
16840 $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
16841 llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
16843 if (( cat_sl == 2 )); then
16844 error "Empty plain llog was not deleted from changelog catalog"
16845 elif (( cat_sl != 1 )); then
16846 error "Active plain llog shouldn't be deleted from catalog"
16849 run_test 256 "Check llog delete for empty and not full state"
16852 remote_mds_nodsh && skip "remote MDS with nodsh"
16853 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
16854 skip "Need MDS version at least 2.8.55"
16856 test_mkdir $DIR/$tdir
16858 setfattr -n trusted.name1 -v value1 $DIR/$tdir ||
16859 error "setfattr -n trusted.name1=value1 $DIR/$tdir failed"
16862 #define OBD_FAIL_MDS_XATTR_REP 0x161
16863 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
16864 local facet=mds$((mdtidx + 1))
16865 set_nodes_failloc $(facet_active_host $facet) 0x80000161
16866 getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
16868 stop $facet || error "stop MDS failed"
16869 start $facet $(mdsdevname $((mdtidx + 1))) $MDS_MOUNT_OPTS ||
16870 error "start MDS fail"
16872 run_test 257 "xattr locks are not lost"
16874 # Verify we take the i_mutex when security requires it
16876 #define OBD_FAIL_IMUTEX_SEC 0x141c
16877 $LCTL set_param fail_loc=0x141c
16879 chmod u+s $DIR/$tfile
16880 chmod a+rwx $DIR/$tfile
16881 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16883 if [ $RC -ne 0 ]; then
16884 error "error, failed to take i_mutex, rc=$?"
16890 # Verify we do NOT take the i_mutex in the normal case
16892 #define OBD_FAIL_IMUTEX_NOSEC 0x141d
16893 $LCTL set_param fail_loc=0x141d
16896 chmod a+rw $DIR/$tfile
16897 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 oflag=append
16899 if [ $RC -ne 0 ]; then
16900 error "error, took i_mutex unnecessarily, rc=$?"
16905 run_test 258b "verify i_mutex security behavior"
16908 local file=$DIR/$tfile
16912 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip "ldiskfs only test"
16914 stack_trap "rm -f $file" EXIT
16916 wait_delete_completed
16917 before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16918 echo "before: $before"
16920 $LFS setstripe -i 0 -c 1 $file
16921 dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
16923 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16924 echo "after write: $after"
16926 #define OBD_FAIL_OSD_FAIL_AT_TRUNCATE 0x2301
16927 do_facet ost1 $LCTL set_param fail_loc=0x2301
16929 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16930 echo "after truncate: $after"
16933 do_facet ost1 $LCTL set_param fail_loc=0
16934 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
16936 after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
16937 echo "after restart: $after"
16938 [ $((after - before)) -ge $(fs_log_size ost1) ] &&
16939 error "missing truncate?"
16943 run_test 259 "crash at delayed truncate"
16946 #define OBD_FAIL_MDC_CLOSE 0x806
16947 $LCTL set_param fail_loc=0x80000806
16951 run_test 260 "Check mdc_close fail"
16953 ### Data-on-MDT sanity tests ###
16955 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
16956 skip "Need MDS version at least 2.10.55 for DoM"
16959 local dom=$DIR/$tdir/dom_file
16960 local tmp=$DIR/$tdir/tmp_file
16962 mkdir -p $DIR/$tdir
16964 # basic checks for DoM component creation
16965 $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
16966 error "Can set MDT layout to non-first entry"
16968 $LFS setstripe -E 1024K -L mdt -E 2048K -L mdt $dom 2>/dev/null &&
16969 error "Can define multiple entries as MDT layout"
16971 $LFS setstripe -E 1M -L mdt $dom || error "Can't create DoM layout"
16973 [ $($LFS getstripe -L $dom) == "mdt" ] || error "bad pattern"
16974 [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
16975 [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
16977 local mdtidx=$($LFS getstripe -m $dom)
16978 local mdtname=MDT$(printf %04x $mdtidx)
16979 local facet=mds$((mdtidx + 1))
16980 local space_check=1
16982 # Skip free space checks with ZFS
16983 [ "$(facet_fstype $facet)" == "zfs" ] && space_check=0
16987 local size_tmp=$((65536 * 3))
16988 local mdtfree1=$(do_facet $facet \
16989 lctl get_param -n osd*.*$mdtname.kbytesfree)
16991 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
16992 # check also direct IO along write
16993 # IO size must be a multiple of PAGE_SIZE on all platforms (ARM=64KB)
16994 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
16996 cmp $tmp $dom || error "file data is different"
16997 [ $(stat -c%s $dom) == $size_tmp ] ||
16998 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
16999 if [ $space_check == 1 ]; then
17000 local mdtfree2=$(do_facet $facet \
17001 lctl get_param -n osd*.*$mdtname.kbytesfree)
17003 # increase in usage from by $size_tmp
17004 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17005 error "MDT free space wrong after write: " \
17006 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17010 local size_dom=10000
17012 $TRUNCATE $dom $size_dom
17013 [ $(stat -c%s $dom) == $size_dom ] ||
17014 error "bad size after truncate: $(stat -c%s $dom) != $size_dom"
17015 if [ $space_check == 1 ]; then
17016 mdtfree1=$(do_facet $facet \
17017 lctl get_param -n osd*.*$mdtname.kbytesfree)
17018 # decrease in usage from $size_tmp to new $size_dom
17019 [ $(($mdtfree1 - $mdtfree2)) -ge \
17020 $(((size_tmp - size_dom) / 1024)) ] ||
17021 error "MDT free space is wrong after truncate: " \
17022 "$mdtfree1 >= $mdtfree2 + ($size_tmp - $size_dom) / 1024"
17028 size_dom=$((size_dom + size_tmp))
17029 [ $(stat -c%s $dom) == $size_dom ] ||
17030 error "bad size after append: $(stat -c%s $dom) != $size_dom"
17031 if [ $space_check == 1 ]; then
17032 mdtfree2=$(do_facet $facet \
17033 lctl get_param -n osd*.*$mdtname.kbytesfree)
17034 # increase in usage by $size_tmp from previous
17035 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_tmp / 1024)) ] ||
17036 error "MDT free space is wrong after append: " \
17037 "$mdtfree1 >= $mdtfree2 + $size_tmp/1024"
17042 if [ $space_check == 1 ]; then
17043 mdtfree1=$(do_facet $facet \
17044 lctl get_param -n osd*.*$mdtname.kbytesfree)
17045 # decrease in usage by $size_dom from previous
17046 [ $(($mdtfree1 - $mdtfree2)) -ge $((size_dom / 1024)) ] ||
17047 error "MDT free space is wrong after removal: " \
17048 "$mdtfree1 >= $mdtfree2 + $size_dom/1024"
17051 # combined striping
17052 $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
17053 error "Can't create DoM + OST striping"
17055 size_tmp=2031616 # must be a multiple of PAGE_SIZE=65536 on ARM
17056 dd if=/dev/urandom of=$tmp bs=1024 count=$((size_tmp / 1024))
17057 # check also direct IO along write
17058 dd if=$tmp of=$dom bs=65536 count=$((size_tmp / 65536)) oflag=direct
17060 cmp $tmp $dom || error "file data is different"
17061 [ $(stat -c%s $dom) == $size_tmp ] ||
17062 error "bad size after write: $(stat -c%s $dom) != $size_tmp"
17067 run_test 270a "DoM: basic functionality tests"
17070 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17071 skip "Need MDS version at least 2.10.55"
17073 local dom=$DIR/$tdir/dom_file
17074 local max_size=1048576
17076 mkdir -p $DIR/$tdir
17077 $LFS setstripe -E $max_size -L mdt $dom
17079 # truncate over the limit
17080 $TRUNCATE $dom $(($max_size + 1)) &&
17081 error "successful truncate over the maximum size"
17082 # write over the limit
17083 dd if=/dev/zero of=$dom bs=$max_size seek=1 count=1 &&
17084 error "successful write over the maximum size"
17085 # append over the limit
17086 dd if=/dev/zero of=$dom bs=$(($max_size - 3)) count=1
17087 echo "12345" >> $dom && error "successful append over the maximum size"
17092 run_test 270b "DoM: maximum size overflow checks for DoM-only file"
17095 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17096 skip "Need MDS version at least 2.10.55"
17098 mkdir -p $DIR/$tdir
17099 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17101 # check files inherit DoM EA
17102 touch $DIR/$tdir/first
17103 [ $($GETSTRIPE -L $DIR/$tdir/first) == "mdt" ] ||
17104 error "bad pattern"
17105 [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
17106 error "bad stripe count"
17107 [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
17108 error "bad stripe size"
17110 # check directory inherits DoM EA and uses it as default
17111 mkdir $DIR/$tdir/subdir
17112 touch $DIR/$tdir/subdir/second
17113 [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == "mdt" ] ||
17114 error "bad pattern in sub-directory"
17115 [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
17116 error "bad stripe count in sub-directory"
17117 [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
17118 error "bad stripe size in sub-directory"
17121 run_test 270c "DoM: DoM EA inheritance tests"
17124 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17125 skip "Need MDS version at least 2.10.55"
17127 mkdir -p $DIR/$tdir
17128 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17130 # inherit default DoM striping
17131 mkdir $DIR/$tdir/subdir
17132 touch $DIR/$tdir/subdir/f1
17134 # change default directory striping
17135 $LFS setstripe -c 1 $DIR/$tdir/subdir
17136 touch $DIR/$tdir/subdir/f2
17137 [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
17138 error "wrong default striping in file 2"
17139 [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == "raid0" ] ||
17140 error "bad pattern in file 2"
17143 run_test 270d "DoM: change striping from DoM to RAID0"
17146 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17147 skip "Need MDS version at least 2.10.55"
17149 mkdir -p $DIR/$tdir/dom
17150 mkdir -p $DIR/$tdir/norm
17153 $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
17154 $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
17156 createmany -o $DIR/$tdir/dom/dom- $DOMFILES
17157 createmany -o $DIR/$tdir/norm/norm- $NORMFILES
17159 # find DoM files by layout
17160 NUM=$($LFS find -L mdt -type f $DIR/$tdir 2>/dev/null | wc -l)
17161 [ $NUM -eq $DOMFILES ] ||
17162 error "lfs find -L: found $NUM, expected $DOMFILES"
17163 echo "Test 1: lfs find 20 DOM files by layout: OK"
17165 # there should be 1 dir with default DOM striping
17166 NUM=$($LFS find -L mdt -type d $DIR/$tdir 2>/dev/null | wc -l)
17168 error "lfs find -L: found $NUM, expected 1 dir"
17169 echo "Test 2: lfs find 1 DOM dir by layout: OK"
17171 # find DoM files by stripe size
17172 NUM=$($LFS find -S -1200K -type f $DIR/$tdir 2>/dev/null | wc -l)
17173 [ $NUM -eq $DOMFILES ] ||
17174 error "lfs find -S: found $NUM, expected $DOMFILES"
17175 echo "Test 4: lfs find 20 DOM files by stripe size: OK"
17177 # find files by stripe offset except DoM files
17178 NUM=$($LFS find -i 0 -type f $DIR/$tdir 2>/dev/null | wc -l)
17179 [ $NUM -eq $NORMFILES ] ||
17180 error "lfs find -i: found $NUM, expected $NORMFILES"
17181 echo "Test 5: lfs find no DOM files by stripe index: OK"
17184 run_test 270e "DoM: lfs find with DoM files test"
17187 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17188 skip "Need MDS version at least 2.10.55"
17190 local mdtname=${FSNAME}-MDT0000-mdtlov
17191 local dom=$DIR/$tdir/dom_file
17192 local dom_limit_saved=$(do_facet mds1 $LCTL get_param -n \
17193 lod.$mdtname.dom_stripesize)
17194 local dom_limit=131072
17196 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=$dom_limit
17197 local dom_current=$(do_facet mds1 $LCTL get_param -n \
17198 lod.$mdtname.dom_stripesize)
17199 [ ${dom_limit} -eq ${dom_current} ] ||
17200 error "Cannot change per-MDT DoM stripe limit to $dom_limit"
17202 $LFS mkdir -i 0 -c 1 $DIR/$tdir
17203 $LFS setstripe -d $DIR/$tdir
17204 $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
17205 error "Can't set directory default striping"
17207 # exceed maximum stripe size
17208 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17209 error "Can't create file with $((dom_limit * 2)) DoM stripe"
17210 [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
17211 error "Able to create DoM component size more than LOD limit"
17213 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
17214 dom_current=$(do_facet mds1 $LCTL get_param -n \
17215 lod.$mdtname.dom_stripesize)
17216 [ 0 -eq ${dom_current} ] ||
17217 error "Can't set zero DoM stripe limit"
17220 # attempt to create DoM file on server with disabled DoM should
17221 # remove DoM entry from layout and be succeed
17222 $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
17223 error "Can't create DoM file (DoM is disabled)"
17224 [ $($LFS getstripe -L $dom) == "mdt" ] &&
17225 error "File has DoM component while DoM is disabled"
17228 # attempt to create DoM file with only DoM stripe should return error
17229 $LFS setstripe -E $dom_limit -L mdt $dom &&
17230 error "Able to create DoM-only file while DoM is disabled"
17232 # too low values to be aligned with smallest stripe size 64K
17233 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
17234 dom_current=$(do_facet mds1 $LCTL get_param -n \
17235 lod.$mdtname.dom_stripesize)
17236 [ 30000 -eq ${dom_current} ] &&
17237 error "Can set too small DoM stripe limit"
17239 # 64K is a minimal stripe size in Lustre, expect limit of that size
17240 [ 65536 -eq ${dom_current} ] ||
17241 error "Limit is not set to 64K but ${dom_current}"
17243 do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
17244 dom_current=$(do_facet mds1 $LCTL get_param -n \
17245 lod.$mdtname.dom_stripesize)
17247 [ 2147483648 -eq ${dom_current} ] &&
17248 error "Can set too large DoM stripe limit"
17250 do_facet mds1 $LCTL set_param -n \
17251 lod.$mdtname.dom_stripesize=$((dom_limit * 2))
17252 $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
17253 error "Can't create DoM component size after limit change"
17254 do_facet mds1 $LCTL set_param -n \
17255 lod.$mdtname.dom_stripesize=$((dom_limit / 2))
17256 $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
17257 error "Can't create DoM file after limit decrease"
17258 [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
17259 error "Can create big DoM component after limit decrease"
17260 touch ${dom}_def ||
17261 error "Can't create file with old default layout"
17263 do_facet mds1 $LCTL set_param -n lod.*.dom_stripesize=$dom_limit_saved
17266 run_test 270f "DoM: maximum DoM stripe size checks"
17269 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17270 skip "Need MDS version at least 2.10.55"
17272 local dom=$DIR/$tdir/dom
17274 mkdir -p $DIR/$tdir
17276 $LFS setstripe -E 1024K -L mdt $dom
17278 lctl set_param -n mdc.*.stats=clear
17279 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17280 cat $dom > /dev/null
17281 local reads=$(lctl get_param -n mdc.*.stats | grep -c ost_read)
17282 [ $reads -eq 0 ] || error "Unexpected $reads READ RPCs"
17286 run_test 271a "DoM: data is cached for read after write"
17289 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17290 skip "Need MDS version at least 2.10.55"
17292 local dom=$DIR/$tdir/dom
17294 mkdir -p $DIR/$tdir
17296 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17298 lctl set_param -n mdc.*.stats=clear
17299 dd if=/dev/zero of=$dom bs=4096 count=1 || return 1
17300 cancel_lru_locks mdc
17301 $CHECKSTAT -t file -s 4096 $dom || error "stat #1 fails"
17302 # second stat to check size is cached on client
17303 $CHECKSTAT -t file -s 4096 $dom || error "stat #2 fails"
17304 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17305 [ $gls -eq 0 ] || error "Unexpected $gls glimpse RPCs"
17308 run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
17311 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17312 skip "Need MDS version at least 2.10.55"
17314 local dom=$DIR/$tdir/dom
17316 mkdir -p $DIR/$tdir
17318 $LFS setstripe -E 1024K -L mdt -E EOF $dom
17320 lctl set_param -n mdc.*.stats=clear
17321 lctl set_param -n osc.*.stats=clear
17322 dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
17323 cancel_lru_locks mdc
17324 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17325 # second stat to check size is cached on client
17326 $CHECKSTAT -t file -s 2097152 $dom || error "stat"
17327 local gls=$(lctl get_param -n mdc.*.stats | grep -c ldlm_glimpse)
17328 [ $gls == 0 ] || error "Unexpected $gls glimpse RPCs"
17329 local gls=$(lctl get_param -n osc.*.stats | grep -c ldlm_glimpse)
17330 [ $gls == 0 ] || error "Unexpected $gls OSC glimpse RPCs"
17333 run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
17339 local mdt=MDT$(printf %04x $mdtidx)
17341 if [ -z $param ]; then
17342 lctl get_param -n mdc.*$mdt*.stats
17344 lctl get_param -n mdc.*$mdt*.stats | awk "/$param/"'{print $2}'
17349 [ $MDS1_VERSION -lt $(version_code 2.10.55) ] &&
17350 skip "Need MDS version at least 2.10.55"
17352 local dom=$DIR/$tdir/dom
17354 mkdir -p $DIR/$tdir
17356 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17358 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
17359 local facet=mds$((mdtidx + 1))
17361 cancel_lru_locks mdc
17362 do_facet $facet lctl set_param -n mdt.*.dom_lock=0
17363 createmany -o $dom 1000
17364 lctl set_param -n mdc.*.stats=clear
17365 smalliomany -w $dom 1000 200
17366 get_mdc_stats $mdtidx
17367 local enq=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17368 # Each file has 1 open, 1 IO enqueues, total 2000
17369 # but now we have also +1 getxattr for security.capability, total 3000
17370 [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
17371 unlinkmany $dom 1000
17373 cancel_lru_locks mdc
17374 do_facet $facet lctl set_param -n mdt.*.dom_lock=1
17375 createmany -o $dom 1000
17376 lctl set_param -n mdc.*.stats=clear
17377 smalliomany -w $dom 1000 200
17378 local enq_2=$(get_mdc_stats $mdtidx ldlm_ibits_enqueue)
17379 # Expect to see reduced amount of RPCs by 1000 due to single enqueue
17380 # for OPEN and IO lock.
17381 [ $((enq - enq_2)) -ge 1000 ] ||
17382 error "Too many enqueues $enq_2, expected about $((enq - 1000))"
17383 unlinkmany $dom 1000
17386 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
17388 cleanup_271def_tests() {
17394 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17395 skip "Need MDS version at least 2.10.57"
17397 local dom=$DIR/$tdir/dom
17398 local tmp=$TMP/$tfile
17399 trap "cleanup_271def_tests $tmp" EXIT
17401 mkdir -p $DIR/$tdir
17403 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17405 local mdtidx=$($GETSTRIPE -M $DIR/$tdir)
17407 cancel_lru_locks mdc
17408 dd if=/dev/urandom of=$tmp bs=1000 count=1
17409 dd if=$tmp of=$dom bs=1000 count=1
17410 cancel_lru_locks mdc
17412 cat /etc/hosts >> $tmp
17413 lctl set_param -n mdc.*.stats=clear
17415 # append data to the same file it should update local page
17416 echo "Append to the same page"
17417 cat /etc/hosts >> $dom
17418 local num=$(get_mdc_stats $mdtidx ost_read)
17419 local ra=$(get_mdc_stats $mdtidx req_active)
17420 local rw=$(get_mdc_stats $mdtidx req_waittime)
17422 [ -z $num ] || error "$num READ RPC occured"
17423 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17427 cmp $tmp $dom || error "file miscompare"
17429 cancel_lru_locks mdc
17430 lctl set_param -n mdc.*.stats=clear
17432 echo "Open and read file"
17433 cat $dom > /dev/null
17434 local num=$(get_mdc_stats $mdtidx ost_read)
17435 local ra=$(get_mdc_stats $mdtidx req_active)
17436 local rw=$(get_mdc_stats $mdtidx req_waittime)
17438 [ -z $num ] || error "$num READ RPC occured"
17439 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17443 cmp $tmp $dom || error "file miscompare"
17447 run_test 271d "DoM: read on open (1K file in reply buffer)"
17450 [ $MDS1_VERSION -lt $(version_code 2.10.57) ] &&
17451 skip "Need MDS version at least 2.10.57"
17453 local dom=$DIR/$tdir/dom
17454 local tmp=$TMP/$tfile
17455 trap "cleanup_271def_tests $tmp" EXIT
17457 mkdir -p $DIR/$tdir
17459 $LFS setstripe -E 1024K -L mdt $DIR/$tdir
17461 local mdtidx=$($GETSTRIPE -M $DIR/$tdir)
17463 cancel_lru_locks mdc
17464 dd if=/dev/urandom of=$tmp bs=200000 count=1
17465 dd if=$tmp of=$dom bs=200000 count=1
17466 cancel_lru_locks mdc
17467 cat /etc/hosts >> $tmp
17468 lctl set_param -n mdc.*.stats=clear
17470 echo "Append to the same page"
17471 cat /etc/hosts >> $dom
17472 local num=$(get_mdc_stats $mdtidx ost_read)
17473 local ra=$(get_mdc_stats $mdtidx req_active)
17474 local rw=$(get_mdc_stats $mdtidx req_waittime)
17476 [ -z $num ] || error "$num READ RPC occured"
17477 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17481 cmp $tmp $dom || error "file miscompare"
17483 cancel_lru_locks mdc
17484 lctl set_param -n mdc.*.stats=clear
17486 echo "Open and read file"
17487 cat $dom > /dev/null
17488 local num=$(get_mdc_stats $mdtidx ost_read)
17489 local ra=$(get_mdc_stats $mdtidx req_active)
17490 local rw=$(get_mdc_stats $mdtidx req_waittime)
17492 [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
17493 [ $ra == $rw ] || error "$((ra - rw)) resend occured"
17497 cmp $tmp $dom || error "file miscompare"
17501 run_test 271f "DoM: read on open (200K file and read tail)"
17504 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17505 skip "Need MDS version at least 2.11.50"
17507 local dom=$DIR/$tdir/dom
17508 mkdir -p $DIR/$tdir
17510 $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
17511 dd if=/dev/urandom of=$dom bs=512K count=1 ||
17512 error "failed to write data into $dom"
17513 local old_md5=$(md5sum $dom)
17515 $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
17516 error "failed to migrate to the same DoM component"
17518 [ $($LFS getstripe -c $dom) -eq 2 ] ||
17519 error "layout was not changed silently"
17521 local new_md5=$(md5sum $dom)
17523 [ "$old_md5" != "$new_md5" ] &&
17524 error "md5sum differ: $old_md5, $new_md5"
17527 run_test 272a "DoM migration: new layout with the same DOM component"
17530 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17531 skip "Need MDS version at least 2.11.50"
17533 local dom=$DIR/$tdir/dom
17534 mkdir -p $DIR/$tdir
17535 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17537 local mdtidx=$($LFS getstripe -m $dom)
17538 local mdtname=MDT$(printf %04x $mdtidx)
17539 local facet=mds$((mdtidx + 1))
17541 local mdtfree1=$(do_facet $facet \
17542 lctl get_param -n osd*.*$mdtname.kbytesfree)
17543 dd if=/dev/urandom of=$dom bs=2M count=1 ||
17544 error "failed to write data into $dom"
17545 local old_md5=$(md5sum $dom)
17546 cancel_lru_locks mdc
17547 local mdtfree1=$(do_facet $facet \
17548 lctl get_param -n osd*.*$mdtname.kbytesfree)
17550 $LFS migrate -c2 $dom ||
17551 error "failed to migrate to the new composite layout"
17552 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17553 error "MDT stripe was not removed"
17555 cancel_lru_locks mdc
17556 local new_md5=$(md5sum $dom)
17557 [ "$old_md5" != "$new_md5" ] &&
17558 error "$old_md5 != $new_md5"
17560 # Skip free space checks with ZFS
17561 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17562 local mdtfree2=$(do_facet $facet \
17563 lctl get_param -n osd*.*$mdtname.kbytesfree)
17564 [ $mdtfree2 -gt $mdtfree1 ] ||
17565 error "MDT space is not freed after migration"
17569 run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
17572 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17573 skip "Need MDS version at least 2.11.50"
17575 local dom=$DIR/$tdir/$tfile
17576 mkdir -p $DIR/$tdir
17577 $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
17579 local mdtidx=$($LFS getstripe -m $dom)
17580 local mdtname=MDT$(printf %04x $mdtidx)
17581 local facet=mds$((mdtidx + 1))
17583 dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
17584 error "failed to write data into $dom"
17585 local old_md5=$(md5sum $dom)
17586 cancel_lru_locks mdc
17587 local mdtfree1=$(do_facet $facet \
17588 lctl get_param -n osd*.*$mdtname.kbytesfree)
17590 $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
17591 error "failed to migrate to the new composite layout"
17592 [ $($LFS getstripe -L $dom) == 'mdt' ] &&
17593 error "MDT stripe was not removed"
17595 cancel_lru_locks mdc
17596 local new_md5=$(md5sum $dom)
17597 [ "$old_md5" != "$new_md5" ] &&
17598 error "$old_md5 != $new_md5"
17600 # Skip free space checks with ZFS
17601 if [ "$(facet_fstype $facet)" != "zfs" ]; then
17602 local mdtfree2=$(do_facet $facet \
17603 lctl get_param -n osd*.*$mdtname.kbytesfree)
17604 [ $mdtfree2 -gt $mdtfree1 ] ||
17605 error "MDS space is not freed after migration"
17609 run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
17612 [ $MDS1_VERSION -lt $(version_code 2.11.50) ] &&
17613 skip "Need MDS version at least 2.11.50"
17615 # Layout swap cannot be done if either file has DOM component,
17616 # this will never be supported, migration should be used instead
17618 local dom=$DIR/$tdir/$tfile
17619 mkdir -p $DIR/$tdir
17621 $LFS setstripe -c2 ${dom}_plain
17622 $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
17623 $LFS swap_layouts ${dom}_plain ${dom}_dom &&
17624 error "can swap layout with DoM component"
17625 $LFS swap_layouts ${dom}_dom ${dom}_plain &&
17626 error "can swap layout with DoM component"
17628 $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
17629 $LFS swap_layouts ${dom}_comp ${dom}_dom &&
17630 error "can swap layout with DoM component"
17631 $LFS swap_layouts ${dom}_dom ${dom}_comp &&
17632 error "can swap layout with DoM component"
17635 run_test 273a "DoM: layout swapping should fail with DOM"
17638 remote_ost_nodsh && skip "remote OST with nodsh"
17639 [ $OST1_VERSION -lt $(version_code 2.10.57) ] &&
17640 skip "Need OST version >= 2.10.57"
17642 local file=$DIR/$tfile
17645 oss=$(comma_list $(osts_nodes))
17647 dd if=/dev/urandom of=$file bs=1M count=2 ||
17648 error "failed to create a file"
17649 cancel_lru_locks osc
17652 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
17653 error "failed to read a file"
17655 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
17656 $LCTL set_param fail_loc=0x8000031f
17658 cancel_lru_locks osc &
17661 #define OBD_FAIL_LDLM_PROLONG_PAUSE 0x32b
17662 do_nodes $oss $LCTL set_param fail_loc=0x8000032b
17663 #IO takes another lock, but matches the PENDING one
17664 #and places it to the IO RPC
17665 dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
17666 error "failed to read a file with PENDING lock"
17668 run_test 275 "Read on a canceled duplicate lock"
17671 remote_ost_nodsh && skip "remote OST with nodsh"
17674 do_facet ost1 "(while true; do \
17675 $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
17676 done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
17679 for LOOP in $(seq 20); do
17681 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
17684 do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
17685 rm $TMP/sanity_276_pid"
17687 run_test 276 "Race between mount and obd_statfs"
17689 cleanup_test_300() {
17693 test_striped_dir() {
17698 mkdir -p $DIR/$tdir
17700 SAVE_UMASK=$(umask)
17701 trap cleanup_test_300 RETURN EXIT
17703 $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
17704 $DIR/$tdir/striped_dir ||
17705 error "set striped dir error"
17707 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
17708 [ "$mode" = "755" ] || error "expect 755 got $mode"
17710 $LFS getdirstripe $DIR/$tdir/striped_dir > /dev/null 2>&1 ||
17711 error "getdirstripe failed"
17712 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
17713 if [ "$stripe_count" != "2" ]; then
17714 error "1:stripe_count is $stripe_count, expect 2"
17716 stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
17717 if [ "$stripe_count" != "2" ]; then
17718 error "2:stripe_count is $stripe_count, expect 2"
17721 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
17722 if [ "$stripe_index" != "$mdt_index" ]; then
17723 error "stripe_index is $stripe_index, expect $mdt_index"
17726 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17727 error "nlink error after create striped dir"
17729 mkdir $DIR/$tdir/striped_dir/a
17730 mkdir $DIR/$tdir/striped_dir/b
17732 stat $DIR/$tdir/striped_dir/a ||
17733 error "create dir under striped dir failed"
17734 stat $DIR/$tdir/striped_dir/b ||
17735 error "create dir under striped dir failed"
17737 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
17738 error "nlink error after mkdir"
17740 rmdir $DIR/$tdir/striped_dir/a
17741 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
17742 error "nlink error after rmdir"
17744 rmdir $DIR/$tdir/striped_dir/b
17745 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
17746 error "nlink error after rmdir"
17748 chattr +i $DIR/$tdir/striped_dir
17749 createmany -o $DIR/$tdir/striped_dir/f 10 &&
17750 error "immutable flags not working under striped dir!"
17751 chattr -i $DIR/$tdir/striped_dir
17753 rmdir $DIR/$tdir/striped_dir ||
17754 error "rmdir striped dir error"
17762 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17763 skip "skipped for lustre < 2.7.0"
17764 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17765 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17767 test_striped_dir 0 || error "failed on striped dir on MDT0"
17768 test_striped_dir 1 || error "failed on striped dir on MDT0"
17770 run_test 300a "basic striped dir sanity test"
17773 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17774 skip "skipped for lustre < 2.7.0"
17775 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17776 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17783 test_mkdir $DIR/$tdir || error "mkdir fail"
17784 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17785 error "set striped dir error"
17786 for i in {0..9}; do
17787 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
17789 touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
17790 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
17791 [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
17793 rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
17794 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
17795 [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
17799 run_test 300b "check ctime/mtime for striped dir"
17802 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17803 skip "skipped for lustre < 2.7.0"
17804 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17805 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17809 mkdir -p $DIR/$tdir
17810 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
17811 error "set striped dir error"
17813 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
17814 error "chown striped dir failed"
17816 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
17817 error "create 5k files failed"
17819 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
17821 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
17825 run_test 300c "chown && check ls under striped directory"
17828 [ $MDS1_VERSION -lt $(version_code 2.7.0) ] &&
17829 skip "skipped for lustre < 2.7.0"
17830 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17831 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17836 mkdir -p $DIR/$tdir
17837 $SETSTRIPE -c 2 $DIR/$tdir
17839 #local striped directory
17840 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17841 error "set striped dir error"
17842 createmany -o $DIR/$tdir/striped_dir/f 10 ||
17843 error "create 10 files failed"
17845 #remote striped directory
17846 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
17847 error "set striped dir error"
17848 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
17849 error "create 10 files failed"
17851 for file in $(find $DIR/$tdir); do
17852 stripe_count=$($LFS getstripe -c $file)
17853 [ $stripe_count -eq 2 ] ||
17854 error "wrong stripe $stripe_count for $file"
17859 run_test 300d "check default stripe under striped directory"
17862 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
17863 skip "Need MDS version at least 2.7.55"
17864 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17865 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17870 mkdir -p $DIR/$tdir
17872 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17873 error "set striped dir error"
17875 touch $DIR/$tdir/striped_dir/a
17876 touch $DIR/$tdir/striped_dir/b
17877 touch $DIR/$tdir/striped_dir/c
17879 mkdir $DIR/$tdir/striped_dir/dir_a
17880 mkdir $DIR/$tdir/striped_dir/dir_b
17881 mkdir $DIR/$tdir/striped_dir/dir_c
17883 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
17884 error "set striped adir under striped dir error"
17886 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
17887 error "set striped bdir under striped dir error"
17889 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
17890 error "set striped cdir under striped dir error"
17892 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
17893 error "rename dir under striped dir fails"
17895 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b ||
17896 error "rename dir under different stripes fails"
17898 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
17899 error "rename file under striped dir should succeed"
17901 mrename $DIR/$tdir/striped_dir/dir_b $DIR/$tdir/striped_dir/dir_c ||
17902 error "rename dir under striped dir should succeed"
17906 run_test 300e "check rename under striped directory"
17909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
17910 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
17911 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
17912 skip "Need MDS version at least 2.7.55"
17918 mkdir -p $DIR/$tdir
17920 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
17921 error "set striped dir error"
17923 $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
17924 error "set striped dir error"
17926 touch $DIR/$tdir/striped_dir/a
17927 mkdir $DIR/$tdir/striped_dir/dir_a
17928 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
17929 error "create striped dir under striped dir fails"
17931 touch $DIR/$tdir/striped_dir1/b
17932 mkdir $DIR/$tdir/striped_dir1/dir_b
17933 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
17934 error "create striped dir under striped dir fails"
17936 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b ||
17937 error "rename dir under different striped dir should fail"
17939 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b ||
17940 error "rename striped dir under diff striped dir should fail"
17942 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
17943 error "rename file under diff striped dirs fails"
17947 run_test 300f "check rename cross striped directory"
17949 test_300_check_default_striped_dir()
17952 local default_count=$2
17953 local default_index=$3
17956 local dir_stripe_index
17959 echo "checking $dirname $default_count $default_index"
17960 $LFS setdirstripe -D -c $default_count -i $default_index \
17961 -t all_char $DIR/$tdir/$dirname ||
17962 error "set default stripe on striped dir error"
17963 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
17964 [ $stripe_count -eq $default_count ] ||
17965 error "expect $default_count get $stripe_count for $dirname"
17967 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
17968 [ $stripe_index -eq $default_index ] ||
17969 error "expect $default_index get $stripe_index for $dirname"
17971 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
17972 error "create dirs failed"
17974 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
17975 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
17976 for dir in $(find $DIR/$tdir/$dirname/*); do
17977 stripe_count=$($LFS getdirstripe -c $dir)
17978 [ $stripe_count -eq $default_count ] ||
17979 [ $stripe_count -eq 0 -o $default_count -eq 1 ] ||
17980 error "stripe count $default_count != $stripe_count for $dir"
17982 stripe_index=$($LFS getdirstripe -i $dir)
17983 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
17984 error "$stripe_index != $default_index for $dir"
17986 #check default stripe
17987 stripe_count=$($LFS getdirstripe -D -c $dir)
17988 [ $stripe_count -eq $default_count ] ||
17989 error "default count $default_count != $stripe_count for $dir"
17991 stripe_index=$($LFS getdirstripe -D -i $dir)
17992 [ $stripe_index -eq $default_index ] ||
17993 error "default index $default_index != $stripe_index for $dir"
17995 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
17999 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18000 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18001 skip "Need MDS version at least 2.7.55"
18008 mkdir $DIR/$tdir/normal_dir
18010 #Checking when client cache stripe index
18011 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
18012 $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
18013 error "create striped_dir failed"
18015 $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
18016 error "create dir0 fails"
18017 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
18018 [ $stripe_index -eq 0 ] ||
18019 error "dir0 expect index 0 got $stripe_index"
18021 mkdir $DIR/$tdir/striped_dir/dir1 ||
18022 error "create dir1 fails"
18023 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
18024 [ $stripe_index -eq 1 ] ||
18025 error "dir1 expect index 1 got $stripe_index"
18027 #check default stripe count/stripe index
18028 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
18029 test_300_check_default_striped_dir normal_dir 1 0
18030 test_300_check_default_striped_dir normal_dir 2 1
18031 test_300_check_default_striped_dir normal_dir 2 -1
18033 #delete default stripe information
18034 echo "delete default stripeEA"
18035 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
18036 error "set default stripe on striped dir error"
18038 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
18039 for dir in $(find $DIR/$tdir/normal_dir/*); do
18040 stripe_count=$($LFS getdirstripe -c $dir)
18041 [ $stripe_count -eq 0 ] ||
18042 error "expect 1 get $stripe_count for $dir"
18043 stripe_index=$($LFS getdirstripe -i $dir)
18044 [ $stripe_index -eq 0 ] ||
18045 error "expect 0 get $stripe_index for $dir"
18048 run_test 300g "check default striped directory for normal directory"
18051 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18052 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18053 skip "Need MDS version at least 2.7.55"
18059 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18060 error "set striped dir error"
18062 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
18063 test_300_check_default_striped_dir striped_dir 1 0
18064 test_300_check_default_striped_dir striped_dir 2 1
18065 test_300_check_default_striped_dir striped_dir 2 -1
18067 #delete default stripe information
18068 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
18069 error "set default stripe on striped dir error"
18071 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
18072 for dir in $(find $DIR/$tdir/striped_dir/*); do
18073 stripe_count=$($LFS getdirstripe -c $dir)
18074 [ $stripe_count -eq 0 ] ||
18075 error "expect 1 get $stripe_count for $dir"
18078 run_test 300h "check default striped directory for striped directory"
18081 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18082 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18083 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18084 skip "Need MDS version at least 2.7.55"
18091 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18092 error "set striped dir error"
18094 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18095 error "create files under striped dir failed"
18097 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
18098 error "set striped hashdir error"
18100 $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
18101 error "create dir0 under hash dir failed"
18102 $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
18103 error "create dir1 under hash dir failed"
18105 # unfortunately, we need to umount to clear dir layout cache for now
18106 # once we fully implement dir layout, we can drop this
18107 umount_client $MOUNT || error "umount failed"
18108 mount_client $MOUNT || error "mount failed"
18110 $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
18111 local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
18112 [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
18114 #set the stripe to be unknown hash type
18115 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
18116 $LCTL set_param fail_loc=0x1901
18117 for ((i = 0; i < 10; i++)); do
18118 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
18119 error "stat f-$i failed"
18120 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
18123 touch $DIR/$tdir/striped_dir/f0 &&
18124 error "create under striped dir with unknown hash should fail"
18126 $LCTL set_param fail_loc=0
18128 umount_client $MOUNT || error "umount failed"
18129 mount_client $MOUNT || error "mount failed"
18133 run_test 300i "client handle unknown hash type striped directory"
18136 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18137 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18138 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18139 skip "Need MDS version at least 2.7.55"
18146 #define OBD_FAIL_SPLIT_UPDATE_REC 0x1702
18147 $LCTL set_param fail_loc=0x1702
18148 $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
18149 error "set striped dir error"
18151 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
18152 error "create files under striped dir failed"
18154 $LCTL set_param fail_loc=0
18156 rm -rf $DIR/$tdir || error "unlink striped dir fails"
18160 run_test 300j "test large update record"
18163 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18164 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18165 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18166 skip "Need MDS version at least 2.7.55"
18173 #define OBD_FAIL_LARGE_STRIPE 0x1703
18174 $LCTL set_param fail_loc=0x1703
18175 $LFS setdirstripe -i 0 -c192 $DIR/$tdir/striped_dir ||
18176 error "set striped dir error"
18177 $LCTL set_param fail_loc=0
18179 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18180 error "getstripeddir fails"
18181 rm -rf $DIR/$tdir/striped_dir ||
18182 error "unlink striped dir fails"
18186 run_test 300k "test large striped directory"
18189 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18190 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18191 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18192 skip "Need MDS version at least 2.7.55"
18196 test_mkdir -p $DIR/$tdir/striped_dir
18197 chown $RUNAS_ID $DIR/$tdir/striped_dir ||
18198 error "chown $RUNAS_ID failed"
18199 $LFS setdirstripe -i 1 -D $DIR/$tdir/striped_dir ||
18200 error "set default striped dir failed"
18202 #define OBD_FAIL_MDS_STALE_DIR_LAYOUT 0x158
18203 $LCTL set_param fail_loc=0x80000158
18204 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir || error "create dir fails"
18206 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/test_dir)
18207 [ $stripe_index -eq 1 ] ||
18208 error "expect 1 get $stripe_index for $dir"
18210 run_test 300l "non-root user to create dir under striped dir with stale layout"
18213 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18214 [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
18215 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18216 skip "Need MDS version at least 2.7.55"
18218 mkdir -p $DIR/$tdir/striped_dir
18219 $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
18220 error "set default stripes dir error"
18222 mkdir $DIR/$tdir/striped_dir/a || error "mkdir a fails"
18224 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/a)
18225 [ $stripe_count -eq 0 ] ||
18226 error "expect 0 get $stripe_count for a"
18228 $LFS setdirstripe -D -c 2 $DIR/$tdir/striped_dir ||
18229 error "set default stripes dir error"
18231 mkdir $DIR/$tdir/striped_dir/b || error "mkdir b fails"
18233 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir/b)
18234 [ $stripe_count -eq 0 ] ||
18235 error "expect 0 get $stripe_count for b"
18237 $LFS setdirstripe -D -c1 -i2 $DIR/$tdir/striped_dir ||
18238 error "set default stripes dir error"
18240 mkdir $DIR/$tdir/striped_dir/c &&
18241 error "default stripe_index is invalid, mkdir c should fails"
18243 rm -rf $DIR/$tdir || error "rmdir fails"
18245 run_test 300m "setstriped directory on single MDT FS"
18248 local list=$(comma_list $(mdts_nodes))
18251 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18255 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18256 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18257 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18258 skip "Need MDS version at least 2.7.55"
18259 remote_mds_nodsh && skip "remote MDS with nodsh"
18262 local list=$(comma_list $(mdts_nodes))
18264 trap cleanup_300n RETURN EXIT
18265 mkdir -p $DIR/$tdir
18266 chmod 777 $DIR/$tdir
18267 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT \
18268 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18269 error "create striped dir succeeds with gid=0"
18271 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18272 $RUNAS $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
18273 error "create striped dir fails with gid=-1"
18275 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18276 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D \
18277 $DIR/$tdir/striped_dir > /dev/null 2>&1 &&
18278 error "set default striped dir succeeds with gid=0"
18281 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=-1
18282 $RUNAS $LFS setdirstripe -i 1 -c$MDSCOUNT -D $DIR/$tdir/striped_dir ||
18283 error "set default striped dir fails with gid=-1"
18286 do_nodes $list $LCTL set_param -n mdt.*.enable_remote_dir_gid=0
18287 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir ||
18288 error "create test_dir fails"
18289 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir1 ||
18290 error "create test_dir1 fails"
18291 $RUNAS mkdir $DIR/$tdir/striped_dir/test_dir2 ||
18292 error "create test_dir2 fails"
18295 run_test 300n "non-root user to create dir under striped dir with default EA"
18298 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18299 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18300 [ $MDS1_VERSION -lt $(version_code 2.7.55) ] &&
18301 skip "Need MDS version at least 2.7.55"
18306 mkdir -p $DIR/$tdir
18308 numfree1=$(lctl get_param -n mdc.*MDT0000*.filesfree)
18309 numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
18310 if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
18311 skip "not enough free inodes $numfree1 $numfree2"
18314 numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
18315 numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
18316 if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
18317 skip "not enough free space $numfree1 $numfree2"
18320 $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
18321 error "setdirstripe fails"
18323 createmany -d $DIR/$tdir/striped_dir/d 131000 ||
18324 error "create dirs fails"
18326 $LCTL set_param ldlm.namespaces.*mdc-*.lru_size=0
18327 ls $DIR/$tdir/striped_dir > /dev/null ||
18328 error "ls striped dir fails"
18329 unlinkmany -d $DIR/$tdir/striped_dir/d 131000 ||
18330 error "unlink big striped dir fails"
18332 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
18335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18336 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18337 remote_mds_nodsh && skip "remote MDS with nodsh"
18339 mkdir -p $DIR/$tdir
18341 #define OBD_FAIL_OUT_ENOSPC 0x1704
18342 do_facet mds2 lctl set_param fail_loc=0x80001704
18343 $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
18344 && error "create striped directory should fail"
18346 [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
18348 $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir
18351 run_test 300p "create striped directory without space"
18354 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18355 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
18357 local fd=$(free_fd)
18358 local cmd="exec $fd<$tdir"
18360 $LFS mkdir -c $MDSCOUNT $tdir || error "create $tdir fails"
18363 trap "eval $cmd" EXIT
18364 cd $tdir || error "cd $tdir fails"
18365 rmdir ../$tdir || error "rmdir $tdir fails"
18366 mkdir local_dir && error "create dir succeeds"
18367 $LFS setdirstripe -i1 remote_dir && error "create remote dir succeeds"
18371 run_test 300q "create remote directory under orphan directory"
18374 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
18375 skip "Need MDS version at least 2.7.55" && return
18376 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
18380 $LFS setdirstripe -i 0 -c -1 $DIR/$tdir/striped_dir ||
18381 error "set striped dir error"
18383 $LFS getdirstripe $DIR/$tdir/striped_dir ||
18384 error "getstripeddir fails"
18387 stripe_count=$($LFS getdirstripe $DIR/$tdir/striped_dir |
18388 awk '/lmv_stripe_count:/ { print $2 }')
18390 [ $MDSCOUNT -ne $stripe_count ] &&
18391 error "wrong stripe count $stripe_count expected $MDSCOUNT"
18393 rm -rf $DIR/$tdir/striped_dir ||
18394 error "unlink striped dir fails"
18396 run_test 300r "test -1 striped directory"
18398 prepare_remote_file() {
18399 mkdir $DIR/$tdir/src_dir ||
18400 error "create remote source failed"
18402 cp /etc/hosts $DIR/$tdir/src_dir/a ||
18403 error "cp to remote source failed"
18404 touch $DIR/$tdir/src_dir/a
18406 $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
18407 error "create remote target dir failed"
18409 touch $DIR/$tdir/tgt_dir/b
18411 mrename $DIR/$tdir/src_dir/a $DIR/$tdir/tgt_dir/b ||
18412 error "rename dir cross MDT failed!"
18414 $CHECKSTAT -t file $DIR/$tdir/src_dir/a &&
18415 error "src_child still exists after rename"
18417 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/b ||
18418 error "missing file(a) after rename"
18420 diff /etc/hosts $DIR/$tdir/tgt_dir/b ||
18421 error "diff after rename"
18425 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18426 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18428 local remote_file=$DIR/$tdir/tgt_dir/b
18430 mkdir -p $DIR/$tdir
18432 prepare_remote_file || error "prepare remote file failed"
18435 $OPENUNLINK $remote_file $remote_file ||
18436 error "openunlink $remote_file failed"
18437 $CHECKSTAT -a $remote_file || error "$remote_file exists"
18439 run_test 310a "open unlink remote file"
18442 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
18443 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18445 local remote_file=$DIR/$tdir/tgt_dir/b
18447 mkdir -p $DIR/$tdir
18449 prepare_remote_file || error "prepare remote file failed"
18451 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18452 $MULTIOP $DIR/$tfile Ouc || error "mulitop failed"
18453 $CHECKSTAT -t file $remote_file || error "check file failed"
18455 run_test 310b "unlink remote file with multiple links while open"
18458 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18459 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
18461 local remote_file=$DIR/$tdir/tgt_dir/b
18463 mkdir -p $DIR/$tdir
18465 prepare_remote_file || error "prepare remote file failed"
18467 ln $remote_file $DIR/$tfile || error "link failed for remote file"
18468 multiop_bg_pause $remote_file O_uc ||
18469 error "mulitop failed for remote file"
18471 $MULTIOP $DIR/$tfile Ouc
18472 kill -USR1 $MULTIPID
18475 run_test 310c "open-unlink remote file with multiple links"
18479 [ $PARALLEL == "yes" ] && skip "skip parallel run"
18480 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18481 [ $MDS1_VERSION -lt $(version_code 2.8.54) ] &&
18482 skip "lustre < 2.8.54 does not contain LU-4825 fix"
18483 remote_mds_nodsh && skip "remote MDS with nodsh"
18485 local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18486 local mdts=$(comma_list $(mdts_nodes))
18488 mkdir -p $DIR/$tdir
18489 $SETSTRIPE -i 0 -c 1 $DIR/$tdir
18490 createmany -o $DIR/$tdir/$tfile. 1000
18492 # statfs data is not real time, let's just calculate it
18493 old_iused=$((old_iused + 1000))
18495 local count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18496 osp.*OST0000*MDT0000.create_count")
18497 local max_count=$(do_facet $SINGLEMDS "$LCTL get_param -n \
18498 osp.*OST0000*MDT0000.max_create_count")
18499 do_nodes $mdts "$LCTL set_param -n osp.*OST0000*.max_create_count=0"
18501 $SETSTRIPE -i 0 $DIR/$tdir/$tfile || error "setstripe failed"
18502 local index=$($GETSTRIPE -i $DIR/$tdir/$tfile)
18503 [ $index -ne 0 ] || error "$tfile stripe index is 0"
18505 unlinkmany $DIR/$tdir/$tfile. 1000
18507 do_nodes $mdts "$LCTL set_param -n \
18508 osp.*OST0000*.max_create_count=$max_count"
18509 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
18510 do_nodes $mdts "$LCTL set_param -n \
18511 osp.*OST0000*.create_count=$count"
18512 do_nodes $mdts "$LCTL get_param osp.*OST0000*.create_count" |
18513 grep "=0" && error "create_count is zero"
18516 for i in $(seq 120); do
18517 new_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
18518 # system may be too busy to destroy all objs in time, use
18519 # a somewhat small value to not fail autotest
18520 [ $((old_iused - new_iused)) -gt 400 ] && break
18524 echo "waited $i sec, old Iused $old_iused, new Iused $new_iused"
18525 [ $((old_iused - new_iused)) -gt 400 ] ||
18526 error "objs not destroyed after unlink"
18528 run_test 311 "disable OSP precreate, and unlink should destroy objs"
18535 local vdevdir=$(dirname $(facet_vdevice $ost))
18536 local cmd="$ZDB -e -p $vdevdir -ddddd $(facet_device $ost)"
18537 local zfs_zapid=$(do_facet $ost $cmd |
18538 grep -w "/O/0/d$((objid%32))" -C 5 |
18539 awk '/Object/{getline; print $1}')
18540 local zfs_objid=$(do_facet $ost $cmd $zfs_zapid |
18541 awk "/$objid = /"'{printf $3}')
18546 zfs_object_blksz() {
18550 local vdevdir=$(dirname $(facet_vdevice $ost))
18551 local cmd="$ZDB -e -p $vdevdir -dddd $(facet_device $ost)"
18552 local blksz=$(do_facet $ost $cmd $objid |
18553 awk '/dblk/{getline; printf $4}')
18555 case "${blksz: -1}" in
18556 k|K) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024)) ;;
18557 m|M) blksz=$((${blksz:0:$((${#blksz} - 1))}*1024*1024)) ;;
18564 test_312() { # LU-4856
18565 remote_ost_nodsh && skip "remote OST with nodsh"
18566 [ "$ost1_FSTYPE" = "zfs" ] ||
18567 skip_env "the test only applies to zfs"
18569 local max_blksz=$(do_facet ost1 \
18570 $ZFS get -p recordsize $(facet_device ost1) |
18571 awk '!/VALUE/{print $3}')
18573 # to make life a little bit easier
18574 $LFS mkdir -c 1 -i 0 $DIR/$tdir
18575 $LFS setstripe -c 1 -i 0 $DIR/$tdir
18577 local tf=$DIR/$tdir/$tfile
18579 local oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18581 # Get ZFS object id
18582 local zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18583 # block size change by sequential overwrite
18586 for ((bs=$PAGE_SIZE; bs <= max_blksz; bs *= 4)) ; do
18587 dd if=/dev/zero of=$tf bs=$bs count=1 oflag=sync conv=notrunc
18589 local blksz=$(zfs_object_blksz ost1 $zfs_objid)
18590 [ $blksz -eq $bs ] || error "blksz error: $blksz, expected: $bs"
18594 # block size change by sequential append write
18595 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=1 oflag=sync conv=notrunc
18596 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18597 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18600 for ((count = 1; count < $((max_blksz / PAGE_SIZE)); count *= 2)); do
18601 dd if=/dev/zero of=$tf bs=$PAGE_SIZE count=$count seek=$count \
18602 oflag=sync conv=notrunc
18604 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18605 [ $blksz -eq $((2 * count * PAGE_SIZE)) ] ||
18606 error "blksz error, actual $blksz, " \
18607 "expected: 2 * $count * $PAGE_SIZE"
18613 oid=$($LFS getstripe $tf | awk '/obdidx/{getline; print $2}')
18614 zfs_objid=$(zfs_oid_to_objid ost1 $oid)
18616 dd if=/dev/zero of=$tf bs=1K count=1 oflag=sync conv=notrunc
18617 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18618 [ $blksz -eq $PAGE_SIZE ] ||
18619 error "blksz error: $blksz, expected: $PAGE_SIZE"
18621 dd if=/dev/zero of=$tf bs=64K count=1 oflag=sync conv=notrunc seek=128
18622 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18623 [ $blksz -eq 65536 ] || error "blksz error: $blksz, expected: 64k"
18625 dd if=/dev/zero of=$tf bs=1M count=1 oflag=sync conv=notrunc
18626 blksz=$(zfs_object_blksz ost1 $zfs_objid)
18627 [ $blksz -eq 65536 ] || error "rewrite error: $blksz, expected: 64k"
18629 run_test 312 "make sure ZFS adjusts its block size by write pattern"
18632 remote_ost_nodsh && skip "remote OST with nodsh"
18634 local file=$DIR/$tfile
18637 $SETSTRIPE -c 1 -i 0 $file || error "setstripe failed"
18639 # define OBD_FAIL_TGT_RCVD_EIO 0x720
18640 do_facet ost1 "$LCTL set_param fail_loc=0x720"
18641 dd if=/dev/zero of=$file bs=$PAGE_SIZE oflag=direct count=1 &&
18642 error "write should failed"
18643 do_facet ost1 "$LCTL set_param fail_loc=0"
18646 run_test 313 "io should fail after last_rcvd update fail"
18649 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
18651 $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
18652 do_facet ost1 "$LCTL set_param fail_loc=0x720"
18654 wait_delete_completed
18655 do_facet ost1 "$LCTL set_param fail_loc=0"
18657 run_test 314 "OSP shouldn't fail after last_rcvd update failure"
18659 test_315() { # LU-618
18660 local file=$DIR/$tfile
18663 $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4063232c ||
18664 error "multiop file write failed"
18665 $MULTIOP $file oO_RDONLY:r4063232_c &
18670 local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
18673 [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
18676 run_test 315 "read should be accounted"
18679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
18680 large_xattr_enabled || skip_env "ea_inode feature disabled"
18682 rm -rf $DIR/$tdir/d
18683 mkdir -p $DIR/$tdir/d
18684 chown nobody $DIR/$tdir/d
18685 touch $DIR/$tdir/d/file
18687 $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
18689 run_test 316 "lfs mv"
18692 [ $MDS1_VERSION -lt $(version_code 2.11.53) ] &&
18693 skip "Need MDS version at least 2.11.53"
18695 local grant_blk_size
18697 if [ "$(facet_fstype $facet)" == "zfs" ]; then
18698 skip "LU-10370: no implementation for ZFS" && return
18701 stack_trap "rm -f $DIR/$tfile" EXIT
18702 grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
18703 awk '/grant_block_size:/ { print $2; exit; }')
18705 # Create File of size 5M. Truncate it to below size's and verify
18708 dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
18709 error "Create file : $DIR/$tfile"
18711 for trunc_sz in 2097152 4097 4000 509 0; do
18712 $TRUNCATE $DIR/$tfile $trunc_sz ||
18713 error "truncate $tfile to $trunc_sz failed"
18714 local sz=$(stat --format=%s $DIR/$tfile)
18715 local blk=$(stat --format=%b $DIR/$tfile)
18716 local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
18717 grant_blk_size) * 8))
18719 if [[ $blk -ne $trunc_blk ]]; then
18720 $(which stat) $DIR/$tfile
18721 error "Expected Block $trunc_blk got $blk for $tfile"
18724 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18725 error "Expected Size $trunc_sz got $sz for $tfile"
18730 # Create file with a hole and write actual two blocks. Block count
18733 dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
18734 conv=fsync || error "Create file : $DIR/$tfile"
18736 # Calculate the final truncate size.
18737 trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
18740 # truncate to size $trunc_sz bytes. Strip the last block
18741 # The block count must drop to 8
18743 $TRUNCATE $DIR/$tfile $trunc_sz ||
18744 error "truncate $tfile to $trunc_sz failed"
18746 local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
18747 sz=$(stat --format=%s $DIR/$tfile)
18748 blk=$(stat --format=%b $DIR/$tfile)
18750 if [[ $blk -ne $trunc_bsz ]]; then
18751 $(which stat) $DIR/$tfile
18752 error "Expected Block $trunc_bsz got $blk for $tfile"
18755 $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
18756 error "Expected Size $trunc_sz got $sz for $tfile"
18758 run_test 317 "Verify blocks get correctly update after truncate"
18761 local read_write=$1
18762 if [ "$read_write" = "write" ]; then
18763 local dd_cmd="dd if=/dev/zero of=$DIR/$tfile"
18764 elif [ "$read_write" = "read" ]; then
18765 local dd_cmd="dd of=/dev/null if=$DIR/$tfile"
18767 error "argument error"
18770 # turn off debug for performance testing
18771 local saved_debug=$($LCTL get_param -n debug)
18772 $LCTL set_param debug=0
18774 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
18776 # get ost1 size - lustre-OST0000
18777 local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }')
18778 local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes
18779 [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum
18781 if [ "$read_write" = "read" ]; then
18782 truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile
18785 local start_time=$(date +%s.%N)
18786 $dd_cmd bs=1M count=$blocks oflag=sync ||
18787 error "real dd $read_write error"
18788 local duration=$(bc <<< "$(date +%s.%N) - $start_time")
18790 if [ "$read_write" = "write" ]; then
18794 # define OBD_FAIL_OST_FAKE_RW 0x238
18795 do_facet ost1 $LCTL set_param fail_loc=0x238
18797 local start_time=$(date +%s.%N)
18798 $dd_cmd bs=1M count=$blocks oflag=sync ||
18799 error "fake dd $read_write error"
18800 local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time")
18802 if [ "$read_write" = "write" ]; then
18804 cancel_lru_locks osc
18805 $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile ||
18806 error "$tfile size not $blocks MB"
18808 do_facet ost1 $LCTL set_param fail_loc=0
18810 echo "fake $read_write $duration_fake vs. normal $read_write" \
18811 "$duration in seconds"
18812 [ $(bc <<< "$duration_fake < $duration") -eq 1 ] ||
18813 error_not_in_vm "fake write is slower"
18815 $LCTL set_param -n debug="$saved_debug"
18818 test_399a() { # LU-7655 for OST fake write
18819 remote_ost_nodsh && skip "remote OST with nodsh"
18823 run_test 399a "fake write should not be slower than normal write"
18825 test_399b() { # LU-8726 for OST fake read
18826 remote_ost_nodsh && skip "remote OST with nodsh"
18827 if [ "$ost1_FSTYPE" != "ldiskfs" ]; then
18828 skip_env "ldiskfs only test"
18833 run_test 399b "fake read should not be slower than normal read"
18835 test_400a() { # LU-1606, was conf-sanity test_74
18836 if ! which $CC > /dev/null 2>&1; then
18837 skip_env "$CC is not installed"
18840 local extra_flags=''
18841 local out=$TMP/$tfile
18842 local prefix=/usr/include/lustre
18845 if ! [[ -d $prefix ]]; then
18846 # Assume we're running in tree and fixup the include path.
18847 extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include"
18848 extra_flags+=" -L$LUSTRE/utils/.lib"
18851 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
18852 $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi ||
18853 error "client api broken"
18857 run_test 400a "Lustre client api program can compile and link"
18859 test_400b() { # LU-1606, LU-5011
18861 local out=$TMP/$tfile
18862 local prefix=/usr/include/linux/lustre
18864 # We use a hard coded prefix so that this test will not fail
18865 # when run in tree. There are headers in lustre/include/lustre/
18866 # that are not packaged (like lustre_idl.h) and have more
18867 # complicated include dependencies (like config.h and lnet/types.h).
18868 # Since this test about correct packaging we just skip them when
18869 # they don't exist (see below) rather than try to fixup cppflags.
18871 if ! which $CC > /dev/null 2>&1; then
18872 skip_env "$CC is not installed"
18875 for header in $prefix/*.h; do
18876 if ! [[ -f "$header" ]]; then
18880 if [[ "$(basename $header)" == lustre_ioctl.h ]]; then
18881 continue # lustre_ioctl.h is internal header
18884 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
18885 error "cannot compile '$header'"
18889 run_test 400b "packaged headers can be compiled"
18891 test_401a() { #LU-7437
18892 local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
18893 [ -n "$printf_arg" ] && skip_env "find does not support -printf"
18895 #count the number of parameters by "list_param -R"
18896 local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
18897 #count the number of parameters by listing proc files
18898 local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
18899 echo "proc_dirs='$proc_dirs'"
18900 [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
18901 local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
18904 [ $params -eq $procs ] ||
18905 error "found $params parameters vs. $procs proc files"
18907 # test the list_param -D option only returns directories
18908 params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
18909 #count the number of parameters by listing proc directories
18910 procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
18913 [ $params -eq $procs ] ||
18914 error "found $params parameters vs. $procs proc files"
18916 run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
18919 local save=$($LCTL get_param -n jobid_var)
18922 $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
18923 error "no error returned when setting bad parameters"
18925 local jobid_new=$($LCTL get_param -n foe jobid_var baz)
18926 [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
18928 $LCTL set_param -n fog=bam jobid_var=$save bat=fog
18929 local jobid_old=$($LCTL get_param -n foe jobid_var bag)
18930 [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
18932 run_test 401b "Verify 'lctl {get,set}_param' continue after error"
18935 local jobid_var_old=$($LCTL get_param -n jobid_var)
18936 local jobid_var_new
18938 $LCTL set_param jobid_var= &&
18939 error "no error returned for 'set_param a='"
18941 jobid_var_new=$($LCTL get_param -n jobid_var)
18942 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
18943 error "jobid_var was changed by setting without value"
18945 $LCTL set_param jobid_var &&
18946 error "no error returned for 'set_param a'"
18948 jobid_var_new=$($LCTL get_param -n jobid_var)
18949 [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
18950 error "jobid_var was changed by setting without value"
18952 run_test 401c "Verify 'lctl set_param' without value fails in either format."
18955 local jobid_var_old=$($LCTL get_param -n jobid_var)
18956 local jobid_var_new
18957 local new_value="foo=bar"
18959 $LCTL set_param jobid_var=$new_value ||
18960 error "'set_param a=b' did not accept a value containing '='"
18962 jobid_var_new=$($LCTL get_param -n jobid_var)
18963 [[ "$jobid_var_new" == "$new_value" ]] ||
18964 error "'set_param a=b' failed on a value containing '='"
18966 # Reset the jobid_var to test the other format
18967 $LCTL set_param jobid_var=$jobid_var_old
18968 jobid_var_new=$($LCTL get_param -n jobid_var)
18969 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
18970 error "failed to reset jobid_var"
18972 $LCTL set_param jobid_var $new_value ||
18973 error "'set_param a b' did not accept a value containing '='"
18975 jobid_var_new=$($LCTL get_param -n jobid_var)
18976 [[ "$jobid_var_new" == "$new_value" ]] ||
18977 error "'set_param a b' failed on a value containing '='"
18979 $LCTL set_param jobid_var $jobid_var_old
18980 jobid_var_new=$($LCTL get_param -n jobid_var)
18981 [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
18982 error "failed to reset jobid_var"
18984 run_test 401d "Verify 'lctl set_param' accepts values containing '='"
18987 [[ $MDS1_VERSION -ge $(version_code 2.7.66) ]] ||
18988 [[ $MDS1_VERSION -ge $(version_code 2.7.18.4) &&
18989 $MDS1_VERSION -lt $(version_code 2.7.50) ]] ||
18990 [[ $MDS1_VERSION -ge $(version_code 2.7.2) &&
18991 $MDS1_VERSION -lt $(version_code 2.7.11) ]] ||
18992 skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
18993 remote_mds_nodsh && skip "remote MDS with nodsh"
18995 $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
18996 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
18997 do_facet mds1 "lctl set_param fail_loc=0x8000015c"
18998 touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
18999 echo "Touch failed - OK"
19001 run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
19004 local file1=$DIR/$tfile.1
19005 local file2=$DIR/$tfile.2
19006 local tfile=$TMP/$tfile
19008 rm -f $file1 $file2 $tfile
19013 # 30 sec OBD_TIMEOUT in ll_getattr()
19014 # right before populating st_nlink
19015 $LCTL set_param fail_loc=0x80001409
19016 stat -c %h $file1 > $tfile &
19018 # create an alias, drop all locks and reclaim the dentry
19020 cancel_lru_locks mdc
19021 cancel_lru_locks osc
19022 sysctl -w vm.drop_caches=2
19026 [ $(cat $tfile) -gt 0 ] || error "wrong nlink count: $(cat $tfile)"
19028 rm -f $tfile $file1 $file2
19030 run_test 403 "i_nlink should not drop to zero due to aliasing"
19032 test_404() { # LU-6601
19033 [[ $MDS1_VERSION -ge $(version_code 2.8.53) ]] ||
19034 skip "Need server version newer than 2.8.52"
19035 remote_mds_nodsh && skip "remote MDS with nodsh"
19037 local mosps=$(do_facet $SINGLEMDS $LCTL dl |
19038 awk '/osp .*-osc-MDT/ { print $4}')
19041 for osp in $mosps; do
19042 echo "Deactivate: " $osp
19043 do_facet $SINGLEMDS $LCTL --device %$osp deactivate
19044 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19045 awk -vp=$osp '$4 == p { print $2 }')
19046 [ $stat = IN ] || {
19047 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19048 error "deactivate error"
19050 echo "Activate: " $osp
19051 do_facet $SINGLEMDS $LCTL --device %$osp activate
19052 local stat=$(do_facet $SINGLEMDS $LCTL dl |
19053 awk -vp=$osp '$4 == p { print $2 }')
19054 [ $stat = UP ] || {
19055 do_facet $SINGLEMDS $LCTL dl | grep -w $osp
19056 error "activate error"
19060 run_test 404 "validate manual {de}activated works properly for OSPs"
19063 [ $MDS1_VERSION -lt $(version_code 2.6.92) -o \
19064 [ $CLIENT_VERSION -lt $(version_code 2.6.99) ] &&
19065 skip "Layout swap lock is not supported"
19066 check_swap_layouts_support
19068 test_mkdir $DIR/$tdir
19069 swap_lock_test -d $DIR/$tdir ||
19070 error "One layout swap locked test failed"
19072 run_test 405 "Various layout swap lock tests"
19075 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19076 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
19077 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
19078 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19079 [ $MDS1_VERSION -lt $(version_code 2.8.50) ] &&
19080 skip "Need MDS version at least 2.8.50"
19082 local def_stripe_size=$($LFS getstripe -S $MOUNT)
19083 local test_pool=$TESTNAME
19085 if ! combined_mgs_mds ; then
19088 pool_add $test_pool || error "pool_add failed"
19089 pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
19090 error "pool_add_targets failed"
19092 save_layout_restore_at_exit $MOUNT
19094 # parent set default stripe count only, child will stripe from both
19095 # parent and fs default
19096 $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
19097 error "setstripe $MOUNT failed"
19098 $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
19099 $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
19100 for i in $(seq 10); do
19101 local f=$DIR/$tdir/$tfile.$i
19102 touch $f || error "touch failed"
19103 local count=$($LFS getstripe -c $f)
19104 [ $count -eq $OSTCOUNT ] ||
19105 error "$f stripe count $count != $OSTCOUNT"
19106 local offset=$($LFS getstripe -i $f)
19107 [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
19108 local size=$($LFS getstripe -S $f)
19109 [ $size -eq $((def_stripe_size * 2)) ] ||
19110 error "$f stripe size $size != $((def_stripe_size * 2))"
19111 local pool=$($LFS getstripe -p $f)
19112 [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
19115 # change fs default striping, delete parent default striping, now child
19116 # will stripe from new fs default striping only
19117 $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
19118 error "change $MOUNT default stripe failed"
19119 $LFS setstripe -c 0 $DIR/$tdir ||
19120 error "delete $tdir default stripe failed"
19121 for i in $(seq 11 20); do
19122 local f=$DIR/$tdir/$tfile.$i
19123 touch $f || error "touch $f failed"
19124 local count=$($LFS getstripe -c $f)
19125 [ $count -eq 1 ] || error "$f stripe count $count != 1"
19126 local offset=$($LFS getstripe -i $f)
19127 [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
19128 local size=$($LFS getstripe -S $f)
19129 [ $size -eq $def_stripe_size ] ||
19130 error "$f stripe size $size != $def_stripe_size"
19131 local pool=$($LFS getstripe -p $f)
19132 [ $pool == $test_pool ] || error "$f pool $pool isn't set"
19135 unlinkmany $DIR/$tdir/$tfile. 1 20
19137 local f=$DIR/$tdir/$tfile
19138 pool_remove_all_targets $test_pool $f
19139 pool_remove $test_pool $f
19141 if ! combined_mgs_mds ; then
19145 run_test 406 "DNE support fs default striping"
19148 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19149 [[ $MDS1_VERSION -lt $(version_code 2.8.55) ]] &&
19150 skip "Need MDS version at least 2.8.55"
19151 remote_mds_nodsh && skip "remote MDS with nodsh"
19153 $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
19154 error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
19155 $LFS mkdir -i 1 -c 1 $DIR/$tdir.1 ||
19156 error "$LFS mkdir -i 1 -c 1 $tdir.1 failed"
19157 touch $DIR/$tdir.0/$tfile.0 || error "touch $tdir.0/$tfile.0 failed"
19159 #define OBD_FAIL_DT_TXN_STOP 0x2019
19160 for idx in $(seq $MDSCOUNT); do
19161 do_facet mds$idx "lctl set_param fail_loc=0x2019"
19163 $LFS mkdir -c 2 $DIR/$tdir && error "$LFS mkdir -c 2 $tdir should fail"
19164 mv $DIR/$tdir.0/$tfile.0 $DIR/$tdir.1/$tfile.1 &&
19165 error "mv $tdir.0/$tfile.0 $tdir.1/$tfile.1 should fail"
19168 run_test 407 "transaction fail should cause operation fail"
19171 dd if=/dev/zero of=$DIR/$tfile bs=$PAGE_SIZE count=1 oflag=direct
19173 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
19174 lctl set_param fail_loc=0x8000040a
19175 # let ll_prepare_partial_page() fail
19176 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 conv=notrunc || true
19180 # create at least 100 unused inodes so that
19181 # shrink_icache_memory(0) should not return 0
19182 touch $DIR/$tfile-{0..100}
19183 rm -f $DIR/$tfile-{0..100}
19186 echo 2 > /proc/sys/vm/drop_caches
19188 run_test 408 "drop_caches should not hang due to page leaks"
19192 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19193 check_mount_and_prep
19195 mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
19196 $LFS mkdir -i 1 -c 2 $DIR/$tdir/foo || error "(1) Fail to mkdir"
19197 touch $DIR/$tdir/guard || error "(2) Fail to create"
19199 local PREFIX=$(str_repeat 'A' 128)
19200 echo "Create 1K hard links start at $(date)"
19201 createmany -l $DIR/$tdir/guard $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19202 error "(3) Fail to hard link"
19204 echo "Links count should be right although linkEA overflow"
19205 stat $DIR/$tdir/guard || error "(4) Fail to stat"
19206 local linkcount=$(stat --format=%h $DIR/$tdir/guard)
19207 [ $linkcount -eq 1001 ] ||
19208 error "(5) Unexpected hard links count: $linkcount"
19210 echo "List all links start at $(date)"
19211 ls -l $DIR/$tdir/foo > /dev/null ||
19212 error "(6) Fail to list $DIR/$tdir/foo"
19214 echo "Unlink hard links start at $(date)"
19215 unlinkmany $DIR/$tdir/foo/${PREFIX}_ 1000 ||
19216 error "(7) Fail to unlink"
19218 run_test 409 "Large amount of cross-MDTs hard links on the same file"
19222 [[ $CLIENT_VERSION -lt $(version_code 2.9.59) ]] &&
19223 skip "Need client version at least 2.9.59"
19225 # Create a file, and stat it from the kernel
19226 local testfile=$DIR/$tfile
19229 local run_id=$RANDOM
19230 local my_ino=$(stat --format "%i" $testfile)
19232 # Try to insert the module. This will always fail as the
19233 # module is designed to not be inserted.
19234 insmod $LUSTRE/tests/kernel/kinode.ko run_id=$run_id fname=$testfile \
19237 # Anything but success is a test failure
19239 "lustre_kinode_$run_id: inode numbers are identical: $my_ino" ||
19240 error "no inode match"
19242 run_test 410 "Test inode number returned from kernel thread"
19244 cleanup_test411_cgroup() {
19250 local cg_basedir=/sys/fs/cgroup/memory
19252 test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
19253 skip "no setup for cgroup"
19255 dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
19256 error "test file creation failed"
19257 cancel_lru_locks osc
19259 # Create a very small memory cgroup to force a slab allocation error
19260 local cgdir=$cg_basedir/osc_slab_alloc
19261 mkdir $cgdir || error "cgroup mkdir '$cgdir' failed"
19262 trap "cleanup_test411_cgroup $cgdir" EXIT
19263 echo 2M > $cgdir/memory.kmem.limit_in_bytes
19264 echo 1M > $cgdir/memory.limit_in_bytes
19266 # Should not LBUG, just be killed by oom-killer
19267 # dd will return 0 even allocation failure in some environment.
19268 # So don't check return value
19269 sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
19270 cleanup_test411_cgroup $cgdir
19274 run_test 411 "Slab allocation error with cgroup does not LBUG"
19277 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
19278 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19279 skip "Need server version at least 2.10.55"
19282 $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
19283 error "mkdir failed"
19284 $LFS getdirstripe $DIR/$tdir
19285 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
19286 [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
19287 error "expect $((MDSCOUT - 1)) get $stripe_index"
19288 local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
19289 [ $stripe_count -eq 2 ] ||
19290 error "expect 2 get $stripe_count"
19292 run_test 412 "mkdir on specific MDTs"
19295 [ $MDSCOUNT -lt 2 ] &&
19296 skip "We need at least 2 MDTs for this test"
19298 if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
19299 skip "Need server version at least 2.10.55"
19302 mkdir $DIR/$tdir || error "mkdir failed"
19304 # find MDT that is the most full
19305 local max=$($LFS df | grep MDT |
19314 END { split(b, c, ":")
19319 for i in $(seq $((MDSCOUNT - 1))); do
19320 $LFS mkdir -c $i $DIR/$tdir/d$i ||
19321 error "mkdir d$i failed"
19322 $LFS getdirstripe $DIR/$tdir/d$i
19323 local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
19324 [ $stripe_index -ne $max ] ||
19325 error "don't expect $max"
19328 run_test 413 "mkdir on less full MDTs"
19331 #define OBD_FAIL_PTLRPC_BULK_ATTACH 0x521
19332 $LCTL set_param fail_loc=0x80000521
19333 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
19336 run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
19339 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19340 [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
19341 skip "Need server version at least 2.11.52"
19351 # this test may be slow on ZFS
19352 [ "$mds1_FSTYPE" == "zfs" ] && total=100
19354 # though this test is designed for striped directory, let's test normal
19355 # directory too since lock is always saved as CoS lock.
19356 test_mkdir $DIR/$tdir || error "mkdir $tdir"
19357 createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
19366 start_time=$(date +%s)
19367 for i in $(seq $total); do
19368 mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
19371 end_time=$(date +%s)
19372 duration=$((end_time - start_time))
19374 kill -9 $setattr_pid
19376 echo "rename $total files took $duration sec"
19377 [ $duration -lt 100 ] || error "rename took $duration sec"
19379 run_test 415 "lock revoke is not missing"
19382 [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
19383 skip "Need server version at least 2.11.55"
19385 # define OBD_FAIL_OSD_TXN_START 0x19a
19386 do_facet mds1 lctl set_param fail_loc=0x19a
19388 lfs mkdir -c $MDSCOUNT $DIR/$tdir
19392 run_test 416 "transaction start failure won't cause system hung"
19396 do_nodes $(comma_list $(mdts_nodes)) \
19397 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=1"
19398 do_nodes $(comma_list $(mdts_nodes)) \
19399 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=1"
19400 do_nodes $(comma_list $(mdts_nodes)) \
19401 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=1"
19405 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
19406 [[ $MDS1_VERSION -lt $(version_code 2.11.56) ]] &&
19407 skip "Need MDS version at least 2.11.56"
19409 trap cleanup_417 RETURN EXIT
19411 $LFS mkdir -i 1 $DIR/$tdir.1 || error "create remote dir $tdir.1 failed"
19412 do_nodes $(comma_list $(mdts_nodes)) \
19413 "$LCTL set_param -n mdt.*MDT*.enable_dir_migration=0"
19414 $LFS migrate -m 0 $DIR/$tdir.1 &&
19415 error "migrate dir $tdir.1 should fail"
19417 do_nodes $(comma_list $(mdts_nodes)) \
19418 "$LCTL set_param -n mdt.*MDT*.enable_remote_dir=0"
19419 $LFS mkdir -i 1 $DIR/$tdir.2 &&
19420 error "create remote dir $tdir.2 should fail"
19422 do_nodes $(comma_list $(mdts_nodes)) \
19423 "$LCTL set_param -n mdt.*MDT*.enable_striped_dir=0"
19424 $LFS mkdir -c 2 $DIR/$tdir.3 &&
19425 error "create striped dir $tdir.3 should fail"
19428 run_test 417 "disable remote dir, striped dir and dir migration"
19430 # Checks that the outputs of df [-i] and lfs df [-i] match
19432 # usage: check_lfs_df <blocks | inodes> <mountpoint>
19442 [ "$1" == "blocks" ] && inodes= || inodes="-i"
19444 for count in {1..100}; do
19448 # read the lines of interest
19449 df_out=($(df -P $inodes $dir | tail -n +2)) ||
19450 error "df $inodes $dir | tail -n +2 failed"
19451 lfs_df_out=($($LFS df $inodes $dir | grep summary:)) ||
19452 error "lfs df $inodes $dir | grep summary: failed"
19454 # skip first substrings of each output as they are different
19455 # "<NID>:/<fsname>" for df, "filesystem_summary:" for lfs df
19456 # compare the remaining fields of the two outputs
19458 for i in {1..5}; do
19459 [ "${df_out[i]}" != "${lfs_df_out[i]}" ] && passed=false
19467 lfs df $inodes $dir
19468 error "df and lfs df $1 output mismatch: " \
19469 "df ${inodes}: ${df_out[*]}, " \
19470 "lfs df ${inodes}: ${lfs_df_out[*]}"
19475 [ $PARALLEL == "yes" ] && skip "skip parallel run"
19477 local dir=$DIR/$tdir
19478 local numfiles=$((RANDOM % 4096 + 2))
19479 local numblocks=$((RANDOM % 256 + 1))
19481 wait_delete_completed
19484 # check block output
19485 check_lfs_df blocks $dir
19486 # check inode output
19487 check_lfs_df inodes $dir
19489 # create a single file and retest
19490 echo "Creating a single file and testing"
19491 createmany -o $dir/$tfile- 1 &>/dev/null ||
19492 error "creating 1 file in $dir failed"
19493 check_lfs_df blocks $dir
19494 check_lfs_df inodes $dir
19496 # create a random number of files
19497 echo "Creating $((numfiles - 1)) files and testing"
19498 createmany -o $dir/$tfile- 1 $((numfiles - 1)) &>/dev/null ||
19499 error "creating $((numfiles - 1)) files in $dir failed"
19501 # write a random number of blocks to the first test file
19502 echo "Writing $numblocks 4K blocks and testing"
19503 dd if=/dev/urandom of=$dir/${tfile}-0 bs=4K conv=fsync \
19504 count=$numblocks &>/dev/null ||
19505 error "dd to $dir/${tfile}-0 failed"
19508 check_lfs_df blocks $dir
19509 check_lfs_df inodes $dir
19511 unlinkmany $dir/$tfile- $numfiles &>/dev/null ||
19512 error "unlinking $numfiles files in $dir failed"
19514 run_test 418 "df and lfs df outputs match"
19518 local dir=$DIR/$tdir
19523 cancel_lru_locks mdc
19525 #OBD_FAIL_LLITE_OPEN_BY_NAME 0x1410
19526 $LCTL set_param fail_loc=0x1410
19528 $LCTL set_param fail_loc=0
19531 run_test 419 "Verify open file by name doesn't crash kernel"
19535 [[ $MDS1_VERSION -ge $(version_code 2.12.1) ]] ||
19536 skip "Need MDS version at least 2.12.1"
19538 local SAVE_UMASK=$(umask)
19539 local dir=$DIR/$tdir
19540 local uname=$(getent passwd $RUNAS_ID | cut -d: -f1)
19544 mkdir -m03777 $dir/testdir
19545 ls -dn $dir/testdir
19546 local dirperms=$(ls -dn $dir/testdir | awk '{print $1}')
19547 [ $dirperms == "drwxrwsrwt" ] ||
19548 error "incorrect perms on $dir/testdir"
19550 $PDSH ${uname}@localhost "PATH=$LUSTRE/tests:\$PATH; \
19551 openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
19552 ls -n $dir/testdir/testfile
19553 local fileperms=$(ls -n $dir/testdir/testfile | awk '{print $1}')
19554 [ $fileperms == "-rwxr-xr-x" ] ||
19555 error "incorrect perms on $dir/testdir/testfile"
19559 run_test 420 "clear SGID bit on non-directories for non-members"
19562 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
19563 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
19564 skip "Need server version at least 2.9.55"
19566 start_full_debug_logging
19570 stop_full_debug_logging
19574 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19575 local st=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19576 awk '/The barrier for/ { print $7 }')
19579 local st=$(do_facet mgs $LCTL barrier_stat -s $FSNAME)
19584 barrier_expired() {
19587 if [ $MGS_VERSION -le $(version_code 2.10.0) ]; then
19588 expired=$(do_facet mgs $LCTL barrier_stat $FSNAME |
19589 awk '/will be expired/ { print $7 }')
19591 expired=$(do_facet mgs $LCTL barrier_stat -t $FSNAME)
19600 echo "Start barrier_freeze at: $(date)"
19601 #define OBD_FAIL_BARRIER_DELAY 0x2202
19602 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
19603 do_facet mgs $LCTL barrier_freeze $FSNAME 10 &
19606 local b_status=$(barrier_stat)
19607 echo "Got barrier status at: $(date)"
19608 [ "$b_status" = "'freezing_p1'" ] ||
19609 error "(1) unexpected barrier status $b_status"
19611 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
19613 b_status=$(barrier_stat)
19614 [ "$b_status" = "'frozen'" ] ||
19615 error "(2) unexpected barrier status $b_status"
19617 local expired=$(barrier_expired)
19618 echo "sleep $((expired + 3)) seconds, then the barrier will be expired"
19619 sleep $((expired + 3))
19621 b_status=$(barrier_stat)
19622 [ "$b_status" = "'expired'" ] ||
19623 error "(3) unexpected barrier status $b_status"
19625 do_facet mgs $LCTL barrier_freeze $FSNAME 10 ||
19626 error "(4) fail to freeze barrier"
19628 b_status=$(barrier_stat)
19629 [ "$b_status" = "'frozen'" ] ||
19630 error "(5) unexpected barrier status $b_status"
19632 echo "Start barrier_thaw at: $(date)"
19633 #define OBD_FAIL_BARRIER_DELAY 0x2202
19634 do_facet mgs $LCTL set_param fail_val=5 fail_loc=0x2202
19635 do_facet mgs $LCTL barrier_thaw $FSNAME &
19638 b_status=$(barrier_stat)
19639 echo "Got barrier status at: $(date)"
19640 [ "$b_status" = "'thawing'" ] ||
19641 error "(6) unexpected barrier status $b_status"
19643 do_facet mgs $LCTL set_param fail_val=0 fail_loc=0
19645 b_status=$(barrier_stat)
19646 [ "$b_status" = "'thawed'" ] ||
19647 error "(7) unexpected barrier status $b_status"
19649 #define OBD_FAIL_BARRIER_FAILURE 0x2203
19650 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2203
19651 do_facet mgs $LCTL barrier_freeze $FSNAME
19653 b_status=$(barrier_stat)
19654 [ "$b_status" = "'failed'" ] ||
19655 error "(8) unexpected barrier status $b_status"
19657 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
19658 do_facet mgs $LCTL barrier_thaw $FSNAME
19662 run_test 801a "write barrier user interfaces and stat machine"
19667 mkdir $DIR/$tdir || error "(1) fail to mkdir"
19668 createmany -d $DIR/$tdir/d 6 || "(2) fail to mkdir"
19669 touch $DIR/$tdir/d2/f10 || error "(3) fail to touch"
19670 touch $DIR/$tdir/d3/f11 || error "(4) fail to touch"
19671 touch $DIR/$tdir/d4/f12 || error "(5) fail to touch"
19673 cancel_lru_locks mdc
19675 # 180 seconds should be long enough
19676 do_facet mgs $LCTL barrier_freeze $FSNAME 180
19678 local b_status=$(barrier_stat)
19679 [ "$b_status" = "'frozen'" ] ||
19680 error "(6) unexpected barrier status $b_status"
19682 mkdir $DIR/$tdir/d0/d10 &
19685 touch $DIR/$tdir/d1/f13 &
19688 ln $DIR/$tdir/d2/f10 $DIR/$tdir/d2/f14 &
19691 mv $DIR/$tdir/d3/f11 $DIR/$tdir/d3/f15 &
19694 rm -f $DIR/$tdir/d4/f12 &
19697 stat $DIR/$tdir/d5 || error "(7) stat should succeed"
19699 # To guarantee taht the 'stat' is not blocked
19700 b_status=$(barrier_stat)
19701 [ "$b_status" = "'frozen'" ] ||
19702 error "(8) unexpected barrier status $b_status"
19704 # let above commands to run at background
19707 ps -p $mkdir_pid || error "(9) mkdir should be blocked"
19708 ps -p $touch_pid || error "(10) touch should be blocked"
19709 ps -p $ln_pid || error "(11) link should be blocked"
19710 ps -p $mv_pid || error "(12) rename should be blocked"
19711 ps -p $rm_pid || error "(13) unlink should be blocked"
19713 b_status=$(barrier_stat)
19714 [ "$b_status" = "'frozen'" ] ||
19715 error "(14) unexpected barrier status $b_status"
19717 do_facet mgs $LCTL barrier_thaw $FSNAME
19718 b_status=$(barrier_stat)
19719 [ "$b_status" = "'thawed'" ] ||
19720 error "(15) unexpected barrier status $b_status"
19722 wait $mkdir_pid || error "(16) mkdir should succeed"
19723 wait $touch_pid || error "(17) touch should succeed"
19724 wait $ln_pid || error "(18) link should succeed"
19725 wait $mv_pid || error "(19) rename should succeed"
19726 wait $rm_pid || error "(20) unlink should succeed"
19730 run_test 801b "modification will be blocked by write barrier"
19733 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19737 stop mds2 || error "(1) Fail to stop mds2"
19739 do_facet mgs $LCTL barrier_freeze $FSNAME 30
19741 local b_status=$(barrier_stat)
19742 [ "$b_status" = "'expired'" -o "$b_status" = "'failed'" ] || {
19743 do_facet mgs $LCTL barrier_thaw $FSNAME
19744 error "(2) unexpected barrier status $b_status"
19747 do_facet mgs $LCTL barrier_rescan $FSNAME ||
19748 error "(3) Fail to rescan barrier bitmap"
19750 do_facet mgs $LCTL barrier_freeze $FSNAME 10
19752 b_status=$(barrier_stat)
19753 [ "$b_status" = "'frozen'" ] ||
19754 error "(4) unexpected barrier status $b_status"
19756 do_facet mgs $LCTL barrier_thaw $FSNAME
19757 b_status=$(barrier_stat)
19758 [ "$b_status" = "'thawed'" ] ||
19759 error "(5) unexpected barrier status $b_status"
19761 local devname=$(mdsdevname 2)
19763 start mds2 $devname $MDS_MOUNT_OPTS || error "(6) Fail to start mds2"
19765 do_facet mgs $LCTL barrier_rescan $FSNAME ||
19766 error "(7) Fail to rescan barrier bitmap"
19770 run_test 801c "rescan barrier bitmap"
19772 saved_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
19773 saved_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
19774 saved_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
19780 MGS_MOUNT_OPTS=$saved_MGS_MOUNT_OPTS
19781 MDS_MOUNT_OPTS=$saved_MDS_MOUNT_OPTS
19782 OST_MOUNT_OPTS=$saved_OST_MOUNT_OPTS
19788 [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
19789 [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&
19790 skip "Need server version at least 2.9.55"
19792 [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
19794 mkdir $DIR/$tdir || error "(1) fail to mkdir"
19796 cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ ||
19797 error "(2) Fail to copy"
19799 trap cleanup_802 EXIT
19801 # sync by force before remount as readonly
19802 sync; sync_all_data; sleep 3; sync_all_data
19806 MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
19807 MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
19808 OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
19810 echo "Mount the server as read only"
19811 setupall server_only || error "(3) Fail to start servers"
19813 echo "Mount client without ro should fail"
19814 mount_client $MOUNT &&
19815 error "(4) Mount client without 'ro' should fail"
19817 echo "Mount client with ro should succeed"
19818 mount_client $MOUNT ro ||
19819 error "(5) Mount client with 'ro' should succeed"
19821 echo "Modify should be refused"
19822 touch $DIR/$tdir/guard && error "(6) Touch should fail under ro mode"
19824 echo "Read should be allowed"
19825 diff $LUSTRE/tests/test-framework.sh $DIR/$tdir/test-framework.sh ||
19826 error "(7) Read should succeed under ro mode"
19830 run_test 802 "simulate readonly device"
19833 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19834 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
19835 skip "MDS needs to be newer than 2.10.54"
19837 mkdir -p $DIR/$tdir
19838 # Create some objects on all MDTs to trigger related logs objects
19839 for idx in $(seq $MDSCOUNT); do
19840 $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
19841 $DIR/$tdir/dir${idx} ||
19842 error "Fail to create $DIR/$tdir/dir${idx}"
19846 wait_delete_completed # ensure old test cleanups are finished
19847 echo "before create:"
19849 local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
19851 for i in {1..10}; do
19852 $LFS mkdir -c 1 -i 1 $DIR/$tdir/foo$i ||
19853 error "Fail to create $DIR/$tdir/foo$i"
19857 echo "after create:"
19859 local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
19861 # allow for an llog to be cleaned up during the test
19862 [ $after_used -ge $((before_used + 10 - 1)) ] ||
19863 error "before ($before_used) + 10 > after ($after_used)"
19865 for i in {1..10}; do
19866 rm -rf $DIR/$tdir/foo$i ||
19867 error "Fail to remove $DIR/$tdir/foo$i"
19870 sleep 3 # avoid MDT return cached statfs
19871 wait_delete_completed
19872 echo "after unlink:"
19874 after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
19876 # allow for an llog to be created during the test
19877 [ $after_used -le $((before_used + 1)) ] ||
19878 error "after ($after_used) > before ($before_used) + 1"
19880 run_test 803 "verify agent object for remote object"
19883 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
19884 [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
19885 skip "MDS needs to be newer than 2.10.54"
19886 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
19888 mkdir -p $DIR/$tdir
19889 $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
19890 error "Fail to create $DIR/$tdir/dir0"
19892 local fid=$($LFS path2fid $DIR/$tdir/dir0)
19893 local dev=$(mdsdevname 2)
19895 do_facet mds2 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
19896 grep ${fid} || error "NOT found agent entry for dir0"
19898 $LFS mkdir -c $MDSCOUNT -i 0 $DIR/$tdir/dir1 ||
19899 error "Fail to create $DIR/$tdir/dir1"
19901 touch $DIR/$tdir/dir1/foo0 ||
19902 error "Fail to create $DIR/$tdir/dir1/foo0"
19903 fid=$($LFS path2fid $DIR/$tdir/dir1/foo0)
19906 for idx in $(seq $MDSCOUNT); do
19907 dev=$(mdsdevname $idx)
19908 do_facet mds${idx} \
19909 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
19910 grep ${fid} && rc=$idx
19913 mv $DIR/$tdir/dir1/foo0 $DIR/$tdir/dir1/foo1 ||
19914 error "Fail to rename foo0 to foo1"
19915 if [ $rc -eq 0 ]; then
19916 for idx in $(seq $MDSCOUNT); do
19917 dev=$(mdsdevname $idx)
19918 do_facet mds${idx} \
19919 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
19920 grep ${fid} && rc=$idx
19924 mv $DIR/$tdir/dir1/foo1 $DIR/$tdir/dir1/foo2 ||
19925 error "Fail to rename foo1 to foo2"
19926 if [ $rc -eq 0 ]; then
19927 for idx in $(seq $MDSCOUNT); do
19928 dev=$(mdsdevname $idx)
19929 do_facet mds${idx} \
19930 "$DEBUGFS -c -R 'ls /REMOTE_PARENT_DIR' $dev" |
19931 grep ${fid} && rc=$idx
19935 [ $rc -ne 0 ] || error "NOT found agent entry for foo"
19937 ln $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir0/guard ||
19938 error "Fail to link to $DIR/$tdir/dir1/foo2"
19939 mv $DIR/$tdir/dir1/foo2 $DIR/$tdir/dir1/foo0 ||
19940 error "Fail to rename foo2 to foo0"
19941 unlink $DIR/$tdir/dir1/foo0 ||
19942 error "Fail to unlink $DIR/$tdir/dir1/foo0"
19943 rm -rf $DIR/$tdir/dir0 ||
19944 error "Fail to rm $DIR/$tdir/dir0"
19946 for idx in $(seq $MDSCOUNT); do
19947 dev=$(mdsdevname $idx)
19951 run_e2fsck $(facet_active_host mds$idx) $dev -n ||
19953 start mds${idx} $dev $MDS_MOUNT_OPTS ||
19954 error "mount mds$idx failed"
19955 df $MOUNT > /dev/null 2>&1
19957 # e2fsck should not return error
19959 error "e2fsck detected error on MDT${idx}: rc=$rc"
19962 run_test 804 "verify agent entry for remote entry"
19965 do_facet $SINGLEMDS zfs set quota=$old $fsset
19966 unlinkmany $DIR/$tdir/f- 1000000
19971 local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
19972 [ "$mds1_FSTYPE" != "zfs" ] && skip "ZFS specific test"
19973 [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
19974 skip "netfree not implemented before 0.7"
19975 [[ $MDS1_VERSION -ge $(version_code 2.10.57) ]] ||
19976 skip "Need MDS version at least 2.10.57"
19983 local pref="osd-zfs.lustre-MDT0000."
19985 # limit available space on MDS dataset to meet nospace issue
19986 # quickly. then ZFS 0.7.2 can use reserved space if asked
19987 # properly (using netfree flag in osd_declare_destroy()
19988 fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
19989 old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
19991 freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
19992 usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
19993 let "usedkb=usedkb-freekb"
19994 let "freekb=freekb/2"
19995 if let "freekb > 5000"; then
19998 do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
19999 trap cleanup_805 EXIT
20001 $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
20002 createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
20003 rm -rf $DIR/$tdir || error "not able to remove"
20004 do_facet $SINGLEMDS zfs set quota=$old $fsset
20007 run_test 805 "ZFS can remove from full fs"
20013 local size=$($LFS getsom -s $file)
20014 local expect=$(stat -c %s $file)
20016 [[ $size == $expect ]] ||
20017 error "$file expected size: $expect, got: $size"
20019 local blocks=$($LFS getsom -b $file)
20020 expect=$(stat -c %b $file)
20021 [[ $blocks == $expect ]] ||
20022 error "$file expected blocks: $expect, got: $blocks"
20027 local size=$($LFS getsom -s $1)
20030 [[ $size == $expect ]] ||
20031 error "$file expected size: $expect, got: $size"
20035 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20036 skip "Need MDS version at least 2.11.52"
20040 touch $DIR/$tfile || error "touch $tfile failed"
20042 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20043 save_lustre_params client "llite.*.xattr_cache" > $save
20044 lctl set_param llite.*.xattr_cache=0
20045 stack_trap "restore_lustre_params < $save" EXIT
20047 # single-threaded write
20048 echo "Test SOM for single-threaded write"
20049 dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
20050 error "write $tfile failed"
20051 check_lsom_size $DIR/$tfile $bs
20054 local size=$(($num * $bs))
20058 echo "Test SOM for single client multi-threaded($num) write"
20059 $TRUNCATE $DIR/$tfile 0
20060 for ((i = 0; i < $num; i++)); do
20061 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20063 offset=$((offset + $bs))
20065 for (( i=0; i < $num; i++ )); do
20068 check_lsom_size $DIR/$tfile $size
20070 $TRUNCATE $DIR/$tfile 0
20071 for ((i = 0; i < $num; i++)); do
20072 offset=$((offset - $bs))
20073 $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20076 for (( i=0; i < $num; i++ )); do
20079 check_lsom_size $DIR/$tfile $size
20081 # multi-client wirtes
20082 num=$(get_node_count ${CLIENTS//,/ })
20083 size=$(($num * $bs))
20087 echo "Test SOM for multi-client ($num) writes"
20088 $TRUNCATE $DIR/$tfile 0
20089 for client in ${CLIENTS//,/ }; do
20090 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20093 offset=$((offset + $bs))
20095 for (( i=0; i < $num; i++ )); do
20098 check_lsom_size $DIR/$tfile $offset
20101 $TRUNCATE $DIR/$tfile 0
20102 for client in ${CLIENTS//,/ }; do
20103 offset=$((offset - $bs))
20104 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20108 for (( i=0; i < $num; i++ )); do
20111 check_lsom_size $DIR/$tfile $size
20114 echo "Test SOM for truncate"
20115 $TRUNCATE $DIR/$tfile 1048576
20116 check_lsom_size $DIR/$tfile 1048576
20117 $TRUNCATE $DIR/$tfile 1234
20118 check_lsom_size $DIR/$tfile 1234
20120 # verify SOM blocks count
20121 echo "Verify SOM block count"
20122 $TRUNCATE $DIR/$tfile 0
20123 $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
20124 error "failed to write file $tfile"
20125 check_lsom_data $DIR/$tfile
20127 run_test 806 "Verify Lazy Size on MDS"
20130 [ $MDS1_VERSION -lt $(version_code 2.11.52) ] &&
20131 skip "Need MDS version at least 2.11.52"
20133 # Registration step
20134 changelog_register || error "changelog_register failed"
20135 local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
20136 changelog_users $SINGLEMDS | grep -q $cl_user ||
20137 error "User $cl_user not found in changelog_users"
20139 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
20140 save_lustre_params client "llite.*.xattr_cache" > $save
20141 lctl set_param llite.*.xattr_cache=0
20142 stack_trap "restore_lustre_params < $save" EXIT
20144 rm -rf $DIR/$tdir || error "rm $tdir failed"
20145 mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
20146 touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
20147 $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
20148 $TRUNCATE $DIR/$tdir/trunc 1048576 ||
20149 error "truncate $tdir/trunc failed"
20152 dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
20153 error "write $tfile failed"
20155 # multi-client wirtes
20156 local num=$(get_node_count ${CLIENTS//,/ })
20160 echo "Test SOM for multi-client ($num) writes"
20161 touch $DIR/$tfile || error "touch $tfile failed"
20162 $TRUNCATE $DIR/$tfile 0
20163 for client in ${CLIENTS//,/ }; do
20164 do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
20167 offset=$((offset + $bs))
20169 for (( i=0; i < $num; i++ )); do
20174 $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
20175 check_lsom_data $DIR/$tdir/trunc
20176 check_lsom_data $DIR/$tdir/single_dd
20177 check_lsom_data $DIR/$tfile
20180 # Deregistration step
20181 changelog_deregister || error "changelog_deregister failed"
20183 run_test 807 "verify LSOM syncing tool"
20185 check_som_nologged()
20187 local lines=$($LFS changelog $FSNAME-MDT0000 |
20188 grep 'x=trusted.som' | wc -l)
20189 [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
20193 [ $MDS1_VERSION -lt $(version_code 2.11.55) ] &&
20194 skip "Need MDS version at least 2.11.55"
20196 # Registration step
20197 changelog_register || error "changelog_register failed"
20199 touch $DIR/$tfile || error "touch $tfile failed"
20202 dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
20203 error "write $tfile failed"
20206 $TRUNCATE $DIR/$tfile 1234
20209 $TRUNCATE $DIR/$tfile 1048576
20212 # Deregistration step
20213 changelog_deregister || error "changelog_deregister failed"
20215 run_test 808 "Check trusted.som xattr not logged in Changelogs"
20220 [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
20224 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
20225 skip "Need MDS version at least 2.11.56"
20227 $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
20228 error "failed to create DoM-only file $DIR/$tfile"
20229 touch $DIR/$tfile || error "touch $tfile failed"
20230 check_som_nodata $DIR/$tfile
20232 dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
20233 error "write $tfile failed"
20234 check_som_nodata $DIR/$tfile
20236 $TRUNCATE $DIR/$tfile 1234
20237 check_som_nodata $DIR/$tfile
20239 $TRUNCATE $DIR/$tfile 4097
20240 check_som_nodata $DIR/$file
20242 run_test 809 "Verify no SOM xattr store for DoM-only files"
20248 # t10 seem to dislike partial pages
20249 lctl set_param osc.*.checksum_type=adler
20250 lctl set_param fail_loc=0x411
20251 dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
20252 ORIG=$(md5sum $DIR/$tfile)
20253 lctl set_param ldlm.namespaces.*osc*.lru_size=clear
20254 CSUM=$(md5sum $DIR/$tfile)
20255 set_checksum_type adler
20256 if [ "$ORIG" != "$CSUM" ]; then
20257 error "$ORIG != $CSUM"
20260 run_test 810 "partial page writes on ZFS (LU-11663)"
20263 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
20264 skip "Need MDS version at least 2.11.56"
20266 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
20267 do_facet mds1 $LCTL set_param fail_loc=0x165
20268 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
20271 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
20274 [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) -eq 0 ]] ||
20275 error "MDD orphan cleanup thread not quit"
20277 run_test 811 "orphan name stub can be cleaned up in startup"
20280 [ $OST1_VERSION -lt $(version_code 2.12.51) ] &&
20281 skip "OST < 2.12.51 doesn't support this fail_loc"
20283 $LFS setstripe -c 1 -i 0 $DIR/$tfile
20284 # ensure ost1 is connected
20285 stat $DIR/$tfile >/dev/null || error "can't stat"
20286 wait_osc_import_state client ost1 FULL
20287 # no locks, no reqs to let the connection idle
20288 cancel_lru_locks osc
20290 # delay OST_DISCONNECT on OST1 to put OSC into intermediate state
20291 #define OBD_FAIL_OST_DISCONNECT_DELAY 0x245
20292 do_facet ost1 "$LCTL set_param fail_loc=0x245 fail_val=8"
20293 wait_osc_import_state client ost1 CONNECTING
20294 do_facet ost1 "$LCTL set_param fail_loc=0 fail_val=0"
20296 stat $DIR/$tfile >/dev/null || error "can't stat file"
20298 run_test 812 "do not drop reqs generated when imp is going to idle (LU-11951)"
20301 # tests that do cleanup/setup should be run at the end
20305 [ $PARALLEL == "yes" ] && skip "skip parallel run"
20308 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
20309 $LCTL set_param fail_loc=0x903
20311 cancel_lru_locks MGC
20313 FAIL_ON_ERROR=true cleanup
20314 FAIL_ON_ERROR=true setup
20316 run_test 900 "umount should not race with any mgc requeue thread"
20319 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
20320 check_and_cleanup_lustre
20321 if [ "$I_MOUNTED" != "yes" ]; then
20322 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true