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
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c"
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-11594 LU-11667 LU-11729
27 ALWAYS_EXCEPT+=" 45 103a 317 810"
30 # Check Grants after these tests
31 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
32 SRCDIR=$(cd $(dirname $0); echo $PWD)
33 export PATH=$PATH:/sbin
39 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
40 CREATETEST=${CREATETEST:-createtest}
42 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
44 OPENFILE=${OPENFILE:-openfile}
45 OPENUNLINK=${OPENUNLINK:-openunlink}
46 export MULTIOP=${MULTIOP:-multiop}
47 READS=${READS:-"reads"}
48 MUNLINK=${MUNLINK:-munlink}
49 SOCKETSERVER=${SOCKETSERVER:-socketserver}
50 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
51 MEMHOG=${MEMHOG:-memhog}
52 DIRECTIO=${DIRECTIO:-directio}
53 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
55 CHECK_GRANT=${CHECK_GRANT:-"yes"}
56 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
57 export PARALLEL=${PARALLEL:-"no"}
59 export NAME=${NAME:-local}
66 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
67 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
68 . $LUSTRE/tests/test-framework.sh
70 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
75 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
77 if [ "$mds1_FSTYPE" = "zfs" ]; then
78 # bug number for skipped test: LU-1957
79 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
81 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
84 # Get the SLES distro version
86 # Returns a version string that should only be used in comparing
87 # strings returned by version_code()
90 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
92 # All SuSE Linux versions have one decimal. version_code expects two
93 local sles_version=$version.0
94 version_code $sles_version
97 # Check if we are running on Ubuntu or SLES so we can make decisions on
99 if [ -r /etc/SuSE-release ]; then
100 sles_version=$(sles_version_code)
101 [ $sles_version -lt $(version_code 11.4.0) ] &&
102 # bug number for skipped test: LU-4341
103 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
104 [ $sles_version -lt $(version_code 12.0.0) ] &&
105 # bug number for skipped test: LU-3703
106 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
107 elif [ -r /etc/os-release ]; then
108 if grep -qi ubuntu /etc/os-release; then
109 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
110 -e 's/^VERSION=//p' \
114 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
115 # bug number for skipped test:
117 ALWAYS_EXCEPT+=" 103a 410"
126 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
127 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
136 check_swap_layouts_support()
138 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
139 skip "Does not support layout lock."
142 check_and_setup_lustre
146 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
148 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
149 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
150 rm -rf $DIR/[Rdfs][0-9]*
152 # $RUNAS_ID may get set incorrectly somewhere else
153 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] &&
154 error "\$RUNAS_ID set to 0, but \$UID is also 0!"
156 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
160 if [ "${ONLY}" = "MOUNT" ] ; then
161 echo "Lustre is up, please go on"
165 echo "preparing for tests involving mounts"
166 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
168 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
169 echo # add a newline after mke2fs.
173 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
174 lctl set_param debug=-1 2> /dev/null || true
177 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
179 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
181 run_test 0a "touch; rm ====================="
184 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
185 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
187 run_test 0b "chmod 0755 $DIR ============================="
190 $LCTL get_param mdc.*.import | grep "state: FULL" ||
191 error "import not FULL"
192 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
195 run_test 0c "check import proc"
197 test_0d() { # LU-3397
198 [ $MGS_VERSION -lt $(version_code 2.10.57) ] &&
199 skip "proc exports not supported before 2.10.57"
201 local mgs_exp="mgs.MGS.exports"
202 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
204 local exp_client_version
207 local temp_imp=$DIR/$tfile.import
208 local temp_exp=$DIR/$tfile.export
210 # save mgc import file to $temp_imp
211 $LCTL get_param mgc.*.import | tee $temp_imp
212 # Check if client uuid is found in MGS export
213 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
214 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
218 # save mgs export file to $temp_exp
219 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
221 # Compare the value of field "connect_flags"
222 imp_val=$(grep "connect_flags" $temp_imp)
223 exp_val=$(grep "connect_flags" $temp_exp)
224 [ "$exp_val" == "$imp_val" ] ||
225 error "export flags '$exp_val' != import flags '$imp_val'"
227 # Compare the value of client version
228 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
229 exp_val=$(version_code $exp_client_version)
230 imp_val=$CLIENT_VERSION
231 [ "$exp_val" == "$imp_val" ] ||
232 error "export client version '$exp_val' != '$imp_val'"
234 run_test 0d "check export proc ============================="
237 test_mkdir $DIR/$tdir
238 test_mkdir $DIR/$tdir/d2
239 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
240 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
243 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
245 run_test 1 "mkdir; remkdir; rmdir"
248 test_mkdir $DIR/$tdir
249 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
250 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
252 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
254 run_test 2 "mkdir; touch; rmdir; check file"
257 test_mkdir $DIR/$tdir
258 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
259 touch $DIR/$tdir/$tfile
260 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
262 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
264 run_test 3 "mkdir; touch; rmdir; check dir"
266 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
268 test_mkdir -i 1 $DIR/$tdir
270 touch $DIR/$tdir/$tfile ||
271 error "Create file under remote directory failed"
274 error "Expect error removing in-use dir $DIR/$tdir"
276 test -d $DIR/$tdir || error "Remote directory disappeared"
278 rm -rf $DIR/$tdir || error "remove remote dir error"
280 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
283 test_mkdir $DIR/$tdir
284 test_mkdir $DIR/$tdir/d2
285 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
286 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
287 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
289 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
292 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
293 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
294 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
295 error "$tfile does not have perm 0666 or UID $UID"
296 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
297 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
298 error "$tfile should be 0666 and owned by UID $UID"
300 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
303 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
306 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
307 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
308 error "$tfile should be owned by UID $RUNAS_ID"
309 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
310 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
311 error "$tfile should be owned by UID $RUNAS_ID"
313 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
316 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
319 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
320 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
321 error "$tfile should be owned by GID $UID"
322 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
323 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
324 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
326 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
329 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
331 test_mkdir $DIR/$tdir
332 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
333 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
334 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
335 test_mkdir $DIR/$tdir/d/subdir
336 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
337 error "$tdir/d/subdir should be GID $RUNAS_GID"
338 if [[ $MDSCOUNT -gt 1 ]]; then
339 # check remote dir sgid inherite
340 $LFS mkdir -i 0 $DIR/$tdir.local ||
341 error "mkdir $tdir.local failed"
342 chmod g+s $DIR/$tdir.local ||
343 error "chmod $tdir.local failed"
344 chgrp $RUNAS_GID $DIR/$tdir.local ||
345 error "chgrp $tdir.local failed"
346 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
347 error "mkdir $tdir.remote failed"
348 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
349 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
350 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
351 error "$tdir.remote should be mode 02755"
354 run_test 6g "verify new dir in sgid dir inherits group"
356 test_6h() { # bug 7331
357 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
359 touch $DIR/$tfile || error "touch failed"
360 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
361 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
362 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
363 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
364 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
366 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
369 test_mkdir $DIR/$tdir
370 $MCREATE $DIR/$tdir/$tfile
371 chmod 0666 $DIR/$tdir/$tfile
372 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
373 error "$tdir/$tfile should be mode 0666"
375 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
378 if [ ! -d $DIR/$tdir ]; then
379 test_mkdir $DIR/$tdir
381 $MCREATE $DIR/$tdir/$tfile
382 echo -n foo > $DIR/$tdir/$tfile
383 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
384 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
386 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
389 test_mkdir $DIR/$tdir
390 touch $DIR/$tdir/$tfile
391 chmod 0666 $DIR/$tdir/$tfile
392 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
393 error "$tfile mode not 0666"
395 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
398 test_mkdir $DIR/$tdir
399 test_mkdir $DIR/$tdir/d2
400 test_mkdir $DIR/$tdir/d2/d3
401 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
403 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
406 test_mkdir $DIR/$tdir
407 test_mkdir $DIR/$tdir/d2
408 touch $DIR/$tdir/d2/$tfile
409 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
410 error "$tdir/d2/$tfile not a file"
412 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
415 test_mkdir $DIR/$tdir
416 test_mkdir $DIR/$tdir/d2
417 chmod 0666 $DIR/$tdir/d2
418 chmod 0705 $DIR/$tdir/d2
419 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
420 error "$tdir/d2 mode not 0705"
422 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
425 test_mkdir $DIR/$tdir
426 touch $DIR/$tdir/$tfile
427 chmod 0666 $DIR/$tdir/$tfile
428 chmod 0654 $DIR/$tdir/$tfile
429 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
430 error "$tdir/d2 mode not 0654"
432 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
435 test_mkdir $DIR/$tdir
436 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
438 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
439 error "$tdir/$tfile size not 0 after truncate"
441 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
444 test_mkdir $DIR/$tdir
445 touch $DIR/$tdir/$tfile
447 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
449 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
452 test_mkdir $DIR/$tdir
453 touch $DIR/$tdir/$tfile
454 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
455 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
456 error "$tdir/${tfile_2} not a file after rename"
457 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
459 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
462 test_mkdir $DIR/$tdir
463 touch $DIR/$tdir/$tfile
464 rm -rf $DIR/$tdir/$tfile
465 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
467 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
470 test_mkdir $DIR/$tdir
471 touch $DIR/$tdir/$tfile
472 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
474 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
475 error "$tdir/l-exist not a symlink"
476 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
477 error "$tdir/l-exist not referencing a file"
478 rm -f $DIR/$tdir/l-exist
479 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
481 run_test 17a "symlinks: create, remove (real)"
484 test_mkdir $DIR/$tdir
485 ln -s no-such-file $DIR/$tdir/l-dangle
487 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
488 error "$tdir/l-dangle not referencing no-such-file"
489 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
490 error "$tdir/l-dangle not referencing non-existent file"
491 rm -f $DIR/$tdir/l-dangle
492 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
494 run_test 17b "symlinks: create, remove (dangling)"
496 test_17c() { # bug 3440 - don't save failed open RPC for replay
497 test_mkdir $DIR/$tdir
498 ln -s foo $DIR/$tdir/$tfile
499 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
501 run_test 17c "symlinks: open dangling (should return error)"
504 test_mkdir $DIR/$tdir
505 ln -s foo $DIR/$tdir/$tfile
506 touch $DIR/$tdir/$tfile || error "creating to new symlink"
508 run_test 17d "symlinks: create dangling"
511 test_mkdir $DIR/$tdir
512 local foo=$DIR/$tdir/$tfile
513 ln -s $foo $foo || error "create symlink failed"
514 ls -l $foo || error "ls -l failed"
515 ls $foo && error "ls not failed" || true
517 run_test 17e "symlinks: create recursive symlink (should return error)"
520 test_mkdir $DIR/$tdir
521 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
522 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
523 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
524 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
525 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
526 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
529 run_test 17f "symlinks: long and very long symlink name"
531 # str_repeat(S, N) generate a string that is string S repeated N times
536 while [ $((n -= 1)) -ge 0 ]; do
542 # Long symlinks and LU-2241
544 test_mkdir $DIR/$tdir
545 local TESTS="59 60 61 4094 4095"
547 # Fix for inode size boundary in 2.1.4
548 [ $MDS1_VERSION -lt $(version_code 2.1.4) ] &&
551 # Patch not applied to 2.2 or 2.3 branches
552 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
553 [ $MDS1_VERSION -le $(version_code 2.3.55) ] &&
556 # skip long symlink name for rhel6.5.
557 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
558 grep -q '6.5' /etc/redhat-release &>/dev/null &&
559 TESTS="59 60 61 4062 4063"
562 local SYMNAME=$(str_repeat 'x' $i)
563 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
564 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
567 run_test 17g "symlinks: really long symlink name and inode boundaries"
569 test_17h() { #bug 17378
570 [ $PARALLEL == "yes" ] && skip "skip parallel run"
571 remote_mds_nodsh && skip "remote MDS with nodsh"
575 test_mkdir $DIR/$tdir
576 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
577 $LFS setstripe -c -1 $DIR/$tdir
578 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
579 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
580 touch $DIR/$tdir/$tfile || true
582 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
584 test_17i() { #bug 20018
585 [ $PARALLEL == "yes" ] && skip "skip parallel run"
586 remote_mds_nodsh && skip "remote MDS with nodsh"
588 local foo=$DIR/$tdir/$tfile
591 test_mkdir -c1 $DIR/$tdir
592 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
593 ln -s $foo $foo || error "create symlink failed"
594 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
595 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
596 ls -l $foo && error "error not detected"
599 run_test 17i "don't panic on short symlink (should return error)"
601 test_17k() { #bug 22301
602 [ $PARALLEL == "yes" ] && skip "skip parallel run"
603 [[ -z "$(which rsync 2>/dev/null)" ]] &&
604 skip "no rsync command"
605 rsync --help | grep -q xattr ||
606 skip_env "$(rsync --version | head -n1) does not support xattrs"
607 test_mkdir $DIR/$tdir
608 test_mkdir $DIR/$tdir.new
609 touch $DIR/$tdir/$tfile
610 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
611 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
612 error "rsync failed with xattrs enabled"
614 run_test 17k "symlinks: rsync with xattrs enabled"
616 test_17l() { # LU-279
617 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
618 skip "no getfattr command"
620 test_mkdir $DIR/$tdir
621 touch $DIR/$tdir/$tfile
622 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
623 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
624 # -h to not follow symlinks. -m '' to list all the xattrs.
625 # grep to remove first line: '# file: $path'.
626 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
628 lgetxattr_size_check $path $xattr ||
629 error "lgetxattr_size_check $path $xattr failed"
633 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
637 [ $PARALLEL == "yes" ] && skip "skip parallel run"
638 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
639 remote_mds_nodsh && skip "remote MDS with nodsh"
640 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
641 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
642 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
644 local short_sym="0123456789"
645 local wdir=$DIR/$tdir
650 # create a long symlink file
651 for ((i = 0; i < 4; ++i)); do
652 long_sym=${long_sym}${long_sym}
655 echo "create 512 short and long symlink files under $wdir"
656 for ((i = 0; i < 256; ++i)); do
657 ln -sf ${long_sym}"a5a5" $wdir/long-$i
658 ln -sf ${short_sym}"a5a5" $wdir/short-$i
664 wait_delete_completed
666 echo "recreate the 512 symlink files with a shorter string"
667 for ((i = 0; i < 512; ++i)); do
668 # rewrite the symlink file with a shorter string
669 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
670 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
673 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
674 local devname=$(mdsdevname $mds_index)
676 echo "stop and checking mds${mds_index}:"
677 # e2fsck should not return error
679 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
682 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
683 error "start mds${mds_index} failed"
684 df $MOUNT > /dev/null 2>&1
686 error "e2fsck detected error for short/long symlink: rc=$rc"
689 run_test 17m "run e2fsck against MDT which contains short/long symlink"
691 check_fs_consistency_17n() {
695 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
696 # so it only check MDT1/MDT2 instead of all of MDTs.
697 for mdt_index in 1 2; do
698 local devname=$(mdsdevname $mdt_index)
699 # e2fsck should not return error
701 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
704 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
705 error "mount mds$mdt_index failed"
706 df $MOUNT > /dev/null 2>&1
712 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
713 [ $PARALLEL == "yes" ] && skip "skip parallel run"
714 [ "$mds1_FSTYPE" != "ldiskfs" ] && skip_env "ldiskfs only test"
715 remote_mds_nodsh && skip "remote MDS with nodsh"
716 [ $MDS1_VERSION -ge $(version_code 2.2.0) ] &&
717 [ $MDS1_VERSION -le $(version_code 2.2.93) ] &&
718 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
722 test_mkdir $DIR/$tdir
723 for ((i=0; i<10; i++)); do
724 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
725 error "create remote dir error $i"
726 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
727 error "create files under remote dir failed $i"
730 check_fs_consistency_17n ||
731 error "e2fsck report error after create files under remote dir"
733 for ((i = 0; i < 10; i++)); do
734 rm -rf $DIR/$tdir/remote_dir_${i} ||
735 error "destroy remote dir error $i"
738 check_fs_consistency_17n ||
739 error "e2fsck report error after unlink files under remote dir"
741 [ $MDS1_VERSION -lt $(version_code 2.4.50) ] &&
742 skip "lustre < 2.4.50 does not support migrate mv"
744 for ((i = 0; i < 10; i++)); do
745 mkdir -p $DIR/$tdir/remote_dir_${i}
746 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
747 error "create files under remote dir failed $i"
748 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
749 error "migrate remote dir error $i"
751 check_fs_consistency_17n || error "e2fsck report error after migration"
753 for ((i = 0; i < 10; i++)); do
754 rm -rf $DIR/$tdir/remote_dir_${i} ||
755 error "destroy remote dir error $i"
758 check_fs_consistency_17n || error "e2fsck report error after unlink"
760 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
763 remote_mds_nodsh && skip "remote MDS with nodsh"
764 [ $MDS1_VERSION -lt $(version_code 2.3.64) ] &&
765 skip "Need MDS version at least 2.3.64"
767 local wdir=$DIR/${tdir}o
773 mdt_index=$($LFS getstripe -m $wdir/$tfile)
774 mdt_index=$((mdt_index + 1))
777 #fail mds will wait the failover finish then set
778 #following fail_loc to avoid interfer the recovery process.
781 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
782 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
783 ls -l $wdir/$tfile && rc=1
784 do_facet mds${mdt_index} lctl set_param fail_loc=0
785 [[ $rc -eq 0 ]] || error "stat file should fail"
787 run_test 17o "stat file with incompat LMA feature"
790 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
791 ls $DIR || error "Failed to ls $DIR: $?"
793 run_test 18 "touch .../f ; ls ... =============================="
799 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
801 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
804 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
806 run_test 19b "ls -l .../f19 (should return error) =============="
809 [ $RUNAS_ID -eq $UID ] &&
810 skip_env "RUNAS_ID = UID = $UID -- skipping"
812 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
814 run_test 19c "$RUNAS touch .../f19 (should return error) =="
817 cat $DIR/f19 && error || true
819 run_test 19d "cat .../f19 (should return error) =============="
828 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
830 run_test 20 "touch .../f ; ls -l ..."
833 test_mkdir $DIR/$tdir
834 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
835 ln -s dangle $DIR/$tdir/link
836 echo foo >> $DIR/$tdir/link
837 cat $DIR/$tdir/dangle
838 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
839 $CHECKSTAT -f -t file $DIR/$tdir/link ||
840 error "$tdir/link not linked to a file"
842 run_test 21 "write to dangling link"
845 local wdir=$DIR/$tdir
847 chown $RUNAS_ID:$RUNAS_GID $wdir
848 (cd $wdir || error "cd $wdir failed";
849 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
851 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
852 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
853 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
854 error "checkstat -u failed"
856 run_test 22 "unpack tar archive as non-root user"
860 test_mkdir $DIR/$tdir
861 local file=$DIR/$tdir/$tfile
863 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
864 openfile -f O_CREAT:O_EXCL $file &&
865 error "$file recreate succeeded" || true
867 run_test 23a "O_CREAT|O_EXCL in subdir"
869 test_23b() { # bug 18988
870 test_mkdir $DIR/$tdir
871 local file=$DIR/$tdir/$tfile
874 echo foo > $file || error "write filed"
875 echo bar >> $file || error "append filed"
876 $CHECKSTAT -s 8 $file || error "wrong size"
879 run_test 23b "O_APPEND check"
881 # LU-9409, size with O_APPEND and tiny writes
883 local file=$DIR/$tfile
886 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
887 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
891 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
894 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
897 #racing tiny & normal writes
898 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
899 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
901 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
904 #racing tiny & normal writes 2, ugly numbers
905 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
906 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
908 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
911 run_test 23c "O_APPEND size checks for tiny writes"
913 # LU-11069 file offset is correct after appending writes
915 local file=$DIR/$tfile
918 echo CentaurHauls > $file
919 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
920 if ((offset != 26)); then
921 error "wrong offset, expected 26, got '$offset'"
924 run_test 23d "file offset is correct after appending writes"
928 echo '-- same directory rename'
929 test_mkdir $DIR/$tdir
930 touch $DIR/$tdir/$tfile.1
931 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
932 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
934 run_test 24a "rename file to non-existent target"
937 test_mkdir $DIR/$tdir
938 touch $DIR/$tdir/$tfile.{1,2}
939 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
940 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
941 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
943 run_test 24b "rename file to existing target"
946 test_mkdir $DIR/$tdir
947 test_mkdir $DIR/$tdir/d$testnum.1
948 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
949 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
950 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
952 run_test 24c "rename directory to non-existent target"
955 test_mkdir -c1 $DIR/$tdir
956 test_mkdir -c1 $DIR/$tdir/d$testnum.1
957 test_mkdir -c1 $DIR/$tdir/d$testnum.2
958 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
959 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
960 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
962 run_test 24d "rename directory to existing target"
965 echo '-- cross directory renames --'
969 mv $DIR/R5a/f $DIR/R5b/g
970 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
971 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
973 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
978 touch $DIR/R6a/f $DIR/R6b/g
979 mv $DIR/R6a/f $DIR/R6b/g
980 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
981 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
983 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
988 test_mkdir $DIR/R7a/d
989 mv $DIR/R7a/d $DIR/R7b/e
990 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
991 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
993 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
996 test_mkdir -c1 $DIR/R8a
997 test_mkdir -c1 $DIR/R8b
998 test_mkdir -c1 $DIR/R8a/d
999 test_mkdir -c1 $DIR/R8b/e
1000 mrename $DIR/R8a/d $DIR/R8b/e
1001 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1002 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1004 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1007 echo "-- rename error cases"
1009 test_mkdir $DIR/R9/a
1011 mrename $DIR/R9/f $DIR/R9/a
1012 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1013 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1014 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1016 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1020 mrename $DIR/R10/f $DIR/R10/g
1021 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1022 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1023 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1025 run_test 24j "source does not exist ============================"
1028 test_mkdir $DIR/R11a
1029 test_mkdir $DIR/R11a/d
1031 mv $DIR/R11a/f $DIR/R11a/d
1032 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1033 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1035 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1037 # bug 2429 - rename foo foo foo creates invalid file
1040 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1042 run_test 24l "Renaming a file to itself ========================"
1046 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1047 # on ext3 this does not remove either the source or target files
1048 # though the "expected" operation would be to remove the source
1049 $CHECKSTAT -t file ${f} || error "${f} missing"
1050 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1052 run_test 24m "Renaming a file to a hard link to itself ========="
1056 # this stats the old file after it was renamed, so it should fail
1058 $CHECKSTAT ${f} || error "${f} missing"
1060 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1061 $CHECKSTAT -a ${f} || error "${f} exists"
1063 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1066 test_mkdir $DIR/$tdir
1067 rename_many -s random -v -n 10 $DIR/$tdir
1069 run_test 24o "rename of files during htree split"
1072 test_mkdir $DIR/R12a
1073 test_mkdir $DIR/R12b
1074 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1075 mrename $DIR/R12a $DIR/R12b
1076 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1077 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1078 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1079 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1081 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1083 cleanup_multiop_pause() {
1085 kill -USR1 $MULTIPID
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1091 test_mkdir $DIR/R13a
1092 test_mkdir $DIR/R13b
1093 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1094 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1097 trap cleanup_multiop_pause EXIT
1098 mrename $DIR/R13a $DIR/R13b
1099 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1100 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1101 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1102 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1103 cleanup_multiop_pause
1104 wait $MULTIPID || error "multiop close failed"
1106 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1108 test_24r() { #bug 3789
1109 test_mkdir $DIR/R14a
1110 test_mkdir $DIR/R14a/b
1111 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1112 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1113 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1115 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1118 test_mkdir $DIR/R15a
1119 test_mkdir $DIR/R15a/b
1120 test_mkdir $DIR/R15a/b/c
1121 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1122 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1123 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1125 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1127 test_mkdir $DIR/R16a
1128 test_mkdir $DIR/R16a/b
1129 test_mkdir $DIR/R16a/b/c
1130 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1131 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1132 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1134 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1136 test_24u() { # bug12192
1137 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1138 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1140 run_test 24u "create stripe file"
1142 simple_cleanup_common() {
1145 [ -z "$DIR" -o -z "$tdir" ] && return 0
1147 local start=$SECONDS
1150 wait_delete_completed
1151 echo "cleanup time $((SECONDS - start))"
1155 max_pages_per_rpc() {
1156 local mdtname="$(printf "MDT%04x" ${1:-0})"
1157 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1161 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1163 local nrfiles=${COUNT:-100000}
1164 local fname="$DIR/$tdir/$tfile"
1166 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1167 [ "$mds1_FSTYPE" = "zfs" ] && nrfiles=${COUNT:-10000}
1169 test_mkdir "$(dirname $fname)"
1170 # assume MDT0000 has the fewest inodes
1171 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1172 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1173 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1175 trap simple_cleanup_common EXIT
1177 createmany -m "$fname" $nrfiles
1179 cancel_lru_locks mdc
1180 lctl set_param mdc.*.stats clear
1182 # was previously test_24D: LU-6101
1183 # readdir() returns correct number of entries after cursor reload
1184 local num_ls=$(ls $DIR/$tdir | wc -l)
1185 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1186 local num_all=$(ls -a $DIR/$tdir | wc -l)
1187 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1188 $num_all -ne $((nrfiles + 2)) ]; then
1189 error "Expected $nrfiles files, got $num_ls " \
1190 "($num_uniq unique $num_all .&..)"
1192 # LU-5 large readdir
1193 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1194 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1195 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1196 # take into account of overhead in lu_dirpage header and end mark in
1197 # each page, plus one in rpc_num calculation.
1198 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1199 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1200 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1201 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1202 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1203 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1204 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1205 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1206 error "large readdir doesn't take effect: " \
1207 "$mds_readpage should be about $rpc_max"
1209 simple_cleanup_common
1211 run_test 24v "list large directory (test hash collision, b=17560)"
1213 test_24w() { # bug21506
1215 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1216 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1217 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1218 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1219 [[ "$SZ1" -eq "$SZ2" ]] ||
1220 error "Error reading at the end of the file $tfile"
1222 run_test 24w "Reading a file larger than 4Gb"
1225 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1226 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1227 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1228 skip "Need MDS version at least 2.7.56"
1231 local remote_dir=$DIR/$tdir/remote_dir
1233 test_mkdir $DIR/$tdir
1234 $LFS mkdir -i $MDTIDX $remote_dir ||
1235 error "create remote directory failed"
1237 test_mkdir $DIR/$tdir/src_dir
1238 touch $DIR/$tdir/src_file
1239 test_mkdir $remote_dir/tgt_dir
1240 touch $remote_dir/tgt_file
1242 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1243 error "rename dir cross MDT failed!"
1245 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1246 error "rename file cross MDT failed!"
1248 touch $DIR/$tdir/ln_file
1249 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1250 error "ln file cross MDT failed"
1252 rm -rf $DIR/$tdir || error "Can not delete directories"
1254 run_test 24x "cross MDT rename/link"
1257 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1258 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1260 local remote_dir=$DIR/$tdir/remote_dir
1263 test_mkdir $DIR/$tdir
1264 $LFS mkdir -i $mdtidx $remote_dir ||
1265 error "create remote directory failed"
1267 test_mkdir $remote_dir/src_dir
1268 touch $remote_dir/src_file
1269 test_mkdir $remote_dir/tgt_dir
1270 touch $remote_dir/tgt_file
1272 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1273 error "rename subdir in the same remote dir failed!"
1275 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1276 error "rename files in the same remote dir failed!"
1278 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1279 error "link files in the same remote dir failed!"
1281 rm -rf $DIR/$tdir || error "Can not delete directories"
1283 run_test 24y "rename/link on the same dir should succeed"
1285 test_24A() { # LU-3182
1289 test_mkdir $DIR/$tdir
1290 trap simple_cleanup_common EXIT
1291 createmany -m $DIR/$tdir/$tfile $NFILES
1292 local t=$(ls $DIR/$tdir | wc -l)
1293 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1294 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1295 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1296 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1299 simple_cleanup_common || error "Can not delete directories"
1301 run_test 24A "readdir() returns correct number of entries."
1303 test_24B() { # LU-4805
1304 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1308 test_mkdir $DIR/$tdir
1309 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1310 error "create striped dir failed"
1312 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1313 [ $count -eq 2 ] || error "Expected 2, got $count"
1315 touch $DIR/$tdir/striped_dir/a
1317 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1318 [ $count -eq 3 ] || error "Expected 3, got $count"
1320 touch $DIR/$tdir/striped_dir/.f
1322 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1323 [ $count -eq 4 ] || error "Expected 4, got $count"
1325 rm -rf $DIR/$tdir || error "Can not delete directories"
1327 run_test 24B "readdir for striped dir return correct number of entries"
1330 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1336 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1337 error "create striped dir failed"
1339 cd $DIR/$tdir/d0/striped_dir
1341 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1342 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1343 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1345 [ "$d0_ino" = "$parent_ino" ] ||
1346 error ".. wrong, expect $d0_ino, get $parent_ino"
1348 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1349 error "mv striped dir failed"
1351 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1353 [ "$d1_ino" = "$parent_ino" ] ||
1354 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1356 run_test 24C "check .. in striped dir"
1359 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1360 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1363 mkdir $DIR/$tdir/src_dir
1364 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1365 error "create remote source failed"
1367 touch $DIR/$tdir/src_dir/src_child/a
1369 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1370 error "create remote target dir failed"
1372 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1373 error "create remote target child failed"
1375 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1376 error "rename dir cross MDT failed!"
1380 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1381 error "src_child still exists after rename"
1383 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1384 error "missing file(a) after rename"
1386 rm -rf $DIR/$tdir || error "Can not delete directories"
1388 run_test 24E "cross MDT rename/link"
1391 echo '== symlink sanity ============================================='
1395 touch $DIR/s25/foo ||
1396 error "File creation in symlinked directory failed"
1398 run_test 25a "create file in symlinked directory ==============="
1401 [ ! -d $DIR/d25 ] && test_25a
1402 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1404 run_test 25b "lookup file in symlinked directory ==============="
1408 test_mkdir $DIR/d26/d26-2
1409 ln -s d26/d26-2 $DIR/s26
1410 touch $DIR/s26/foo || error "File creation failed"
1412 run_test 26a "multiple component symlink ======================="
1415 test_mkdir -p $DIR/$tdir/d26-2
1416 ln -s $tdir/d26-2/foo $DIR/s26-2
1417 touch $DIR/s26-2 || error "File creation failed"
1419 run_test 26b "multiple component symlink at end of lookup ======"
1422 test_mkdir $DIR/d26.2
1423 touch $DIR/d26.2/foo
1424 ln -s d26.2 $DIR/s26.2-1
1425 ln -s s26.2-1 $DIR/s26.2-2
1426 ln -s s26.2-2 $DIR/s26.2-3
1427 chmod 0666 $DIR/s26.2-3/foo
1429 run_test 26c "chain of symlinks"
1431 # recursive symlinks (bug 439)
1433 ln -s d26-3/foo $DIR/d26-3
1435 run_test 26d "create multiple component recursive symlink"
1438 [ ! -h $DIR/d26-3 ] && test_26d
1441 run_test 26e "unlink multiple component recursive symlink"
1443 # recursive symlinks (bug 7022)
1445 test_mkdir $DIR/$tdir
1446 test_mkdir $DIR/$tdir/$tfile
1447 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1448 test_mkdir -p lndir/bar1
1449 test_mkdir $DIR/$tdir/$tfile/$tfile
1450 cd $tfile || error "cd $tfile failed"
1451 ln -s .. dotdot || error "ln dotdot failed"
1452 ln -s dotdot/lndir lndir || error "ln lndir failed"
1453 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1454 output=`ls $tfile/$tfile/lndir/bar1`
1455 [ "$output" = bar1 ] && error "unexpected output"
1456 rm -r $tfile || error "rm $tfile failed"
1457 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1459 run_test 26f "rm -r of a directory which has recursive symlink"
1462 test_mkdir $DIR/$tdir
1463 $LFS getstripe $DIR/$tdir
1464 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1465 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1466 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1468 run_test 27a "one stripe file"
1471 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1473 test_mkdir $DIR/$tdir
1474 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1475 $LFS getstripe -c $DIR/$tdir/$tfile
1476 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1477 error "two-stripe file doesn't have two stripes"
1479 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1481 run_test 27b "create and write to two stripe file"
1484 test_mkdir $DIR/$tdir
1485 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1486 error "setstripe failed"
1487 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1488 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1490 run_test 27d "create file with default settings"
1493 # LU-5839 adds check for existed layout before setting it
1494 [[ $MDS1_VERSION -lt $(version_code 2.7.56) ]] &&
1495 skip "Need MDS version at least 2.7.56"
1497 test_mkdir $DIR/$tdir
1498 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1499 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1500 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1502 run_test 27e "setstripe existing file (should return error)"
1505 test_mkdir $DIR/$tdir
1506 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1507 error "$LFS setstripe $DIR/$tdir/$tfile failed"
1508 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1509 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1510 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1511 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1513 run_test 27f "setstripe with bad stripe size (should return error)"
1516 test_mkdir $DIR/$tdir
1517 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1518 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1519 error "$DIR/$tdir/$tfile has object"
1521 run_test 27g "$LFS getstripe with no objects"
1524 test_mkdir $DIR/$tdir
1525 touch $DIR/$tdir/$tfile || error "touch failed"
1526 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1527 error "missing objects"
1529 run_test 27i "$LFS getstripe with some objects"
1532 test_mkdir $DIR/$tdir
1533 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1534 error "setstripe failed" || true
1536 run_test 27j "setstripe with bad stripe offset (should return error)"
1538 test_27k() { # bug 2844
1539 test_mkdir $DIR/$tdir
1540 local file=$DIR/$tdir/$tfile
1541 local ll_max_blksize=$((4 * 1024 * 1024))
1542 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1543 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1544 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1545 dd if=/dev/zero of=$file bs=4k count=1
1546 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1547 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1549 run_test 27k "limit i_blksize for broken user apps"
1552 mcreate $DIR/$tfile || error "creating file"
1553 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1554 error "setstripe should have failed" || true
1556 run_test 27l "check setstripe permissions (should return error)"
1559 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1561 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1563 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1564 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1566 trap simple_cleanup_common EXIT
1567 test_mkdir $DIR/$tdir
1568 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1569 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1570 error "dd should fill OST0"
1572 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1574 [ $i -gt 256 ] && break
1577 touch $DIR/$tdir/$tfile.$i
1578 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1579 awk '{print $1}'| grep -w "0") ] &&
1580 error "OST0 was full but new created file still use it"
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"
1586 simple_cleanup_common
1588 run_test 27m "create file while OST0 was full"
1591 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1592 awk '{ print $1 * 2; exit; }')
1596 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1597 # if the OST isn't full anymore.
1599 local OSTIDX=${1:-""}
1601 local list=$(comma_list $(osts_nodes))
1602 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1604 do_nodes $list lctl set_param fail_loc=0
1605 sync # initiate all OST_DESTROYs from MDS to OST
1609 exhaust_precreations() {
1612 local FAILIDX=${3:-$OSTIDX}
1613 local ofacet=ost$((OSTIDX + 1))
1615 test_mkdir -p -c1 $DIR/$tdir
1616 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1617 local mfacet=mds$((mdtidx + 1))
1618 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1620 local OST=$(ostname_from_index $OSTIDX)
1623 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1624 local last_id=$(do_facet $mfacet lctl get_param -n \
1625 osc.$mdtosc_proc1.prealloc_last_id)
1626 local next_id=$(do_facet $mfacet lctl get_param -n \
1627 osc.$mdtosc_proc1.prealloc_next_id)
1629 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1630 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1632 test_mkdir -p $DIR/$tdir/${OST}
1633 $LFS setstripe -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1634 #define OBD_FAIL_OST_ENOSPC 0x215
1635 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1636 echo "Creating to objid $last_id on ost $OST..."
1637 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1638 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1639 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1643 exhaust_all_precreations() {
1645 for (( i=0; i < OSTCOUNT; i++ )) ; do
1646 exhaust_precreations $i $1 -1
1651 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1652 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1653 remote_mds_nodsh && skip "remote MDS with nodsh"
1654 remote_ost_nodsh && skip "remote OST with nodsh"
1657 rm -f $DIR/$tdir/$tfile
1658 exhaust_precreations 0 0x80000215
1659 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1660 touch $DIR/$tdir/$tfile || error "touch failed"
1661 $LFS getstripe $DIR/$tdir/$tfile
1664 run_test 27n "create file with some full OSTs"
1667 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1668 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1669 remote_mds_nodsh && skip "remote MDS with nodsh"
1670 remote_ost_nodsh && skip "remote OST with nodsh"
1673 rm -f $DIR/$tdir/$tfile
1674 exhaust_all_precreations 0x215
1676 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1681 run_test 27o "create file with all full OSTs (should error)"
1684 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1685 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1686 remote_mds_nodsh && skip "remote MDS with nodsh"
1687 remote_ost_nodsh && skip "remote OST with nodsh"
1690 rm -f $DIR/$tdir/$tfile
1691 test_mkdir $DIR/$tdir
1693 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1694 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1695 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1697 exhaust_precreations 0 0x80000215
1698 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1699 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1700 $LFS getstripe $DIR/$tdir/$tfile
1704 run_test 27p "append to a truncated file with some full OSTs"
1707 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1708 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1709 remote_mds_nodsh && skip "remote MDS with nodsh"
1710 remote_ost_nodsh && skip "remote OST with nodsh"
1713 rm -f $DIR/$tdir/$tfile
1715 test_mkdir $DIR/$tdir
1716 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1717 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1718 error "truncate $DIR/$tdir/$tfile failed"
1719 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1721 exhaust_all_precreations 0x215
1723 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1724 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1728 run_test 27q "append to truncated file with all OSTs full (should error)"
1731 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1733 remote_mds_nodsh && skip "remote MDS with nodsh"
1734 remote_ost_nodsh && skip "remote OST with nodsh"
1737 rm -f $DIR/$tdir/$tfile
1738 exhaust_precreations 0 0x80000215
1740 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1744 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1746 test_27s() { # bug 10725
1747 test_mkdir $DIR/$tdir
1748 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1749 local stripe_count=0
1750 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1751 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1752 error "stripe width >= 2^32 succeeded" || true
1755 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1757 test_27t() { # bug 10864
1762 $WLFS getstripe $tfile
1765 run_test 27t "check that utils parse path correctly"
1767 test_27u() { # bug 4900
1768 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1769 remote_mds_nodsh && skip "remote MDS with nodsh"
1772 local list=$(comma_list $(mdts_nodes))
1774 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1775 do_nodes $list $LCTL set_param fail_loc=0x139
1776 test_mkdir -p $DIR/$tdir
1777 trap simple_cleanup_common EXIT
1778 createmany -o $DIR/$tdir/t- 1000
1779 do_nodes $list $LCTL set_param fail_loc=0
1781 TLOG=$TMP/$tfile.getstripe
1782 $LFS getstripe $DIR/$tdir > $TLOG
1783 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1784 unlinkmany $DIR/$tdir/t- 1000
1786 [[ $OBJS -gt 0 ]] &&
1787 error "$OBJS objects created on OST-0. See $TLOG" ||
1790 run_test 27u "skip object creation on OSC w/o objects"
1792 test_27v() { # bug 4900
1793 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1794 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1795 remote_mds_nodsh && skip "remote MDS with nodsh"
1796 remote_ost_nodsh && skip "remote OST with nodsh"
1798 exhaust_all_precreations 0x215
1801 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1803 touch $DIR/$tdir/$tfile
1804 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1806 for (( i=1; i < OSTCOUNT; i++ )); do
1807 do_facet ost$i lctl set_param fail_loc=0x705
1809 local START=`date +%s`
1810 createmany -o $DIR/$tdir/$tfile 32
1812 local FINISH=`date +%s`
1813 local TIMEOUT=`lctl get_param -n timeout`
1814 local PROCESS=$((FINISH - START))
1815 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1816 error "$FINISH - $START >= $TIMEOUT / 2"
1817 sleep $((TIMEOUT / 2 - PROCESS))
1820 run_test 27v "skip object creation on slow OST"
1822 test_27w() { # bug 10997
1823 test_mkdir $DIR/$tdir
1824 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1825 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1826 error "stripe size $size != 65536" || true
1827 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1828 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1830 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1833 [[ $OSTCOUNT -lt 2 ]] &&
1834 skip_env "skipping multiple stripe count/offset test"
1836 test_mkdir $DIR/$tdir
1837 for i in $(seq 1 $OSTCOUNT); do
1839 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1840 error "setstripe -c $i -i $offset failed"
1841 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1842 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1843 [ $count -ne $i ] && error "stripe count $count != $i" || true
1844 [ $index -ne $offset ] &&
1845 error "stripe offset $index != $offset" || true
1848 run_test 27wa "check $LFS setstripe -c -i options"
1851 remote_ost_nodsh && skip "remote OST with nodsh"
1852 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1853 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1855 OFFSET=$(($OSTCOUNT - 1))
1857 local OST=$(ostname_from_index $OSTIDX)
1859 test_mkdir $DIR/$tdir
1860 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1861 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1863 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1864 for i in $(seq 0 $OFFSET); do
1865 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1866 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1867 error "OST0 was degraded but new created file still use it"
1869 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1871 run_test 27x "create files while OST0 is degraded"
1874 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1875 remote_mds_nodsh && skip "remote MDS with nodsh"
1876 remote_ost_nodsh && skip "remote OST with nodsh"
1877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1879 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1880 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1881 osc.$mdtosc.prealloc_last_id)
1882 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1883 osc.$mdtosc.prealloc_next_id)
1884 local fcount=$((last_id - next_id))
1885 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1886 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1888 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1889 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1890 local OST_DEACTIVE_IDX=-1
1895 for OSC in $MDS_OSCS; do
1896 OST=$(osc_to_ost $OSC)
1897 OSTIDX=$(index_from_ostuuid $OST)
1898 if [ $OST_DEACTIVE_IDX == -1 ]; then
1899 OST_DEACTIVE_IDX=$OSTIDX
1901 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1902 echo $OSC "is Deactivated:"
1903 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1907 OSTIDX=$(index_from_ostuuid $OST)
1908 test_mkdir $DIR/$tdir
1909 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1911 for OSC in $MDS_OSCS; do
1912 OST=$(osc_to_ost $OSC)
1913 OSTIDX=$(index_from_ostuuid $OST)
1914 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1915 echo $OST "is degraded:"
1916 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1917 obdfilter.$OST.degraded=1
1922 createmany -o $DIR/$tdir/$tfile $fcount
1924 for OSC in $MDS_OSCS; do
1925 OST=$(osc_to_ost $OSC)
1926 OSTIDX=$(index_from_ostuuid $OST)
1927 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1928 echo $OST "is recovered from degraded:"
1929 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1930 obdfilter.$OST.degraded=0
1932 do_facet $SINGLEMDS lctl --device %$OSC activate
1936 # all osp devices get activated, hence -1 stripe count restored
1937 local stripe_count=0
1939 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1940 # devices get activated.
1942 $LFS setstripe -c -1 $DIR/$tfile
1943 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1945 [ $stripe_count -ne $OSTCOUNT ] &&
1946 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1949 run_test 27y "create files while OST0 is degraded and the rest inactive"
1955 lmm_count=$($LFS getstripe -c $1)
1956 lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
1957 lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
1959 local old_ifs="$IFS"
1961 fid=($($LFS path2fid $1))
1964 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1965 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1967 # compare lmm_seq and lu_fid->f_seq
1968 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1969 # compare lmm_object_id and lu_fid->oid
1970 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1972 # check the trusted.fid attribute of the OST objects of the file
1973 local have_obdidx=false
1975 $LFS getstripe $1 | while read obdidx oid hex seq; do
1976 # skip lines up to and including "obdidx"
1977 [ -z "$obdidx" ] && break
1978 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1979 $have_obdidx || continue
1981 local ost=$((obdidx + 1))
1982 local dev=$(ostdevname $ost)
1985 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1987 seq=$(echo $seq | sed -e "s/^0x//g")
1988 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1989 oid_hex=$(echo $oid)
1991 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1993 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1997 # Don't unmount/remount the OSTs if we don't need to do that.
1998 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1999 # update too, until that use mount/ll_decode_filter_fid/mount.
2000 # Re-enable when debugfs will understand new filter_fid.
2002 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2003 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2004 $dev 2>/dev/null" | grep "parent=")
2006 if [ -z "$ff" ]; then
2008 mount_fstype ost$ost
2009 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2010 $(facet_mntpt ost$ost)/$obj_file)
2011 unmount_fstype ost$ost
2012 start ost$ost $dev $OST_MOUNT_OPTS
2016 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2018 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2020 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2021 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2023 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2024 # stripe_size=1048576 component_id=1 component_start=0 \
2025 # component_end=33554432
2026 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2027 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2028 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2030 if grep -q 'stripe=' <<<$ff; then
2031 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2033 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2034 # into f_ver in this case. See comment on ff_parent.
2035 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2038 # compare lmm_seq and filter_fid->ff_parent.f_seq
2039 [ $ff_pseq = $lmm_seq ] ||
2040 error "FF parent SEQ $ff_pseq != $lmm_seq"
2041 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2042 [ $ff_poid = $lmm_oid ] ||
2043 error "FF parent OID $ff_poid != $lmm_oid"
2044 (($ff_pstripe == $stripe_nr)) ||
2045 error "FF stripe $ff_pstripe != $stripe_nr"
2047 stripe_nr=$((stripe_nr + 1))
2048 [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2050 if grep -q 'stripe_count=' <<<$ff; then
2051 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2052 -e 's/ .*//' <<<$ff)
2053 [ $lmm_count = $ff_scnt ] ||
2054 error "FF stripe count $lmm_count != $ff_scnt"
2060 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2061 remote_ost_nodsh && skip "remote OST with nodsh"
2063 test_mkdir $DIR/$tdir
2064 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2065 { error "setstripe -c -1 failed"; return 1; }
2066 # We need to send a write to every object to get parent FID info set.
2067 # This _should_ also work for setattr, but does not currently.
2068 # touch $DIR/$tdir/$tfile-1 ||
2069 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2070 { error "dd $tfile-1 failed"; return 2; }
2071 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2072 { error "setstripe -c -1 failed"; return 3; }
2073 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2074 { error "dd $tfile-2 failed"; return 4; }
2076 # make sure write RPCs have been sent to OSTs
2079 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2080 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2082 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2084 test_27A() { # b=19102
2085 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2087 save_layout_restore_at_exit $MOUNT
2088 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2089 wait_update $HOSTNAME "$LFS getstripe -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2090 error "stripe count $($LFS getstripe -c $MOUNT) != 1"
2091 local default_size=$($LFS getstripe -S $MOUNT)
2092 local default_offset=$($LFS getstripe -i $MOUNT)
2093 local dsize=$(do_facet $SINGLEMDS \
2094 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2095 [ $default_size -eq $dsize ] ||
2096 error "stripe size $default_size != $dsize"
2097 [ $default_offset -eq -1 ] ||
2098 error "stripe offset $default_offset != -1"
2100 run_test 27A "check filesystem-wide default LOV EA values"
2102 test_27B() { # LU-2523
2103 test_mkdir $DIR/$tdir
2104 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2106 # open f1 with O_LOV_DELAY_CREATE
2108 # call setstripe ioctl on open file descriptor for f1
2110 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2114 # open f1 with O_LOV_DELAY_CREATE
2116 # call setstripe ioctl on open file descriptor for f1
2118 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2120 # Allow multiop to fail in imitation of NFS's busted semantics.
2123 run_test 27B "call setstripe on open unlinked file/rename victim"
2125 test_27C() { #LU-2871
2126 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2134 test_mkdir $DIR/$tdir
2136 for i in $(seq 0 $((OSTCOUNT - 1))); do
2137 # set stripe across all OSTs starting from OST$i
2138 $LFS setstripe -i $i -c -1 $tfile$i
2139 # get striping information
2140 ost_idx=($($LFS getstripe $tfile$i |
2141 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2145 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2146 error "${#ost_idx[@]} != $OSTCOUNT"
2148 for index in $(seq 0 $((OSTCOUNT - 1))); do
2150 for j in $(echo ${ost_idx[@]}); do
2151 if [ $index -eq $j ]; then
2157 error "Can not find $index in ${ost_idx[@]}"
2161 run_test 27C "check full striping across all OSTs"
2164 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2165 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2166 remote_mds_nodsh && skip "remote MDS with nodsh"
2168 local POOL=${POOL:-testpool}
2170 local last_ost=$(($OSTCOUNT - 1))
2172 local ost_list=$(seq $first_ost $ost_step $last_ost)
2173 local ost_range="$first_ost $last_ost $ost_step"
2175 if ! combined_mgs_mds ; then
2179 test_mkdir $DIR/$tdir
2180 pool_add $POOL || error "pool_add failed"
2181 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2184 [ $MDS1_VERSION -lt $(version_code 2.8.55) ] &&
2186 [ $MDS1_VERSION -lt $(version_code 2.9.55) -o \
2187 $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
2188 skip27D+=" -s 30,31"
2189 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2190 error "llapi_layout_test failed"
2192 destroy_test_pools || error "destroy test pools failed"
2194 if ! combined_mgs_mds ; then
2198 run_test 27D "validate llapi_layout API"
2200 # Verify that default_easize is increased from its initial value after
2201 # accessing a widely striped file.
2203 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2204 [ $CLIENT_VERSION -lt $(version_code 2.5.57) ] &&
2205 skip "client does not have LU-3338 fix"
2207 # 72 bytes is the minimum space required to store striping
2208 # information for a file striped across one OST:
2209 # (sizeof(struct lov_user_md_v3) +
2210 # sizeof(struct lov_user_ost_data_v1))
2212 $LCTL set_param -n llite.*.default_easize $min_easize ||
2213 error "lctl set_param failed"
2214 local easize=$($LCTL get_param -n llite.*.default_easize)
2216 [ $easize -eq $min_easize ] ||
2217 error "failed to set default_easize"
2219 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2220 error "setstripe failed"
2224 easize=$($LCTL get_param -n llite.*.default_easize)
2226 [ $easize -gt $min_easize ] ||
2227 error "default_easize not updated"
2229 run_test 27E "check that default extended attribute size properly increases"
2231 test_27F() { # LU-5346/LU-7975
2232 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2233 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2234 [[ $MDS1_VERSION -lt $(version_code 2.8.51) ]] &&
2235 skip "Need MDS version at least 2.8.51"
2236 remote_ost_nodsh && skip "remote OST with nodsh"
2238 test_mkdir $DIR/$tdir
2240 $LFS setstripe -c 2 $DIR/$tdir
2242 # stop all OSTs to reproduce situation for LU-7975 ticket
2243 for num in $(seq $OSTCOUNT); do
2247 # open/create f0 with O_LOV_DELAY_CREATE
2248 # truncate f0 to a non-0 size
2250 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2252 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2253 # open/write it again to force delayed layout creation
2254 cat /etc/hosts > $DIR/$tdir/f0 &
2258 for num in $(seq $OSTCOUNT); do
2259 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2260 error "ost$num failed to start"
2263 wait $catpid || error "cat failed"
2265 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2266 [[ $($LFS getstripe -c $DIR/$tdir/f0) == 2 ]] ||
2267 error "wrong stripecount"
2270 run_test 27F "Client resend delayed layout creation with non-zero size"
2272 test_27G() { #LU-10629
2273 [ $MDS1_VERSION -lt $(version_code 2.11.51) ] &&
2274 skip "Need MDS version at least 2.11.51"
2275 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2276 remote_mds_nodsh && skip "remote MDS with nodsh"
2277 local POOL=${POOL:-testpool}
2278 local ostrange="0 0 1"
2280 test_mkdir $DIR/$tdir
2281 pool_add $POOL || error "pool_add failed"
2282 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2283 $LFS setstripe -p $POOL $DIR/$tdir
2285 local pool=$($LFS getstripe -p $DIR/$tdir)
2287 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2289 $LFS setstripe -d $DIR/$tdir
2291 pool=$($LFS getstripe -p $DIR/$tdir)
2295 [ -z "$pool" ] || error "'$pool' is not empty"
2297 run_test 27G "Clear OST pool from stripe"
2300 [[ $MDS1_VERSION -le $(version_code 2.11.54) ]] &&
2301 skip "Need MDS version newer than 2.11.54"
2302 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2303 test_mkdir $DIR/$tdir
2304 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2305 touch $DIR/$tdir/$tfile
2306 $LFS getstripe -c $DIR/$tdir/$tfile
2307 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2308 error "two-stripe file doesn't have two stripes"
2310 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2311 $LFS getstripe -y $DIR/$tdir/$tfile
2312 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2313 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2314 error "expected l_ost_idx: [02]$ not matched"
2316 # make sure ost list has been cleared
2317 local stripesize=$($LFS getstripe -S $DIR/$tdir)
2318 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2319 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2321 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2323 run_test 27H "Set specific OSTs stripe"
2325 # createtest also checks that device nodes are created and
2326 # then visible correctly (#2091)
2327 test_28() { # bug 2091
2329 $CREATETEST $DIR/d28/ct || error "createtest failed"
2331 run_test 28 "create/mknod/mkdir with bad file types ============"
2334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2336 sync; sleep 1; sync # flush out any dirty pages from previous tests
2343 declare -i LOCKCOUNTORIG=0
2344 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2345 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2347 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2349 declare -i LOCKUNUSEDCOUNTORIG=0
2350 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2351 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2358 declare -i LOCKCOUNTCURRENT=0
2359 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2360 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2363 declare -i LOCKUNUSEDCOUNTCURRENT=0
2364 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2365 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2368 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2369 $LCTL set_param -n ldlm.dump_namespaces ""
2370 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2371 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2372 log "dumped log to $TMP/test_29.dk (bug 5793)"
2375 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2376 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2377 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2378 log "dumped log to $TMP/test_29.dk (bug 5793)"
2382 run_test 29 "IT_GETATTR regression ============================"
2384 test_30a() { # was test_30
2385 cp $(which ls) $DIR || cp /bin/ls $DIR
2386 $DIR/ls / || error "Can't execute binary from lustre"
2389 run_test 30a "execute binary from Lustre (execve) =============="
2392 cp `which ls` $DIR || cp /bin/ls $DIR
2394 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2397 run_test 30b "execute binary from Lustre as non-root ==========="
2399 test_30c() { # b=22376
2400 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2402 cp `which ls` $DIR || cp /bin/ls $DIR
2404 cancel_lru_locks mdc
2405 cancel_lru_locks osc
2406 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2409 run_test 30c "execute binary from Lustre without read perms ===="
2412 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2413 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2415 run_test 31a "open-unlink file =================================="
2418 touch $DIR/f31 || error "touch $DIR/f31 failed"
2419 ln $DIR/f31 $DIR/f31b || error "ln failed"
2420 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2421 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2423 run_test 31b "unlink file with multiple links while open ======="
2426 touch $DIR/f31 || error "touch $DIR/f31 failed"
2427 ln $DIR/f31 $DIR/f31c || error "ln failed"
2428 multiop_bg_pause $DIR/f31 O_uc ||
2429 error "multiop_bg_pause for $DIR/f31 failed"
2431 $MULTIOP $DIR/f31c Ouc
2432 kill -USR1 $MULTIPID
2435 run_test 31c "open-unlink file with multiple links ============="
2438 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2439 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2441 run_test 31d "remove of open directory ========================="
2443 test_31e() { # bug 2904
2444 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2446 run_test 31e "remove of open non-empty directory ==============="
2448 test_31f() { # bug 4554
2449 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2452 test_mkdir $DIR/d31f
2453 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2454 cp /etc/hosts $DIR/d31f
2456 $LFS getstripe $DIR/d31f/hosts
2457 multiop_bg_pause $DIR/d31f D_c || return 1
2460 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2461 test_mkdir $DIR/d31f
2462 $LFS setstripe -S 1048576 -c 1 $DIR/d31f
2463 cp /etc/hosts $DIR/d31f
2465 $LFS getstripe $DIR/d31f/hosts
2466 multiop_bg_pause $DIR/d31f D_c || return 1
2469 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2470 wait $MULTIPID || error "first opendir $MULTIPID failed"
2474 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2475 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2478 run_test 31f "remove of open directory with open-unlink file ==="
2481 echo "-- cross directory link --"
2482 test_mkdir -c1 $DIR/${tdir}ga
2483 test_mkdir -c1 $DIR/${tdir}gb
2484 touch $DIR/${tdir}ga/f
2485 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2486 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2487 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2488 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2489 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2491 run_test 31g "cross directory link==============="
2494 echo "-- cross directory link --"
2495 test_mkdir -c1 $DIR/${tdir}
2496 test_mkdir -c1 $DIR/${tdir}/dir
2497 touch $DIR/${tdir}/f
2498 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2499 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2500 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2501 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2502 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2504 run_test 31h "cross directory link under child==============="
2507 echo "-- cross directory link --"
2508 test_mkdir -c1 $DIR/$tdir
2509 test_mkdir -c1 $DIR/$tdir/dir
2510 touch $DIR/$tdir/dir/f
2511 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2512 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2513 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2514 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2515 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2517 run_test 31i "cross directory link under parent==============="
2520 test_mkdir -c1 -p $DIR/$tdir
2521 test_mkdir -c1 -p $DIR/$tdir/dir1
2522 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2523 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2524 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2525 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2528 run_test 31j "link for directory==============="
2531 test_mkdir -c1 -p $DIR/$tdir
2533 touch $DIR/$tdir/exist
2534 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2535 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2536 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2537 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2538 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2539 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2540 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2543 run_test 31k "link to file: the same, non-existing, dir==============="
2549 touch $DIR/d31m2/exist
2550 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2551 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2552 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2553 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2554 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2555 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2558 run_test 31m "link to file: the same, non-existing, dir==============="
2561 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2562 nlink=$(stat --format=%h $DIR/$tfile)
2563 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2565 local cmd="exec $fd<$DIR/$tfile"
2568 trap "eval $cmd" EXIT
2569 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2570 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2571 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2572 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2573 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2576 run_test 31n "check link count of unlinked file"
2579 local TEMPNAME=$(mktemp $1_XXXXXX)
2580 mlink $TEMPNAME $1 2> /dev/null &&
2581 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2585 test_31o() { # LU-2901
2586 test_mkdir $DIR/$tdir
2587 for LOOP in $(seq 100); do
2588 rm -f $DIR/$tdir/$tfile*
2589 for THREAD in $(seq 8); do
2590 link_one $DIR/$tdir/$tfile.$LOOP &
2593 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2594 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2595 error "$LINKS duplicate links to $tfile.$LOOP" &&
2599 run_test 31o "duplicate hard links with same filename"
2602 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2604 test_mkdir $DIR/$tdir
2605 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2606 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2608 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2609 error "open unlink test1 failed"
2610 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2611 error "open unlink test2 failed"
2613 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2614 error "test1 still exists"
2615 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2616 error "test2 still exists"
2618 run_test 31p "remove of open striped directory"
2620 cleanup_test32_mount() {
2623 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2624 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2625 losetup -d $loopdev || true
2631 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2633 echo "== more mountpoints and symlinks ================="
2634 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2635 trap cleanup_test32_mount EXIT
2636 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2637 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2638 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2639 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2640 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2641 cleanup_test32_mount
2643 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2646 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2648 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2649 trap cleanup_test32_mount EXIT
2650 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2651 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2652 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2653 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2654 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2655 cleanup_test32_mount
2657 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2660 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2662 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2663 trap cleanup_test32_mount EXIT
2664 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2665 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2666 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2667 test_mkdir -p $DIR/$tdir/d2/test_dir
2668 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2669 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2670 cleanup_test32_mount
2672 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2675 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2677 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2678 trap cleanup_test32_mount EXIT
2679 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2680 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2681 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2682 test_mkdir -p $DIR/$tdir/d2/test_dir
2683 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2684 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2685 cleanup_test32_mount
2687 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2691 test_mkdir -p $DIR/$tdir/tmp
2692 local tmp_dir=$DIR/$tdir/tmp
2693 ln -s $DIR/$tdir $tmp_dir/symlink11
2694 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2695 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2696 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2698 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2702 test_mkdir -p $DIR/$tdir/tmp
2703 local tmp_dir=$DIR/$tdir/tmp
2704 ln -s $DIR/$tdir $tmp_dir/symlink11
2705 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2706 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2707 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2709 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2712 local tmp_dir=$DIR/$tdir/tmp
2713 test_mkdir -p $tmp_dir
2714 test_mkdir $DIR/${tdir}2
2715 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2716 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2717 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2718 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2719 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2720 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2722 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2725 rm -fr $DIR/$tdir $DIR/${tdir}2
2726 tmp_dir=$DIR/$tdir/tmp
2727 test_mkdir -p $tmp_dir
2728 test_mkdir $DIR/${tdir}2
2729 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2730 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2731 ls $tmp_dir/symlink12 || error "listing symlink12"
2732 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2734 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2737 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2739 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2740 trap cleanup_test32_mount EXIT
2741 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2742 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2743 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2744 touch $DIR/$tdir/test_file
2745 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2746 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2747 cleanup_test32_mount
2749 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2752 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2754 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2755 trap cleanup_test32_mount EXIT
2756 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2757 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2758 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2759 touch $DIR/$tdir/test_file
2760 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2761 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2762 cleanup_test32_mount
2764 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2767 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2770 trap cleanup_test32_mount EXIT
2771 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2772 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2773 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2774 test_mkdir -p $DIR/$tdir/d2
2775 touch $DIR/$tdir/d2/test_file || error "touch failed"
2776 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2777 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2778 cleanup_test32_mount
2780 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2783 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2786 trap cleanup_test32_mount EXIT
2787 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2788 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2789 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2790 test_mkdir -p $DIR/$tdir/d2
2791 touch $DIR/$tdir/d2/test_file || error "touch failed"
2792 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2793 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2794 cleanup_test32_mount
2796 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2800 test_mkdir -p $DIR/d32m/tmp
2801 TMP_DIR=$DIR/d32m/tmp
2802 ln -s $DIR $TMP_DIR/symlink11
2803 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2804 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2805 error "symlink11 not a link"
2806 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2807 error "symlink01 not a link"
2809 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2813 test_mkdir -p $DIR/d32n/tmp
2814 TMP_DIR=$DIR/d32n/tmp
2815 ln -s $DIR $TMP_DIR/symlink11
2816 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2817 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2818 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2820 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2824 test_mkdir -p $DIR/d32o/tmp
2825 TMP_DIR=$DIR/d32o/tmp
2826 ln -s $DIR/$tfile $TMP_DIR/symlink12
2827 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2828 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2829 error "symlink12 not a link"
2830 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2831 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2832 error "$DIR/d32o/tmp/symlink12 not file type"
2833 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2834 error "$DIR/d32o/symlink02 not file type"
2836 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2846 test_mkdir -p $DIR/d32p/tmp
2848 TMP_DIR=$DIR/d32p/tmp
2850 ln -s $DIR/$tfile $TMP_DIR/symlink12
2852 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2854 cat $DIR/d32p/tmp/symlink12 ||
2855 error "Can't open $DIR/d32p/tmp/symlink12"
2857 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2860 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2863 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2865 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2866 trap cleanup_test32_mount EXIT
2867 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2868 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2869 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2870 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2871 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2872 cleanup_test32_mount
2874 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2877 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2879 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2880 trap cleanup_test32_mount EXIT
2881 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2882 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2883 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2884 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2885 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2886 cleanup_test32_mount
2888 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2893 chmod 444 $DIR/$tfile
2894 chown $RUNAS_ID $DIR/$tfile
2896 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2899 run_test 33aa "write file with mode 444 (should return error)"
2903 test_mkdir $DIR/$tdir
2904 chown $RUNAS_ID $DIR/$tdir
2905 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2906 error "$RUNAS create $tdir/$tfile failed"
2907 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2908 error "open RDWR" || true
2910 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2914 test_mkdir $DIR/$tdir
2915 chown $RUNAS_ID $DIR/$tdir
2916 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2918 run_test 33b "test open file with malformed flags (No panic)"
2921 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2922 remote_ost_nodsh && skip "remote OST with nodsh"
2931 test_mkdir $DIR/$tdir
2932 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2935 for ostnum in $(seq $OSTCOUNT); do
2936 # test-framework's OST numbering is one-based, while Lustre's
2938 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2939 # Parsing llobdstat's output sucks; we could grep the /proc
2940 # path, but that's likely to not be as portable as using the
2941 # llobdstat utility. So we parse lctl output instead.
2942 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2943 obdfilter/$ostname/stats |
2944 awk '/^write_bytes/ {print $7}' )
2945 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2946 if (( ${write_bytes:-0} > 0 ))
2953 $all_zeros || return 0
2956 echo foo > $DIR/$tdir/bar
2960 # Total up write_bytes after writing. We'd better find non-zeros.
2961 for ostnum in $(seq $OSTCOUNT); do
2962 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2963 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2964 obdfilter/$ostname/stats |
2965 awk '/^write_bytes/ {print $7}' )
2966 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2967 if (( ${write_bytes:-0} > 0 ))
2976 for ostnum in $(seq $OSTCOUNT); do
2977 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2978 echo "Check that write_bytes is present in obdfilter/*/stats:"
2979 do_facet ost$ostnum lctl get_param -n \
2980 obdfilter/$ostname/stats
2982 error "OST not keeping write_bytes stats (b22312)"
2985 run_test 33c "test llobdstat and write_bytes"
2988 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
2989 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2992 local remote_dir=$DIR/$tdir/remote_dir
2994 test_mkdir $DIR/$tdir
2995 $LFS mkdir -i $MDTIDX $remote_dir ||
2996 error "create remote directory failed"
2998 touch $remote_dir/$tfile
2999 chmod 444 $remote_dir/$tfile
3000 chown $RUNAS_ID $remote_dir/$tfile
3002 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
3004 chown $RUNAS_ID $remote_dir
3005 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3006 error "create" || true
3007 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3008 error "open RDWR" || true
3009 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3011 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3014 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3018 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3019 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3020 mkdir $DIR/$tdir/local_dir
3022 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3023 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3024 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3026 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3027 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3029 rmdir $DIR/$tdir/* || error "rmdir failed"
3032 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3033 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3034 mkdir $DIR/$tdir/local_dir
3036 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3037 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3038 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3040 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3041 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3043 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3046 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3047 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3048 mkdir $DIR/$tdir/local_dir
3050 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3051 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3052 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3054 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3055 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3057 run_test 33e "mkdir and striped directory should have same mode"
3061 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3065 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3066 remote_mds_nodsh && skip "remote MDS with nodsh"
3069 chmod go+rwx $DIR/$tdir
3070 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3071 trap cleanup_33f EXIT
3073 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3074 error "cannot create striped directory"
3076 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3077 error "cannot create files in striped directory"
3079 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3080 error "cannot remove files in striped directory"
3082 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3083 error "cannot remove striped directory"
3087 run_test 33f "nonroot user can create, access, and remove a striped directory"
3090 mkdir -p $DIR/$tdir/dir2
3092 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3094 [[ $err =~ "exists" ]] || error "Not exists error"
3096 run_test 33g "nonroot user create already existing root created file"
3098 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3101 $MCREATE $DIR/f34 || error "mcreate failed"
3102 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3103 error "getstripe failed"
3104 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3105 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3106 error "getstripe failed"
3107 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3108 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3110 run_test 34a "truncate file that has not been opened ==========="
3113 [ ! -f $DIR/f34 ] && test_34a
3114 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3115 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3116 $OPENFILE -f O_RDONLY $DIR/f34
3117 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" ||
3118 error "getstripe failed"
3119 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3120 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3122 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3125 [ ! -f $DIR/f34 ] && test_34a
3126 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3127 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3128 $OPENFILE -f O_RDWR $DIR/f34
3129 $LFS getstripe $DIR/f34 2>&1 | grep -q "no stripe info" &&
3130 error "$LFS getstripe failed"
3131 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3132 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3134 run_test 34c "O_RDWR opening file-with-size works =============="
3137 [ ! -f $DIR/f34 ] && test_34a
3138 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3140 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3141 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3144 run_test 34d "write to sparse file ============================="
3148 $MCREATE $DIR/f34e || error "mcreate failed"
3149 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3150 $CHECKSTAT -s 1000 $DIR/f34e ||
3151 error "Size of $DIR/f34e not equal to 1000 bytes"
3152 $OPENFILE -f O_RDWR $DIR/f34e
3153 $CHECKSTAT -s 1000 $DIR/f34e ||
3154 error "Size of $DIR/f34e not equal to 1000 bytes"
3156 run_test 34e "create objects, some with size and some without =="
3158 test_34f() { # bug 6242, 6243
3159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3163 $MCREATE $DIR/f34f || error "mcreate failed"
3164 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3165 dd if=$DIR/f34f of=$TMP/f34f
3166 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3167 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3168 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3169 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3170 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3172 run_test 34f "read from a file with no objects until EOF ======="
3175 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3177 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3179 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3180 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3181 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3182 cancel_lru_locks osc
3183 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3184 error "wrong size after lock cancel"
3186 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3187 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3188 error "expanding truncate failed"
3189 cancel_lru_locks osc
3190 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3191 error "wrong expanded size after lock cancel"
3193 run_test 34g "truncate long file ==============================="
3196 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3201 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3202 sync # Flush the cache so that multiop below does not block on cache
3203 # flush when getting the group lock
3204 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3207 # Since just timed wait is not good enough, let's do a sync write
3208 # that way we are sure enough time for a roundtrip + processing
3209 # passed + 2 seconds of extra margin.
3210 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3214 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3215 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3219 local nsz=`stat -c %s $DIR/$tfile`
3220 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3222 run_test 34h "ftruncate file under grouplock should not block"
3225 cp /bin/sh $DIR/f35a
3227 chown $RUNAS_ID $DIR/f35a
3228 $RUNAS $DIR/f35a && error || true
3231 run_test 35a "exec file with mode 444 (should return and not leak)"
3235 utime $DIR/f36 || error "utime failed for MDS"
3237 run_test 36a "MDS utime check (mknod, utime)"
3241 utime $DIR/f36 || error "utime failed for OST"
3243 run_test 36b "OST utime check (open, utime)"
3248 chown $RUNAS_ID $DIR/d36
3249 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3251 run_test 36c "non-root MDS utime check (mknod, utime)"
3254 [ ! -d $DIR/d36 ] && test_36c
3255 echo "" > $DIR/d36/f36
3256 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3258 run_test 36d "non-root OST utime check (open, utime)"
3261 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3263 test_mkdir $DIR/$tdir
3264 touch $DIR/$tdir/$tfile
3265 $RUNAS utime $DIR/$tdir/$tfile &&
3266 error "utime worked, expected failure" || true
3268 run_test 36e "utime on non-owned file (should return error)"
3272 local LANG_SAVE=$LANG
3273 local LC_LANG_SAVE=$LC_LANG
3274 export LANG=C LC_LANG=C # for date language
3276 DATESTR="Dec 20 2000"
3277 test_mkdir $DIR/$tdir
3278 lctl set_param fail_loc=$fl
3280 cp /etc/hosts $DIR/$tdir/$tfile
3281 sync & # write RPC generated with "current" inode timestamp, but delayed
3283 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3284 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3285 cancel_lru_locks osc
3286 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3288 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3289 echo "BEFORE: $LS_BEFORE" && \
3290 echo "AFTER : $LS_AFTER" && \
3291 echo "WANT : $DATESTR" && \
3292 error "$DIR/$tdir/$tfile timestamps changed" || true
3294 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3298 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3300 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3301 subr_36fh "0x80000214"
3303 run_test 36f "utime on file racing with OST BRW write =========="
3306 remote_ost_nodsh && skip "remote OST with nodsh"
3307 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3313 test_mkdir $DIR/$tdir
3314 fmd_max_age=$(do_facet ost1 \
3315 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3318 fmd_before=$(do_facet ost1 \
3319 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3320 touch $DIR/$tdir/$tfile
3321 sleep $((fmd_max_age + 12))
3322 fmd_after=$(do_facet ost1 \
3323 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3325 echo "fmd_before: $fmd_before"
3326 echo "fmd_after: $fmd_after"
3327 [[ $fmd_after -gt $fmd_before ]] &&
3328 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3329 error "fmd didn't expire after ping" || true
3331 run_test 36g "filter mod data cache expiry ====================="
3334 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3336 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3337 subr_36fh "0x80000227"
3339 run_test 36h "utime on file racing with OST BRW write =========="
3342 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3344 test_mkdir $DIR/$tdir
3345 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3347 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3348 local new_mtime=$((mtime + 200))
3350 #change Modify time of striped dir
3351 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3352 error "change mtime failed"
3354 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3356 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3358 run_test 36i "change mtime on striped directory"
3360 # test_37 - duplicate with tests 32q 32r
3363 local file=$DIR/$tfile
3365 openfile -f O_DIRECTORY $file
3368 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3369 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3371 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3373 test_39a() { # was test_39
3375 touch $DIR/${tfile}2
3376 # ls -l $DIR/$tfile $DIR/${tfile}2
3377 # ls -lu $DIR/$tfile $DIR/${tfile}2
3378 # ls -lc $DIR/$tfile $DIR/${tfile}2
3380 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3381 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3383 ls -l --full-time $DIR/$tfile $DIR/${tfile}2