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
27 ALWAYS_EXCEPT+=" 45 101c 103a 317"
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}
73 if [[ $MDSCOUNT -gt 1 ]]; then
74 # bug number: LU-11161
75 ALWAYS_EXCEPT+=" 160g"
79 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
81 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
82 # bug number for skipped test: LU-1957
83 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
85 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
88 # Get the SLES distro version
90 # Returns a version string that should only be used in comparing
91 # strings returned by version_code()
94 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
96 # All SuSE Linux versions have one decimal. version_code expects two
97 local sles_version=$version.0
98 version_code $sles_version
101 # Check if we are running on Ubuntu or SLES so we can make decisions on
103 if [ -r /etc/SuSE-release ]; then
104 sles_version=$(sles_version_code)
105 [ $sles_version -lt $(version_code 11.4.0) ] &&
106 # bug number for skipped test: LU-4341
107 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
108 [ $sles_version -lt $(version_code 12.0.0) ] &&
109 # bug number for skipped test: LU-3703
110 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
111 elif [ -r /etc/os-release ]; then
112 if grep -qi ubuntu /etc/os-release; then
113 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
114 -e 's/^VERSION=//p' \
118 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
119 # bug number for skipped test:
121 ALWAYS_EXCEPT+=" 103a 410"
130 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
131 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
140 check_swap_layouts_support()
142 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
143 skip "Does not support layout lock."
146 check_and_setup_lustre
150 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
152 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
153 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
154 rm -rf $DIR/[Rdfs][0-9]*
156 # $RUNAS_ID may get set incorrectly somewhere else
157 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
159 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
163 if [ "${ONLY}" = "MOUNT" ] ; then
164 echo "Lustre is up, please go on"
168 echo "preparing for tests involving mounts"
169 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
171 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
172 echo # add a newline after mke2fs.
176 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
177 lctl set_param debug=-1 2> /dev/null || true
180 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
182 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
184 run_test 0a "touch; rm ====================="
187 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
188 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
190 run_test 0b "chmod 0755 $DIR ============================="
193 $LCTL get_param mdc.*.import | grep "state: FULL" ||
194 error "import not FULL"
195 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
198 run_test 0c "check import proc"
200 test_0d() { # LU-3397
201 [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
202 skip "proc exports not supported before 2.10.57"
204 local mgs_exp="mgs.MGS.exports"
205 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
207 local exp_client_version
210 local temp_imp=$DIR/$tfile.import
211 local temp_exp=$DIR/$tfile.export
213 # save mgc import file to $temp_imp
214 $LCTL get_param mgc.*.import | tee $temp_imp
215 # Check if client uuid is found in MGS export
216 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
217 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
221 # save mgs export file to $temp_exp
222 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
224 # Compare the value of field "connect_flags"
225 imp_val=$(grep "connect_flags" $temp_imp)
226 exp_val=$(grep "connect_flags" $temp_exp)
227 [ "$exp_val" == "$imp_val" ] ||
228 error "export flags '$exp_val' != import flags '$imp_val'"
230 # Compare the value of client version
231 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
232 exp_val=$(version_code $exp_client_version)
233 imp_val=$(lustre_version_code client)
234 [ "$exp_val" == "$imp_val" ] ||
235 error "export client version '$exp_val' != '$imp_val'"
237 run_test 0d "check export proc ============================="
240 test_mkdir $DIR/$tdir
241 test_mkdir $DIR/$tdir/d2
242 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
243 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
246 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
248 run_test 1 "mkdir; remkdir; rmdir"
251 test_mkdir $DIR/$tdir
252 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
253 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
255 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
257 run_test 2 "mkdir; touch; rmdir; check file"
260 test_mkdir $DIR/$tdir
261 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
262 touch $DIR/$tdir/$tfile
263 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
265 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
267 run_test 3 "mkdir; touch; rmdir; check dir"
269 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
271 test_mkdir -i 1 $DIR/$tdir
273 touch $DIR/$tdir/$tfile ||
274 error "Create file under remote directory failed"
277 error "Expect error removing in-use dir $DIR/$tdir"
279 test -d $DIR/$tdir || error "Remote directory disappeared"
281 rm -rf $DIR/$tdir || error "remove remote dir error"
283 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
286 test_mkdir $DIR/$tdir
287 test_mkdir $DIR/$tdir/d2
288 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
289 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
290 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
292 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
295 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
296 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile does not have perm 0666 or UID $UID"
299 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
300 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
301 error "$tfile should be 0666 and owned by UID $UID"
303 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
306 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
309 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
312 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
313 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
314 error "$tfile should be owned by UID $RUNAS_ID"
316 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
319 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
322 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by GID $UID"
325 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
326 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
327 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
329 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
332 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
334 test_mkdir $DIR/$tdir
335 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
336 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
337 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
338 test_mkdir $DIR/$tdir/d/subdir
339 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
340 error "$tdir/d/subdir should be GID $RUNAS_GID"
341 if [[ $MDSCOUNT -gt 1 ]]; then
342 # check remote dir sgid inherite
343 $LFS mkdir -i 0 $DIR/$tdir.local ||
344 error "mkdir $tdir.local failed"
345 chmod g+s $DIR/$tdir.local ||
346 error "chmod $tdir.local failed"
347 chgrp $RUNAS_GID $DIR/$tdir.local ||
348 error "chgrp $tdir.local failed"
349 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
350 error "mkdir $tdir.remote failed"
351 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
352 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
353 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
354 error "$tdir.remote should be mode 02755"
357 run_test 6g "verify new dir in sgid dir inherits group"
359 test_6h() { # bug 7331
360 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
362 touch $DIR/$tfile || error "touch failed"
363 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
364 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
365 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
366 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
367 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
369 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
372 test_mkdir $DIR/$tdir
373 $MCREATE $DIR/$tdir/$tfile
374 chmod 0666 $DIR/$tdir/$tfile
375 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
376 error "$tdir/$tfile should be mode 0666"
378 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
381 if [ ! -d $DIR/$tdir ]; then
382 test_mkdir $DIR/$tdir
384 $MCREATE $DIR/$tdir/$tfile
385 echo -n foo > $DIR/$tdir/$tfile
386 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
387 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
389 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 chmod 0666 $DIR/$tdir/$tfile
395 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
396 error "$tfile mode not 0666"
398 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
401 test_mkdir $DIR/$tdir
402 test_mkdir $DIR/$tdir/d2
403 test_mkdir $DIR/$tdir/d2/d3
404 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
406 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
409 test_mkdir $DIR/$tdir
410 test_mkdir $DIR/$tdir/d2
411 touch $DIR/$tdir/d2/$tfile
412 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
413 error "$tdir/d2/$tfile not a file"
415 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
418 test_mkdir $DIR/$tdir
419 test_mkdir $DIR/$tdir/d2
420 chmod 0666 $DIR/$tdir/d2
421 chmod 0705 $DIR/$tdir/d2
422 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
423 error "$tdir/d2 mode not 0705"
425 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
428 test_mkdir $DIR/$tdir
429 touch $DIR/$tdir/$tfile
430 chmod 0666 $DIR/$tdir/$tfile
431 chmod 0654 $DIR/$tdir/$tfile
432 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
433 error "$tdir/d2 mode not 0654"
435 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
438 test_mkdir $DIR/$tdir
439 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
441 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
442 error "$tdir/$tfile size not 0 after truncate"
444 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
447 test_mkdir $DIR/$tdir
448 touch $DIR/$tdir/$tfile
450 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
452 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
455 test_mkdir $DIR/$tdir
456 touch $DIR/$tdir/$tfile
457 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
458 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
459 error "$tdir/${tfile_2} not a file after rename"
460 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
462 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
465 test_mkdir $DIR/$tdir
466 touch $DIR/$tdir/$tfile
467 rm -rf $DIR/$tdir/$tfile
468 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
470 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
473 test_mkdir $DIR/$tdir
474 touch $DIR/$tdir/$tfile
475 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
477 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
478 error "$tdir/l-exist not a symlink"
479 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
480 error "$tdir/l-exist not referencing a file"
481 rm -f $DIR/$tdir/l-exist
482 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
484 run_test 17a "symlinks: create, remove (real)"
487 test_mkdir $DIR/$tdir
488 ln -s no-such-file $DIR/$tdir/l-dangle
490 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
491 error "$tdir/l-dangle not referencing no-such-file"
492 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
493 error "$tdir/l-dangle not referencing non-existent file"
494 rm -f $DIR/$tdir/l-dangle
495 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
497 run_test 17b "symlinks: create, remove (dangling)"
499 test_17c() { # bug 3440 - don't save failed open RPC for replay
500 test_mkdir $DIR/$tdir
501 ln -s foo $DIR/$tdir/$tfile
502 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
504 run_test 17c "symlinks: open dangling (should return error)"
507 test_mkdir $DIR/$tdir
508 ln -s foo $DIR/$tdir/$tfile
509 touch $DIR/$tdir/$tfile || error "creating to new symlink"
511 run_test 17d "symlinks: create dangling"
514 test_mkdir $DIR/$tdir
515 local foo=$DIR/$tdir/$tfile
516 ln -s $foo $foo || error "create symlink failed"
517 ls -l $foo || error "ls -l failed"
518 ls $foo && error "ls not failed" || true
520 run_test 17e "symlinks: create recursive symlink (should return error)"
523 test_mkdir $DIR/$tdir
524 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
527 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
528 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
529 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
532 run_test 17f "symlinks: long and very long symlink name"
534 # str_repeat(S, N) generate a string that is string S repeated N times
539 while [ $((n -= 1)) -ge 0 ]; do
545 # Long symlinks and LU-2241
547 test_mkdir $DIR/$tdir
548 local TESTS="59 60 61 4094 4095"
550 # Fix for inode size boundary in 2.1.4
551 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
554 # Patch not applied to 2.2 or 2.3 branches
555 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
556 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
559 # skip long symlink name for rhel6.5.
560 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
561 grep -q '6.5' /etc/redhat-release &>/dev/null &&
562 TESTS="59 60 61 4062 4063"
565 local SYMNAME=$(str_repeat 'x' $i)
566 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
567 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
570 run_test 17g "symlinks: really long symlink name and inode boundaries"
572 test_17h() { #bug 17378
573 [ $PARALLEL == "yes" ] && skip "skip parallel run"
574 remote_mds_nodsh && skip "remote MDS with nodsh"
578 test_mkdir $DIR/$tdir
579 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
580 $LFS setstripe -c -1 $DIR/$tdir
581 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
582 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
583 touch $DIR/$tdir/$tfile || true
585 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
587 test_17i() { #bug 20018
588 [ $PARALLEL == "yes" ] && skip "skip parallel run"
589 remote_mds_nodsh && skip "remote MDS with nodsh"
591 local foo=$DIR/$tdir/$tfile
594 test_mkdir -c1 $DIR/$tdir
595 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
596 ln -s $foo $foo || error "create symlink failed"
597 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
598 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
599 ls -l $foo && error "error not detected"
602 run_test 17i "don't panic on short symlink (should return error)"
604 test_17k() { #bug 22301
605 [ $PARALLEL == "yes" ] && skip "skip parallel run"
606 [[ -z "$(which rsync 2>/dev/null)" ]] &&
607 skip "no rsync command"
608 rsync --help | grep -q xattr ||
609 skip_env "$(rsync --version | head -n1) does not support xattrs"
610 test_mkdir $DIR/$tdir
611 test_mkdir $DIR/$tdir.new
612 touch $DIR/$tdir/$tfile
613 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
614 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
615 error "rsync failed with xattrs enabled"
617 run_test 17k "symlinks: rsync with xattrs enabled"
619 test_17l() { # LU-279
620 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
621 skip "no getfattr command"
623 test_mkdir $DIR/$tdir
624 touch $DIR/$tdir/$tfile
625 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
626 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
627 # -h to not follow symlinks. -m '' to list all the xattrs.
628 # grep to remove first line: '# file: $path'.
629 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
631 lgetxattr_size_check $path $xattr ||
632 error "lgetxattr_size_check $path $xattr failed"
636 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
640 [ $PARALLEL == "yes" ] && skip "skip parallel run"
641 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
642 skip_env "ldiskfs only test"
643 remote_mds_nodsh && skip "remote MDS with nodsh"
644 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
645 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
646 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
648 local short_sym="0123456789"
649 local wdir=$DIR/$tdir
654 # create a long symlink file
655 for ((i = 0; i < 4; ++i)); do
656 long_sym=${long_sym}${long_sym}
659 echo "create 512 short and long symlink files under $wdir"
660 for ((i = 0; i < 256; ++i)); do
661 ln -sf ${long_sym}"a5a5" $wdir/long-$i
662 ln -sf ${short_sym}"a5a5" $wdir/short-$i
668 wait_delete_completed
670 echo "recreate the 512 symlink files with a shorter string"
671 for ((i = 0; i < 512; ++i)); do
672 # rewrite the symlink file with a shorter string
673 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
674 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
677 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
678 local devname=$(mdsdevname $mds_index)
680 echo "stop and checking mds${mds_index}:"
681 # e2fsck should not return error
683 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
686 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
687 error "start mds${mds_index} failed"
688 df $MOUNT > /dev/null 2>&1
690 error "e2fsck detected error for short/long symlink: rc=$rc"
693 run_test 17m "run e2fsck against MDT which contains short/long symlink"
695 check_fs_consistency_17n() {
699 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
700 # so it only check MDT1/MDT2 instead of all of MDTs.
701 for mdt_index in 1 2; do
702 local devname=$(mdsdevname $mdt_index)
703 # e2fsck should not return error
705 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
708 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
709 error "mount mds$mdt_index failed"
710 df $MOUNT > /dev/null 2>&1
716 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
717 [ $PARALLEL == "yes" ] && skip "skip parallel run"
718 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
719 skip_env "ldiskfs only test"
720 remote_mds_nodsh && skip "remote MDS with nodsh"
721 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
722 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
723 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
727 test_mkdir $DIR/$tdir
728 for ((i=0; i<10; i++)); do
729 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
730 error "create remote dir error $i"
731 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
732 error "create files under remote dir failed $i"
735 check_fs_consistency_17n ||
736 error "e2fsck report error after create files under remote dir"
738 for ((i = 0; i < 10; i++)); do
739 rm -rf $DIR/$tdir/remote_dir_${i} ||
740 error "destroy remote dir error $i"
743 check_fs_consistency_17n ||
744 error "e2fsck report error after unlink files under remote dir"
746 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
747 skip "lustre < 2.4.50 does not support migrate mv"
749 for ((i = 0; i < 10; i++)); do
750 mkdir -p $DIR/$tdir/remote_dir_${i}
751 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
752 error "create files under remote dir failed $i"
753 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
754 error "migrate remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after migration"
758 for ((i = 0; i < 10; i++)); do
759 rm -rf $DIR/$tdir/remote_dir_${i} ||
760 error "destroy remote dir error $i"
763 check_fs_consistency_17n || error "e2fsck report error after unlink"
765 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
768 remote_mds_nodsh && skip "remote MDS with nodsh"
769 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
770 skip "Need MDS version at least 2.3.64"
772 local wdir=$DIR/${tdir}o
778 mdt_index=$($LFS getstripe -m $wdir/$tfile)
779 mdt_index=$((mdt_index + 1))
782 #fail mds will wait the failover finish then set
783 #following fail_loc to avoid interfer the recovery process.
786 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
787 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
788 ls -l $wdir/$tfile && rc=1
789 do_facet mds${mdt_index} lctl set_param fail_loc=0
790 [[ $rc -eq 0 ]] || error "stat file should fail"
792 run_test 17o "stat file with incompat LMA feature"
795 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
796 ls $DIR || error "Failed to ls $DIR: $?"
798 run_test 18 "touch .../f ; ls ... =============================="
804 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
806 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
809 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
811 run_test 19b "ls -l .../f19 (should return error) =============="
814 [ $RUNAS_ID -eq $UID ] &&
815 skip_env "RUNAS_ID = UID = $UID -- skipping"
817 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
819 run_test 19c "$RUNAS touch .../f19 (should return error) =="
822 cat $DIR/f19 && error || true
824 run_test 19d "cat .../f19 (should return error) =============="
833 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
835 run_test 20 "touch .../f ; ls -l ..."
838 test_mkdir $DIR/$tdir
839 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
840 ln -s dangle $DIR/$tdir/link
841 echo foo >> $DIR/$tdir/link
842 cat $DIR/$tdir/dangle
843 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
844 $CHECKSTAT -f -t file $DIR/$tdir/link ||
845 error "$tdir/link not linked to a file"
847 run_test 21 "write to dangling link"
850 local wdir=$DIR/$tdir
852 chown $RUNAS_ID:$RUNAS_GID $wdir
853 (cd $wdir || error "cd $wdir failed";
854 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
856 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
857 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
858 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
859 error "checkstat -u failed"
861 run_test 22 "unpack tar archive as non-root user"
865 test_mkdir $DIR/$tdir
866 local file=$DIR/$tdir/$tfile
868 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
869 openfile -f O_CREAT:O_EXCL $file &&
870 error "$file recreate succeeded" || true
872 run_test 23a "O_CREAT|O_EXCL in subdir"
874 test_23b() { # bug 18988
875 test_mkdir $DIR/$tdir
876 local file=$DIR/$tdir/$tfile
879 echo foo > $file || error "write filed"
880 echo bar >> $file || error "append filed"
881 $CHECKSTAT -s 8 $file || error "wrong size"
884 run_test 23b "O_APPEND check"
886 # LU-9409, size with O_APPEND and tiny writes
888 local file=$DIR/$tfile
891 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
892 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
899 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
902 #racing tiny & normal writes
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
906 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
909 #racing tiny & normal writes 2, ugly numbers
910 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
911 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
913 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
916 run_test 23c "O_APPEND size checks for tiny writes"
918 # LU-11069 file offset is correct after appending writes
920 local file=$DIR/$tfile
923 echo CentaurHauls > $file
924 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
925 if ((offset != 26)); then
926 error "wrong offset, expected 26, got '$offset'"
929 run_test 23d "file offset is correct after appending writes"
933 echo '-- same directory rename'
934 test_mkdir $DIR/$tdir
935 touch $DIR/$tdir/$tfile.1
936 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
937 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
939 run_test 24a "rename file to non-existent target"
942 test_mkdir $DIR/$tdir
943 touch $DIR/$tdir/$tfile.{1,2}
944 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
945 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
946 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
948 run_test 24b "rename file to existing target"
951 test_mkdir $DIR/$tdir
952 test_mkdir $DIR/$tdir/d$testnum.1
953 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
954 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
955 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
957 run_test 24c "rename directory to non-existent target"
960 test_mkdir -c1 $DIR/$tdir
961 test_mkdir -c1 $DIR/$tdir/d$testnum.1
962 test_mkdir -c1 $DIR/$tdir/d$testnum.2
963 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
964 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
965 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
967 run_test 24d "rename directory to existing target"
970 echo '-- cross directory renames --'
974 mv $DIR/R5a/f $DIR/R5b/g
975 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
976 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
978 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
983 touch $DIR/R6a/f $DIR/R6b/g
984 mv $DIR/R6a/f $DIR/R6b/g
985 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
986 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
988 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
993 test_mkdir $DIR/R7a/d
994 mv $DIR/R7a/d $DIR/R7b/e
995 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
996 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
998 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
1001 test_mkdir -c1 $DIR/R8a
1002 test_mkdir -c1 $DIR/R8b
1003 test_mkdir -c1 $DIR/R8a/d
1004 test_mkdir -c1 $DIR/R8b/e
1005 mrename $DIR/R8a/d $DIR/R8b/e
1006 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1007 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1009 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1012 echo "-- rename error cases"
1014 test_mkdir $DIR/R9/a
1016 mrename $DIR/R9/f $DIR/R9/a
1017 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1018 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1019 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1021 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1025 mrename $DIR/R10/f $DIR/R10/g
1026 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1027 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1028 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1030 run_test 24j "source does not exist ============================"
1033 test_mkdir $DIR/R11a
1034 test_mkdir $DIR/R11a/d
1036 mv $DIR/R11a/f $DIR/R11a/d
1037 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1038 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1040 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1042 # bug 2429 - rename foo foo foo creates invalid file
1045 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1047 run_test 24l "Renaming a file to itself ========================"
1051 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1052 # on ext3 this does not remove either the source or target files
1053 # though the "expected" operation would be to remove the source
1054 $CHECKSTAT -t file ${f} || error "${f} missing"
1055 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1057 run_test 24m "Renaming a file to a hard link to itself ========="
1061 # this stats the old file after it was renamed, so it should fail
1063 $CHECKSTAT ${f} || error "${f} missing"
1065 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1066 $CHECKSTAT -a ${f} || error "${f} exists"
1068 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1071 test_mkdir $DIR/$tdir
1072 rename_many -s random -v -n 10 $DIR/$tdir
1074 run_test 24o "rename of files during htree split"
1077 test_mkdir $DIR/R12a
1078 test_mkdir $DIR/R12b
1079 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1080 mrename $DIR/R12a $DIR/R12b
1081 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1082 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1083 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1084 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1086 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1088 cleanup_multiop_pause() {
1090 kill -USR1 $MULTIPID
1094 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1096 test_mkdir $DIR/R13a
1097 test_mkdir $DIR/R13b
1098 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1099 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1102 trap cleanup_multiop_pause EXIT
1103 mrename $DIR/R13a $DIR/R13b
1104 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1105 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1106 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1107 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1108 cleanup_multiop_pause
1109 wait $MULTIPID || error "multiop close failed"
1111 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1113 test_24r() { #bug 3789
1114 test_mkdir $DIR/R14a
1115 test_mkdir $DIR/R14a/b
1116 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1117 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1118 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1120 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1123 test_mkdir $DIR/R15a
1124 test_mkdir $DIR/R15a/b
1125 test_mkdir $DIR/R15a/b/c
1126 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1127 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1128 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1130 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1132 test_mkdir $DIR/R16a
1133 test_mkdir $DIR/R16a/b
1134 test_mkdir $DIR/R16a/b/c
1135 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1136 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1137 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1139 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1141 test_24u() { # bug12192
1142 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1143 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1145 run_test 24u "create stripe file"
1147 simple_cleanup_common() {
1150 [ -z "$DIR" -o -z "$tdir" ] && return 0
1152 local start=$SECONDS
1155 wait_delete_completed
1156 echo "cleanup time $((SECONDS - start))"
1160 max_pages_per_rpc() {
1161 local mdtname="$(printf "MDT%04x" ${1:-0})"
1162 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1166 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1168 local nrfiles=${COUNT:-100000}
1169 local fname="$DIR/$tdir/$tfile"
1171 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1172 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1174 test_mkdir "$(dirname $fname)"
1175 # assume MDT0000 has the fewest inodes
1176 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1177 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1178 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1180 trap simple_cleanup_common EXIT
1182 createmany -m "$fname" $nrfiles
1184 cancel_lru_locks mdc
1185 lctl set_param mdc.*.stats clear
1187 # was previously test_24D: LU-6101
1188 # readdir() returns correct number of entries after cursor reload
1189 local num_ls=$(ls $DIR/$tdir | wc -l)
1190 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1191 local num_all=$(ls -a $DIR/$tdir | wc -l)
1192 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1193 $num_all -ne $((nrfiles + 2)) ]; then
1194 error "Expected $nrfiles files, got $num_ls " \
1195 "($num_uniq unique $num_all .&..)"
1197 # LU-5 large readdir
1198 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1199 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1200 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1201 # take into account of overhead in lu_dirpage header and end mark in
1202 # each page, plus one in rpc_num calculation.
1203 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1204 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1205 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1206 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1207 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1208 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1209 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1210 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1211 error "large readdir doesn't take effect: " \
1212 "$mds_readpage should be about $rpc_max"
1214 simple_cleanup_common
1216 run_test 24v "list large directory (test hash collision, b=17560)"
1218 test_24w() { # bug21506
1220 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1221 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1222 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1223 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1224 [[ "$SZ1" -eq "$SZ2" ]] ||
1225 error "Error reading at the end of the file $tfile"
1227 run_test 24w "Reading a file larger than 4Gb"
1230 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1231 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1232 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1233 skip "Need MDS version at least 2.7.56"
1236 local remote_dir=$DIR/$tdir/remote_dir
1238 test_mkdir $DIR/$tdir
1239 $LFS mkdir -i $MDTIDX $remote_dir ||
1240 error "create remote directory failed"
1242 test_mkdir $DIR/$tdir/src_dir
1243 touch $DIR/$tdir/src_file
1244 test_mkdir $remote_dir/tgt_dir
1245 touch $remote_dir/tgt_file
1247 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1248 error "rename dir cross MDT failed!"
1250 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1251 error "rename file cross MDT failed!"
1253 touch $DIR/$tdir/ln_file
1254 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1255 error "ln file cross MDT failed"
1257 rm -rf $DIR/$tdir || error "Can not delete directories"
1259 run_test 24x "cross MDT rename/link"
1262 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1263 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1265 local remote_dir=$DIR/$tdir/remote_dir
1268 test_mkdir $DIR/$tdir
1269 $LFS mkdir -i $mdtidx $remote_dir ||
1270 error "create remote directory failed"
1272 test_mkdir $remote_dir/src_dir
1273 touch $remote_dir/src_file
1274 test_mkdir $remote_dir/tgt_dir
1275 touch $remote_dir/tgt_file
1277 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1278 error "rename subdir in the same remote dir failed!"
1280 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1281 error "rename files in the same remote dir failed!"
1283 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1284 error "link files in the same remote dir failed!"
1286 rm -rf $DIR/$tdir || error "Can not delete directories"
1288 run_test 24y "rename/link on the same dir should succeed"
1290 test_24A() { # LU-3182
1294 test_mkdir $DIR/$tdir
1295 trap simple_cleanup_common EXIT
1296 createmany -m $DIR/$tdir/$tfile $NFILES
1297 local t=$(ls $DIR/$tdir | wc -l)
1298 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1299 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1300 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1301 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1304 simple_cleanup_common || error "Can not delete directories"
1306 run_test 24A "readdir() returns correct number of entries."
1308 test_24B() { # LU-4805
1309 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1313 test_mkdir $DIR/$tdir
1314 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1315 error "create striped dir failed"
1317 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1318 [ $count -eq 2 ] || error "Expected 2, got $count"
1320 touch $DIR/$tdir/striped_dir/a
1322 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1323 [ $count -eq 3 ] || error "Expected 3, got $count"
1325 touch $DIR/$tdir/striped_dir/.f
1327 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1328 [ $count -eq 4 ] || error "Expected 4, got $count"
1330 rm -rf $DIR/$tdir || error "Can not delete directories"
1332 run_test 24B "readdir for striped dir return correct number of entries"
1335 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1341 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1342 error "create striped dir failed"
1344 cd $DIR/$tdir/d0/striped_dir
1346 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1347 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1348 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1350 [ "$d0_ino" = "$parent_ino" ] ||
1351 error ".. wrong, expect $d0_ino, get $parent_ino"
1353 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1354 error "mv striped dir failed"
1356 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1358 [ "$d1_ino" = "$parent_ino" ] ||
1359 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1361 run_test 24C "check .. in striped dir"
1364 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1365 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1368 mkdir $DIR/$tdir/src_dir
1369 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1370 error "create remote source failed"
1372 touch $DIR/$tdir/src_dir/src_child/a
1374 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1375 error "create remote target dir failed"
1377 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1378 error "create remote target child failed"
1380 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1381 error "rename dir cross MDT failed!"
1385 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1386 error "src_child still exists after rename"
1388 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1389 error "missing file(a) after rename"
1391 rm -rf $DIR/$tdir || error "Can not delete directories"
1393 run_test 24E "cross MDT rename/link"
1396 echo '== symlink sanity ============================================='
1400 touch $DIR/s25/foo ||
1401 error "File creation in symlinked directory failed"
1403 run_test 25a "create file in symlinked directory ==============="
1406 [ ! -d $DIR/d25 ] && test_25a
1407 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1409 run_test 25b "lookup file in symlinked directory ==============="
1413 test_mkdir $DIR/d26/d26-2
1414 ln -s d26/d26-2 $DIR/s26
1415 touch $DIR/s26/foo || error "File creation failed"
1417 run_test 26a "multiple component symlink ======================="
1420 test_mkdir -p $DIR/$tdir/d26-2
1421 ln -s $tdir/d26-2/foo $DIR/s26-2
1422 touch $DIR/s26-2 || error "File creation failed"
1424 run_test 26b "multiple component symlink at end of lookup ======"
1427 test_mkdir $DIR/d26.2
1428 touch $DIR/d26.2/foo
1429 ln -s d26.2 $DIR/s26.2-1
1430 ln -s s26.2-1 $DIR/s26.2-2
1431 ln -s s26.2-2 $DIR/s26.2-3
1432 chmod 0666 $DIR/s26.2-3/foo
1434 run_test 26c "chain of symlinks"
1436 # recursive symlinks (bug 439)
1438 ln -s d26-3/foo $DIR/d26-3
1440 run_test 26d "create multiple component recursive symlink"
1443 [ ! -h $DIR/d26-3 ] && test_26d
1446 run_test 26e "unlink multiple component recursive symlink"
1448 # recursive symlinks (bug 7022)
1450 test_mkdir $DIR/$tdir
1451 test_mkdir $DIR/$tdir/$tfile
1452 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1453 test_mkdir -p lndir/bar1
1454 test_mkdir $DIR/$tdir/$tfile/$tfile
1455 cd $tfile || error "cd $tfile failed"
1456 ln -s .. dotdot || error "ln dotdot failed"
1457 ln -s dotdot/lndir lndir || error "ln lndir failed"
1458 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1459 output=`ls $tfile/$tfile/lndir/bar1`
1460 [ "$output" = bar1 ] && error "unexpected output"
1461 rm -r $tfile || error "rm $tfile failed"
1462 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1464 run_test 26f "rm -r of a directory which has recursive symlink"
1467 test_mkdir $DIR/$tdir
1468 $LFS getstripe $DIR/$tdir
1469 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1470 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1471 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1473 run_test 27a "one stripe file"
1476 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1478 test_mkdir $DIR/$tdir
1479 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1480 $LFS getstripe -c $DIR/$tdir/$tfile
1481 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1482 error "two-stripe file doesn't have two stripes"
1484 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1486 run_test 27b "create and write to two stripe file"
1489 test_mkdir $DIR/$tdir
1490 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1491 error "setstripe failed"
1492 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1493 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1495 run_test 27d "create file with default settings"
1498 # LU-5839 adds check for existed layout before setting it
1499 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1500 skip "Need MDS version at least 2.7.56"
1502 test_mkdir $DIR/$tdir
1503 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1504 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1505 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1507 run_test 27e "setstripe existing file (should return error)"
1510 test_mkdir $DIR/$tdir
1511 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1512 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1513 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1514 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1515 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1516 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1518 run_test 27f "setstripe with bad stripe size (should return error)"
1521 test_mkdir $DIR/$tdir
1522 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1523 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1524 error "$DIR/$tdir/$tfile has object"
1526 run_test 27g "$LFS getstripe with no objects"
1529 test_mkdir $DIR/$tdir
1530 touch $DIR/$tdir/$tfile || error "touch failed"
1531 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1532 error "missing objects"
1534 run_test 27i "$LFS getstripe with some objects"
1537 test_mkdir $DIR/$tdir
1538 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1539 error "setstripe failed" || true
1541 run_test 27j "setstripe with bad stripe offset (should return error)"
1543 test_27k() { # bug 2844
1544 test_mkdir $DIR/$tdir
1545 local file=$DIR/$tdir/$tfile
1546 local ll_max_blksize=$((4 * 1024 * 1024))
1547 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1548 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1549 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1550 dd if=/dev/zero of=$file bs=4k count=1
1551 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1552 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1554 run_test 27k "limit i_blksize for broken user apps"
1557 mcreate $DIR/$tfile || error "creating file"
1558 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1559 error "setstripe should have failed" || true
1561 run_test 27l "check setstripe permissions (should return error)"
1564 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1566 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1568 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1569 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1571 trap simple_cleanup_common EXIT
1572 test_mkdir $DIR/$tdir
1573 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1574 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1575 error "dd should fill OST0"
1577 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1579 [ $i -gt 256 ] && break
1582 touch $DIR/$tdir/$tfile.$i
1583 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1584 awk '{print $1}'| grep -w "0") ] &&
1585 error "OST0 was full but new created file still use it"
1587 touch $DIR/$tdir/$tfile.$i
1588 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1589 awk '{print $1}'| grep -w "0") ] &&
1590 error "OST0 was full but new created file still use it"
1591 simple_cleanup_common
1593 run_test 27m "create file while OST0 was full"
1596 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1597 awk '{ print $1 * 2; exit; }')
1601 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1602 # if the OST isn't full anymore.
1604 local OSTIDX=${1:-""}
1606 local list=$(comma_list $(osts_nodes))
1607 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1609 do_nodes $list lctl set_param fail_loc=0
1610 sync # initiate all OST_DESTROYs from MDS to OST
1614 exhaust_precreations() {
1617 local FAILIDX=${3:-$OSTIDX}
1618 local ofacet=ost$((OSTIDX + 1))
1620 test_mkdir -p -c1 $DIR/$tdir
1621 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1622 local mfacet=mds$((mdtidx + 1))
1623 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1625 local OST=$(ostname_from_index $OSTIDX)
1628 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1629 local last_id=$(do_facet $mfacet lctl get_param -n \
1630 osc.$mdtosc_proc1.prealloc_last_id)
1631 local next_id=$(do_facet $mfacet lctl get_param -n \
1632 osc.$mdtosc_proc1.prealloc_next_id)
1634 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1635 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1637 test_mkdir -p $DIR/$tdir/${OST}
1638 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1639 #define OBD_FAIL_OST_ENOSPC 0x215
1640 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1641 echo "Creating to objid $last_id on ost $OST..."
1642 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1643 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1644 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1648 exhaust_all_precreations() {
1650 for (( i=0; i < OSTCOUNT; i++ )) ; do
1651 exhaust_precreations $i $1 -1
1656 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1658 remote_mds_nodsh && skip "remote MDS with nodsh"
1659 remote_ost_nodsh && skip "remote OST with nodsh"
1662 rm -f $DIR/$tdir/$tfile
1663 exhaust_precreations 0 0x80000215
1664 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1665 touch $DIR/$tdir/$tfile || error "touch failed"
1666 $LFS getstripe $DIR/$tdir/$tfile
1669 run_test 27n "create file with some full OSTs"
1672 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1673 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1674 remote_mds_nodsh && skip "remote MDS with nodsh"
1675 remote_ost_nodsh && skip "remote OST with nodsh"
1678 rm -f $DIR/$tdir/$tfile
1679 exhaust_all_precreations 0x215
1681 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1686 run_test 27o "create file with all full OSTs (should error)"
1689 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1690 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1691 remote_mds_nodsh && skip "remote MDS with nodsh"
1692 remote_ost_nodsh && skip "remote OST with nodsh"
1695 rm -f $DIR/$tdir/$tfile
1696 test_mkdir $DIR/$tdir
1698 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1699 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1700 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1702 exhaust_precreations 0 0x80000215
1703 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1704 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1705 $LFS getstripe $DIR/$tdir/$tfile
1709 run_test 27p "append to a truncated file with some full OSTs"
1712 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1714 remote_mds_nodsh && skip "remote MDS with nodsh"
1715 remote_ost_nodsh && skip "remote OST with nodsh"
1718 rm -f $DIR/$tdir/$tfile
1720 test_mkdir $DIR/$tdir
1721 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1722 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1723 error "truncate $DIR/$tdir/$tfile failed"
1724 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1726 exhaust_all_precreations 0x215
1728 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1729 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1733 run_test 27q "append to truncated file with all OSTs full (should error)"
1736 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1738 remote_mds_nodsh && skip "remote MDS with nodsh"
1739 remote_ost_nodsh && skip "remote OST with nodsh"
1742 rm -f $DIR/$tdir/$tfile
1743 exhaust_precreations 0 0x80000215
1745 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1749 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1751 test_27s() { # bug 10725
1752 test_mkdir $DIR/$tdir
1753 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1754 local stripe_count=0
1755 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1756 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1757 error "stripe width >= 2^32 succeeded" || true
1760 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1762 test_27t() { # bug 10864
1767 $WLFS getstripe $tfile
1770 run_test 27t "check that utils parse path correctly"
1772 test_27u() { # bug 4900
1773 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1774 remote_mds_nodsh && skip "remote MDS with nodsh"
1777 local list=$(comma_list $(mdts_nodes))
1779 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1780 do_nodes $list $LCTL set_param fail_loc=0x139
1781 test_mkdir -p $DIR/$tdir
1782 trap simple_cleanup_common EXIT
1783 createmany -o $DIR/$tdir/t- 1000
1784 do_nodes $list $LCTL set_param fail_loc=0
1786 TLOG=$TMP/$tfile.getstripe
1787 $LFS getstripe $DIR/$tdir > $TLOG
1788 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1789 unlinkmany $DIR/$tdir/t- 1000
1791 [[ $OBJS -gt 0 ]] &&
1792 error "$OBJS objects created on OST-0. See $TLOG" ||
1795 run_test 27u "skip object creation on OSC w/o objects"
1797 test_27v() { # bug 4900
1798 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1799 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1800 remote_mds_nodsh && skip "remote MDS with nodsh"
1801 remote_ost_nodsh && skip "remote OST with nodsh"
1803 exhaust_all_precreations 0x215
1806 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1808 touch $DIR/$tdir/$tfile
1809 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1811 for (( i=1; i < OSTCOUNT; i++ )); do
1812 do_facet ost$i lctl set_param fail_loc=0x705
1814 local START=`date +%s`
1815 createmany -o $DIR/$tdir/$tfile 32
1817 local FINISH=`date +%s`
1818 local TIMEOUT=`lctl get_param -n timeout`
1819 local PROCESS=$((FINISH - START))
1820 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1821 error "$FINISH - $START >= $TIMEOUT / 2"
1822 sleep $((TIMEOUT / 2 - PROCESS))
1825 run_test 27v "skip object creation on slow OST"
1827 test_27w() { # bug 10997
1828 test_mkdir $DIR/$tdir
1829 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1830 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1831 error "stripe size $size != 65536" || true
1832 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1833 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1835 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1838 [[ $OSTCOUNT -lt 2 ]] &&
1839 skip_env "skipping multiple stripe count/offset test"
1841 test_mkdir $DIR/$tdir
1842 for i in $(seq 1 $OSTCOUNT); do
1844 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1845 error "setstripe -c $i -i $offset failed"
1846 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1847 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1848 [ $count -ne $i ] && error "stripe count $count != $i" || true
1849 [ $index -ne $offset ] &&
1850 error "stripe offset $index != $offset" || true
1853 run_test 27wa "check $LFS setstripe -c -i options"
1856 remote_ost_nodsh && skip "remote OST with nodsh"
1857 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1860 OFFSET=$(($OSTCOUNT - 1))
1862 local OST=$(ostname_from_index $OSTIDX)
1864 test_mkdir $DIR/$tdir
1865 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1866 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1868 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1869 for i in $(seq 0 $OFFSET); do
1870 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1871 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1872 error "OST0 was degraded but new created file still use it"
1874 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1876 run_test 27x "create files while OST0 is degraded"
1879 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1880 remote_mds_nodsh && skip "remote MDS with nodsh"
1881 remote_ost_nodsh && skip "remote OST with nodsh"
1882 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1884 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1885 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1886 osc.$mdtosc.prealloc_last_id)
1887 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1888 osc.$mdtosc.prealloc_next_id)
1889 local fcount=$((last_id - next_id))
1890 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1891 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1893 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1894 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1895 local OST_DEACTIVE_IDX=-1
1900 for OSC in $MDS_OSCS; do
1901 OST=$(osc_to_ost $OSC)
1902 OSTIDX=$(index_from_ostuuid $OST)
1903 if [ $OST_DEACTIVE_IDX == -1 ]; then
1904 OST_DEACTIVE_IDX=$OSTIDX
1906 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1907 echo $OSC "is Deactivated:"
1908 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1912 OSTIDX=$(index_from_ostuuid $OST)
1913 test_mkdir $DIR/$tdir
1914 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1916 for OSC in $MDS_OSCS; do
1917 OST=$(osc_to_ost $OSC)
1918 OSTIDX=$(index_from_ostuuid $OST)
1919 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1920 echo $OST "is degraded:"
1921 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1922 obdfilter.$OST.degraded=1
1927 createmany -o $DIR/$tdir/$tfile $fcount
1929 for OSC in $MDS_OSCS; do
1930 OST=$(osc_to_ost $OSC)
1931 OSTIDX=$(index_from_ostuuid $OST)
1932 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1933 echo $OST "is recovered from degraded:"
1934 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1935 obdfilter.$OST.degraded=0
1937 do_facet $SINGLEMDS lctl --device %$OSC activate
1941 # all osp devices get activated, hence -1 stripe count restored
1942 local stripe_count=0
1944 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1945 # devices get activated.
1947 $LFS setstripe -c -1 $DIR/$tfile
1948 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1950 [ $stripe_count -ne $OSTCOUNT ] &&
1951 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1954 run_test 27y "create files while OST0 is degraded and the rest inactive"
1960 lmm_count=$($GETSTRIPE -c $1)
1961 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1962 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1964 local old_ifs="$IFS"
1966 fid=($($LFS path2fid $1))
1969 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1970 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1972 # compare lmm_seq and lu_fid->f_seq
1973 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1974 # compare lmm_object_id and lu_fid->oid
1975 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1977 # check the trusted.fid attribute of the OST objects of the file
1978 local have_obdidx=false
1980 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1981 # skip lines up to and including "obdidx"
1982 [ -z "$obdidx" ] && break
1983 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1984 $have_obdidx || continue
1986 local ost=$((obdidx + 1))
1987 local dev=$(ostdevname $ost)
1990 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1992 seq=$(echo $seq | sed -e "s/^0x//g")
1993 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1994 oid_hex=$(echo $oid)
1996 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1998 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
2002 # Don't unmount/remount the OSTs if we don't need to do that.
2003 # LU-2577 changes filter_fid to be smaller, so debugfs needs
2004 # update too, until that use mount/ll_decode_filter_fid/mount.
2005 # Re-enable when debugfs will understand new filter_fid.
2007 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2008 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2009 $dev 2>/dev/null" | grep "parent=")
2011 if [ -z "$ff" ]; then
2013 mount_fstype ost$ost
2014 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2015 $(facet_mntpt ost$ost)/$obj_file)
2016 unmount_fstype ost$ost
2017 start ost$ost $dev $OST_MOUNT_OPTS
2021 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2023 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2025 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2026 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2028 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2029 # stripe_size=1048576 component_id=1 component_start=0 \
2030 # component_end=33554432
2031 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2032 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2033 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2035 if grep -q 'stripe=' <<<$ff; then
2036 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2038 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2039 # into f_ver in this case. See comment on ff_parent.
2040 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2043 # compare lmm_seq and filter_fid->ff_parent.f_seq
2044 [ $ff_pseq = $lmm_seq ] ||
2045 error "FF parent SEQ $ff_pseq != $lmm_seq"
2046 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2047 [ $ff_poid = $lmm_oid ] ||
2048 error "FF parent OID $ff_poid != $lmm_oid"
2049 (($ff_pstripe == $stripe_nr)) ||
2050 error "FF stripe $ff_pstripe != $stripe_nr"
2052 stripe_nr=$((stripe_nr + 1))
2053 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2055 if grep -q 'stripe_count=' <<<$ff; then
2056 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2057 -e 's/ .*//' <<<$ff)
2058 [ $lmm_count = $ff_scnt ] ||
2059 error "FF stripe count $lmm_count != $ff_scnt"
2065 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2066 remote_ost_nodsh && skip "remote OST with nodsh"
2068 test_mkdir $DIR/$tdir
2069 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2070 { error "setstripe -c -1 failed"; return 1; }
2071 # We need to send a write to every object to get parent FID info set.
2072 # This _should_ also work for setattr, but does not currently.
2073 # touch $DIR/$tdir/$tfile-1 ||
2074 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2075 { error "dd $tfile-1 failed"; return 2; }
2076 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2077 { error "setstripe -c -1 failed"; return 3; }
2078 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2079 { error "dd $tfile-2 failed"; return 4; }
2081 # make sure write RPCs have been sent to OSTs
2084 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2085 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2087 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2089 test_27A() { # b=19102
2090 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2092 save_layout_restore_at_exit $MOUNT
2093 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2094 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2095 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2096 local default_size=$($GETSTRIPE -S $MOUNT)
2097 local default_offset=$($GETSTRIPE -i $MOUNT)
2098 local dsize=$(do_facet $SINGLEMDS \
2099 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2100 [ $default_size -eq $dsize ] ||
2101 error "stripe size $default_size != $dsize"
2102 [ $default_offset -eq -1 ] ||
2103 error "stripe offset $default_offset != -1"
2105 run_test 27A "check filesystem-wide default LOV EA values"
2107 test_27B() { # LU-2523
2108 test_mkdir $DIR/$tdir
2109 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2111 # open f1 with O_LOV_DELAY_CREATE
2113 # call setstripe ioctl on open file descriptor for f1
2115 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2119 # open f1 with O_LOV_DELAY_CREATE
2121 # call setstripe ioctl on open file descriptor for f1
2123 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2125 # Allow multiop to fail in imitation of NFS's busted semantics.
2128 run_test 27B "call setstripe on open unlinked file/rename victim"
2130 test_27C() { #LU-2871
2131 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2139 test_mkdir $DIR/$tdir
2141 for i in $(seq 0 $((OSTCOUNT - 1))); do
2142 # set stripe across all OSTs starting from OST$i
2143 $SETSTRIPE -i $i -c -1 $tfile$i
2144 # get striping information
2145 ost_idx=($($GETSTRIPE $tfile$i |
2146 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2150 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2151 error "${#ost_idx[@]} != $OSTCOUNT"
2153 for index in $(seq 0 $((OSTCOUNT - 1))); do
2155 for j in $(echo ${ost_idx[@]}); do
2156 if [ $index -eq $j ]; then
2162 error "Can not find $index in ${ost_idx[@]}"
2166 run_test 27C "check full striping across all OSTs"
2169 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2170 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2171 remote_mds_nodsh && skip "remote MDS with nodsh"
2173 local POOL=${POOL:-testpool}
2175 local last_ost=$(($OSTCOUNT - 1))
2177 local ost_list=$(seq $first_ost $ost_step $last_ost)
2178 local ost_range="$first_ost $last_ost $ost_step"
2180 if ! combined_mgs_mds ; then
2184 test_mkdir $DIR/$tdir
2185 pool_add $POOL || error "pool_add failed"
2186 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2189 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2191 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2192 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2193 skip27D+=" -s 30,31"
2194 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2195 error "llapi_layout_test failed"
2197 destroy_test_pools || error "destroy test pools failed"
2199 if ! combined_mgs_mds ; then
2203 run_test 27D "validate llapi_layout API"
2205 # Verify that default_easize is increased from its initial value after
2206 # accessing a widely striped file.
2208 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2209 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2210 skip "client does not have LU-3338 fix"
2212 # 72 bytes is the minimum space required to store striping
2213 # information for a file striped across one OST:
2214 # (sizeof(struct lov_user_md_v3) +
2215 # sizeof(struct lov_user_ost_data_v1))
2217 $LCTL set_param -n llite.*.default_easize $min_easize ||
2218 error "lctl set_param failed"
2219 local easize=$($LCTL get_param -n llite.*.default_easize)
2221 [ $easize -eq $min_easize ] ||
2222 error "failed to set default_easize"
2224 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2225 error "setstripe failed"
2229 easize=$($LCTL get_param -n llite.*.default_easize)
2231 [ $easize -gt $min_easize ] ||
2232 error "default_easize not updated"
2234 run_test 27E "check that default extended attribute size properly increases"
2236 test_27F() { # LU-5346/LU-7975
2237 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2238 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2239 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2240 skip "Need MDS version at least 2.8.51"
2241 remote_ost_nodsh && skip "remote OST with nodsh"
2243 test_mkdir $DIR/$tdir
2245 $SETSTRIPE -c 2 $DIR/$tdir
2247 # stop all OSTs to reproduce situation for LU-7975 ticket
2248 for num in $(seq $OSTCOUNT); do
2252 # open/create f0 with O_LOV_DELAY_CREATE
2253 # truncate f0 to a non-0 size
2255 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2257 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2258 # open/write it again to force delayed layout creation
2259 cat /etc/hosts > $DIR/$tdir/f0 &
2263 for num in $(seq $OSTCOUNT); do
2264 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2265 error "ost$num failed to start"
2268 wait $catpid || error "cat failed"
2270 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2271 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2274 run_test 27F "Client resend delayed layout creation with non-zero size"
2276 test_27G() { #LU-10629
2277 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2278 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2279 local POOL=${POOL:-testpool}
2280 local ostrange="0 0 1"
2282 test_mkdir $DIR/$tdir
2283 pool_add $POOL || error "pool_add failed"
2284 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2285 $LFS setstripe -p $POOL $DIR/$tdir
2287 local pool=$($LFS getstripe -p $DIR/$tdir)
2289 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2291 $LFS setstripe -d $DIR/$tdir
2293 pool=$($LFS getstripe -p $DIR/$tdir)
2297 [ -z "$pool" ] || error "'$pool' is not empty"
2299 run_test 27G "Clear OST pool from stripe"
2302 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.54) ]] &&
2303 skip "Need MDS version newer than 2.11.54"
2304 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2305 test_mkdir $DIR/$tdir
2306 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2307 touch $DIR/$tdir/$tfile
2308 $LFS getstripe -c $DIR/$tdir/$tfile
2309 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2310 error "two-stripe file doesn't have two stripes"
2312 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2313 $LFS getstripe -y $DIR/$tdir/$tfile
2314 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2315 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2316 error "expected l_ost_idx: [02]$ not matched"
2318 # make sure ost list have been cleared
2319 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2320 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2321 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2323 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2325 run_test 27H "Set specific OSTs stripe"
2327 # createtest also checks that device nodes are created and
2328 # then visible correctly (#2091)
2329 test_28() { # bug 2091
2331 $CREATETEST $DIR/d28/ct || error "createtest failed"
2333 run_test 28 "create/mknod/mkdir with bad file types ============"
2336 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2338 sync; sleep 1; sync # flush out any dirty pages from previous tests
2345 declare -i LOCKCOUNTORIG=0
2346 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2347 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2349 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2351 declare -i LOCKUNUSEDCOUNTORIG=0
2352 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2353 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2360 declare -i LOCKCOUNTCURRENT=0
2361 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2362 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2365 declare -i LOCKUNUSEDCOUNTCURRENT=0
2366 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2367 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2370 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2371 $LCTL set_param -n ldlm.dump_namespaces ""
2372 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2373 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2374 log "dumped log to $TMP/test_29.dk (bug 5793)"
2377 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2378 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2379 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2380 log "dumped log to $TMP/test_29.dk (bug 5793)"
2384 run_test 29 "IT_GETATTR regression ============================"
2386 test_30a() { # was test_30
2387 cp $(which ls) $DIR || cp /bin/ls $DIR
2388 $DIR/ls / || error "Can't execute binary from lustre"
2391 run_test 30a "execute binary from Lustre (execve) =============="
2394 cp `which ls` $DIR || cp /bin/ls $DIR
2396 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2399 run_test 30b "execute binary from Lustre as non-root ==========="
2401 test_30c() { # b=22376
2402 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2404 cp `which ls` $DIR || cp /bin/ls $DIR
2406 cancel_lru_locks mdc
2407 cancel_lru_locks osc
2408 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2411 run_test 30c "execute binary from Lustre without read perms ===="
2414 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2415 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2417 run_test 31a "open-unlink file =================================="
2420 touch $DIR/f31 || error "touch $DIR/f31 failed"
2421 ln $DIR/f31 $DIR/f31b || error "ln failed"
2422 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2423 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2425 run_test 31b "unlink file with multiple links while open ======="
2428 touch $DIR/f31 || error "touch $DIR/f31 failed"
2429 ln $DIR/f31 $DIR/f31c || error "ln failed"
2430 multiop_bg_pause $DIR/f31 O_uc ||
2431 error "multiop_bg_pause for $DIR/f31 failed"
2433 $MULTIOP $DIR/f31c Ouc
2434 kill -USR1 $MULTIPID
2437 run_test 31c "open-unlink file with multiple links ============="
2440 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2441 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2443 run_test 31d "remove of open directory ========================="
2445 test_31e() { # bug 2904
2446 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2448 run_test 31e "remove of open non-empty directory ==============="
2450 test_31f() { # bug 4554
2451 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2454 test_mkdir $DIR/d31f
2455 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2456 cp /etc/hosts $DIR/d31f
2458 $GETSTRIPE $DIR/d31f/hosts
2459 multiop_bg_pause $DIR/d31f D_c || return 1
2462 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2463 test_mkdir $DIR/d31f
2464 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2465 cp /etc/hosts $DIR/d31f
2467 $GETSTRIPE $DIR/d31f/hosts
2468 multiop_bg_pause $DIR/d31f D_c || return 1
2471 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2472 wait $MULTIPID || error "first opendir $MULTIPID failed"
2476 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2477 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2480 run_test 31f "remove of open directory with open-unlink file ==="
2483 echo "-- cross directory link --"
2484 test_mkdir -c1 $DIR/${tdir}ga
2485 test_mkdir -c1 $DIR/${tdir}gb
2486 touch $DIR/${tdir}ga/f
2487 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2488 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2489 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2490 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2491 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2493 run_test 31g "cross directory link==============="
2496 echo "-- cross directory link --"
2497 test_mkdir -c1 $DIR/${tdir}
2498 test_mkdir -c1 $DIR/${tdir}/dir
2499 touch $DIR/${tdir}/f
2500 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2501 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2502 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2503 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2504 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2506 run_test 31h "cross directory link under child==============="
2509 echo "-- cross directory link --"
2510 test_mkdir -c1 $DIR/$tdir
2511 test_mkdir -c1 $DIR/$tdir/dir
2512 touch $DIR/$tdir/dir/f
2513 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2514 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2515 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2516 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2517 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2519 run_test 31i "cross directory link under parent==============="
2522 test_mkdir -c1 -p $DIR/$tdir
2523 test_mkdir -c1 -p $DIR/$tdir/dir1
2524 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2525 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2526 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2527 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2530 run_test 31j "link for directory==============="
2533 test_mkdir -c1 -p $DIR/$tdir
2535 touch $DIR/$tdir/exist
2536 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2537 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2538 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2539 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2540 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2541 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2542 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2545 run_test 31k "link to file: the same, non-existing, dir==============="
2551 touch $DIR/d31m2/exist
2552 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2553 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2554 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2555 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2556 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2557 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2560 run_test 31m "link to file: the same, non-existing, dir==============="
2563 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2564 nlink=$(stat --format=%h $DIR/$tfile)
2565 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2567 local cmd="exec $fd<$DIR/$tfile"
2570 trap "eval $cmd" EXIT
2571 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2572 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2573 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2574 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2575 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2578 run_test 31n "check link count of unlinked file"
2581 local TEMPNAME=$(mktemp $1_XXXXXX)
2582 mlink $TEMPNAME $1 2> /dev/null &&
2583 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2587 test_31o() { # LU-2901
2588 test_mkdir $DIR/$tdir
2589 for LOOP in $(seq 100); do
2590 rm -f $DIR/$tdir/$tfile*
2591 for THREAD in $(seq 8); do
2592 link_one $DIR/$tdir/$tfile.$LOOP &
2595 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2596 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2597 error "$LINKS duplicate links to $tfile.$LOOP" &&
2601 run_test 31o "duplicate hard links with same filename"
2604 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2606 test_mkdir $DIR/$tdir
2607 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2608 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2610 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2611 error "open unlink test1 failed"
2612 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2613 error "open unlink test2 failed"
2615 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2616 error "test1 still exists"
2617 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2618 error "test2 still exists"
2620 run_test 31p "remove of open striped directory"
2622 cleanup_test32_mount() {
2625 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2626 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2627 losetup -d $loopdev || true
2633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2635 echo "== more mountpoints and symlinks ================="
2636 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2637 trap cleanup_test32_mount EXIT
2638 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2639 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2640 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2641 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2642 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2643 cleanup_test32_mount
2645 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2648 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2650 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2651 trap cleanup_test32_mount EXIT
2652 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2653 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2654 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2655 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2656 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2657 cleanup_test32_mount
2659 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2662 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2664 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2665 trap cleanup_test32_mount EXIT
2666 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2667 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2668 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2669 test_mkdir -p $DIR/$tdir/d2/test_dir
2670 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2671 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2672 cleanup_test32_mount
2674 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2677 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2679 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2680 trap cleanup_test32_mount EXIT
2681 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2682 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2683 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2684 test_mkdir -p $DIR/$tdir/d2/test_dir
2685 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2686 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2687 cleanup_test32_mount
2689 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2693 test_mkdir -p $DIR/$tdir/tmp
2694 local tmp_dir=$DIR/$tdir/tmp
2695 ln -s $DIR/$tdir $tmp_dir/symlink11
2696 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2697 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2698 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2700 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2704 test_mkdir -p $DIR/$tdir/tmp
2705 local tmp_dir=$DIR/$tdir/tmp
2706 ln -s $DIR/$tdir $tmp_dir/symlink11
2707 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2708 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2709 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2711 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2714 local tmp_dir=$DIR/$tdir/tmp
2715 test_mkdir -p $tmp_dir
2716 test_mkdir $DIR/${tdir}2
2717 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2718 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2719 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2720 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2721 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2722 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2724 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2727 rm -fr $DIR/$tdir $DIR/${tdir}2
2728 tmp_dir=$DIR/$tdir/tmp
2729 test_mkdir -p $tmp_dir
2730 test_mkdir $DIR/${tdir}2
2731 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2732 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2733 ls $tmp_dir/symlink12 || error "listing symlink12"
2734 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2736 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2739 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2741 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2742 trap cleanup_test32_mount EXIT
2743 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2744 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2745 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2746 touch $DIR/$tdir/test_file
2747 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2748 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2749 cleanup_test32_mount
2751 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2754 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2756 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2757 trap cleanup_test32_mount EXIT
2758 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2759 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2760 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2761 touch $DIR/$tdir/test_file
2762 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2763 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2764 cleanup_test32_mount
2766 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2769 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2772 trap cleanup_test32_mount EXIT
2773 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2774 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2775 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2776 test_mkdir -p $DIR/$tdir/d2
2777 touch $DIR/$tdir/d2/test_file || error "touch failed"
2778 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2779 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2780 cleanup_test32_mount
2782 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2785 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2788 trap cleanup_test32_mount EXIT
2789 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2790 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2791 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2792 test_mkdir -p $DIR/$tdir/d2
2793 touch $DIR/$tdir/d2/test_file || error "touch failed"
2794 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2795 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2796 cleanup_test32_mount
2798 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2802 test_mkdir -p $DIR/d32m/tmp
2803 TMP_DIR=$DIR/d32m/tmp
2804 ln -s $DIR $TMP_DIR/symlink11
2805 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2806 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2807 error "symlink11 not a link"
2808 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2809 error "symlink01 not a link"
2811 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2815 test_mkdir -p $DIR/d32n/tmp
2816 TMP_DIR=$DIR/d32n/tmp
2817 ln -s $DIR $TMP_DIR/symlink11
2818 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2819 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2820 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2822 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2826 test_mkdir -p $DIR/d32o/tmp
2827 TMP_DIR=$DIR/d32o/tmp
2828 ln -s $DIR/$tfile $TMP_DIR/symlink12
2829 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2830 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2831 error "symlink12 not a link"
2832 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2833 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2834 error "$DIR/d32o/tmp/symlink12 not file type"
2835 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2836 error "$DIR/d32o/symlink02 not file type"
2838 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2848 test_mkdir -p $DIR/d32p/tmp
2850 TMP_DIR=$DIR/d32p/tmp
2852 ln -s $DIR/$tfile $TMP_DIR/symlink12
2854 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2856 cat $DIR/d32p/tmp/symlink12 ||
2857 error "Can't open $DIR/d32p/tmp/symlink12"
2859 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2862 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2865 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2867 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2868 trap cleanup_test32_mount EXIT
2869 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2870 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2871 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2872 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2873 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2874 cleanup_test32_mount
2876 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2879 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2881 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2882 trap cleanup_test32_mount EXIT
2883 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2884 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2885 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2886 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2887 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2888 cleanup_test32_mount
2890 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2895 chmod 444 $DIR/$tfile
2896 chown $RUNAS_ID $DIR/$tfile
2898 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2901 run_test 33aa "write file with mode 444 (should return error)"
2905 test_mkdir $DIR/$tdir
2906 chown $RUNAS_ID $DIR/$tdir
2907 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2908 error "$RUNAS create $tdir/$tfile failed"
2909 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2910 error "open RDWR" || true
2912 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2916 test_mkdir $DIR/$tdir
2917 chown $RUNAS_ID $DIR/$tdir
2918 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2920 run_test 33b "test open file with malformed flags (No panic)"
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2924 remote_ost_nodsh && skip "remote OST with nodsh"
2933 test_mkdir $DIR/$tdir
2934 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2937 for ostnum in $(seq $OSTCOUNT); do
2938 # test-framework's OST numbering is one-based, while Lustre's
2940 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2941 # Parsing llobdstat's output sucks; we could grep the /proc
2942 # path, but that's likely to not be as portable as using the
2943 # llobdstat utility. So we parse lctl output instead.
2944 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2945 obdfilter/$ostname/stats |
2946 awk '/^write_bytes/ {print $7}' )
2947 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2948 if (( ${write_bytes:-0} > 0 ))
2955 $all_zeros || return 0
2958 echo foo > $DIR/$tdir/bar
2962 # Total up write_bytes after writing. We'd better find non-zeros.
2963 for ostnum in $(seq $OSTCOUNT); do
2964 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2965 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2966 obdfilter/$ostname/stats |
2967 awk '/^write_bytes/ {print $7}' )
2968 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2969 if (( ${write_bytes:-0} > 0 ))
2978 for ostnum in $(seq $OSTCOUNT); do
2979 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2980 echo "Check that write_bytes is present in obdfilter/*/stats:"
2981 do_facet ost$ostnum lctl get_param -n \
2982 obdfilter/$ostname/stats
2984 error "OST not keeping write_bytes stats (b22312)"
2987 run_test 33c "test llobdstat and write_bytes"
2990 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
2991 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2994 local remote_dir=$DIR/$tdir/remote_dir
2996 test_mkdir $DIR/$tdir
2997 $LFS mkdir -i $MDTIDX $remote_dir ||
2998 error "create remote directory failed"
3000 touch $remote_dir/$tfile
3001 chmod 444 $remote_dir/$tfile
3002 chown $RUNAS_ID $remote_dir/$tfile
3004 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3006 chown $RUNAS_ID $remote_dir
3007 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3008 error "create" || true
3009 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3010 error "open RDWR" || true
3011 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3013 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3016 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3020 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3021 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3022 mkdir $DIR/$tdir/local_dir
3024 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3025 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3026 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3028 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3029 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3031 rmdir $DIR/$tdir/* || error "rmdir failed"
3034 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3035 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3036 mkdir $DIR/$tdir/local_dir
3038 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3039 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3040 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3042 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3043 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3045 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3048 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3049 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3050 mkdir $DIR/$tdir/local_dir
3052 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3053 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3054 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3056 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3057 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3059 run_test 33e "mkdir and striped directory should have same mode"
3063 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3067 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3068 remote_mds_nodsh && skip "remote MDS with nodsh"
3071 chmod go+rwx $DIR/$tdir
3072 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3073 trap cleanup_33f EXIT
3075 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3076 error "cannot create striped directory"
3078 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3079 error "cannot create files in striped directory"
3081 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3082 error "cannot remove files in striped directory"
3084 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3085 error "cannot remove striped directory"
3089 run_test 33f "nonroot user can create, access, and remove a striped directory"
3092 mkdir -p $DIR/$tdir/dir2
3094 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3096 [[ $err =~ "exists" ]] || error "Not exists error"
3098 run_test 33g "nonroot user create already existing root created file"
3100 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3103 $MCREATE $DIR/f34 || error "mcreate failed"
3104 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3105 error "getstripe failed"
3106 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3107 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3108 error "getstripe failed"
3109 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3110 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3112 run_test 34a "truncate file that has not been opened ==========="
3115 [ ! -f $DIR/f34 ] && test_34a
3116 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3117 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3118 $OPENFILE -f O_RDONLY $DIR/f34
3119 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3120 error "getstripe failed"
3121 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3122 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3124 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3127 [ ! -f $DIR/f34 ] && test_34a
3128 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3129 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3130 $OPENFILE -f O_RDWR $DIR/f34
3131 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3132 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3133 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3135 run_test 34c "O_RDWR opening file-with-size works =============="
3138 [ ! -f $DIR/f34 ] && test_34a
3139 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3141 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3142 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3145 run_test 34d "write to sparse file ============================="
3149 $MCREATE $DIR/f34e || error "mcreate failed"
3150 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3151 $CHECKSTAT -s 1000 $DIR/f34e ||
3152 error "Size of $DIR/f34e not equal to 1000 bytes"
3153 $OPENFILE -f O_RDWR $DIR/f34e
3154 $CHECKSTAT -s 1000 $DIR/f34e ||
3155 error "Size of $DIR/f34e not equal to 1000 bytes"
3157 run_test 34e "create objects, some with size and some without =="
3159 test_34f() { # bug 6242, 6243
3160 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3164 $MCREATE $DIR/f34f || error "mcreate failed"
3165 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3166 dd if=$DIR/f34f of=$TMP/f34f
3167 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3168 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3169 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3170 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3171 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3173 run_test 34f "read from a file with no objects until EOF ======="
3176 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3178 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3180 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3181 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3182 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3183 cancel_lru_locks osc
3184 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3185 error "wrong size after lock cancel"
3187 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3188 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3189 error "expanding truncate failed"
3190 cancel_lru_locks osc
3191 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3192 error "wrong expanded size after lock cancel"
3194 run_test 34g "truncate long file ==============================="
3197 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3202 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3203 sync # Flush the cache so that multiop below does not block on cache
3204 # flush when getting the group lock
3205 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3208 # Since just timed wait is not good enough, let's do a sync write
3209 # that way we are sure enough time for a roundtrip + processing
3210 # passed + 2 seconds of extra margin.
3211 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3215 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3216 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3220 local nsz=`stat -c %s $DIR/$tfile`
3221 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3223 run_test 34h "ftruncate file under grouplock should not block"
3226 cp /bin/sh $DIR/f35a
3228 chown $RUNAS_ID $DIR/f35a
3229 $RUNAS $DIR/f35a && error || true
3232 run_test 35a "exec file with mode 444 (should return and not leak)"
3236 utime $DIR/f36 || error "utime failed for MDS"
3238 run_test 36a "MDS utime check (mknod, utime)"
3242 utime $DIR/f36 || error "utime failed for OST"
3244 run_test 36b "OST utime check (open, utime)"
3249 chown $RUNAS_ID $DIR/d36
3250 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3252 run_test 36c "non-root MDS utime check (mknod, utime)"
3255 [ ! -d $DIR/d36 ] && test_36c
3256 echo "" > $DIR/d36/f36
3257 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3259 run_test 36d "non-root OST utime check (open, utime)"
3262 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3264 test_mkdir $DIR/$tdir
3265 touch $DIR/$tdir/$tfile
3266 $RUNAS utime $DIR/$tdir/$tfile &&
3267 error "utime worked, expected failure" || true
3269 run_test 36e "utime on non-owned file (should return error)"
3273 local LANG_SAVE=$LANG
3274 local LC_LANG_SAVE=$LC_LANG
3275 export LANG=C LC_LANG=C # for date language
3277 DATESTR="Dec 20 2000"
3278 test_mkdir $DIR/$tdir
3279 lctl set_param fail_loc=$fl
3281 cp /etc/hosts $DIR/$tdir/$tfile
3282 sync & # write RPC generated with "current" inode timestamp, but delayed
3284 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3285 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3286 cancel_lru_locks osc
3287 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3289 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3290 echo "BEFORE: $LS_BEFORE" && \
3291 echo "AFTER : $LS_AFTER" && \
3292 echo "WANT : $DATESTR" && \
3293 error "$DIR/$tdir/$tfile timestamps changed" || true
3295 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3299 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3301 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3302 subr_36fh "0x80000214"
3304 run_test 36f "utime on file racing with OST BRW write =========="
3307 remote_ost_nodsh && skip "remote OST with nodsh"
3308 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3314 test_mkdir $DIR/$tdir
3315 fmd_max_age=$(do_facet ost1 \
3316 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3319 fmd_before=$(do_facet ost1 \
3320 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3321 touch $DIR/$tdir/$tfile
3322 sleep $((fmd_max_age + 12))
3323 fmd_after=$(do_facet ost1 \
3324 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3326 echo "fmd_before: $fmd_before"
3327 echo "fmd_after: $fmd_after"
3328 [[ $fmd_after -gt $fmd_before ]] &&
3329 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3330 error "fmd didn't expire after ping" || true
3332 run_test 36g "filter mod data cache expiry ====================="
3335 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3337 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3338 subr_36fh "0x80000227"
3340 run_test 36h "utime on file racing with OST BRW write =========="
3343 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3345 test_mkdir $DIR/$tdir
3346 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3348 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3349 local new_mtime=$((mtime + 200))
3351 #change Modify time of striped dir
3352 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3353 error "change mtime failed"
3355 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3357 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3359 run_test 36i "change mtime on striped directory"
3361 # test_37 - duplicate with tests 32q 32r
3364 local file=$DIR/$tfile
3366 openfile -f O_DIRECTORY $file
3369 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3370 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3372 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3374 test_39a() { # was test_39
3376 touch $DIR/${tfile}2
3377 # ls -l $DIR/$tfile $DIR/${tfile}2
3378 # ls -lu $DIR/$tfile $DIR/${tfile}2
3379 # ls -lc $DIR/$tfile $DIR/${tfile}2
3381 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3382 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then