2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 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"
21 if [ -r /etc/SuSE-release ]
23 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
41 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
42 CREATETEST=${CREATETEST:-createtest}
44 LFIND=${LFIND:-"$LFS find"}
45 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
47 MCREATE=${MCREATE:-mcreate}
48 OPENFILE=${OPENFILE:-openfile}
49 OPENUNLINK=${OPENUNLINK:-openunlink}
50 export MULTIOP=${MULTIOP:-multiop}
51 READS=${READS:-"reads"}
52 MUNLINK=${MUNLINK:-munlink}
53 SOCKETSERVER=${SOCKETSERVER:-socketserver}
54 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
55 MEMHOG=${MEMHOG:-memhog}
56 DIRECTIO=${DIRECTIO:-directio}
57 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
58 UMOUNT=${UMOUNT:-"umount -d"}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 . $LUSTRE/tests/test-framework.sh
74 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
77 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
79 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
80 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
81 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
87 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
88 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
97 check_kernel_version() {
99 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
101 patchless|patchless_client) return 0;;
102 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
104 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
108 check_swap_layouts_support()
110 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
111 { skip "Does not support layout lock."; return 0; }
115 if [ "$ONLY" == "cleanup" ]; then
120 check_and_setup_lustre
125 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
126 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
127 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
128 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
129 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
130 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
131 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
132 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
134 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
135 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
136 rm -rf $DIR/[Rdfs][0-9]*
138 # $RUNAS_ID may get set incorrectly somewhere else
139 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
141 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
145 if [ "${ONLY}" = "MOUNT" ] ; then
146 echo "Lustre is up, please go on"
150 echo "preparing for tests involving mounts"
151 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
153 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
154 echo # add a newline after mke2fs.
158 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
159 lctl set_param debug=-1 2> /dev/null || true
162 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
164 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
166 run_test 0a "touch; rm ====================="
169 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
170 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
172 run_test 0b "chmod 0755 $DIR ============================="
175 $LCTL get_param mdc.*.import | grep "state: FULL" ||
176 error "import not FULL"
177 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
180 run_test 0c "check import proc ============================="
183 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
184 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
185 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
186 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
189 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
191 run_test 1 "mkdir; remkdir; rmdir =============================="
194 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
195 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
198 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
200 run_test 2 "mkdir; touch; rmdir; check file ===================="
203 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
204 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
205 touch $DIR/$tdir/$tfile
206 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
208 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
210 run_test 3 "mkdir; touch; rmdir; check dir ====================="
212 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
215 local remote_dir=remote_dir
217 test_mkdir $DIR/$remote_dir ||
218 error "Create remote directory failed"
220 touch $DIR/$remote_dir/$tfile ||
221 error "Create file under remote directory failed"
223 rmdir $DIR/$remote_dir &&
224 error "Expect error removing in-use dir $DIR/$remote_dir"
226 test -d $DIR/$remote_dir || error "Remote directory disappeared"
228 rm -rf $DIR/$remote_dir || error "remove remote dir error"
230 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
233 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
234 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
235 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
236 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
237 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
239 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
242 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
243 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
245 error "$tfile does not have perm 0666 or UID $UID"
246 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
247 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
248 error "$tfile should be 0666 and owned by UID $UID"
250 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
253 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
255 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
256 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
257 error "$tfile should be owned by UID $RUNAS_ID"
258 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
260 error "$tfile should be owned by UID $RUNAS_ID"
262 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
265 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
267 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
268 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
269 error "$tfile should be owned by GID $UID"
270 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
272 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
274 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
278 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
279 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
280 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
281 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
282 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
283 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
284 error "$tdir/d/subdir should be GID $RUNAS_GID"
286 run_test 6g "Is new dir in sgid dir inheriting group?"
288 test_6h() { # bug 7331
289 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
290 touch $DIR/$tfile || error "touch failed"
291 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
292 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
293 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
294 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
295 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
297 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
300 test_mkdir $DIR/$tdir
301 $MCREATE $DIR/$tdir/$tfile
302 chmod 0666 $DIR/$tdir/$tfile
303 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
304 error "$tdir/$tfile should be mode 0666"
306 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
309 if [ ! -d $DIR/$tdir ]; then
312 $MCREATE $DIR/$tdir/$tfile
313 echo -n foo > $DIR/$tdir/$tfile
314 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
315 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
317 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
320 test_mkdir $DIR/$tdir
321 touch $DIR/$tdir/$tfile
322 chmod 0666 $DIR/$tdir/$tfile
323 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
324 error "$tfile mode not 0666"
326 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 test_mkdir $DIR/$tdir/d2/d3
332 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
334 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
337 test_mkdir $DIR/$tdir
338 test_mkdir $DIR/$tdir/d2
339 touch $DIR/$tdir/d2/$tfile
340 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
341 error "$tdir/d2/$tfile not a file"
343 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
346 test_mkdir $DIR/$tdir
347 test_mkdir $DIR/$tdir/d2
348 chmod 0666 $DIR/$tdir/d2
349 chmod 0705 $DIR/$tdir/d2
350 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
351 error "$tdir/d2 mode not 0705"
353 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
358 chmod 0666 $DIR/$tdir/$tfile
359 chmod 0654 $DIR/$tdir/$tfile
360 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
361 error "$tdir/d2 mode not 0654"
363 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
366 test_mkdir $DIR/$tdir
367 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
369 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
370 error "$tdir/$tfile size not 0 after truncate"
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
383 test_mkdir $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
386 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
387 error "$tdir/${tfile_2} not a file after rename"
389 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 rm -rf $DIR/$tdir/$tfile
395 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
397 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
400 test_mkdir -p $DIR/$tdir
401 touch $DIR/$tdir/$tfile
402 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
404 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not a symlink"
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
407 error "$tdir/l-exist not referencing a file"
408 rm -f $DIR/$tdir/l-exist
409 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
411 run_test 17a "symlinks: create, remove (real) =================="
414 test_mkdir -p $DIR/$tdir
415 ln -s no-such-file $DIR/$tdir/l-dangle
417 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing no-such-file"
419 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
420 error "$tdir/l-dangle not referencing non-existent file"
421 rm -f $DIR/$tdir/l-dangle
422 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
424 run_test 17b "symlinks: create, remove (dangling) =============="
426 test_17c() { # bug 3440 - don't save failed open RPC for replay
427 test_mkdir -p $DIR/$tdir
428 ln -s foo $DIR/$tdir/$tfile
429 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
431 run_test 17c "symlinks: open dangling (should return error) ===="
434 test_mkdir -p $DIR/$tdir
435 ln -s foo $DIR/$tdir/$tfile
436 touch $DIR/$tdir/$tfile || error "creating to new symlink"
438 run_test 17d "symlinks: create dangling ========================"
441 test_mkdir -p $DIR/$tdir
442 local foo=$DIR/$tdir/$tfile
443 ln -s $foo $foo || error "create symlink failed"
444 ls -l $foo || error "ls -l failed"
445 ls $foo && error "ls not failed" || true
447 run_test 17e "symlinks: create recursive symlink (should return error) ===="
450 test_mkdir -p $DIR/d17f
451 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
456 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
459 run_test 17f "symlinks: long and very long symlink name ========================"
461 # str_repeat(S, N) generate a string that is string S repeated N times
466 while [ $((n -= 1)) -ge 0 ]; do
472 # Long symlinks and LU-2241
474 test_mkdir -p $DIR/$tdir
475 local TESTS="59 60 61 4094 4095"
477 # Fix for inode size boundary in 2.1.4
478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
481 # Patch not applied to 2.2 or 2.3 branches
482 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
483 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
486 # skip long symlink name for rhel6.5.
487 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
488 grep -q '6.5' /etc/redhat-release &>/dev/null &&
489 TESTS="59 60 61 4062 4063"
492 local SYMNAME=$(str_repeat 'x' $i)
493 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
494 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
497 run_test 17g "symlinks: really long symlink name and inode boundaries"
499 test_17h() { #bug 17378
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
503 test_mkdir -p $DIR/$tdir
504 if [[ $MDSCOUNT -gt 1 ]]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 $SETSTRIPE -c -1 $DIR/$tdir
510 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
512 touch $DIR/$tdir/$tfile || true
514 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
516 test_17i() { #bug 20018
517 remote_mds_nodsh && skip "remote MDS with nodsh" && return
518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
519 test_mkdir -c1 $DIR/$tdir
520 local foo=$DIR/$tdir/$tfile
522 if [[ $MDSCOUNT -gt 1 ]]; then
523 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
527 ln -s $foo $foo || error "create symlink failed"
528 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
529 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
530 ls -l $foo && error "error not detected"
533 run_test 17i "don't panic on short symlink"
535 test_17k() { #bug 22301
536 [[ -z "$(which rsync 2>/dev/null)" ]] &&
537 skip "no rsync command" && return 0
538 rsync --help | grep -q xattr ||
539 skip_env "$(rsync --version | head -n1) does not support xattrs"
540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
541 test_mkdir -p $DIR/$tdir
542 test_mkdir -p $DIR/$tdir.new
543 touch $DIR/$tdir/$tfile
544 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
545 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
546 error "rsync failed with xattrs enabled"
548 run_test 17k "symlinks: rsync with xattrs enabled ========================="
550 test_17l() { # LU-279
551 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
552 skip "no getfattr command" && return 0
554 touch $DIR/$tdir/$tfile
555 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
556 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
557 # -h to not follow symlinks. -m '' to list all the xattrs.
558 # grep to remove first line: '# file: $path'.
559 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
561 lgetxattr_size_check $path $xattr ||
562 error "lgetxattr_size_check $path $xattr failed"
566 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
570 local short_sym="0123456789"
571 local WDIR=$DIR/${tdir}m
578 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
579 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
580 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
582 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
583 skip "only for ldiskfs MDT" && return 0
585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
589 # create a long symlink file
590 for ((i = 0; i < 4; ++i)); do
591 long_sym=${long_sym}${long_sym}
594 echo "create 512 short and long symlink files under $WDIR"
595 for ((i = 0; i < 256; ++i)); do
596 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
597 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
603 wait_delete_completed
605 echo "recreate the 512 symlink files with a shorter string"
606 for ((i = 0; i < 512; ++i)); do
607 # rewrite the symlink file with a shorter string
608 ln -sf ${long_sym} $WDIR/long-$i
609 ln -sf ${short_sym} $WDIR/short-$i
612 mds_index=$($LFS getstripe -M $WDIR)
613 mds_index=$((mds_index+1))
614 devname=$(mdsdevname $mds_index)
615 cmd="$E2FSCK -fnvd $devname"
617 echo "stop and checking mds${mds_index}: $cmd"
618 # e2fsck should not return error
620 do_facet mds${mds_index} $cmd || rc=$?
622 start mds${mds_index} $devname $MDS_MOUNT_OPTS
623 df $MOUNT > /dev/null 2>&1
624 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
625 "short/long symlink MDT: rc=$rc"
628 run_test 17m "run e2fsck against MDT which contains short/long symlink"
630 check_fs_consistency_17n() {
636 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
637 # so it only check MDT1/MDT2 instead of all of MDTs.
638 for mdt_index in $(seq 1 2); do
639 devname=$(mdsdevname $mdt_index)
640 cmd="$E2FSCK -fnvd $devname"
642 echo "stop and checking mds${mdt_index}: $cmd"
643 # e2fsck should not return error
645 do_facet mds${mdt_index} $cmd || rc=$?
647 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
648 df $MOUNT > /dev/null 2>&1
649 [ $rc -ne 0 ] && break
657 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
658 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
659 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
661 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
662 skip "only for ldiskfs MDT" && return 0
664 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
669 for ((i=0; i<10; i++)); do
670 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
671 error "create remote dir error $i"
672 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
673 error "create files under remote dir failed $i"
676 check_fs_consistency_17n ||
677 error "e2fsck report error after create files under remote dir"
679 for ((i=0;i<10;i++)); do
680 rm -rf $DIR/$tdir/remote_dir_${i} ||
681 error "destroy remote dir error $i"
684 check_fs_consistency_17n ||
685 error "e2fsck report error after unlink files under remote dir"
687 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
688 skip "lustre < 2.4.50 does not support migrate mv " && return
690 for ((i=0; i<10; i++)); do
691 mkdir -p $DIR/$tdir/remote_dir_${i}
692 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
693 error "create files under remote dir failed $i"
694 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
695 error "migrate remote dir error $i"
697 check_fs_consistency_17n || error "e2fsck report error after migration"
699 for ((i=0;i<10;i++)); do
700 rm -rf $DIR/$tdir/remote_dir_${i} ||
701 error "destroy remote dir error $i"
704 check_fs_consistency_17n || error "e2fsck report error after unlink"
706 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
709 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
710 skip "Need MDS version at least 2.3.64" && return
712 local WDIR=$DIR/${tdir}o
718 mdt_index=$($LFS getstripe -M $WDIR)
719 mdt_index=$((mdt_index+1))
720 mdtdevname=$(mdsdevname $mdt_index)
724 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
726 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
727 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
728 ls -l $WDIR/$tfile && rc=1
729 do_facet mds${mdt_index} lctl set_param fail_loc=0
730 [[ $rc -ne 0 ]] && error "stat file should fail"
733 run_test 17o "stat file with incompat LMA feature"
736 touch $DIR/f || error "Failed to touch $DIR/f: $?"
737 ls $DIR || error "Failed to ls $DIR: $?"
739 run_test 18 "touch .../f ; ls ... =============================="
745 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
747 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
750 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
752 run_test 19b "ls -l .../f19 (should return error) =============="
755 [ $RUNAS_ID -eq $UID ] &&
756 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
757 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
759 run_test 19c "$RUNAS touch .../f19 (should return error) =="
762 cat $DIR/f19 && error || true
764 run_test 19d "cat .../f19 (should return error) =============="
776 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
778 run_test 20 "touch .../f ; ls -l ... ==========================="
781 test_mkdir -p $DIR/$tdir
782 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
783 ln -s dangle $DIR/$tdir/link
784 echo foo >> $DIR/$tdir/link
785 cat $DIR/$tdir/dangle
786 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
787 $CHECKSTAT -f -t file $DIR/$tdir/link ||
788 error "$tdir/link not linked to a file"
790 run_test 21 "write to dangling link ============================"
794 test_mkdir -p $DIR/$tdir
795 chown $RUNAS_ID:$RUNAS_GID $WDIR
796 (cd $WDIR || error "cd $WDIR failed";
797 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
799 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
800 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
801 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
803 run_test 22 "unpack tar archive as non-root user ==============="
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
810 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
811 openfile -f O_CREAT:O_EXCL $file &&
812 error "$file recreate succeeded" || true
814 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
816 test_23b() { # bug 18988
817 test_mkdir -p $DIR/$tdir
818 local file=$DIR/$tdir/$tfile
821 echo foo > $file || error "write filed"
822 echo bar >> $file || error "append filed"
823 $CHECKSTAT -s 8 $file || error "wrong size"
826 run_test 23b "O_APPEND check =========================="
830 echo '-- same directory rename'
831 test_mkdir $DIR/$tdir
832 touch $DIR/$tdir/$tfile.1
833 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
834 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
836 run_test 24a "rename file to non-existent target"
839 test_mkdir $DIR/$tdir
840 touch $DIR/$tdir/$tfile.{1,2}
841 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
842 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
843 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
845 run_test 24b "rename file to existing target"
848 test_mkdir $DIR/$tdir
849 test_mkdir $DIR/$tdir/d$testnum.1
850 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
851 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
852 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
854 run_test 24c "rename directory to non-existent target"
857 test_mkdir -c1 $DIR/$tdir
858 test_mkdir -c1 $DIR/$tdir/d$testnum.1
859 test_mkdir -c1 $DIR/$tdir/d$testnum.2
860 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
861 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
862 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
864 run_test 24d "rename directory to existing target"
867 echo '-- cross directory renames --'
871 mv $DIR/R5a/f $DIR/R5b/g
872 $CHECKSTAT -a $DIR/R5a/f || error
873 $CHECKSTAT -t file $DIR/R5b/g || error
875 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
880 touch $DIR/R6a/f $DIR/R6b/g
881 mv $DIR/R6a/f $DIR/R6b/g
882 $CHECKSTAT -a $DIR/R6a/f || error
883 $CHECKSTAT -t file $DIR/R6b/g || error
885 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
890 test_mkdir $DIR/R7a/d
891 mv $DIR/R7a/d $DIR/R7b/e
892 $CHECKSTAT -a $DIR/R7a/d || error
893 $CHECKSTAT -t dir $DIR/R7b/e || error
895 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
898 test_mkdir -c1 $DIR/R8a
899 test_mkdir -c1 $DIR/R8b
900 test_mkdir -c1 $DIR/R8a/d
901 test_mkdir -c1 $DIR/R8b/e
902 mrename $DIR/R8a/d $DIR/R8b/e
903 $CHECKSTAT -a $DIR/R8a/d || error
904 $CHECKSTAT -t dir $DIR/R8b/e || error
906 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
909 echo "-- rename error cases"
913 mrename $DIR/R9/f $DIR/R9/a
914 $CHECKSTAT -t file $DIR/R9/f || error
915 $CHECKSTAT -t dir $DIR/R9/a || error
916 $CHECKSTAT -a $DIR/R9/a/f || error
918 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
922 mrename $DIR/R10/f $DIR/R10/g
923 $CHECKSTAT -t dir $DIR/R10 || error
924 $CHECKSTAT -a $DIR/R10/f || error
925 $CHECKSTAT -a $DIR/R10/g || error
927 run_test 24j "source does not exist ============================"
931 test_mkdir $DIR/R11a/d
933 mv $DIR/R11a/f $DIR/R11a/d
934 $CHECKSTAT -a $DIR/R11a/f || error
935 $CHECKSTAT -t file $DIR/R11a/d/f || error
937 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
939 # bug 2429 - rename foo foo foo creates invalid file
942 $MULTIOP $f OcNs || error
944 run_test 24l "Renaming a file to itself ========================"
948 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
949 # on ext3 this does not remove either the source or target files
950 # though the "expected" operation would be to remove the source
951 $CHECKSTAT -t file ${f} || error "${f} missing"
952 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
954 run_test 24m "Renaming a file to a hard link to itself ========="
958 # this stats the old file after it was renamed, so it should fail
962 $CHECKSTAT ${f}.rename
965 run_test 24n "Statting the old file after renaming (Posix rename 2)"
968 check_kernel_version 37 || return 0
969 test_mkdir -p $DIR/d24o
970 rename_many -s random -v -n 10 $DIR/d24o
972 run_test 24o "rename of files during htree split ==============="
977 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
978 mrename $DIR/R12a $DIR/R12b
979 $CHECKSTAT -a $DIR/R12a || error
980 $CHECKSTAT -t dir $DIR/R12b || error
981 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
982 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
984 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
986 cleanup_multiop_pause() {
992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
995 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
996 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
999 trap cleanup_multiop_pause EXIT
1000 mrename $DIR/R13a $DIR/R13b
1001 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1002 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1003 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1004 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1005 cleanup_multiop_pause
1006 wait $MULTIPID || error "multiop close failed"
1008 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1010 test_24r() { #bug 3789
1011 test_mkdir $DIR/R14a
1012 test_mkdir $DIR/R14a/b
1013 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1015 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1017 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1020 test_mkdir $DIR/R15a
1021 test_mkdir $DIR/R15a/b
1022 test_mkdir $DIR/R15a/b/c
1023 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1024 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1025 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1027 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1029 test_mkdir $DIR/R16a
1030 test_mkdir $DIR/R16a/b
1031 test_mkdir $DIR/R16a/b/c
1032 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1033 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1034 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1036 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1038 test_24u() { # bug12192
1040 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1041 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1043 run_test 24u "create stripe file"
1049 simple_cleanup_common() {
1052 wait_delete_completed
1055 max_pages_per_rpc() {
1056 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1060 local NRFILES=100000
1061 local FREE_INODES=$(mdt_free_inodes 0)
1062 [[ $FREE_INODES -lt $NRFILES ]] &&
1063 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1067 trap simple_cleanup_common EXIT
1069 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1070 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1073 createmany -m $DIR/$tdir/$tfile $NRFILES
1075 cancel_lru_locks mdc
1076 lctl set_param mdc.*.stats clear
1078 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1080 # LU-5 large readdir
1081 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1082 # 8 bytes for name(filename is mostly 5 in this test) +
1083 # 8 bytes for luda_type
1084 # take into account of overhead in lu_dirpage header and end mark in
1085 # each page, plus one in RPC_NUM calculation.
1087 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1088 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1089 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1090 awk '/^mds_readpage/ {print $2}')
1091 [[ $mds_readpage -gt $RPC_NUM ]] &&
1092 error "large readdir doesn't take effect"
1094 simple_cleanup_common
1096 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1098 test_24w() { # bug21506
1100 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1101 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1102 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1103 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1104 [ "$SZ1" = "$SZ2" ] || \
1105 error "Error reading at the end of the file $tfile"
1107 run_test 24w "Reading a file larger than 4Gb"
1110 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1113 local remote_dir=$DIR/$tdir/remote_dir
1116 $LFS mkdir -i $MDTIDX $remote_dir ||
1117 error "create remote directory failed"
1119 mkdir -p $DIR/$tdir/src_dir
1120 touch $DIR/$tdir/src_file
1121 mkdir -p $remote_dir/tgt_dir
1122 touch $remote_dir/tgt_file
1124 mrename $remote_dir $DIR/ &&
1125 error "rename dir cross MDT works!"
1127 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1128 error "rename dir cross MDT works!"
1130 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1131 error "rename file cross MDT works!"
1133 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1134 error "ln file cross MDT should not work!"
1136 rm -rf $DIR/$tdir || error "Can not delete directories"
1138 run_test 24x "cross rename/link should be failed"
1141 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1144 local remote_dir=$DIR/$tdir/remote_dir
1147 $LFS mkdir -i $MDTIDX $remote_dir ||
1148 error "create remote directory failed"
1150 mkdir -p $remote_dir/src_dir
1151 touch $remote_dir/src_file
1152 mkdir -p $remote_dir/tgt_dir
1153 touch $remote_dir/tgt_file
1155 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1156 error "rename subdir in the same remote dir failed!"
1158 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1159 error "rename files in the same remote dir failed!"
1161 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1162 error "link files in the same remote dir failed!"
1164 rm -rf $DIR/$tdir || error "Can not delete directories"
1166 run_test 24y "rename/link on the same dir should succeed"
1169 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1172 local remote_src=$DIR/$tdir/remote_dir
1173 local remote_tgt=$DIR/$tdir/remote_tgt
1176 $LFS mkdir -i $MDTIDX $remote_src ||
1177 error "create remote directory failed"
1179 $LFS mkdir -i $MDTIDX $remote_tgt ||
1180 error "create remote directory failed"
1182 mrename $remote_src $remote_tgt &&
1183 error "rename remote dirs should not work!"
1185 # If target dir does not exists, it should succeed
1187 mrename $remote_src $remote_tgt ||
1188 error "rename remote dirs(tgt dir does not exists) failed!"
1190 rm -rf $DIR/$tdir || error "Can not delete directories"
1192 run_test 24z "rename one remote dir to another remote dir should fail"
1194 test_24A() { # LU-3182
1199 createmany -m $DIR/$tdir/$tfile $NFILES
1200 local t=`ls $DIR/$tdir | wc -l`
1201 local u=`ls $DIR/$tdir | sort -u | wc -l`
1202 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1203 error "Expected $NFILES files, got $t ($u unique)"
1206 rm -rf $DIR/$tdir || error "Can not delete directories"
1208 run_test 24A "readdir() returns correct number of entries."
1211 echo '== symlink sanity ============================================='
1215 touch $DIR/s25/foo || error
1217 run_test 25a "create file in symlinked directory ==============="
1220 [ ! -d $DIR/d25 ] && test_25a
1221 $CHECKSTAT -t file $DIR/s25/foo || error
1223 run_test 25b "lookup file in symlinked directory ==============="
1227 test_mkdir $DIR/d26/d26-2
1228 ln -s d26/d26-2 $DIR/s26
1229 touch $DIR/s26/foo || error
1231 run_test 26a "multiple component symlink ======================="
1234 test_mkdir -p $DIR/d26b/d26-2
1235 ln -s d26b/d26-2/foo $DIR/s26-2
1236 touch $DIR/s26-2 || error
1238 run_test 26b "multiple component symlink at end of lookup ======"
1241 test_mkdir $DIR/d26.2
1242 touch $DIR/d26.2/foo
1243 ln -s d26.2 $DIR/s26.2-1
1244 ln -s s26.2-1 $DIR/s26.2-2
1245 ln -s s26.2-2 $DIR/s26.2-3
1246 chmod 0666 $DIR/s26.2-3/foo
1248 run_test 26c "chain of symlinks ================================"
1250 # recursive symlinks (bug 439)
1252 ln -s d26-3/foo $DIR/d26-3
1254 run_test 26d "create multiple component recursive symlink ======"
1257 [ ! -h $DIR/d26-3 ] && test_26d
1260 run_test 26e "unlink multiple component recursive symlink ======"
1262 # recursive symlinks (bug 7022)
1264 test_mkdir -p $DIR/$tdir
1265 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1266 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1267 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1268 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1269 cd $tfile || error "cd $tfile failed"
1270 ln -s .. dotdot || error "ln dotdot failed"
1271 ln -s dotdot/lndir lndir || error "ln lndir failed"
1272 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1273 output=`ls $tfile/$tfile/lndir/bar1`
1274 [ "$output" = bar1 ] && error "unexpected output"
1275 rm -r $tfile || error "rm $tfile failed"
1276 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1278 run_test 26f "rm -r of a directory which has recursive symlink ="
1281 echo '== stripe sanity =============================================='
1282 test_mkdir -p $DIR/d27 || error "mkdir failed"
1284 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1285 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1286 log "== test_27a: write to one stripe file ========================="
1287 cp /etc/hosts $DIR/d27/f0 || error
1289 run_test 27a "one stripe file =================================="
1292 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1293 test_mkdir -p $DIR/d27
1294 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1295 $GETSTRIPE -c $DIR/d27/f01
1296 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1297 error "two-stripe file doesn't have two stripes"
1299 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1301 run_test 27b "create and write to two stripe file"
1304 test_mkdir -p $DIR/d27
1305 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1306 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1307 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1309 run_test 27d "create file with default settings ================"
1312 test_mkdir -p $DIR/d27
1313 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1314 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1315 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1317 run_test 27e "setstripe existing file (should return error) ======"
1320 test_mkdir -p $DIR/d27
1321 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1322 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1323 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1325 run_test 27f "setstripe with bad stripe size (should return error)"
1328 test_mkdir -p $DIR/d27
1329 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1330 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1331 error "$DIR/d27/fnone has object"
1333 run_test 27g "$GETSTRIPE with no objects"
1336 touch $DIR/d27/fsome || error "touch failed"
1337 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1339 run_test 27i "$GETSTRIPE with some objects"
1342 test_mkdir -p $DIR/d27
1343 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1345 run_test 27j "setstripe with bad stripe offset (should return error)"
1347 test_27k() { # bug 2844
1348 test_mkdir -p $DIR/d27
1350 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1351 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1352 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1353 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1354 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1355 dd if=/dev/zero of=$FILE bs=4k count=1
1356 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1357 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1359 run_test 27k "limit i_blksize for broken user apps ============="
1362 test_mkdir -p $DIR/d27
1363 mcreate $DIR/f27l || error "creating file"
1364 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1365 error "setstripe should have failed" || true
1367 run_test 27l "check setstripe permissions (should return error)"
1370 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1372 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1373 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1376 trap simple_cleanup_common EXIT
1377 test_mkdir -p $DIR/$tdir
1378 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1379 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1380 error "dd should fill OST0"
1382 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1384 [ $i -gt 256 ] && break
1387 touch $DIR/$tdir/f27m_$i
1388 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1389 error "OST0 was full but new created file still use it"
1391 touch $DIR/$tdir/f27m_$i
1392 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1393 error "OST0 was full but new created file still use it"
1394 simple_cleanup_common
1396 run_test 27m "create file while OST0 was full =================="
1399 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1403 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1404 # if the OST isn't full anymore.
1406 local OSTIDX=${1:-""}
1408 local list=$(comma_list $(osts_nodes))
1409 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1411 do_nodes $list lctl set_param fail_loc=0
1412 sync # initiate all OST_DESTROYs from MDS to OST
1416 exhaust_precreations() {
1419 local FAILIDX=${3:-$OSTIDX}
1421 test_mkdir -p $DIR/$tdir
1422 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1423 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1425 local OST=$(ostname_from_index $OSTIDX)
1426 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1427 sed -e 's/_UUID$//;s/^.*-//')
1430 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1431 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1432 osc.$mdtosc_proc1.prealloc_last_id)
1433 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1434 osc.$mdtosc_proc1.prealloc_next_id)
1436 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1437 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1439 test_mkdir -p $DIR/$tdir/${OST}
1440 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1441 #define OBD_FAIL_OST_ENOSPC 0x215
1442 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1443 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1444 echo "Creating to objid $last_id on ost $OST..."
1445 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1446 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1447 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1451 exhaust_all_precreations() {
1453 for (( i=0; i < OSTCOUNT; i++ )) ; do
1454 exhaust_precreations $i $1 -1
1459 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1461 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1462 remote_ost_nodsh && skip "remote OST with nodsh" && return
1465 rm -f $DIR/$tdir/$tfile
1466 exhaust_precreations 0 0x80000215
1467 $SETSTRIPE -c -1 $DIR/$tdir
1468 touch $DIR/$tdir/$tfile || error
1469 $GETSTRIPE $DIR/$tdir/$tfile
1472 run_test 27n "create file with some full OSTs =================="
1475 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1478 remote_ost_nodsh && skip "remote OST with nodsh" && return
1481 rm -f $DIR/$tdir/$tfile
1482 exhaust_all_precreations 0x215
1484 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1489 run_test 27o "create file with all full OSTs (should error) ===="
1492 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1493 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1495 remote_ost_nodsh && skip "remote OST with nodsh" && return
1498 rm -f $DIR/$tdir/$tfile
1499 test_mkdir -p $DIR/$tdir
1501 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1502 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1503 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1505 exhaust_precreations 0 0x80000215
1506 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1507 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1508 $GETSTRIPE $DIR/$tdir/$tfile
1512 run_test 27p "append to a truncated file with some full OSTs ==="
1515 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1517 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1518 remote_ost_nodsh && skip "remote OST with nodsh" && return
1521 rm -f $DIR/$tdir/$tfile
1523 test_mkdir -p $DIR/$tdir
1524 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1525 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1526 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1528 exhaust_all_precreations 0x215
1530 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1531 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1535 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1538 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1541 remote_ost_nodsh && skip "remote OST with nodsh" && return
1544 rm -f $DIR/$tdir/$tfile
1545 exhaust_precreations 0 0x80000215
1547 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1551 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1553 test_27s() { # bug 10725
1554 test_mkdir -p $DIR/$tdir
1555 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1556 local stripe_count=0
1557 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1558 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1559 error "stripe width >= 2^32 succeeded" || true
1562 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1564 test_27t() { # bug 10864
1569 $WLFS getstripe $tfile
1572 run_test 27t "check that utils parse path correctly"
1574 test_27u() { # bug 4900
1575 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1576 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 local list=$(comma_list $(mdts_nodes))
1580 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1581 do_nodes $list $LCTL set_param fail_loc=0x139
1582 test_mkdir -p $DIR/$tdir
1584 createmany -o $DIR/$tdir/t- 1000
1585 do_nodes $list $LCTL set_param fail_loc=0
1587 TLOG=$DIR/$tfile.getstripe
1588 $GETSTRIPE $DIR/$tdir > $TLOG
1589 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1590 unlinkmany $DIR/$tdir/t- 1000
1591 [[ $OBJS -gt 0 ]] &&
1592 error "$OBJS objects created on OST-0. See $TLOG" || pass
1594 run_test 27u "skip object creation on OSC w/o objects =========="
1596 test_27v() { # bug 4900
1597 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1599 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1600 remote_ost_nodsh && skip "remote OST with nodsh" && return
1602 exhaust_all_precreations 0x215
1605 test_mkdir -p $DIR/$tdir
1606 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1608 touch $DIR/$tdir/$tfile
1609 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1611 for (( i=1; i < OSTCOUNT; i++ )); do
1612 do_facet ost$i lctl set_param fail_loc=0x705
1614 local START=`date +%s`
1615 createmany -o $DIR/$tdir/$tfile 32
1617 local FINISH=`date +%s`
1618 local TIMEOUT=`lctl get_param -n timeout`
1619 local PROCESS=$((FINISH - START))
1620 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1621 error "$FINISH - $START >= $TIMEOUT / 2"
1622 sleep $((TIMEOUT / 2 - PROCESS))
1625 run_test 27v "skip object creation on slow OST ================="
1627 test_27w() { # bug 10997
1628 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1629 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1630 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1631 error "stripe size $size != 65536" || true
1632 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1633 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1635 run_test 27w "check $SETSTRIPE -S option"
1638 [[ $OSTCOUNT -lt 2 ]] &&
1639 skip_env "skipping multiple stripe count/offset test" && return
1641 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1642 for i in $(seq 1 $OSTCOUNT); do
1644 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1645 error "setstripe -c $i -i $offset failed"
1646 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1647 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1648 [ $count -ne $i ] && error "stripe count $count != $i" || true
1649 [ $index -ne $offset ] &&
1650 error "stripe offset $index != $offset" || true
1653 run_test 27wa "check $SETSTRIPE -c -i options"
1656 remote_ost_nodsh && skip "remote OST with nodsh" && return
1657 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1659 OFFSET=$(($OSTCOUNT - 1))
1661 local OST=$(ostname_from_index $OSTIDX)
1663 test_mkdir -p $DIR/$tdir
1664 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1665 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1667 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1668 for i in `seq 0 $OFFSET`; do
1669 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1670 error "OST0 was degraded but new created file still use it"
1672 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1674 run_test 27x "create files while OST0 is degraded"
1677 [[ $OSTCOUNT -lt 2 ]] &&
1678 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1679 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1680 remote_ost_nodsh && skip "remote OST with nodsh" && return
1681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1683 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1684 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1685 osc.$mdtosc.prealloc_last_id)
1686 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1687 osc.$mdtosc.prealloc_next_id)
1688 local fcount=$((last_id - next_id))
1689 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1690 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1692 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1693 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1694 local OST_DEACTIVE_IDX=-1
1699 for OSC in $MDS_OSCS; do
1700 OST=$(osc_to_ost $OSC)
1701 OSTIDX=$(index_from_ostuuid $OST)
1702 if [ $OST_DEACTIVE_IDX == -1 ]; then
1703 OST_DEACTIVE_IDX=$OSTIDX
1705 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1706 echo $OSC "is Deactivated:"
1707 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1711 OSTIDX=$(index_from_ostuuid $OST)
1713 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1715 for OSC in $MDS_OSCS; do
1716 OST=$(osc_to_ost $OSC)
1717 OSTIDX=$(index_from_ostuuid $OST)
1718 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1719 echo $OST "is degraded:"
1720 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1721 obdfilter.$OST.degraded=1
1726 createmany -o $DIR/$tdir/$tfile $fcount
1728 for OSC in $MDS_OSCS; do
1729 OST=$(osc_to_ost $OSC)
1730 OSTIDX=$(index_from_ostuuid $OST)
1731 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1732 echo $OST "is recovered from degraded:"
1733 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1734 obdfilter.$OST.degraded=0
1736 do_facet $SINGLEMDS lctl --device %$OSC activate
1740 # all osp devices get activated, hence -1 stripe count restored
1743 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1744 # devices get activated.
1746 $SETSTRIPE -c -1 $DIR/$tfile
1747 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1749 [ $stripecnt -ne $OSTCOUNT ] &&
1750 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1753 run_test 27y "create files while OST0 is degraded and the rest inactive"
1759 lmm_count=$($GETSTRIPE -c $1)
1760 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1761 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1763 local old_ifs="$IFS"
1765 fid=($($LFS path2fid $1))
1768 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1769 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1771 # compare lmm_seq and lu_fid->f_seq
1772 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1773 # compare lmm_object_id and lu_fid->oid
1774 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1776 # check the trusted.fid attribute of the OST objects of the file
1777 local have_obdidx=false
1779 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1780 # skip lines up to and including "obdidx"
1781 [ -z "$obdidx" ] && break
1782 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1783 $have_obdidx || continue
1785 local ost=$((obdidx + 1))
1786 local dev=$(ostdevname $ost)
1789 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1791 seq=$(echo $seq | sed -e "s/^0x//g")
1792 if [ $seq == 0 ]; then
1793 oid_hex=$(echo $oid)
1795 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1797 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1801 # Don't unmount/remount the OSTs if we don't need to do that.
1802 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1803 # update too, until that use mount/ll_decode_filter_fid/mount.
1804 # Re-enable when debugfs will understand new filter_fid.
1806 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1807 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1808 $dev 2>/dev/null" | grep "parent=")
1811 mount_fstype ost$ost
1812 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1813 $(facet_mntpt ost$ost)/$obj_file)
1814 unmount_fstype ost$ost
1815 start ost$ost $dev $OST_MOUNT_OPTS
1818 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1820 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1822 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1823 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1824 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1825 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1826 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1828 if echo $ff_parent | grep -q 'stripe='; then
1829 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1832 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1833 # into f_ver in this case. See the comment on
1836 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1840 # compare lmm_seq and filter_fid->ff_parent.f_seq
1841 [ $ff_pseq = $lmm_seq ] ||
1842 error "FF parent SEQ $ff_pseq != $lmm_seq"
1843 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1844 [ $ff_poid = $lmm_oid ] ||
1845 error "FF parent OID $ff_poid != $lmm_oid"
1846 (($ff_pstripe == $stripe_nr)) ||
1847 error "FF stripe $ff_pstripe != $stripe_nr"
1849 stripe_nr=$((stripe_nr + 1))
1854 remote_ost_nodsh && skip "remote OST with nodsh" && return
1855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1856 test_mkdir -p $DIR/$tdir
1858 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1859 { error "setstripe -c -1 failed"; return 1; }
1860 # We need to send a write to every object to get parent FID info set.
1861 # This _should_ also work for setattr, but does not currently.
1862 # touch $DIR/$tdir/$tfile-1 ||
1863 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1864 { error "dd $tfile-1 failed"; return 2; }
1865 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1866 { error "setstripe -c -1 failed"; return 3; }
1867 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1868 { error "dd $tfile-2 failed"; return 4; }
1870 # make sure write RPCs have been sent to OSTs
1873 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1874 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1876 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1878 test_27A() { # b=19102
1879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1880 local restore_size=$($GETSTRIPE -S $MOUNT)
1881 local restore_count=$($GETSTRIPE -c $MOUNT)
1882 local restore_offset=$($GETSTRIPE -i $MOUNT)
1883 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1884 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1885 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1886 local default_size=$($GETSTRIPE -S $MOUNT)
1887 local default_offset=$($GETSTRIPE -i $MOUNT)
1888 local dsize=$((1024 * 1024))
1889 [ $default_size -eq $dsize ] ||
1890 error "stripe size $default_size != $dsize"
1891 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1892 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1894 run_test 27A "check filesystem-wide default LOV EA values"
1896 test_27B() { # LU-2523
1897 test_mkdir -p $DIR/$tdir
1898 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1900 # open f1 with O_LOV_DELAY_CREATE
1902 # call setstripe ioctl on open file descriptor for f1
1904 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1908 # open f1 with O_LOV_DELAY_CREATE
1910 # call setstripe ioctl on open file descriptor for f1
1912 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1914 # Allow multiop to fail in imitation of NFS's busted semantics.
1917 run_test 27B "call setstripe on open unlinked file/rename victim"
1919 test_27C() { #LU-2871
1920 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1928 test_mkdir -p $DIR/$tdir
1930 for i in $(seq 0 $((OSTCOUNT - 1))); do
1931 # set stripe across all OSTs starting from OST$i
1932 $SETSTRIPE -i $i -c -1 $tfile$i
1933 # get striping information
1934 ost_idx=($($GETSTRIPE $tfile$i |
1935 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1939 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1940 error "${#ost_idx[@]} != $OSTCOUNT"
1942 for index in $(seq 0 $((OSTCOUNT - 1))); do
1944 for j in $(echo ${ost_idx[@]}); do
1945 if [ $index -eq $j ]; then
1951 error "Can not find $index in ${ost_idx[@]}"
1955 run_test 27C "check full striping across all OSTs"
1957 # createtest also checks that device nodes are created and
1958 # then visible correctly (#2091)
1959 test_28() { # bug 2091
1961 $CREATETEST $DIR/d28/ct || error
1963 run_test 28 "create/mknod/mkdir with bad file types ============"
1966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1967 cancel_lru_locks mdc
1973 declare -i LOCKCOUNTORIG=0
1974 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1975 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1977 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1979 declare -i LOCKUNUSEDCOUNTORIG=0
1980 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1981 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1988 declare -i LOCKCOUNTCURRENT=0
1989 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1990 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1993 declare -i LOCKUNUSEDCOUNTCURRENT=0
1994 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1995 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1998 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
1999 $LCTL set_param -n ldlm.dump_namespaces ""
2000 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2001 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2002 log "dumped log to $TMP/test_29.dk (bug 5793)"
2005 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2006 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2007 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2008 log "dumped log to $TMP/test_29.dk (bug 5793)"
2012 run_test 29 "IT_GETATTR regression ============================"
2014 test_30a() { # was test_30
2015 cp $(which ls) $DIR || cp /bin/ls $DIR
2019 run_test 30a "execute binary from Lustre (execve) =============="
2022 cp `which ls` $DIR || cp /bin/ls $DIR
2024 $RUNAS $DIR/ls / || error
2027 run_test 30b "execute binary from Lustre as non-root ==========="
2029 test_30c() { # b=22376
2030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2031 cp `which ls` $DIR || cp /bin/ls $DIR
2033 cancel_lru_locks mdc
2034 cancel_lru_locks osc
2035 $RUNAS $DIR/ls / || error
2038 run_test 30c "execute binary from Lustre without read perms ===="
2041 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2042 $CHECKSTAT -a $DIR/f31 || error
2044 run_test 31a "open-unlink file =================================="
2047 touch $DIR/f31 || error
2048 ln $DIR/f31 $DIR/f31b || error
2049 $MULTIOP $DIR/f31b Ouc || error
2050 $CHECKSTAT -t file $DIR/f31 || error
2052 run_test 31b "unlink file with multiple links while open ======="
2055 touch $DIR/f31 || error
2056 ln $DIR/f31 $DIR/f31c || error
2057 multiop_bg_pause $DIR/f31 O_uc || return 1
2059 $MULTIOP $DIR/f31c Ouc
2060 kill -USR1 $MULTIPID
2063 run_test 31c "open-unlink file with multiple links ============="
2066 opendirunlink $DIR/d31d $DIR/d31d || error
2067 $CHECKSTAT -a $DIR/d31d || error
2069 run_test 31d "remove of open directory ========================="
2071 test_31e() { # bug 2904
2072 check_kernel_version 34 || return 0
2073 openfilleddirunlink $DIR/d31e || error
2075 run_test 31e "remove of open non-empty directory ==============="
2077 test_31f() { # bug 4554
2078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2080 test_mkdir $DIR/d31f
2081 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2082 cp /etc/hosts $DIR/d31f
2084 $GETSTRIPE $DIR/d31f/hosts
2085 multiop_bg_pause $DIR/d31f D_c || return 1
2088 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2089 test_mkdir $DIR/d31f
2090 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2091 cp /etc/hosts $DIR/d31f
2093 $GETSTRIPE $DIR/d31f/hosts
2094 multiop_bg_pause $DIR/d31f D_c || return 1
2097 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2098 wait $MULTIPID || error "first opendir $MULTIPID failed"
2102 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2103 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2106 run_test 31f "remove of open directory with open-unlink file ==="
2109 echo "-- cross directory link --"
2110 test_mkdir -c1 $DIR/${tdir}ga
2111 test_mkdir -c1 $DIR/${tdir}gb
2112 touch $DIR/${tdir}ga/f
2113 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2114 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2115 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2116 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2117 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2119 run_test 31g "cross directory link==============="
2122 echo "-- cross directory link --"
2123 test_mkdir -c1 $DIR/${tdir}
2124 test_mkdir -c1 $DIR/${tdir}/dir
2125 touch $DIR/${tdir}/f
2126 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2127 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2128 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2129 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2130 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2132 run_test 31h "cross directory link under child==============="
2135 echo "-- cross directory link --"
2136 test_mkdir -c1 $DIR/$tdir
2137 test_mkdir -c1 $DIR/$tdir/dir
2138 touch $DIR/$tdir/dir/f
2139 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2140 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2141 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2142 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2143 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2145 run_test 31i "cross directory link under parent==============="
2148 test_mkdir -c1 -p $DIR/$tdir
2149 test_mkdir -c1 -p $DIR/$tdir/dir1
2150 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2151 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2152 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2153 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2156 run_test 31j "link for directory==============="
2159 test_mkdir -c1 -p $DIR/$tdir
2161 touch $DIR/$tdir/exist
2162 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2163 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2164 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2165 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2166 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2167 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2168 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2171 run_test 31k "link to file: the same, non-existing, dir==============="
2177 touch $DIR/d31m2/exist
2178 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2179 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2180 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2181 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2182 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2183 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2186 run_test 31m "link to file: the same, non-existing, dir==============="
2189 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2190 nlink=$(stat --format=%h $DIR/$tfile)
2191 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2193 local cmd="exec $fd<$DIR/$tfile"
2196 trap "eval $cmd" EXIT
2197 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2198 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2199 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2200 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2201 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2204 run_test 31n "check link count of unlinked file"
2207 local TEMPNAME=$(mktemp $1_XXXXXX)
2208 mlink $TEMPNAME $1 2> /dev/null &&
2209 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2213 test_31o() { # LU-2901
2215 for LOOP in $(seq 100); do
2216 rm -f $DIR/$tdir/$tfile*
2217 for THREAD in $(seq 8); do
2218 link_one $DIR/$tdir/$tfile.$LOOP &
2221 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2222 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2223 error "$LINKS duplicate links to $tfile.$LOOP" &&
2227 run_test 31o "duplicate hard links with same filename"
2230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2233 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2234 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2236 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2237 error "open unlink test1 failed"
2238 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2239 error "open unlink test2 failed"
2241 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2242 error "test1 still exists"
2243 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2244 error "test2 still exists"
2246 run_test 31p "remove of open striped directory"
2248 cleanup_test32_mount() {
2250 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2255 echo "== more mountpoints and symlinks ================="
2256 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2257 trap cleanup_test32_mount EXIT
2258 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2259 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2260 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2261 cleanup_test32_mount
2263 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2267 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2268 trap cleanup_test32_mount EXIT
2269 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2270 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2271 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2272 cleanup_test32_mount
2274 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2278 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2279 trap cleanup_test32_mount EXIT
2280 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2281 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2282 test_mkdir -p $DIR/$tdir/d2/test_dir
2283 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2284 cleanup_test32_mount
2286 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2289 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2290 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2291 trap cleanup_test32_mount EXIT
2292 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2293 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2294 test_mkdir -p $DIR/$tdir/d2/test_dir
2295 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2296 cleanup_test32_mount
2298 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2301 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2302 test_mkdir -p $DIR/d32e/tmp
2303 TMP_DIR=$DIR/d32e/tmp
2304 ln -s $DIR/d32e $TMP_DIR/symlink11
2305 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2306 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2307 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2309 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2312 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2313 test_mkdir -p $DIR/d32f/tmp
2314 TMP_DIR=$DIR/d32f/tmp
2315 ln -s $DIR/d32f $TMP_DIR/symlink11
2316 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2317 ls $DIR/d32f/tmp/symlink11 || error
2318 ls $DIR/d32f/symlink01 || error
2320 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2323 TMP_DIR=$DIR/$tdir/tmp
2324 test_mkdir -p $DIR/$tdir/tmp
2325 test_mkdir $DIR/${tdir}2
2326 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2327 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2328 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2329 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2330 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2331 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2333 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2336 rm -fr $DIR/$tdir $DIR/${tdir}2
2337 TMP_DIR=$DIR/$tdir/tmp
2338 test_mkdir -p $DIR/$tdir/tmp
2339 test_mkdir $DIR/${tdir}2
2340 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2341 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2342 ls $TMP_DIR/symlink12 || error
2343 ls $DIR/$tdir/symlink02 || error
2345 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2349 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2350 trap cleanup_test32_mount EXIT
2351 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2352 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2353 touch $DIR/$tdir/test_file
2354 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2355 cleanup_test32_mount
2357 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2361 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2362 trap cleanup_test32_mount EXIT
2363 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2364 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2365 touch $DIR/$tdir/test_file
2366 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2367 cleanup_test32_mount
2369 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2374 trap cleanup_test32_mount EXIT
2375 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2376 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2377 test_mkdir -p $DIR/$tdir/d2
2378 touch $DIR/$tdir/d2/test_file || error
2379 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2380 cleanup_test32_mount
2382 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2387 trap cleanup_test32_mount EXIT
2388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2390 test_mkdir -p $DIR/$tdir/d2
2391 touch $DIR/$tdir/d2/test_file
2392 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2393 cleanup_test32_mount
2395 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2399 test_mkdir -p $DIR/d32m/tmp
2400 TMP_DIR=$DIR/d32m/tmp
2401 ln -s $DIR $TMP_DIR/symlink11
2402 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2403 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2404 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2406 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2410 test_mkdir -p $DIR/d32n/tmp
2411 TMP_DIR=$DIR/d32n/tmp
2412 ln -s $DIR $TMP_DIR/symlink11
2413 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2414 ls -l $DIR/d32n/tmp/symlink11 || error
2415 ls -l $DIR/d32n/symlink01 || error
2417 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2420 rm -fr $DIR/d32o $DIR/$tfile
2422 test_mkdir -p $DIR/d32o/tmp
2423 TMP_DIR=$DIR/d32o/tmp
2424 ln -s $DIR/$tfile $TMP_DIR/symlink12
2425 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2426 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2427 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2428 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2429 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2431 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2441 test_mkdir -p $DIR/d32p/tmp
2443 TMP_DIR=$DIR/d32p/tmp
2445 ln -s $DIR/$tfile $TMP_DIR/symlink12
2447 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2449 cat $DIR/d32p/tmp/symlink12 || error
2451 cat $DIR/d32p/symlink02 || error
2454 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2456 cleanup_testdir_mount() {
2458 $UMOUNT -d $DIR/$tdir
2462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2463 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2464 trap cleanup_testdir_mount EXIT
2465 test_mkdir -p $DIR/$tdir
2466 touch $DIR/$tdir/under_the_mount
2467 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2468 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2469 cleanup_testdir_mount
2471 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2475 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2476 trap cleanup_testdir_mount EXIT
2477 test_mkdir -p $DIR/$tdir
2478 touch $DIR/$tdir/under_the_mount
2479 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2480 ls $DIR/$tdir | grep -q under_the_mount && error || true
2481 cleanup_testdir_mount
2483 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2488 chmod 444 $DIR/$tfile
2489 chown $RUNAS_ID $DIR/$tfile
2491 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2494 run_test 33aa "write file with mode 444 (should return error) ===="
2498 test_mkdir -p $DIR/d33
2499 chown $RUNAS_ID $DIR/d33
2500 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2501 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2502 error "open RDWR" || true
2504 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2508 test_mkdir -p $DIR/d33
2509 chown $RUNAS_ID $DIR/d33
2510 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2512 run_test 33b "test open file with malformed flags (No panic and return error)"
2515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2521 remote_ost_nodsh && skip "remote OST with nodsh" && return
2524 test_mkdir -p $DIR/d33
2525 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2528 for ostnum in $(seq $OSTCOUNT); do
2529 # test-framework's OST numbering is one-based, while Lustre's
2531 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2532 # Parsing llobdstat's output sucks; we could grep the /proc
2533 # path, but that's likely to not be as portable as using the
2534 # llobdstat utility. So we parse lctl output instead.
2535 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2536 obdfilter/$ostname/stats |
2537 awk '/^write_bytes/ {print $7}' )
2538 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2539 if (( ${write_bytes:-0} > 0 ))
2546 $all_zeros || return 0
2549 echo foo > $DIR/d33/bar
2553 # Total up write_bytes after writing. We'd better find non-zeros.
2554 for ostnum in $(seq $OSTCOUNT); do
2555 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2556 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2557 obdfilter/$ostname/stats |
2558 awk '/^write_bytes/ {print $7}' )
2559 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2560 if (( ${write_bytes:-0} > 0 ))
2569 for ostnum in $(seq $OSTCOUNT); do
2570 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2571 echo "Check that write_bytes is present in obdfilter/*/stats:"
2572 do_facet ost$ostnum lctl get_param -n \
2573 obdfilter/$ostname/stats
2575 error "OST not keeping write_bytes stats (b22312)"
2578 run_test 33c "test llobdstat and write_bytes"
2581 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2584 local remote_dir=$DIR/$tdir/remote_dir
2587 $LFS mkdir -i $MDTIDX $remote_dir ||
2588 error "create remote directory failed"
2590 touch $remote_dir/$tfile
2591 chmod 444 $remote_dir/$tfile
2592 chown $RUNAS_ID $remote_dir/$tfile
2594 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2596 chown $RUNAS_ID $remote_dir
2597 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2598 error "create" || true
2599 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2600 error "open RDWR" || true
2601 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2602 error "create" || true
2604 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2606 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2609 $MCREATE $DIR/f34 || error
2610 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2611 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2612 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2613 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2615 run_test 34a "truncate file that has not been opened ==========="
2618 [ ! -f $DIR/f34 ] && test_34a
2619 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2620 $OPENFILE -f O_RDONLY $DIR/f34
2621 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2622 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2624 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2627 [ ! -f $DIR/f34 ] && test_34a
2628 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2629 $OPENFILE -f O_RDWR $DIR/f34
2630 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2631 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2633 run_test 34c "O_RDWR opening file-with-size works =============="
2636 [ ! -f $DIR/f34 ] && test_34a
2637 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2638 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2641 run_test 34d "write to sparse file ============================="
2645 $MCREATE $DIR/f34e || error
2646 $TRUNCATE $DIR/f34e 1000 || error
2647 $CHECKSTAT -s 1000 $DIR/f34e || error
2648 $OPENFILE -f O_RDWR $DIR/f34e
2649 $CHECKSTAT -s 1000 $DIR/f34e || error
2651 run_test 34e "create objects, some with size and some without =="
2653 test_34f() { # bug 6242, 6243
2654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2657 $MCREATE $DIR/f34f || error
2658 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2659 dd if=$DIR/f34f of=$TMP/f34f
2660 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2661 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2662 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2663 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2664 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2666 run_test 34f "read from a file with no objects until EOF ======="
2669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2670 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2671 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2672 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2673 cancel_lru_locks osc
2674 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2675 error "wrong size after lock cancel"
2677 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2678 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2679 error "expanding truncate failed"
2680 cancel_lru_locks osc
2681 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2682 error "wrong expanded size after lock cancel"
2684 run_test 34g "truncate long file ==============================="
2687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2691 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2692 sync # Flush the cache so that multiop below does not block on cache
2693 # flush when getting the group lock
2694 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2697 # Since just timed wait is not good enough, let's do a sync write
2698 # that way we are sure enough time for a roundtrip + processing
2699 # passed + 2 seconds of extra margin.
2700 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2704 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2705 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2709 local nsz=`stat -c %s $DIR/$tfile`
2710 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2712 run_test 34h "ftruncate file under grouplock should not block"
2715 cp /bin/sh $DIR/f35a
2717 chown $RUNAS_ID $DIR/f35a
2718 $RUNAS $DIR/f35a && error || true
2721 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2725 utime $DIR/f36 || error
2727 run_test 36a "MDS utime check (mknod, utime) ==================="
2731 utime $DIR/f36 || error
2733 run_test 36b "OST utime check (open, utime) ===================="
2738 chown $RUNAS_ID $DIR/d36
2739 $RUNAS utime $DIR/d36/f36 || error
2741 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2744 [ ! -d $DIR/d36 ] && test_36c
2745 echo "" > $DIR/d36/f36
2746 $RUNAS utime $DIR/d36/f36 || error
2748 run_test 36d "non-root OST utime check (open, utime) ==========="
2751 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2752 test_mkdir -p $DIR/$tdir
2753 touch $DIR/$tdir/$tfile
2754 $RUNAS utime $DIR/$tdir/$tfile && \
2755 error "utime worked, expected failure" || true
2757 run_test 36e "utime on non-owned file (should return error) ===="
2761 local LANG_SAVE=$LANG
2762 local LC_LANG_SAVE=$LC_LANG
2763 export LANG=C LC_LANG=C # for date language
2765 DATESTR="Dec 20 2000"
2766 test_mkdir -p $DIR/$tdir
2767 lctl set_param fail_loc=$fl
2769 cp /etc/hosts $DIR/$tdir/$tfile
2770 sync & # write RPC generated with "current" inode timestamp, but delayed
2772 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2773 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2774 cancel_lru_locks osc
2775 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2777 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2778 echo "BEFORE: $LS_BEFORE" && \
2779 echo "AFTER : $LS_AFTER" && \
2780 echo "WANT : $DATESTR" && \
2781 error "$DIR/$tdir/$tfile timestamps changed" || true
2783 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2788 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2789 subr_36fh "0x80000214"
2791 run_test 36f "utime on file racing with OST BRW write =========="
2794 remote_ost_nodsh && skip "remote OST with nodsh" && return
2795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2800 test_mkdir -p $DIR/$tdir
2801 fmd_max_age=$(do_facet ost1 \
2802 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2805 fmd_before=$(do_facet ost1 \
2806 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2807 touch $DIR/$tdir/$tfile
2808 sleep $((fmd_max_age + 12))
2809 fmd_after=$(do_facet ost1 \
2810 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2812 echo "fmd_before: $fmd_before"
2813 echo "fmd_after: $fmd_after"
2814 [[ $fmd_after -gt $fmd_before ]] &&
2815 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2816 error "fmd didn't expire after ping" || true
2818 run_test 36g "filter mod data cache expiry ====================="
2821 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2822 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2823 subr_36fh "0x80000227"
2825 run_test 36h "utime on file racing with OST BRW write =========="
2828 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2831 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2833 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2834 local new_mtime=$((mtime + 200))
2836 #change Modify time of striped dir
2837 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2838 error "change mtime failed"
2840 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2842 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2844 run_test 36i "change mtime on striped directory"
2846 # test_37 - duplicate with tests 32q 32r
2849 local file=$DIR/$tfile
2851 openfile -f O_DIRECTORY $file
2854 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2855 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2857 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2861 touch $DIR/${tfile}2
2862 # ls -l $DIR/$tfile $DIR/${tfile}2
2863 # ls -lu $DIR/$tfile $DIR/${tfile}2
2864 # ls -lc $DIR/$tfile $DIR/${tfile}2
2866 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2867 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2869 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2871 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2873 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2874 error "O_TRUNC didn't change timestamps"
2877 run_test 39 "mtime changed on create ==========================="
2880 test_mkdir -p -c1 $DIR/$tdir
2881 cp -p /etc/passwd $DIR/$tdir/fopen
2882 cp -p /etc/passwd $DIR/$tdir/flink
2883 cp -p /etc/passwd $DIR/$tdir/funlink
2884 cp -p /etc/passwd $DIR/$tdir/frename
2885 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2888 echo "aaaaaa" >> $DIR/$tdir/fopen
2889 echo "aaaaaa" >> $DIR/$tdir/flink
2890 echo "aaaaaa" >> $DIR/$tdir/funlink
2891 echo "aaaaaa" >> $DIR/$tdir/frename
2893 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2894 local link_new=`stat -c %Y $DIR/$tdir/flink`
2895 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2896 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2898 cat $DIR/$tdir/fopen > /dev/null
2899 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2900 rm -f $DIR/$tdir/funlink2
2901 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2903 for (( i=0; i < 2; i++ )) ; do
2904 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2905 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2906 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2907 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2909 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2910 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2911 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2912 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2914 cancel_lru_locks osc
2915 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2918 run_test 39b "mtime change on open, link, unlink, rename ======"
2920 # this should be set to past
2921 TEST_39_MTIME=`date -d "1 year ago" +%s`
2927 local mtime0=`stat -c %Y $DIR1/$tfile`
2929 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2930 local mtime1=`stat -c %Y $DIR1/$tfile`
2931 [ "$mtime1" = $TEST_39_MTIME ] || \
2932 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2935 echo hello >> $DIR1/$tfile
2937 local mtime2=`stat -c %Y $DIR1/$tfile`
2938 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2939 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2941 mv $DIR1/$tfile $DIR1/$tfile-1
2943 for (( i=0; i < 2; i++ )) ; do
2944 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2945 [ "$mtime2" = "$mtime3" ] || \
2946 error "mtime ($mtime2) changed (to $mtime3) on rename"
2948 cancel_lru_locks osc
2949 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2952 run_test 39c "mtime change on rename ==========================="
2956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2959 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2961 for (( i=0; i < 2; i++ )) ; do
2962 local mtime=`stat -c %Y $DIR1/$tfile`
2963 [ $mtime = $TEST_39_MTIME ] || \
2964 error "mtime($mtime) is not set to $TEST_39_MTIME"
2966 cancel_lru_locks osc
2967 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2970 run_test 39d "create, utime, stat =============================="
2974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2976 local mtime1=`stat -c %Y $DIR1/$tfile`
2978 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2980 for (( i=0; i < 2; i++ )) ; do
2981 local mtime2=`stat -c %Y $DIR1/$tfile`
2982 [ $mtime2 = $TEST_39_MTIME ] || \
2983 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2985 cancel_lru_locks osc
2986 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2989 run_test 39e "create, stat, utime, stat ========================"
2993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2995 mtime1=`stat -c %Y $DIR1/$tfile`
2998 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3000 for (( i=0; i < 2; i++ )) ; do
3001 local mtime2=`stat -c %Y $DIR1/$tfile`
3002 [ $mtime2 = $TEST_39_MTIME ] || \
3003 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3005 cancel_lru_locks osc
3006 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3009 run_test 39f "create, stat, sleep, utime, stat ================="
3013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3014 echo hello >> $DIR1/$tfile
3015 local mtime1=`stat -c %Y $DIR1/$tfile`
3018 chmod o+r $DIR1/$tfile
3020 for (( i=0; i < 2; i++ )) ; do
3021 local mtime2=`stat -c %Y $DIR1/$tfile`
3022 [ "$mtime1" = "$mtime2" ] || \
3023 error "lost mtime: $mtime2, should be $mtime1"
3025 cancel_lru_locks osc
3026 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3029 run_test 39g "write, chmod, stat ==============================="
3033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3038 echo hello >> $DIR1/$tfile
3039 local mtime1=`stat -c %Y $DIR1/$tfile`
3041 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3043 if [ "$d1" != "$d2" ]; then
3044 echo "write and touch not within one second"
3046 for (( i=0; i < 2; i++ )) ; do
3047 local mtime2=`stat -c %Y $DIR1/$tfile`
3048 [ "$mtime2" = $TEST_39_MTIME ] || \
3049 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3051 cancel_lru_locks osc
3052 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3056 run_test 39h "write, utime within one second, stat ============="
3059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3063 echo hello >> $DIR1/$tfile
3064 local mtime1=`stat -c %Y $DIR1/$tfile`
3066 mv $DIR1/$tfile $DIR1/$tfile-1
3068 for (( i=0; i < 2; i++ )) ; do
3069 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3071 [ "$mtime1" = "$mtime2" ] || \
3072 error "lost mtime: $mtime2, should be $mtime1"
3074 cancel_lru_locks osc
3075 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3078 run_test 39i "write, rename, stat =============================="
3081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3082 start_full_debug_logging
3086 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3087 lctl set_param fail_loc=0x80000412
3088 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3089 error "multiop failed"
3091 local mtime1=`stat -c %Y $DIR1/$tfile`
3093 mv $DIR1/$tfile $DIR1/$tfile-1
3095 kill -USR1 $multipid
3096 wait $multipid || error "multiop close failed"
3098 for (( i=0; i < 2; i++ )) ; do
3099 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3100 [ "$mtime1" = "$mtime2" ] ||
3101 error "mtime is lost on close: $mtime2, " \
3104 cancel_lru_locks osc
3105 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3107 lctl set_param fail_loc=0
3108 stop_full_debug_logging
3110 run_test 39j "write, rename, close, stat ======================="
3113 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3117 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3119 local mtime1=`stat -c %Y $DIR1/$tfile`
3121 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3123 kill -USR1 $multipid
3124 wait $multipid || error "multiop close failed"
3126 for (( i=0; i < 2; i++ )) ; do
3127 local mtime2=`stat -c %Y $DIR1/$tfile`
3129 [ "$mtime2" = $TEST_39_MTIME ] || \
3130 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3132 cancel_lru_locks osc
3133 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3136 run_test 39k "write, utime, close, stat ========================"
3138 # this should be set to future
3139 TEST_39_ATIME=`date -d "1 year" +%s`
3142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3143 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3144 local atime_diff=$(do_facet $SINGLEMDS \
3145 lctl get_param -n mdd.*MDT0000*.atime_diff)
3149 # test setting directory atime to future
3150 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3151 local atime=$(stat -c %X $DIR/$tdir)
3152 [ "$atime" = $TEST_39_ATIME ] || \
3153 error "atime is not set to future: $atime, $TEST_39_ATIME"
3155 # test setting directory atime from future to now
3156 local d1=$(date +%s)
3158 local d2=$(date +%s)
3160 cancel_lru_locks mdc
3161 atime=$(stat -c %X $DIR/$tdir)
3162 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3163 error "atime is not updated from future: $atime, $d1<atime<$d2"
3165 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3168 # test setting directory atime when now > dir atime + atime_diff
3172 cancel_lru_locks mdc
3173 atime=$(stat -c %X $DIR/$tdir)
3174 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3175 error "atime is not updated : $atime, should be $d2"
3177 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3180 # test not setting directory atime when now < dir atime + atime_diff
3182 cancel_lru_locks mdc
3183 atime=$(stat -c %X $DIR/$tdir)
3184 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3185 error "atime is updated to $atime, should remain $d1<atime<$d2"
3187 do_facet $SINGLEMDS \
3188 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3190 run_test 39l "directory atime update ==========================="
3193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3196 local far_past_mtime=$(date -d "May 29 1953" +%s)
3197 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3199 touch -m -d @$far_past_mtime $DIR1/$tfile
3200 touch -a -d @$far_past_atime $DIR1/$tfile
3202 for (( i=0; i < 2; i++ )) ; do
3203 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3204 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3205 error "atime or mtime set incorrectly"
3207 cancel_lru_locks osc
3208 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3211 run_test 39m "test atime and mtime before 1970"
3213 test_39n() { # LU-3832
3214 local atime_diff=$(do_facet $SINGLEMDS \
3215 lctl get_param -n mdd.*MDT0000*.atime_diff)
3220 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3223 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3224 atime0=$(stat -c %X $DIR/$tfile)
3227 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3228 atime1=$(stat -c %X $DIR/$tfile)
3231 cancel_lru_locks mdc
3232 cancel_lru_locks osc
3233 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3234 atime2=$(stat -c %X $DIR/$tfile)
3236 do_facet $SINGLEMDS \
3237 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3239 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3240 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3242 run_test 39n "check that O_NOATIME is honored"
3245 TESTDIR=$DIR/$tdir/$tfile
3246 [ -e $TESTDIR ] && rm -rf $TESTDIR
3247 test_mkdir -p $TESTDIR
3253 links2=$(stat -c %h .)
3254 [ $(($links1 + 2)) != $links2 ] &&
3255 error "wrong links count $(($links1 + 2)) != $links2"
3257 links3=$(stat -c %h .)
3258 [ $(($links1 + 1)) != $links3 ] &&
3259 error "wrong links count $links1 != $links3"
3262 run_test 39o "directory cached attributes updated after create ========"
3265 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3267 TESTDIR=$DIR/$tdir/$tfile
3268 [ -e $TESTDIR ] && rm -rf $TESTDIR
3273 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3274 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3276 links2=$(stat -c %h .)
3277 [ $(($links1 + 2)) != $links2 ] &&
3278 error "wrong links count $(($links1 + 2)) != $links2"
3280 links3=$(stat -c %h .)
3281 [ $(($links1 + 1)) != $links3 ] &&
3282 error "wrong links count $links1 != $links3"
3285 run_test 39p "remote directory cached attributes updated after create ========"
3289 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3290 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3291 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3292 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3293 error "$tfile is not 4096 bytes in size"
3295 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3299 small_write $DIR/f41 18
3301 run_test 41 "test small file write + fstat ====================="
3303 count_ost_writes() {
3304 lctl get_param -n osc.*.stats |
3305 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3306 END { printf("%0.0f", writes) }'
3313 BG_DIRTY_RATIO_SAVE=10
3314 MAX_BG_DIRTY_RATIO=25
3318 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3319 # dirty_ratio, dirty_background_ratio
3320 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3321 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3322 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3323 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3325 # if file not here, we are a 2.4 kernel
3326 kill -CONT `pidof kupdated`
3331 # setup the trap first, so someone cannot exit the test at the
3332 # exact wrong time and mess up a machine
3333 trap start_writeback EXIT
3334 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3335 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3336 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3337 sysctl -w vm.dirty_writeback_centisecs=0
3338 sysctl -w vm.dirty_writeback_centisecs=0
3339 # save and increase /proc/sys/vm/dirty_ratio
3340 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3341 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3342 # save and increase /proc/sys/vm/dirty_background_ratio
3343 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3344 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3346 # if file not here, we are a 2.4 kernel
3347 kill -STOP `pidof kupdated`
3351 # ensure that all stripes have some grant before we test client-side cache
3353 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3354 dd if=/dev/zero of=$i bs=4k count=1
3359 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3360 # file truncation, and file removal.
3362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3364 cancel_lru_locks osc
3366 sync; sleep 1; sync # just to be safe
3367 BEFOREWRITES=`count_ost_writes`
3368 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3369 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3370 AFTERWRITES=`count_ost_writes`
3371 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3372 error "$BEFOREWRITES < $AFTERWRITES"
3375 run_test 42a "ensure that we don't flush on close =============="
3378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3380 cancel_lru_locks osc
3383 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3384 BEFOREWRITES=$(count_ost_writes)
3385 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3386 AFTERWRITES=$(count_ost_writes)
3387 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3388 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3390 BEFOREWRITES=$(count_ost_writes)
3391 sync || error "sync: $?"
3392 AFTERWRITES=$(count_ost_writes)
3393 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3394 error "$BEFOREWRITES < $AFTERWRITES on sync"
3396 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3400 run_test 42b "test destroy of file with cached dirty data ======"
3402 # if these tests just want to test the effect of truncation,
3403 # they have to be very careful. consider:
3404 # - the first open gets a {0,EOF}PR lock
3405 # - the first write conflicts and gets a {0, count-1}PW
3406 # - the rest of the writes are under {count,EOF}PW
3407 # - the open for truncate tries to match a {0,EOF}PR
3408 # for the filesize and cancels the PWs.
3409 # any number of fixes (don't get {0,EOF} on open, match
3410 # composite locks, do smarter file size management) fix
3411 # this, but for now we want these tests to verify that
3412 # the cancellation with truncate intent works, so we
3413 # start the file with a full-file pw lock to match against
3414 # until the truncate.
3419 cancel_lru_locks osc
3421 # prime the file with 0,EOF PW to match
3425 # now the real test..
3426 dd if=/dev/zero of=$file bs=1024 count=100
3427 BEFOREWRITES=`count_ost_writes`
3428 $TRUNCATE $file $offset
3429 cancel_lru_locks osc
3430 AFTERWRITES=`count_ost_writes`
3435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3437 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3438 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3441 run_test 42c "test partial truncate of file with cached dirty data"
3444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3446 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3447 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3450 run_test 42d "test complete truncate of file with cached dirty data"
3452 test_42e() { # bug22074
3453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3454 local TDIR=$DIR/${tdir}e
3455 local pagesz=$(page_size)
3456 local pages=16 # hardcoded 16 pages, don't change it.
3457 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3458 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3462 test_mkdir -p $DIR/${tdir}e
3463 $SETSTRIPE -c 1 $TDIR
3464 createmany -o $TDIR/f $files
3466 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3468 # we assume that with $OSTCOUNT files, at least one of them will
3469 # be allocated on OST0.
3470 warmup_files=$((OSTCOUNT * max_dirty_mb))
3471 createmany -o $TDIR/w $warmup_files
3473 # write a large amount of data into one file and sync, to get good
3474 # avail_grant number from OST.
3475 for ((i=0; i<$warmup_files; i++)); do
3476 idx=$($GETSTRIPE -i $TDIR/w$i)
3477 [ $idx -ne 0 ] && continue
3478 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3481 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3483 $LCTL get_param $proc_osc0/cur_dirty_bytes
3484 $LCTL get_param $proc_osc0/cur_grant_bytes
3486 # create as much dirty pages as we can while not to trigger the actual
3487 # RPCs directly. but depends on the env, VFS may trigger flush during this
3488 # period, hopefully we are good.
3489 for ((i=0; i<$warmup_files; i++)); do
3490 idx=$($GETSTRIPE -i $TDIR/w$i)
3491 [ $idx -ne 0 ] && continue
3492 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3494 $LCTL get_param $proc_osc0/cur_dirty_bytes
3495 $LCTL get_param $proc_osc0/cur_grant_bytes
3497 # perform the real test
3498 $LCTL set_param $proc_osc0/rpc_stats 0
3499 for ((;i<$files; i++)); do
3500 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3501 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3504 $LCTL get_param $proc_osc0/rpc_stats
3507 local have_ppr=false
3508 $LCTL get_param $proc_osc0/rpc_stats |
3509 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3510 # skip lines until we are at the RPC histogram data
3511 [ "$PPR" == "pages" ] && have_ppr=true && continue
3512 $have_ppr || continue
3514 # we only want the percent stat for < 16 pages
3515 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3517 percent=$((percent + WPCT))
3518 if [[ $percent -gt 15 ]]; then
3519 error "less than 16-pages write RPCs" \
3526 run_test 42e "verify sub-RPC writes are not done synchronously"
3529 test_mkdir -p $DIR/$tdir
3530 cp -p /bin/ls $DIR/$tdir/$tfile
3531 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3533 # give multiop a chance to open
3536 $DIR/$tdir/$tfile && error || true
3539 run_test 43 "execution of file opened for write should return -ETXTBSY"
3542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3543 test_mkdir -p $DIR/$tdir
3544 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3545 cp -p multiop $DIR/$tdir/multiop
3546 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3549 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3550 kill -USR1 $MULTIOP_PID || return 2
3551 wait $MULTIOP_PID || return 3
3552 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3554 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3557 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3558 test_mkdir -p $DIR/$tdir
3559 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3560 cp -p multiop $DIR/$tdir/multiop
3561 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3564 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3565 kill -USR1 $MULTIOP_PID || return 2
3566 wait $MULTIOP_PID || return 3
3567 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3569 run_test 43b "truncate of file being executed should return -ETXTBSY"
3572 local testdir="$DIR/$tdir"
3573 test_mkdir -p $DIR/$tdir
3575 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3576 ( cd $testdir && md5sum -c)
3578 run_test 43c "md5sum of copy into lustre========================"
3581 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3582 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3583 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3585 run_test 44 "zero length read from a sparse stripe ============="
3588 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3590 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3591 [[ $nstripe -gt $OSTCOUNT ]] &&
3592 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3594 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3596 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3597 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3601 OFFSETS="0 $((stride/2)) $((stride-1))"
3602 for offset in $OFFSETS; do
3603 for i in $(seq 0 $((nstripe-1))); do
3604 local GLOBALOFFSETS=""
3606 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3607 local myfn=$DIR/d44a-$size
3608 echo "--------writing $myfn at $size"
3609 ll_sparseness_write $myfn $size ||
3610 error "ll_sparseness_write"
3611 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3612 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3613 error "ll_sparseness_verify $GLOBALOFFSETS"
3615 for j in $(seq 0 $((nstripe-1))); do
3617 size=$((((j + $nstripe )*$stride + $offset)))
3618 ll_sparseness_write $myfn $size ||
3619 error "ll_sparseness_write"
3620 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3622 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3623 error "ll_sparseness_verify $GLOBALOFFSETS"
3628 run_test 44a "test sparse pwrite ==============================="
3632 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3638 before=`dirty_osc_total`
3639 echo executing "\"$*\""
3641 after=`dirty_osc_total`
3642 echo before $before, after $after
3645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3647 # Obtain grants from OST if it supports it
3648 echo blah > ${f}_grant
3651 do_dirty_record "echo blah > $f"
3652 [[ $before -eq $after ]] && error "write wasn't cached"
3653 do_dirty_record "> $f"
3654 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3655 do_dirty_record "echo blah > $f"
3656 [[ $before -eq $after ]] && error "write wasn't cached"
3657 do_dirty_record "sync"
3658 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3659 do_dirty_record "echo blah > $f"
3660 [[ $before -eq $after ]] && error "write wasn't cached"
3661 do_dirty_record "cancel_lru_locks osc"
3662 [[ $before -gt $after ]] ||
3663 error "lock cancellation didn't lower dirty count"
3666 run_test 45 "osc io page accounting ============================"
3668 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3669 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3670 # objects offset and an assert hit when an rpc was built with 1023's mapped
3671 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3673 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3677 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3679 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3680 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3684 run_test 46 "dirtying a previously written page ================"
3686 # test_47 is removed "Device nodes check" is moved to test_28
3688 test_48a() { # bug 2399
3689 check_kernel_version 34 || return 0
3690 test_mkdir -p $DIR/$tdir
3692 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3693 test_mkdir $DIR/$tdir || error "recreate directory failed"
3694 touch foo || error "'touch foo' failed after recreating cwd"
3695 test_mkdir $DIR/$tdir/bar ||
3696 error "'mkdir foo' failed after recreating cwd"
3697 if check_kernel_version 44; then
3698 touch .foo || error "'touch .foo' failed after recreating cwd"
3699 test_mkdir $DIR/$tdir/.bar ||
3700 error "'mkdir .foo' failed after recreating cwd"
3702 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3703 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3704 cd . || error "'cd .' failed after recreating cwd"
3705 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3706 rmdir . && error "'rmdir .' worked after recreating cwd"
3707 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3708 cd .. || error "'cd ..' failed after recreating cwd"
3710 run_test 48a "Access renamed working dir (should return errors)="
3712 test_48b() { # bug 2399
3713 check_kernel_version 34 || return 0
3715 test_mkdir -p $DIR/$tdir
3717 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3718 touch foo && error "'touch foo' worked after removing cwd"
3719 test_mkdir $DIR/$tdir/foo &&
3720 error "'mkdir foo' worked after removing cwd"
3721 if check_kernel_version 44; then
3722 touch .foo && error "'touch .foo' worked after removing cwd"
3723 test_mkdir $DIR/$tdir/.foo &&
3724 error "'mkdir .foo' worked after removing cwd"
3726 ls . > /dev/null && error "'ls .' worked after removing cwd"
3727 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3728 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3729 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3730 rmdir . && error "'rmdir .' worked after removing cwd"
3731 ln -s . foo && error "'ln -s .' worked after removing cwd"
3732 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3734 run_test 48b "Access removed working dir (should return errors)="
3736 test_48c() { # bug 2350
3737 check_kernel_version 36 || return 0
3738 #lctl set_param debug=-1
3741 test_mkdir -p $DIR/$tdir/dir
3743 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3744 $TRACE touch foo && error "touch foo worked after removing cwd"
3745 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3746 if check_kernel_version 44; then
3747 touch .foo && error "touch .foo worked after removing cwd"
3748 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3750 $TRACE ls . && error "'ls .' worked after removing cwd"
3751 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3752 is_patchless || ( $TRACE cd . &&
3753 error "'cd .' worked after removing cwd" )
3754 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3755 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3756 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3757 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3759 run_test 48c "Access removed working subdir (should return errors)"
3761 test_48d() { # bug 2350
3762 check_kernel_version 36 || return 0
3763 #lctl set_param debug=-1
3766 test_mkdir -p $DIR/$tdir/dir
3768 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3769 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3770 $TRACE touch foo && error "'touch foo' worked after removing parent"
3771 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3772 if check_kernel_version 44; then
3773 touch .foo && error "'touch .foo' worked after removing parent"
3775 error "mkdir .foo worked after removing parent"
3777 $TRACE ls . && error "'ls .' worked after removing parent"
3778 $TRACE ls .. && error "'ls ..' worked after removing parent"
3779 is_patchless || ( $TRACE cd . &&
3780 error "'cd .' worked after recreate parent" )
3781 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3782 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3783 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3784 is_patchless || ( $TRACE cd .. &&
3785 error "'cd ..' worked after removing parent" || true )
3787 run_test 48d "Access removed parent subdir (should return errors)"
3789 test_48e() { # bug 4134
3790 check_kernel_version 41 || return 0
3791 #lctl set_param debug=-1
3794 test_mkdir -p $DIR/$tdir/dir
3796 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3797 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3798 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3799 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3800 # On a buggy kernel addition of "touch foo" after cd .. will
3801 # produce kernel oops in lookup_hash_it
3802 touch ../foo && error "'cd ..' worked after recreate parent"
3804 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3806 run_test 48e "Access to recreated parent subdir (should return errors)"
3808 test_49() { # LU-1030
3809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3810 # get ost1 size - lustre-OST0000
3811 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3813 # write 800M at maximum
3814 [[ $ost1_size -lt 2 ]] && ost1_size=2
3815 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3817 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3818 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3821 # change max_pages_per_rpc while writing the file
3822 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3823 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3824 # loop until dd process exits
3825 while ps ax -opid | grep -wq $dd_pid; do
3826 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3827 sleep $((RANDOM % 5 + 1))
3829 # restore original max_pages_per_rpc
3830 $LCTL set_param $osc1_mppc=$orig_mppc
3831 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3833 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3837 test_mkdir $DIR/$tdir
3839 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3841 run_test 50 "special situations: /proc symlinks ==============="
3843 test_51a() { # was test_51
3844 # bug 1516 - create an empty entry right after ".." then split dir
3845 test_mkdir -c1 $DIR/$tdir
3846 touch $DIR/$tdir/foo
3847 $MCREATE $DIR/$tdir/bar
3849 createmany -m $DIR/$tdir/longfile 201
3851 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3852 $MCREATE $DIR/$tdir/longfile$FNUM
3857 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3859 run_test 51a "special situations: split htree with empty entry =="
3861 export NUMTEST=70000
3863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3864 local BASE=$DIR/d${base}.${TESTSUITE}
3866 # cleanup the directory
3869 test_mkdir -p -c1 $BASE
3871 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3872 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3873 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3876 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3877 echo "reduced count to $NUMTEST due to inodes"
3879 # need to check free space for the directories as well
3880 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3881 numfree=$((blkfree / 4))
3882 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3883 echo "reduced count to $NUMTEST due to blocks"
3885 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3886 echo "failed" > $BASE/fnum
3888 run_test 51b "exceed 64k subdirectory nlink limit"
3890 test_51ba() { # LU-993
3891 local BASE=$DIR/d${base}.${TESTSUITE}
3892 # unlink all but 100 subdirectories, then check it still works
3894 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3896 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3897 local DELETE=$((NUMTEST - LEFT))
3899 # continue on to run this test even if 51b didn't finish,
3900 # just to delete the many subdirectories created.
3901 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3903 # for ldiskfs the nlink count should be 1, but this is OSD specific
3904 # and so this is listed for informational purposes only
3905 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3906 unlinkmany -d $BASE/d $DELETE
3909 if [ $RC -ne 0 ]; then