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=" 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 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
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 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 local remote_dir=remote_dir
201 [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4690" && return #LU-4690
202 test_mkdir $DIR/$remote_dir ||
203 error "Create remote directory failed"
205 touch $DIR/$remote_dir/$tfile ||
206 error "Create file under remote directory failed"
208 rmdir $DIR/$remote_dir &&
209 error "Expect error removing in-use dir $DIR/$remote_dir"
211 test -d $DIR/$remote_dir || error "Remote directory disappeared"
213 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
216 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
217 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
218 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
219 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
220 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
222 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
225 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
226 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile does not have perm 0666 or UID $UID"
229 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile should be 0666 and owned by UID $UID"
233 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
238 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
241 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
245 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
250 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by GID $UID"
253 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
257 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
260 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
261 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
262 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
263 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
264 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
265 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
266 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
267 error "$tdir/d/subdir should be GID $RUNAS_GID"
269 run_test 6g "Is new dir in sgid dir inheriting group?"
271 test_6h() { # bug 7331
272 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
273 touch $DIR/$tfile || error "touch failed"
274 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
275 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
276 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
277 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
278 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
280 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
283 test_mkdir $DIR/$tdir
284 $MCREATE $DIR/$tdir/$tfile
285 chmod 0666 $DIR/$tdir/$tfile
286 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
287 error "$tdir/$tfile should be mode 0666"
289 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
292 if [ ! -d $DIR/$tdir ]; then
295 $MCREATE $DIR/$tdir/$tfile
296 echo -n foo > $DIR/$tdir/$tfile
297 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
298 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
300 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
303 test_mkdir $DIR/$tdir
304 touch $DIR/$tdir/$tfile
305 chmod 0666 $DIR/$tdir/$tfile
306 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
307 error "$tfile mode not 0666"
309 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 test_mkdir $DIR/$tdir/d2/d3
315 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
317 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
320 test_mkdir $DIR/$tdir
321 test_mkdir $DIR/$tdir/d2
322 touch $DIR/$tdir/d2/$tfile
323 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
324 error "$tdir/d2/$tfile not a file"
326 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 chmod 0666 $DIR/$tdir/d2
332 chmod 0705 $DIR/$tdir/d2
333 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
334 error "$tdir/d2 mode not 0705"
336 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
341 chmod 0666 $DIR/$tdir/$tfile
342 chmod 0654 $DIR/$tdir/$tfile
343 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
344 error "$tdir/d2 mode not 0654"
346 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
349 test_mkdir $DIR/$tdir
350 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
352 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
353 error "$tdir/$tfile size not 0 after truncate"
355 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
361 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
363 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
366 test_mkdir $DIR/$tdir
367 touch $DIR/$tdir/$tfile
368 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
369 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
370 error "$tdir/${tfile_2} not a file after rename"
372 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
377 rm -rf $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
383 test_mkdir -p $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
387 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not a symlink"
389 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not referencing a file"
391 rm -f $DIR/$tdir/l-exist
392 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
394 run_test 17a "symlinks: create, remove (real) =================="
397 test_mkdir -p $DIR/$tdir
398 ln -s no-such-file $DIR/$tdir/l-dangle
400 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing no-such-file"
402 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing non-existent file"
404 rm -f $DIR/$tdir/l-dangle
405 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
407 run_test 17b "symlinks: create, remove (dangling) =============="
409 test_17c() { # bug 3440 - don't save failed open RPC for replay
410 test_mkdir -p $DIR/$tdir
411 ln -s foo $DIR/$tdir/$tfile
412 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
414 run_test 17c "symlinks: open dangling (should return error) ===="
417 test_mkdir -p $DIR/$tdir
418 ln -s foo $DIR/$tdir/$tfile
419 touch $DIR/$tdir/$tfile || error "creating to new symlink"
421 run_test 17d "symlinks: create dangling ========================"
424 test_mkdir -p $DIR/$tdir
425 local foo=$DIR/$tdir/$tfile
426 ln -s $foo $foo || error "create symlink failed"
427 ls -l $foo || error "ls -l failed"
428 ls $foo && error "ls not failed" || true
430 run_test 17e "symlinks: create recursive symlink (should return error) ===="
433 test_mkdir -p $DIR/d17f
434 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
439 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
442 run_test 17f "symlinks: long and very long symlink name ========================"
444 # str_repeat(S, N) generate a string that is string S repeated N times
449 while [ $((n -= 1)) -ge 0 ]; do
455 # Long symlinks and LU-2241
457 test_mkdir -p $DIR/$tdir
458 local TESTS="59 60 61 4094 4095"
460 # Fix for inode size boundary in 2.1.4
461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
464 # Patch not applied to 2.2 or 2.3 branches
465 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
466 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
469 # skip long symlink name for rhel6.5.
470 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
471 grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
474 local SYMNAME=$(str_repeat 'x' $i)
475 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
476 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
479 run_test 17g "symlinks: really long symlink name and inode boundaries"
481 test_17h() { #bug 17378
482 remote_mds_nodsh && skip "remote MDS with nodsh" && return
483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && 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 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir -p $DIR/$tdir
502 local foo=$DIR/$tdir/$tfile
504 if [ $MDSCOUNT -gt 1 ]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 ln -s $foo $foo || error "create symlink failed"
510 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
512 ls -l $foo && error "error not detected"
515 run_test 17i "don't panic on short symlink"
517 test_17k() { #bug 22301
518 rsync --help | grep -q xattr ||
519 skip_env "$(rsync --version| head -1) does not support xattrs"
520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
521 test_mkdir -p $DIR/$tdir
522 test_mkdir -p $DIR/$tdir.new
523 touch $DIR/$tdir/$tfile
524 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
525 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
526 error "rsync failed with xattrs enabled"
528 run_test 17k "symlinks: rsync with xattrs enabled ========================="
530 test_17l() { # LU-279
532 touch $DIR/$tdir/$tfile
533 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
534 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
535 # -h to not follow symlinks. -m '' to list all the xattrs.
536 # grep to remove first line: '# file: $path'.
537 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
539 lgetxattr_size_check $path $xattr ||
540 error "lgetxattr_size_check $path $xattr failed"
544 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
548 local short_sym="0123456789"
549 local WDIR=$DIR/${tdir}m
556 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
557 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
558 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
560 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
561 skip "only for ldiskfs MDT" && return 0
563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
567 # create a long symlink file
568 for ((i = 0; i < 4; ++i)); do
569 long_sym=${long_sym}${long_sym}
572 echo "create 512 short and long symlink files under $WDIR"
573 for ((i = 0; i < 256; ++i)); do
574 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
575 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
581 wait_delete_completed
583 echo "recreate the 512 symlink files with a shorter string"
584 for ((i = 0; i < 512; ++i)); do
585 # rewrite the symlink file with a shorter string
586 ln -sf ${long_sym} $WDIR/long-$i
587 ln -sf ${short_sym} $WDIR/short-$i
590 mds_index=$($LFS getstripe -M $WDIR)
591 mds_index=$((mds_index+1))
592 devname=$(mdsdevname $mds_index)
593 cmd="$E2FSCK -fnvd $devname"
595 echo "stop and checking mds${mds_index}: $cmd"
596 # e2fsck should not return error
598 do_facet mds${mds_index} $cmd || rc=$?
600 start mds${mds_index} $devname $MDS_MOUNT_OPTS
601 df $MOUNT > /dev/null 2>&1
602 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
603 "short/long symlink MDT: rc=$rc"
606 run_test 17m "run e2fsck against MDT which contains short/long symlink"
608 check_fs_consistency_17n() {
614 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
615 # so it only check MDT1/MDT2 instead of all of MDTs.
616 for mdt_index in $(seq 1 2); do
617 devname=$(mdsdevname $mdt_index)
618 cmd="$E2FSCK -fnvd $devname"
620 echo "stop and checking mds${mdt_index}: $cmd"
621 # e2fsck should not return error
623 do_facet mds${mdt_index} $cmd || rc=$?
625 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
626 df $MOUNT > /dev/null 2>&1
627 [ $rc -ne 0 ] && break
635 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
636 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
637 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
639 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
640 skip "only for ldiskfs MDT" && return 0
642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
647 for ((i=0; i<10; i++)); do
648 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
649 error "create remote dir error $i"
650 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
651 error "create files under remote dir failed $i"
654 check_fs_consistency_17n ||
655 error "e2fsck report error after create files under remote dir"
657 for ((i=0;i<10;i++)); do
658 rm -rf $DIR/$tdir/remote_dir_${i} ||
659 error "destroy remote dir error $i"
662 check_fs_consistency_17n ||
663 error "e2fsck report error after unlink files under remote dir"
665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
666 skip "lustre < 2.4.50 does not support migrate mv " && return
668 for ((i=0; i<10; i++)); do
669 mkdir -p $DIR/$tdir/remote_dir_${i}
670 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
671 error "create files under remote dir failed $i"
672 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
673 error "migrate remote dir error $i"
675 check_fs_consistency_17n || error "e2fsck report error after migration"
677 for ((i=0;i<10;i++)); do
678 rm -rf $DIR/$tdir/remote_dir_${i} ||
679 error "destroy remote dir error $i"
682 check_fs_consistency_17n || error "e2fsck report error after unlink"
684 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
687 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
688 skip "Need MDS version at least 2.3.64" && return
690 local WDIR=$DIR/${tdir}o
696 mdt_index=$($LFS getstripe -M $WDIR)
697 mdt_index=$((mdt_index+1))
698 mdtdevname=$(mdsdevname $mdt_index)
702 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
704 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
705 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
706 ls -l $WDIR/$tfile && rc=1
707 do_facet mds${mdt_index} lctl set_param fail_loc=0
708 [[ $rc -ne 0 ]] && error "stat file should fail"
711 run_test 17o "stat file with incompat LMA feature"
714 touch $DIR/f || error "Failed to touch $DIR/f: $?"
715 ls $DIR || error "Failed to ls $DIR: $?"
717 run_test 18 "touch .../f ; ls ... =============================="
723 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
725 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
728 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
730 run_test 19b "ls -l .../f19 (should return error) =============="
733 [ $RUNAS_ID -eq $UID ] &&
734 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
735 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
737 run_test 19c "$RUNAS touch .../f19 (should return error) =="
740 cat $DIR/f19 && error || true
742 run_test 19d "cat .../f19 (should return error) =============="
754 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
756 run_test 20 "touch .../f ; ls -l ... ==========================="
759 test_mkdir -p $DIR/$tdir
760 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
761 ln -s dangle $DIR/$tdir/link
762 echo foo >> $DIR/$tdir/link
763 cat $DIR/$tdir/dangle
764 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
765 $CHECKSTAT -f -t file $DIR/$tdir/link ||
766 error "$tdir/link not linked to a file"
768 run_test 21 "write to dangling link ============================"
772 test_mkdir -p $DIR/$tdir
773 chown $RUNAS_ID:$RUNAS_GID $WDIR
774 (cd $WDIR || error "cd $WDIR failed";
775 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
777 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
778 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
779 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
781 run_test 22 "unpack tar archive as non-root user ==============="
785 test_mkdir -p $DIR/$tdir
786 local file=$DIR/$tdir/$tfile
788 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
789 openfile -f O_CREAT:O_EXCL $file &&
790 error "$file recreate succeeded" || true
792 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
794 test_23b() { # bug 18988
795 test_mkdir -p $DIR/$tdir
796 local file=$DIR/$tdir/$tfile
799 echo foo > $file || error "write filed"
800 echo bar >> $file || error "append filed"
801 $CHECKSTAT -s 8 $file || error "wrong size"
804 run_test 23b "O_APPEND check =========================="
808 echo '-- same directory rename'
809 test_mkdir $DIR/$tdir
810 touch $DIR/$tdir/$tfile.1
811 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
812 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
814 run_test 24a "rename file to non-existent target"
817 test_mkdir $DIR/$tdir
818 touch $DIR/$tdir/$tfile.{1,2}
819 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
820 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
821 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
823 run_test 24b "rename file to existing target"
826 test_mkdir $DIR/$tdir
827 test_mkdir $DIR/$tdir/d$testnum.1
828 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
829 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
830 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
832 run_test 24c "rename directory to non-existent target"
835 test_mkdir -c1 $DIR/$tdir
836 test_mkdir -c1 $DIR/$tdir/d$testnum.1
837 test_mkdir -c1 $DIR/$tdir/d$testnum.2
838 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
839 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
840 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
842 run_test 24d "rename directory to existing target"
845 echo '-- cross directory renames --'
849 mv $DIR/R5a/f $DIR/R5b/g
850 $CHECKSTAT -a $DIR/R5a/f || error
851 $CHECKSTAT -t file $DIR/R5b/g || error
853 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
858 touch $DIR/R6a/f $DIR/R6b/g
859 mv $DIR/R6a/f $DIR/R6b/g
860 $CHECKSTAT -a $DIR/R6a/f || error
861 $CHECKSTAT -t file $DIR/R6b/g || error
863 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
868 test_mkdir $DIR/R7a/d
869 mv $DIR/R7a/d $DIR/R7b/e
870 $CHECKSTAT -a $DIR/R7a/d || error
871 $CHECKSTAT -t dir $DIR/R7b/e || error
873 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
876 test_mkdir -c1 $DIR/R8a
877 test_mkdir -c1 $DIR/R8b
878 test_mkdir -c1 $DIR/R8a/d
879 test_mkdir -c1 $DIR/R8b/e
880 mrename $DIR/R8a/d $DIR/R8b/e
881 $CHECKSTAT -a $DIR/R8a/d || error
882 $CHECKSTAT -t dir $DIR/R8b/e || error
884 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
887 echo "-- rename error cases"
891 mrename $DIR/R9/f $DIR/R9/a
892 $CHECKSTAT -t file $DIR/R9/f || error
893 $CHECKSTAT -t dir $DIR/R9/a || error
894 $CHECKSTAT -a $DIR/R9/a/f || error
896 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
900 mrename $DIR/R10/f $DIR/R10/g
901 $CHECKSTAT -t dir $DIR/R10 || error
902 $CHECKSTAT -a $DIR/R10/f || error
903 $CHECKSTAT -a $DIR/R10/g || error
905 run_test 24j "source does not exist ============================"
909 test_mkdir $DIR/R11a/d
911 mv $DIR/R11a/f $DIR/R11a/d
912 $CHECKSTAT -a $DIR/R11a/f || error
913 $CHECKSTAT -t file $DIR/R11a/d/f || error
915 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
917 # bug 2429 - rename foo foo foo creates invalid file
920 $MULTIOP $f OcNs || error
922 run_test 24l "Renaming a file to itself ========================"
926 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
927 # on ext3 this does not remove either the source or target files
928 # though the "expected" operation would be to remove the source
929 $CHECKSTAT -t file ${f} || error "${f} missing"
930 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
932 run_test 24m "Renaming a file to a hard link to itself ========="
936 # this stats the old file after it was renamed, so it should fail
940 $CHECKSTAT ${f}.rename
943 run_test 24n "Statting the old file after renaming (Posix rename 2)"
946 check_kernel_version 37 || return 0
947 test_mkdir -p $DIR/d24o
948 rename_many -s random -v -n 10 $DIR/d24o
950 run_test 24o "rename of files during htree split ==============="
955 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
956 mrename $DIR/R12a $DIR/R12b
957 $CHECKSTAT -a $DIR/R12a || error
958 $CHECKSTAT -t dir $DIR/R12b || error
959 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
960 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
962 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
964 cleanup_multiop_pause() {
970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
973 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
974 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
977 trap cleanup_multiop_pause EXIT
978 mrename $DIR/R13a $DIR/R13b
979 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
980 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
981 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
982 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
983 cleanup_multiop_pause
984 wait $MULTIPID || error "multiop close failed"
986 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
988 test_24r() { #bug 3789
990 test_mkdir $DIR/R14a/b
991 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
992 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
993 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
995 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
999 test_mkdir $DIR/R15a/b
1000 test_mkdir $DIR/R15a/b/c
1001 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1002 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1003 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1005 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1007 test_mkdir $DIR/R16a
1008 test_mkdir $DIR/R16a/b
1009 test_mkdir $DIR/R16a/b/c
1010 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1011 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1012 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1014 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1016 test_24u() { # bug12192
1018 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1019 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1021 run_test 24u "create stripe file"
1027 simple_cleanup_common() {
1030 wait_delete_completed
1033 max_pages_per_rpc() {
1034 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1038 local NRFILES=100000
1039 local FREE_INODES=$(mdt_free_inodes 0)
1040 [ $FREE_INODES -lt $NRFILES ] && \
1041 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1045 trap simple_cleanup_common EXIT
1047 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1048 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1051 createmany -m $DIR/$tdir/$tfile $NRFILES
1053 cancel_lru_locks mdc
1054 lctl set_param mdc.*.stats clear
1056 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1058 # LU-5 large readdir
1059 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1060 # 8 bytes for name(filename is mostly 5 in this test) +
1061 # 8 bytes for luda_type
1062 # take into account of overhead in lu_dirpage header and end mark in
1063 # each page, plus one in RPC_NUM calculation.
1065 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1066 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1067 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1068 awk '/^mds_readpage/ {print $2}')
1069 [ $mds_readpage -gt $RPC_NUM ] && \
1070 error "large readdir doesn't take effect"
1072 simple_cleanup_common
1074 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1076 test_24w() { # bug21506
1078 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1079 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1080 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1081 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1082 [ "$SZ1" = "$SZ2" ] || \
1083 error "Error reading at the end of the file $tfile"
1085 run_test 24w "Reading a file larger than 4Gb"
1088 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local remote_dir=$DIR/$tdir/remote_dir
1094 $LFS mkdir -i $MDTIDX $remote_dir ||
1095 error "create remote directory failed"
1097 mkdir -p $DIR/$tdir/src_dir
1098 touch $DIR/$tdir/src_file
1099 mkdir -p $remote_dir/tgt_dir
1100 touch $remote_dir/tgt_file
1102 mrename $remote_dir $DIR/ &&
1103 error "rename dir cross MDT works!"
1105 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1106 error "rename dir cross MDT works!"
1108 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1109 error "rename file cross MDT works!"
1111 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1112 error "ln file cross MDT should not work!"
1114 rm -rf $DIR/$tdir || error "Can not delete directories"
1116 run_test 24x "cross rename/link should be failed"
1119 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1122 local remote_dir=$DIR/$tdir/remote_dir
1125 $LFS mkdir -i $MDTIDX $remote_dir ||
1126 error "create remote directory failed"
1128 mkdir -p $remote_dir/src_dir
1129 touch $remote_dir/src_file
1130 mkdir -p $remote_dir/tgt_dir
1131 touch $remote_dir/tgt_file
1133 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1134 error "rename subdir in the same remote dir failed!"
1136 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1137 error "rename files in the same remote dir failed!"
1139 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1140 error "link files in the same remote dir failed!"
1142 rm -rf $DIR/$tdir || error "Can not delete directories"
1144 run_test 24y "rename/link on the same dir should succeed"
1147 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1150 local remote_src=$DIR/$tdir/remote_dir
1151 local remote_tgt=$DIR/$tdir/remote_tgt
1154 $LFS mkdir -i $MDTIDX $remote_src ||
1155 error "create remote directory failed"
1157 $LFS mkdir -i $MDTIDX $remote_tgt ||
1158 error "create remote directory failed"
1160 mrename $remote_src $remote_tgt &&
1161 error "rename remote dirs should not work!"
1163 # If target dir does not exists, it should succeed
1165 mrename $remote_src $remote_tgt ||
1166 error "rename remote dirs(tgt dir does not exists) failed!"
1168 rm -rf $DIR/$tdir || error "Can not delete directories"
1170 run_test 24z "rename one remote dir to another remote dir should fail"
1172 test_24A() { # LU-3182
1177 createmany -m $DIR/$tdir/$tfile $NFILES
1178 local t=`ls $DIR/$tdir | wc -l`
1179 local u=`ls $DIR/$tdir | sort -u | wc -l`
1180 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1181 error "Expected $NFILES files, got $t ($u unique)"
1184 rm -rf $DIR/$tdir || error "Can not delete directories"
1186 run_test 24A "readdir() returns correct number of entries."
1189 echo '== symlink sanity ============================================='
1193 touch $DIR/s25/foo || error
1195 run_test 25a "create file in symlinked directory ==============="
1198 [ ! -d $DIR/d25 ] && test_25a
1199 $CHECKSTAT -t file $DIR/s25/foo || error
1201 run_test 25b "lookup file in symlinked directory ==============="
1205 test_mkdir $DIR/d26/d26-2
1206 ln -s d26/d26-2 $DIR/s26
1207 touch $DIR/s26/foo || error
1209 run_test 26a "multiple component symlink ======================="
1212 test_mkdir -p $DIR/d26b/d26-2
1213 ln -s d26b/d26-2/foo $DIR/s26-2
1214 touch $DIR/s26-2 || error
1216 run_test 26b "multiple component symlink at end of lookup ======"
1219 test_mkdir $DIR/d26.2
1220 touch $DIR/d26.2/foo
1221 ln -s d26.2 $DIR/s26.2-1
1222 ln -s s26.2-1 $DIR/s26.2-2
1223 ln -s s26.2-2 $DIR/s26.2-3
1224 chmod 0666 $DIR/s26.2-3/foo
1226 run_test 26c "chain of symlinks ================================"
1228 # recursive symlinks (bug 439)
1230 ln -s d26-3/foo $DIR/d26-3
1232 run_test 26d "create multiple component recursive symlink ======"
1235 [ ! -h $DIR/d26-3 ] && test_26d
1238 run_test 26e "unlink multiple component recursive symlink ======"
1240 # recursive symlinks (bug 7022)
1242 test_mkdir -p $DIR/$tdir
1243 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1244 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1245 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1246 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1247 cd $tfile || error "cd $tfile failed"
1248 ln -s .. dotdot || error "ln dotdot failed"
1249 ln -s dotdot/lndir lndir || error "ln lndir failed"
1250 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1251 output=`ls $tfile/$tfile/lndir/bar1`
1252 [ "$output" = bar1 ] && error "unexpected output"
1253 rm -r $tfile || error "rm $tfile failed"
1254 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1256 run_test 26f "rm -r of a directory which has recursive symlink ="
1259 echo '== stripe sanity =============================================='
1260 test_mkdir -p $DIR/d27 || error "mkdir failed"
1262 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1263 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1265 log "== test_27a: write to one stripe file ========================="
1266 cp /etc/hosts $DIR/d27/f0 || error
1268 run_test 27a "one stripe file =================================="
1271 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1272 test_mkdir -p $DIR/d27
1273 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1274 $GETSTRIPE -c $DIR/d27/f01
1275 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1276 error "two-stripe file doesn't have two stripes"
1278 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1280 run_test 27b "create and write to two stripe file"
1283 test_mkdir -p $DIR/d27
1284 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1285 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1286 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1288 run_test 27d "create file with default settings ================"
1291 test_mkdir -p $DIR/d27
1292 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1293 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1294 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1296 run_test 27e "setstripe existing file (should return error) ======"
1299 test_mkdir -p $DIR/d27
1300 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1301 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1302 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1304 run_test 27f "setstripe with bad stripe size (should return error)"
1307 test_mkdir -p $DIR/d27
1308 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1309 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1310 error "$DIR/d27/fnone has object"
1312 run_test 27g "$GETSTRIPE with no objects"
1315 touch $DIR/d27/fsome || error "touch failed"
1316 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1318 run_test 27i "$GETSTRIPE with some objects"
1321 test_mkdir -p $DIR/d27
1322 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1324 run_test 27j "setstripe with bad stripe offset (should return error)"
1326 test_27k() { # bug 2844
1327 test_mkdir -p $DIR/d27
1329 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1330 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1331 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1332 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1333 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1334 dd if=/dev/zero of=$FILE bs=4k count=1
1335 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1336 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1338 run_test 27k "limit i_blksize for broken user apps ============="
1341 test_mkdir -p $DIR/d27
1342 mcreate $DIR/f27l || error "creating file"
1343 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1344 error "setstripe should have failed" || true
1346 run_test 27l "check setstripe permissions (should return error)"
1349 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1351 if [ $ORIGFREE -gt $MAXFREE ]; then
1352 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1355 trap simple_cleanup_common EXIT
1356 test_mkdir -p $DIR/$tdir
1357 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1358 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1359 error "dd should fill OST0"
1361 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1363 [ $i -gt 256 ] && break
1366 touch $DIR/$tdir/f27m_$i
1367 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1368 error "OST0 was full but new created file still use it"
1370 touch $DIR/$tdir/f27m_$i
1371 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1372 error "OST0 was full but new created file still use it"
1373 simple_cleanup_common
1375 run_test 27m "create file while OST0 was full =================="
1378 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1382 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1383 # if the OST isn't full anymore.
1385 local OSTIDX=${1:-""}
1387 local list=$(comma_list $(osts_nodes))
1388 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1390 do_nodes $list lctl set_param fail_loc=0
1391 sync # initiate all OST_DESTROYs from MDS to OST
1395 exhaust_precreations() {
1398 local FAILIDX=${3:-$OSTIDX}
1400 test_mkdir -p $DIR/$tdir
1401 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1402 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1404 local OST=$(ostname_from_index $OSTIDX)
1405 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1406 sed -e 's/_UUID$//;s/^.*-//')
1409 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1410 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1411 osc.$mdtosc_proc1.prealloc_last_id)
1412 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1413 osc.$mdtosc_proc1.prealloc_next_id)
1415 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1416 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1418 test_mkdir -p $DIR/$tdir/${OST}
1419 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1420 #define OBD_FAIL_OST_ENOSPC 0x215
1421 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1422 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1423 echo "Creating to objid $last_id on ost $OST..."
1424 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1425 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1426 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1430 exhaust_all_precreations() {
1432 for (( i=0; i < OSTCOUNT; i++ )) ; do
1433 exhaust_precreations $i $1 -1
1438 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1440 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1441 remote_ost_nodsh && skip "remote OST with nodsh" && return
1444 rm -f $DIR/$tdir/$tfile
1445 exhaust_precreations 0 0x80000215
1446 $SETSTRIPE -c -1 $DIR/$tdir
1447 touch $DIR/$tdir/$tfile || error
1448 $GETSTRIPE $DIR/$tdir/$tfile
1451 run_test 27n "create file with some full OSTs =================="
1454 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1457 remote_ost_nodsh && skip "remote OST with nodsh" && return
1460 rm -f $DIR/$tdir/$tfile
1461 exhaust_all_precreations 0x215
1463 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1468 run_test 27o "create file with all full OSTs (should error) ===="
1471 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1473 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1474 remote_ost_nodsh && skip "remote OST with nodsh" && return
1477 rm -f $DIR/$tdir/$tfile
1478 test_mkdir -p $DIR/$tdir
1480 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1481 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1482 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1484 exhaust_precreations 0 0x80000215
1485 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1486 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1487 $GETSTRIPE $DIR/$tdir/$tfile
1491 run_test 27p "append to a truncated file with some full OSTs ==="
1494 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1497 remote_ost_nodsh && skip "remote OST with nodsh" && return
1500 rm -f $DIR/$tdir/$tfile
1502 test_mkdir -p $DIR/$tdir
1503 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1504 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1505 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1507 exhaust_all_precreations 0x215
1509 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1510 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1514 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1517 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 remote_ost_nodsh && skip "remote OST with nodsh" && return
1523 rm -f $DIR/$tdir/$tfile
1524 exhaust_precreations 0 0x80000215
1526 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1530 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1532 test_27s() { # bug 10725
1533 test_mkdir -p $DIR/$tdir
1534 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1535 local stripe_count=0
1536 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1537 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1538 error "stripe width >= 2^32 succeeded" || true
1541 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1543 test_27t() { # bug 10864
1548 $WLFS getstripe $tfile
1551 run_test 27t "check that utils parse path correctly"
1553 test_27u() { # bug 4900
1554 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 local list=$(comma_list $(mdts_nodes))
1559 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1560 do_nodes $list $LCTL set_param fail_loc=0x139
1561 test_mkdir -p $DIR/$tdir
1563 createmany -o $DIR/$tdir/t- 1000
1564 do_nodes $list $LCTL set_param fail_loc=0
1566 TLOG=$DIR/$tfile.getstripe
1567 $GETSTRIPE $DIR/$tdir > $TLOG
1568 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1569 unlinkmany $DIR/$tdir/t- 1000
1570 [ $OBJS -gt 0 ] && \
1571 error "$OBJS objects created on OST-0. See $TLOG" || pass
1573 run_test 27u "skip object creation on OSC w/o objects =========="
1575 test_27v() { # bug 4900
1576 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1579 remote_ost_nodsh && skip "remote OST with nodsh" && return
1581 exhaust_all_precreations 0x215
1584 test_mkdir -p $DIR/$tdir
1585 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1587 touch $DIR/$tdir/$tfile
1588 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1590 for (( i=1; i < OSTCOUNT; i++ )); do
1591 do_facet ost$i lctl set_param fail_loc=0x705
1593 local START=`date +%s`
1594 createmany -o $DIR/$tdir/$tfile 32
1596 local FINISH=`date +%s`
1597 local TIMEOUT=`lctl get_param -n timeout`
1598 local PROCESS=$((FINISH - START))
1599 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1600 error "$FINISH - $START >= $TIMEOUT / 2"
1601 sleep $((TIMEOUT / 2 - PROCESS))
1604 run_test 27v "skip object creation on slow OST ================="
1606 test_27w() { # bug 10997
1607 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1608 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1609 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1610 error "stripe size $size != 65536" || true
1611 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1612 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1614 run_test 27w "check $SETSTRIPE -S option"
1617 [ "$OSTCOUNT" -lt "2" ] &&
1618 skip_env "skipping multiple stripe count/offset test" && return
1620 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1621 for i in $(seq 1 $OSTCOUNT); do
1623 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1624 error "setstripe -c $i -i $offset failed"
1625 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1626 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1627 [ $count -ne $i ] && error "stripe count $count != $i" || true
1628 [ $index -ne $offset ] &&
1629 error "stripe offset $index != $offset" || true
1632 run_test 27wa "check $SETSTRIPE -c -i options"
1635 remote_ost_nodsh && skip "remote OST with nodsh" && return
1636 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1638 OFFSET=$(($OSTCOUNT - 1))
1640 local OST=$(ostname_from_index $OSTIDX)
1642 test_mkdir -p $DIR/$tdir
1643 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1644 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1646 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1647 for i in `seq 0 $OFFSET`; do
1648 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1649 error "OST0 was degraded but new created file still use it"
1651 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1653 run_test 27x "create files while OST0 is degraded"
1656 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1657 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1658 remote_ost_nodsh && skip "remote OST with nodsh" && return
1659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1662 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1663 osc.$mdtosc.prealloc_last_id)
1664 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1665 osc.$mdtosc.prealloc_next_id)
1666 local fcount=$((last_id - next_id))
1667 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1668 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1670 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1671 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1672 local OST_DEACTIVE_IDX=-1
1677 for OSC in $MDS_OSCS; do
1678 OST=$(osc_to_ost $OSC)
1679 OSTIDX=$(index_from_ostuuid $OST)
1680 if [ $OST_DEACTIVE_IDX == -1 ]; then
1681 OST_DEACTIVE_IDX=$OSTIDX
1683 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1684 echo $OSC "is Deactivated:"
1685 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1689 OSTIDX=$(index_from_ostuuid $OST)
1691 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1693 for OSC in $MDS_OSCS; do
1694 OST=$(osc_to_ost $OSC)
1695 OSTIDX=$(index_from_ostuuid $OST)
1696 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1697 echo $OST "is degraded:"
1698 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1699 obdfilter.$OST.degraded=1
1704 createmany -o $DIR/$tdir/$tfile $fcount
1706 for OSC in $MDS_OSCS; do
1707 OST=$(osc_to_ost $OSC)
1708 OSTIDX=$(index_from_ostuuid $OST)
1709 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1710 echo $OST "is recovered from degraded:"
1711 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1712 obdfilter.$OST.degraded=0
1714 do_facet $SINGLEMDS lctl --device %$OSC activate
1718 # all osp devices get activated, hence -1 stripe count restored
1721 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1722 # devices get activated.
1724 $SETSTRIPE -c -1 $DIR/$tfile
1725 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1727 [ $stripecnt -ne $OSTCOUNT ] &&
1728 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1731 run_test 27y "create files while OST0 is degraded and the rest inactive"
1737 lmm_count=$($GETSTRIPE -c $1)
1738 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1739 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1741 local old_ifs="$IFS"
1743 fid=($($LFS path2fid $1))
1746 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1747 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1749 # compare lmm_seq and lu_fid->f_seq
1750 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1751 # compare lmm_object_id and lu_fid->oid
1752 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1754 # check the trusted.fid attribute of the OST objects of the file
1755 local have_obdidx=false
1757 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1758 # skip lines up to and including "obdidx"
1759 [ -z "$obdidx" ] && break
1760 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1761 $have_obdidx || continue
1763 local ost=$((obdidx + 1))
1764 local dev=$(ostdevname $ost)
1767 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1769 seq=$(echo $seq | sed -e "s/^0x//g")
1770 if [ $seq == 0 ]; then
1771 oid_hex=$(echo $oid)
1773 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1775 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1779 # Don't unmount/remount the OSTs if we don't need to do that.
1780 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1781 # update too, until that use mount/ll_decode_filter_fid/mount.
1782 # Re-enable when debugfs will understand new filter_fid.
1784 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1785 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1786 $dev 2>/dev/null" | grep "parent=")
1789 mount_fstype ost$ost
1790 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1791 $(facet_mntpt ost$ost)/$obj_file)
1792 unmount_fstype ost$ost
1793 start ost$ost $dev $OST_MOUNT_OPTS
1796 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1798 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1800 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1801 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1802 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1803 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1804 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1806 if echo $ff_parent | grep -q 'stripe='; then
1807 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1810 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1811 # into f_ver in this case. See the comment on
1814 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1818 # compare lmm_seq and filter_fid->ff_parent.f_seq
1819 [ $ff_pseq = $lmm_seq ] ||
1820 error "FF parent SEQ $ff_pseq != $lmm_seq"
1821 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1822 [ $ff_poid = $lmm_oid ] ||
1823 error "FF parent OID $ff_poid != $lmm_oid"
1824 (($ff_pstripe == $stripe_nr)) ||
1825 error "FF stripe $ff_pstripe != $stripe_nr"
1827 stripe_nr=$((stripe_nr + 1))
1832 remote_ost_nodsh && skip "remote OST with nodsh" && return
1833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1834 test_mkdir -p $DIR/$tdir
1836 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1837 { error "setstripe -c -1 failed"; return 1; }
1838 # We need to send a write to every object to get parent FID info set.
1839 # This _should_ also work for setattr, but does not currently.
1840 # touch $DIR/$tdir/$tfile-1 ||
1841 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1842 { error "dd $tfile-1 failed"; return 2; }
1843 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1844 { error "setstripe -c -1 failed"; return 3; }
1845 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1846 { error "dd $tfile-2 failed"; return 4; }
1848 # make sure write RPCs have been sent to OSTs
1851 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1852 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1854 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1856 test_27A() { # b=19102
1857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1858 local restore_size=$($GETSTRIPE -S $MOUNT)
1859 local restore_count=$($GETSTRIPE -c $MOUNT)
1860 local restore_offset=$($GETSTRIPE -i $MOUNT)
1861 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1862 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1863 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1864 local default_size=$($GETSTRIPE -S $MOUNT)
1865 local default_offset=$($GETSTRIPE -i $MOUNT)
1866 local dsize=$((1024 * 1024))
1867 [ $default_size -eq $dsize ] ||
1868 error "stripe size $default_size != $dsize"
1869 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1870 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1872 run_test 27A "check filesystem-wide default LOV EA values"
1874 test_27B() { # LU-2523
1875 test_mkdir -p $DIR/$tdir
1876 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1878 # open f1 with O_LOV_DELAY_CREATE
1880 # call setstripe ioctl on open file descriptor for f1
1882 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1886 # open f1 with O_LOV_DELAY_CREATE
1888 # call setstripe ioctl on open file descriptor for f1
1890 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1892 # Allow multiop to fail in imitation of NFS's busted semantics.
1895 run_test 27B "call setstripe on open unlinked file/rename victim"
1897 test_27C() { #LU-2871
1898 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1906 test_mkdir -p $DIR/$tdir
1908 for i in $(seq 0 $((OSTCOUNT - 1))); do
1909 # set stripe across all OSTs starting from OST$i
1910 $SETSTRIPE -i $i -c -1 $tfile$i
1911 # get striping information
1912 ost_idx=($($GETSTRIPE $tfile$i |
1913 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1917 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1918 error "${#ost_idx[@]} != $OSTCOUNT"
1920 for index in $(seq 0 $((OSTCOUNT - 1))); do
1922 for j in $(echo ${ost_idx[@]}); do
1923 if [ $index -eq $j ]; then
1929 error "Can not find $index in ${ost_idx[@]}"
1933 run_test 27C "check full striping across all OSTs"
1935 # createtest also checks that device nodes are created and
1936 # then visible correctly (#2091)
1937 test_28() { # bug 2091
1939 $CREATETEST $DIR/d28/ct || error
1941 run_test 28 "create/mknod/mkdir with bad file types ============"
1944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1945 cancel_lru_locks mdc
1951 declare -i LOCKCOUNTORIG=0
1952 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1953 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1955 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1957 declare -i LOCKUNUSEDCOUNTORIG=0
1958 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1959 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1966 declare -i LOCKCOUNTCURRENT=0
1967 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1968 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1971 declare -i LOCKUNUSEDCOUNTCURRENT=0
1972 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1973 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1976 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1977 lctl set_param -n ldlm.dump_namespaces ""
1978 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1979 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1980 log "dumped log to $TMP/test_29.dk (bug 5793)"
1983 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1984 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1985 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1986 log "dumped log to $TMP/test_29.dk (bug 5793)"
1990 run_test 29 "IT_GETATTR regression ============================"
1992 test_30a() { # was test_30
1993 cp `which ls` $DIR || cp /bin/ls $DIR
1997 run_test 30a "execute binary from Lustre (execve) =============="
2000 cp `which ls` $DIR || cp /bin/ls $DIR
2002 $RUNAS $DIR/ls / || error
2005 run_test 30b "execute binary from Lustre as non-root ==========="
2007 test_30c() { # b=22376
2008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2009 cp `which ls` $DIR || cp /bin/ls $DIR
2011 cancel_lru_locks mdc
2012 cancel_lru_locks osc
2013 $RUNAS $DIR/ls / || error
2016 run_test 30c "execute binary from Lustre without read perms ===="
2019 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2020 $CHECKSTAT -a $DIR/f31 || error
2022 run_test 31a "open-unlink file =================================="
2025 touch $DIR/f31 || error
2026 ln $DIR/f31 $DIR/f31b || error
2027 $MULTIOP $DIR/f31b Ouc || error
2028 $CHECKSTAT -t file $DIR/f31 || error
2030 run_test 31b "unlink file with multiple links while open ======="
2033 touch $DIR/f31 || error
2034 ln $DIR/f31 $DIR/f31c || error
2035 multiop_bg_pause $DIR/f31 O_uc || return 1
2037 $MULTIOP $DIR/f31c Ouc
2038 kill -USR1 $MULTIPID
2041 run_test 31c "open-unlink file with multiple links ============="
2044 opendirunlink $DIR/d31d $DIR/d31d || error
2045 $CHECKSTAT -a $DIR/d31d || error
2047 run_test 31d "remove of open directory ========================="
2049 test_31e() { # bug 2904
2050 check_kernel_version 34 || return 0
2051 openfilleddirunlink $DIR/d31e || error
2053 run_test 31e "remove of open non-empty directory ==============="
2055 test_31f() { # bug 4554
2056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2058 test_mkdir $DIR/d31f
2059 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2060 cp /etc/hosts $DIR/d31f
2062 $GETSTRIPE $DIR/d31f/hosts
2063 multiop_bg_pause $DIR/d31f D_c || return 1
2066 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2067 test_mkdir $DIR/d31f
2068 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2069 cp /etc/hosts $DIR/d31f
2071 $GETSTRIPE $DIR/d31f/hosts
2072 multiop_bg_pause $DIR/d31f D_c || return 1
2075 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2076 wait $MULTIPID || error "first opendir $MULTIPID failed"
2080 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2081 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2084 run_test 31f "remove of open directory with open-unlink file ==="
2087 echo "-- cross directory link --"
2088 test_mkdir -c1 $DIR/${tdir}ga
2089 test_mkdir -c1 $DIR/${tdir}gb
2090 touch $DIR/${tdir}ga/f
2091 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2092 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2093 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2094 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2095 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2097 run_test 31g "cross directory link==============="
2100 echo "-- cross directory link --"
2101 test_mkdir -c1 $DIR/${tdir}
2102 test_mkdir -c1 $DIR/${tdir}/dir
2103 touch $DIR/${tdir}/f
2104 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2105 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2106 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2107 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2108 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2110 run_test 31h "cross directory link under child==============="
2113 echo "-- cross directory link --"
2114 test_mkdir -c1 $DIR/$tdir
2115 test_mkdir -c1 $DIR/$tdir/dir
2116 touch $DIR/$tdir/dir/f
2117 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2118 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2119 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2120 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2121 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2123 run_test 31i "cross directory link under parent==============="
2126 test_mkdir -c1 -p $DIR/$tdir
2127 test_mkdir -c1 -p $DIR/$tdir/dir1
2128 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2129 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2130 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2131 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2134 run_test 31j "link for directory==============="
2137 test_mkdir -c1 -p $DIR/$tdir
2139 touch $DIR/$tdir/exist
2140 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2141 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2142 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2143 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2144 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2145 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2146 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2149 run_test 31k "link to file: the same, non-existing, dir==============="
2155 touch $DIR/d31m2/exist
2156 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2157 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2158 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2159 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2160 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2161 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2164 run_test 31m "link to file: the same, non-existing, dir==============="
2167 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2168 nlink=$(stat --format=%h $DIR/$tfile)
2169 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2171 local cmd="exec $fd<$DIR/$tfile"
2174 trap "eval $cmd" EXIT
2175 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2176 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2177 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2178 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2179 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2182 run_test 31n "check link count of unlinked file"
2185 local TEMPNAME=$(mktemp $1_XXXXXX)
2186 mlink $TEMPNAME $1 2> /dev/null &&
2187 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2191 test_31o() { # LU-2901
2193 for LOOP in $(seq 100); do
2194 rm -f $DIR/$tdir/$tfile*
2195 for THREAD in $(seq 8); do
2196 link_one $DIR/$tdir/$tfile.$LOOP &
2199 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2200 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2201 error "$LINKS duplicate links to $tfile.$LOOP" &&
2205 run_test 31o "duplicate hard links with same filename"
2207 cleanup_test32_mount() {
2209 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2214 echo "== more mountpoints and symlinks ================="
2215 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2216 trap cleanup_test32_mount EXIT
2217 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2218 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2219 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2220 cleanup_test32_mount
2222 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2226 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2227 trap cleanup_test32_mount EXIT
2228 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2229 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2230 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2231 cleanup_test32_mount
2233 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2237 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2238 trap cleanup_test32_mount EXIT
2239 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2240 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2241 test_mkdir -p $DIR/$tdir/d2/test_dir
2242 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2243 cleanup_test32_mount
2245 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2249 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2250 trap cleanup_test32_mount EXIT
2251 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2252 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2253 test_mkdir -p $DIR/$tdir/d2/test_dir
2254 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2255 cleanup_test32_mount
2257 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2260 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2261 test_mkdir -p $DIR/d32e/tmp
2262 TMP_DIR=$DIR/d32e/tmp
2263 ln -s $DIR/d32e $TMP_DIR/symlink11
2264 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2265 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2266 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2268 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2271 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2272 test_mkdir -p $DIR/d32f/tmp
2273 TMP_DIR=$DIR/d32f/tmp
2274 ln -s $DIR/d32f $TMP_DIR/symlink11
2275 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2276 ls $DIR/d32f/tmp/symlink11 || error
2277 ls $DIR/d32f/symlink01 || error
2279 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2282 TMP_DIR=$DIR/$tdir/tmp
2283 test_mkdir -p $DIR/$tdir/tmp
2284 test_mkdir $DIR/${tdir}2
2285 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2286 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2287 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2288 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2289 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2290 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2292 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2295 rm -fr $DIR/$tdir $DIR/${tdir}2
2296 TMP_DIR=$DIR/$tdir/tmp
2297 test_mkdir -p $DIR/$tdir/tmp
2298 test_mkdir $DIR/${tdir}2
2299 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2300 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2301 ls $TMP_DIR/symlink12 || error
2302 ls $DIR/$tdir/symlink02 || error
2304 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2308 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2309 trap cleanup_test32_mount EXIT
2310 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2311 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2312 touch $DIR/$tdir/test_file
2313 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2314 cleanup_test32_mount
2316 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2320 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2321 trap cleanup_test32_mount EXIT
2322 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2323 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2324 touch $DIR/$tdir/test_file
2325 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2326 cleanup_test32_mount
2328 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2333 trap cleanup_test32_mount EXIT
2334 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2335 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2336 test_mkdir -p $DIR/$tdir/d2
2337 touch $DIR/$tdir/d2/test_file || error
2338 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2339 cleanup_test32_mount
2341 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2346 trap cleanup_test32_mount EXIT
2347 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2348 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2349 test_mkdir -p $DIR/$tdir/d2
2350 touch $DIR/$tdir/d2/test_file
2351 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2352 cleanup_test32_mount
2354 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2358 test_mkdir -p $DIR/d32m/tmp
2359 TMP_DIR=$DIR/d32m/tmp
2360 ln -s $DIR $TMP_DIR/symlink11
2361 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2362 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2363 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2365 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2369 test_mkdir -p $DIR/d32n/tmp
2370 TMP_DIR=$DIR/d32n/tmp
2371 ln -s $DIR $TMP_DIR/symlink11
2372 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2373 ls -l $DIR/d32n/tmp/symlink11 || error
2374 ls -l $DIR/d32n/symlink01 || error
2376 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2379 rm -fr $DIR/d32o $DIR/$tfile
2381 test_mkdir -p $DIR/d32o/tmp
2382 TMP_DIR=$DIR/d32o/tmp
2383 ln -s $DIR/$tfile $TMP_DIR/symlink12
2384 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2385 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2386 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2387 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2388 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2390 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2400 test_mkdir -p $DIR/d32p/tmp
2402 TMP_DIR=$DIR/d32p/tmp
2404 ln -s $DIR/$tfile $TMP_DIR/symlink12
2406 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2408 cat $DIR/d32p/tmp/symlink12 || error
2410 cat $DIR/d32p/symlink02 || error
2413 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2415 cleanup_testdir_mount() {
2417 $UMOUNT -d $DIR/$tdir
2421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2422 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2423 trap cleanup_testdir_mount EXIT
2424 test_mkdir -p $DIR/$tdir
2425 touch $DIR/$tdir/under_the_mount
2426 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2427 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2428 cleanup_testdir_mount
2430 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2434 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2435 trap cleanup_testdir_mount EXIT
2436 test_mkdir -p $DIR/$tdir
2437 touch $DIR/$tdir/under_the_mount
2438 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2439 ls $DIR/$tdir | grep -q under_the_mount && error || true
2440 cleanup_testdir_mount
2442 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2447 chmod 444 $DIR/$tfile
2448 chown $RUNAS_ID $DIR/$tfile
2450 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2453 run_test 33aa "write file with mode 444 (should return error) ===="
2457 test_mkdir -p $DIR/d33
2458 chown $RUNAS_ID $DIR/d33
2459 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2460 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2461 error "open RDWR" || true
2463 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2467 test_mkdir -p $DIR/d33
2468 chown $RUNAS_ID $DIR/d33
2469 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2471 run_test 33b "test open file with malformed flags (No panic and return error)"
2474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2480 remote_ost_nodsh && skip "remote OST with nodsh" && return
2483 test_mkdir -p $DIR/d33
2484 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2487 for ostnum in $(seq $OSTCOUNT); do
2488 # test-framework's OST numbering is one-based, while Lustre's
2490 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2491 # Parsing llobdstat's output sucks; we could grep the /proc
2492 # path, but that's likely to not be as portable as using the
2493 # llobdstat utility. So we parse lctl output instead.
2494 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2495 obdfilter/$ostname/stats |
2496 awk '/^write_bytes/ {print $7}' )
2497 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2498 if (( ${write_bytes:-0} > 0 ))
2505 $all_zeros || return 0
2508 echo foo > $DIR/d33/bar
2512 # Total up write_bytes after writing. We'd better find non-zeros.
2513 for ostnum in $(seq $OSTCOUNT); do
2514 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2515 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2516 obdfilter/$ostname/stats |
2517 awk '/^write_bytes/ {print $7}' )
2518 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2519 if (( ${write_bytes:-0} > 0 ))
2528 for ostnum in $(seq $OSTCOUNT); do
2529 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2530 echo "Check that write_bytes is present in obdfilter/*/stats:"
2531 do_facet ost$ostnum lctl get_param -n \
2532 obdfilter/$ostname/stats
2534 error "OST not keeping write_bytes stats (b22312)"
2537 run_test 33c "test llobdstat and write_bytes"
2540 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2543 local remote_dir=$DIR/$tdir/remote_dir
2546 $LFS mkdir -i $MDTIDX $remote_dir ||
2547 error "create remote directory failed"
2549 touch $remote_dir/$tfile
2550 chmod 444 $remote_dir/$tfile
2551 chown $RUNAS_ID $remote_dir/$tfile
2553 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2555 chown $RUNAS_ID $remote_dir
2556 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2557 error "create" || true
2558 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2559 error "open RDWR" || true
2560 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2561 error "create" || true
2563 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2565 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2568 $MCREATE $DIR/f34 || error
2569 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2570 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2571 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2572 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2574 run_test 34a "truncate file that has not been opened ==========="
2577 [ ! -f $DIR/f34 ] && test_34a
2578 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2579 $OPENFILE -f O_RDONLY $DIR/f34
2580 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2581 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2583 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2586 [ ! -f $DIR/f34 ] && test_34a
2587 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2588 $OPENFILE -f O_RDWR $DIR/f34
2589 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2590 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2592 run_test 34c "O_RDWR opening file-with-size works =============="
2595 [ ! -f $DIR/f34 ] && test_34a
2596 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2597 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2600 run_test 34d "write to sparse file ============================="
2604 $MCREATE $DIR/f34e || error
2605 $TRUNCATE $DIR/f34e 1000 || error
2606 $CHECKSTAT -s 1000 $DIR/f34e || error
2607 $OPENFILE -f O_RDWR $DIR/f34e
2608 $CHECKSTAT -s 1000 $DIR/f34e || error
2610 run_test 34e "create objects, some with size and some without =="
2612 test_34f() { # bug 6242, 6243
2613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2616 $MCREATE $DIR/f34f || error
2617 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2618 dd if=$DIR/f34f of=$TMP/f34f
2619 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2620 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2621 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2622 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2623 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2625 run_test 34f "read from a file with no objects until EOF ======="
2628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2629 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2630 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2631 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2632 cancel_lru_locks osc
2633 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2634 error "wrong size after lock cancel"
2636 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2637 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2638 error "expanding truncate failed"
2639 cancel_lru_locks osc
2640 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2641 error "wrong expanded size after lock cancel"
2643 run_test 34g "truncate long file ==============================="
2646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2650 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2651 sync # Flush the cache so that multiop below does not block on cache
2652 # flush when getting the group lock
2653 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2656 # Since just timed wait is not good enough, let's do a sync write
2657 # that way we are sure enough time for a roundtrip + processing
2658 # passed + 2 seconds of extra margin.
2659 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2663 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2664 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2668 local nsz=`stat -c %s $DIR/$tfile`
2669 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2671 run_test 34h "ftruncate file under grouplock should not block"
2674 cp /bin/sh $DIR/f35a
2676 chown $RUNAS_ID $DIR/f35a
2677 $RUNAS $DIR/f35a && error || true
2680 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2684 utime $DIR/f36 || error
2686 run_test 36a "MDS utime check (mknod, utime) ==================="
2690 utime $DIR/f36 || error
2692 run_test 36b "OST utime check (open, utime) ===================="
2697 chown $RUNAS_ID $DIR/d36
2698 $RUNAS utime $DIR/d36/f36 || error
2700 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2703 [ ! -d $DIR/d36 ] && test_36c
2704 echo "" > $DIR/d36/f36
2705 $RUNAS utime $DIR/d36/f36 || error
2707 run_test 36d "non-root OST utime check (open, utime) ==========="
2710 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2711 test_mkdir -p $DIR/$tdir
2712 touch $DIR/$tdir/$tfile
2713 $RUNAS utime $DIR/$tdir/$tfile && \
2714 error "utime worked, expected failure" || true
2716 run_test 36e "utime on non-owned file (should return error) ===="
2720 local LANG_SAVE=$LANG
2721 local LC_LANG_SAVE=$LC_LANG
2722 export LANG=C LC_LANG=C # for date language
2724 DATESTR="Dec 20 2000"
2725 test_mkdir -p $DIR/$tdir
2726 lctl set_param fail_loc=$fl
2728 cp /etc/hosts $DIR/$tdir/$tfile
2729 sync & # write RPC generated with "current" inode timestamp, but delayed
2731 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2732 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2733 cancel_lru_locks osc
2734 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2736 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2737 echo "BEFORE: $LS_BEFORE" && \
2738 echo "AFTER : $LS_AFTER" && \
2739 echo "WANT : $DATESTR" && \
2740 error "$DIR/$tdir/$tfile timestamps changed" || true
2742 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2747 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2748 subr_36fh "0x80000214"
2750 run_test 36f "utime on file racing with OST BRW write =========="
2753 remote_ost_nodsh && skip "remote OST with nodsh" && return
2754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2759 test_mkdir -p $DIR/$tdir
2760 fmd_max_age=$(do_facet ost1 \
2761 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2764 fmd_before=$(do_facet ost1 \
2765 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2766 touch $DIR/$tdir/$tfile
2767 sleep $((fmd_max_age + 12))
2768 fmd_after=$(do_facet ost1 \
2769 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2771 echo "fmd_before: $fmd_before"
2772 echo "fmd_after: $fmd_after"
2773 [ "$fmd_after" -gt "$fmd_before" ] && \
2774 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2775 error "fmd didn't expire after ping" || true
2777 run_test 36g "filter mod data cache expiry ====================="
2780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2781 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2782 subr_36fh "0x80000227"
2784 run_test 36h "utime on file racing with OST BRW write =========="
2786 # test_37 - duplicate with tests 32q 32r
2789 local file=$DIR/$tfile
2791 openfile -f O_DIRECTORY $file
2794 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2795 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2797 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2801 touch $DIR/${tfile}2
2802 # ls -l $DIR/$tfile $DIR/${tfile}2
2803 # ls -lu $DIR/$tfile $DIR/${tfile}2
2804 # ls -lc $DIR/$tfile $DIR/${tfile}2
2806 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2807 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2809 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2811 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2813 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2814 error "O_TRUNC didn't change timestamps"
2817 run_test 39 "mtime changed on create ==========================="
2820 test_mkdir -p $DIR/$tdir
2821 cp -p /etc/passwd $DIR/$tdir/fopen
2822 cp -p /etc/passwd $DIR/$tdir/flink
2823 cp -p /etc/passwd $DIR/$tdir/funlink
2824 cp -p /etc/passwd $DIR/$tdir/frename
2825 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2828 echo "aaaaaa" >> $DIR/$tdir/fopen
2829 echo "aaaaaa" >> $DIR/$tdir/flink
2830 echo "aaaaaa" >> $DIR/$tdir/funlink
2831 echo "aaaaaa" >> $DIR/$tdir/frename
2833 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2834 local link_new=`stat -c %Y $DIR/$tdir/flink`
2835 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2836 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2838 cat $DIR/$tdir/fopen > /dev/null
2839 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2840 rm -f $DIR/$tdir/funlink2
2841 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2843 for (( i=0; i < 2; i++ )) ; do
2844 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2845 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2846 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2847 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2849 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2850 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2851 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2852 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2854 cancel_lru_locks osc
2855 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2858 run_test 39b "mtime change on open, link, unlink, rename ======"
2860 # this should be set to past
2861 TEST_39_MTIME=`date -d "1 year ago" +%s`
2867 local mtime0=`stat -c %Y $DIR1/$tfile`
2869 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2870 local mtime1=`stat -c %Y $DIR1/$tfile`
2871 [ "$mtime1" = $TEST_39_MTIME ] || \
2872 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2875 echo hello >> $DIR1/$tfile
2877 local mtime2=`stat -c %Y $DIR1/$tfile`
2878 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2879 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2881 mv $DIR1/$tfile $DIR1/$tfile-1
2883 for (( i=0; i < 2; i++ )) ; do
2884 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2885 [ "$mtime2" = "$mtime3" ] || \
2886 error "mtime ($mtime2) changed (to $mtime3) on rename"
2888 cancel_lru_locks osc
2889 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2892 run_test 39c "mtime change on rename ==========================="
2896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2899 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2901 for (( i=0; i < 2; i++ )) ; do
2902 local mtime=`stat -c %Y $DIR1/$tfile`
2903 [ $mtime = $TEST_39_MTIME ] || \
2904 error "mtime($mtime) is not set to $TEST_39_MTIME"
2906 cancel_lru_locks osc
2907 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2910 run_test 39d "create, utime, stat =============================="
2914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2916 local mtime1=`stat -c %Y $DIR1/$tfile`
2918 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2920 for (( i=0; i < 2; i++ )) ; do
2921 local mtime2=`stat -c %Y $DIR1/$tfile`
2922 [ $mtime2 = $TEST_39_MTIME ] || \
2923 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2925 cancel_lru_locks osc
2926 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2929 run_test 39e "create, stat, utime, stat ========================"
2933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2935 mtime1=`stat -c %Y $DIR1/$tfile`
2938 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2940 for (( i=0; i < 2; i++ )) ; do
2941 local mtime2=`stat -c %Y $DIR1/$tfile`
2942 [ $mtime2 = $TEST_39_MTIME ] || \
2943 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2945 cancel_lru_locks osc
2946 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2949 run_test 39f "create, stat, sleep, utime, stat ================="
2953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2954 echo hello >> $DIR1/$tfile
2955 local mtime1=`stat -c %Y $DIR1/$tfile`
2958 chmod o+r $DIR1/$tfile
2960 for (( i=0; i < 2; i++ )) ; do
2961 local mtime2=`stat -c %Y $DIR1/$tfile`
2962 [ "$mtime1" = "$mtime2" ] || \
2963 error "lost mtime: $mtime2, should be $mtime1"
2965 cancel_lru_locks osc
2966 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2969 run_test 39g "write, chmod, stat ==============================="
2973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2978 echo hello >> $DIR1/$tfile
2979 local mtime1=`stat -c %Y $DIR1/$tfile`
2981 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2983 if [ "$d1" != "$d2" ]; then
2984 echo "write and touch not within one second"
2986 for (( i=0; i < 2; i++ )) ; do
2987 local mtime2=`stat -c %Y $DIR1/$tfile`
2988 [ "$mtime2" = $TEST_39_MTIME ] || \
2989 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2991 cancel_lru_locks osc
2992 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2996 run_test 39h "write, utime within one second, stat ============="
2999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3003 echo hello >> $DIR1/$tfile
3004 local mtime1=`stat -c %Y $DIR1/$tfile`
3006 mv $DIR1/$tfile $DIR1/$tfile-1
3008 for (( i=0; i < 2; i++ )) ; do
3009 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3011 [ "$mtime1" = "$mtime2" ] || \
3012 error "lost mtime: $mtime2, should be $mtime1"
3014 cancel_lru_locks osc
3015 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3018 run_test 39i "write, rename, stat =============================="
3021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3022 start_full_debug_logging
3026 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3027 lctl set_param fail_loc=0x80000412
3028 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3029 error "multiop failed"
3031 local mtime1=`stat -c %Y $DIR1/$tfile`
3033 mv $DIR1/$tfile $DIR1/$tfile-1
3035 kill -USR1 $multipid
3036 wait $multipid || error "multiop close failed"
3038 for (( i=0; i < 2; i++ )) ; do
3039 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3040 [ "$mtime1" = "$mtime2" ] ||
3041 error "mtime is lost on close: $mtime2, " \
3044 cancel_lru_locks osc
3045 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3047 lctl set_param fail_loc=0
3048 stop_full_debug_logging
3050 run_test 39j "write, rename, close, stat ======================="
3053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3057 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3059 local mtime1=`stat -c %Y $DIR1/$tfile`
3061 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3063 kill -USR1 $multipid
3064 wait $multipid || error "multiop close failed"
3066 for (( i=0; i < 2; i++ )) ; do
3067 local mtime2=`stat -c %Y $DIR1/$tfile`
3069 [ "$mtime2" = $TEST_39_MTIME ] || \
3070 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3072 cancel_lru_locks osc
3073 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3076 run_test 39k "write, utime, close, stat ========================"
3078 # this should be set to future
3079 TEST_39_ATIME=`date -d "1 year" +%s`
3082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3083 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3084 local atime_diff=$(do_facet $SINGLEMDS \
3085 lctl get_param -n mdd.*MDT0000*.atime_diff)
3089 # test setting directory atime to future
3090 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3091 local atime=$(stat -c %X $DIR/$tdir)
3092 [ "$atime" = $TEST_39_ATIME ] || \
3093 error "atime is not set to future: $atime, $TEST_39_ATIME"
3095 # test setting directory atime from future to now
3096 local d1=$(date +%s)
3098 local d2=$(date +%s)
3100 cancel_lru_locks mdc
3101 atime=$(stat -c %X $DIR/$tdir)
3102 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3103 error "atime is not updated from future: $atime, $d1<atime<$d2"
3105 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3108 # test setting directory atime when now > dir atime + atime_diff
3112 cancel_lru_locks mdc
3113 atime=$(stat -c %X $DIR/$tdir)
3114 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3115 error "atime is not updated : $atime, should be $d2"
3117 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3120 # test not setting directory atime when now < dir atime + atime_diff
3122 cancel_lru_locks mdc
3123 atime=$(stat -c %X $DIR/$tdir)
3124 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3125 error "atime is updated to $atime, should remain $d1<atime<$d2"
3127 do_facet $SINGLEMDS \
3128 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3130 run_test 39l "directory atime update ==========================="
3133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3136 local far_past_mtime=$(date -d "May 29 1953" +%s)
3137 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3139 touch -m -d @$far_past_mtime $DIR1/$tfile
3140 touch -a -d @$far_past_atime $DIR1/$tfile
3142 for (( i=0; i < 2; i++ )) ; do
3143 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3144 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3145 error "atime or mtime set incorrectly"
3147 cancel_lru_locks osc
3148 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3151 run_test 39m "test atime and mtime before 1970"
3153 test_39n() { # LU-3832
3154 local atime_diff=$(do_facet $SINGLEMDS \
3155 lctl get_param -n mdd.*MDT0000*.atime_diff)
3160 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3163 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3164 atime0=$(stat -c %X $DIR/$tfile)
3167 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3168 atime1=$(stat -c %X $DIR/$tfile)
3171 cancel_lru_locks mdc
3172 cancel_lru_locks osc
3173 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3174 atime2=$(stat -c %X $DIR/$tfile)
3176 do_facet $SINGLEMDS \
3177 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3179 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3180 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3182 run_test 39n "check that O_NOATIME is honored"
3185 TESTDIR=$DIR/$tdir/$tfile
3186 [ -e $TESTDIR ] && rm -rf $TESTDIR
3187 test_mkdir -p $TESTDIR
3193 links2=$(stat -c %h .)
3194 [ $(($links1 + 2)) != $links2 ] &&
3195 error "wrong links count $(($links1 + 2)) != $links2"
3197 links3=$(stat -c %h .)
3198 [ $(($links1 + 1)) != $links3 ] &&
3199 error "wrong links count $links1 != $links3"
3202 run_test 39o "directory cached attributes updated after create ========"
3205 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3207 TESTDIR=$DIR/$tdir/$tfile
3208 [ -e $TESTDIR ] && rm -rf $TESTDIR
3213 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3214 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3216 links2=$(stat -c %h .)
3217 [ $(($links1 + 2)) != $links2 ] &&
3218 error "wrong links count $(($links1 + 2)) != $links2"
3220 links3=$(stat -c %h .)
3221 [ $(($links1 + 1)) != $links3 ] &&
3222 error "wrong links count $links1 != $links3"
3225 run_test 39p "remote directory cached attributes updated after create ========"
3229 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3230 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3231 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3232 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3233 error "$tfile is not 4096 bytes in size"
3235 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3239 small_write $DIR/f41 18
3241 run_test 41 "test small file write + fstat ====================="
3243 count_ost_writes() {
3244 lctl get_param -n osc.*.stats |
3245 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3252 BG_DIRTY_RATIO_SAVE=10
3253 MAX_BG_DIRTY_RATIO=25
3257 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3258 # dirty_ratio, dirty_background_ratio
3259 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3260 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3261 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3262 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3264 # if file not here, we are a 2.4 kernel
3265 kill -CONT `pidof kupdated`
3270 # setup the trap first, so someone cannot exit the test at the
3271 # exact wrong time and mess up a machine
3272 trap start_writeback EXIT
3273 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3274 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3275 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3276 sysctl -w vm.dirty_writeback_centisecs=0
3277 sysctl -w vm.dirty_writeback_centisecs=0
3278 # save and increase /proc/sys/vm/dirty_ratio
3279 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3280 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3281 # save and increase /proc/sys/vm/dirty_background_ratio
3282 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3283 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3285 # if file not here, we are a 2.4 kernel
3286 kill -STOP `pidof kupdated`
3290 # ensure that all stripes have some grant before we test client-side cache
3292 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3293 dd if=/dev/zero of=$i bs=4k count=1
3298 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3299 # file truncation, and file removal.
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3303 cancel_lru_locks osc
3305 sync; sleep 1; sync # just to be safe
3306 BEFOREWRITES=`count_ost_writes`
3307 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3308 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3309 AFTERWRITES=`count_ost_writes`
3310 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3311 error "$BEFOREWRITES < $AFTERWRITES"
3314 run_test 42a "ensure that we don't flush on close =============="
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3319 cancel_lru_locks osc
3322 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3323 BEFOREWRITES=`count_ost_writes`
3324 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3325 AFTERWRITES=`count_ost_writes`
3326 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3327 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3329 BEFOREWRITES=`count_ost_writes`
3330 sync || error "sync: $?"
3331 AFTERWRITES=`count_ost_writes`
3332 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3333 error "$BEFOREWRITES < $AFTERWRITES on sync"
3335 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3339 run_test 42b "test destroy of file with cached dirty data ======"
3341 # if these tests just want to test the effect of truncation,
3342 # they have to be very careful. consider:
3343 # - the first open gets a {0,EOF}PR lock
3344 # - the first write conflicts and gets a {0, count-1}PW
3345 # - the rest of the writes are under {count,EOF}PW
3346 # - the open for truncate tries to match a {0,EOF}PR
3347 # for the filesize and cancels the PWs.
3348 # any number of fixes (don't get {0,EOF} on open, match
3349 # composite locks, do smarter file size management) fix
3350 # this, but for now we want these tests to verify that
3351 # the cancellation with truncate intent works, so we
3352 # start the file with a full-file pw lock to match against
3353 # until the truncate.
3358 cancel_lru_locks osc
3360 # prime the file with 0,EOF PW to match
3364 # now the real test..
3365 dd if=/dev/zero of=$file bs=1024 count=100
3366 BEFOREWRITES=`count_ost_writes`
3367 $TRUNCATE $file $offset
3368 cancel_lru_locks osc
3369 AFTERWRITES=`count_ost_writes`
3374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3376 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3377 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3380 run_test 42c "test partial truncate of file with cached dirty data"
3383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3385 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3386 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3389 run_test 42d "test complete truncate of file with cached dirty data"
3391 test_42e() { # bug22074
3392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3393 local TDIR=$DIR/${tdir}e
3394 local pagesz=$(page_size)
3395 local pages=16 # hardcoded 16 pages, don't change it.
3396 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3397 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3401 test_mkdir -p $DIR/${tdir}e
3402 $SETSTRIPE -c 1 $TDIR
3403 createmany -o $TDIR/f $files
3405 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3407 # we assume that with $OSTCOUNT files, at least one of them will
3408 # be allocated on OST0.
3409 warmup_files=$((OSTCOUNT * max_dirty_mb))
3410 createmany -o $TDIR/w $warmup_files
3412 # write a large amount of data into one file and sync, to get good
3413 # avail_grant number from OST.
3414 for ((i=0; i<$warmup_files; i++)); do
3415 idx=$($GETSTRIPE -i $TDIR/w$i)
3416 [ $idx -ne 0 ] && continue
3417 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3420 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3422 $LCTL get_param $proc_osc0/cur_dirty_bytes
3423 $LCTL get_param $proc_osc0/cur_grant_bytes
3425 # create as much dirty pages as we can while not to trigger the actual
3426 # RPCs directly. but depends on the env, VFS may trigger flush during this
3427 # period, hopefully we are good.
3428 for ((i=0; i<$warmup_files; i++)); do
3429 idx=$($GETSTRIPE -i $TDIR/w$i)
3430 [ $idx -ne 0 ] && continue
3431 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3433 $LCTL get_param $proc_osc0/cur_dirty_bytes
3434 $LCTL get_param $proc_osc0/cur_grant_bytes
3436 # perform the real test
3437 $LCTL set_param $proc_osc0/rpc_stats 0
3438 for ((;i<$files; i++)); do
3439 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3440 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3443 $LCTL get_param $proc_osc0/rpc_stats
3446 local have_ppr=false
3447 $LCTL get_param $proc_osc0/rpc_stats |
3448 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3449 # skip lines until we are at the RPC histogram data
3450 [ "$PPR" == "pages" ] && have_ppr=true && continue
3451 $have_ppr || continue
3453 # we only want the percent stat for < 16 pages
3454 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3456 percent=$((percent + WPCT))
3457 if [ $percent -gt 15 ]; then
3458 error "less than 16-pages write RPCs" \
3465 run_test 42e "verify sub-RPC writes are not done synchronously"
3468 test_mkdir -p $DIR/$tdir
3469 cp -p /bin/ls $DIR/$tdir/$tfile
3470 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3472 # give multiop a chance to open
3475 $DIR/$tdir/$tfile && error || true
3478 run_test 43 "execution of file opened for write should return -ETXTBSY"
3481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3482 test_mkdir -p $DIR/$tdir
3483 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3484 cp -p multiop $DIR/$tdir/multiop
3485 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3488 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3489 kill -USR1 $MULTIOP_PID || return 2
3490 wait $MULTIOP_PID || return 3
3491 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3493 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3497 test_mkdir -p $DIR/$tdir
3498 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3499 cp -p multiop $DIR/$tdir/multiop
3500 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3503 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3504 kill -USR1 $MULTIOP_PID || return 2
3505 wait $MULTIOP_PID || return 3
3506 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3508 run_test 43b "truncate of file being executed should return -ETXTBSY"
3511 local testdir="$DIR/$tdir"
3512 test_mkdir -p $DIR/$tdir
3514 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3515 ( cd $testdir && md5sum -c)
3517 run_test 43c "md5sum of copy into lustre========================"
3520 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3521 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3522 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3524 run_test 44 "zero length read from a sparse stripe ============="
3527 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3529 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3530 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3531 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3533 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3534 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3537 OFFSETS="0 $((stride/2)) $((stride-1))"
3538 for offset in $OFFSETS ; do
3539 for i in `seq 0 $((nstripe-1))`; do
3540 local GLOBALOFFSETS=""
3541 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3542 local myfn=$DIR/d44a-$size
3543 echo "--------writing $myfn at $size"
3544 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3545 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3546 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3547 || error "ll_sparseness_verify $GLOBALOFFSETS"
3549 for j in `seq 0 $((nstripe-1))`; do
3550 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3551 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3552 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3554 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3555 || error "ll_sparseness_verify $GLOBALOFFSETS"
3560 run_test 44a "test sparse pwrite ==============================="
3564 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3570 before=`dirty_osc_total`
3571 echo executing "\"$*\""
3573 after=`dirty_osc_total`
3574 echo before $before, after $after
3577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3579 # Obtain grants from OST if it supports it
3580 echo blah > ${f}_grant
3583 do_dirty_record "echo blah > $f"
3584 [ $before -eq $after ] && error "write wasn't cached"
3585 do_dirty_record "> $f"
3586 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3587 do_dirty_record "echo blah > $f"
3588 [ $before -eq $after ] && error "write wasn't cached"
3589 do_dirty_record "sync"
3590 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3591 do_dirty_record "echo blah > $f"
3592 [ $before -eq $after ] && error "write wasn't cached"
3593 do_dirty_record "cancel_lru_locks osc"
3594 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3597 run_test 45 "osc io page accounting ============================"
3599 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3600 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3601 # objects offset and an assert hit when an rpc was built with 1023's mapped
3602 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3608 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3610 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3611 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3615 run_test 46 "dirtying a previously written page ================"
3617 # test_47 is removed "Device nodes check" is moved to test_28
3619 test_48a() { # bug 2399
3620 check_kernel_version 34 || return 0
3621 test_mkdir -p $DIR/$tdir
3623 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3624 test_mkdir $DIR/$tdir || error "recreate directory failed"
3625 touch foo || error "'touch foo' failed after recreating cwd"
3626 test_mkdir $DIR/$tdir/bar ||
3627 error "'mkdir foo' failed after recreating cwd"
3628 if check_kernel_version 44; then
3629 touch .foo || error "'touch .foo' failed after recreating cwd"
3630 test_mkdir $DIR/$tdir/.bar ||
3631 error "'mkdir .foo' failed after recreating cwd"
3633 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3634 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3635 cd . || error "'cd .' failed after recreating cwd"
3636 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3637 rmdir . && error "'rmdir .' worked after recreating cwd"
3638 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3639 cd .. || error "'cd ..' failed after recreating cwd"
3641 run_test 48a "Access renamed working dir (should return errors)="
3643 test_48b() { # bug 2399
3644 check_kernel_version 34 || return 0
3646 test_mkdir -p $DIR/$tdir
3648 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3649 touch foo && error "'touch foo' worked after removing cwd"
3650 test_mkdir $DIR/$tdir/foo &&
3651 error "'mkdir foo' worked after removing cwd"
3652 if check_kernel_version 44; then
3653 touch .foo && error "'touch .foo' worked after removing cwd"
3654 test_mkdir $DIR/$tdir/.foo &&
3655 error "'mkdir .foo' worked after removing cwd"
3657 ls . > /dev/null && error "'ls .' worked after removing cwd"
3658 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3659 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3660 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3661 rmdir . && error "'rmdir .' worked after removing cwd"
3662 ln -s . foo && error "'ln -s .' worked after removing cwd"
3663 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3665 run_test 48b "Access removed working dir (should return errors)="
3667 test_48c() { # bug 2350
3668 check_kernel_version 36 || return 0
3669 #lctl set_param debug=-1
3672 test_mkdir -p $DIR/$tdir/dir
3674 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3675 $TRACE touch foo && error "touch foo worked after removing cwd"
3676 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3677 if check_kernel_version 44; then
3678 touch .foo && error "touch .foo worked after removing cwd"
3679 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3681 $TRACE ls . && error "'ls .' worked after removing cwd"
3682 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3683 is_patchless || ( $TRACE cd . &&
3684 error "'cd .' worked after removing cwd" )
3685 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3686 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3687 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3688 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3690 run_test 48c "Access removed working subdir (should return errors)"
3692 test_48d() { # bug 2350
3693 check_kernel_version 36 || return 0
3694 #lctl set_param debug=-1
3697 test_mkdir -p $DIR/$tdir/dir
3699 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3700 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3701 $TRACE touch foo && error "'touch foo' worked after removing parent"
3702 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3703 if check_kernel_version 44; then
3704 touch .foo && error "'touch .foo' worked after removing parent"
3706 error "mkdir .foo worked after removing parent"
3708 $TRACE ls . && error "'ls .' worked after removing parent"
3709 $TRACE ls .. && error "'ls ..' worked after removing parent"
3710 is_patchless || ( $TRACE cd . &&
3711 error "'cd .' worked after recreate parent" )
3712 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3713 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3714 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3715 is_patchless || ( $TRACE cd .. &&
3716 error "'cd ..' worked after removing parent" || true )
3718 run_test 48d "Access removed parent subdir (should return errors)"
3720 test_48e() { # bug 4134
3721 check_kernel_version 41 || return 0
3722 #lctl set_param debug=-1
3725 test_mkdir -p $DIR/$tdir/dir
3727 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3728 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3729 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3730 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3731 # On a buggy kernel addition of "touch foo" after cd .. will
3732 # produce kernel oops in lookup_hash_it
3733 touch ../foo && error "'cd ..' worked after recreate parent"
3735 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3737 run_test 48e "Access to recreated parent subdir (should return errors)"
3739 test_49() { # LU-1030
3740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3741 # get ost1 size - lustre-OST0000
3742 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3743 # write 800M at maximum
3744 [ $ost1_size -gt 819200 ] && ost1_size=819200
3746 lfs setstripe -c 1 -i 0 $DIR/$tfile
3747 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3750 # change max_pages_per_rpc while writing the file
3751 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3752 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3753 # loop until dd process exits
3754 while ps ax -opid | grep -wq $dd_pid; do
3755 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3756 sleep $((RANDOM % 5 + 1))
3758 # restore original max_pages_per_rpc
3759 $LCTL set_param $osc1_mppc=$orig_mppc
3760 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3762 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3766 test_mkdir $DIR/$tdir
3768 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3770 run_test 50 "special situations: /proc symlinks ==============="
3772 test_51a() { # was test_51
3773 # bug 1516 - create an empty entry right after ".." then split dir
3774 test_mkdir -p $DIR/$tdir
3775 touch $DIR/$tdir/foo
3776 $MCREATE $DIR/$tdir/bar
3778 createmany -m $DIR/$tdir/longfile 201
3780 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3781 $MCREATE $DIR/$tdir/longfile$FNUM
3786 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3788 run_test 51a "special situations: split htree with empty entry =="
3790 export NUMTEST=70000
3792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3793 local BASE=$DIR/d${base}.${TESTSUITE}
3795 # cleanup the directory
3800 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3801 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3802 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3805 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3806 echo "reduced count to $NUMTEST due to inodes"
3808 # need to check free space for the directories as well
3809 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3810 numfree=$((blkfree / 4))
3811 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3812 echo "reduced count to $NUMTEST due to blocks"
3814 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3815 echo "failed" > $BASE/fnum
3817 run_test 51b "exceed 64k subdirectory nlink limit"
3819 test_51ba() { # LU-993
3820 local BASE=$DIR/d${base}.${TESTSUITE}
3821 # unlink all but 100 subdirectories, then check it still works
3823 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3825 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3826 local DELETE=$((NUMTEST - LEFT))
3828 # continue on to run this test even if 51b didn't finish,
3829 # just to delete the many subdirectories created.
3830 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3832 # for ldiskfs the nlink count should be 1, but this is OSD specific
3833 # and so this is listed for informational purposes only
3834 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3835 unlinkmany -d $BASE/d $DELETE
3838 if [ $RC -ne 0 ]; then
3839 if [ "$NUMPREV" == "failed" ]; then
3840 skip "previous setup failed"
3843 error "unlink of first $DELETE subdirs failed"
3848 echo "nlink between: $(stat -c %h $BASE)"
3849 # trim the first line of ls output
3850 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3851 [ $FOUND -ne $LEFT ] &&
3852 error "can't find subdirs: found only $FOUND/$LEFT"
3854 unlinkmany -d $BASE/d $DELETE $LEFT ||
3855 error "unlink of second $LEFT subdirs failed"
3856 # regardless of whether the backing filesystem tracks nlink accurately
3857 # or not, the nlink count shouldn't be more than "." and ".." here
3858 local AFTER=$(stat -c %h $BASE)
3859 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3860 echo "nlink after: $AFTER"
3862 run_test 51ba "verify nlink for many subdirectory cleanup"
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3866 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3867 test_mkdir -p $DIR/$tdir
3868 createmany -o $DIR/$tdir/t- 1000
3869 $GETSTRIPE $DIR/$tdir > $TMP/files
3870 for N in `seq 0 $((OSTCOUNT - 1))`; do
3871 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3872 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3873 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3875 unlinkmany $DIR/$tdir/t- 1000
3878 for N in `seq 1 $((OSTCOUNT - 1))`; do
3879 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3880 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3881 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3882 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3884 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3885 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3886 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3887 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3891 run_test 51d "check object distribution ===================="
3894 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3895 test_mkdir -p $DIR/$tdir
3896 touch $DIR/$tdir/foo
3897 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3898 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3899 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3900 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3901 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3903 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3904 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3905 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3907 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3908 cp -r $DIR/$tdir /tmp/
3909 rm -fr $DIR/$tdir || error "cleanup rm failed"
3911 run_test 52a "append-only flag test (should return errors) ====="
3914 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3915 test_mkdir -p $DIR/$tdir
3916 touch $DIR/$tdir/foo
3917 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3918 cat test > $DIR/$tdir/foo && error "cat test worked"
3919 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3920 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3921 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3923 echo foo >> $DIR/$tdir/foo && error "echo worked"