2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: LU-9693 LU-6493 LU-9693 LU-11058
12 ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c 77k"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # skipped tests: LU-8411 LU-9096 LU-9054 ..
16 ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT"
19 # bug number for skipped tests: LU-9795 (all below)
20 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 17n 60a 133g 300f"
23 # Check Grants after these tests
24 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
32 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
33 CREATETEST=${CREATETEST:-createtest}
35 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
37 OPENFILE=${OPENFILE:-openfile}
38 OPENUNLINK=${OPENUNLINK:-openunlink}
39 export MULTIOP=${MULTIOP:-multiop}
40 READS=${READS:-"reads"}
41 MUNLINK=${MUNLINK:-munlink}
42 SOCKETSERVER=${SOCKETSERVER:-socketserver}
43 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
44 MEMHOG=${MEMHOG:-memhog}
45 DIRECTIO=${DIRECTIO:-directio}
46 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
48 CHECK_GRANT=${CHECK_GRANT:-"yes"}
49 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
50 export PARALLEL=${PARALLEL:-"no"}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
61 . $LUSTRE/tests/test-framework.sh
63 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
66 if [[ $MDSCOUNT -gt 1 ]]; then
67 # bug number: LU-11161
68 ALWAYS_EXCEPT+=" 160g"
72 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
74 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
75 # bug number for skipped test: LU-1957
76 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 180"
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
81 # Get the SLES distro version
83 # Returns a version string that should only be used in comparing
84 # strings returned by version_code()
87 local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
89 # All SuSE Linux versions have one decimal. version_code expects two
90 local sles_version=$version.0
91 version_code $sles_version
94 # Check if we are running on Ubuntu or SLES so we can make decisions on
96 if [ -r /etc/SuSE-release ]; then
97 sles_version=$(sles_version_code)
98 [ $sles_version -lt $(version_code 11.4.0) ] &&
99 # bug number for skipped test: LU-4341
100 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 170"
101 [ $sles_version -lt $(version_code 12.0.0) ] &&
102 # bug number for skipped test: LU-3703
103 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 234"
104 elif [ -r /etc/os-release ]; then
105 if grep -qi ubuntu /etc/os-release; then
106 ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
107 -e 's/^VERSION=//p' \
111 if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
112 # bug number for skipped test:
114 ALWAYS_EXCEPT+=" 103a 410"
123 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
124 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
133 check_swap_layouts_support()
135 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
136 skip "Does not support layout lock."
139 check_and_setup_lustre
143 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
145 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
146 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
147 rm -rf $DIR/[Rdfs][0-9]*
149 # $RUNAS_ID may get set incorrectly somewhere else
150 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
152 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
156 if [ "${ONLY}" = "MOUNT" ] ; then
157 echo "Lustre is up, please go on"
161 echo "preparing for tests involving mounts"
162 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
164 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
165 echo # add a newline after mke2fs.
169 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
170 lctl set_param debug=-1 2> /dev/null || true
173 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
175 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
177 run_test 0a "touch; rm ====================="
180 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
181 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
183 run_test 0b "chmod 0755 $DIR ============================="
186 $LCTL get_param mdc.*.import | grep "state: FULL" ||
187 error "import not FULL"
188 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
191 run_test 0c "check import proc"
193 test_0d() { # LU-3397
194 [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
195 skip "proc exports not supported before 2.10.57"
197 local mgs_exp="mgs.MGS.exports"
198 local client_uuid=$($LCTL get_param -n mgc.*.uuid)
200 local exp_client_version
203 local temp_imp=$DIR/$tfile.import
204 local temp_exp=$DIR/$tfile.export
206 # save mgc import file to $temp_imp
207 $LCTL get_param mgc.*.import | tee $temp_imp
208 # Check if client uuid is found in MGS export
209 for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
210 [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
214 # save mgs export file to $temp_exp
215 do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
217 # Compare the value of field "connect_flags"
218 imp_val=$(grep "connect_flags" $temp_imp)
219 exp_val=$(grep "connect_flags" $temp_exp)
220 [ "$exp_val" == "$imp_val" ] ||
221 error "export flags '$exp_val' != import flags '$imp_val'"
223 # Compare the value of client version
224 exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
225 exp_val=$(version_code $exp_client_version)
226 imp_val=$(lustre_version_code client)
227 [ "$exp_val" == "$imp_val" ] ||
228 error "export client version '$exp_val' != '$imp_val'"
230 run_test 0d "check export proc ============================="
233 test_mkdir $DIR/$tdir
234 test_mkdir $DIR/$tdir/d2
235 mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
236 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
239 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
241 run_test 1 "mkdir; remkdir; rmdir"
244 test_mkdir $DIR/$tdir
245 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
246 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
248 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
250 run_test 2 "mkdir; touch; rmdir; check file"
253 test_mkdir $DIR/$tdir
254 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
255 touch $DIR/$tdir/$tfile
256 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
258 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
260 run_test 3 "mkdir; touch; rmdir; check dir"
262 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
264 test_mkdir -i 1 $DIR/$tdir
266 touch $DIR/$tdir/$tfile ||
267 error "Create file under remote directory failed"
270 error "Expect error removing in-use dir $DIR/$tdir"
272 test -d $DIR/$tdir || error "Remote directory disappeared"
274 rm -rf $DIR/$tdir || error "remove remote dir error"
276 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
279 test_mkdir $DIR/$tdir
280 test_mkdir $DIR/$tdir/d2
281 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
282 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
283 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
285 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2"
288 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
289 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
290 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
291 error "$tfile does not have perm 0666 or UID $UID"
292 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
293 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
294 error "$tfile should be 0666 and owned by UID $UID"
296 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
299 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
302 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
303 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
304 error "$tfile should be owned by UID $RUNAS_ID"
305 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
306 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
307 error "$tfile should be owned by UID $RUNAS_ID"
309 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
312 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
315 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
316 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
317 error "$tfile should be owned by GID $UID"
318 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
319 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
320 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
322 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
325 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
327 test_mkdir $DIR/$tdir
328 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
329 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
330 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
331 test_mkdir $DIR/$tdir/d/subdir
332 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
333 error "$tdir/d/subdir should be GID $RUNAS_GID"
334 if [[ $MDSCOUNT -gt 1 ]]; then
335 # check remote dir sgid inherite
336 $LFS mkdir -i 0 $DIR/$tdir.local ||
337 error "mkdir $tdir.local failed"
338 chmod g+s $DIR/$tdir.local ||
339 error "chmod $tdir.local failed"
340 chgrp $RUNAS_GID $DIR/$tdir.local ||
341 error "chgrp $tdir.local failed"
342 $LFS mkdir -i 1 $DIR/$tdir.local/$tdir.remote ||
343 error "mkdir $tdir.remote failed"
344 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir.local/$tdir.remote ||
345 error "$tdir.remote should be owned by $UID.$RUNAS_ID"
346 $CHECKSTAT -p 02755 $DIR/$tdir.local/$tdir.remote ||
347 error "$tdir.remote should be mode 02755"
350 run_test 6g "verify new dir in sgid dir inherits group"
352 test_6h() { # bug 7331
353 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
355 touch $DIR/$tfile || error "touch failed"
356 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
357 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
358 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
359 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
360 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
362 run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
365 test_mkdir $DIR/$tdir
366 $MCREATE $DIR/$tdir/$tfile
367 chmod 0666 $DIR/$tdir/$tfile
368 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
369 error "$tdir/$tfile should be mode 0666"
371 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
374 if [ ! -d $DIR/$tdir ]; then
375 test_mkdir $DIR/$tdir
377 $MCREATE $DIR/$tdir/$tfile
378 echo -n foo > $DIR/$tdir/$tfile
379 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
380 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
382 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 chmod 0666 $DIR/$tdir/$tfile
388 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
389 error "$tfile mode not 0666"
391 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
394 test_mkdir $DIR/$tdir
395 test_mkdir $DIR/$tdir/d2
396 test_mkdir $DIR/$tdir/d2/d3
397 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
399 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
402 test_mkdir $DIR/$tdir
403 test_mkdir $DIR/$tdir/d2
404 touch $DIR/$tdir/d2/$tfile
405 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
406 error "$tdir/d2/$tfile not a file"
408 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
411 test_mkdir $DIR/$tdir
412 test_mkdir $DIR/$tdir/d2
413 chmod 0666 $DIR/$tdir/d2
414 chmod 0705 $DIR/$tdir/d2
415 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
416 error "$tdir/d2 mode not 0705"
418 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
421 test_mkdir $DIR/$tdir
422 touch $DIR/$tdir/$tfile
423 chmod 0666 $DIR/$tdir/$tfile
424 chmod 0654 $DIR/$tdir/$tfile
425 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
426 error "$tdir/d2 mode not 0654"
428 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
431 test_mkdir $DIR/$tdir
432 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
434 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
435 error "$tdir/$tfile size not 0 after truncate"
437 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
440 test_mkdir $DIR/$tdir
441 touch $DIR/$tdir/$tfile
443 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
445 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
448 test_mkdir $DIR/$tdir
449 touch $DIR/$tdir/$tfile
450 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
451 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
452 error "$tdir/${tfile_2} not a file after rename"
453 rm $DIR/$tdir/${tfile}_2 || error "unlink failed after rename"
455 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
458 test_mkdir $DIR/$tdir
459 touch $DIR/$tdir/$tfile
460 rm -rf $DIR/$tdir/$tfile
461 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
463 run_test 16 "touch .../d16/f; rm -rf .../d16/f"
466 test_mkdir $DIR/$tdir
467 touch $DIR/$tdir/$tfile
468 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
470 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
471 error "$tdir/l-exist not a symlink"
472 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
473 error "$tdir/l-exist not referencing a file"
474 rm -f $DIR/$tdir/l-exist
475 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
477 run_test 17a "symlinks: create, remove (real)"
480 test_mkdir $DIR/$tdir
481 ln -s no-such-file $DIR/$tdir/l-dangle
483 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
484 error "$tdir/l-dangle not referencing no-such-file"
485 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
486 error "$tdir/l-dangle not referencing non-existent file"
487 rm -f $DIR/$tdir/l-dangle
488 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
490 run_test 17b "symlinks: create, remove (dangling)"
492 test_17c() { # bug 3440 - don't save failed open RPC for replay
493 test_mkdir $DIR/$tdir
494 ln -s foo $DIR/$tdir/$tfile
495 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
497 run_test 17c "symlinks: open dangling (should return error)"
500 test_mkdir $DIR/$tdir
501 ln -s foo $DIR/$tdir/$tfile
502 touch $DIR/$tdir/$tfile || error "creating to new symlink"
504 run_test 17d "symlinks: create dangling"
507 test_mkdir $DIR/$tdir
508 local foo=$DIR/$tdir/$tfile
509 ln -s $foo $foo || error "create symlink failed"
510 ls -l $foo || error "ls -l failed"
511 ls $foo && error "ls not failed" || true
513 run_test 17e "symlinks: create recursive symlink (should return error)"
516 test_mkdir $DIR/$tdir
517 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
518 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
519 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
520 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
521 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
522 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
525 run_test 17f "symlinks: long and very long symlink name"
527 # str_repeat(S, N) generate a string that is string S repeated N times
532 while [ $((n -= 1)) -ge 0 ]; do
538 # Long symlinks and LU-2241
540 test_mkdir $DIR/$tdir
541 local TESTS="59 60 61 4094 4095"
543 # Fix for inode size boundary in 2.1.4
544 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
547 # Patch not applied to 2.2 or 2.3 branches
548 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
549 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
552 # skip long symlink name for rhel6.5.
553 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
554 grep -q '6.5' /etc/redhat-release &>/dev/null &&
555 TESTS="59 60 61 4062 4063"
558 local SYMNAME=$(str_repeat 'x' $i)
559 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
560 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
563 run_test 17g "symlinks: really long symlink name and inode boundaries"
565 test_17h() { #bug 17378
566 [ $PARALLEL == "yes" ] && skip "skip parallel run"
567 remote_mds_nodsh && skip "remote MDS with nodsh"
571 test_mkdir $DIR/$tdir
572 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
573 $LFS setstripe -c -1 $DIR/$tdir
574 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
575 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
576 touch $DIR/$tdir/$tfile || true
578 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
580 test_17i() { #bug 20018
581 [ $PARALLEL == "yes" ] && skip "skip parallel run"
582 remote_mds_nodsh && skip "remote MDS with nodsh"
584 local foo=$DIR/$tdir/$tfile
587 test_mkdir -c1 $DIR/$tdir
588 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
589 ln -s $foo $foo || error "create symlink failed"
590 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
591 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
592 ls -l $foo && error "error not detected"
595 run_test 17i "don't panic on short symlink (should return error)"
597 test_17k() { #bug 22301
598 [ $PARALLEL == "yes" ] && skip "skip parallel run"
599 [[ -z "$(which rsync 2>/dev/null)" ]] &&
600 skip "no rsync command"
601 rsync --help | grep -q xattr ||
602 skip_env "$(rsync --version | head -n1) does not support xattrs"
603 test_mkdir $DIR/$tdir
604 test_mkdir $DIR/$tdir.new
605 touch $DIR/$tdir/$tfile
606 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
607 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
608 error "rsync failed with xattrs enabled"
610 run_test 17k "symlinks: rsync with xattrs enabled"
612 test_17l() { # LU-279
613 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
614 skip "no getfattr command"
616 test_mkdir $DIR/$tdir
617 touch $DIR/$tdir/$tfile
618 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
619 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
620 # -h to not follow symlinks. -m '' to list all the xattrs.
621 # grep to remove first line: '# file: $path'.
622 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
624 lgetxattr_size_check $path $xattr ||
625 error "lgetxattr_size_check $path $xattr failed"
629 run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
633 [ $PARALLEL == "yes" ] && skip "skip parallel run"
634 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
635 skip_env "ldiskfs only test"
636 remote_mds_nodsh && skip "remote MDS with nodsh"
637 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
638 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
639 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
641 local short_sym="0123456789"
642 local wdir=$DIR/$tdir
647 # create a long symlink file
648 for ((i = 0; i < 4; ++i)); do
649 long_sym=${long_sym}${long_sym}
652 echo "create 512 short and long symlink files under $wdir"
653 for ((i = 0; i < 256; ++i)); do
654 ln -sf ${long_sym}"a5a5" $wdir/long-$i
655 ln -sf ${short_sym}"a5a5" $wdir/short-$i
661 wait_delete_completed
663 echo "recreate the 512 symlink files with a shorter string"
664 for ((i = 0; i < 512; ++i)); do
665 # rewrite the symlink file with a shorter string
666 ln -sf ${long_sym} $wdir/long-$i || error "long_sym failed"
667 ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
670 local mds_index=$(($($LFS getstripe -m $wdir) + 1))
671 local devname=$(mdsdevname $mds_index)
673 echo "stop and checking mds${mds_index}:"
674 # e2fsck should not return error
676 run_e2fsck $(facet_active_host mds${mds_index}) $devname -n
679 start mds${mds_index} $devname $MDS_MOUNT_OPTS ||
680 error "start mds${mds_index} failed"
681 df $MOUNT > /dev/null 2>&1
683 error "e2fsck detected error for short/long symlink: rc=$rc"
686 run_test 17m "run e2fsck against MDT which contains short/long symlink"
688 check_fs_consistency_17n() {
692 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
693 # so it only check MDT1/MDT2 instead of all of MDTs.
694 for mdt_index in 1 2; do
695 local devname=$(mdsdevname $mdt_index)
696 # e2fsck should not return error
698 run_e2fsck $(facet_active_host mds$mdt_index) $devname -n ||
701 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
702 error "mount mds$mdt_index failed"
703 df $MOUNT > /dev/null 2>&1
709 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
710 [ $PARALLEL == "yes" ] && skip "skip parallel run"
711 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
712 skip_env "ldiskfs only test"
713 remote_mds_nodsh && skip "remote MDS with nodsh"
714 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
715 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
716 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
720 test_mkdir $DIR/$tdir
721 for ((i=0; i<10; i++)); do
722 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
723 error "create remote dir error $i"
724 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
725 error "create files under remote dir failed $i"
728 check_fs_consistency_17n ||
729 error "e2fsck report error after create files under remote dir"
731 for ((i = 0; i < 10; i++)); do
732 rm -rf $DIR/$tdir/remote_dir_${i} ||
733 error "destroy remote dir error $i"
736 check_fs_consistency_17n ||
737 error "e2fsck report error after unlink files under remote dir"
739 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
740 skip "lustre < 2.4.50 does not support migrate mv"
742 for ((i = 0; i < 10; i++)); do
743 mkdir -p $DIR/$tdir/remote_dir_${i}
744 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
745 error "create files under remote dir failed $i"
746 $LFS migrate --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
747 error "migrate remote dir error $i"
749 check_fs_consistency_17n || error "e2fsck report error after migration"
751 for ((i = 0; i < 10; i++)); do
752 rm -rf $DIR/$tdir/remote_dir_${i} ||
753 error "destroy remote dir error $i"
756 check_fs_consistency_17n || error "e2fsck report error after unlink"
758 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
761 remote_mds_nodsh && skip "remote MDS with nodsh"
762 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
763 skip "Need MDS version at least 2.3.64"
765 local wdir=$DIR/${tdir}o
771 mdt_index=$($LFS getstripe -m $wdir/$tfile)
772 mdt_index=$((mdt_index + 1))
775 #fail mds will wait the failover finish then set
776 #following fail_loc to avoid interfer the recovery process.
779 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
780 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
781 ls -l $wdir/$tfile && rc=1
782 do_facet mds${mdt_index} lctl set_param fail_loc=0
783 [[ $rc -eq 0 ]] || error "stat file should fail"
785 run_test 17o "stat file with incompat LMA feature"
788 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
789 ls $DIR || error "Failed to ls $DIR: $?"
791 run_test 18 "touch .../f ; ls ... =============================="
797 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
799 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
802 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
804 run_test 19b "ls -l .../f19 (should return error) =============="
807 [ $RUNAS_ID -eq $UID ] &&
808 skip_env "RUNAS_ID = UID = $UID -- skipping"
810 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
812 run_test 19c "$RUNAS touch .../f19 (should return error) =="
815 cat $DIR/f19 && error || true
817 run_test 19d "cat .../f19 (should return error) =============="
826 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
828 run_test 20 "touch .../f ; ls -l ..."
831 test_mkdir $DIR/$tdir
832 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
833 ln -s dangle $DIR/$tdir/link
834 echo foo >> $DIR/$tdir/link
835 cat $DIR/$tdir/dangle
836 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
837 $CHECKSTAT -f -t file $DIR/$tdir/link ||
838 error "$tdir/link not linked to a file"
840 run_test 21 "write to dangling link"
843 local wdir=$DIR/$tdir
845 chown $RUNAS_ID:$RUNAS_GID $wdir
846 (cd $wdir || error "cd $wdir failed";
847 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network |
849 ls -lR $wdir/etc || error "ls -lR $wdir/etc failed"
850 $CHECKSTAT -t dir $wdir/etc || error "checkstat -t dir failed"
851 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $wdir/etc ||
852 error "checkstat -u failed"
854 run_test 22 "unpack tar archive as non-root user"
858 test_mkdir $DIR/$tdir
859 local file=$DIR/$tdir/$tfile
861 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
862 openfile -f O_CREAT:O_EXCL $file &&
863 error "$file recreate succeeded" || true
865 run_test 23a "O_CREAT|O_EXCL in subdir"
867 test_23b() { # bug 18988
868 test_mkdir $DIR/$tdir
869 local file=$DIR/$tdir/$tfile
872 echo foo > $file || error "write filed"
873 echo bar >> $file || error "append filed"
874 $CHECKSTAT -s 8 $file || error "wrong size"
877 run_test 23b "O_APPEND check"
879 # LU-9409, size with O_APPEND and tiny writes
881 local file=$DIR/$tfile
884 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
885 $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
889 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
890 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
892 $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
895 #racing tiny & normal writes
896 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
897 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
899 $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
902 #racing tiny & normal writes 2, ugly numbers
903 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
904 dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
906 $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
909 run_test 23c "O_APPEND size checks for tiny writes"
911 # LU-11069 file offset is correct after appending writes
913 local file=$DIR/$tfile
916 echo CentaurHauls > $file
917 offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
918 if ((offset != 26)); then
919 error "wrong offset, expected 26, got '$offset'"
922 run_test 23d "file offset is correct after appending writes"
926 echo '-- same directory rename'
927 test_mkdir $DIR/$tdir
928 touch $DIR/$tdir/$tfile.1
929 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
930 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
932 run_test 24a "rename file to non-existent target"
935 test_mkdir $DIR/$tdir
936 touch $DIR/$tdir/$tfile.{1,2}
937 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
938 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
939 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
941 run_test 24b "rename file to existing target"
944 test_mkdir $DIR/$tdir
945 test_mkdir $DIR/$tdir/d$testnum.1
946 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
947 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
948 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
950 run_test 24c "rename directory to non-existent target"
953 test_mkdir -c1 $DIR/$tdir
954 test_mkdir -c1 $DIR/$tdir/d$testnum.1
955 test_mkdir -c1 $DIR/$tdir/d$testnum.2
956 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
957 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
958 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
960 run_test 24d "rename directory to existing target"
963 echo '-- cross directory renames --'
967 mv $DIR/R5a/f $DIR/R5b/g
968 $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
969 $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
971 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
976 touch $DIR/R6a/f $DIR/R6b/g
977 mv $DIR/R6a/f $DIR/R6b/g
978 $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
979 $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
981 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
986 test_mkdir $DIR/R7a/d
987 mv $DIR/R7a/d $DIR/R7b/e
988 $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
989 $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
991 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
994 test_mkdir -c1 $DIR/R8a
995 test_mkdir -c1 $DIR/R8b
996 test_mkdir -c1 $DIR/R8a/d
997 test_mkdir -c1 $DIR/R8b/e
998 mrename $DIR/R8a/d $DIR/R8b/e
999 $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
1000 $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
1002 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
1005 echo "-- rename error cases"
1007 test_mkdir $DIR/R9/a
1009 mrename $DIR/R9/f $DIR/R9/a
1010 $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
1011 $CHECKSTAT -t dir $DIR/R9/a || error "$DIR/R9/a not dir type"
1012 $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
1014 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
1018 mrename $DIR/R10/f $DIR/R10/g
1019 $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
1020 $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
1021 $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
1023 run_test 24j "source does not exist ============================"
1026 test_mkdir $DIR/R11a
1027 test_mkdir $DIR/R11a/d
1029 mv $DIR/R11a/f $DIR/R11a/d
1030 $CHECKSTAT -a $DIR/R11a/f || error "$DIR/R11a/f exists"
1031 $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
1033 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
1035 # bug 2429 - rename foo foo foo creates invalid file
1038 $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
1040 run_test 24l "Renaming a file to itself ========================"
1044 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
1045 # on ext3 this does not remove either the source or target files
1046 # though the "expected" operation would be to remove the source
1047 $CHECKSTAT -t file ${f} || error "${f} missing"
1048 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
1050 run_test 24m "Renaming a file to a hard link to itself ========="
1054 # this stats the old file after it was renamed, so it should fail
1056 $CHECKSTAT ${f} || error "${f} missing"
1058 $CHECKSTAT ${f}.rename || error "${f}.rename missing"
1059 $CHECKSTAT -a ${f} || error "${f} exists"
1061 run_test 24n "Statting the old file after renaming (Posix rename 2)"
1064 test_mkdir $DIR/$tdir
1065 rename_many -s random -v -n 10 $DIR/$tdir
1067 run_test 24o "rename of files during htree split"
1070 test_mkdir $DIR/R12a
1071 test_mkdir $DIR/R12b
1072 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
1073 mrename $DIR/R12a $DIR/R12b
1074 $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
1075 $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
1076 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
1077 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
1079 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
1081 cleanup_multiop_pause() {
1083 kill -USR1 $MULTIPID
1087 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1089 test_mkdir $DIR/R13a
1090 test_mkdir $DIR/R13b
1091 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
1092 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
1095 trap cleanup_multiop_pause EXIT
1096 mrename $DIR/R13a $DIR/R13b
1097 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1098 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1099 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1100 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1101 cleanup_multiop_pause
1102 wait $MULTIPID || error "multiop close failed"
1104 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1106 test_24r() { #bug 3789
1107 test_mkdir $DIR/R14a
1108 test_mkdir $DIR/R14a/b
1109 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1110 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1111 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1113 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1116 test_mkdir $DIR/R15a
1117 test_mkdir $DIR/R15a/b
1118 test_mkdir $DIR/R15a/b/c
1119 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1120 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1121 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1123 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1125 test_mkdir $DIR/R16a
1126 test_mkdir $DIR/R16a/b
1127 test_mkdir $DIR/R16a/b/c
1128 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1129 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1130 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1132 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1134 test_24u() { # bug12192
1135 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
1136 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1138 run_test 24u "create stripe file"
1140 simple_cleanup_common() {
1143 [ -z "$DIR" -o -z "$tdir" ] && return 0
1145 local start=$SECONDS
1148 wait_delete_completed
1149 echo "cleanup time $((SECONDS - start))"
1153 max_pages_per_rpc() {
1154 local mdtname="$(printf "MDT%04x" ${1:-0})"
1155 $LCTL get_param -n mdc.*$mdtname*.max_pages_per_rpc
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1161 local nrfiles=${COUNT:-100000}
1162 local fname="$DIR/$tdir/$tfile"
1164 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1165 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
1167 test_mkdir "$(dirname $fname)"
1168 # assume MDT0000 has the fewest inodes
1169 local stripes=$($LFS getdirstripe -c $(dirname $fname))
1170 local free_inodes=$(($(mdt_free_inodes 0) * stripes))
1171 [[ $free_inodes -lt $nrfiles ]] && nrfiles=$free_inodes
1173 trap simple_cleanup_common EXIT
1175 createmany -m "$fname" $nrfiles
1177 cancel_lru_locks mdc
1178 lctl set_param mdc.*.stats clear
1180 # was previously test_24D: LU-6101
1181 # readdir() returns correct number of entries after cursor reload
1182 local num_ls=$(ls $DIR/$tdir | wc -l)
1183 local num_uniq=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local num_all=$(ls -a $DIR/$tdir | wc -l)
1185 if [ $num_ls -ne $nrfiles -o $num_uniq -ne $nrfiles -o \
1186 $num_all -ne $((nrfiles + 2)) ]; then
1187 error "Expected $nrfiles files, got $num_ls " \
1188 "($num_uniq unique $num_all .&..)"
1190 # LU-5 large readdir
1191 # dirent_size = 32 bytes for sizeof(struct lu_dirent) +
1192 # N bytes for name (len($nrfiles) rounded to 8 bytes) +
1193 # 8 bytes for luda_type (4 bytes rounded to 8 bytes)
1194 # take into account of overhead in lu_dirpage header and end mark in
1195 # each page, plus one in rpc_num calculation.
1196 local dirent_size=$((32 + (${#tfile} | 7) + 1 + 8))
1197 local page_entries=$(((PAGE_SIZE - 24) / dirent_size))
1198 local mdt_idx=$($LFS getdirstripe -i $(dirname $fname))
1199 local rpc_pages=$(max_pages_per_rpc $mdt_idx)
1200 local rpc_max=$((nrfiles / (page_entries * rpc_pages) + stripes))
1201 local mds_readpage=$(calc_stats mdc.*.stats mds_readpage)
1202 echo "readpages: $mds_readpage rpc_max: $rpc_max"
1203 (( $mds_readpage < $rpc_max - 2 || $mds_readpage > $rpc_max + 1)) &&
1204 error "large readdir doesn't take effect: " \
1205 "$mds_readpage should be about $rpc_max"
1207 simple_cleanup_common
1209 run_test 24v "list large directory (test hash collision, b=17560)"
1211 test_24w() { # bug21506
1213 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1214 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1215 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1216 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1217 [[ "$SZ1" -eq "$SZ2" ]] ||
1218 error "Error reading at the end of the file $tfile"
1220 run_test 24w "Reading a file larger than 4Gb"
1223 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1224 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1225 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1226 skip "Need MDS version at least 2.7.56"
1229 local remote_dir=$DIR/$tdir/remote_dir
1231 test_mkdir $DIR/$tdir
1232 $LFS mkdir -i $MDTIDX $remote_dir ||
1233 error "create remote directory failed"
1235 test_mkdir $DIR/$tdir/src_dir
1236 touch $DIR/$tdir/src_file
1237 test_mkdir $remote_dir/tgt_dir
1238 touch $remote_dir/tgt_file
1240 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir ||
1241 error "rename dir cross MDT failed!"
1243 mrename $DIR/$tdir/src_file $remote_dir/tgt_file ||
1244 error "rename file cross MDT failed!"
1246 touch $DIR/$tdir/ln_file
1247 ln $DIR/$tdir/ln_file $remote_dir/ln_name ||
1248 error "ln file cross MDT failed"
1250 rm -rf $DIR/$tdir || error "Can not delete directories"
1252 run_test 24x "cross MDT rename/link"
1255 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
1256 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1258 local remote_dir=$DIR/$tdir/remote_dir
1261 test_mkdir $DIR/$tdir
1262 $LFS mkdir -i $mdtidx $remote_dir ||
1263 error "create remote directory failed"
1265 test_mkdir $remote_dir/src_dir
1266 touch $remote_dir/src_file
1267 test_mkdir $remote_dir/tgt_dir
1268 touch $remote_dir/tgt_file
1270 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1271 error "rename subdir in the same remote dir failed!"
1273 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1274 error "rename files in the same remote dir failed!"
1276 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1277 error "link files in the same remote dir failed!"
1279 rm -rf $DIR/$tdir || error "Can not delete directories"
1281 run_test 24y "rename/link on the same dir should succeed"
1283 test_24A() { # LU-3182
1287 test_mkdir $DIR/$tdir
1288 trap simple_cleanup_common EXIT
1289 createmany -m $DIR/$tdir/$tfile $NFILES
1290 local t=$(ls $DIR/$tdir | wc -l)
1291 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1292 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1293 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1294 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1297 simple_cleanup_common || error "Can not delete directories"
1299 run_test 24A "readdir() returns correct number of entries."
1301 test_24B() { # LU-4805
1302 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1306 test_mkdir $DIR/$tdir
1307 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1308 error "create striped dir failed"
1310 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1311 [ $count -eq 2 ] || error "Expected 2, got $count"
1313 touch $DIR/$tdir/striped_dir/a
1315 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1316 [ $count -eq 3 ] || error "Expected 3, got $count"
1318 touch $DIR/$tdir/striped_dir/.f
1320 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1321 [ $count -eq 4 ] || error "Expected 4, got $count"
1323 rm -rf $DIR/$tdir || error "Can not delete directories"
1325 run_test 24B "readdir for striped dir return correct number of entries"
1328 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
1334 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1335 error "create striped dir failed"
1337 cd $DIR/$tdir/d0/striped_dir
1339 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1340 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1341 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1343 [ "$d0_ino" = "$parent_ino" ] ||
1344 error ".. wrong, expect $d0_ino, get $parent_ino"
1346 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1347 error "mv striped dir failed"
1349 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1351 [ "$d1_ino" = "$parent_ino" ] ||
1352 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1354 run_test 24C "check .. in striped dir"
1357 [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
1358 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1361 mkdir $DIR/$tdir/src_dir
1362 $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
1363 error "create remote source failed"
1365 touch $DIR/$tdir/src_dir/src_child/a
1367 $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
1368 error "create remote target dir failed"
1370 $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
1371 error "create remote target child failed"
1373 mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
1374 error "rename dir cross MDT failed!"
1378 $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
1379 error "src_child still exists after rename"
1381 $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
1382 error "missing file(a) after rename"
1384 rm -rf $DIR/$tdir || error "Can not delete directories"
1386 run_test 24E "cross MDT rename/link"
1389 echo '== symlink sanity ============================================='
1393 touch $DIR/s25/foo ||
1394 error "File creation in symlinked directory failed"
1396 run_test 25a "create file in symlinked directory ==============="
1399 [ ! -d $DIR/d25 ] && test_25a
1400 $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
1402 run_test 25b "lookup file in symlinked directory ==============="
1406 test_mkdir $DIR/d26/d26-2
1407 ln -s d26/d26-2 $DIR/s26
1408 touch $DIR/s26/foo || error "File creation failed"
1410 run_test 26a "multiple component symlink ======================="
1413 test_mkdir -p $DIR/$tdir/d26-2
1414 ln -s $tdir/d26-2/foo $DIR/s26-2
1415 touch $DIR/s26-2 || error "File creation failed"
1417 run_test 26b "multiple component symlink at end of lookup ======"
1420 test_mkdir $DIR/d26.2
1421 touch $DIR/d26.2/foo
1422 ln -s d26.2 $DIR/s26.2-1
1423 ln -s s26.2-1 $DIR/s26.2-2
1424 ln -s s26.2-2 $DIR/s26.2-3
1425 chmod 0666 $DIR/s26.2-3/foo
1427 run_test 26c "chain of symlinks"
1429 # recursive symlinks (bug 439)
1431 ln -s d26-3/foo $DIR/d26-3
1433 run_test 26d "create multiple component recursive symlink"
1436 [ ! -h $DIR/d26-3 ] && test_26d
1439 run_test 26e "unlink multiple component recursive symlink"
1441 # recursive symlinks (bug 7022)
1443 test_mkdir $DIR/$tdir
1444 test_mkdir $DIR/$tdir/$tfile
1445 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1446 test_mkdir -p lndir/bar1
1447 test_mkdir $DIR/$tdir/$tfile/$tfile
1448 cd $tfile || error "cd $tfile failed"
1449 ln -s .. dotdot || error "ln dotdot failed"
1450 ln -s dotdot/lndir lndir || error "ln lndir failed"
1451 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1452 output=`ls $tfile/$tfile/lndir/bar1`
1453 [ "$output" = bar1 ] && error "unexpected output"
1454 rm -r $tfile || error "rm $tfile failed"
1455 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1457 run_test 26f "rm -r of a directory which has recursive symlink"
1460 test_mkdir $DIR/$tdir
1461 $LFS getstripe $DIR/$tdir
1462 $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
1463 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1464 cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
1466 run_test 27a "one stripe file"
1469 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1471 test_mkdir $DIR/$tdir
1472 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1473 $LFS getstripe -c $DIR/$tdir/$tfile
1474 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
1475 error "two-stripe file doesn't have two stripes"
1477 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1479 run_test 27b "create and write to two stripe file"
1482 test_mkdir $DIR/$tdir
1483 $LFS setstripe -c 0 -i -1 -S 0 $DIR/$tdir/$tfile ||
1484 error "setstripe failed"
1485 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1486 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1488 run_test 27d "create file with default settings"
1491 # LU-5839 adds check for existed layout before setting it
1492 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
1493 skip "Need MDS version at least 2.7.56"
1495 test_mkdir $DIR/$tdir
1496 $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1497 $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
1498 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
1500 run_test 27e "setstripe existing file (should return error)"
1503 test_mkdir $DIR/$tdir
1504 $LFS setstripe -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1505 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1506 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1507 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1508 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1509 $LFS getstripe $DIR/$tdir/$tfile || error "$LFS getstripe failed"
1511 run_test 27f "setstripe with bad stripe size (should return error)"
1514 test_mkdir $DIR/$tdir
1515 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1516 $LFS getstripe $DIR/$tdir/$tfile 2>&1 | grep "no stripe info" ||
1517 error "$DIR/$tdir/$tfile has object"
1519 run_test 27g "$LFS getstripe with no objects"
1522 test_mkdir $DIR/$tdir
1523 touch $DIR/$tdir/$tfile || error "touch failed"
1524 [[ $($LFS getstripe -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1525 error "missing objects"
1527 run_test 27i "$LFS getstripe with some objects"
1530 test_mkdir $DIR/$tdir
1531 $LFS setstripe -i $OSTCOUNT $DIR/$tdir/$tfile &&
1532 error "setstripe failed" || true
1534 run_test 27j "setstripe with bad stripe offset (should return error)"
1536 test_27k() { # bug 2844
1537 test_mkdir $DIR/$tdir
1538 local file=$DIR/$tdir/$tfile
1539 local ll_max_blksize=$((4 * 1024 * 1024))
1540 $LFS setstripe -S 67108864 $file || error "setstripe failed"
1541 local blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1542 [ $blksize -le $ll_max_blksize ] || error "1:$blksize > $ll_max_blksize"
1543 dd if=/dev/zero of=$file bs=4k count=1
1544 blksize=$(stat $file | awk '/IO Block:/ { print $7 }')
1545 [ $blksize -le $ll_max_blksize ] || error "2:$blksize > $ll_max_blksize"
1547 run_test 27k "limit i_blksize for broken user apps"
1550 mcreate $DIR/$tfile || error "creating file"
1551 $RUNAS $LFS setstripe -c 1 $DIR/$tfile &&
1552 error "setstripe should have failed" || true
1554 run_test 27l "check setstripe permissions (should return error)"
1557 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1559 ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
1561 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1562 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1564 trap simple_cleanup_common EXIT
1565 test_mkdir $DIR/$tdir
1566 $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.1
1567 dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=1024 count=$MAXFREE &&
1568 error "dd should fill OST0"
1570 while $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile.$i; do
1572 [ $i -gt 256 ] && break
1575 touch $DIR/$tdir/$tfile.$i
1576 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1577 awk '{print $1}'| grep -w "0") ] &&
1578 error "OST0 was full but new created file still use it"
1580 touch $DIR/$tdir/$tfile.$i
1581 [ $($LFS getstripe $DIR/$tdir/$tfile.$i | grep -A 10 obdidx |
1582 awk '{print $1}'| grep -w "0") ] &&
1583 error "OST0 was full but new created file still use it"
1584 simple_cleanup_common
1586 run_test 27m "create file while OST0 was full"
1589 local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
1590 awk '{ print $1 * 2; exit; }')
1594 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1595 # if the OST isn't full anymore.
1597 local OSTIDX=${1:-""}
1599 local list=$(comma_list $(osts_nodes))
1600 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1602 do_nodes $list lctl set_param fail_loc=0
1603 sync # initiate all OST_DESTROYs from MDS to OST
1607 exhaust_precreations() {
1610 local FAILIDX=${3:-$OSTIDX}
1611 local ofacet=ost$((OSTIDX + 1))
1613 test_mkdir -p -c1 $DIR/$tdir
1614 local mdtidx=$($LFS getstripe -m $DIR/$tdir)
1615 local mfacet=mds$((mdtidx + 1))
1616 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1618 local OST=$(ostname_from_index $OSTIDX)
1621 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1622 local last_id=$(do_facet $mfacet lctl get_param -n \
1623 osc.$mdtosc_proc1.prealloc_last_id)
1624 local next_id=$(do_facet $mfacet lctl get_param -n \
1625 osc.$mdtosc_proc1.prealloc_next_id)
1627 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1628 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1630 test_mkdir -p $DIR/$tdir/${OST}
1631 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1632 #define OBD_FAIL_OST_ENOSPC 0x215
1633 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1634 echo "Creating to objid $last_id on ost $OST..."
1635 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1636 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1637 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1641 exhaust_all_precreations() {
1643 for (( i=0; i < OSTCOUNT; i++ )) ; do
1644 exhaust_precreations $i $1 -1
1649 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1650 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1651 remote_mds_nodsh && skip "remote MDS with nodsh"
1652 remote_ost_nodsh && skip "remote OST with nodsh"
1655 rm -f $DIR/$tdir/$tfile
1656 exhaust_precreations 0 0x80000215
1657 $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
1658 touch $DIR/$tdir/$tfile || error "touch failed"
1659 $LFS getstripe $DIR/$tdir/$tfile
1662 run_test 27n "create file with some full OSTs"
1665 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1666 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1667 remote_mds_nodsh && skip "remote MDS with nodsh"
1668 remote_ost_nodsh && skip "remote OST with nodsh"
1671 rm -f $DIR/$tdir/$tfile
1672 exhaust_all_precreations 0x215
1674 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1679 run_test 27o "create file with all full OSTs (should error)"
1682 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1683 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1684 remote_mds_nodsh && skip "remote MDS with nodsh"
1685 remote_ost_nodsh && skip "remote OST with nodsh"
1688 rm -f $DIR/$tdir/$tfile
1689 test_mkdir $DIR/$tdir
1691 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1692 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1693 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1695 exhaust_precreations 0 0x80000215
1696 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1697 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1698 $LFS getstripe $DIR/$tdir/$tfile
1702 run_test 27p "append to a truncated file with some full OSTs"
1705 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1706 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1707 remote_mds_nodsh && skip "remote MDS with nodsh"
1708 remote_ost_nodsh && skip "remote OST with nodsh"
1711 rm -f $DIR/$tdir/$tfile
1713 test_mkdir $DIR/$tdir
1714 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1715 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
1716 error "truncate $DIR/$tdir/$tfile failed"
1717 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1719 exhaust_all_precreations 0x215
1721 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1722 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1726 run_test 27q "append to truncated file with all OSTs full (should error)"
1729 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1730 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1731 remote_mds_nodsh && skip "remote MDS with nodsh"
1732 remote_ost_nodsh && skip "remote OST with nodsh"
1735 rm -f $DIR/$tdir/$tfile
1736 exhaust_precreations 0 0x80000215
1738 $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
1742 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1744 test_27s() { # bug 10725
1745 test_mkdir $DIR/$tdir
1746 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1747 local stripe_count=0
1748 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1749 $LFS setstripe -S $stripe_size -c $stripe_count $DIR/$tdir &&
1750 error "stripe width >= 2^32 succeeded" || true
1753 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1755 test_27t() { # bug 10864
1760 $WLFS getstripe $tfile
1763 run_test 27t "check that utils parse path correctly"
1765 test_27u() { # bug 4900
1766 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1767 remote_mds_nodsh && skip "remote MDS with nodsh"
1770 local list=$(comma_list $(mdts_nodes))
1772 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1773 do_nodes $list $LCTL set_param fail_loc=0x139
1774 test_mkdir -p $DIR/$tdir
1775 trap simple_cleanup_common EXIT
1776 createmany -o $DIR/$tdir/t- 1000
1777 do_nodes $list $LCTL set_param fail_loc=0
1779 TLOG=$TMP/$tfile.getstripe
1780 $LFS getstripe $DIR/$tdir > $TLOG
1781 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1782 unlinkmany $DIR/$tdir/t- 1000
1784 [[ $OBJS -gt 0 ]] &&
1785 error "$OBJS objects created on OST-0. See $TLOG" ||
1788 run_test 27u "skip object creation on OSC w/o objects"
1790 test_27v() { # bug 4900
1791 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1792 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1793 remote_mds_nodsh && skip "remote MDS with nodsh"
1794 remote_ost_nodsh && skip "remote OST with nodsh"
1796 exhaust_all_precreations 0x215
1799 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1801 touch $DIR/$tdir/$tfile
1802 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1804 for (( i=1; i < OSTCOUNT; i++ )); do
1805 do_facet ost$i lctl set_param fail_loc=0x705
1807 local START=`date +%s`
1808 createmany -o $DIR/$tdir/$tfile 32
1810 local FINISH=`date +%s`
1811 local TIMEOUT=`lctl get_param -n timeout`
1812 local PROCESS=$((FINISH - START))
1813 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1814 error "$FINISH - $START >= $TIMEOUT / 2"
1815 sleep $((TIMEOUT / 2 - PROCESS))
1818 run_test 27v "skip object creation on slow OST"
1820 test_27w() { # bug 10997
1821 test_mkdir $DIR/$tdir
1822 $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1823 [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
1824 error "stripe size $size != 65536" || true
1825 [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
1826 error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
1828 run_test 27w "check $LFS setstripe -S and getstrip -d options"
1831 [[ $OSTCOUNT -lt 2 ]] &&
1832 skip_env "skipping multiple stripe count/offset test"
1834 test_mkdir $DIR/$tdir
1835 for i in $(seq 1 $OSTCOUNT); do
1837 $LFS setstripe -c $i -i $offset $DIR/$tdir/f$i ||
1838 error "setstripe -c $i -i $offset failed"
1839 count=$($LFS getstripe -c $DIR/$tdir/f$i)
1840 index=$($LFS getstripe -i $DIR/$tdir/f$i)
1841 [ $count -ne $i ] && error "stripe count $count != $i" || true
1842 [ $index -ne $offset ] &&
1843 error "stripe offset $index != $offset" || true
1846 run_test 27wa "check $LFS setstripe -c -i options"
1849 remote_ost_nodsh && skip "remote OST with nodsh"
1850 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1851 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1853 OFFSET=$(($OSTCOUNT - 1))
1855 local OST=$(ostname_from_index $OSTIDX)
1857 test_mkdir $DIR/$tdir
1858 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe per file
1859 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1861 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1862 for i in $(seq 0 $OFFSET); do
1863 [ $($LFS getstripe $DIR/$tdir/$tfile$i | grep -A 10 obdidx |
1864 awk '{print $1}' | grep -w "$OSTIDX") ] &&
1865 error "OST0 was degraded but new created file still use it"
1867 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1869 run_test 27x "create files while OST0 is degraded"
1872 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
1873 remote_mds_nodsh && skip "remote MDS with nodsh"
1874 remote_ost_nodsh && skip "remote OST with nodsh"
1875 [ $PARALLEL == "yes" ] && skip "skip parallel run"
1877 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1878 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1879 osc.$mdtosc.prealloc_last_id)
1880 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1881 osc.$mdtosc.prealloc_next_id)
1882 local fcount=$((last_id - next_id))
1883 [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
1884 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1886 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1887 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1888 local OST_DEACTIVE_IDX=-1
1893 for OSC in $MDS_OSCS; do
1894 OST=$(osc_to_ost $OSC)
1895 OSTIDX=$(index_from_ostuuid $OST)
1896 if [ $OST_DEACTIVE_IDX == -1 ]; then
1897 OST_DEACTIVE_IDX=$OSTIDX
1899 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1900 echo $OSC "is Deactivated:"
1901 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1905 OSTIDX=$(index_from_ostuuid $OST)
1906 test_mkdir $DIR/$tdir
1907 $LFS setstripe -c 1 $DIR/$tdir # 1 stripe / file
1909 for OSC in $MDS_OSCS; do
1910 OST=$(osc_to_ost $OSC)
1911 OSTIDX=$(index_from_ostuuid $OST)
1912 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1913 echo $OST "is degraded:"
1914 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1915 obdfilter.$OST.degraded=1
1920 createmany -o $DIR/$tdir/$tfile $fcount
1922 for OSC in $MDS_OSCS; do
1923 OST=$(osc_to_ost $OSC)
1924 OSTIDX=$(index_from_ostuuid $OST)
1925 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1926 echo $OST "is recovered from degraded:"
1927 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1928 obdfilter.$OST.degraded=0
1930 do_facet $SINGLEMDS lctl --device %$OSC activate
1934 # all osp devices get activated, hence -1 stripe count restored
1935 local stripe_count=0
1937 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1938 # devices get activated.
1940 $LFS setstripe -c -1 $DIR/$tfile
1941 stripe_count=$($LFS getstripe -c $DIR/$tfile)
1943 [ $stripe_count -ne $OSTCOUNT ] &&
1944 error "Of $OSTCOUNT OSTs, only $stripe_count is available"
1947 run_test 27y "create files while OST0 is degraded and the rest inactive"
1953 lmm_count=$($GETSTRIPE -c $1)
1954 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1955 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1957 local old_ifs="$IFS"
1959 fid=($($LFS path2fid $1))
1962 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1963 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1965 # compare lmm_seq and lu_fid->f_seq
1966 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1967 # compare lmm_object_id and lu_fid->oid
1968 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1970 # check the trusted.fid attribute of the OST objects of the file
1971 local have_obdidx=false
1973 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1974 # skip lines up to and including "obdidx"
1975 [ -z "$obdidx" ] && break
1976 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1977 $have_obdidx || continue
1979 local ost=$((obdidx + 1))
1980 local dev=$(ostdevname $ost)
1983 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1985 seq=$(echo $seq | sed -e "s/^0x//g")
1986 if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
1987 oid_hex=$(echo $oid)
1989 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1991 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1995 # Don't unmount/remount the OSTs if we don't need to do that.
1996 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1997 # update too, until that use mount/ll_decode_filter_fid/mount.
1998 # Re-enable when debugfs will understand new filter_fid.
2000 if [ $(facet_fstype ost$ost) == ldiskfs ]; then
2001 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
2002 $dev 2>/dev/null" | grep "parent=")
2004 if [ -z "$ff" ]; then
2006 mount_fstype ost$ost
2007 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
2008 $(facet_mntpt ost$ost)/$obj_file)
2009 unmount_fstype ost$ost
2010 start ost$ost $dev $OST_MOUNT_OPTS
2014 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
2016 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
2018 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
2019 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
2021 # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
2022 # stripe_size=1048576 component_id=1 component_start=0 \
2023 # component_end=33554432
2024 local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
2025 local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
2026 local ff_poid=$(cut -d: -f2 <<<$ff_parent)
2028 if grep -q 'stripe=' <<<$ff; then
2029 ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
2031 # $LL_DECODE_FILTER_FID does not print "stripe="; look
2032 # into f_ver in this case. See comment on ff_parent.
2033 ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
2036 # compare lmm_seq and filter_fid->ff_parent.f_seq
2037 [ $ff_pseq = $lmm_seq ] ||
2038 error "FF parent SEQ $ff_pseq != $lmm_seq"
2039 # compare lmm_object_id and filter_fid->ff_parent.f_oid
2040 [ $ff_poid = $lmm_oid ] ||
2041 error "FF parent OID $ff_poid != $lmm_oid"
2042 (($ff_pstripe == $stripe_nr)) ||
2043 error "FF stripe $ff_pstripe != $stripe_nr"
2045 stripe_nr=$((stripe_nr + 1))
2046 [ $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2048 if grep -q 'stripe_count=' <<<$ff; then
2049 local ff_scnt=$(sed -e 's/.*stripe_count=//' \
2050 -e 's/ .*//' <<<$ff)
2051 [ $lmm_count = $ff_scnt ] ||
2052 error "FF stripe count $lmm_count != $ff_scnt"
2058 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2059 remote_ost_nodsh && skip "remote OST with nodsh"
2061 test_mkdir $DIR/$tdir
2062 $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
2063 { error "setstripe -c -1 failed"; return 1; }
2064 # We need to send a write to every object to get parent FID info set.
2065 # This _should_ also work for setattr, but does not currently.
2066 # touch $DIR/$tdir/$tfile-1 ||
2067 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
2068 { error "dd $tfile-1 failed"; return 2; }
2069 $LFS setstripe -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
2070 { error "setstripe -c -1 failed"; return 3; }
2071 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
2072 { error "dd $tfile-2 failed"; return 4; }
2074 # make sure write RPCs have been sent to OSTs
2077 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
2078 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
2080 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
2082 test_27A() { # b=19102
2083 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2085 save_layout_restore_at_exit $MOUNT
2086 $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
2087 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
2088 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
2089 local default_size=$($GETSTRIPE -S $MOUNT)
2090 local default_offset=$($GETSTRIPE -i $MOUNT)
2091 local dsize=$(do_facet $SINGLEMDS \
2092 "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
2093 [ $default_size -eq $dsize ] ||
2094 error "stripe size $default_size != $dsize"
2095 [ $default_offset -eq -1 ] ||
2096 error "stripe offset $default_offset != -1"
2098 run_test 27A "check filesystem-wide default LOV EA values"
2100 test_27B() { # LU-2523
2101 test_mkdir $DIR/$tdir
2102 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
2104 # open f1 with O_LOV_DELAY_CREATE
2106 # call setstripe ioctl on open file descriptor for f1
2108 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
2112 # open f1 with O_LOV_DELAY_CREATE
2114 # call setstripe ioctl on open file descriptor for f1
2116 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
2118 # Allow multiop to fail in imitation of NFS's busted semantics.
2121 run_test 27B "call setstripe on open unlinked file/rename victim"
2123 test_27C() { #LU-2871
2124 [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
2132 test_mkdir $DIR/$tdir
2134 for i in $(seq 0 $((OSTCOUNT - 1))); do
2135 # set stripe across all OSTs starting from OST$i
2136 $SETSTRIPE -i $i -c -1 $tfile$i
2137 # get striping information
2138 ost_idx=($($GETSTRIPE $tfile$i |
2139 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2143 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2144 error "${#ost_idx[@]} != $OSTCOUNT"
2146 for index in $(seq 0 $((OSTCOUNT - 1))); do
2148 for j in $(echo ${ost_idx[@]}); do
2149 if [ $index -eq $j ]; then
2155 error "Can not find $index in ${ost_idx[@]}"
2159 run_test 27C "check full striping across all OSTs"
2162 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2163 [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
2164 remote_mds_nodsh && skip "remote MDS with nodsh"
2166 local POOL=${POOL:-testpool}
2168 local last_ost=$(($OSTCOUNT - 1))
2170 local ost_list=$(seq $first_ost $ost_step $last_ost)
2171 local ost_range="$first_ost $last_ost $ost_step"
2173 if ! combined_mgs_mds ; then
2177 test_mkdir $DIR/$tdir
2178 pool_add $POOL || error "pool_add failed"
2179 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2182 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ] &&
2184 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.55) -o \
2185 $(lustre_version_code client) -lt $(version_code 2.9.55) ] &&
2186 skip27D+=" -s 30,31"
2187 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
2188 error "llapi_layout_test failed"
2190 destroy_test_pools || error "destroy test pools failed"
2192 if ! combined_mgs_mds ; then
2196 run_test 27D "validate llapi_layout API"
2198 # Verify that default_easize is increased from its initial value after
2199 # accessing a widely striped file.
2201 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
2202 [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
2203 skip "client does not have LU-3338 fix"
2205 # 72 bytes is the minimum space required to store striping
2206 # information for a file striped across one OST:
2207 # (sizeof(struct lov_user_md_v3) +
2208 # sizeof(struct lov_user_ost_data_v1))
2210 $LCTL set_param -n llite.*.default_easize $min_easize ||
2211 error "lctl set_param failed"
2212 local easize=$($LCTL get_param -n llite.*.default_easize)
2214 [ $easize -eq $min_easize ] ||
2215 error "failed to set default_easize"
2217 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2218 error "setstripe failed"
2222 easize=$($LCTL get_param -n llite.*.default_easize)
2224 [ $easize -gt $min_easize ] ||
2225 error "default_easize not updated"
2227 run_test 27E "check that default extended attribute size properly increases"
2229 test_27F() { # LU-5346/LU-7975
2230 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2231 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
2232 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
2233 skip "Need MDS version at least 2.8.51"
2234 remote_ost_nodsh && skip "remote OST with nodsh"
2236 test_mkdir $DIR/$tdir
2238 $SETSTRIPE -c 2 $DIR/$tdir
2240 # stop all OSTs to reproduce situation for LU-7975 ticket
2241 for num in $(seq $OSTCOUNT); do
2245 # open/create f0 with O_LOV_DELAY_CREATE
2246 # truncate f0 to a non-0 size
2248 multiop $DIR/$tdir/f0 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T1050000c
2250 $CHECKSTAT -s 1050000 $DIR/$tdir/f0 || error "checkstat failed"
2251 # open/write it again to force delayed layout creation
2252 cat /etc/hosts > $DIR/$tdir/f0 &
2256 for num in $(seq $OSTCOUNT); do
2257 start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
2258 error "ost$num failed to start"
2261 wait $catpid || error "cat failed"
2263 cmp /etc/hosts $DIR/$tdir/f0 || error "cmp failed"
2264 [[ $($GETSTRIPE -c $DIR/$tdir/f0) == 2 ]] || error "wrong stripecount"
2267 run_test 27F "Client resend delayed layout creation with non-zero size"
2269 test_27G() { #LU-10629
2270 [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
2271 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2272 local POOL=${POOL:-testpool}
2273 local ostrange="0 0 1"
2275 test_mkdir $DIR/$tdir
2276 pool_add $POOL || error "pool_add failed"
2277 pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
2278 $LFS setstripe -p $POOL $DIR/$tdir
2280 local pool=$($LFS getstripe -p $DIR/$tdir)
2282 [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
2284 $LFS setstripe -d $DIR/$tdir
2286 pool=$($LFS getstripe -p $DIR/$tdir)
2290 [ -z "$pool" ] || error "'$pool' is not empty"
2292 run_test 27G "Clear OST pool from stripe"
2295 [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.54) ]] &&
2296 skip "Need MDS version newer than 2.11.54"
2297 [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
2298 test_mkdir $DIR/$tdir
2299 $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
2300 touch $DIR/$tdir/$tfile
2301 $LFS getstripe -c $DIR/$tdir/$tfile
2302 [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
2303 error "two-stripe file doesn't have two stripes"
2305 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
2306 $LFS getstripe -y $DIR/$tdir/$tfile
2307 (( $($LFS getstripe -y $DIR/$tdir/$tfile |
2308 egrep -c "l_ost_idx: [02]$") == "2" )) ||
2309 error "expected l_ost_idx: [02]$ not matched"
2311 # make sure ost list have been cleared
2312 local stripesize=$($GETSTRIPE -S $DIR/$tdir)
2313 $LFS setstripe -S $((stripesize * 4)) -i 1 \
2314 -c $((OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
2316 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
2318 run_test 27H "Set specific OSTs stripe"
2320 # createtest also checks that device nodes are created and
2321 # then visible correctly (#2091)
2322 test_28() { # bug 2091
2324 $CREATETEST $DIR/d28/ct || error "createtest failed"
2326 run_test 28 "create/mknod/mkdir with bad file types ============"
2329 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2331 sync; sleep 1; sync # flush out any dirty pages from previous tests
2338 declare -i LOCKCOUNTORIG=0
2339 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2340 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2342 [ $LOCKCOUNTORIG -eq 0 ] && error "No mdc lock count" && return 1
2344 declare -i LOCKUNUSEDCOUNTORIG=0
2345 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2346 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2353 declare -i LOCKCOUNTCURRENT=0
2354 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2355 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2358 declare -i LOCKUNUSEDCOUNTCURRENT=0
2359 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2360 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2363 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2364 $LCTL set_param -n ldlm.dump_namespaces ""
2365 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2366 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2367 log "dumped log to $TMP/test_29.dk (bug 5793)"
2370 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2371 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2372 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2373 log "dumped log to $TMP/test_29.dk (bug 5793)"
2377 run_test 29 "IT_GETATTR regression ============================"
2379 test_30a() { # was test_30
2380 cp $(which ls) $DIR || cp /bin/ls $DIR
2381 $DIR/ls / || error "Can't execute binary from lustre"
2384 run_test 30a "execute binary from Lustre (execve) =============="
2387 cp `which ls` $DIR || cp /bin/ls $DIR
2389 $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
2392 run_test 30b "execute binary from Lustre as non-root ==========="
2394 test_30c() { # b=22376
2395 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2397 cp `which ls` $DIR || cp /bin/ls $DIR
2399 cancel_lru_locks mdc
2400 cancel_lru_locks osc
2401 $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
2404 run_test 30c "execute binary from Lustre without read perms ===="
2407 $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
2408 $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
2410 run_test 31a "open-unlink file =================================="
2413 touch $DIR/f31 || error "touch $DIR/f31 failed"
2414 ln $DIR/f31 $DIR/f31b || error "ln failed"
2415 $MULTIOP $DIR/f31b Ouc || error "multiop failed"
2416 $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
2418 run_test 31b "unlink file with multiple links while open ======="
2421 touch $DIR/f31 || error "touch $DIR/f31 failed"
2422 ln $DIR/f31 $DIR/f31c || error "ln failed"
2423 multiop_bg_pause $DIR/f31 O_uc ||
2424 error "multiop_bg_pause for $DIR/f31 failed"
2426 $MULTIOP $DIR/f31c Ouc
2427 kill -USR1 $MULTIPID
2430 run_test 31c "open-unlink file with multiple links ============="
2433 opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
2434 $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
2436 run_test 31d "remove of open directory ========================="
2438 test_31e() { # bug 2904
2439 openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
2441 run_test 31e "remove of open non-empty directory ==============="
2443 test_31f() { # bug 4554
2444 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2447 test_mkdir $DIR/d31f
2448 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2449 cp /etc/hosts $DIR/d31f
2451 $GETSTRIPE $DIR/d31f/hosts
2452 multiop_bg_pause $DIR/d31f D_c || return 1
2455 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2456 test_mkdir $DIR/d31f
2457 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2458 cp /etc/hosts $DIR/d31f
2460 $GETSTRIPE $DIR/d31f/hosts
2461 multiop_bg_pause $DIR/d31f D_c || return 1
2464 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2465 wait $MULTIPID || error "first opendir $MULTIPID failed"
2469 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2470 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2473 run_test 31f "remove of open directory with open-unlink file ==="
2476 echo "-- cross directory link --"
2477 test_mkdir -c1 $DIR/${tdir}ga
2478 test_mkdir -c1 $DIR/${tdir}gb
2479 touch $DIR/${tdir}ga/f
2480 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2481 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2482 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2483 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2484 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2486 run_test 31g "cross directory link==============="
2489 echo "-- cross directory link --"
2490 test_mkdir -c1 $DIR/${tdir}
2491 test_mkdir -c1 $DIR/${tdir}/dir
2492 touch $DIR/${tdir}/f
2493 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2494 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2495 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2496 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2497 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2499 run_test 31h "cross directory link under child==============="
2502 echo "-- cross directory link --"
2503 test_mkdir -c1 $DIR/$tdir
2504 test_mkdir -c1 $DIR/$tdir/dir
2505 touch $DIR/$tdir/dir/f
2506 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2507 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2508 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2509 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2510 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2512 run_test 31i "cross directory link under parent==============="
2515 test_mkdir -c1 -p $DIR/$tdir
2516 test_mkdir -c1 -p $DIR/$tdir/dir1
2517 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2518 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2519 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2520 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2523 run_test 31j "link for directory==============="
2526 test_mkdir -c1 -p $DIR/$tdir
2528 touch $DIR/$tdir/exist
2529 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2530 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2531 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2532 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2533 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2534 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2535 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2538 run_test 31k "link to file: the same, non-existing, dir==============="
2544 touch $DIR/d31m2/exist
2545 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2546 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2547 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2548 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2549 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2550 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2553 run_test 31m "link to file: the same, non-existing, dir==============="
2556 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2557 nlink=$(stat --format=%h $DIR/$tfile)
2558 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2560 local cmd="exec $fd<$DIR/$tfile"
2563 trap "eval $cmd" EXIT
2564 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2565 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2566 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2567 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2568 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2571 run_test 31n "check link count of unlinked file"
2574 local TEMPNAME=$(mktemp $1_XXXXXX)
2575 mlink $TEMPNAME $1 2> /dev/null &&
2576 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2580 test_31o() { # LU-2901
2581 test_mkdir $DIR/$tdir
2582 for LOOP in $(seq 100); do
2583 rm -f $DIR/$tdir/$tfile*
2584 for THREAD in $(seq 8); do
2585 link_one $DIR/$tdir/$tfile.$LOOP &
2588 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2589 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2590 error "$LINKS duplicate links to $tfile.$LOOP" &&
2594 run_test 31o "duplicate hard links with same filename"
2597 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
2599 test_mkdir $DIR/$tdir
2600 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2601 $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
2603 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2604 error "open unlink test1 failed"
2605 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2606 error "open unlink test2 failed"
2608 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2609 error "test1 still exists"
2610 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2611 error "test2 still exists"
2613 run_test 31p "remove of open striped directory"
2615 cleanup_test32_mount() {
2618 local loopdev=$(losetup -a | grep $EXT2_DEV | sed -ne 's/:.*$//p')
2619 $UMOUNT $DIR/$tdir/ext2-mountpoint || rc=$?
2620 losetup -d $loopdev || true
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2628 echo "== more mountpoints and symlinks ================="
2629 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2630 trap cleanup_test32_mount EXIT
2631 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2632 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2633 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2634 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
2635 error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
2636 cleanup_test32_mount
2638 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2641 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2643 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2644 trap cleanup_test32_mount EXIT
2645 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2646 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2647 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2648 ls -al $DIR/$tdir/ext2-mountpoint/.. ||
2649 error "Can't list $DIR/$tdir/ext2-mountpoint/.."
2650 cleanup_test32_mount
2652 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2655 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2657 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2658 trap cleanup_test32_mount EXIT
2659 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2660 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2661 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2662 test_mkdir -p $DIR/$tdir/d2/test_dir
2663 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2664 error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
2665 cleanup_test32_mount
2667 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2670 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2672 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2673 trap cleanup_test32_mount EXIT
2674 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2675 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2676 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2677 test_mkdir -p $DIR/$tdir/d2/test_dir
2678 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
2679 error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
2680 cleanup_test32_mount
2682 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
2686 test_mkdir -p $DIR/$tdir/tmp
2687 local tmp_dir=$DIR/$tdir/tmp
2688 ln -s $DIR/$tdir $tmp_dir/symlink11
2689 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2690 $CHECKSTAT -t link $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2691 $CHECKSTAT -t link $DIR/$tdir/symlink01 || error "symlink01 bad"
2693 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir"
2697 test_mkdir -p $DIR/$tdir/tmp
2698 local tmp_dir=$DIR/$tdir/tmp
2699 ln -s $DIR/$tdir $tmp_dir/symlink11
2700 ln -s $tmp_dir/symlink11 $tmp_dir/../symlink01
2701 ls $DIR/$tdir/tmp/symlink11 || error "symlink11 bad"
2702 ls $DIR/$tdir/symlink01 || error "symlink01 bad"
2704 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir"
2707 local tmp_dir=$DIR/$tdir/tmp
2708 test_mkdir -p $tmp_dir
2709 test_mkdir $DIR/${tdir}2
2710 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2711 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2712 $CHECKSTAT -t link $tmp_dir/symlink12 || error "symlink12 not a link"
2713 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error "symlink02 not a link"
2714 $CHECKSTAT -t dir -f $tmp_dir/symlink12 || error "symlink12 not a dir"
2715 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error "symlink12 not a dir"
2717 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2720 rm -fr $DIR/$tdir $DIR/${tdir}2
2721 tmp_dir=$DIR/$tdir/tmp
2722 test_mkdir -p $tmp_dir
2723 test_mkdir $DIR/${tdir}2
2724 ln -s $DIR/${tdir}2 $tmp_dir/symlink12
2725 ln -s $tmp_dir/symlink12 $tmp_dir/../symlink02
2726 ls $tmp_dir/symlink12 || error "listing symlink12"
2727 ls $DIR/$tdir/symlink02 || error "listing symlink02"
2729 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2732 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2734 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2735 trap cleanup_test32_mount EXIT
2736 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2737 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2738 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2739 touch $DIR/$tdir/test_file
2740 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
2741 error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
2742 cleanup_test32_mount
2744 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2747 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2749 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2750 trap cleanup_test32_mount EXIT
2751 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2752 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2753 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2754 touch $DIR/$tdir/test_file
2755 cat $DIR/$tdir/ext2-mountpoint/../test_file ||
2756 error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
2757 cleanup_test32_mount
2759 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2762 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2765 trap cleanup_test32_mount EXIT
2766 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2767 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2768 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2769 test_mkdir -p $DIR/$tdir/d2
2770 touch $DIR/$tdir/d2/test_file || error "touch failed"
2771 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2772 error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
2773 cleanup_test32_mount
2775 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2778 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2781 trap cleanup_test32_mount EXIT
2782 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2783 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2784 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2785 test_mkdir -p $DIR/$tdir/d2
2786 touch $DIR/$tdir/d2/test_file || error "touch failed"
2787 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
2788 error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
2789 cleanup_test32_mount
2791 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2795 test_mkdir -p $DIR/d32m/tmp
2796 TMP_DIR=$DIR/d32m/tmp
2797 ln -s $DIR $TMP_DIR/symlink11
2798 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2799 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
2800 error "symlink11 not a link"
2801 $CHECKSTAT -t link $DIR/d32m/symlink01 ||
2802 error "symlink01 not a link"
2804 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2808 test_mkdir -p $DIR/d32n/tmp
2809 TMP_DIR=$DIR/d32n/tmp
2810 ln -s $DIR $TMP_DIR/symlink11
2811 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2812 ls -l $DIR/d32n/tmp/symlink11 || error "listing symlink11"
2813 ls -l $DIR/d32n/symlink01 || error "listing symlink01"
2815 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2819 test_mkdir -p $DIR/d32o/tmp
2820 TMP_DIR=$DIR/d32o/tmp
2821 ln -s $DIR/$tfile $TMP_DIR/symlink12
2822 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2823 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
2824 error "symlink12 not a link"
2825 $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
2826 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
2827 error "$DIR/d32o/tmp/symlink12 not file type"
2828 $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
2829 error "$DIR/d32o/symlink02 not file type"
2831 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2841 test_mkdir -p $DIR/d32p/tmp
2843 TMP_DIR=$DIR/d32p/tmp
2845 ln -s $DIR/$tfile $TMP_DIR/symlink12
2847 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2849 cat $DIR/d32p/tmp/symlink12 ||
2850 error "Can't open $DIR/d32p/tmp/symlink12"
2852 cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
2855 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2858 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2860 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2861 trap cleanup_test32_mount EXIT
2862 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2863 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2864 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2865 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2866 ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
2867 cleanup_test32_mount
2869 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2872 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2874 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2875 trap cleanup_test32_mount EXIT
2876 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2877 touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
2878 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
2879 error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
2880 ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
2881 cleanup_test32_mount
2883 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2888 chmod 444 $DIR/$tfile
2889 chown $RUNAS_ID $DIR/$tfile
2891 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2894 run_test 33aa "write file with mode 444 (should return error)"
2898 test_mkdir $DIR/$tdir
2899 chown $RUNAS_ID $DIR/$tdir
2900 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile ||
2901 error "$RUNAS create $tdir/$tfile failed"
2902 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/$tdir/$tfile &&
2903 error "open RDWR" || true
2905 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2909 test_mkdir $DIR/$tdir
2910 chown $RUNAS_ID $DIR/$tdir
2911 $RUNAS $OPENFILE -f 1286739555 $DIR/$tdir/$tfile || true
2913 run_test 33b "test open file with malformed flags (No panic)"
2916 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2917 remote_ost_nodsh && skip "remote OST with nodsh"
2926 test_mkdir $DIR/$tdir
2927 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2930 for ostnum in $(seq $OSTCOUNT); do
2931 # test-framework's OST numbering is one-based, while Lustre's
2933 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2934 # Parsing llobdstat's output sucks; we could grep the /proc
2935 # path, but that's likely to not be as portable as using the
2936 # llobdstat utility. So we parse lctl output instead.
2937 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2938 obdfilter/$ostname/stats |
2939 awk '/^write_bytes/ {print $7}' )
2940 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2941 if (( ${write_bytes:-0} > 0 ))
2948 $all_zeros || return 0
2951 echo foo > $DIR/$tdir/bar
2955 # Total up write_bytes after writing. We'd better find non-zeros.
2956 for ostnum in $(seq $OSTCOUNT); do
2957 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2958 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2959 obdfilter/$ostname/stats |
2960 awk '/^write_bytes/ {print $7}' )
2961 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2962 if (( ${write_bytes:-0} > 0 ))
2971 for ostnum in $(seq $OSTCOUNT); do
2972 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2973 echo "Check that write_bytes is present in obdfilter/*/stats:"
2974 do_facet ost$ostnum lctl get_param -n \
2975 obdfilter/$ostname/stats
2977 error "OST not keeping write_bytes stats (b22312)"
2980 run_test 33c "test llobdstat and write_bytes"
2983 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
2984 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2987 local remote_dir=$DIR/$tdir/remote_dir
2989 test_mkdir $DIR/$tdir
2990 $LFS mkdir -i $MDTIDX $remote_dir ||
2991 error "create remote directory failed"
2993 touch $remote_dir/$tfile
2994 chmod 444 $remote_dir/$tfile
2995 chown $RUNAS_ID $remote_dir/$tfile
2997 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2999 chown $RUNAS_ID $remote_dir
3000 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
3001 error "create" || true
3002 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
3003 error "open RDWR" || true
3004 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 || true
3006 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
3009 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3013 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3014 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3015 mkdir $DIR/$tdir/local_dir
3017 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3018 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3019 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3021 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3022 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
3024 rmdir $DIR/$tdir/* || error "rmdir failed"
3027 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3028 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3029 mkdir $DIR/$tdir/local_dir
3031 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3032 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3033 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3035 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3036 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
3038 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
3041 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
3042 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
3043 mkdir $DIR/$tdir/local_dir
3045 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
3046 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
3047 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
3049 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
3050 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
3052 run_test 33e "mkdir and striped directory should have same mode"
3056 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
3060 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3061 remote_mds_nodsh && skip "remote MDS with nodsh"
3064 chmod go+rwx $DIR/$tdir
3065 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
3066 trap cleanup_33f EXIT
3068 $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
3069 error "cannot create striped directory"
3071 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
3072 error "cannot create files in striped directory"
3074 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
3075 error "cannot remove files in striped directory"
3077 $RUNAS rmdir $DIR/$tdir/striped_dir ||
3078 error "cannot remove striped directory"
3082 run_test 33f "nonroot user can create, access, and remove a striped directory"
3085 mkdir -p $DIR/$tdir/dir2
3087 local err=$($RUNAS mkdir $DIR/$tdir/dir2 2>&1)
3089 [[ $err =~ "exists" ]] || error "Not exists error"
3091 run_test 33g "nonroot user create already existing root created file"
3093 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
3096 $MCREATE $DIR/f34 || error "mcreate failed"
3097 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3098 error "getstripe failed"
3099 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
3100 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3101 error "getstripe failed"
3102 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3103 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3105 run_test 34a "truncate file that has not been opened ==========="
3108 [ ! -f $DIR/f34 ] && test_34a
3109 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3110 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3111 $OPENFILE -f O_RDONLY $DIR/f34
3112 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
3113 error "getstripe failed"
3114 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3115 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3117 run_test 34b "O_RDONLY opening file doesn't create objects ====="
3120 [ ! -f $DIR/f34 ] && test_34a
3121 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3122 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3123 $OPENFILE -f O_RDWR $DIR/f34
3124 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
3125 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3126 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3128 run_test 34c "O_RDWR opening file-with-size works =============="
3131 [ ! -f $DIR/f34 ] && test_34a
3132 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
3134 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
3135 error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
3138 run_test 34d "write to sparse file ============================="
3142 $MCREATE $DIR/f34e || error "mcreate failed"
3143 $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
3144 $CHECKSTAT -s 1000 $DIR/f34e ||
3145 error "Size of $DIR/f34e not equal to 1000 bytes"
3146 $OPENFILE -f O_RDWR $DIR/f34e
3147 $CHECKSTAT -s 1000 $DIR/f34e ||
3148 error "Size of $DIR/f34e not equal to 1000 bytes"
3150 run_test 34e "create objects, some with size and some without =="
3152 test_34f() { # bug 6242, 6243
3153 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3157 $MCREATE $DIR/f34f || error "mcreate failed"
3158 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
3159 dd if=$DIR/f34f of=$TMP/f34f
3160 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
3161 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
3162 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
3163 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
3164 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
3166 run_test 34f "read from a file with no objects until EOF ======="
3169 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3171 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
3173 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
3174 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3175 error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
3176 cancel_lru_locks osc
3177 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
3178 error "wrong size after lock cancel"
3180 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
3181 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3182 error "expanding truncate failed"
3183 cancel_lru_locks osc
3184 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
3185 error "wrong expanded size after lock cancel"
3187 run_test 34g "truncate long file ==============================="
3190 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3195 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
3196 sync # Flush the cache so that multiop below does not block on cache
3197 # flush when getting the group lock
3198 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
3201 # Since just timed wait is not good enough, let's do a sync write
3202 # that way we are sure enough time for a roundtrip + processing
3203 # passed + 2 seconds of extra margin.
3204 dd if=/dev/zero of=$DIR/${tfile}-1 bs=$PAGE_SIZE oflag=direct count=1
3208 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
3209 error "Multiop blocked on ftruncate, pid=$MULTIPID"
3213 local nsz=`stat -c %s $DIR/$tfile`
3214 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
3216 run_test 34h "ftruncate file under grouplock should not block"
3219 cp /bin/sh $DIR/f35a
3221 chown $RUNAS_ID $DIR/f35a
3222 $RUNAS $DIR/f35a && error || true
3225 run_test 35a "exec file with mode 444 (should return and not leak)"
3229 utime $DIR/f36 || error "utime failed for MDS"
3231 run_test 36a "MDS utime check (mknod, utime)"
3235 utime $DIR/f36 || error "utime failed for OST"
3237 run_test 36b "OST utime check (open, utime)"
3242 chown $RUNAS_ID $DIR/d36
3243 $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
3245 run_test 36c "non-root MDS utime check (mknod, utime)"
3248 [ ! -d $DIR/d36 ] && test_36c
3249 echo "" > $DIR/d36/f36
3250 $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
3252 run_test 36d "non-root OST utime check (open, utime)"
3255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
3257 test_mkdir $DIR/$tdir
3258 touch $DIR/$tdir/$tfile
3259 $RUNAS utime $DIR/$tdir/$tfile &&
3260 error "utime worked, expected failure" || true
3262 run_test 36e "utime on non-owned file (should return error)"
3266 local LANG_SAVE=$LANG
3267 local LC_LANG_SAVE=$LC_LANG
3268 export LANG=C LC_LANG=C # for date language
3270 DATESTR="Dec 20 2000"
3271 test_mkdir $DIR/$tdir
3272 lctl set_param fail_loc=$fl
3274 cp /etc/hosts $DIR/$tdir/$tfile
3275 sync & # write RPC generated with "current" inode timestamp, but delayed
3277 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
3278 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
3279 cancel_lru_locks osc
3280 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
3282 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
3283 echo "BEFORE: $LS_BEFORE" && \
3284 echo "AFTER : $LS_AFTER" && \
3285 echo "WANT : $DATESTR" && \
3286 error "$DIR/$tdir/$tfile timestamps changed" || true
3288 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
3292 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3294 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3295 subr_36fh "0x80000214"
3297 run_test 36f "utime on file racing with OST BRW write =========="
3300 remote_ost_nodsh && skip "remote OST with nodsh"
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3307 test_mkdir $DIR/$tdir
3308 fmd_max_age=$(do_facet ost1 \
3309 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
3312 fmd_before=$(do_facet ost1 \
3313 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3314 touch $DIR/$tdir/$tfile
3315 sleep $((fmd_max_age + 12))
3316 fmd_after=$(do_facet ost1 \
3317 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
3319 echo "fmd_before: $fmd_before"
3320 echo "fmd_after: $fmd_after"
3321 [[ $fmd_after -gt $fmd_before ]] &&
3322 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3323 error "fmd didn't expire after ping" || true
3325 run_test 36g "filter mod data cache expiry ====================="
3328 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3330 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3331 subr_36fh "0x80000227"
3333 run_test 36h "utime on file racing with OST BRW write =========="
3336 [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
3338 test_mkdir $DIR/$tdir
3339 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3341 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3342 local new_mtime=$((mtime + 200))
3344 #change Modify time of striped dir
3345 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3346 error "change mtime failed"
3348 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3350 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3352 run_test 36i "change mtime on striped directory"
3354 # test_37 - duplicate with tests 32q 32r
3357 local file=$DIR/$tfile
3359 openfile -f O_DIRECTORY $file
3362 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3363 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3365 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3367 test_39a() { # was test_39
3369 touch $DIR/${tfile}2
3370 # ls -l $DIR/$tfile $DIR/${tfile}2
3371 # ls -lu $DIR/$tfile $DIR/${tfile}2
3372 # ls -lc $DIR/$tfile $DIR/${tfile}2
3374 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3375 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3377 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3379 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3381 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3382 error "O_TRUNC didn't change timestamps"
3385 run_test 39a "mtime changed on create"
3388 test_mkdir -c1 $DIR/$tdir
3389 cp -p /etc/passwd $DIR/$tdir/fopen
3390 cp -p /etc/passwd $DIR/$tdir/flink
3391 cp -p /etc/passwd $DIR/$tdir/funlink
3392 cp -p /etc/passwd $DIR/$tdir/frename
3393 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3396 echo "aaaaaa" >> $DIR/$tdir/fopen
3397 echo "aaaaaa" >> $DIR/$tdir/flink
3398 echo "aaaaaa" >> $DIR/$tdir/funlink
3399 echo "aaaaaa" >> $DIR/$tdir/frename
3401 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3402 local link_new=`stat -c %Y $DIR/$tdir/flink`
3403 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3404 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3406 cat $DIR/$tdir/fopen > /dev/null
3407 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3408 rm -f $DIR/$tdir/funlink2
3409 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3411 for (( i=0; i < 2; i++ )) ; do
3412 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3413 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3414 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3415 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3417 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3418 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3419 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3420 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3422 cancel_lru_locks osc
3423 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3426 run_test 39b "mtime change on open, link, unlink, rename ======"
3428 # this should be set to past
3429 TEST_39_MTIME=`date -d "1 year ago" +%s`
3435 local mtime0=`stat -c %Y $DIR1/$tfile`
3437 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3438 local mtime1=`stat -c %Y $DIR1/$tfile`
3439 [ "$mtime1" = $TEST_39_MTIME ] || \
3440 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3443 echo hello >> $DIR1/$tfile
3445 local mtime2=`stat -c %Y $DIR1/$tfile`
3446 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3447 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3449 mv $DIR1/$tfile $DIR1/$tfile-1
3451 for (( i=0; i < 2; i++ )) ; do
3452 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3453 [ "$mtime2" = "$mtime3" ] || \
3454 error "mtime ($mtime2) changed (to $mtime3) on rename"
3456 cancel_lru_locks osc
3457 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3460 run_test 39c "mtime change on rename ==========================="
3464 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3467 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3469 for (( i=0; i < 2; i++ )) ; do
3470 local mtime=`stat -c %Y $DIR1/$tfile`
3471 [ $mtime = $TEST_39_MTIME ] || \
3472 error "mtime($mtime) is not set to $TEST_39_MTIME"
3474 cancel_lru_locks osc
3475 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3478 run_test 39d "create, utime, stat =============================="
3482 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3485 local mtime1=`stat -c %Y $DIR1/$tfile`
3487 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3489 for (( i=0; i < 2; i++ )) ; do
3490 local mtime2=`stat -c %Y $DIR1/$tfile`
3491 [ $mtime2 = $TEST_39_MTIME ] || \
3492 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3494 cancel_lru_locks osc
3495 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3498 run_test 39e "create, stat, utime, stat ========================"
3502 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3505 mtime1=`stat -c %Y $DIR1/$tfile`
3508 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3510 for (( i=0; i < 2; i++ )) ; do
3511 local mtime2=`stat -c %Y $DIR1/$tfile`
3512 [ $mtime2 = $TEST_39_MTIME ] || \
3513 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3515 cancel_lru_locks osc
3516 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3519 run_test 39f "create, stat, sleep, utime, stat ================="
3523 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3525 echo hello >> $DIR1/$tfile
3526 local mtime1=`stat -c %Y $DIR1/$tfile`
3529 chmod o+r $DIR1/$tfile
3531 for (( i=0; i < 2; i++ )) ; do
3532 local mtime2=`stat -c %Y $DIR1/$tfile`
3533 [ "$mtime1" = "$mtime2" ] || \
3534 error "lost mtime: $mtime2, should be $mtime1"
3536 cancel_lru_locks osc
3537 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3540 run_test 39g "write, chmod, stat ==============================="
3544 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3550 echo hello >> $DIR1/$tfile
3551 local mtime1=`stat -c %Y $DIR1/$tfile`
3553 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3555 if [ "$d1" != "$d2" ]; then
3556 echo "write and touch not within one second"
3558 for (( i=0; i < 2; i++ )) ; do
3559 local mtime2=`stat -c %Y $DIR1/$tfile`
3560 [ "$mtime2" = $TEST_39_MTIME ] || \
3561 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3563 cancel_lru_locks osc
3564 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3568 run_test 39h "write, utime within one second, stat ============="
3571 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3576 echo hello >> $DIR1/$tfile
3577 local mtime1=`stat -c %Y $DIR1/$tfile`
3579 mv $DIR1/$tfile $DIR1/$tfile-1
3581 for (( i=0; i < 2; i++ )) ; do
3582 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3584 [ "$mtime1" = "$mtime2" ] || \
3585 error "lost mtime: $mtime2, should be $mtime1"
3587 cancel_lru_locks osc
3588 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3591 run_test 39i "write, rename, stat =============================="
3594 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3596 start_full_debug_logging
3600 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3601 lctl set_param fail_loc=0x80000412
3602 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3603 error "multiop failed"
3605 local mtime1=`stat -c %Y $DIR1/$tfile`
3607 mv $DIR1/$tfile $DIR1/$tfile-1
3609 kill -USR1 $multipid
3610 wait $multipid || error "multiop close failed"
3612 for (( i=0; i < 2; i++ )) ; do
3613 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3614 [ "$mtime1" = "$mtime2" ] ||
3615 error "mtime is lost on close: $mtime2, " \
3618 cancel_lru_locks osc
3619 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3621 lctl set_param fail_loc=0
3622 stop_full_debug_logging
3624 run_test 39j "write, rename, close, stat ======================="
3627 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3632 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3634 local mtime1=`stat -c %Y $DIR1/$tfile`
3636 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3638 kill -USR1 $multipid
3639 wait $multipid || error "multiop close failed"
3641 for (( i=0; i < 2; i++ )) ; do
3642 local mtime2=`stat -c %Y $DIR1/$tfile`
3644 [ "$mtime2" = $TEST_39_MTIME ] || \
3645 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3647 cancel_lru_locks osc
3648 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3651 run_test 39k "write, utime, close, stat ========================"
3653 # this should be set to future
3654 TEST_39_ATIME=`date -d "1 year" +%s`
3657 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3658 remote_mds_nodsh && skip "remote MDS with nodsh"
3660 local atime_diff=$(do_facet $SINGLEMDS \
3661 lctl get_param -n mdd.*MDT0000*.atime_diff)
3665 # test setting directory atime to future
3666 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3667 local atime=$(stat -c %X $DIR/$tdir)
3668 [ "$atime" = $TEST_39_ATIME ] ||
3669 error "atime is not set to future: $atime, $TEST_39_ATIME"
3671 # test setting directory atime from future to now
3672 local now=$(date +%s)
3673 touch -a -d @$now $DIR/$tdir
3675 atime=$(stat -c %X $DIR/$tdir)
3676 [ "$atime" -eq "$now" ] ||
3677 error "atime is not updated from future: $atime, $now"
3679 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3682 # test setting directory atime when now > dir atime + atime_diff
3683 local d1=$(date +%s)
3685 local d2=$(date +%s)
3686 cancel_lru_locks mdc
3687 atime=$(stat -c %X $DIR/$tdir)
3688 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3689 error "atime is not updated : $atime, should be $d2"
3691 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3694 # test not setting directory atime when now < dir atime + atime_diff
3696 cancel_lru_locks mdc
3697 atime=$(stat -c %X $DIR/$tdir)
3698 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] ||
3699 error "atime is updated to $atime, should remain $d1<atime<$d2"
3701 do_facet $SINGLEMDS \
3702 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3704 run_test 39l "directory atime update ==========================="
3707 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3711 local far_past_mtime=$(date -d "May 29 1953" +%s)
3712 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3714 touch -m -d @$far_past_mtime $DIR1/$tfile
3715 touch -a -d @$far_past_atime $DIR1/$tfile
3717 for (( i=0; i < 2; i++ )) ; do
3718 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3719 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3720 error "atime or mtime set incorrectly"
3722 cancel_lru_locks osc
3723 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3726 run_test 39m "test atime and mtime before 1970"
3728 test_39n() { # LU-3832
3729 remote_mds_nodsh && skip "remote MDS with nodsh"
3731 local atime_diff=$(do_facet $SINGLEMDS \
3732 lctl get_param -n mdd.*MDT0000*.atime_diff)
3737 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3740 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3741 atime0=$(stat -c %X $DIR/$tfile)
3744 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3745 atime1=$(stat -c %X $DIR/$tfile)
3748 cancel_lru_locks mdc
3749 cancel_lru_locks osc
3750 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3751 atime2=$(stat -c %X $DIR/$tfile)
3753 do_facet $SINGLEMDS \
3754 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3756 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3757 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3759 run_test 39n "check that O_NOATIME is honored"
3762 TESTDIR=$DIR/$tdir/$tfile
3763 [ -e $TESTDIR ] && rm -rf $TESTDIR
3770 links2=$(stat -c %h .)
3771 [ $(($links1 + 2)) != $links2 ] &&
3772 error "wrong links count $(($links1 + 2)) != $links2"
3774 links3=$(stat -c %h .)
3775 [ $(($links1 + 1)) != $links3 ] &&
3776 error "wrong links count $links1 != $links3"
3779 run_test 39o "directory cached attributes updated after create"
3782 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3785 TESTDIR=$DIR/$tdir/$tdir
3786 [ -e $TESTDIR ] && rm -rf $TESTDIR
3787 test_mkdir -p $TESTDIR
3791 test_mkdir -i $MDTIDX $TESTDIR/remote_dir1
3792 test_mkdir -i $MDTIDX $TESTDIR/remote_dir2
3794 links2=$(stat -c %h .)
3795 [ $(($links1 + 2)) != $links2 ] &&
3796 error "wrong links count $(($links1 + 2)) != $links2"
3798 links3=$(stat -c %h .)
3799 [ $(($links1 + 1)) != $links3 ] &&
3800 error "wrong links count $links1 != $links3"
3803 run_test 39p "remote directory cached attributes updated after create ========"
3806 test_39q() { # LU-8041
3807 local testdir=$DIR/$tdir
3809 multiop_bg_pause $testdir D_c || error "multiop failed"
3811 cancel_lru_locks mdc
3812 kill -USR1 $multipid
3813 local atime=$(stat -c %X $testdir)
3814 [ "$atime" -ne 0 ] || error "atime is zero"
3816 run_test 39q "close won't zero out atime"
3819 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3820 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3821 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3822 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3823 error "$tfile is not 4096 bytes in size"
3825 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3829 small_write $DIR/f41 18
3831 run_test 41 "test small file write + fstat ====================="
3833 count_ost_writes() {
3834 lctl get_param -n ${OSC}.*.stats |
3835 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3836 END { printf("%0.0f", writes) }'
3843 BG_DIRTY_RATIO_SAVE=10
3844 MAX_BG_DIRTY_RATIO=25
3848 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3849 # dirty_ratio, dirty_background_ratio
3850 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3851 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3852 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3853 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3855 # if file not here, we are a 2.4 kernel
3856 kill -CONT `pidof kupdated`
3861 # setup the trap first, so someone cannot exit the test at the
3862 # exact wrong time and mess up a machine
3863 trap start_writeback EXIT
3864 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3865 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3866 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3867 sysctl -w vm.dirty_writeback_centisecs=0
3868 sysctl -w vm.dirty_writeback_centisecs=0
3869 # save and increase /proc/sys/vm/dirty_ratio
3870 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3871 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3872 # save and increase /proc/sys/vm/dirty_background_ratio
3873 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3874 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3876 # if file not here, we are a 2.4 kernel
3877 kill -STOP `pidof kupdated`
3881 # ensure that all stripes have some grant before we test client-side cache
3883 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3884 dd if=/dev/zero of=$i bs=4k count=1
3889 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3890 # file truncation, and file removal.
3892 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3895 cancel_lru_locks $OSC
3897 sync; sleep 1; sync # just to be safe
3898 BEFOREWRITES=`count_ost_writes`
3899 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3900 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3901 AFTERWRITES=`count_ost_writes`
3902 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3903 error "$BEFOREWRITES < $AFTERWRITES"
3906 run_test 42a "ensure that we don't flush on close"
3909 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3912 cancel_lru_locks $OSC
3915 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3916 BEFOREWRITES=$(count_ost_writes)
3917 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3918 AFTERWRITES=$(count_ost_writes)
3919 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3920 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3922 BEFOREWRITES=$(count_ost_writes)
3923 sync || error "sync: $?"
3924 AFTERWRITES=$(count_ost_writes)
3925 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3926 error "$BEFOREWRITES < $AFTERWRITES on sync"
3928 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3932 run_test 42b "test destroy of file with cached dirty data ======"
3934 # if these tests just want to test the effect of truncation,
3935 # they have to be very careful. consider:
3936 # - the first open gets a {0,EOF}PR lock
3937 # - the first write conflicts and gets a {0, count-1}PW
3938 # - the rest of the writes are under {count,EOF}PW
3939 # - the open for truncate tries to match a {0,EOF}PR
3940 # for the filesize and cancels the PWs.
3941 # any number of fixes (don't get {0,EOF} on open, match
3942 # composite locks, do smarter file size management) fix
3943 # this, but for now we want these tests to verify that
3944 # the cancellation with truncate intent works, so we
3945 # start the file with a full-file pw lock to match against
3946 # until the truncate.
3951 cancel_lru_locks $OSC
3953 # prime the file with 0,EOF PW to match