2 # -*- tab-width: 4; 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: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 27u 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 # Tests that fail on uml
21 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
22 # buffer i/o errs sock spc runas
23 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a 64b 99a 99b 99c 99d 99e 99f 101a"
25 SRCDIR=$(cd $(dirname $0); echo $PWD)
26 export PATH=$PATH:/sbin
30 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
31 CREATETEST=${CREATETEST:-createtest}
33 LFIND=${LFIND:-"$LFS find"}
34 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
36 MCREATE=${MCREATE:-mcreate}
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}
47 UMOUNT=${UMOUNT:-"umount -d"}
49 CHECK_GRANT=${CHECK_GRANT:-"yes"}
50 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
51 export PARALLEL=${PARALLEL:-"no"}
53 export NAME=${NAME:-local}
60 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
61 . $LUSTRE/tests/test-framework.sh
63 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
72 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
73 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
82 check_kernel_version() {
84 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
86 patchless|patchless_client) return 0;;
87 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
89 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
93 if [ "$ONLY" == "cleanup" ]; then
98 check_and_setup_lustre
103 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
104 awk '{gsub(/_UUID/,""); print $1}' | head -1)
105 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
106 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
107 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
108 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
109 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
110 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
112 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
113 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
114 rm -rf $DIR/[Rdfs][0-9]*
116 # $RUNAS_ID may get set incorrectly somewhere else
117 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
119 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
123 if [ "${ONLY}" = "MOUNT" ] ; then
124 echo "Lustre is up, please go on"
128 echo "preparing for tests involving mounts"
129 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
131 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
132 echo # add a newline after mke2fs.
136 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
137 lctl set_param debug=-1 2> /dev/null || true
140 $CHECKSTAT -t file $DIR/$tfile || error
142 $CHECKSTAT -a $DIR/$tfile || error
144 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
147 chmod 0755 $DIR || error
148 $CHECKSTAT -p 0755 $DIR || error
150 run_test 0b "chmod 0755 $DIR ============================="
153 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
154 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
156 run_test 0c "check import proc ============================="
159 test_mkdir -p $DIR/$tdir
160 test_mkdir -p $DIR/$tdir/d2
161 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
162 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
164 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
169 $CHECKSTAT -a $DIR/$tdir || error
171 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
174 test_mkdir $DIR/$tdir
175 touch $DIR/$tdir/$tfile
176 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
178 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
182 $CHECKSTAT -a $DIR/$tdir || error
184 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
187 test_mkdir -p $DIR/$tdir
188 $CHECKSTAT -t dir $DIR/$tdir || error
190 run_test 3a "mkdir .../d3 ======================================"
193 if [ ! -d $DIR/$tdir ]; then
196 touch $DIR/$tdir/$tfile
197 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
199 run_test 3b "touch .../d3/f ===================================="
203 $CHECKSTAT -a $DIR/$tdir || error
205 run_test 3c "rm -r .../d3 ======================================"
208 test_mkdir -p $DIR/$tdir
209 $CHECKSTAT -t dir $DIR/$tdir || error
211 run_test 4a "mkdir .../d4 ======================================"
214 if [ ! -d $DIR/$tdir ]; then
215 test_mkdir $DIR/$tdir
217 test_mkdir $DIR/$tdir/d2
219 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
221 run_test 4b "mkdir .../d4/d2 ==================================="
224 test_mkdir $DIR/$tdir
225 test_mkdir $DIR/$tdir/d2
226 chmod 0707 $DIR/$tdir/d2
227 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
229 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
233 chmod 0666 $DIR/$tfile || error
234 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
236 run_test 6a "touch .../f6a; chmod .../f6a ======================"
239 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
240 if [ ! -f $DIR/$tfile ]; then
242 chmod 0666 $DIR/$tfile
244 $RUNAS chmod 0444 $DIR/$tfile && error
245 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
247 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
252 chown $RUNAS_ID $DIR/$tfile || error
253 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
255 run_test 6c "touch .../f6c; chown .../f6c ======================"
258 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
259 if [ ! -f $DIR/$tfile ]; then
261 chown $RUNAS_ID $DIR/$tfile
263 $RUNAS chown $UID $DIR/$tfile && error
264 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
266 run_test 6d "$RUNAS chown .../f6c (should return error) =="
269 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
271 chgrp $RUNAS_ID $DIR/$tfile || error
272 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
274 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
278 if [ ! -f $DIR/$tfile ]; then
280 chgrp $RUNAS_ID $DIR/$tfile
282 $RUNAS chgrp $UID $DIR/$tfile && error
283 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
285 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 test_mkdir $DIR/$tdir || error
290 chmod 777 $DIR/$tdir || error
291 $RUNAS mkdir $DIR/$tdir/d || error
292 chmod g+s $DIR/$tdir/d || error
293 test_mkdir $DIR/$tdir/d/subdir
294 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
296 run_test 6g "Is new dir in sgid dir inheriting group?"
298 test_6h() { # bug 7331
299 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
300 touch $DIR/$tfile || error "touch failed"
301 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
302 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
304 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
306 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
309 test_mkdir $DIR/$tdir
310 $MCREATE $DIR/$tdir/$tfile
311 chmod 0666 $DIR/$tdir/$tfile
312 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
314 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
317 if [ ! -d $DIR/$tdir ]; then
320 $MCREATE $DIR/$tdir/$tfile
321 echo -n foo > $DIR/$tdir/$tfile
322 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
323 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
325 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
328 test_mkdir $DIR/$tdir
329 touch $DIR/$tdir/$tfile
330 chmod 0666 $DIR/$tdir/$tfile
331 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
333 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 test_mkdir $DIR/$tdir/d2/d3
339 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
341 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
344 test_mkdir $DIR/$tdir
345 test_mkdir $DIR/$tdir/d2
346 touch $DIR/$tdir/d2/$tfile
347 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
349 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
352 test_mkdir $DIR/$tdir
353 test_mkdir $DIR/$tdir/d2
354 chmod 0666 $DIR/$tdir/d2
355 chmod 0705 $DIR/$tdir/d2
356 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
358 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
361 test_mkdir $DIR/$tdir
362 touch $DIR/$tdir/$tfile
363 chmod 0666 $DIR/$tdir/$tfile
364 chmod 0654 $DIR/$tdir/$tfile
365 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
367 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
370 test_mkdir $DIR/$tdir
371 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
373 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
375 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
378 test_mkdir $DIR/$tdir
379 touch $DIR/$tdir/$tfile
381 $CHECKSTAT -a $DIR/$tdir/$tfile || error
383 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
386 test_mkdir $DIR/$tdir
387 touch $DIR/$tdir/$tfile
388 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
389 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
391 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
394 test_mkdir $DIR/$tdir
395 touch $DIR/$tdir/$tfile
396 rm -rf $DIR/$tdir/$tfile
397 $CHECKSTAT -a $DIR/$tdir/$tfile || error
399 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
402 test_mkdir -p $DIR/$tdir
403 touch $DIR/$tdir/$tfile
404 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
406 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
407 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
408 rm -f $DIR/$tdir/l-exist
409 $CHECKSTAT -a $DIR/$tdir/l-exist || error
411 run_test 17a "symlinks: create, remove (real) =================="
414 test_mkdir -p $DIR/$tdir
415 ln -s no-such-file $DIR/$tdir/l-dangle
417 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
418 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
419 rm -f $DIR/$tdir/l-dangle
420 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
422 run_test 17b "symlinks: create, remove (dangling) =============="
424 test_17c() { # bug 3440 - don't save failed open RPC for replay
425 test_mkdir -p $DIR/$tdir
426 ln -s foo $DIR/$tdir/$tfile
427 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
429 run_test 17c "symlinks: open dangling (should return error) ===="
432 test_mkdir -p $DIR/$tdir
433 ln -s foo $DIR/$tdir/$tfile
434 touch $DIR/$tdir/$tfile || error "creating to new symlink"
436 run_test 17d "symlinks: create dangling ========================"
439 test_mkdir -p $DIR/$tdir
440 local foo=$DIR/$tdir/$tfile
441 ln -s $foo $foo || error "create symlink failed"
442 ls -l $foo || error "ls -l failed"
443 ls $foo && error "ls not failed" || true
445 run_test 17e "symlinks: create recursive symlink (should return error) ===="
448 test_mkdir -p $DIR/d17f
449 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
457 run_test 17f "symlinks: long and very long symlink name ========================"
459 # str_repeat(S, N) generate a string that is string S repeated N times
464 while [ $((n -= 1)) -ge 0 ]; do
470 # Long symlinks and LU-2241
472 test_mkdir -p $DIR/$tdir
473 local TESTS="59 60 61 4094 4095"
476 local SYMNAME=$(str_repeat 'x' $i)
477 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
478 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
481 run_test 17g "symlinks: really long symlink name and inode boundaries"
483 test_17h() { #bug 17378
484 remote_mds_nodsh && skip "remote MDS with nodsh" && return
485 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
487 test_mkdir -p $DIR/$tdir
488 if [ $MDSCOUNT -gt 1 ]; then
489 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
493 $SETSTRIPE -c -1 $DIR/$tdir
494 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
495 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
496 touch $DIR/$tdir/$tfile || true
498 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
500 test_17i() { #bug 20018
501 remote_mds_nodsh && skip "remote MDS with nodsh" && return
502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
503 test_mkdir -p $DIR/$tdir
504 local foo=$DIR/$tdir/$tfile
506 if [ $MDSCOUNT -gt 1 ]; then
507 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
511 ln -s $foo $foo || error "create symlink failed"
512 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
513 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
514 ls -l $foo && error "error not detected"
517 run_test 17i "don't panic on short symlink"
519 test_17k() { #bug 22301
520 rsync --help | grep -q xattr ||
521 skip_env "$(rsync --version| head -1) does not support xattrs"
522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
523 test_mkdir -p $DIR/$tdir
524 test_mkdir -p $DIR/$tdir.new
525 touch $DIR/$tdir/$tfile
526 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
527 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
528 error "rsync failed with xattrs enabled"
530 run_test 17k "symlinks: rsync with xattrs enabled ========================="
532 test_17l() { # LU-279
534 touch $DIR/$tdir/$tfile
535 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
536 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
537 # -h to not follow symlinks. -m '' to list all the xattrs.
538 # grep to remove first line: '# file: $path'.
539 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
541 lgetxattr_size_check $path $xattr ||
542 error "lgetxattr_size_check $path $xattr failed"
546 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
550 local short_sym="0123456789"
551 local WDIR=$DIR/${tdir}m
558 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
559 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
560 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
562 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
563 skip "only for ldiskfs MDT" && return 0
565 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
569 # create a long symlink file
570 for ((i = 0; i < 4; ++i)); do
571 long_sym=${long_sym}${long_sym}
574 echo "create 512 short and long symlink files under $WDIR"
575 for ((i = 0; i < 256; ++i)); do
576 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
577 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
583 wait_delete_completed
585 echo "recreate the 512 symlink files with a shorter string"
586 for ((i = 0; i < 512; ++i)); do
587 # rewrite the symlink file with a shorter string
588 ln -sf ${long_sym} $WDIR/long-$i
589 ln -sf ${short_sym} $WDIR/short-$i
592 mds_index=$($LFS getstripe -M $WDIR)
593 mds_index=$((mds_index+1))
594 devname=$(mdsdevname $mds_index)
595 cmd="$E2FSCK -fnvd $devname"
597 echo "stop and checking mds${mds_index}: $cmd"
598 # e2fsck should not return error
599 stop mds${mds_index} -f
600 do_facet mds${mds_index} $cmd || rc=$?
602 start mds${mds_index} $devname $MDS_MOUNT_OPTS
603 df $MOUNT > /dev/null 2>&1
604 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
605 "short/long symlink MDT: rc=$rc"
608 run_test 17m "run e2fsck against MDT which contains short/long symlink"
610 check_fs_consistency_17n() {
616 for mdt_index in $(seq 1 $MDSCOUNT); do
617 devname=$(mdsdevname $mdt_index)
618 cmd="$E2FSCK -fnvd $devname"
620 echo "stop and checking mds${mdt_index}: $cmd"
621 # e2fsck should not return error
623 do_facet mds${mdt_index} $cmd || rc=$?
625 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
626 df $MOUNT > /dev/null 2>&1
627 [ $rc -ne 0 ] && break
635 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
636 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
637 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
639 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
640 skip "only for ldiskfs MDT" && return 0
642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
647 for ((i=0; i<10; i++)); do
648 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
649 error "create remote dir error $i"
650 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
651 error "create files under remote dir failed $i"
654 check_fs_consistency_17n || error "e2fsck report error"
656 for ((i=0;i<10;i++)); do
657 rm -rf $DIR/$tdir/remote_dir_${i} ||
658 error "destroy remote dir error $i"
661 check_fs_consistency_17n || error "e2fsck report error"
663 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
669 run_test 18 "touch .../f ; ls ... =============================="
675 $CHECKSTAT -a $DIR/f19 || error
677 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
680 ls -l $DIR/f19 && error || true
682 run_test 19b "ls -l .../f19 (should return error) =============="
685 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
686 $RUNAS touch $DIR/f19 && error || true
688 run_test 19c "$RUNAS touch .../f19 (should return error) =="
691 cat $DIR/f19 && error || true
693 run_test 19d "cat .../f19 (should return error) =============="
705 $CHECKSTAT -a $DIR/f || error
707 run_test 20 "touch .../f ; ls -l ... ==========================="
711 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
712 ln -s dangle $DIR/d21/link
713 echo foo >> $DIR/d21/link
715 $CHECKSTAT -t link $DIR/d21/link || error
716 $CHECKSTAT -f -t file $DIR/d21/link || error
718 run_test 21 "write to dangling link ============================"
722 test_mkdir -p $DIR/$tdir
723 chown $RUNAS_ID:$RUNAS_GID $WDIR
724 (cd $WDIR || error "cd $WDIR failed";
725 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
727 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
728 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
729 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
731 run_test 22 "unpack tar archive as non-root user ==============="
735 test_mkdir -p $DIR/$tdir
736 local file=$DIR/$tdir/$tfile
738 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
739 openfile -f O_CREAT:O_EXCL $file &&
740 error "$file recreate succeeded" || true
742 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
744 test_23b() { # bug 18988
745 test_mkdir -p $DIR/$tdir
746 local file=$DIR/$tdir/$tfile
749 echo foo > $file || error "write filed"
750 echo bar >> $file || error "append filed"
751 $CHECKSTAT -s 8 $file || error "wrong size"
754 run_test 23b "O_APPEND check =========================="
757 echo '== rename sanity =============================================='
758 echo '-- same directory rename'
761 mv $DIR/R1/f $DIR/R1/g
762 $CHECKSTAT -t file $DIR/R1/g || error
764 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
769 mv $DIR/R2/f $DIR/R2/g
770 $CHECKSTAT -a $DIR/R2/f || error
771 $CHECKSTAT -t file $DIR/R2/g || error
773 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
778 mv $DIR/R3/f $DIR/R3/g
779 $CHECKSTAT -a $DIR/R3/f || error
780 $CHECKSTAT -t dir $DIR/R3/g || error
782 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
788 mrename $DIR/R4/f $DIR/R4/g
789 $CHECKSTAT -a $DIR/R4/f || error
790 $CHECKSTAT -t dir $DIR/R4/g || error
792 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
795 echo '-- cross directory renames --'
799 mv $DIR/R5a/f $DIR/R5b/g
800 $CHECKSTAT -a $DIR/R5a/f || error
801 $CHECKSTAT -t file $DIR/R5b/g || error
803 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
808 touch $DIR/R6a/f $DIR/R6b/g
809 mv $DIR/R6a/f $DIR/R6b/g
810 $CHECKSTAT -a $DIR/R6a/f || error
811 $CHECKSTAT -t file $DIR/R6b/g || error
813 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
818 test_mkdir $DIR/R7a/d
819 mv $DIR/R7a/d $DIR/R7b/e
820 $CHECKSTAT -a $DIR/R7a/d || error
821 $CHECKSTAT -t dir $DIR/R7b/e || error
823 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
828 test_mkdir $DIR/R8a/d
829 test_mkdir $DIR/R8b/e
830 mrename $DIR/R8a/d $DIR/R8b/e
831 $CHECKSTAT -a $DIR/R8a/d || error
832 $CHECKSTAT -t dir $DIR/R8b/e || error
834 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
837 echo "-- rename error cases"
841 mrename $DIR/R9/f $DIR/R9/a
842 $CHECKSTAT -t file $DIR/R9/f || error
843 $CHECKSTAT -t dir $DIR/R9/a || error
844 $CHECKSTAT -a $DIR/R9/a/f || error
846 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
850 mrename $DIR/R10/f $DIR/R10/g
851 $CHECKSTAT -t dir $DIR/R10 || error
852 $CHECKSTAT -a $DIR/R10/f || error
853 $CHECKSTAT -a $DIR/R10/g || error
855 run_test 24j "source does not exist ============================"
859 test_mkdir $DIR/R11a/d
861 mv $DIR/R11a/f $DIR/R11a/d
862 $CHECKSTAT -a $DIR/R11a/f || error
863 $CHECKSTAT -t file $DIR/R11a/d/f || error
865 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
867 # bug 2429 - rename foo foo foo creates invalid file
870 $MULTIOP $f OcNs || error
872 run_test 24l "Renaming a file to itself ========================"
876 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
877 # on ext3 this does not remove either the source or target files
878 # though the "expected" operation would be to remove the source
879 $CHECKSTAT -t file ${f} || error "${f} missing"
880 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
882 run_test 24m "Renaming a file to a hard link to itself ========="
886 # this stats the old file after it was renamed, so it should fail
890 $CHECKSTAT ${f}.rename
893 run_test 24n "Statting the old file after renaming (Posix rename 2)"
896 check_kernel_version 37 || return 0
897 test_mkdir -p $DIR/d24o
898 rename_many -s random -v -n 10 $DIR/d24o
900 run_test 24o "rename of files during htree split ==============="
905 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
906 mrename $DIR/R12a $DIR/R12b
907 $CHECKSTAT -a $DIR/R12a || error
908 $CHECKSTAT -t dir $DIR/R12b || error
909 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
910 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
912 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
914 cleanup_multiop_pause() {
920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
923 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
924 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
927 trap cleanup_multiop_pause EXIT
928 mrename $DIR/R13a $DIR/R13b
929 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
930 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
931 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
932 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
933 cleanup_multiop_pause
934 wait $MULTIPID || error "multiop close failed"
936 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
938 test_24r() { #bug 3789
940 test_mkdir $DIR/R14a/b
941 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
942 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
943 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
945 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
949 test_mkdir $DIR/R15a/b
950 test_mkdir $DIR/R15a/b/c
951 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
952 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
953 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
955 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
958 test_mkdir $DIR/R16a/b
959 test_mkdir $DIR/R16a/b/c
960 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
961 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
962 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
964 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
966 test_24u() { # bug12192
968 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
969 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
971 run_test 24u "create stripe file"
977 simple_cleanup_common() {
980 wait_delete_completed
983 max_pages_per_rpc() {
984 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
989 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
990 [ $FREE_INODES -lt $NRFILES ] && \
991 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
995 trap simple_cleanup_common EXIT
998 createmany -m $DIR/$tdir/$tfile $NRFILES
1000 cancel_lru_locks mdc
1001 lctl set_param mdc.*.stats clear
1003 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1005 # LU-5 large readdir
1006 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1007 # 8 bytes for name(filename is mostly 5 in this test) +
1008 # 8 bytes for luda_type
1009 # take into account of overhead in lu_dirpage header and end mark in
1010 # each page, plus one in RPC_NUM calculation.
1012 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1013 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1014 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1015 awk '/^mds_readpage/ {print $2}')
1016 [ $mds_readpage -gt $RPC_NUM ] && \
1017 error "large readdir doesn't take effect"
1019 simple_cleanup_common
1021 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1023 test_24w() { # bug21506
1025 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1026 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1027 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1028 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1029 [ "$SZ1" = "$SZ2" ] || \
1030 error "Error reading at the end of the file $tfile"
1032 run_test 24w "Reading a file larger than 4Gb"
1035 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1038 local remote_dir=$DIR/$tdir/remote_dir
1041 $LFS mkdir -i $MDTIDX $remote_dir ||
1042 error "create remote directory failed"
1044 mkdir -p $DIR/$tdir/src_dir
1045 touch $DIR/$tdir/src_file
1046 mkdir -p $remote_dir/tgt_dir
1047 touch $remote_dir/tgt_file
1049 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1050 error "rename dir cross MDT works!"
1052 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1053 error "rename file cross MDT works!"
1055 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1056 error "ln file cross MDT should not work!"
1058 rm -rf $DIR/$tdir || error "Can not delete directories"
1060 run_test 24x "cross rename/link should be failed"
1063 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1066 local remote_dir=$DIR/$tdir/remote_dir
1069 $LFS mkdir -i $MDTIDX $remote_dir ||
1070 error "create remote directory failed"
1072 mkdir -p $remote_dir/src_dir
1073 touch $remote_dir/src_file
1074 mkdir -p $remote_dir/tgt_dir
1075 touch $remote_dir/tgt_file
1077 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1078 error "rename subdir in the same remote dir failed!"
1080 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1081 error "rename files in the same remote dir failed!"
1083 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1084 error "link files in the same remote dir failed!"
1086 rm -rf $DIR/$tdir || error "Can not delete directories"
1088 run_test 24y "rename/link on the same dir should succeed"
1091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1094 local remote_src=$DIR/$tdir/remote_dir
1095 local remote_tgt=$DIR/$tdir/remote_tgt
1098 $LFS mkdir -i $MDTIDX $remote_src ||
1099 error "create remote directory failed"
1101 $LFS mkdir -i $MDTIDX $remote_tgt ||
1102 error "create remote directory failed"
1104 mrename $remote_src $remote_tgt &&
1105 error "rename remote dirs should not work!"
1107 rm -rf $DIR/$tdir || error "Can not delete directories"
1109 run_test 24z "rename one remote dir to another remote dir should fail"
1112 echo '== symlink sanity ============================================='
1116 touch $DIR/s25/foo || error
1118 run_test 25a "create file in symlinked directory ==============="
1121 [ ! -d $DIR/d25 ] && test_25a
1122 $CHECKSTAT -t file $DIR/s25/foo || error
1124 run_test 25b "lookup file in symlinked directory ==============="
1128 test_mkdir $DIR/d26/d26-2
1129 ln -s d26/d26-2 $DIR/s26
1130 touch $DIR/s26/foo || error
1132 run_test 26a "multiple component symlink ======================="
1135 test_mkdir -p $DIR/d26b/d26-2
1136 ln -s d26b/d26-2/foo $DIR/s26-2
1137 touch $DIR/s26-2 || error
1139 run_test 26b "multiple component symlink at end of lookup ======"
1142 test_mkdir $DIR/d26.2
1143 touch $DIR/d26.2/foo
1144 ln -s d26.2 $DIR/s26.2-1
1145 ln -s s26.2-1 $DIR/s26.2-2
1146 ln -s s26.2-2 $DIR/s26.2-3
1147 chmod 0666 $DIR/s26.2-3/foo
1149 run_test 26c "chain of symlinks ================================"
1151 # recursive symlinks (bug 439)
1153 ln -s d26-3/foo $DIR/d26-3
1155 run_test 26d "create multiple component recursive symlink ======"
1158 [ ! -h $DIR/d26-3 ] && test_26d
1161 run_test 26e "unlink multiple component recursive symlink ======"
1163 # recursive symlinks (bug 7022)
1165 test_mkdir -p $DIR/$tdir
1166 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1167 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1168 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1169 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1170 cd $tfile || error "cd $tfile failed"
1171 ln -s .. dotdot || error "ln dotdot failed"
1172 ln -s dotdot/lndir lndir || error "ln lndir failed"
1173 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1174 output=`ls $tfile/$tfile/lndir/bar1`
1175 [ "$output" = bar1 ] && error "unexpected output"
1176 rm -r $tfile || error "rm $tfile failed"
1177 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1179 run_test 26f "rm -r of a directory which has recursive symlink ="
1182 echo '== stripe sanity =============================================='
1183 test_mkdir -p $DIR/d27 || error "mkdir failed"
1185 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1186 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1188 log "== test_27a: write to one stripe file ========================="
1189 cp /etc/hosts $DIR/d27/f0 || error
1191 run_test 27a "one stripe file =================================="
1194 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1195 test_mkdir -p $DIR/d27
1196 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1197 $GETSTRIPE -c $DIR/d27/f01
1198 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1199 error "two-stripe file doesn't have two stripes"
1201 run_test 27b "create two stripe file"
1204 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1206 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1208 run_test 27c "write to two stripe file"
1211 test_mkdir -p $DIR/d27
1212 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1213 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1214 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1216 run_test 27d "create file with default settings ================"
1219 test_mkdir -p $DIR/d27
1220 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1221 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1222 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1224 run_test 27e "setstripe existing file (should return error) ======"
1227 test_mkdir -p $DIR/d27
1228 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1229 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1230 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1232 run_test 27f "setstripe with bad stripe size (should return error)"
1235 test_mkdir -p $DIR/d27
1236 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1237 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1238 error "$DIR/d27/fnone has object"
1240 run_test 27g "$GETSTRIPE with no objects"
1243 touch $DIR/d27/fsome || error "touch failed"
1244 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1246 run_test 27i "$GETSTRIPE with some objects"
1249 test_mkdir -p $DIR/d27
1250 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1252 run_test 27j "setstripe with bad stripe offset (should return error)"
1254 test_27k() { # bug 2844
1255 test_mkdir -p $DIR/d27
1257 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1258 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1259 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1260 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1261 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1262 dd if=/dev/zero of=$FILE bs=4k count=1
1263 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1264 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1266 run_test 27k "limit i_blksize for broken user apps ============="
1269 test_mkdir -p $DIR/d27
1270 mcreate $DIR/f27l || error "creating file"
1271 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1272 error "setstripe should have failed" || true
1274 run_test 27l "check setstripe permissions (should return error)"
1277 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1279 if [ $ORIGFREE -gt $MAXFREE ]; then
1280 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1283 trap simple_cleanup_common EXIT
1284 test_mkdir -p $DIR/$tdir
1285 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1286 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1287 error "dd should fill OST0"
1289 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1291 [ $i -gt 256 ] && break
1294 touch $DIR/$tdir/f27m_$i
1295 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1296 error "OST0 was full but new created file still use it"
1298 touch $DIR/$tdir/f27m_$i
1299 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1300 error "OST0 was full but new created file still use it"
1301 simple_cleanup_common
1303 run_test 27m "create file while OST0 was full =================="
1306 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1310 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1311 # if the OST isn't full anymore.
1313 local OSTIDX=${1:-""}
1315 local list=$(comma_list $(osts_nodes))
1316 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1318 do_nodes $list lctl set_param fail_loc=0
1319 sync # initiate all OST_DESTROYs from MDS to OST
1323 exhaust_precreations() {
1326 local FAILIDX=${3:-$OSTIDX}
1328 test_mkdir -p $DIR/$tdir
1329 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1330 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1332 local OST=$(ostname_from_index $OSTIDX)
1333 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1334 sed -e 's/_UUID$//;s/^.*-//')
1337 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1338 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1339 osc.$mdtosc_proc1.prealloc_last_id)
1340 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1341 osc.$mdtosc_proc1.prealloc_next_id)
1343 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1344 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1346 test_mkdir -p $DIR/$tdir/${OST}
1347 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1348 #define OBD_FAIL_OST_ENOSPC 0x215
1349 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1350 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1351 echo "Creating to objid $last_id on ost $OST..."
1352 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1353 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1354 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1358 exhaust_all_precreations() {
1360 for (( i=0; i < OSTCOUNT; i++ )) ; do
1361 exhaust_precreations $i $1 -1
1366 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1368 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1369 remote_ost_nodsh && skip "remote OST with nodsh" && return
1372 rm -f $DIR/$tdir/$tfile
1373 exhaust_precreations 0 0x80000215
1374 $SETSTRIPE -c -1 $DIR/$tdir
1375 touch $DIR/$tdir/$tfile || error
1376 $GETSTRIPE $DIR/$tdir/$tfile
1379 run_test 27n "create file with some full OSTs =================="
1382 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1384 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1385 remote_ost_nodsh && skip "remote OST with nodsh" && return
1388 rm -f $DIR/$tdir/$tfile
1389 exhaust_all_precreations 0x215
1391 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1396 run_test 27o "create file with all full OSTs (should error) ===="
1399 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1401 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1402 remote_ost_nodsh && skip "remote OST with nodsh" && return
1405 rm -f $DIR/$tdir/$tfile
1406 test_mkdir -p $DIR/$tdir
1408 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1409 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1410 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1412 exhaust_precreations 0 0x80000215
1413 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1414 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1415 $GETSTRIPE $DIR/$tdir/$tfile
1419 run_test 27p "append to a truncated file with some full OSTs ==="
1422 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1424 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1425 remote_ost_nodsh && skip "remote OST with nodsh" && return
1428 rm -f $DIR/$tdir/$tfile
1430 test_mkdir -p $DIR/$tdir
1431 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1432 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1433 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1435 exhaust_all_precreations 0x215
1437 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1438 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1442 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1445 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1447 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1448 remote_ost_nodsh && skip "remote OST with nodsh" && return
1451 rm -f $DIR/$tdir/$tfile
1452 exhaust_precreations 0 0x80000215
1454 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1458 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1460 test_27s() { # bug 10725
1461 test_mkdir -p $DIR/$tdir
1462 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1463 local stripe_count=0
1464 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1465 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1466 error "stripe width >= 2^32 succeeded" || true
1469 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1471 test_27t() { # bug 10864
1476 $WLFS getstripe $tfile
1479 run_test 27t "check that utils parse path correctly"
1481 test_27u() { # bug 4900
1482 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1485 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1486 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1487 test_mkdir -p $DIR/$tdir
1488 createmany -o $DIR/$tdir/t- 1000
1489 do_facet $SINGLEMDS lctl set_param fail_loc=0
1491 TLOG=$DIR/$tfile.getstripe
1492 $GETSTRIPE $DIR/$tdir > $TLOG
1493 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1494 unlinkmany $DIR/$tdir/t- 1000
1495 [ $OBJS -gt 0 ] && \
1496 error "$OBJS objects created on OST-0. See $TLOG" || pass
1498 run_test 27u "skip object creation on OSC w/o objects =========="
1500 test_27v() { # bug 4900
1501 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1503 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1504 remote_ost_nodsh && skip "remote OST with nodsh" && return
1506 exhaust_all_precreations 0x215
1509 test_mkdir -p $DIR/$tdir
1510 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1512 touch $DIR/$tdir/$tfile
1513 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1515 for (( i=1; i < OSTCOUNT; i++ )); do
1516 do_facet ost$i lctl set_param fail_loc=0x705
1518 local START=`date +%s`
1519 createmany -o $DIR/$tdir/$tfile 32
1521 local FINISH=`date +%s`
1522 local TIMEOUT=`lctl get_param -n timeout`
1523 local PROCESS=$((FINISH - START))
1524 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1525 error "$FINISH - $START >= $TIMEOUT / 2"
1526 sleep $((TIMEOUT / 2 - PROCESS))
1529 run_test 27v "skip object creation on slow OST ================="
1531 test_27w() { # bug 10997
1532 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1533 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1534 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1535 error "stripe size $size != 65536" || true
1536 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1537 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1539 run_test 27w "check $SETSTRIPE -S option"
1542 [ "$OSTCOUNT" -lt "2" ] &&
1543 skip_env "skipping multiple stripe count/offset test" && return
1545 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1546 for i in $(seq 1 $OSTCOUNT); do
1548 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1549 error "setstripe -c $i -i $offset failed"
1550 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1551 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1552 [ $count -ne $i ] && error "stripe count $count != $i" || true
1553 [ $index -ne $offset ] &&
1554 error "stripe offset $index != $offset" || true
1557 run_test 27wa "check $SETSTRIPE -c -i options"
1560 remote_ost_nodsh && skip "remote OST with nodsh" && return
1561 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1563 OFFSET=$(($OSTCOUNT - 1))
1565 local OST=$(ostname_from_index $OSTIDX)
1567 test_mkdir -p $DIR/$tdir
1568 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1569 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1571 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1572 for i in `seq 0 $OFFSET`; do
1573 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1574 error "OST0 was degraded but new created file still use it"
1576 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1578 run_test 27x "create files while OST0 is degraded"
1581 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1582 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1583 remote_ost_nodsh && skip "remote OST with nodsh" && return
1584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1586 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1587 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1588 osc.$mdtosc.prealloc_last_id)
1589 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1590 osc.$mdtosc.prealloc_next_id)
1591 local fcount=$((last_id - next_id))
1592 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1593 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1595 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1596 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1597 local OST_DEACTIVE_IDX=-1
1602 for OSC in $MDS_OSCS; do
1603 OST=$(osc_to_ost $OSC)
1604 OSTIDX=$(index_from_ostuuid $OST)
1605 if [ $OST_DEACTIVE_IDX == -1 ]; then
1606 OST_DEACTIVE_IDX=$OSTIDX
1608 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1609 echo $OSC "is Deactivated:"
1610 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1614 OSTIDX=$(index_from_ostuuid $OST)
1616 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1618 for OSC in $MDS_OSCS; do
1619 OST=$(osc_to_ost $OSC)
1620 OSTIDX=$(index_from_ostuuid $OST)
1621 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1622 echo $OST "is degraded:"
1623 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1624 obdfilter.$OST.degraded=1
1629 createmany -o $DIR/$tdir/$tfile $fcount
1631 for OSC in $MDS_OSCS; do
1632 OST=$(osc_to_ost $OSC)
1633 OSTIDX=$(index_from_ostuuid $OST)
1634 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1635 echo $OST "is recovered from degraded:"
1636 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1637 obdfilter.$OST.degraded=0
1639 do_facet $SINGLEMDS lctl --device %$OSC activate
1643 run_test 27y "create files while OST0 is degraded and the rest inactive"
1649 lmm_count=$($GETSTRIPE -c $1)
1650 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1651 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1653 local old_ifs="$IFS"
1655 fid=($($LFS path2fid $1))
1658 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1659 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1661 # compare lmm_seq and lu_fid->f_seq
1662 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1663 # compare lmm_object_id and lu_fid->oid
1664 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1666 # check the trusted.fid attribute of the OST objects of the file
1667 local have_obdidx=false
1669 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1670 # skip lines up to and including "obdidx"
1671 [ -z "$obdidx" ] && break
1672 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1673 $have_obdidx || continue
1675 local ost=$((obdidx + 1))
1676 local dev=$(ostdevname $ost)
1678 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1679 echo "Currently only works with ldiskfs-based OSTs"
1683 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1685 #don't unmount/remount the OSTs if we don't need to do that
1686 #local dir=$(facet_mntpt ost$ost)
1688 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1689 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1690 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1691 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1692 seq=$(echo $seq | sed -e "s/^0x//g")
1693 if [ $seq == 0 ]; then
1694 oid_hex=$(echo $oid)
1696 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1698 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1699 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1700 $dev 2>/dev/null" | grep "parent=")
1702 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1704 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1706 #do_facet ost$ost umount -d $dir
1707 #start ost$ost $dev $OST_MOUNT_OPTS
1709 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1710 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1711 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1712 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1713 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1714 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1716 # compare lmm_seq and filter_fid->ff_parent.f_seq
1717 [ $ff_pseq = $lmm_seq ] ||
1718 error "FF parent SEQ $ff_pseq != $lmm_seq"
1719 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1720 [ $ff_poid = $lmm_oid ] ||
1721 error "FF parent OID $ff_poid != $lmm_oid"
1722 [ $ff_pstripe = $stripe_nr ] ||
1723 error "FF stripe $ff_pstripe != $stripe_nr"
1725 stripe_nr=$((stripe_nr + 1))
1730 remote_ost_nodsh && skip "remote OST with nodsh" && return
1731 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1732 test_mkdir -p $DIR/$tdir
1734 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1735 { error "setstripe -c -1 failed"; return 1; }
1736 # We need to send a write to every object to get parent FID info set.
1737 # This _should_ also work for setattr, but does not currently.
1738 # touch $DIR/$tdir/$tfile-1 ||
1739 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1740 { error "dd $tfile-1 failed"; return 2; }
1741 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1742 { error "setstripe -c -1 failed"; return 3; }
1743 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1744 { error "dd $tfile-2 failed"; return 4; }
1746 # make sure write RPCs have been sent to OSTs
1749 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1750 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1752 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1754 test_27A() { # b=19102
1755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1756 local restore_size=$($GETSTRIPE -S $MOUNT)
1757 local restore_count=$($GETSTRIPE -c $MOUNT)
1758 local restore_offset=$($GETSTRIPE -i $MOUNT)
1759 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1760 local default_size=$($GETSTRIPE -S $MOUNT)
1761 local default_count=$($GETSTRIPE -c $MOUNT)
1762 local default_offset=$($GETSTRIPE -i $MOUNT)
1763 local dsize=$((1024 * 1024))
1764 [ $default_size -eq $dsize ] ||
1765 error "stripe size $default_size != $dsize"
1766 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1767 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1768 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1770 run_test 27A "check filesystem-wide default LOV EA values"
1772 # createtest also checks that device nodes are created and
1773 # then visible correctly (#2091)
1774 test_28() { # bug 2091
1776 $CREATETEST $DIR/d28/ct || error
1778 run_test 28 "create/mknod/mkdir with bad file types ============"
1781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1782 cancel_lru_locks mdc
1788 declare -i LOCKCOUNTORIG=0
1789 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1790 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1792 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1794 declare -i LOCKUNUSEDCOUNTORIG=0
1795 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1796 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1803 declare -i LOCKCOUNTCURRENT=0
1804 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1805 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1808 declare -i LOCKUNUSEDCOUNTCURRENT=0
1809 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1810 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1813 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1814 lctl set_param -n ldlm.dump_namespaces ""
1815 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1816 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1817 log "dumped log to $TMP/test_29.dk (bug 5793)"
1820 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1821 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1822 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1823 log "dumped log to $TMP/test_29.dk (bug 5793)"
1827 run_test 29 "IT_GETATTR regression ============================"
1829 test_30a() { # was test_30
1830 cp `which ls` $DIR || cp /bin/ls $DIR
1834 run_test 30a "execute binary from Lustre (execve) =============="
1837 cp `which ls` $DIR || cp /bin/ls $DIR
1839 $RUNAS $DIR/ls / || error
1842 run_test 30b "execute binary from Lustre as non-root ==========="
1844 test_30c() { # b=22376
1845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1846 cp `which ls` $DIR || cp /bin/ls $DIR
1848 cancel_lru_locks mdc
1849 cancel_lru_locks osc
1850 $RUNAS $DIR/ls / || error
1853 run_test 30c "execute binary from Lustre without read perms ===="
1856 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1857 $CHECKSTAT -a $DIR/f31 || error
1859 run_test 31a "open-unlink file =================================="
1862 touch $DIR/f31 || error
1863 ln $DIR/f31 $DIR/f31b || error
1864 $MULTIOP $DIR/f31b Ouc || error
1865 $CHECKSTAT -t file $DIR/f31 || error
1867 run_test 31b "unlink file with multiple links while open ======="
1870 touch $DIR/f31 || error
1871 ln $DIR/f31 $DIR/f31c || error
1872 multiop_bg_pause $DIR/f31 O_uc || return 1
1874 $MULTIOP $DIR/f31c Ouc
1875 kill -USR1 $MULTIPID
1878 run_test 31c "open-unlink file with multiple links ============="
1881 opendirunlink $DIR/d31d $DIR/d31d || error
1882 $CHECKSTAT -a $DIR/d31d || error
1884 run_test 31d "remove of open directory ========================="
1886 test_31e() { # bug 2904
1887 check_kernel_version 34 || return 0
1888 openfilleddirunlink $DIR/d31e || error
1890 run_test 31e "remove of open non-empty directory ==============="
1892 test_31f() { # bug 4554
1893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1895 test_mkdir $DIR/d31f
1896 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1897 cp /etc/hosts $DIR/d31f
1899 $GETSTRIPE $DIR/d31f/hosts
1900 multiop_bg_pause $DIR/d31f D_c || return 1
1903 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1904 test_mkdir $DIR/d31f
1905 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1906 cp /etc/hosts $DIR/d31f
1908 $GETSTRIPE $DIR/d31f/hosts
1909 multiop_bg_pause $DIR/d31f D_c || return 1
1912 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1913 wait $MULTIPID || error "first opendir $MULTIPID failed"
1917 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1918 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1921 run_test 31f "remove of open directory with open-unlink file ==="
1924 echo "-- cross directory link --"
1925 test_mkdir $DIR/d31ga
1926 test_mkdir $DIR/d31gb
1928 ln $DIR/d31ga/f $DIR/d31gb/g
1929 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1930 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1931 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1932 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1934 run_test 31g "cross directory link==============="
1937 echo "-- cross directory link --"
1938 test_mkdir $DIR/d31h
1939 test_mkdir $DIR/d31h/dir
1941 ln $DIR/d31h/f $DIR/d31h/dir/g
1942 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1943 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1944 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1945 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1947 run_test 31h "cross directory link under child==============="
1950 echo "-- cross directory link --"
1951 test_mkdir $DIR/d31i
1952 test_mkdir $DIR/d31i/dir
1953 touch $DIR/d31i/dir/f
1954 ln $DIR/d31i/dir/f $DIR/d31i/g
1955 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1956 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1957 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1958 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1960 run_test 31i "cross directory link under parent==============="
1964 test_mkdir $DIR/d31j
1965 test_mkdir $DIR/d31j/dir1
1966 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1967 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1968 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1969 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1972 run_test 31j "link for directory==============="
1976 test_mkdir $DIR/d31k
1978 touch $DIR/d31k/exist
1979 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1980 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1981 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1982 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1983 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1984 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1985 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1988 run_test 31k "link to file: the same, non-existing, dir==============="
1991 test_mkdir $DIR/d31m
1993 test_mkdir $DIR/d31m2
1994 touch $DIR/d31m2/exist
1995 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1996 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1997 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1998 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1999 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2000 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2003 run_test 31m "link to file: the same, non-existing, dir==============="
2005 cleanup_test32_mount() {
2007 $UMOUNT $DIR/$tdir/ext2-mountpoint
2011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2012 echo "== more mountpoints and symlinks ================="
2013 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2014 trap cleanup_test32_mount EXIT
2015 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2016 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2017 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2018 cleanup_test32_mount
2020 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2024 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2025 trap cleanup_test32_mount EXIT
2026 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2027 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2028 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2029 cleanup_test32_mount
2031 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2035 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2036 trap cleanup_test32_mount EXIT
2037 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2038 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2039 test_mkdir -p $DIR/$tdir/d2/test_dir
2040 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2041 cleanup_test32_mount
2043 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2047 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2048 trap cleanup_test32_mount EXIT
2049 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2050 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2051 test_mkdir -p $DIR/$tdir/d2/test_dir
2052 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2053 cleanup_test32_mount
2055 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2058 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2059 test_mkdir -p $DIR/d32e/tmp
2060 TMP_DIR=$DIR/d32e/tmp
2061 ln -s $DIR/d32e $TMP_DIR/symlink11
2062 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2063 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2064 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2066 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2069 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2070 test_mkdir -p $DIR/d32f/tmp
2071 TMP_DIR=$DIR/d32f/tmp
2072 ln -s $DIR/d32f $TMP_DIR/symlink11
2073 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2074 ls $DIR/d32f/tmp/symlink11 || error
2075 ls $DIR/d32f/symlink01 || error
2077 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2080 TMP_DIR=$DIR/$tdir/tmp
2081 test_mkdir -p $DIR/$tdir/tmp
2082 test_mkdir $DIR/${tdir}2
2083 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2084 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2085 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2086 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2087 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2088 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2090 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2093 rm -fr $DIR/$tdir $DIR/${tdir}2
2094 TMP_DIR=$DIR/$tdir/tmp
2095 test_mkdir -p $DIR/$tdir/tmp
2096 test_mkdir $DIR/${tdir}2
2097 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2098 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2099 ls $TMP_DIR/symlink12 || error
2100 ls $DIR/$tdir/symlink02 || error
2102 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2106 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2107 trap cleanup_test32_mount EXIT
2108 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2109 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2110 touch $DIR/$tdir/test_file
2111 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2112 cleanup_test32_mount
2114 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2118 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2119 trap cleanup_test32_mount EXIT
2120 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2121 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2122 touch $DIR/$tdir/test_file
2123 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2124 cleanup_test32_mount
2126 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2131 trap cleanup_test32_mount EXIT
2132 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2133 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2134 test_mkdir -p $DIR/$tdir/d2
2135 touch $DIR/$tdir/d2/test_file || error
2136 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2137 cleanup_test32_mount
2139 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2144 trap cleanup_test32_mount EXIT
2145 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2146 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2147 test_mkdir -p $DIR/$tdir/d2
2148 touch $DIR/$tdir/d2/test_file
2149 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2150 cleanup_test32_mount
2152 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2156 test_mkdir -p $DIR/d32m/tmp
2157 TMP_DIR=$DIR/d32m/tmp
2158 ln -s $DIR $TMP_DIR/symlink11
2159 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2160 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2161 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2163 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2167 test_mkdir -p $DIR/d32n/tmp
2168 TMP_DIR=$DIR/d32n/tmp
2169 ln -s $DIR $TMP_DIR/symlink11
2170 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2171 ls -l $DIR/d32n/tmp/symlink11 || error
2172 ls -l $DIR/d32n/symlink01 || error
2174 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2177 rm -fr $DIR/d32o $DIR/$tfile
2179 test_mkdir -p $DIR/d32o/tmp
2180 TMP_DIR=$DIR/d32o/tmp
2181 ln -s $DIR/$tfile $TMP_DIR/symlink12
2182 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2183 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2184 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2185 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2186 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2188 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2198 test_mkdir -p $DIR/d32p/tmp
2200 TMP_DIR=$DIR/d32p/tmp
2202 ln -s $DIR/$tfile $TMP_DIR/symlink12
2204 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2206 cat $DIR/d32p/tmp/symlink12 || error
2208 cat $DIR/d32p/symlink02 || error
2211 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2213 cleanup_testdir_mount() {
2219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2220 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2221 trap cleanup_testdir_mount EXIT
2222 test_mkdir -p $DIR/$tdir
2223 touch $DIR/$tdir/under_the_mount
2224 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2225 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2226 cleanup_testdir_mount
2228 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2232 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2233 trap cleanup_testdir_mount EXIT
2234 test_mkdir -p $DIR/$tdir
2235 touch $DIR/$tdir/under_the_mount
2236 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2237 ls $DIR/$tdir | grep -q under_the_mount && error || true
2238 cleanup_testdir_mount
2240 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2245 chmod 444 $DIR/$tfile
2246 chown $RUNAS_ID $DIR/$tfile
2248 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2251 run_test 33aa "write file with mode 444 (should return error) ===="
2255 test_mkdir -p $DIR/d33
2256 chown $RUNAS_ID $DIR/d33
2257 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2258 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2259 error "open RDWR" || true
2261 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2265 test_mkdir -p $DIR/d33
2266 chown $RUNAS_ID $DIR/d33
2267 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2269 run_test 33b "test open file with malformed flags (No panic and return error)"
2272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2278 remote_ost_nodsh && skip "remote OST with nodsh" && return
2281 test_mkdir -p $DIR/d33
2282 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2285 for ostnum in $(seq $OSTCOUNT); do
2286 # test-framework's OST numbering is one-based, while Lustre's
2288 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2289 # Parsing llobdstat's output sucks; we could grep the /proc
2290 # path, but that's likely to not be as portable as using the
2291 # llobdstat utility. So we parse lctl output instead.
2292 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2293 obdfilter/$ostname/stats |
2294 awk '/^write_bytes/ {print $7}' )
2295 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2296 if (( ${write_bytes:-0} > 0 ))
2303 $all_zeros || return 0
2306 echo foo > $DIR/d33/bar
2310 # Total up write_bytes after writing. We'd better find non-zeros.
2311 for ostnum in $(seq $OSTCOUNT); do
2312 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2313 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2314 obdfilter/$ostname/stats |
2315 awk '/^write_bytes/ {print $7}' )
2316 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2317 if (( ${write_bytes:-0} > 0 ))
2326 for ostnum in $(seq $OSTCOUNT); do
2327 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2328 echo "Check that write_bytes is present in obdfilter/*/stats:"
2329 do_facet ost$ostnum lctl get_param -n \
2330 obdfilter/$ostname/stats
2332 error "OST not keeping write_bytes stats (b22312)"
2335 run_test 33c "test llobdstat and write_bytes"
2338 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 local remote_dir=$DIR/$tdir/remote_dir
2344 $LFS mkdir -i $MDTIDX $remote_dir ||
2345 error "create remote directory failed"
2347 touch $remote_dir/$tfile
2348 chmod 444 $remote_dir/$tfile
2349 chown $RUNAS_ID $remote_dir/$tfile
2351 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2353 chown $RUNAS_ID $remote_dir
2354 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2355 error "create" || true
2356 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2357 error "open RDWR" || true
2358 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2359 error "create" || true
2361 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2363 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2366 $MCREATE $DIR/f34 || error
2367 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2368 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2369 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2370 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2372 run_test 34a "truncate file that has not been opened ==========="
2375 [ ! -f $DIR/f34 ] && test_34a
2376 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2377 $OPENFILE -f O_RDONLY $DIR/f34
2378 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2379 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2381 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2384 [ ! -f $DIR/f34 ] && test_34a
2385 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2386 $OPENFILE -f O_RDWR $DIR/f34
2387 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2388 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2390 run_test 34c "O_RDWR opening file-with-size works =============="
2393 [ ! -f $DIR/f34 ] && test_34a
2394 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2395 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2398 run_test 34d "write to sparse file ============================="
2402 $MCREATE $DIR/f34e || error
2403 $TRUNCATE $DIR/f34e 1000 || error
2404 $CHECKSTAT -s 1000 $DIR/f34e || error
2405 $OPENFILE -f O_RDWR $DIR/f34e
2406 $CHECKSTAT -s 1000 $DIR/f34e || error
2408 run_test 34e "create objects, some with size and some without =="
2410 test_34f() { # bug 6242, 6243
2411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2414 $MCREATE $DIR/f34f || error
2415 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2416 dd if=$DIR/f34f of=$TMP/f34f
2417 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2418 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2419 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2420 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2421 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2423 run_test 34f "read from a file with no objects until EOF ======="
2426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2427 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2428 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2429 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2430 cancel_lru_locks osc
2431 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2432 error "wrong size after lock cancel"
2434 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2435 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2436 error "expanding truncate failed"
2437 cancel_lru_locks osc
2438 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2439 error "wrong expanded size after lock cancel"
2441 run_test 34g "truncate long file ==============================="
2444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2448 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2449 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2453 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2454 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2458 local nsz=`stat -c %s $DIR/$tfile`
2459 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2461 run_test 34h "ftruncate file under grouplock should not block"
2464 cp /bin/sh $DIR/f35a
2466 chown $RUNAS_ID $DIR/f35a
2467 $RUNAS $DIR/f35a && error || true
2470 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2474 utime $DIR/f36 || error
2476 run_test 36a "MDS utime check (mknod, utime) ==================="
2480 utime $DIR/f36 || error
2482 run_test 36b "OST utime check (open, utime) ===================="
2487 chown $RUNAS_ID $DIR/d36
2488 $RUNAS utime $DIR/d36/f36 || error
2490 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2493 [ ! -d $DIR/d36 ] && test_36c
2494 echo "" > $DIR/d36/f36
2495 $RUNAS utime $DIR/d36/f36 || error
2497 run_test 36d "non-root OST utime check (open, utime) ==========="
2500 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2501 test_mkdir -p $DIR/$tdir
2502 touch $DIR/$tdir/$tfile
2503 $RUNAS utime $DIR/$tdir/$tfile && \
2504 error "utime worked, expected failure" || true
2506 run_test 36e "utime on non-owned file (should return error) ===="
2510 local LANG_SAVE=$LANG
2511 local LC_LANG_SAVE=$LC_LANG
2512 export LANG=C LC_LANG=C # for date language
2514 DATESTR="Dec 20 2000"
2515 test_mkdir -p $DIR/$tdir
2516 lctl set_param fail_loc=$fl
2518 cp /etc/hosts $DIR/$tdir/$tfile
2519 sync & # write RPC generated with "current" inode timestamp, but delayed
2521 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2522 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2523 cancel_lru_locks osc
2524 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2526 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2527 echo "BEFORE: $LS_BEFORE" && \
2528 echo "AFTER : $LS_AFTER" && \
2529 echo "WANT : $DATESTR" && \
2530 error "$DIR/$tdir/$tfile timestamps changed" || true
2532 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2537 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2538 subr_36fh "0x80000214"
2540 run_test 36f "utime on file racing with OST BRW write =========="
2543 remote_ost_nodsh && skip "remote OST with nodsh" && return
2544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2549 test_mkdir -p $DIR/$tdir
2550 fmd_max_age=$(do_facet ost1 \
2551 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2554 fmd_before=$(do_facet ost1 \
2555 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2556 touch $DIR/$tdir/$tfile
2557 sleep $((fmd_max_age + 12))
2558 fmd_after=$(do_facet ost1 \
2559 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2561 echo "fmd_before: $fmd_before"
2562 echo "fmd_after: $fmd_after"
2563 [ "$fmd_after" -gt "$fmd_before" ] && \
2564 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2565 error "fmd didn't expire after ping" || true
2567 run_test 36g "filter mod data cache expiry ====================="
2570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2571 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2572 subr_36fh "0x80000227"
2574 run_test 36h "utime on file racing with OST BRW write =========="
2576 # test_37 - duplicate with tests 32q 32r
2579 local file=$DIR/$tfile
2581 openfile -f O_DIRECTORY $file
2584 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2585 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2587 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2591 touch $DIR/${tfile}2
2592 # ls -l $DIR/$tfile $DIR/${tfile}2
2593 # ls -lu $DIR/$tfile $DIR/${tfile}2
2594 # ls -lc $DIR/$tfile $DIR/${tfile}2
2596 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2597 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2599 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2601 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2603 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2604 error "O_TRUNC didn't change timestamps"
2607 run_test 39 "mtime changed on create ==========================="
2610 test_mkdir -p $DIR/$tdir
2611 cp -p /etc/passwd $DIR/$tdir/fopen
2612 cp -p /etc/passwd $DIR/$tdir/flink
2613 cp -p /etc/passwd $DIR/$tdir/funlink
2614 cp -p /etc/passwd $DIR/$tdir/frename
2615 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2618 echo "aaaaaa" >> $DIR/$tdir/fopen
2619 echo "aaaaaa" >> $DIR/$tdir/flink
2620 echo "aaaaaa" >> $DIR/$tdir/funlink
2621 echo "aaaaaa" >> $DIR/$tdir/frename
2623 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2624 local link_new=`stat -c %Y $DIR/$tdir/flink`
2625 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2626 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2628 cat $DIR/$tdir/fopen > /dev/null
2629 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2630 rm -f $DIR/$tdir/funlink2
2631 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2633 for (( i=0; i < 2; i++ )) ; do
2634 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2635 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2636 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2637 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2639 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2640 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2641 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2642 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2644 cancel_lru_locks osc
2645 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2648 run_test 39b "mtime change on open, link, unlink, rename ======"
2650 # this should be set to past
2651 TEST_39_MTIME=`date -d "1 year ago" +%s`
2657 local mtime0=`stat -c %Y $DIR1/$tfile`
2659 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2660 local mtime1=`stat -c %Y $DIR1/$tfile`
2661 [ "$mtime1" = $TEST_39_MTIME ] || \
2662 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2665 echo hello >> $DIR1/$tfile
2667 local mtime2=`stat -c %Y $DIR1/$tfile`
2668 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2669 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2671 mv $DIR1/$tfile $DIR1/$tfile-1
2673 for (( i=0; i < 2; i++ )) ; do
2674 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2675 [ "$mtime2" = "$mtime3" ] || \
2676 error "mtime ($mtime2) changed (to $mtime3) on rename"
2678 cancel_lru_locks osc
2679 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2682 run_test 39c "mtime change on rename ==========================="
2686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2689 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2691 for (( i=0; i < 2; i++ )) ; do
2692 local mtime=`stat -c %Y $DIR1/$tfile`
2693 [ $mtime = $TEST_39_MTIME ] || \
2694 error "mtime($mtime) is not set to $TEST_39_MTIME"
2696 cancel_lru_locks osc
2697 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2700 run_test 39d "create, utime, stat =============================="
2704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2706 local mtime1=`stat -c %Y $DIR1/$tfile`
2708 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2710 for (( i=0; i < 2; i++ )) ; do
2711 local mtime2=`stat -c %Y $DIR1/$tfile`
2712 [ $mtime2 = $TEST_39_MTIME ] || \
2713 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2715 cancel_lru_locks osc
2716 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2719 run_test 39e "create, stat, utime, stat ========================"
2723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2725 mtime1=`stat -c %Y $DIR1/$tfile`
2728 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2730 for (( i=0; i < 2; i++ )) ; do
2731 local mtime2=`stat -c %Y $DIR1/$tfile`
2732 [ $mtime2 = $TEST_39_MTIME ] || \
2733 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2735 cancel_lru_locks osc
2736 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2739 run_test 39f "create, stat, sleep, utime, stat ================="
2743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2744 echo hello >> $DIR1/$tfile
2745 local mtime1=`stat -c %Y $DIR1/$tfile`
2748 chmod o+r $DIR1/$tfile
2750 for (( i=0; i < 2; i++ )) ; do
2751 local mtime2=`stat -c %Y $DIR1/$tfile`
2752 [ "$mtime1" = "$mtime2" ] || \
2753 error "lost mtime: $mtime2, should be $mtime1"
2755 cancel_lru_locks osc
2756 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2759 run_test 39g "write, chmod, stat ==============================="
2763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2768 echo hello >> $DIR1/$tfile
2769 local mtime1=`stat -c %Y $DIR1/$tfile`
2771 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2773 if [ "$d1" != "$d2" ]; then
2774 echo "write and touch not within one second"
2776 for (( i=0; i < 2; i++ )) ; do
2777 local mtime2=`stat -c %Y $DIR1/$tfile`
2778 [ "$mtime2" = $TEST_39_MTIME ] || \
2779 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2781 cancel_lru_locks osc
2782 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2786 run_test 39h "write, utime within one second, stat ============="
2789 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2793 echo hello >> $DIR1/$tfile
2794 local mtime1=`stat -c %Y $DIR1/$tfile`
2796 mv $DIR1/$tfile $DIR1/$tfile-1
2798 for (( i=0; i < 2; i++ )) ; do
2799 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2801 [ "$mtime1" = "$mtime2" ] || \
2802 error "lost mtime: $mtime2, should be $mtime1"
2804 cancel_lru_locks osc
2805 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2808 run_test 39i "write, rename, stat =============================="
2811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2812 start_full_debug_logging
2816 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2817 lctl set_param fail_loc=0x80000412
2818 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2819 error "multiop failed"
2821 local mtime1=`stat -c %Y $DIR1/$tfile`
2823 mv $DIR1/$tfile $DIR1/$tfile-1
2825 kill -USR1 $multipid
2826 wait $multipid || error "multiop close failed"
2828 for (( i=0; i < 2; i++ )) ; do
2829 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2830 [ "$mtime1" = "$mtime2" ] ||
2831 error "mtime is lost on close: $mtime2, " \
2834 cancel_lru_locks osc
2835 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2837 lctl set_param fail_loc=0
2838 stop_full_debug_logging
2840 run_test 39j "write, rename, close, stat ======================="
2843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2847 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2849 local mtime1=`stat -c %Y $DIR1/$tfile`
2851 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2853 kill -USR1 $multipid
2854 wait $multipid || error "multiop close failed"
2856 for (( i=0; i < 2; i++ )) ; do
2857 local mtime2=`stat -c %Y $DIR1/$tfile`
2859 [ "$mtime2" = $TEST_39_MTIME ] || \
2860 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2862 cancel_lru_locks osc
2863 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2866 run_test 39k "write, utime, close, stat ========================"
2868 # this should be set to future
2869 TEST_39_ATIME=`date -d "1 year" +%s`
2872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2873 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2874 local atime_diff=$(do_facet $SINGLEMDS \
2875 lctl get_param -n mdd.*MDT0000*.atime_diff)
2879 # test setting directory atime to future
2880 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2881 local atime=$(stat -c %X $DIR/$tdir)
2882 [ "$atime" = $TEST_39_ATIME ] || \
2883 error "atime is not set to future: $atime, $TEST_39_ATIME"
2885 # test setting directory atime from future to now
2886 local d1=$(date +%s)
2888 local d2=$(date +%s)
2890 cancel_lru_locks mdc
2891 atime=$(stat -c %X $DIR/$tdir)
2892 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2893 error "atime is not updated from future: $atime, $d1<atime<$d2"
2895 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2898 # test setting directory atime when now > dir atime + atime_diff
2902 cancel_lru_locks mdc
2903 atime=$(stat -c %X $DIR/$tdir)
2904 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2905 error "atime is not updated : $atime, should be $d2"
2907 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2910 # test not setting directory atime when now < dir atime + atime_diff
2912 cancel_lru_locks mdc
2913 atime=$(stat -c %X $DIR/$tdir)
2914 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2915 error "atime is updated to $atime, should remain $d1<atime<$d2"
2917 do_facet $SINGLEMDS \
2918 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2920 run_test 39l "directory atime update ==========================="
2923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2926 local far_past_mtime=$(date -d "May 29 1953" +%s)
2927 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2929 touch -m -d @$far_past_mtime $DIR1/$tfile
2930 touch -a -d @$far_past_atime $DIR1/$tfile
2932 for (( i=0; i < 2; i++ )) ; do
2933 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2934 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2935 error "atime or mtime set incorrectly"
2937 cancel_lru_locks osc
2938 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2941 run_test 39m "test atime and mtime before 1970"
2944 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2945 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2946 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2948 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2952 small_write $DIR/f41 18
2954 run_test 41 "test small file write + fstat ====================="
2956 count_ost_writes() {
2957 lctl get_param -n osc.*.stats |
2958 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2965 BG_DIRTY_RATIO_SAVE=10
2966 MAX_BG_DIRTY_RATIO=25
2970 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2971 # dirty_ratio, dirty_background_ratio
2972 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2973 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2974 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2975 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2977 # if file not here, we are a 2.4 kernel
2978 kill -CONT `pidof kupdated`
2983 # setup the trap first, so someone cannot exit the test at the
2984 # exact wrong time and mess up a machine
2985 trap start_writeback EXIT
2986 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2987 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2988 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2989 sysctl -w vm.dirty_writeback_centisecs=0
2990 sysctl -w vm.dirty_writeback_centisecs=0
2991 # save and increase /proc/sys/vm/dirty_ratio
2992 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2993 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2994 # save and increase /proc/sys/vm/dirty_background_ratio
2995 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2996 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2998 # if file not here, we are a 2.4 kernel
2999 kill -STOP `pidof kupdated`
3003 # ensure that all stripes have some grant before we test client-side cache
3005 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3006 dd if=/dev/zero of=$i bs=4k count=1
3011 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3012 # file truncation, and file removal.
3014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3016 cancel_lru_locks osc
3018 sync; sleep 1; sync # just to be safe
3019 BEFOREWRITES=`count_ost_writes`
3020 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3021 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3022 AFTERWRITES=`count_ost_writes`
3023 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3024 error "$BEFOREWRITES < $AFTERWRITES"
3027 run_test 42a "ensure that we don't flush on close =============="
3030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3032 cancel_lru_locks osc
3035 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3036 BEFOREWRITES=`count_ost_writes`
3037 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3038 AFTERWRITES=`count_ost_writes`
3039 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3040 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3042 BEFOREWRITES=`count_ost_writes`
3043 sync || error "sync: $?"
3044 AFTERWRITES=`count_ost_writes`
3045 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3046 error "$BEFOREWRITES < $AFTERWRITES on sync"
3048 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3052 run_test 42b "test destroy of file with cached dirty data ======"
3054 # if these tests just want to test the effect of truncation,
3055 # they have to be very careful. consider:
3056 # - the first open gets a {0,EOF}PR lock
3057 # - the first write conflicts and gets a {0, count-1}PW
3058 # - the rest of the writes are under {count,EOF}PW
3059 # - the open for truncate tries to match a {0,EOF}PR
3060 # for the filesize and cancels the PWs.
3061 # any number of fixes (don't get {0,EOF} on open, match
3062 # composite locks, do smarter file size management) fix
3063 # this, but for now we want these tests to verify that
3064 # the cancellation with truncate intent works, so we
3065 # start the file with a full-file pw lock to match against
3066 # until the truncate.
3071 cancel_lru_locks osc
3073 # prime the file with 0,EOF PW to match
3077 # now the real test..
3078 dd if=/dev/zero of=$file bs=1024 count=100
3079 BEFOREWRITES=`count_ost_writes`
3080 $TRUNCATE $file $offset
3081 cancel_lru_locks osc
3082 AFTERWRITES=`count_ost_writes`
3087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3089 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3090 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3093 run_test 42c "test partial truncate of file with cached dirty data"
3096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3098 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3099 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3102 run_test 42d "test complete truncate of file with cached dirty data"
3104 test_42e() { # bug22074
3105 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3106 local TDIR=$DIR/${tdir}e
3107 local pagesz=$(page_size)
3108 local pages=16 # hardcoded 16 pages, don't change it.
3109 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3110 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3114 test_mkdir -p $DIR/${tdir}e
3115 $SETSTRIPE -c 1 $TDIR
3116 createmany -o $TDIR/f $files
3118 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3120 # we assume that with $OSTCOUNT files, at least one of them will
3121 # be allocated on OST0.
3122 warmup_files=$((OSTCOUNT * max_dirty_mb))
3123 createmany -o $TDIR/w $warmup_files
3125 # write a large amount of data into one file and sync, to get good
3126 # avail_grant number from OST.
3127 for ((i=0; i<$warmup_files; i++)); do
3128 idx=$($GETSTRIPE -i $TDIR/w$i)
3129 [ $idx -ne 0 ] && continue
3130 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3133 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3135 $LCTL get_param $proc_osc0/cur_dirty_bytes
3136 $LCTL get_param $proc_osc0/cur_grant_bytes
3138 # create as much dirty pages as we can while not to trigger the actual
3139 # RPCs directly. but depends on the env, VFS may trigger flush during this
3140 # period, hopefully we are good.
3141 for ((i=0; i<$warmup_files; i++)); do
3142 idx=$($GETSTRIPE -i $TDIR/w$i)
3143 [ $idx -ne 0 ] && continue
3144 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3146 $LCTL get_param $proc_osc0/cur_dirty_bytes
3147 $LCTL get_param $proc_osc0/cur_grant_bytes
3149 # perform the real test
3150 $LCTL set_param $proc_osc0/rpc_stats 0
3151 for ((;i<$files; i++)); do
3152 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3153 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3156 $LCTL get_param $proc_osc0/rpc_stats
3159 local have_ppr=false
3160 $LCTL get_param $proc_osc0/rpc_stats |
3161 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3162 # skip lines until we are at the RPC histogram data
3163 [ "$PPR" == "pages" ] && have_ppr=true && continue
3164 $have_ppr || continue
3166 # we only want the percent stat for < 16 pages
3167 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3169 percent=$((percent + WPCT))
3170 if [ $percent -gt 15 ]; then
3171 error "less than 16-pages write RPCs" \
3178 run_test 42e "verify sub-RPC writes are not done synchronously"
3181 test_mkdir -p $DIR/$tdir
3182 cp -p /bin/ls $DIR/$tdir/$tfile
3183 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3185 # give multiop a chance to open
3188 $DIR/$tdir/$tfile && error || true
3191 run_test 43 "execution of file opened for write should return -ETXTBSY"
3194 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3195 test_mkdir -p $DIR/$tdir
3196 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3197 cp -p multiop $DIR/$tdir/multiop
3198 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3201 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3202 kill -USR1 $MULTIOP_PID || return 2
3203 wait $MULTIOP_PID || return 3
3206 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3210 test_mkdir -p $DIR/$tdir
3211 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3212 cp -p multiop $DIR/$tdir/multiop
3213 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3216 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3217 kill -USR1 $MULTIOP_PID || return 2
3218 wait $MULTIOP_PID || return 3
3221 run_test 43b "truncate of file being executed should return -ETXTBSY"
3224 local testdir="$DIR/$tdir"
3225 test_mkdir -p $DIR/$tdir
3227 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3228 ( cd $testdir && md5sum -c)
3230 run_test 43c "md5sum of copy into lustre========================"
3233 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3234 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3235 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3237 run_test 44 "zero length read from a sparse stripe ============="
3240 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3242 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3243 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3244 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3246 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3247 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3250 OFFSETS="0 $((stride/2)) $((stride-1))"
3251 for offset in $OFFSETS ; do
3252 for i in `seq 0 $((nstripe-1))`; do
3253 local GLOBALOFFSETS=""
3254 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3255 local myfn=$DIR/d44a-$size
3256 echo "--------writing $myfn at $size"
3257 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3258 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3259 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3260 || error "ll_sparseness_verify $GLOBALOFFSETS"
3262 for j in `seq 0 $((nstripe-1))`; do
3263 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3264 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3265 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3267 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3268 || error "ll_sparseness_verify $GLOBALOFFSETS"
3273 run_test 44a "test sparse pwrite ==============================="
3277 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3283 before=`dirty_osc_total`
3284 echo executing "\"$*\""
3286 after=`dirty_osc_total`
3287 echo before $before, after $after
3290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3292 # Obtain grants from OST if it supports it
3293 echo blah > ${f}_grant
3296 do_dirty_record "echo blah > $f"
3297 [ $before -eq $after ] && error "write wasn't cached"
3298 do_dirty_record "> $f"
3299 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3300 do_dirty_record "echo blah > $f"
3301 [ $before -eq $after ] && error "write wasn't cached"
3302 do_dirty_record "sync"
3303 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3304 do_dirty_record "echo blah > $f"
3305 [ $before -eq $after ] && error "write wasn't cached"
3306 do_dirty_record "cancel_lru_locks osc"
3307 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3310 run_test 45 "osc io page accounting ============================"
3312 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3313 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3314 # objects offset and an assert hit when an rpc was built with 1023's mapped
3315 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3321 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3323 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3324 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3328 run_test 46 "dirtying a previously written page ================"
3330 # test_47 is removed "Device nodes check" is moved to test_28
3332 test_48a() { # bug 2399
3333 check_kernel_version 34 || return 0
3334 test_mkdir -p $DIR/$tdir
3336 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3337 test_mkdir $DIR/$tdir || error "recreate directory failed"
3338 touch foo || error "'touch foo' failed after recreating cwd"
3339 test_mkdir $DIR/$tdir/bar ||
3340 error "'mkdir foo' failed after recreating cwd"
3341 if check_kernel_version 44; then
3342 touch .foo || error "'touch .foo' failed after recreating cwd"
3343 test_mkdir $DIR/$tdir/.bar ||
3344 error "'mkdir .foo' failed after recreating cwd"
3346 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3347 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3348 cd . || error "'cd .' failed after recreating cwd"
3349 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3350 rmdir . && error "'rmdir .' worked after recreating cwd"
3351 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3352 cd .. || error "'cd ..' failed after recreating cwd"
3354 run_test 48a "Access renamed working dir (should return errors)="
3356 test_48b() { # bug 2399
3357 check_kernel_version 34 || return 0
3359 test_mkdir -p $DIR/$tdir
3361 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3362 touch foo && error "'touch foo' worked after removing cwd"
3363 test_mkdir $DIR/$tdir/foo &&
3364 error "'mkdir foo' worked after removing cwd"
3365 if check_kernel_version 44; then
3366 touch .foo && error "'touch .foo' worked after removing cwd"
3367 test_mkdir $DIR/$tdir/.foo &&
3368 error "'mkdir .foo' worked after removing cwd"
3370 ls . > /dev/null && error "'ls .' worked after removing cwd"
3371 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3372 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3373 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3374 rmdir . && error "'rmdir .' worked after removing cwd"
3375 ln -s . foo && error "'ln -s .' worked after removing cwd"
3376 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3378 run_test 48b "Access removed working dir (should return errors)="
3380 test_48c() { # bug 2350
3381 check_kernel_version 36 || return 0
3382 #lctl set_param debug=-1
3385 test_mkdir -p $DIR/$tdir/dir
3387 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3388 $TRACE touch foo && error "touch foo worked after removing cwd"
3389 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3390 if check_kernel_version 44; then
3391 touch .foo && error "touch .foo worked after removing cwd"
3392 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3394 $TRACE ls . && error "'ls .' worked after removing cwd"
3395 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3396 is_patchless || ( $TRACE cd . &&
3397 error "'cd .' worked after removing cwd" )
3398 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3399 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3400 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3401 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3403 run_test 48c "Access removed working subdir (should return errors)"
3405 test_48d() { # bug 2350
3406 check_kernel_version 36 || return 0
3407 #lctl set_param debug=-1
3410 test_mkdir -p $DIR/$tdir/dir
3412 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3413 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3414 $TRACE touch foo && error "'touch foo' worked after removing parent"
3415 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3416 if check_kernel_version 44; then
3417 touch .foo && error "'touch .foo' worked after removing parent"
3419 error "mkdir .foo worked after removing parent"
3421 $TRACE ls . && error "'ls .' worked after removing parent"
3422 $TRACE ls .. && error "'ls ..' worked after removing parent"
3423 is_patchless || ( $TRACE cd . &&
3424 error "'cd .' worked after recreate parent" )
3425 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3426 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3427 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3428 is_patchless || ( $TRACE cd .. &&
3429 error "'cd ..' worked after removing parent" || true )
3431 run_test 48d "Access removed parent subdir (should return errors)"
3433 test_48e() { # bug 4134
3434 check_kernel_version 41 || return 0
3435 #lctl set_param debug=-1
3438 test_mkdir -p $DIR/$tdir/dir
3440 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3441 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3442 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3443 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3444 # On a buggy kernel addition of "touch foo" after cd .. will
3445 # produce kernel oops in lookup_hash_it
3446 touch ../foo && error "'cd ..' worked after recreate parent"
3448 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3450 run_test 48e "Access to recreated parent subdir (should return errors)"
3452 test_49() { # LU-1030
3453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3454 # get ost1 size - lustre-OST0000
3455 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3456 # write 800M at maximum
3457 [ $ost1_size -gt 819200 ] && ost1_size=819200
3459 lfs setstripe -c 1 -i 0 $DIR/$tfile
3460 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3463 # change max_pages_per_rpc while writing the file
3464 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3465 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3466 # loop until dd process exits
3467 while ps ax -opid | grep -wq $dd_pid; do
3468 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3469 sleep $((RANDOM % 5 + 1))
3471 # restore original max_pages_per_rpc
3472 $LCTL set_param $osc1_mppc=$orig_mppc
3473 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3475 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3479 test_mkdir $DIR/$tdir
3481 ls /proc/$$/cwd || error
3483 run_test 50 "special situations: /proc symlinks ==============="
3485 test_51a() { # was test_51
3486 # bug 1516 - create an empty entry right after ".." then split dir
3487 test_mkdir $DIR/$tdir
3488 touch $DIR/$tdir/foo
3489 $MCREATE $DIR/$tdir/bar
3491 createmany -m $DIR/$tdir/longfile 201
3493 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3494 $MCREATE $DIR/$tdir/longfile$FNUM
3499 ls -l $DIR/$tdir > /dev/null || error
3501 run_test 51a "special situations: split htree with empty entry =="
3503 export NUMTEST=70000
3505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3506 local BASE=$DIR/$tdir
3510 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3511 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3512 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3515 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3516 echo "reduced count to $NUMTEST due to inodes"
3518 # need to check free space for the directories as well
3519 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3520 numfree=$((blkfree / 4))
3521 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3522 echo "reduced count to $NUMTEST due to blocks"
3524 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3525 echo "failed" > $BASE/fnum
3527 run_test 51b "exceed 64k subdirectory nlink limit"
3529 test_51ba() { # LU-993
3530 local BASE=$DIR/$tdir
3531 # unlink all but 100 subdirectories, then check it still works
3533 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3535 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3536 local DELETE=$((NUMTEST - LEFT))
3538 # continue on to run this test even if 51b didn't finish,
3539 # just to delete the many subdirectories created.
3540 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3542 # for ldiskfs the nlink count should be 1, but this is OSD specific
3543 # and so this is listed for informational purposes only
3544 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3545 unlinkmany -d $BASE/d $DELETE
3548 if [ $RC -ne 0 ]; then
3549 if [ "$NUMPREV" == "failed" ]; then
3550 skip "previous setup failed"
3553 error "unlink of first $DELETE subdirs failed"
3558 echo "nlink between: $(stat -c %h $BASE)"
3559 # trim the first line of ls output
3560 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3561 [ $FOUND -ne $LEFT ] &&
3562 error "can't find subdirs: found only $FOUND/$LEFT"
3564 unlinkmany -d $BASE/d $DELETE $LEFT ||
3565 error "unlink of second $LEFT subdirs failed"
3566 # regardless of whether the backing filesystem tracks nlink accurately
3567 # or not, the nlink count shouldn't be more than "." and ".." here
3568 local AFTER=$(stat -c %h $BASE)
3569 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3570 echo "nlink after: $AFTER"
3572 run_test 51ba "verify nlink for many subdirectory cleanup"
3575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3576 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3577 test_mkdir -p $DIR/$tdir
3578 createmany -o $DIR/$tdir/t- 1000
3579 $GETSTRIPE $DIR/$tdir > $TMP/files
3580 for N in `seq 0 $((OSTCOUNT - 1))`; do
3581 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3582 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3583 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3585 unlinkmany $DIR/$tdir/t- 1000
3588 for N in `seq 1 $((OSTCOUNT - 1))`; do
3589 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3590 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3591 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3592 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3594 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3595 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3596 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3597 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3601 run_test 51d "check object distribution ===================="
3604 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3605 test_mkdir -p $DIR/$tdir
3606 touch $DIR/$tdir/foo
3607 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3608 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3609 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3610 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3611 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3613 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3614 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3615 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3617 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3618 cp -r $DIR/$tdir /tmp/
3619 rm -fr $DIR/$tdir || error "cleanup rm failed"
3621 run_test 52a "append-only flag test (should return errors) ====="
3624 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3625 test_mkdir -p $DIR/$tdir
3626 touch $DIR/$tdir/foo
3627 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3628 cat test > $DIR/$tdir/foo && error "cat test worked"
3629 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3630 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3631 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3633 echo foo >> $DIR/$tdir/foo && error "echo worked"
3634 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3635 [ -f $DIR/$tdir/foo ] || error
3636 [ -f $DIR/$tdir/foo_ren ] && error
3637 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3639 chattr -i $DIR/$tdir/foo || error "chattr failed"
3641 rm -fr $DIR/$tdir || error
3643 run_test 52b "immutable flag test (should return errors) ======="
3646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3647 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3648 remote_ost_nodsh && skip "remote OST with nodsh" && return
3658 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3659 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3660 param=`echo ${value[0]} | cut -d "=" -f1`
3661 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3662 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3663 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3664 node=$(facet_active_host ost$((ostnum+1)))
3665 param="obdfilter.$ostname.last_id"
3666 ost_last=$(do_node $node lctl get_param -n $param | head -n 1)
3667 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3668 if [ $ost_last != $mds_last ]; then
3669 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3673 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3676 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3677 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3678 $SOCKETSERVER $DIR/socket
3679 $SOCKETCLIENT $DIR/socket || error
3680 $MUNLINK $DIR/socket
3682 run_test 54a "unix domain socket test =========================="
3688 dd if=/dev/zero of=$f bs=`page_size` count=1
3690 run_test 54b "char device works in lustre ======================"
3693 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3694 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3695 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3697 for i in `seq 3 7`; do
3698 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3709 loopdev="$DIR/loop54c"
3712 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3713 mknod $loopdev b 7 $LOOPNUM
3714 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3715 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3716 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3717 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3719 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3720 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3722 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3727 run_test 54c "block device works in lustre ====================="
3733 [ "$string" = `echo $string > $f | cat $f` ] || error
3735 run_test 54d "fifo device works in lustre ======================"
3738 check_kernel_version 46 || return 0
3741 cp -aL /dev/console $f
3742 echo $string > $f || error
3744 run_test 54e "console/tty device works in lustre ======================"
3746 #The test_55 used to be iopen test and it was removed by bz#24037.
3747 #run_test 55 "check iopen_connect_dentry() ======================"
3749 test_56a() { # was test_56
3752 test_mkdir $DIR/$tdir
3753 test_mkdir $DIR/$tdir/dir
3755 NUMFILESx2=$(($NUMFILES * 2))
3756 for i in `seq 1 $NUMFILES` ; do
3757 touch $DIR/$tdir/file$i
3758 touch $DIR/$tdir/dir/file$i
3761 # test lfs getstripe with --recursive
3762 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3763 [ $FILENUM -eq $NUMFILESx2 ] ||
3764 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3765 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3766 [ $FILENUM -eq $NUMFILES ] ||
3767 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3768 echo "$GETSTRIPE --recursive passed."
3770 # test lfs getstripe with file instead of dir
3771 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3772 [ $FILENUM -eq 1 ] || error \
3773 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3774 echo "$GETSTRIPE file1 passed."
3776 #test lfs getstripe with --verbose
3777 [ `$GETSTRIPE --verbose $DIR/$tdir |
3778 grep -c lmm_magic` -eq $NUMFILES ] ||
3779 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3780 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3781 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3782 echo "$GETSTRIPE --verbose passed."
3784 #test lfs getstripe with --obd
3785 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3786 grep -q "unknown obduuid" ||
3787 error "$GETSTRIPE --obd wrong_uuid should return error message"
3789 [ "$OSTCOUNT" -lt 2 ] &&
3790 skip_env "skipping other $GETSTRIPE --obd test" && return
3793 OBDUUID=$(ostuuid_from_index $OSTIDX)
3794 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3795 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3796 [ $FOUND -eq $FILENUM ] ||
3797 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3798 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3799 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3800 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3801 error "$GETSTRIPE --obd: should not show file on other obd"
3802 echo "$GETSTRIPE --obd passed"
3804 run_test 56a "check $GETSTRIPE"
3809 local LOCAL_NUMFILES="$1"
3810 local LOCAL_NUMDIRS="$2"
3811 local MKDIR_PARAMS="$3"
3813 if [ ! -d "$TDIR" ] ; then
3815 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3816 for i in `seq 1 $LOCAL_NUMFILES` ; do
3819 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3820 test_mkdir $TDIR/dir$i
3821 for j in `seq 1 $LOCAL_NUMFILES` ; do
3822 touch $TDIR/dir$i/file$j
3828 setup_56_special() {
3832 if [ ! -e "$TDIR/loop1b" ] ; then
3833 for i in `seq 1 $LOCAL_NUMFILES` ; do
3834 mknod $TDIR/loop${i}b b 7 $i
3835 mknod $TDIR/null${i}c c 1 3
3836 ln -s $TDIR/file1 $TDIR/link${i}l
3838 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3839 mknod $TDIR/dir$i/loop${i}b b 7 $i
3840 mknod $TDIR/dir$i/null${i}c c 1 3
3841 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3850 setup_56 $NUMFILES $NUMDIRS
3852 EXPECTED=$(($NUMDIRS + 2))
3853 # test lfs find with -name
3854 for i in $(seq 1 $NUMFILES) ; do
3855 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3856 [ $NUMS -eq $EXPECTED ] ||
3857 error "lfs find -name \"*$i\" $TDIR wrong: "\
3858 "found $NUMS, expected $EXPECTED"
3861 run_test 56g "check lfs find -name ============================="
3867 setup_56 $NUMFILES $NUMDIRS
3869 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3870 # test lfs find with ! -name
3871 for i in $(seq 1 $NUMFILES) ; do
3872 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3873 [ $NUMS -eq $EXPECTED ] ||
3874 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3875 "found $NUMS, expected $EXPECTED"
3878 run_test 56h "check lfs find ! -name ============================="
3882 test_mkdir -p $DIR/$tdir
3883 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3884 CMD="$LFIND -ost $UUID $DIR/$tdir"
3886 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3888 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3892 setup_56_special $NUMFILES $NUMDIRS
3894 EXPECTED=$((NUMDIRS + 1))
3895 CMD="$LFIND -type d $TDIR"
3896 NUMS=$($CMD | wc -l)
3897 [ $NUMS -eq $EXPECTED ] ||
3898 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3900 run_test 56j "check lfs find -type d ============================="
3904 setup_56_special $NUMFILES $NUMDIRS
3906 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3907 CMD="$LFIND -type f $TDIR"
3908 NUMS=$($CMD | wc -l)
3909 [ $NUMS -eq $EXPECTED ] ||
3910 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3912 run_test 56k "check lfs find -type f ============================="
3916 setup_56_special $NUMFILES $NUMDIRS
3918 EXPECTED=$((NUMDIRS + NUMFILES))
3919 CMD="$LFIND -type b $TDIR"
3920 NUMS=$($CMD | wc -l)
3921 [ $NUMS -eq $EXPECTED ] ||
3922 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3924 run_test 56l "check lfs find -type b ============================="
3928 setup_56_special $NUMFILES $NUMDIRS
3930 EXPECTED=$((NUMDIRS + NUMFILES))
3931 CMD="$LFIND -type c $TDIR"
3932 NUMS=$($CMD | wc -l)
3933 [ $NUMS -eq $EXPECTED ] ||
3934 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3936 run_test 56m "check lfs find -type c ============================="
3940 setup_56_special $NUMFILES $NUMDIRS
3942 EXPECTED=$((NUMDIRS + NUMFILES))
3943 CMD="$LFIND -type l $TDIR"
3944 NUMS=$($CMD | wc -l)
3945 [ $NUMS -eq $EXPECTED ] ||
3946 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3948 run_test 56n "check lfs find -type l ============================="
3952 setup_56 $NUMFILES $NUMDIRS
3954 utime $TDIR/file1 > /dev/null || error "utime (1)"
3955 utime $TDIR/file2 > /dev/null || error "utime (2)"
3956 utime $TDIR/dir1 > /dev/null || error "utime (3)"