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:-""}
52 export NAME=${NAME:-local}
59 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
60 . $LUSTRE/tests/test-framework.sh
62 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
65 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 24v 27m 36f 36g 36h 51b 60c 63 64b 68 71 73 77f 78 101a 103 115 120g 124b"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 if [ "$ONLY" == "cleanup" ]; then
97 check_and_setup_lustre
102 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
103 awk '{gsub(/_UUID/,""); print $1}' | head -1)
104 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
105 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
106 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
107 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
108 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
109 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
111 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
112 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
113 rm -rf $DIR/[Rdfs][0-9]*
115 # $RUNAS_ID may get set incorrectly somewhere else
116 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
118 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
122 if [ "${ONLY}" = "MOUNT" ] ; then
123 echo "Lustre is up, please go on"
127 echo "preparing for tests involving mounts"
128 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
130 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
131 echo # add a newline after mke2fs.
135 OLDDEBUG="`lctl get_param -n debug 2> /dev/null`"
136 lctl set_param debug=-1 2> /dev/null || true
139 $CHECKSTAT -t file $DIR/$tfile || error
141 $CHECKSTAT -a $DIR/$tfile || error
143 run_test 0 "touch .../$tfile ; rm .../$tfile ====================="
146 chmod 0755 $DIR || error
147 $CHECKSTAT -p 0755 $DIR || error
149 run_test 0b "chmod 0755 $DIR ============================="
152 $LCTL get_param mdc.*.import | grep "state: FULL" || error "import not FULL"
153 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" || error "bad target"
155 run_test 0c "check import proc ============================="
158 test_mkdir -p $DIR/$tdir
159 test_mkdir -p $DIR/$tdir/d2
160 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
161 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
163 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
168 $CHECKSTAT -a $DIR/$tdir || error
170 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
173 test_mkdir $DIR/$tdir
174 touch $DIR/$tdir/$tfile
175 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
177 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
181 $CHECKSTAT -a $DIR/$tdir || error
183 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
186 test_mkdir -p $DIR/$tdir
187 $CHECKSTAT -t dir $DIR/$tdir || error
189 run_test 3a "mkdir .../d3 ======================================"
192 if [ ! -d $DIR/$tdir ]; then
195 touch $DIR/$tdir/$tfile
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error
198 run_test 3b "touch .../d3/f ===================================="
202 $CHECKSTAT -a $DIR/$tdir || error
204 run_test 3c "rm -r .../d3 ======================================"
207 test_mkdir -p $DIR/$tdir
208 $CHECKSTAT -t dir $DIR/$tdir || error
210 run_test 4a "mkdir .../d4 ======================================"
213 if [ ! -d $DIR/$tdir ]; then
214 test_mkdir $DIR/$tdir
216 test_mkdir $DIR/$tdir/d2
218 $CHECKSTAT -t dir $DIR/$tdir/d2 || error
220 run_test 4b "mkdir .../d4/d2 ==================================="
223 test_mkdir $DIR/$tdir
224 test_mkdir $DIR/$tdir/d2
225 chmod 0707 $DIR/$tdir/d2
226 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error
228 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
232 chmod 0666 $DIR/$tfile || error
233 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
235 run_test 6a "touch .../f6a; chmod .../f6a ======================"
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
239 if [ ! -f $DIR/$tfile ]; then
241 chmod 0666 $DIR/$tfile
243 $RUNAS chmod 0444 $DIR/$tfile && error
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile || error
246 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
249 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
251 chown $RUNAS_ID $DIR/$tfile || error
252 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
254 run_test 6c "touch .../f6c; chown .../f6c ======================"
257 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
258 if [ ! -f $DIR/$tfile ]; then
260 chown $RUNAS_ID $DIR/$tfile
262 $RUNAS chown $UID $DIR/$tfile && error
263 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile || error
265 run_test 6d "$RUNAS chown .../f6c (should return error) =="
268 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
270 chgrp $RUNAS_ID $DIR/$tfile || error
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
273 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 if [ ! -f $DIR/$tfile ]; then
279 chgrp $RUNAS_ID $DIR/$tfile
281 $RUNAS chgrp $UID $DIR/$tfile && error
282 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile || error
284 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
287 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
288 test_mkdir $DIR/$tdir || error
289 chmod 777 $DIR/$tdir || error
290 $RUNAS mkdir $DIR/$tdir/d || error
291 chmod g+s $DIR/$tdir/d || error
292 test_mkdir $DIR/$tdir/d/subdir
293 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir || error
295 run_test 6g "Is new dir in sgid dir inheriting group?"
297 test_6h() { # bug 7331
298 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
299 touch $DIR/$tfile || error "touch failed"
300 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
301 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
303 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile || error
305 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
308 test_mkdir $DIR/$tdir
309 $MCREATE $DIR/$tdir/$tfile
310 chmod 0666 $DIR/$tdir/$tfile
311 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
313 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
316 if [ ! -d $DIR/$tdir ]; then
319 $MCREATE $DIR/$tdir/$tfile
320 echo -n foo > $DIR/$tdir/$tfile
321 [ "`cat $DIR/$tdir/$tfile`" = "foo" ] || error
322 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error
324 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
327 test_mkdir $DIR/$tdir
328 touch $DIR/$tdir/$tfile
329 chmod 0666 $DIR/$tdir/$tfile
330 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile || error
332 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
335 test_mkdir $DIR/$tdir
336 test_mkdir $DIR/$tdir/d2
337 test_mkdir $DIR/$tdir/d2/d3
338 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error
340 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
343 test_mkdir $DIR/$tdir
344 test_mkdir $DIR/$tdir/d2
345 touch $DIR/$tdir/d2/$tfile
346 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile || error
348 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
351 test_mkdir $DIR/$tdir
352 test_mkdir $DIR/$tdir/d2
353 chmod 0666 $DIR/$tdir/d2
354 chmod 0705 $DIR/$tdir/d2
355 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 || error
357 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
360 test_mkdir $DIR/$tdir
361 touch $DIR/$tdir/$tfile
362 chmod 0666 $DIR/$tdir/$tfile
363 chmod 0654 $DIR/$tdir/$tfile
364 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile || error
366 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
369 test_mkdir $DIR/$tdir
370 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
372 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile || error
374 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error
382 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
385 test_mkdir $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
388 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 || error
390 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
393 test_mkdir $DIR/$tdir
394 touch $DIR/$tdir/$tfile
395 rm -rf $DIR/$tdir/$tfile
396 $CHECKSTAT -a $DIR/$tdir/$tfile || error
398 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
401 test_mkdir -p $DIR/$tdir
402 touch $DIR/$tdir/$tfile
403 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
405 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist || error
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist || error
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle || error
417 $CHECKSTAT -fa $DIR/$tdir/l-dangle || error
418 rm -f $DIR/$tdir/l-dangle
419 $CHECKSTAT -a $DIR/$tdir/l-dangle || error
421 run_test 17b "symlinks: create, remove (dangling) =============="
423 test_17c() { # bug 3440 - don't save failed open RPC for replay
424 test_mkdir -p $DIR/$tdir
425 ln -s foo $DIR/$tdir/$tfile
426 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
428 run_test 17c "symlinks: open dangling (should return error) ===="
431 test_mkdir -p $DIR/$tdir
432 ln -s foo $DIR/$tdir/$tfile
433 touch $DIR/$tdir/$tfile || error "creating to new symlink"
435 run_test 17d "symlinks: create dangling ========================"
438 test_mkdir -p $DIR/$tdir
439 local foo=$DIR/$tdir/$tfile
440 ln -s $foo $foo || error "create symlink failed"
441 ls -l $foo || error "ls -l failed"
442 ls $foo && error "ls not failed" || true
444 run_test 17e "symlinks: create recursive symlink (should return error) ===="
447 test_mkdir -p $DIR/d17f
448 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
449 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
450 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
453 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
456 run_test 17f "symlinks: long and very long symlink name ========================"
458 # str_repeat(S, N) generate a string that is string S repeated N times
463 while [ $((n -= 1)) -ge 0 ]; do
469 # Long symlinks and LU-2241
471 test_mkdir -p $DIR/$tdir
472 local TESTS="59 60 61 4094 4095"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
485 test_mkdir -p $DIR/$tdir
486 if [ $MDSCOUNT -gt 1 ]; then
487 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
491 $SETSTRIPE -c -1 $DIR/$tdir
492 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
493 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
494 touch $DIR/$tdir/$tfile || true
496 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
498 test_17i() { #bug 20018
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 test_mkdir -p $DIR/$tdir
501 local foo=$DIR/$tdir/$tfile
503 if [ $MDSCOUNT -gt 1 ]; then
504 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
508 ln -s $foo $foo || error "create symlink failed"
509 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
510 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
511 ls -l $foo && error "error not detected"
514 run_test 17i "don't panic on short symlink"
516 test_17k() { #bug 22301
517 rsync --help | grep -q xattr ||
518 skip_env "$(rsync --version| head -1) does not support xattrs"
519 test_mkdir -p $DIR/$tdir
520 test_mkdir -p $DIR/$tdir.new
521 touch $DIR/$tdir/$tfile
522 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
523 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
524 error "rsync failed with xattrs enabled"
526 run_test 17k "symlinks: rsync with xattrs enabled ========================="
528 test_17l() { # LU-279
530 touch $DIR/$tdir/$tfile
531 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
532 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
533 # -h to not follow symlinks. -m '' to list all the xattrs.
534 # grep to remove first line: '# file: $path'.
535 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
537 lgetxattr_size_check $path $xattr ||
538 error "lgetxattr_size_check $path $xattr failed"
542 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
546 local short_sym="0123456789"
547 local WDIR=$DIR/${tdir}m
554 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
555 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
556 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
558 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
559 skip "only for ldiskfs MDT" && return 0
563 # create a long symlink file
564 for ((i = 0; i < 4; ++i)); do
565 long_sym=${long_sym}${long_sym}
568 echo "create 512 short and long symlink files under $WDIR"
569 for ((i = 0; i < 256; ++i)); do
570 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
571 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
577 wait_delete_completed
579 echo "recreate the 512 symlink files with a shorter string"
580 for ((i = 0; i < 512; ++i)); do
581 # rewrite the symlink file with a shorter string
582 ln -sf ${long_sym} $WDIR/long-$i
583 ln -sf ${short_sym} $WDIR/short-$i
586 mds_index=$($LFS getstripe -M $WDIR)
587 mds_index=$((mds_index+1))
588 devname=$(mdsdevname $mds_index)
589 cmd="$E2FSCK -fnvd $devname"
591 echo "stop and checking mds${mds_index}: $cmd"
592 # e2fsck should not return error
593 stop mds${mds_index} -f
594 do_facet mds${mds_index} $cmd || rc=$?
596 start mds${mds_index} $devname $MDS_MOUNT_OPTS
597 df $MOUNT > /dev/null 2>&1
598 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
599 "short/long symlink MDT: rc=$rc"
602 run_test 17m "run e2fsck against MDT which contains short/long symlink"
604 check_fs_consistency_17n() {
610 for mdt_index in $(seq 1 $MDSCOUNT); do
611 devname=$(mdsdevname $mdt_index)
612 cmd="$E2FSCK -fnvd $devname"
614 echo "stop and checking mds${mdt_index}: $cmd"
615 # e2fsck should not return error
617 do_facet mds${mdt_index} $cmd || rc=$?
619 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
620 df $MOUNT > /dev/null 2>&1
621 [ $rc -ne 0 ] && break
629 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
630 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
631 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
633 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
634 skip "only for ldiskfs MDT" && return 0
636 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
639 for ((i=0; i<10; i++)); do
640 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
641 error "create remote dir error $i"
642 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
643 error "create files under remote dir failed $i"
646 check_fs_consistency_17n || error "e2fsck report error"
648 for ((i=0;i<10;i++)); do
649 rm -rf $DIR/$tdir/remote_dir_${i} ||
650 error "destroy remote dir error $i"
653 check_fs_consistency_17n || error "e2fsck report error"
655 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
661 run_test 18 "touch .../f ; ls ... =============================="
667 $CHECKSTAT -a $DIR/f19 || error
669 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
672 ls -l $DIR/f19 && error || true
674 run_test 19b "ls -l .../f19 (should return error) =============="
677 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
678 $RUNAS touch $DIR/f19 && error || true
680 run_test 19c "$RUNAS touch .../f19 (should return error) =="
683 cat $DIR/f19 && error || true
685 run_test 19d "cat .../f19 (should return error) =============="
697 $CHECKSTAT -a $DIR/f || error
699 run_test 20 "touch .../f ; ls -l ... ==========================="
703 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
704 ln -s dangle $DIR/d21/link
705 echo foo >> $DIR/d21/link
707 $CHECKSTAT -t link $DIR/d21/link || error
708 $CHECKSTAT -f -t file $DIR/d21/link || error
710 run_test 21 "write to dangling link ============================"
714 test_mkdir -p $DIR/$tdir
715 chown $RUNAS_ID:$RUNAS_GID $WDIR
716 (cd $WDIR || error "cd $WDIR failed";
717 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
719 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
720 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
721 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
723 run_test 22 "unpack tar archive as non-root user ==============="
727 test_mkdir -p $DIR/$tdir
728 local file=$DIR/$tdir/$tfile
730 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
731 openfile -f O_CREAT:O_EXCL $file &&
732 error "$file recreate succeeded" || true
734 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
736 test_23b() { # bug 18988
737 test_mkdir -p $DIR/$tdir
738 local file=$DIR/$tdir/$tfile
741 echo foo > $file || error "write filed"
742 echo bar >> $file || error "append filed"
743 $CHECKSTAT -s 8 $file || error "wrong size"
746 run_test 23b "O_APPEND check =========================="
749 echo '== rename sanity =============================================='
750 echo '-- same directory rename'
753 mv $DIR/R1/f $DIR/R1/g
754 $CHECKSTAT -t file $DIR/R1/g || error
756 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
761 mv $DIR/R2/f $DIR/R2/g
762 $CHECKSTAT -a $DIR/R2/f || error
763 $CHECKSTAT -t file $DIR/R2/g || error
765 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
770 mv $DIR/R3/f $DIR/R3/g
771 $CHECKSTAT -a $DIR/R3/f || error
772 $CHECKSTAT -t dir $DIR/R3/g || error
774 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
780 mrename $DIR/R4/f $DIR/R4/g
781 $CHECKSTAT -a $DIR/R4/f || error
782 $CHECKSTAT -t dir $DIR/R4/g || error
784 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
787 echo '-- cross directory renames --'
791 mv $DIR/R5a/f $DIR/R5b/g
792 $CHECKSTAT -a $DIR/R5a/f || error
793 $CHECKSTAT -t file $DIR/R5b/g || error
795 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
800 touch $DIR/R6a/f $DIR/R6b/g
801 mv $DIR/R6a/f $DIR/R6b/g
802 $CHECKSTAT -a $DIR/R6a/f || error
803 $CHECKSTAT -t file $DIR/R6b/g || error
805 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
810 test_mkdir $DIR/R7a/d
811 mv $DIR/R7a/d $DIR/R7b/e
812 $CHECKSTAT -a $DIR/R7a/d || error
813 $CHECKSTAT -t dir $DIR/R7b/e || error
815 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
820 test_mkdir $DIR/R8a/d
821 test_mkdir $DIR/R8b/e
822 mrename $DIR/R8a/d $DIR/R8b/e
823 $CHECKSTAT -a $DIR/R8a/d || error
824 $CHECKSTAT -t dir $DIR/R8b/e || error
826 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
829 echo "-- rename error cases"
833 mrename $DIR/R9/f $DIR/R9/a
834 $CHECKSTAT -t file $DIR/R9/f || error
835 $CHECKSTAT -t dir $DIR/R9/a || error
836 $CHECKSTAT -a $DIR/R9/a/f || error
838 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
842 mrename $DIR/R10/f $DIR/R10/g
843 $CHECKSTAT -t dir $DIR/R10 || error
844 $CHECKSTAT -a $DIR/R10/f || error
845 $CHECKSTAT -a $DIR/R10/g || error
847 run_test 24j "source does not exist ============================"
851 test_mkdir $DIR/R11a/d
853 mv $DIR/R11a/f $DIR/R11a/d
854 $CHECKSTAT -a $DIR/R11a/f || error
855 $CHECKSTAT -t file $DIR/R11a/d/f || error
857 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
859 # bug 2429 - rename foo foo foo creates invalid file
862 $MULTIOP $f OcNs || error
864 run_test 24l "Renaming a file to itself ========================"
868 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
869 # on ext3 this does not remove either the source or target files
870 # though the "expected" operation would be to remove the source
871 $CHECKSTAT -t file ${f} || error "${f} missing"
872 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
874 run_test 24m "Renaming a file to a hard link to itself ========="
878 # this stats the old file after it was renamed, so it should fail
882 $CHECKSTAT ${f}.rename
885 run_test 24n "Statting the old file after renaming (Posix rename 2)"
888 check_kernel_version 37 || return 0
889 test_mkdir -p $DIR/d24o
890 rename_many -s random -v -n 10 $DIR/d24o
892 run_test 24o "rename of files during htree split ==============="
897 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
898 mrename $DIR/R12a $DIR/R12b
899 $CHECKSTAT -a $DIR/R12a || error
900 $CHECKSTAT -t dir $DIR/R12b || error
901 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
902 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
904 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
909 DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
910 multiop_bg_pause $DIR/R13b D_c || return 1
913 mrename $DIR/R13a $DIR/R13b
914 $CHECKSTAT -a $DIR/R13a || error
915 $CHECKSTAT -t dir $DIR/R13b || error
916 DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
917 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
919 wait $MULTIPID || error "multiop close failed"
921 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
923 test_24r() { #bug 3789
925 test_mkdir $DIR/R14a/b
926 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
927 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
928 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
930 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
934 test_mkdir $DIR/R15a/b
935 test_mkdir $DIR/R15a/b/c
936 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
937 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
938 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
940 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
943 test_mkdir $DIR/R16a/b
944 test_mkdir $DIR/R16a/b/c
945 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
946 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
947 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
949 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
951 test_24u() { # bug12192
953 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
954 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
956 run_test 24u "create stripe file"
962 simple_cleanup_common() {
965 wait_delete_completed
968 max_pages_per_rpc() {
969 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
974 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
975 [ $FREE_INODES -lt $NRFILES ] && \
976 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
979 trap simple_cleanup_common EXIT
982 createmany -m $DIR/$tdir/$tfile $NRFILES
985 lctl set_param mdc.*.stats clear
987 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
990 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
991 # 8 bytes for name(filename is mostly 5 in this test) +
992 # 8 bytes for luda_type
993 # take into account of overhead in lu_dirpage header and end mark in
994 # each page, plus one in RPC_NUM calculation.
996 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
997 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
998 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
999 awk '/^mds_readpage/ {print $2}')
1000 [ $mds_readpage -gt $RPC_NUM ] && \
1001 error "large readdir doesn't take effect"
1003 simple_cleanup_common
1005 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1007 test_24w() { # bug21506
1009 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1010 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1011 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1012 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1013 [ "$SZ1" = "$SZ2" ] || \
1014 error "Error reading at the end of the file $tfile"
1016 run_test 24w "Reading a file larger than 4Gb"
1019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1021 local remote_dir=$DIR/$tdir/remote_dir
1024 $LFS mkdir -i $MDTIDX $remote_dir ||
1025 error "create remote directory failed"
1027 mkdir -p $DIR/$tdir/src_dir
1028 touch $DIR/$tdir/src_file
1029 mkdir -p $remote_dir/tgt_dir
1030 touch $remote_dir/tgt_file
1032 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1033 error "rename dir cross MDT works!"
1035 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1036 error "rename file cross MDT works!"
1038 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1039 error "ln file cross MDT should not work!"
1041 rm -rf $DIR/$tdir || error "Can not delete directories"
1043 run_test 24x "cross rename/link should be failed"
1046 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1048 local remote_dir=$DIR/$tdir/remote_dir
1051 $LFS mkdir -i $MDTIDX $remote_dir ||
1052 error "create remote directory failed"
1054 mkdir -p $remote_dir/src_dir
1055 touch $remote_dir/src_file
1056 mkdir -p $remote_dir/tgt_dir
1057 touch $remote_dir/tgt_file
1059 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1060 error "rename subdir in the same remote dir failed!"
1062 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1063 error "rename files in the same remote dir failed!"
1065 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1066 error "link files in the same remote dir failed!"
1068 rm -rf $DIR/$tdir || error "Can not delete directories"
1070 run_test 24y "rename/link on the same dir should succeed"
1073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1075 local remote_src=$DIR/$tdir/remote_dir
1076 local remote_tgt=$DIR/$tdir/remote_tgt
1079 $LFS mkdir -i $MDTIDX $remote_src ||
1080 error "create remote directory failed"
1082 $LFS mkdir -i $MDTIDX $remote_tgt ||
1083 error "create remote directory failed"
1085 mrename $remote_src $remote_tgt &&
1086 error "rename remote dirs should not work!"
1088 rm -rf $DIR/$tdir || error "Can not delete directories"
1090 run_test 24z "rename one remote dir to another remote dir should fail"
1093 echo '== symlink sanity ============================================='
1097 touch $DIR/s25/foo || error
1099 run_test 25a "create file in symlinked directory ==============="
1102 [ ! -d $DIR/d25 ] && test_25a
1103 $CHECKSTAT -t file $DIR/s25/foo || error
1105 run_test 25b "lookup file in symlinked directory ==============="
1109 test_mkdir $DIR/d26/d26-2
1110 ln -s d26/d26-2 $DIR/s26
1111 touch $DIR/s26/foo || error
1113 run_test 26a "multiple component symlink ======================="
1116 test_mkdir -p $DIR/d26b/d26-2
1117 ln -s d26b/d26-2/foo $DIR/s26-2
1118 touch $DIR/s26-2 || error
1120 run_test 26b "multiple component symlink at end of lookup ======"
1123 test_mkdir $DIR/d26.2
1124 touch $DIR/d26.2/foo
1125 ln -s d26.2 $DIR/s26.2-1
1126 ln -s s26.2-1 $DIR/s26.2-2
1127 ln -s s26.2-2 $DIR/s26.2-3
1128 chmod 0666 $DIR/s26.2-3/foo
1130 run_test 26c "chain of symlinks ================================"
1132 # recursive symlinks (bug 439)
1134 ln -s d26-3/foo $DIR/d26-3
1136 run_test 26d "create multiple component recursive symlink ======"
1139 [ ! -h $DIR/d26-3 ] && test_26d
1142 run_test 26e "unlink multiple component recursive symlink ======"
1144 # recursive symlinks (bug 7022)
1146 test_mkdir -p $DIR/$tdir
1147 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1148 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1149 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1150 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1151 cd $tfile || error "cd $tfile failed"
1152 ln -s .. dotdot || error "ln dotdot failed"
1153 ln -s dotdot/lndir lndir || error "ln lndir failed"
1154 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1155 output=`ls $tfile/$tfile/lndir/bar1`
1156 [ "$output" = bar1 ] && error "unexpected output"
1157 rm -r $tfile || error "rm $tfile failed"
1158 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1160 run_test 26f "rm -r of a directory which has recursive symlink ="
1163 echo '== stripe sanity =============================================='
1164 test_mkdir -p $DIR/d27 || error "mkdir failed"
1166 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1167 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1169 log "== test_27a: write to one stripe file ========================="
1170 cp /etc/hosts $DIR/d27/f0 || error
1172 run_test 27a "one stripe file =================================="
1175 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1176 test_mkdir -p $DIR/d27
1177 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1178 $GETSTRIPE -c $DIR/d27/f01
1179 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1180 error "two-stripe file doesn't have two stripes"
1182 run_test 27b "create two stripe file"
1185 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1187 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1189 run_test 27c "write to two stripe file"
1192 test_mkdir -p $DIR/d27
1193 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1194 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1195 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1197 run_test 27d "create file with default settings ================"
1200 test_mkdir -p $DIR/d27
1201 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1202 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1203 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1205 run_test 27e "setstripe existing file (should return error) ======"
1208 test_mkdir -p $DIR/d27
1209 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1210 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
1211 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1213 run_test 27f "setstripe with bad stripe size (should return error)"
1216 test_mkdir -p $DIR/d27
1217 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1218 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1219 error "$DIR/d27/fnone has object"
1221 run_test 27g "$GETSTRIPE with no objects"
1224 touch $DIR/d27/fsome || error "touch failed"
1225 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1227 run_test 27i "$GETSTRIPE with some objects"
1230 test_mkdir -p $DIR/d27
1231 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1233 run_test 27j "setstripe with bad stripe offset (should return error)"
1235 test_27k() { # bug 2844
1236 test_mkdir -p $DIR/d27
1238 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1239 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1240 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1241 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1242 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1243 dd if=/dev/zero of=$FILE bs=4k count=1
1244 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1245 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1247 run_test 27k "limit i_blksize for broken user apps ============="
1250 test_mkdir -p $DIR/d27
1251 mcreate $DIR/f27l || error "creating file"
1252 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1253 error "setstripe should have failed" || true
1255 run_test 27l "check setstripe permissions (should return error)"
1258 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1260 if [ $ORIGFREE -gt $MAXFREE ]; then
1261 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1264 trap simple_cleanup_common EXIT
1265 test_mkdir -p $DIR/$tdir
1266 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1267 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1268 error "dd should fill OST0"
1270 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1272 [ $i -gt 256 ] && break
1275 touch $DIR/$tdir/f27m_$i
1276 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1277 error "OST0 was full but new created file still use it"
1279 touch $DIR/$tdir/f27m_$i
1280 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1281 error "OST0 was full but new created file still use it"
1282 simple_cleanup_common
1284 run_test 27m "create file while OST0 was full =================="
1287 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1291 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1292 # if the OST isn't full anymore.
1294 local OSTIDX=${1:-""}
1296 local list=$(comma_list $(osts_nodes))
1297 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1299 do_nodes $list lctl set_param fail_loc=0
1300 sync # initiate all OST_DESTROYs from MDS to OST
1304 exhaust_precreations() {
1307 local FAILIDX=${3:-$OSTIDX}
1309 test_mkdir -p $DIR/$tdir
1310 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1311 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1313 local OST=$(ostname_from_index $OSTIDX)
1314 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1315 sed -e 's/_UUID$//;s/^.*-//')
1318 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1319 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1320 osc.$mdtosc_proc1.prealloc_last_id)
1321 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1322 osc.$mdtosc_proc1.prealloc_next_id)
1324 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1325 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1327 test_mkdir -p $DIR/$tdir/${OST}
1328 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1329 #define OBD_FAIL_OST_ENOSPC 0x215
1330 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1331 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1332 echo "Creating to objid $last_id on ost $OST..."
1333 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1334 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1335 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1339 exhaust_all_precreations() {
1341 for (( i=0; i < OSTCOUNT; i++ )) ; do
1342 exhaust_precreations $i $1 -1
1347 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1348 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1349 remote_ost_nodsh && skip "remote OST with nodsh" && return
1352 rm -f $DIR/$tdir/$tfile
1353 exhaust_precreations 0 0x80000215
1354 $SETSTRIPE -c -1 $DIR/$tdir
1355 touch $DIR/$tdir/$tfile || error
1356 $GETSTRIPE $DIR/$tdir/$tfile
1359 run_test 27n "create file with some full OSTs =================="
1362 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1363 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1364 remote_ost_nodsh && skip "remote OST with nodsh" && return
1367 rm -f $DIR/$tdir/$tfile
1368 exhaust_all_precreations 0x215
1370 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1375 run_test 27o "create file with all full OSTs (should error) ===="
1378 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1379 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1380 remote_ost_nodsh && skip "remote OST with nodsh" && return
1383 rm -f $DIR/$tdir/$tfile
1384 test_mkdir -p $DIR/$tdir
1386 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1387 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1388 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1390 exhaust_precreations 0 0x80000215
1391 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1392 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1393 $GETSTRIPE $DIR/$tdir/$tfile
1397 run_test 27p "append to a truncated file with some full OSTs ==="
1400 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && 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
1407 test_mkdir -p $DIR/$tdir
1408 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1409 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1410 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1412 exhaust_all_precreations 0x215
1414 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1415 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1419 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1422 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1423 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1424 remote_ost_nodsh && skip "remote OST with nodsh" && return
1427 rm -f $DIR/$tdir/$tfile
1428 exhaust_precreations 0 0x80000215
1430 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1434 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1436 test_27s() { # bug 10725
1437 test_mkdir -p $DIR/$tdir
1438 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1439 local stripe_count=0
1440 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1441 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1442 error "stripe width >= 2^32 succeeded" || true
1445 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1447 test_27t() { # bug 10864
1452 $WLFS getstripe $tfile
1455 run_test 27t "check that utils parse path correctly"
1457 test_27u() { # bug 4900
1458 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1461 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1462 do_facet $SINGLEMDS lctl set_param fail_loc=0x139
1463 test_mkdir -p $DIR/$tdir
1464 createmany -o $DIR/$tdir/t- 1000
1465 do_facet $SINGLEMDS lctl set_param fail_loc=0
1467 TLOG=$DIR/$tfile.getstripe
1468 $GETSTRIPE $DIR/$tdir > $TLOG
1469 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1470 unlinkmany $DIR/$tdir/t- 1000
1471 [ $OBJS -gt 0 ] && \
1472 error "$OBJS objects created on OST-0. See $TLOG" || pass
1474 run_test 27u "skip object creation on OSC w/o objects =========="
1476 test_27v() { # bug 4900
1477 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1478 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1479 remote_ost_nodsh && skip "remote OST with nodsh" && return
1481 exhaust_all_precreations 0x215
1484 test_mkdir -p $DIR/$tdir
1485 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1487 touch $DIR/$tdir/$tfile
1488 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1490 for (( i=1; i < OSTCOUNT; i++ )); do
1491 do_facet ost$i lctl set_param fail_loc=0x705
1493 local START=`date +%s`
1494 createmany -o $DIR/$tdir/$tfile 32
1496 local FINISH=`date +%s`
1497 local TIMEOUT=`lctl get_param -n timeout`
1498 local PROCESS=$((FINISH - START))
1499 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1500 error "$FINISH - $START >= $TIMEOUT / 2"
1501 sleep $((TIMEOUT / 2 - PROCESS))
1504 run_test 27v "skip object creation on slow OST ================="
1506 test_27w() { # bug 10997
1507 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1508 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1509 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1510 error "stripe size $size != 65536" || true
1511 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1512 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1514 run_test 27w "check $SETSTRIPE -S option"
1517 [ "$OSTCOUNT" -lt "2" ] &&
1518 skip_env "skipping multiple stripe count/offset test" && return
1520 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1521 for i in $(seq 1 $OSTCOUNT); do
1523 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1524 error "setstripe -c $i -i $offset failed"
1525 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1526 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1527 [ $count -ne $i ] && error "stripe count $count != $i" || true
1528 [ $index -ne $offset ] &&
1529 error "stripe offset $index != $offset" || true
1532 run_test 27wa "check $SETSTRIPE -c -i options"
1535 remote_ost_nodsh && skip "remote OST with nodsh" && return
1536 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1537 OFFSET=$(($OSTCOUNT - 1))
1539 local OST=$(ostname_from_index $OSTIDX)
1541 test_mkdir -p $DIR/$tdir
1542 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1543 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1545 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1546 for i in `seq 0 $OFFSET`; do
1547 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1548 error "OST0 was degraded but new created file still use it"
1550 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1552 run_test 27x "create files while OST0 is degraded"
1555 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1556 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return
1559 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1560 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1561 osc.$mdtosc.prealloc_last_id)
1562 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1563 osc.$mdtosc.prealloc_next_id)
1564 local fcount=$((last_id - next_id))
1565 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1566 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1568 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1569 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1570 local OST_DEACTIVE_IDX=-1
1575 for OSC in $MDS_OSCS; do
1576 OST=$(osc_to_ost $OSC)
1577 OSTIDX=$(index_from_ostuuid $OST)
1578 if [ $OST_DEACTIVE_IDX == -1 ]; then
1579 OST_DEACTIVE_IDX=$OSTIDX
1581 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1582 echo $OSC "is Deactivated:"
1583 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1587 OSTIDX=$(index_from_ostuuid $OST)
1589 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1591 for OSC in $MDS_OSCS; do
1592 OST=$(osc_to_ost $OSC)
1593 OSTIDX=$(index_from_ostuuid $OST)
1594 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1595 echo $OST "is degraded:"
1596 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1597 obdfilter.$OST.degraded=1
1602 createmany -o $DIR/$tdir/$tfile $fcount
1604 for OSC in $MDS_OSCS; do
1605 OST=$(osc_to_ost $OSC)
1606 OSTIDX=$(index_from_ostuuid $OST)
1607 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1608 echo $OST "is recovered from degraded:"
1609 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1610 obdfilter.$OST.degraded=0
1612 do_facet $SINGLEMDS lctl --device %$OSC activate
1616 run_test 27y "create files while OST0 is degraded and the rest inactive"
1622 lmm_count=$($GETSTRIPE -c $1)
1623 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1624 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1626 local old_ifs="$IFS"
1628 fid=($($LFS path2fid $1))
1631 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1632 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1634 # compare lmm_seq and lu_fid->f_seq
1635 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1636 # compare lmm_object_id and lu_fid->oid
1637 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1639 # check the trusted.fid attribute of the OST objects of the file
1640 local have_obdidx=false
1642 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1643 # skip lines up to and including "obdidx"
1644 [ -z "$obdidx" ] && break
1645 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1646 $have_obdidx || continue
1648 local ost=$((obdidx + 1))
1649 local dev=$(ostdevname $ost)
1651 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1652 echo "Currently only works with ldiskfs-based OSTs"
1656 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1658 #don't unmount/remount the OSTs if we don't need to do that
1659 #local dir=$(facet_mntpt ost$ost)
1661 #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
1662 # { error "mounting $dev as $FSTYPE failed"; return 3; }
1663 #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid)
1664 #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1666 local obj_file="O/$seq/d$((oid %32))/$oid"
1667 local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1668 $dev 2>/dev/null" | grep "parent=")
1670 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1672 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1674 #do_facet ost$ost umount -d $dir
1675 #start ost$ost $dev $OST_MOUNT_OPTS
1677 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1678 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1679 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1680 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1681 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1682 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1684 # compare lmm_seq and filter_fid->ff_parent.f_seq
1685 [ $ff_pseq = $lmm_seq ] ||
1686 error "FF parent SEQ $ff_pseq != $lmm_seq"
1687 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1688 [ $ff_poid = $lmm_oid ] ||
1689 error "FF parent OID $ff_poid != $lmm_oid"
1690 [ $ff_pstripe = $stripe_nr ] ||
1691 error "FF stripe $ff_pstripe != $stripe_nr"
1693 stripe_nr=$((stripe_nr + 1))
1698 remote_ost_nodsh && skip "remote OST with nodsh" && return
1699 test_mkdir -p $DIR/$tdir
1701 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1702 { error "setstripe -c -1 failed"; return 1; }
1703 # We need to send a write to every object to get parent FID info set.
1704 # This _should_ also work for setattr, but does not currently.
1705 # touch $DIR/$tdir/$tfile-1 ||
1706 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1707 { error "dd $tfile-1 failed"; return 2; }
1708 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1709 { error "setstripe -c -1 failed"; return 3; }
1710 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1711 { error "dd $tfile-2 failed"; return 4; }
1713 # make sure write RPCs have been sent to OSTs
1716 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1717 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1719 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1721 test_27A() { # b=19102
1722 local restore_size=$($GETSTRIPE -S $MOUNT)
1723 local restore_count=$($GETSTRIPE -c $MOUNT)
1724 local restore_offset=$($GETSTRIPE -i $MOUNT)
1725 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1726 local default_size=$($GETSTRIPE -S $MOUNT)
1727 local default_count=$($GETSTRIPE -c $MOUNT)
1728 local default_offset=$($GETSTRIPE -i $MOUNT)
1729 local dsize=$((1024 * 1024))
1730 [ $default_size -eq $dsize ] ||
1731 error "stripe size $default_size != $dsize"
1732 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1733 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1734 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1736 run_test 27A "check filesystem-wide default LOV EA values"
1738 # createtest also checks that device nodes are created and
1739 # then visible correctly (#2091)
1740 test_28() { # bug 2091
1742 $CREATETEST $DIR/d28/ct || error
1744 run_test 28 "create/mknod/mkdir with bad file types ============"
1747 cancel_lru_locks mdc
1753 declare -i LOCKCOUNTORIG=0
1754 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1755 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1757 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1759 declare -i LOCKUNUSEDCOUNTORIG=0
1760 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1761 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1768 declare -i LOCKCOUNTCURRENT=0
1769 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1770 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1773 declare -i LOCKUNUSEDCOUNTCURRENT=0
1774 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1775 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1778 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1779 lctl set_param -n ldlm.dump_namespaces ""
1780 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1781 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1782 log "dumped log to $TMP/test_29.dk (bug 5793)"
1785 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1786 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1787 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1788 log "dumped log to $TMP/test_29.dk (bug 5793)"
1792 run_test 29 "IT_GETATTR regression ============================"
1794 test_30a() { # was test_30
1795 cp `which ls` $DIR || cp /bin/ls $DIR
1799 run_test 30a "execute binary from Lustre (execve) =============="
1802 cp `which ls` $DIR || cp /bin/ls $DIR
1804 $RUNAS $DIR/ls / || error
1807 run_test 30b "execute binary from Lustre as non-root ==========="
1809 test_30c() { # b=22376
1810 cp `which ls` $DIR || cp /bin/ls $DIR
1812 cancel_lru_locks mdc
1813 cancel_lru_locks osc
1814 $RUNAS $DIR/ls / || error
1817 run_test 30c "execute binary from Lustre without read perms ===="
1820 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1821 $CHECKSTAT -a $DIR/f31 || error
1823 run_test 31a "open-unlink file =================================="
1826 touch $DIR/f31 || error
1827 ln $DIR/f31 $DIR/f31b || error
1828 $MULTIOP $DIR/f31b Ouc || error
1829 $CHECKSTAT -t file $DIR/f31 || error
1831 run_test 31b "unlink file with multiple links while open ======="
1834 touch $DIR/f31 || error
1835 ln $DIR/f31 $DIR/f31c || error
1836 multiop_bg_pause $DIR/f31 O_uc || return 1
1838 $MULTIOP $DIR/f31c Ouc
1839 kill -USR1 $MULTIPID
1842 run_test 31c "open-unlink file with multiple links ============="
1845 opendirunlink $DIR/d31d $DIR/d31d || error
1846 $CHECKSTAT -a $DIR/d31d || error
1848 run_test 31d "remove of open directory ========================="
1850 test_31e() { # bug 2904
1851 check_kernel_version 34 || return 0
1852 openfilleddirunlink $DIR/d31e || error
1854 run_test 31e "remove of open non-empty directory ==============="
1856 test_31f() { # bug 4554
1858 test_mkdir $DIR/d31f
1859 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1860 cp /etc/hosts $DIR/d31f
1862 $GETSTRIPE $DIR/d31f/hosts
1863 multiop_bg_pause $DIR/d31f D_c || return 1
1866 rm -rv $DIR/d31f || error "first of $DIR/d31f"
1867 test_mkdir $DIR/d31f
1868 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
1869 cp /etc/hosts $DIR/d31f
1871 $GETSTRIPE $DIR/d31f/hosts
1872 multiop_bg_pause $DIR/d31f D_c || return 1
1875 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
1876 wait $MULTIPID || error "first opendir $MULTIPID failed"
1880 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
1881 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
1884 run_test 31f "remove of open directory with open-unlink file ==="
1887 echo "-- cross directory link --"
1888 test_mkdir $DIR/d31ga
1889 test_mkdir $DIR/d31gb
1891 ln $DIR/d31ga/f $DIR/d31gb/g
1892 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
1893 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
1894 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
1895 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
1897 run_test 31g "cross directory link==============="
1900 echo "-- cross directory link --"
1901 test_mkdir $DIR/d31h
1902 test_mkdir $DIR/d31h/dir
1904 ln $DIR/d31h/f $DIR/d31h/dir/g
1905 $CHECKSTAT -t file $DIR/d31h/f || error "source"
1906 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
1907 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
1908 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
1910 run_test 31h "cross directory link under child==============="
1913 echo "-- cross directory link --"
1914 test_mkdir $DIR/d31i
1915 test_mkdir $DIR/d31i/dir
1916 touch $DIR/d31i/dir/f
1917 ln $DIR/d31i/dir/f $DIR/d31i/g
1918 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
1919 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
1920 $CHECKSTAT -t file $DIR/d31i/g || error "target"
1921 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
1923 run_test 31i "cross directory link under parent==============="
1927 test_mkdir $DIR/d31j
1928 test_mkdir $DIR/d31j/dir1
1929 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
1930 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
1931 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
1932 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
1935 run_test 31j "link for directory==============="
1939 test_mkdir $DIR/d31k
1941 touch $DIR/d31k/exist
1942 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
1943 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
1944 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
1945 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
1946 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
1947 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
1948 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
1951 run_test 31k "link to file: the same, non-existing, dir==============="
1954 test_mkdir $DIR/d31m
1956 test_mkdir $DIR/d31m2
1957 touch $DIR/d31m2/exist
1958 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
1959 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
1960 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
1961 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
1962 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
1963 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
1966 run_test 31m "link to file: the same, non-existing, dir==============="
1968 cleanup_test32_mount() {
1970 $UMOUNT $DIR/$tdir/ext2-mountpoint
1974 echo "== more mountpoints and symlinks ================="
1975 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1976 trap cleanup_test32_mount EXIT
1977 test_mkdir -p $DIR/$tdir/ext2-mountpoint
1978 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1979 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
1980 cleanup_test32_mount
1982 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
1985 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1986 trap cleanup_test32_mount EXIT
1987 test_mkdir -p $DIR/$tdir/ext2-mountpoint
1988 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1989 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
1990 cleanup_test32_mount
1992 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
1995 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
1996 trap cleanup_test32_mount EXIT
1997 test_mkdir -p $DIR/$tdir/ext2-mountpoint
1998 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
1999 test_mkdir -p $DIR/$tdir/d2/test_dir
2000 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2001 cleanup_test32_mount
2003 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2006 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2007 trap cleanup_test32_mount EXIT
2008 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2009 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2010 test_mkdir -p $DIR/$tdir/d2/test_dir
2011 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2012 cleanup_test32_mount
2014 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2017 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2018 test_mkdir -p $DIR/d32e/tmp
2019 TMP_DIR=$DIR/d32e/tmp
2020 ln -s $DIR/d32e $TMP_DIR/symlink11
2021 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2022 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2023 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2025 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2028 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2029 test_mkdir -p $DIR/d32f/tmp
2030 TMP_DIR=$DIR/d32f/tmp
2031 ln -s $DIR/d32f $TMP_DIR/symlink11
2032 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2033 ls $DIR/d32f/tmp/symlink11 || error
2034 ls $DIR/d32f/symlink01 || error
2036 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2039 TMP_DIR=$DIR/$tdir/tmp
2040 test_mkdir -p $DIR/$tdir/tmp
2041 test_mkdir $DIR/${tdir}2
2042 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2043 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2044 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2045 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2046 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2047 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2049 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2052 rm -fr $DIR/$tdir $DIR/${tdir}2
2053 TMP_DIR=$DIR/$tdir/tmp
2054 test_mkdir -p $DIR/$tdir/tmp
2055 test_mkdir $DIR/${tdir}2
2056 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2057 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2058 ls $TMP_DIR/symlink12 || error
2059 ls $DIR/$tdir/symlink02 || error
2061 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2064 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2065 trap cleanup_test32_mount EXIT
2066 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2067 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2068 touch $DIR/$tdir/test_file
2069 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2070 cleanup_test32_mount
2072 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2075 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2076 trap cleanup_test32_mount EXIT
2077 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2078 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2079 touch $DIR/$tdir/test_file
2080 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2081 cleanup_test32_mount
2083 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2087 trap cleanup_test32_mount EXIT
2088 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2089 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2090 test_mkdir -p $DIR/$tdir/d2
2091 touch $DIR/$tdir/d2/test_file || error
2092 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2093 cleanup_test32_mount
2095 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2099 trap cleanup_test32_mount EXIT
2100 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2101 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2102 test_mkdir -p $DIR/$tdir/d2
2103 touch $DIR/$tdir/d2/test_file
2104 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2105 cleanup_test32_mount
2107 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2111 test_mkdir -p $DIR/d32m/tmp
2112 TMP_DIR=$DIR/d32m/tmp
2113 ln -s $DIR $TMP_DIR/symlink11
2114 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2115 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2116 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2118 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2122 test_mkdir -p $DIR/d32n/tmp
2123 TMP_DIR=$DIR/d32n/tmp
2124 ln -s $DIR $TMP_DIR/symlink11
2125 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2126 ls -l $DIR/d32n/tmp/symlink11 || error
2127 ls -l $DIR/d32n/symlink01 || error
2129 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2132 rm -fr $DIR/d32o $DIR/$tfile
2134 test_mkdir -p $DIR/d32o/tmp
2135 TMP_DIR=$DIR/d32o/tmp
2136 ln -s $DIR/$tfile $TMP_DIR/symlink12
2137 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2138 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2139 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2140 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2141 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2143 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2153 test_mkdir -p $DIR/d32p/tmp
2155 TMP_DIR=$DIR/d32p/tmp
2157 ln -s $DIR/$tfile $TMP_DIR/symlink12
2159 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2161 cat $DIR/d32p/tmp/symlink12 || error
2163 cat $DIR/d32p/symlink02 || error
2166 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2168 cleanup_testdir_mount() {
2174 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2175 trap cleanup_testdir_mount EXIT
2176 test_mkdir -p $DIR/$tdir
2177 touch $DIR/$tdir/under_the_mount
2178 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2179 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2180 cleanup_testdir_mount
2182 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2185 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2186 trap cleanup_testdir_mount EXIT
2187 test_mkdir -p $DIR/$tdir
2188 touch $DIR/$tdir/under_the_mount
2189 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2190 ls $DIR/$tdir | grep -q under_the_mount && error || true
2191 cleanup_testdir_mount
2193 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2198 chmod 444 $DIR/$tfile
2199 chown $RUNAS_ID $DIR/$tfile
2201 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2204 run_test 33aa "write file with mode 444 (should return error) ===="
2208 test_mkdir -p $DIR/d33
2209 chown $RUNAS_ID $DIR/d33
2210 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2211 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2212 error "open RDWR" || true
2214 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2218 test_mkdir -p $DIR/d33
2219 chown $RUNAS_ID $DIR/d33
2220 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2222 run_test 33b "test open file with malformed flags (No panic and return error)"
2230 remote_ost_nodsh && skip "remote OST with nodsh" && return
2233 test_mkdir -p $DIR/d33
2234 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2237 for ostnum in $(seq $OSTCOUNT); do
2238 # test-framework's OST numbering is one-based, while Lustre's
2240 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2241 # Parsing llobdstat's output sucks; we could grep the /proc
2242 # path, but that's likely to not be as portable as using the
2243 # llobdstat utility. So we parse lctl output instead.
2244 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2245 obdfilter/$ostname/stats |
2246 awk '/^write_bytes/ {print $7}' )
2247 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2248 if (( ${write_bytes:-0} > 0 ))
2255 $all_zeros || return 0
2258 echo foo > $DIR/d33/bar
2262 # Total up write_bytes after writing. We'd better find non-zeros.
2263 for ostnum in $(seq $OSTCOUNT); do
2264 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2265 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2266 obdfilter/$ostname/stats |
2267 awk '/^write_bytes/ {print $7}' )
2268 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2269 if (( ${write_bytes:-0} > 0 ))
2278 for ostnum in $(seq $OSTCOUNT); do
2279 ostname=$(printf "$FSNAME-OST%.4d" $((ostnum - 1)))
2280 echo "Check that write_bytes is present in obdfilter/*/stats:"
2281 do_facet ost$ostnum lctl get_param -n \
2282 obdfilter/$ostname/stats
2284 error "OST not keeping write_bytes stats (b22312)"
2287 run_test 33c "test llobdstat and write_bytes"
2290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2292 local remote_dir=$DIR/$tdir/remote_dir
2295 $LFS mkdir -i $MDTIDX $remote_dir ||
2296 error "create remote directory failed"
2298 touch $remote_dir/$tfile
2299 chmod 444 $remote_dir/$tfile
2300 chown $RUNAS_ID $remote_dir/$tfile
2302 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2304 chown $RUNAS_ID $remote_dir
2305 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2306 error "create" || true
2307 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2308 error "open RDWR" || true
2309 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2310 error "create" || true
2312 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2314 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2317 $MCREATE $DIR/f34 || error
2318 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2319 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2320 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2321 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2323 run_test 34a "truncate file that has not been opened ==========="
2326 [ ! -f $DIR/f34 ] && test_34a
2327 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2328 $OPENFILE -f O_RDONLY $DIR/f34
2329 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2330 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2332 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2335 [ ! -f $DIR/f34 ] && test_34a
2336 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2337 $OPENFILE -f O_RDWR $DIR/f34
2338 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2339 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2341 run_test 34c "O_RDWR opening file-with-size works =============="
2344 [ ! -f $DIR/f34 ] && test_34a
2345 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2346 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2349 run_test 34d "write to sparse file ============================="
2353 $MCREATE $DIR/f34e || error
2354 $TRUNCATE $DIR/f34e 1000 || error
2355 $CHECKSTAT -s 1000 $DIR/f34e || error
2356 $OPENFILE -f O_RDWR $DIR/f34e
2357 $CHECKSTAT -s 1000 $DIR/f34e || error
2359 run_test 34e "create objects, some with size and some without =="
2361 test_34f() { # bug 6242, 6243
2364 $MCREATE $DIR/f34f || error
2365 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2366 dd if=$DIR/f34f of=$TMP/f34f
2367 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2368 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2369 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2370 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2371 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2373 run_test 34f "read from a file with no objects until EOF ======="
2376 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2377 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2378 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2379 cancel_lru_locks osc
2380 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2381 error "wrong size after lock cancel"
2383 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2384 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2385 error "expanding truncate failed"
2386 cancel_lru_locks osc
2387 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2388 error "wrong expanded size after lock cancel"
2390 run_test 34g "truncate long file ==============================="
2396 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2397 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2401 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2402 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2406 local nsz=`stat -c %s $DIR/$tfile`
2407 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2409 run_test 34h "ftruncate file under grouplock should not block"
2412 cp /bin/sh $DIR/f35a
2414 chown $RUNAS_ID $DIR/f35a
2415 $RUNAS $DIR/f35a && error || true
2418 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2422 utime $DIR/f36 || error
2424 run_test 36a "MDS utime check (mknod, utime) ==================="
2428 utime $DIR/f36 || error
2430 run_test 36b "OST utime check (open, utime) ===================="
2435 chown $RUNAS_ID $DIR/d36
2436 $RUNAS utime $DIR/d36/f36 || error
2438 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2441 [ ! -d $DIR/d36 ] && test_36c
2442 echo "" > $DIR/d36/f36
2443 $RUNAS utime $DIR/d36/f36 || error
2445 run_test 36d "non-root OST utime check (open, utime) ==========="
2448 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2449 test_mkdir -p $DIR/$tdir
2450 touch $DIR/$tdir/$tfile
2451 $RUNAS utime $DIR/$tdir/$tfile && \
2452 error "utime worked, expected failure" || true
2454 run_test 36e "utime on non-owned file (should return error) ===="
2458 local LANG_SAVE=$LANG
2459 local LC_LANG_SAVE=$LC_LANG
2460 export LANG=C LC_LANG=C # for date language
2462 DATESTR="Dec 20 2000"
2463 test_mkdir -p $DIR/$tdir
2464 lctl set_param fail_loc=$fl
2466 cp /etc/hosts $DIR/$tdir/$tfile
2467 sync & # write RPC generated with "current" inode timestamp, but delayed
2469 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2470 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2471 cancel_lru_locks osc
2472 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2474 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2475 echo "BEFORE: $LS_BEFORE" && \
2476 echo "AFTER : $LS_AFTER" && \
2477 echo "WANT : $DATESTR" && \
2478 error "$DIR/$tdir/$tfile timestamps changed" || true
2480 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2484 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2485 subr_36fh "0x80000214"
2487 run_test 36f "utime on file racing with OST BRW write =========="
2490 remote_ost_nodsh && skip "remote OST with nodsh" && return
2495 test_mkdir -p $DIR/$tdir
2496 fmd_max_age=$(do_facet ost1 \
2497 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2500 fmd_before=$(do_facet ost1 \
2501 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2502 touch $DIR/$tdir/$tfile
2503 sleep $((fmd_max_age + 12))
2504 fmd_after=$(do_facet ost1 \
2505 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2507 echo "fmd_before: $fmd_before"
2508 echo "fmd_after: $fmd_after"
2509 [ "$fmd_after" -gt "$fmd_before" ] && \
2510 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2511 error "fmd didn't expire after ping" || true
2513 run_test 36g "filter mod data cache expiry ====================="
2516 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2517 subr_36fh "0x80000227"
2519 run_test 36h "utime on file racing with OST BRW write =========="
2521 # test_37 - duplicate with tests 32q 32r
2524 local file=$DIR/$tfile
2526 openfile -f O_DIRECTORY $file
2529 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2530 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2532 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2536 touch $DIR/${tfile}2
2537 # ls -l $DIR/$tfile $DIR/${tfile}2
2538 # ls -lu $DIR/$tfile $DIR/${tfile}2
2539 # ls -lc $DIR/$tfile $DIR/${tfile}2
2541 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2542 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2544 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2546 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2548 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2549 error "O_TRUNC didn't change timestamps"
2552 run_test 39 "mtime changed on create ==========================="
2555 test_mkdir -p $DIR/$tdir
2556 cp -p /etc/passwd $DIR/$tdir/fopen
2557 cp -p /etc/passwd $DIR/$tdir/flink
2558 cp -p /etc/passwd $DIR/$tdir/funlink
2559 cp -p /etc/passwd $DIR/$tdir/frename
2560 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2563 echo "aaaaaa" >> $DIR/$tdir/fopen
2564 echo "aaaaaa" >> $DIR/$tdir/flink
2565 echo "aaaaaa" >> $DIR/$tdir/funlink
2566 echo "aaaaaa" >> $DIR/$tdir/frename
2568 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2569 local link_new=`stat -c %Y $DIR/$tdir/flink`
2570 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2571 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2573 cat $DIR/$tdir/fopen > /dev/null
2574 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2575 rm -f $DIR/$tdir/funlink2
2576 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2578 for (( i=0; i < 2; i++ )) ; do
2579 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2580 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2581 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2582 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2584 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2585 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2586 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2587 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2589 cancel_lru_locks osc
2590 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2593 run_test 39b "mtime change on open, link, unlink, rename ======"
2595 # this should be set to past
2596 TEST_39_MTIME=`date -d "1 year ago" +%s`
2602 local mtime0=`stat -c %Y $DIR1/$tfile`
2604 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2605 local mtime1=`stat -c %Y $DIR1/$tfile`
2606 [ "$mtime1" = $TEST_39_MTIME ] || \
2607 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2610 echo hello >> $DIR1/$tfile
2612 local mtime2=`stat -c %Y $DIR1/$tfile`
2613 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2614 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2616 mv $DIR1/$tfile $DIR1/$tfile-1
2618 for (( i=0; i < 2; i++ )) ; do
2619 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2620 [ "$mtime2" = "$mtime3" ] || \
2621 error "mtime ($mtime2) changed (to $mtime3) on rename"
2623 cancel_lru_locks osc
2624 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2627 run_test 39c "mtime change on rename ==========================="
2633 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2635 for (( i=0; i < 2; i++ )) ; do
2636 local mtime=`stat -c %Y $DIR1/$tfile`
2637 [ $mtime = $TEST_39_MTIME ] || \
2638 error "mtime($mtime) is not set to $TEST_39_MTIME"
2640 cancel_lru_locks osc
2641 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2644 run_test 39d "create, utime, stat =============================="
2649 local mtime1=`stat -c %Y $DIR1/$tfile`
2651 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2653 for (( i=0; i < 2; i++ )) ; do
2654 local mtime2=`stat -c %Y $DIR1/$tfile`
2655 [ $mtime2 = $TEST_39_MTIME ] || \
2656 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2658 cancel_lru_locks osc
2659 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2662 run_test 39e "create, stat, utime, stat ========================"
2667 mtime1=`stat -c %Y $DIR1/$tfile`
2670 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2672 for (( i=0; i < 2; i++ )) ; do
2673 local mtime2=`stat -c %Y $DIR1/$tfile`
2674 [ $mtime2 = $TEST_39_MTIME ] || \
2675 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2677 cancel_lru_locks osc
2678 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2681 run_test 39f "create, stat, sleep, utime, stat ================="
2685 echo hello >> $DIR1/$tfile
2686 local mtime1=`stat -c %Y $DIR1/$tfile`
2689 chmod o+r $DIR1/$tfile
2691 for (( i=0; i < 2; i++ )) ; do
2692 local mtime2=`stat -c %Y $DIR1/$tfile`
2693 [ "$mtime1" = "$mtime2" ] || \
2694 error "lost mtime: $mtime2, should be $mtime1"
2696 cancel_lru_locks osc
2697 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2700 run_test 39g "write, chmod, stat ==============================="
2708 echo hello >> $DIR1/$tfile
2709 local mtime1=`stat -c %Y $DIR1/$tfile`
2711 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2713 if [ "$d1" != "$d2" ]; then
2714 echo "write and touch not within one second"
2716 for (( i=0; i < 2; i++ )) ; do
2717 local mtime2=`stat -c %Y $DIR1/$tfile`
2718 [ "$mtime2" = $TEST_39_MTIME ] || \
2719 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2721 cancel_lru_locks osc
2722 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2726 run_test 39h "write, utime within one second, stat ============="
2732 echo hello >> $DIR1/$tfile
2733 local mtime1=`stat -c %Y $DIR1/$tfile`
2735 mv $DIR1/$tfile $DIR1/$tfile-1
2737 for (( i=0; i < 2; i++ )) ; do
2738 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2740 [ "$mtime1" = "$mtime2" ] || \
2741 error "lost mtime: $mtime2, should be $mtime1"
2743 cancel_lru_locks osc
2744 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2747 run_test 39i "write, rename, stat =============================="
2750 start_full_debug_logging
2754 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2755 lctl set_param fail_loc=0x80000412
2756 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2757 error "multiop failed"
2759 local mtime1=`stat -c %Y $DIR1/$tfile`
2761 mv $DIR1/$tfile $DIR1/$tfile-1
2763 kill -USR1 $multipid
2764 wait $multipid || error "multiop close failed"
2766 for (( i=0; i < 2; i++ )) ; do
2767 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2768 [ "$mtime1" = "$mtime2" ] ||
2769 error "mtime is lost on close: $mtime2, " \
2772 cancel_lru_locks osc
2773 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2775 lctl set_param fail_loc=0
2776 stop_full_debug_logging
2778 run_test 39j "write, rename, close, stat ======================="
2784 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
2786 local mtime1=`stat -c %Y $DIR1/$tfile`
2788 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2790 kill -USR1 $multipid
2791 wait $multipid || error "multiop close failed"
2793 for (( i=0; i < 2; i++ )) ; do
2794 local mtime2=`stat -c %Y $DIR1/$tfile`
2796 [ "$mtime2" = $TEST_39_MTIME ] || \
2797 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
2799 cancel_lru_locks osc
2800 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2803 run_test 39k "write, utime, close, stat ========================"
2805 # this should be set to future
2806 TEST_39_ATIME=`date -d "1 year" +%s`
2809 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2810 local atime_diff=$(do_facet $SINGLEMDS \
2811 lctl get_param -n mdd.*MDT0000*.atime_diff)
2815 # test setting directory atime to future
2816 touch -a -d @$TEST_39_ATIME $DIR/$tdir
2817 local atime=$(stat -c %X $DIR/$tdir)
2818 [ "$atime" = $TEST_39_ATIME ] || \
2819 error "atime is not set to future: $atime, $TEST_39_ATIME"
2821 # test setting directory atime from future to now
2822 local d1=$(date +%s)
2824 local d2=$(date +%s)
2826 cancel_lru_locks mdc
2827 atime=$(stat -c %X $DIR/$tdir)
2828 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2829 error "atime is not updated from future: $atime, $d1<atime<$d2"
2831 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
2834 # test setting directory atime when now > dir atime + atime_diff
2838 cancel_lru_locks mdc
2839 atime=$(stat -c %X $DIR/$tdir)
2840 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2841 error "atime is not updated : $atime, should be $d2"
2843 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
2846 # test not setting directory atime when now < dir atime + atime_diff
2848 cancel_lru_locks mdc
2849 atime=$(stat -c %X $DIR/$tdir)
2850 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
2851 error "atime is updated to $atime, should remain $d1<atime<$d2"
2853 do_facet $SINGLEMDS \
2854 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
2856 run_test 39l "directory atime update ==========================="
2861 local far_past_mtime=$(date -d "May 29 1953" +%s)
2862 local far_past_atime=$(date -d "Dec 17 1903" +%s)
2864 touch -m -d @$far_past_mtime $DIR1/$tfile
2865 touch -a -d @$far_past_atime $DIR1/$tfile
2867 for (( i=0; i < 2; i++ )) ; do
2868 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
2869 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
2870 error "atime or mtime set incorrectly"
2872 cancel_lru_locks osc
2873 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2876 run_test 39m "test atime and mtime before 1970"
2879 dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
2880 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
2881 $CHECKSTAT -t file -s 4096 $DIR/f40 || error
2883 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
2887 small_write $DIR/f41 18
2889 run_test 41 "test small file write + fstat ====================="
2891 count_ost_writes() {
2892 lctl get_param -n osc.*.stats |
2893 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
2900 BG_DIRTY_RATIO_SAVE=10
2901 MAX_BG_DIRTY_RATIO=25
2905 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
2906 # dirty_ratio, dirty_background_ratio
2907 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2908 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
2909 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
2910 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
2912 # if file not here, we are a 2.4 kernel
2913 kill -CONT `pidof kupdated`
2918 # setup the trap first, so someone cannot exit the test at the
2919 # exact wrong time and mess up a machine
2920 trap start_writeback EXIT
2921 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
2922 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
2923 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
2924 sysctl -w vm.dirty_writeback_centisecs=0
2925 sysctl -w vm.dirty_writeback_centisecs=0
2926 # save and increase /proc/sys/vm/dirty_ratio
2927 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
2928 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
2929 # save and increase /proc/sys/vm/dirty_background_ratio
2930 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
2931 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
2933 # if file not here, we are a 2.4 kernel
2934 kill -STOP `pidof kupdated`
2938 # ensure that all stripes have some grant before we test client-side cache
2940 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
2941 dd if=/dev/zero of=$i bs=4k count=1
2946 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
2947 # file truncation, and file removal.
2950 cancel_lru_locks osc
2952 sync; sleep 1; sync # just to be safe
2953 BEFOREWRITES=`count_ost_writes`
2954 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
2955 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
2956 AFTERWRITES=`count_ost_writes`
2957 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
2958 error "$BEFOREWRITES < $AFTERWRITES"
2961 run_test 42a "ensure that we don't flush on close =============="
2965 cancel_lru_locks osc
2968 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
2969 BEFOREWRITES=`count_ost_writes`
2970 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
2971 AFTERWRITES=`count_ost_writes`
2972 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2973 error "$BEFOREWRITES < $AFTERWRITES on unlink"
2975 BEFOREWRITES=`count_ost_writes`
2976 sync || error "sync: $?"
2977 AFTERWRITES=`count_ost_writes`
2978 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
2979 error "$BEFOREWRITES < $AFTERWRITES on sync"
2981 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
2985 run_test 42b "test destroy of file with cached dirty data ======"
2987 # if these tests just want to test the effect of truncation,
2988 # they have to be very careful. consider:
2989 # - the first open gets a {0,EOF}PR lock
2990 # - the first write conflicts and gets a {0, count-1}PW
2991 # - the rest of the writes are under {count,EOF}PW
2992 # - the open for truncate tries to match a {0,EOF}PR
2993 # for the filesize and cancels the PWs.
2994 # any number of fixes (don't get {0,EOF} on open, match
2995 # composite locks, do smarter file size management) fix
2996 # this, but for now we want these tests to verify that
2997 # the cancellation with truncate intent works, so we
2998 # start the file with a full-file pw lock to match against
2999 # until the truncate.
3004 cancel_lru_locks osc
3006 # prime the file with 0,EOF PW to match
3010 # now the real test..
3011 dd if=/dev/zero of=$file bs=1024 count=100
3012 BEFOREWRITES=`count_ost_writes`
3013 $TRUNCATE $file $offset
3014 cancel_lru_locks osc
3015 AFTERWRITES=`count_ost_writes`
3021 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3022 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3025 run_test 42c "test partial truncate of file with cached dirty data"
3029 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3030 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3033 run_test 42d "test complete truncate of file with cached dirty data"
3035 test_42e() { # bug22074
3036 local TDIR=$DIR/${tdir}e
3037 local pagesz=$(page_size)
3038 local pages=16 # hardcoded 16 pages, don't change it.
3039 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3040 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3044 test_mkdir -p $DIR/${tdir}e
3045 $SETSTRIPE -c 1 $TDIR
3046 createmany -o $TDIR/f $files
3048 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3050 # we assume that with $OSTCOUNT files, at least one of them will
3051 # be allocated on OST0.
3052 warmup_files=$((OSTCOUNT * max_dirty_mb))
3053 createmany -o $TDIR/w $warmup_files
3055 # write a large amount of data into one file and sync, to get good
3056 # avail_grant number from OST.
3057 for ((i=0; i<$warmup_files; i++)); do
3058 idx=$($GETSTRIPE -i $TDIR/w$i)
3059 [ $idx -ne 0 ] && continue
3060 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3063 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3065 $LCTL get_param $proc_osc0/cur_dirty_bytes
3066 $LCTL get_param $proc_osc0/cur_grant_bytes
3068 # create as much dirty pages as we can while not to trigger the actual
3069 # RPCs directly. but depends on the env, VFS may trigger flush during this
3070 # period, hopefully we are good.
3071 for ((i=0; i<$warmup_files; i++)); do
3072 idx=$($GETSTRIPE -i $TDIR/w$i)
3073 [ $idx -ne 0 ] && continue
3074 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3076 $LCTL get_param $proc_osc0/cur_dirty_bytes
3077 $LCTL get_param $proc_osc0/cur_grant_bytes
3079 # perform the real test
3080 $LCTL set_param $proc_osc0/rpc_stats 0
3081 for ((;i<$files; i++)); do
3082 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3083 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3086 $LCTL get_param $proc_osc0/rpc_stats
3089 local have_ppr=false
3090 $LCTL get_param $proc_osc0/rpc_stats |
3091 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3092 # skip lines until we are at the RPC histogram data
3093 [ "$PPR" == "pages" ] && have_ppr=true && continue
3094 $have_ppr || continue
3096 # we only want the percent stat for < 16 pages
3097 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3099 percent=$((percent + WPCT))
3100 if [ $percent -gt 15 ]; then
3101 error "less than 16-pages write RPCs" \
3108 run_test 42e "verify sub-RPC writes are not done synchronously"
3111 test_mkdir -p $DIR/$tdir
3112 cp -p /bin/ls $DIR/$tdir/$tfile
3113 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3115 # give multiop a chance to open
3118 $DIR/$tdir/$tfile && error || true
3121 run_test 43 "execution of file opened for write should return -ETXTBSY"
3124 test_mkdir -p $DIR/$tdir
3125 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3126 cp -p multiop $DIR/$tdir/multiop
3127 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3130 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3131 kill -USR1 $MULTIOP_PID || return 2
3132 wait $MULTIOP_PID || return 3
3135 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3138 test_mkdir -p $DIR/$tdir
3139 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3140 cp -p multiop $DIR/$tdir/multiop
3141 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3144 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3145 kill -USR1 $MULTIOP_PID || return 2
3146 wait $MULTIOP_PID || return 3
3149 run_test 43b "truncate of file being executed should return -ETXTBSY"
3152 local testdir="$DIR/$tdir"
3153 test_mkdir -p $DIR/$tdir
3155 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3156 ( cd $testdir && md5sum -c)
3158 run_test 43c "md5sum of copy into lustre========================"
3161 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3162 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3163 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3165 run_test 44 "zero length read from a sparse stripe ============="
3168 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3170 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3171 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3172 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3174 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3175 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3178 OFFSETS="0 $((stride/2)) $((stride-1))"
3179 for offset in $OFFSETS ; do
3180 for i in `seq 0 $((nstripe-1))`; do
3181 local GLOBALOFFSETS=""
3182 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3183 local myfn=$DIR/d44a-$size
3184 echo "--------writing $myfn at $size"
3185 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3186 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3187 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3188 || error "ll_sparseness_verify $GLOBALOFFSETS"
3190 for j in `seq 0 $((nstripe-1))`; do
3191 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3192 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3193 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3195 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3196 || error "ll_sparseness_verify $GLOBALOFFSETS"
3201 run_test 44a "test sparse pwrite ==============================="
3205 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3211 before=`dirty_osc_total`
3212 echo executing "\"$*\""
3214 after=`dirty_osc_total`
3215 echo before $before, after $after
3219 # Obtain grants from OST if it supports it
3220 echo blah > ${f}_grant
3223 do_dirty_record "echo blah > $f"
3224 [ $before -eq $after ] && error "write wasn't cached"
3225 do_dirty_record "> $f"
3226 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3227 do_dirty_record "echo blah > $f"
3228 [ $before -eq $after ] && error "write wasn't cached"
3229 do_dirty_record "sync"
3230 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3231 do_dirty_record "echo blah > $f"
3232 [ $before -eq $after ] && error "write wasn't cached"
3233 do_dirty_record "cancel_lru_locks osc"
3234 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3237 run_test 45 "osc io page accounting ============================"
3239 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3240 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3241 # objects offset and an assert hit when an rpc was built with 1023's mapped
3242 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3247 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3249 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3250 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3254 run_test 46 "dirtying a previously written page ================"
3256 # test_47 is removed "Device nodes check" is moved to test_28
3258 test_48a() { # bug 2399
3259 check_kernel_version 34 || return 0
3260 test_mkdir -p $DIR/$tdir
3262 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3263 test_mkdir $DIR/$tdir || error "recreate directory failed"
3264 touch foo || error "'touch foo' failed after recreating cwd"
3265 test_mkdir $DIR/$tdir/bar ||
3266 error "'mkdir foo' failed after recreating cwd"
3267 if check_kernel_version 44; then
3268 touch .foo || error "'touch .foo' failed after recreating cwd"
3269 test_mkdir $DIR/$tdir/.bar ||
3270 error "'mkdir .foo' failed after recreating cwd"
3272 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3273 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3274 cd . || error "'cd .' failed after recreating cwd"
3275 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3276 rmdir . && error "'rmdir .' worked after recreating cwd"
3277 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3278 cd .. || error "'cd ..' failed after recreating cwd"
3280 run_test 48a "Access renamed working dir (should return errors)="
3282 test_48b() { # bug 2399
3283 check_kernel_version 34 || return 0
3285 test_mkdir -p $DIR/$tdir
3287 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3288 touch foo && error "'touch foo' worked after removing cwd"
3289 test_mkdir $DIR/$tdir/foo &&
3290 error "'mkdir foo' worked after removing cwd"
3291 if check_kernel_version 44; then
3292 touch .foo && error "'touch .foo' worked after removing cwd"
3293 test_mkdir $DIR/$tdir/.foo &&
3294 error "'mkdir .foo' worked after removing cwd"
3296 ls . > /dev/null && error "'ls .' worked after removing cwd"
3297 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3298 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3299 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3300 rmdir . && error "'rmdir .' worked after removing cwd"
3301 ln -s . foo && error "'ln -s .' worked after removing cwd"
3302 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3304 run_test 48b "Access removed working dir (should return errors)="
3306 test_48c() { # bug 2350
3307 check_kernel_version 36 || return 0
3308 #lctl set_param debug=-1
3311 test_mkdir -p $DIR/$tdir/dir
3313 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3314 $TRACE touch foo && error "touch foo worked after removing cwd"
3315 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3316 if check_kernel_version 44; then
3317 touch .foo && error "touch .foo worked after removing cwd"
3318 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3320 $TRACE ls . && error "'ls .' worked after removing cwd"
3321 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3322 is_patchless || ( $TRACE cd . &&
3323 error "'cd .' worked after removing cwd" )
3324 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3325 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3326 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3327 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3329 run_test 48c "Access removed working subdir (should return errors)"
3331 test_48d() { # bug 2350
3332 check_kernel_version 36 || return 0
3333 #lctl set_param debug=-1
3336 test_mkdir -p $DIR/$tdir/dir
3338 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3339 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3340 $TRACE touch foo && error "'touch foo' worked after removing parent"
3341 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3342 if check_kernel_version 44; then
3343 touch .foo && error "'touch .foo' worked after removing parent"
3345 error "mkdir .foo worked after removing parent"
3347 $TRACE ls . && error "'ls .' worked after removing parent"
3348 $TRACE ls .. && error "'ls ..' worked after removing parent"
3349 is_patchless || ( $TRACE cd . &&
3350 error "'cd .' worked after recreate parent" )
3351 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3352 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3353 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3354 is_patchless || ( $TRACE cd .. &&
3355 error "'cd ..' worked after removing parent" || true )
3357 run_test 48d "Access removed parent subdir (should return errors)"
3359 test_48e() { # bug 4134
3360 check_kernel_version 41 || return 0
3361 #lctl set_param debug=-1
3364 test_mkdir -p $DIR/$tdir/dir
3366 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3367 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3368 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3369 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3370 # On a buggy kernel addition of "touch foo" after cd .. will
3371 # produce kernel oops in lookup_hash_it
3372 touch ../foo && error "'cd ..' worked after recreate parent"
3374 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3376 run_test 48e "Access to recreated parent subdir (should return errors)"
3378 test_49() { # LU-1030
3379 # get ost1 size - lustre-OST0000
3380 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3381 # write 800M at maximum
3382 [ $ost1_size -gt 819200 ] && ost1_size=819200
3384 lfs setstripe -c 1 -i 0 $DIR/$tfile
3385 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3388 # change max_pages_per_rpc while writing the file
3389 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3390 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3391 # loop until dd process exits
3392 while ps ax -opid | grep -wq $dd_pid; do
3393 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3394 sleep $((RANDOM % 5 + 1))
3396 # restore original max_pages_per_rpc
3397 $LCTL set_param $osc1_mppc=$orig_mppc
3398 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3400 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3404 test_mkdir $DIR/$tdir
3406 ls /proc/$$/cwd || error
3408 run_test 50 "special situations: /proc symlinks ==============="
3410 test_51a() { # was test_51
3411 # bug 1516 - create an empty entry right after ".." then split dir
3412 test_mkdir $DIR/$tdir
3413 touch $DIR/$tdir/foo
3414 $MCREATE $DIR/$tdir/bar
3416 createmany -m $DIR/$tdir/longfile 201
3418 while [ `ls -sd $DIR/$tdir | awk '{ print $1 }'` -eq 4 ]; do
3419 $MCREATE $DIR/$tdir/longfile$FNUM
3424 ls -l $DIR/$tdir > /dev/null || error
3426 run_test 51a "special situations: split htree with empty entry =="
3428 export NUMTEST=70000
3430 local BASE=$DIR/$tdir
3434 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3435 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3436 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3439 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3440 echo "reduced count to $NUMTEST due to inodes"
3442 # need to check free space for the directories as well
3443 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3444 numfree=$((blkfree / 4))
3445 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3446 echo "reduced count to $NUMTEST due to blocks"
3448 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3449 echo "failed" > $BASE/fnum
3451 run_test 51b "exceed 64k subdirectory nlink limit"
3453 test_51ba() { # LU-993
3454 local BASE=$DIR/$tdir
3455 # unlink all but 100 subdirectories, then check it still works
3457 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3459 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3460 local DELETE=$((NUMTEST - LEFT))
3462 # continue on to run this test even if 51b didn't finish,
3463 # just to delete the many subdirectories created.
3464 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3466 # for ldiskfs the nlink count should be 1, but this is OSD specific
3467 # and so this is listed for informational purposes only
3468 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3469 unlinkmany -d $BASE/d $DELETE
3472 if [ $RC -ne 0 ]; then
3473 if [ "$NUMPREV" == "failed" ]; then
3474 skip "previous setup failed"
3477 error "unlink of first $DELETE subdirs failed"
3482 echo "nlink between: $(stat -c %h $BASE)"
3483 # trim the first line of ls output
3484 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3485 [ $FOUND -ne $LEFT ] &&
3486 error "can't find subdirs: found only $FOUND/$LEFT"
3488 unlinkmany -d $BASE/d $DELETE $LEFT ||
3489 error "unlink of second $LEFT subdirs failed"
3490 # regardless of whether the backing filesystem tracks nlink accurately
3491 # or not, the nlink count shouldn't be more than "." and ".." here
3492 local AFTER=$(stat -c %h $BASE)
3493 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3494 echo "nlink after: $AFTER"
3496 run_test 51ba "verify nlink for many subdirectory cleanup"
3499 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3500 test_mkdir -p $DIR/$tdir
3501 createmany -o $DIR/$tdir/t- 1000
3502 $GETSTRIPE $DIR/$tdir > $TMP/files
3503 for N in `seq 0 $((OSTCOUNT - 1))`; do
3504 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3505 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3506 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3508 unlinkmany $DIR/$tdir/t- 1000
3511 for N in `seq 1 $((OSTCOUNT - 1))`; do
3512 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3513 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3514 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3515 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3517 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3518 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3519 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3520 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3524 run_test 51d "check object distribution ===================="
3527 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3528 test_mkdir -p $DIR/$tdir
3529 touch $DIR/$tdir/foo
3530 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3531 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3532 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3533 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3534 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3536 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3537 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3538 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3540 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3541 cp -r $DIR/$tdir /tmp/
3542 rm -fr $DIR/$tdir || error "cleanup rm failed"
3544 run_test 52a "append-only flag test (should return errors) ====="
3547 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3548 test_mkdir -p $DIR/$tdir
3549 touch $DIR/$tdir/foo
3550 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3551 cat test > $DIR/$tdir/foo && error "cat test worked"
3552 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3553 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3554 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3556 echo foo >> $DIR/$tdir/foo && error "echo worked"
3557 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3558 [ -f $DIR/$tdir/foo ] || error
3559 [ -f $DIR/$tdir/foo_ren ] && error
3560 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3562 chattr -i $DIR/$tdir/foo || error "chattr failed"
3564 rm -fr $DIR/$tdir || error
3566 run_test 52b "immutable flag test (should return errors) ======="
3569 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3570 remote_ost_nodsh && skip "remote OST with nodsh" && return
3579 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3580 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3581 param=`echo ${value[0]} | cut -d "=" -f1`
3582 ostname=`echo $param | cut -d "." -f2 | cut -d - -f 1-2`
3583 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3584 ostnum=$(echo $ostname | sed "s/${FSNAME}-OST//g" | awk '{print ($1+1)}' )
3585 ost_last=$(do_facet ost$ostnum lctl get_param -n obdfilter.$ostname.last_id | head -n 1)
3586 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3587 if [ $ost_last != $mds_last ]; then
3588 error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
3592 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3595 [ ! -f "$SOCKETSERVER" ] && skip_env "no socketserver, skipping" && return
3596 [ ! -f "$SOCKETCLIENT" ] && skip_env "no socketclient, skipping" && return
3597 $SOCKETSERVER $DIR/socket
3598 $SOCKETCLIENT $DIR/socket || error
3599 $MUNLINK $DIR/socket
3601 run_test 54a "unix domain socket test =========================="
3607 dd if=/dev/zero of=$f bs=`page_size` count=1
3609 run_test 54b "char device works in lustre ======================"
3612 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3613 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3614 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3616 for i in `seq 3 7`; do
3617 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3627 loopdev="$DIR/loop54c"
3630 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3631 mknod $loopdev b 7 $LOOPNUM
3632 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3633 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3634 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3635 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3637 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3638 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3640 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3645 run_test 54c "block device works in lustre ====================="
3651 [ "$string" = `echo $string > $f | cat $f` ] || error
3653 run_test 54d "fifo device works in lustre ======================"
3656 check_kernel_version 46 || return 0
3659 cp -aL /dev/console $f
3660 echo $string > $f || error
3662 run_test 54e "console/tty device works in lustre ======================"
3664 #The test_55 used to be iopen test and it was removed by bz#24037.
3665 #run_test 55 "check iopen_connect_dentry() ======================"
3667 test_56a() { # was test_56
3670 test_mkdir $DIR/$tdir
3671 test_mkdir $DIR/$tdir/dir
3673 NUMFILESx2=$(($NUMFILES * 2))
3674 for i in `seq 1 $NUMFILES` ; do
3675 touch $DIR/$tdir/file$i
3676 touch $DIR/$tdir/dir/file$i
3679 # test lfs getstripe with --recursive
3680 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3681 [ $FILENUM -eq $NUMFILESx2 ] ||
3682 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3683 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3684 [ $FILENUM -eq $NUMFILES ] ||
3685 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3686 echo "$GETSTRIPE --recursive passed."
3688 # test lfs getstripe with file instead of dir
3689 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3690 [ $FILENUM -eq 1 ] || error \
3691 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3692 echo "$GETSTRIPE file1 passed."
3694 #test lfs getstripe with --verbose
3695 [ `$GETSTRIPE --verbose $DIR/$tdir |
3696 grep -c lmm_magic` -eq $NUMFILES ] ||
3697 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3698 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3699 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3700 echo "$GETSTRIPE --verbose passed."
3702 #test lfs getstripe with --obd
3703 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3704 grep -q "unknown obduuid" ||
3705 error "$GETSTRIPE --obd wrong_uuid should return error message"
3707 [ "$OSTCOUNT" -lt 2 ] &&
3708 skip_env "skipping other $GETSTRIPE --obd test" && return
3711 OBDUUID=$(ostuuid_from_index $OSTIDX)
3712 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3713 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3714 [ $FOUND -eq $FILENUM ] ||
3715 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3716 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3717 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3718 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3719 error "$GETSTRIPE --obd: should not show file on other obd"
3720 echo "$GETSTRIPE --obd passed"
3722 run_test 56a "check $GETSTRIPE"
3727 local LOCAL_NUMFILES="$1"
3728 local LOCAL_NUMDIRS="$2"
3729 local MKDIR_PARAMS="$3"
3731 if [ ! -d "$TDIR" ] ; then
3733 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3734 for i in `seq 1 $LOCAL_NUMFILES` ; do
3737 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3738 test_mkdir $TDIR/dir$i
3739 for j in `seq 1 $LOCAL_NUMFILES` ; do
3740 touch $TDIR/dir$i/file$j
3746 setup_56_special() {
3750 if [ ! -e "$TDIR/loop1b" ] ; then
3751 for i in `seq 1 $LOCAL_NUMFILES` ; do
3752 mknod $TDIR/loop${i}b b 7 $i
3753 mknod $TDIR/null${i}c c 1 3
3754 ln -s $TDIR/file1 $TDIR/link${i}l
3756 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3757 mknod $TDIR/dir$i/loop${i}b b 7 $i
3758 mknod $TDIR/dir$i/null${i}c c 1 3
3759 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
3768 setup_56 $NUMFILES $NUMDIRS
3770 EXPECTED=$(($NUMDIRS + 2))
3771 # test lfs find with -name
3772 for i in $(seq 1 $NUMFILES) ; do
3773 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
3774 [ $NUMS -eq $EXPECTED ] ||
3775 error "lfs find -name \"*$i\" $TDIR wrong: "\
3776 "found $NUMS, expected $EXPECTED"
3779 run_test 56g "check lfs find -name ============================="
3785 setup_56 $NUMFILES $NUMDIRS
3787 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
3788 # test lfs find with ! -name
3789 for i in $(seq 1 $NUMFILES) ; do
3790 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
3791 [ $NUMS -eq $EXPECTED ] ||
3792 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
3793 "found $NUMS, expected $EXPECTED"
3796 run_test 56h "check lfs find ! -name ============================="
3800 test_mkdir -p $DIR/$tdir
3801 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
3802 CMD="$LFIND -ost $UUID $DIR/$tdir"
3804 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
3806 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
3810 setup_56_special $NUMFILES $NUMDIRS
3812 EXPECTED=$((NUMDIRS + 1))
3813 CMD="$LFIND -type d $TDIR"
3814 NUMS=$($CMD | wc -l)
3815 [ $NUMS -eq $EXPECTED ] ||
3816 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3818 run_test 56j "check lfs find -type d ============================="
3822 setup_56_special $NUMFILES $NUMDIRS
3824 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
3825 CMD="$LFIND -type f $TDIR"
3826 NUMS=$($CMD | wc -l)
3827 [ $NUMS -eq $EXPECTED ] ||
3828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3830 run_test 56k "check lfs find -type f ============================="
3834 setup_56_special $NUMFILES $NUMDIRS
3836 EXPECTED=$((NUMDIRS + NUMFILES))
3837 CMD="$LFIND -type b $TDIR"
3838 NUMS=$($CMD | wc -l)
3839 [ $NUMS -eq $EXPECTED ] ||
3840 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3842 run_test 56l "check lfs find -type b ============================="
3846 setup_56_special $NUMFILES $NUMDIRS
3848 EXPECTED=$((NUMDIRS + NUMFILES))
3849 CMD="$LFIND -type c $TDIR"
3850 NUMS=$($CMD | wc -l)
3851 [ $NUMS -eq $EXPECTED ] ||
3852 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3854 run_test 56m "check lfs find -type c ============================="
3858 setup_56_special $NUMFILES $NUMDIRS
3860 EXPECTED=$((NUMDIRS + NUMFILES))
3861 CMD="$LFIND -type l $TDIR"
3862 NUMS=$($CMD | wc -l)
3863 [ $NUMS -eq $EXPECTED ] ||
3864 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3866 run_test 56n "check lfs find -type l ============================="
3870 setup_56 $NUMFILES $NUMDIRS
3872 utime $TDIR/file1 > /dev/null || error "utime (1)"
3873 utime $TDIR/file2 > /dev/null || error "utime (2)"
3874 utime $TDIR/dir1 > /dev/null || error "utime (3)"
3875 utime $TDIR/dir2 > /dev/null || error "utime (4)"
3876 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
3877 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
3880 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
3881 [ $NUMS -eq $EXPECTED ] || \
3882 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
3885 CMD="$LFIND -mtime 0 $TDIR"
3886 NUMS=$($CMD | wc -l)
3887 [ $NUMS -eq $EXPECTED ] ||
3888 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3890 run_test 56o "check lfs find -mtime for old files =========================="
3893 [ $RUNAS_ID -eq $UID ] &&
3894 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3897 setup_56 $NUMFILES $NUMDIRS
3899 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
3901 CMD="$LFIND -uid $RUNAS_ID $TDIR"
3902 NUMS=$($CMD | wc -l)
3903 [ $NUMS -eq $EXPECTED ] || \
3904 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3906 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
3907 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
3908 NUMS=$($CMD | wc -l)
3909 [ $NUMS -eq $EXPECTED ] || \
3910 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3912 run_test 56p "check lfs find -uid and ! -uid ==============================="
3915 [ $RUNAS_ID -eq $UID ] &&
3916 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
3919 setup_56 $NUMFILES $NUMDIRS
3921 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
3924 CMD="$LFIND -gid $RUNAS_GID $TDIR"
3925 NUMS=$($CMD | wc -l)
3926 [ $NUMS -eq $EXPECTED ] ||
3927 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3929 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
3930 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
3931 NUMS=$($CMD | wc -l)
3932 [ $NUMS -eq $EXPECTED ] ||
3933 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3935 run_test 56q "check lfs find -gid and ! -gid ==============================="
3939 setup_56 $NUMFILES $NUMDIRS
3942 CMD="$LFIND -size 0 -type f $TDIR"
3943 NUMS=$($CMD | wc -l)
3944 [ $NUMS -eq $EXPECTED ] ||
3945 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3947 CMD="$LFIND ! -size 0 -type f $TDIR"
3948 NUMS=$($CMD | wc -l)
3949 [ $NUMS -eq $EXPECTED ] ||
3950 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3951 echo "test" > $TDIR/$tfile
3952 echo "test2" > $TDIR/$tfile.2 && sync
3954 CMD="$LFIND -size 5 -type f $TDIR"
3955 NUMS=$($CMD | wc -l)
3956 [ $NUMS -eq $EXPECTED ] ||
3957 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3959 CMD="$LFIND -size +5 -type f $TDIR"
3960 NUMS=$($CMD | wc -l)
3961 [ $NUMS -eq $EXPECTED ] ||
3962 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3964 CMD="$LFIND -size +0 -type f $TDIR"
3965 NUMS=$($CMD | wc -l)
3966 [ $NUMS -eq $EXPECTED ] ||
3967 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3969 CMD="$LFIND ! -size -5 -type f $TDIR"
3970 NUMS=$($CMD | wc -l)
3971 [ $NUMS -eq $EXPECTED ] ||
3972 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3974 CMD="$LFIND -size -5 -type f $TDIR"
3975 NUMS=$($CMD | wc -l)
3976 [ $NUMS -eq $EXPECTED ] ||
3977 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
3979 run_test 56r "check lfs find -size works =========================="
3981 test_56s() { # LU-611