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"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
63 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
64 # bug number for skipped test: LU-1593 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 48a 180 184c"
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
73 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
74 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
83 check_kernel_version() {
85 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
87 patchless|patchless_client) return 0;;
88 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
90 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
94 check_swap_layouts_support()
96 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
97 { skip "Does not support layout lock."; return 0; }
101 if [ "$ONLY" == "cleanup" ]; then
106 check_and_setup_lustre
111 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
112 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
113 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
114 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
115 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
116 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
117 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
118 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
120 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
121 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
122 rm -rf $DIR/[Rdfs][0-9]*
124 # $RUNAS_ID may get set incorrectly somewhere else
125 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
127 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
131 if [ "${ONLY}" = "MOUNT" ] ; then
132 echo "Lustre is up, please go on"
136 echo "preparing for tests involving mounts"
137 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
139 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
140 echo # add a newline after mke2fs.
144 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
145 lctl set_param debug=-1 2> /dev/null || true
148 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
150 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
152 run_test 0a "touch; rm ====================="
155 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
156 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
158 run_test 0b "chmod 0755 $DIR ============================="
161 $LCTL get_param mdc.*.import | grep "state: FULL" ||
162 error "import not FULL"
163 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
166 run_test 0c "check import proc ============================="
169 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
170 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
171 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
172 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
175 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
177 run_test 1 "mkdir; remkdir; rmdir =============================="
180 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
181 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
182 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
184 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
186 run_test 2 "mkdir; touch; rmdir; check file ===================="
189 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
190 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
191 touch $DIR/$tdir/$tfile
192 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
194 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
196 run_test 3 "mkdir; touch; rmdir; check dir ====================="
198 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
202 test_mkdir $DIR/$tdir ||
203 error "Create remote directory failed"
205 touch $DIR/$tdir/$tfile ||
206 error "Create file under remote directory failed"
209 error "Expect error removing in-use dir $DIR/$tdir"
211 test -d $DIR/$tdir || error "Remote directory disappeared"
213 rm -rf $DIR/$tdir || error "remove remote dir error"
215 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
218 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
219 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
220 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
221 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
222 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
224 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
227 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
228 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile does not have perm 0666 or UID $UID"
231 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
233 error "$tfile should be 0666 and owned by UID $UID"
235 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
240 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
243 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
244 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
245 error "$tfile should be owned by UID $RUNAS_ID"
247 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
252 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by GID $UID"
255 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
256 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
257 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
259 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
262 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
263 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
264 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
265 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
266 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
267 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
268 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
269 error "$tdir/d/subdir should be GID $RUNAS_GID"
271 run_test 6g "Is new dir in sgid dir inheriting group?"
273 test_6h() { # bug 7331
274 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
275 touch $DIR/$tfile || error "touch failed"
276 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
277 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
278 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
279 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
280 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
282 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
285 test_mkdir $DIR/$tdir
286 $MCREATE $DIR/$tdir/$tfile
287 chmod 0666 $DIR/$tdir/$tfile
288 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
289 error "$tdir/$tfile should be mode 0666"
291 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
294 if [ ! -d $DIR/$tdir ]; then
297 $MCREATE $DIR/$tdir/$tfile
298 echo -n foo > $DIR/$tdir/$tfile
299 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
300 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
302 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
305 test_mkdir $DIR/$tdir
306 touch $DIR/$tdir/$tfile
307 chmod 0666 $DIR/$tdir/$tfile
308 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
309 error "$tfile mode not 0666"
311 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
314 test_mkdir $DIR/$tdir
315 test_mkdir $DIR/$tdir/d2
316 test_mkdir $DIR/$tdir/d2/d3
317 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
319 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
322 test_mkdir $DIR/$tdir
323 test_mkdir $DIR/$tdir/d2
324 touch $DIR/$tdir/d2/$tfile
325 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
326 error "$tdir/d2/$tfile not a file"
328 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 chmod 0666 $DIR/$tdir/d2
334 chmod 0705 $DIR/$tdir/d2
335 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
336 error "$tdir/d2 mode not 0705"
338 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
341 test_mkdir $DIR/$tdir
342 touch $DIR/$tdir/$tfile
343 chmod 0666 $DIR/$tdir/$tfile
344 chmod 0654 $DIR/$tdir/$tfile
345 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
346 error "$tdir/d2 mode not 0654"
348 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
351 test_mkdir $DIR/$tdir
352 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
354 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
355 error "$tdir/$tfile size not 0 after truncate"
357 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
360 test_mkdir $DIR/$tdir
361 touch $DIR/$tdir/$tfile
363 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
365 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
368 test_mkdir $DIR/$tdir
369 touch $DIR/$tdir/$tfile
370 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
371 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
372 error "$tdir/${tfile_2} not a file after rename"
374 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
379 rm -rf $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
382 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
385 test_mkdir -p $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
389 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not a symlink"
391 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
392 error "$tdir/l-exist not referencing a file"
393 rm -f $DIR/$tdir/l-exist
394 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
396 run_test 17a "symlinks: create, remove (real) =================="
399 test_mkdir -p $DIR/$tdir
400 ln -s no-such-file $DIR/$tdir/l-dangle
402 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing no-such-file"
404 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
405 error "$tdir/l-dangle not referencing non-existent file"
406 rm -f $DIR/$tdir/l-dangle
407 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
409 run_test 17b "symlinks: create, remove (dangling) =============="
411 test_17c() { # bug 3440 - don't save failed open RPC for replay
412 test_mkdir -p $DIR/$tdir
413 ln -s foo $DIR/$tdir/$tfile
414 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
416 run_test 17c "symlinks: open dangling (should return error) ===="
419 test_mkdir -p $DIR/$tdir
420 ln -s foo $DIR/$tdir/$tfile
421 touch $DIR/$tdir/$tfile || error "creating to new symlink"
423 run_test 17d "symlinks: create dangling ========================"
426 test_mkdir -p $DIR/$tdir
427 local foo=$DIR/$tdir/$tfile
428 ln -s $foo $foo || error "create symlink failed"
429 ls -l $foo || error "ls -l failed"
430 ls $foo && error "ls not failed" || true
432 run_test 17e "symlinks: create recursive symlink (should return error) ===="
435 test_mkdir -p $DIR/$tdir
436 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
444 run_test 17f "symlinks: long and very long symlink name ========================"
446 # str_repeat(S, N) generate a string that is string S repeated N times
451 while [ $((n -= 1)) -ge 0 ]; do
457 # Long symlinks and LU-2241
459 test_mkdir -p $DIR/$tdir
460 local TESTS="59 60 61 4094 4095"
462 # Fix for inode size boundary in 2.1.4
463 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
466 # Patch not applied to 2.2 or 2.3 branches
467 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
468 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
471 # skip long symlink name for rhel6.5.
472 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
473 grep -q '6.5' /etc/redhat-release &>/dev/null &&
474 TESTS="59 60 61 4062 4063"
477 local SYMNAME=$(str_repeat 'x' $i)
478 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
479 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
482 run_test 17g "symlinks: really long symlink name and inode boundaries"
484 test_17h() { #bug 17378
485 remote_mds_nodsh && skip "remote MDS with nodsh" && return
486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
488 test_mkdir -p $DIR/$tdir
489 if [[ $MDSCOUNT -gt 1 ]]; then
490 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
494 $SETSTRIPE -c -1 $DIR/$tdir
495 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
496 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
497 touch $DIR/$tdir/$tfile || true
499 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
501 test_17i() { #bug 20018
502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
504 test_mkdir -c1 $DIR/$tdir
505 local foo=$DIR/$tdir/$tfile
507 if [[ $MDSCOUNT -gt 1 ]]; then
508 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
512 ln -s $foo $foo || error "create symlink failed"
513 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
514 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
515 ls -l $foo && error "error not detected"
518 run_test 17i "don't panic on short symlink"
520 test_17k() { #bug 22301
521 [[ -z "$(which rsync 2>/dev/null)" ]] &&
522 skip "no rsync command" && return 0
523 rsync --help | grep -q xattr ||
524 skip_env "$(rsync --version | head -n1) does not support xattrs"
525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
526 test_mkdir -p $DIR/$tdir
527 test_mkdir -p $DIR/$tdir.new
528 touch $DIR/$tdir/$tfile
529 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
530 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
531 error "rsync failed with xattrs enabled"
533 run_test 17k "symlinks: rsync with xattrs enabled ========================="
535 test_17l() { # LU-279
536 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
537 skip "no getfattr command" && return 0
539 touch $DIR/$tdir/$tfile
540 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
541 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
542 # -h to not follow symlinks. -m '' to list all the xattrs.
543 # grep to remove first line: '# file: $path'.
544 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
546 lgetxattr_size_check $path $xattr ||
547 error "lgetxattr_size_check $path $xattr failed"
551 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
555 local short_sym="0123456789"
556 local WDIR=$DIR/${tdir}m
563 remote_mds_nodsh && skip "remote MDS with nodsh" && return
564 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
565 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
566 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
568 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
569 skip "only for ldiskfs MDT" && return 0
571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
575 # create a long symlink file
576 for ((i = 0; i < 4; ++i)); do
577 long_sym=${long_sym}${long_sym}
580 echo "create 512 short and long symlink files under $WDIR"
581 for ((i = 0; i < 256; ++i)); do
582 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
583 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
589 wait_delete_completed
591 echo "recreate the 512 symlink files with a shorter string"
592 for ((i = 0; i < 512; ++i)); do
593 # rewrite the symlink file with a shorter string
594 ln -sf ${long_sym} $WDIR/long-$i
595 ln -sf ${short_sym} $WDIR/short-$i
598 mds_index=$($LFS getstripe -M $WDIR)
599 mds_index=$((mds_index+1))
600 devname=$(mdsdevname $mds_index)
601 cmd="$E2FSCK -fnvd $devname"
603 echo "stop and checking mds${mds_index}: $cmd"
604 # e2fsck should not return error
606 do_facet mds${mds_index} $cmd || rc=$?
608 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
609 df $MOUNT > /dev/null 2>&1
610 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
611 "short/long symlink MDT: rc=$rc"
614 run_test 17m "run e2fsck against MDT which contains short/long symlink"
616 check_fs_consistency_17n() {
622 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
623 # so it only check MDT1/MDT2 instead of all of MDTs.
624 for mdt_index in $(seq 1 2); do
625 devname=$(mdsdevname $mdt_index)
626 cmd="$E2FSCK -fnvd $devname"
628 echo "stop and checking mds${mdt_index}: $cmd"
629 # e2fsck should not return error
631 do_facet mds${mdt_index} $cmd || rc=$?
633 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
634 error "mount mds${mdt_index} failed"
635 df $MOUNT > /dev/null 2>&1
636 [ $rc -ne 0 ] && break
644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
645 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
646 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
647 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
649 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
650 skip "only for ldiskfs MDT" && return 0
652 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
657 for ((i=0; i<10; i++)); do
658 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
659 error "create remote dir error $i"
660 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
661 error "create files under remote dir failed $i"
664 check_fs_consistency_17n ||
665 error "e2fsck report error after create files under remote dir"
667 for ((i=0;i<10;i++)); do
668 rm -rf $DIR/$tdir/remote_dir_${i} ||
669 error "destroy remote dir error $i"
672 check_fs_consistency_17n ||
673 error "e2fsck report error after unlink files under remote dir"
675 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
676 skip "lustre < 2.4.50 does not support migrate mv " && return
678 for ((i=0; i<10; i++)); do
679 mkdir -p $DIR/$tdir/remote_dir_${i}
680 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
681 error "create files under remote dir failed $i"
682 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
683 error "migrate remote dir error $i"
685 check_fs_consistency_17n || error "e2fsck report error after migration"
687 for ((i=0;i<10;i++)); do
688 rm -rf $DIR/$tdir/remote_dir_${i} ||
689 error "destroy remote dir error $i"
692 check_fs_consistency_17n || error "e2fsck report error after unlink"
694 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
697 remote_mds_nodsh && skip "remote MDS with nodsh" && return
698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
699 skip "Need MDS version at least 2.3.64" && return
701 local WDIR=$DIR/${tdir}o
707 mdt_index=$($LFS getstripe -M $WDIR)
708 mdt_index=$((mdt_index+1))
709 mdtdevname=$(mdsdevname $mdt_index)
713 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
714 error "mount mds${mdt_index} failed"
716 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
717 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
718 ls -l $WDIR/$tfile && rc=1
719 do_facet mds${mdt_index} lctl set_param fail_loc=0
720 [[ $rc -ne 0 ]] && error "stat file should fail"
723 run_test 17o "stat file with incompat LMA feature"
726 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
727 ls $DIR || error "Failed to ls $DIR: $?"
729 run_test 18 "touch .../f ; ls ... =============================="
735 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
737 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
740 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
742 run_test 19b "ls -l .../f19 (should return error) =============="
745 [ $RUNAS_ID -eq $UID ] &&
746 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
747 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
749 run_test 19c "$RUNAS touch .../f19 (should return error) =="
752 cat $DIR/f19 && error || true
754 run_test 19d "cat .../f19 (should return error) =============="
766 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
768 run_test 20 "touch .../f ; ls -l ... ==========================="
771 test_mkdir -p $DIR/$tdir
772 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
773 ln -s dangle $DIR/$tdir/link
774 echo foo >> $DIR/$tdir/link
775 cat $DIR/$tdir/dangle
776 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
777 $CHECKSTAT -f -t file $DIR/$tdir/link ||
778 error "$tdir/link not linked to a file"
780 run_test 21 "write to dangling link ============================"
784 test_mkdir -p $DIR/$tdir
785 chown $RUNAS_ID:$RUNAS_GID $WDIR
786 (cd $WDIR || error "cd $WDIR failed";
787 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
789 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
790 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
791 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
793 run_test 22 "unpack tar archive as non-root user ==============="
797 test_mkdir -p $DIR/$tdir
798 local file=$DIR/$tdir/$tfile
800 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
801 openfile -f O_CREAT:O_EXCL $file &&
802 error "$file recreate succeeded" || true
804 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
806 test_23b() { # bug 18988
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
811 echo foo > $file || error "write filed"
812 echo bar >> $file || error "append filed"
813 $CHECKSTAT -s 8 $file || error "wrong size"
816 run_test 23b "O_APPEND check =========================="
820 echo '-- same directory rename'
821 test_mkdir $DIR/$tdir
822 touch $DIR/$tdir/$tfile.1
823 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
824 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
826 run_test 24a "rename file to non-existent target"
829 test_mkdir $DIR/$tdir
830 touch $DIR/$tdir/$tfile.{1,2}
831 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
832 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
833 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
835 run_test 24b "rename file to existing target"
838 test_mkdir $DIR/$tdir
839 test_mkdir $DIR/$tdir/d$testnum.1
840 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
841 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
842 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
844 run_test 24c "rename directory to non-existent target"
847 test_mkdir -c1 $DIR/$tdir
848 test_mkdir -c1 $DIR/$tdir/d$testnum.1
849 test_mkdir -c1 $DIR/$tdir/d$testnum.2
850 mrename $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 24d "rename directory to existing target"
857 echo '-- cross directory renames --'
861 mv $DIR/R5a/f $DIR/R5b/g
862 $CHECKSTAT -a $DIR/R5a/f || error
863 $CHECKSTAT -t file $DIR/R5b/g || error
865 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
870 touch $DIR/R6a/f $DIR/R6b/g
871 mv $DIR/R6a/f $DIR/R6b/g
872 $CHECKSTAT -a $DIR/R6a/f || error
873 $CHECKSTAT -t file $DIR/R6b/g || error
875 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
880 test_mkdir $DIR/R7a/d
881 mv $DIR/R7a/d $DIR/R7b/e
882 $CHECKSTAT -a $DIR/R7a/d || error
883 $CHECKSTAT -t dir $DIR/R7b/e || error
885 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
888 test_mkdir -c1 $DIR/R8a
889 test_mkdir -c1 $DIR/R8b
890 test_mkdir -c1 $DIR/R8a/d
891 test_mkdir -c1 $DIR/R8b/e
892 mrename $DIR/R8a/d $DIR/R8b/e
893 $CHECKSTAT -a $DIR/R8a/d || error
894 $CHECKSTAT -t dir $DIR/R8b/e || error
896 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
899 echo "-- rename error cases"
903 mrename $DIR/R9/f $DIR/R9/a
904 $CHECKSTAT -t file $DIR/R9/f || error
905 $CHECKSTAT -t dir $DIR/R9/a || error
906 $CHECKSTAT -a $DIR/R9/a/f || error
908 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
912 mrename $DIR/R10/f $DIR/R10/g
913 $CHECKSTAT -t dir $DIR/R10 || error
914 $CHECKSTAT -a $DIR/R10/f || error
915 $CHECKSTAT -a $DIR/R10/g || error
917 run_test 24j "source does not exist ============================"
921 test_mkdir $DIR/R11a/d
923 mv $DIR/R11a/f $DIR/R11a/d
924 $CHECKSTAT -a $DIR/R11a/f || error
925 $CHECKSTAT -t file $DIR/R11a/d/f || error
927 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
929 # bug 2429 - rename foo foo foo creates invalid file
932 $MULTIOP $f OcNs || error
934 run_test 24l "Renaming a file to itself ========================"
938 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
939 # on ext3 this does not remove either the source or target files
940 # though the "expected" operation would be to remove the source
941 $CHECKSTAT -t file ${f} || error "${f} missing"
942 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
944 run_test 24m "Renaming a file to a hard link to itself ========="
948 # this stats the old file after it was renamed, so it should fail
952 $CHECKSTAT ${f}.rename
955 run_test 24n "Statting the old file after renaming (Posix rename 2)"
958 check_kernel_version 37 || return 0
959 test_mkdir -p $DIR/d24o
960 rename_many -s random -v -n 10 $DIR/d24o
962 run_test 24o "rename of files during htree split ==============="
967 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
968 mrename $DIR/R12a $DIR/R12b
969 $CHECKSTAT -a $DIR/R12a || error
970 $CHECKSTAT -t dir $DIR/R12b || error
971 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
972 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
974 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
976 cleanup_multiop_pause() {
982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
985 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
986 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
989 trap cleanup_multiop_pause EXIT
990 mrename $DIR/R13a $DIR/R13b
991 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
992 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
993 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
994 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
995 cleanup_multiop_pause
996 wait $MULTIPID || error "multiop close failed"
998 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1000 test_24r() { #bug 3789
1001 test_mkdir $DIR/R14a
1002 test_mkdir $DIR/R14a/b
1003 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1004 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1005 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1007 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1010 test_mkdir $DIR/R15a
1011 test_mkdir $DIR/R15a/b
1012 test_mkdir $DIR/R15a/b/c
1013 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1015 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1017 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1019 test_mkdir $DIR/R16a
1020 test_mkdir $DIR/R16a/b
1021 test_mkdir $DIR/R16a/b/c
1022 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1024 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1026 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1028 test_24u() { # bug12192
1029 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1030 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1032 run_test 24u "create stripe file"
1038 simple_cleanup_common() {
1041 wait_delete_completed
1044 max_pages_per_rpc() {
1045 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1049 local NRFILES=100000
1050 local FREE_INODES=$(mdt_free_inodes 0)
1051 [[ $FREE_INODES -lt $NRFILES ]] &&
1052 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1056 trap simple_cleanup_common EXIT
1058 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1059 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1062 createmany -m $DIR/$tdir/$tfile $NRFILES
1064 cancel_lru_locks mdc
1065 lctl set_param mdc.*.stats clear
1067 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1069 # LU-5 large readdir
1070 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1071 # 8 bytes for name(filename is mostly 5 in this test) +
1072 # 8 bytes for luda_type
1073 # take into account of overhead in lu_dirpage header and end mark in
1074 # each page, plus one in RPC_NUM calculation.
1076 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1077 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1078 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1079 awk '/^mds_readpage/ {print $2}')
1080 [[ $mds_readpage -gt $RPC_NUM ]] &&
1081 error "large readdir doesn't take effect"
1083 simple_cleanup_common
1085 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1087 test_24w() { # bug21506
1089 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1090 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1091 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1092 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1093 [[ "$SZ1" -eq "$SZ2" ]] ||
1094 error "Error reading at the end of the file $tfile"
1096 run_test 24w "Reading a file larger than 4Gb"
1099 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 mkdir -p $DIR/$tdir/src_dir
1109 touch $DIR/$tdir/src_file
1110 mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $remote_dir $DIR/ &&
1114 error "rename dir cross MDT works!"
1116 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1117 error "rename dir cross MDT works!"
1119 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1120 error "rename file cross MDT works!"
1122 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1123 error "ln file cross MDT should not work!"
1125 rm -rf $DIR/$tdir || error "Can not delete directories"
1127 run_test 24x "cross rename/link should be failed"
1130 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1133 local remote_dir=$DIR/$tdir/remote_dir
1136 $LFS mkdir -i $MDTIDX $remote_dir ||
1137 error "create remote directory failed"
1139 mkdir -p $remote_dir/src_dir
1140 touch $remote_dir/src_file
1141 mkdir -p $remote_dir/tgt_dir
1142 touch $remote_dir/tgt_file
1144 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1145 error "rename subdir in the same remote dir failed!"
1147 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1148 error "rename files in the same remote dir failed!"
1150 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1151 error "link files in the same remote dir failed!"
1153 rm -rf $DIR/$tdir || error "Can not delete directories"
1155 run_test 24y "rename/link on the same dir should succeed"
1158 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1161 local remote_src=$DIR/$tdir/remote_dir
1162 local remote_tgt=$DIR/$tdir/remote_tgt
1165 $LFS mkdir -i $MDTIDX $remote_src ||
1166 error "create remote directory failed"
1168 $LFS mkdir -i $MDTIDX $remote_tgt ||
1169 error "create remote directory failed"
1171 mrename $remote_src $remote_tgt &&
1172 error "rename remote dirs should not work!"
1174 # If target dir does not exists, it should succeed
1176 mrename $remote_src $remote_tgt ||
1177 error "rename remote dirs(tgt dir does not exists) failed!"
1179 rm -rf $DIR/$tdir || error "Can not delete directories"
1181 run_test 24z "rename one remote dir to another remote dir should fail"
1183 test_24A() { # LU-3182
1188 createmany -m $DIR/$tdir/$tfile $NFILES
1189 local t=$(ls $DIR/$tdir | wc -l)
1190 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1191 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1192 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1193 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1196 rm -rf $DIR/$tdir || error "Can not delete directories"
1198 run_test 24A "readdir() returns correct number of entries."
1200 test_24B() { # LU-4805
1201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1205 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1206 error "create striped dir failed"
1208 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1209 [ $count -eq 2 ] || error "Expected 2, got $count"
1211 touch $DIR/$tdir/striped_dir/a
1213 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1214 [ $count -eq 3 ] || error "Expected 3, got $count"
1216 touch $DIR/$tdir/striped_dir/.f
1218 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1219 [ $count -eq 4 ] || error "Expected 4, got $count"
1221 rm -rf $DIR/$tdir || error "Can not delete directories"
1223 run_test 24B "readdir for striped dir return correct number of entries"
1226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1232 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1233 error "create striped dir failed"
1235 cd $DIR/$tdir/d0/striped_dir
1237 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1238 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1239 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1241 [ "$d0_ino" = "$parent_ino" ] ||
1242 error ".. wrong, expect $d0_ino, get $parent_ino"
1244 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1245 error "mv striped dir failed"
1247 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1249 [ "$d1_ino" = "$parent_ino" ] ||
1250 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1252 run_test 24C "check .. in striped dir"
1255 echo '== symlink sanity ============================================='
1259 touch $DIR/s25/foo || error
1261 run_test 25a "create file in symlinked directory ==============="
1264 [ ! -d $DIR/d25 ] && test_25a
1265 $CHECKSTAT -t file $DIR/s25/foo || error
1267 run_test 25b "lookup file in symlinked directory ==============="
1271 test_mkdir $DIR/d26/d26-2
1272 ln -s d26/d26-2 $DIR/s26
1273 touch $DIR/s26/foo || error
1275 run_test 26a "multiple component symlink ======================="
1278 test_mkdir -p $DIR/d26b/d26-2
1279 ln -s d26b/d26-2/foo $DIR/s26-2
1280 touch $DIR/s26-2 || error
1282 run_test 26b "multiple component symlink at end of lookup ======"
1285 test_mkdir $DIR/d26.2
1286 touch $DIR/d26.2/foo
1287 ln -s d26.2 $DIR/s26.2-1
1288 ln -s s26.2-1 $DIR/s26.2-2
1289 ln -s s26.2-2 $DIR/s26.2-3
1290 chmod 0666 $DIR/s26.2-3/foo
1292 run_test 26c "chain of symlinks ================================"
1294 # recursive symlinks (bug 439)
1296 ln -s d26-3/foo $DIR/d26-3
1298 run_test 26d "create multiple component recursive symlink ======"
1301 [ ! -h $DIR/d26-3 ] && test_26d
1304 run_test 26e "unlink multiple component recursive symlink ======"
1306 # recursive symlinks (bug 7022)
1308 test_mkdir -p $DIR/$tdir
1309 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1310 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1311 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1312 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1313 cd $tfile || error "cd $tfile failed"
1314 ln -s .. dotdot || error "ln dotdot failed"
1315 ln -s dotdot/lndir lndir || error "ln lndir failed"
1316 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1317 output=`ls $tfile/$tfile/lndir/bar1`
1318 [ "$output" = bar1 ] && error "unexpected output"
1319 rm -r $tfile || error "rm $tfile failed"
1320 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1322 run_test 26f "rm -r of a directory which has recursive symlink ="
1325 echo '== stripe sanity =============================================='
1326 test_mkdir -p $DIR/d27 || error "mkdir failed"
1328 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1329 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1330 log "== test_27a: write to one stripe file ========================="
1331 cp /etc/hosts $DIR/d27/f0 || error
1333 run_test 27a "one stripe file =================================="
1336 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1337 test_mkdir -p $DIR/d27
1338 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1339 $GETSTRIPE -c $DIR/d27/f01
1340 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1341 error "two-stripe file doesn't have two stripes"
1343 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1345 run_test 27b "create and write to two stripe file"
1348 test_mkdir -p $DIR/d27
1349 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1350 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1351 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1353 run_test 27d "create file with default settings ================"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1358 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1359 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1361 run_test 27e "setstripe existing file (should return error) ======"
1364 test_mkdir $DIR/$tdir
1365 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1366 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1367 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1368 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1370 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1372 run_test 27f "setstripe with bad stripe size (should return error)"
1375 test_mkdir -p $DIR/d27
1376 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1377 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1378 error "$DIR/d27/fnone has object"
1380 run_test 27g "$GETSTRIPE with no objects"
1383 touch $DIR/d27/fsome || error "touch failed"
1384 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1386 run_test 27i "$GETSTRIPE with some objects"
1389 test_mkdir -p $DIR/d27
1390 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1392 run_test 27j "setstripe with bad stripe offset (should return error)"
1394 test_27k() { # bug 2844
1395 test_mkdir -p $DIR/d27
1397 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1398 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1399 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1400 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1401 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1402 dd if=/dev/zero of=$FILE bs=4k count=1
1403 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1404 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1406 run_test 27k "limit i_blksize for broken user apps ============="
1409 test_mkdir -p $DIR/d27
1410 mcreate $DIR/f27l || error "creating file"
1411 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1412 error "setstripe should have failed" || true
1414 run_test 27l "check setstripe permissions (should return error)"
1417 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1419 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1420 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1423 trap simple_cleanup_common EXIT
1424 test_mkdir -p $DIR/$tdir
1425 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1426 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1427 error "dd should fill OST0"
1429 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1431 [ $i -gt 256 ] && break
1434 touch $DIR/$tdir/f27m_$i
1435 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1436 error "OST0 was full but new created file still use it"
1438 touch $DIR/$tdir/f27m_$i
1439 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1440 error "OST0 was full but new created file still use it"
1441 simple_cleanup_common
1443 run_test 27m "create file while OST0 was full =================="
1446 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1450 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1451 # if the OST isn't full anymore.
1453 local OSTIDX=${1:-""}
1455 local list=$(comma_list $(osts_nodes))
1456 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1458 do_nodes $list lctl set_param fail_loc=0
1459 sync # initiate all OST_DESTROYs from MDS to OST
1463 exhaust_precreations() {
1466 local FAILIDX=${3:-$OSTIDX}
1468 test_mkdir -p $DIR/$tdir
1469 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1470 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1472 local OST=$(ostname_from_index $OSTIDX)
1473 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1474 sed -e 's/_UUID$//;s/^.*-//')
1477 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1478 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1479 osc.$mdtosc_proc1.prealloc_last_id)
1480 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1481 osc.$mdtosc_proc1.prealloc_next_id)
1483 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1484 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1486 test_mkdir -p $DIR/$tdir/${OST}
1487 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1488 #define OBD_FAIL_OST_ENOSPC 0x215
1489 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1490 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1491 echo "Creating to objid $last_id on ost $OST..."
1492 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1493 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1494 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1498 exhaust_all_precreations() {
1500 for (( i=0; i < OSTCOUNT; i++ )) ; do
1501 exhaust_precreations $i $1 -1
1506 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1508 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1509 remote_ost_nodsh && skip "remote OST with nodsh" && return
1512 rm -f $DIR/$tdir/$tfile
1513 exhaust_precreations 0 0x80000215
1514 $SETSTRIPE -c -1 $DIR/$tdir
1515 touch $DIR/$tdir/$tfile || error
1516 $GETSTRIPE $DIR/$tdir/$tfile
1519 run_test 27n "create file with some full OSTs =================="
1522 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 remote_ost_nodsh && skip "remote OST with nodsh" && return
1528 rm -f $DIR/$tdir/$tfile
1529 exhaust_all_precreations 0x215
1531 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1536 run_test 27o "create file with all full OSTs (should error) ===="
1539 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1542 remote_ost_nodsh && skip "remote OST with nodsh" && return
1545 rm -f $DIR/$tdir/$tfile
1546 test_mkdir -p $DIR/$tdir
1548 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1549 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1550 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1552 exhaust_precreations 0 0x80000215
1553 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1554 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1555 $GETSTRIPE $DIR/$tdir/$tfile
1559 run_test 27p "append to a truncated file with some full OSTs ==="
1562 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1564 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1565 remote_ost_nodsh && skip "remote OST with nodsh" && return
1568 rm -f $DIR/$tdir/$tfile
1570 test_mkdir -p $DIR/$tdir
1571 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1572 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1573 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1575 exhaust_all_precreations 0x215
1577 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1578 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1582 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1585 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1588 remote_ost_nodsh && skip "remote OST with nodsh" && return
1591 rm -f $DIR/$tdir/$tfile
1592 exhaust_precreations 0 0x80000215
1594 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1598 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1600 test_27s() { # bug 10725
1601 test_mkdir -p $DIR/$tdir
1602 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1603 local stripe_count=0
1604 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1605 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1606 error "stripe width >= 2^32 succeeded" || true
1609 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1611 test_27t() { # bug 10864
1616 $WLFS getstripe $tfile
1619 run_test 27t "check that utils parse path correctly"
1621 test_27u() { # bug 4900
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 local list=$(comma_list $(mdts_nodes))
1627 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1628 do_nodes $list $LCTL set_param fail_loc=0x139
1629 test_mkdir -p $DIR/$tdir
1631 createmany -o $DIR/$tdir/t- 1000
1632 do_nodes $list $LCTL set_param fail_loc=0
1634 TLOG=$DIR/$tfile.getstripe
1635 $GETSTRIPE $DIR/$tdir > $TLOG
1636 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1637 unlinkmany $DIR/$tdir/t- 1000
1638 [[ $OBJS -gt 0 ]] &&
1639 error "$OBJS objects created on OST-0. See $TLOG" || pass
1641 run_test 27u "skip object creation on OSC w/o objects =========="
1643 test_27v() { # bug 4900
1644 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1647 remote_ost_nodsh && skip "remote OST with nodsh" && return
1649 exhaust_all_precreations 0x215
1652 test_mkdir -p $DIR/$tdir
1653 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1655 touch $DIR/$tdir/$tfile
1656 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1658 for (( i=1; i < OSTCOUNT; i++ )); do
1659 do_facet ost$i lctl set_param fail_loc=0x705
1661 local START=`date +%s`
1662 createmany -o $DIR/$tdir/$tfile 32
1664 local FINISH=`date +%s`
1665 local TIMEOUT=`lctl get_param -n timeout`
1666 local PROCESS=$((FINISH - START))
1667 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1668 error "$FINISH - $START >= $TIMEOUT / 2"
1669 sleep $((TIMEOUT / 2 - PROCESS))
1672 run_test 27v "skip object creation on slow OST ================="
1674 test_27w() { # bug 10997
1675 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1676 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1677 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1678 error "stripe size $size != 65536" || true
1679 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1680 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1682 run_test 27w "check $SETSTRIPE -S option"
1685 [[ $OSTCOUNT -lt 2 ]] &&
1686 skip_env "skipping multiple stripe count/offset test" && return
1688 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1689 for i in $(seq 1 $OSTCOUNT); do
1691 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1692 error "setstripe -c $i -i $offset failed"
1693 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1694 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1695 [ $count -ne $i ] && error "stripe count $count != $i" || true
1696 [ $index -ne $offset ] &&
1697 error "stripe offset $index != $offset" || true
1700 run_test 27wa "check $SETSTRIPE -c -i options"
1703 remote_ost_nodsh && skip "remote OST with nodsh" && return
1704 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1706 OFFSET=$(($OSTCOUNT - 1))
1708 local OST=$(ostname_from_index $OSTIDX)
1710 test_mkdir -p $DIR/$tdir
1711 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1712 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1714 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1715 for i in `seq 0 $OFFSET`; do
1716 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1717 error "OST0 was degraded but new created file still use it"
1719 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1721 run_test 27x "create files while OST0 is degraded"
1724 [[ $OSTCOUNT -lt 2 ]] &&
1725 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1726 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1727 remote_ost_nodsh && skip "remote OST with nodsh" && return
1728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1730 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1731 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1732 osc.$mdtosc.prealloc_last_id)
1733 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1734 osc.$mdtosc.prealloc_next_id)
1735 local fcount=$((last_id - next_id))
1736 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1737 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1739 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1740 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1741 local OST_DEACTIVE_IDX=-1
1746 for OSC in $MDS_OSCS; do
1747 OST=$(osc_to_ost $OSC)
1748 OSTIDX=$(index_from_ostuuid $OST)
1749 if [ $OST_DEACTIVE_IDX == -1 ]; then
1750 OST_DEACTIVE_IDX=$OSTIDX
1752 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1753 echo $OSC "is Deactivated:"
1754 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1758 OSTIDX=$(index_from_ostuuid $OST)
1760 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1762 for OSC in $MDS_OSCS; do
1763 OST=$(osc_to_ost $OSC)
1764 OSTIDX=$(index_from_ostuuid $OST)
1765 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1766 echo $OST "is degraded:"
1767 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1768 obdfilter.$OST.degraded=1
1773 createmany -o $DIR/$tdir/$tfile $fcount
1775 for OSC in $MDS_OSCS; do
1776 OST=$(osc_to_ost $OSC)
1777 OSTIDX=$(index_from_ostuuid $OST)
1778 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1779 echo $OST "is recovered from degraded:"
1780 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1781 obdfilter.$OST.degraded=0
1783 do_facet $SINGLEMDS lctl --device %$OSC activate
1787 # all osp devices get activated, hence -1 stripe count restored
1790 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1791 # devices get activated.
1793 $SETSTRIPE -c -1 $DIR/$tfile
1794 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1796 [ $stripecnt -ne $OSTCOUNT ] &&
1797 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1800 run_test 27y "create files while OST0 is degraded and the rest inactive"
1806 lmm_count=$($GETSTRIPE -c $1)
1807 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1808 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1810 local old_ifs="$IFS"
1812 fid=($($LFS path2fid $1))
1815 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1816 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1818 # compare lmm_seq and lu_fid->f_seq
1819 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1820 # compare lmm_object_id and lu_fid->oid
1821 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1823 # check the trusted.fid attribute of the OST objects of the file
1824 local have_obdidx=false
1826 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1827 # skip lines up to and including "obdidx"
1828 [ -z "$obdidx" ] && break
1829 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1830 $have_obdidx || continue
1832 local ost=$((obdidx + 1))
1833 local dev=$(ostdevname $ost)
1836 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1838 seq=$(echo $seq | sed -e "s/^0x//g")
1839 if [ $seq == 0 ]; then
1840 oid_hex=$(echo $oid)
1842 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1844 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1848 # Don't unmount/remount the OSTs if we don't need to do that.
1849 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1850 # update too, until that use mount/ll_decode_filter_fid/mount.
1851 # Re-enable when debugfs will understand new filter_fid.
1853 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1854 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1855 $dev 2>/dev/null" | grep "parent=")
1858 mount_fstype ost$ost
1859 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1860 $(facet_mntpt ost$ost)/$obj_file)
1861 unmount_fstype ost$ost
1862 start ost$ost $dev $OST_MOUNT_OPTS
1865 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1867 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1869 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1870 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1871 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1872 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1873 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1875 if echo $ff_parent | grep -q 'stripe='; then
1876 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1879 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1880 # into f_ver in this case. See the comment on
1883 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1887 # compare lmm_seq and filter_fid->ff_parent.f_seq
1888 [ $ff_pseq = $lmm_seq ] ||
1889 error "FF parent SEQ $ff_pseq != $lmm_seq"
1890 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1891 [ $ff_poid = $lmm_oid ] ||
1892 error "FF parent OID $ff_poid != $lmm_oid"
1893 (($ff_pstripe == $stripe_nr)) ||
1894 error "FF stripe $ff_pstripe != $stripe_nr"
1896 stripe_nr=$((stripe_nr + 1))
1901 remote_ost_nodsh && skip "remote OST with nodsh" && return
1902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1903 test_mkdir -p $DIR/$tdir
1905 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1906 { error "setstripe -c -1 failed"; return 1; }
1907 # We need to send a write to every object to get parent FID info set.
1908 # This _should_ also work for setattr, but does not currently.
1909 # touch $DIR/$tdir/$tfile-1 ||
1910 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1911 { error "dd $tfile-1 failed"; return 2; }
1912 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1913 { error "setstripe -c -1 failed"; return 3; }
1914 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1915 { error "dd $tfile-2 failed"; return 4; }
1917 # make sure write RPCs have been sent to OSTs
1920 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1921 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1923 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1925 test_27A() { # b=19102
1926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1927 local restore_size=$($GETSTRIPE -S $MOUNT)
1928 local restore_count=$($GETSTRIPE -c $MOUNT)
1929 local restore_offset=$($GETSTRIPE -i $MOUNT)
1930 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1931 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1932 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1933 local default_size=$($GETSTRIPE -S $MOUNT)
1934 local default_offset=$($GETSTRIPE -i $MOUNT)
1935 local dsize=$((1024 * 1024))
1936 [ $default_size -eq $dsize ] ||
1937 error "stripe size $default_size != $dsize"
1938 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1939 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1941 run_test 27A "check filesystem-wide default LOV EA values"
1943 test_27B() { # LU-2523
1944 test_mkdir -p $DIR/$tdir
1945 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1947 # open f1 with O_LOV_DELAY_CREATE
1949 # call setstripe ioctl on open file descriptor for f1
1951 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1961 # Allow multiop to fail in imitation of NFS's busted semantics.
1964 run_test 27B "call setstripe on open unlinked file/rename victim"
1966 test_27C() { #LU-2871
1967 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1975 test_mkdir -p $DIR/$tdir
1977 for i in $(seq 0 $((OSTCOUNT - 1))); do
1978 # set stripe across all OSTs starting from OST$i
1979 $SETSTRIPE -i $i -c -1 $tfile$i
1980 # get striping information
1981 ost_idx=($($GETSTRIPE $tfile$i |
1982 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1986 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1987 error "${#ost_idx[@]} != $OSTCOUNT"
1989 for index in $(seq 0 $((OSTCOUNT - 1))); do
1991 for j in $(echo ${ost_idx[@]}); do
1992 if [ $index -eq $j ]; then
1998 error "Can not find $index in ${ost_idx[@]}"
2002 run_test 27C "check full striping across all OSTs"
2005 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2006 local POOL=${POOL:-testpool}
2008 local last_ost=$(($OSTCOUNT - 1))
2010 local ost_list=$(seq $first_ost $ost_step $last_ost)
2011 local ost_range="$first_ost $last_ost $ost_step"
2014 pool_add $POOL || error "pool_add failed"
2015 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2016 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2017 error "llapi_layout_test failed"
2018 cleanup_pools || error "cleanup_pools failed"
2020 run_test 27D "validate llapi_layout API"
2022 # createtest also checks that device nodes are created and
2023 # then visible correctly (#2091)
2024 test_28() { # bug 2091
2026 $CREATETEST $DIR/d28/ct || error
2028 run_test 28 "create/mknod/mkdir with bad file types ============"
2031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2032 cancel_lru_locks mdc
2038 declare -i LOCKCOUNTORIG=0
2039 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2040 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2042 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2044 declare -i LOCKUNUSEDCOUNTORIG=0
2045 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2046 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2053 declare -i LOCKCOUNTCURRENT=0
2054 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2055 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2058 declare -i LOCKUNUSEDCOUNTCURRENT=0
2059 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2060 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2063 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2064 $LCTL set_param -n ldlm.dump_namespaces ""
2065 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2066 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2067 log "dumped log to $TMP/test_29.dk (bug 5793)"
2070 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2071 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2072 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2073 log "dumped log to $TMP/test_29.dk (bug 5793)"
2077 run_test 29 "IT_GETATTR regression ============================"
2079 test_30a() { # was test_30
2080 cp $(which ls) $DIR || cp /bin/ls $DIR
2084 run_test 30a "execute binary from Lustre (execve) =============="
2087 cp `which ls` $DIR || cp /bin/ls $DIR
2089 $RUNAS $DIR/ls / || error
2092 run_test 30b "execute binary from Lustre as non-root ==========="
2094 test_30c() { # b=22376
2095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2096 cp `which ls` $DIR || cp /bin/ls $DIR
2098 cancel_lru_locks mdc
2099 cancel_lru_locks osc
2100 $RUNAS $DIR/ls / || error
2103 run_test 30c "execute binary from Lustre without read perms ===="
2106 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2107 $CHECKSTAT -a $DIR/f31 || error
2109 run_test 31a "open-unlink file =================================="
2112 touch $DIR/f31 || error
2113 ln $DIR/f31 $DIR/f31b || error
2114 $MULTIOP $DIR/f31b Ouc || error
2115 $CHECKSTAT -t file $DIR/f31 || error
2117 run_test 31b "unlink file with multiple links while open ======="
2120 touch $DIR/f31 || error
2121 ln $DIR/f31 $DIR/f31c || error
2122 multiop_bg_pause $DIR/f31 O_uc || return 1
2124 $MULTIOP $DIR/f31c Ouc
2125 kill -USR1 $MULTIPID
2128 run_test 31c "open-unlink file with multiple links ============="
2131 opendirunlink $DIR/d31d $DIR/d31d || error
2132 $CHECKSTAT -a $DIR/d31d || error
2134 run_test 31d "remove of open directory ========================="
2136 test_31e() { # bug 2904
2137 check_kernel_version 34 || return 0
2138 openfilleddirunlink $DIR/d31e || error
2140 run_test 31e "remove of open non-empty directory ==============="
2142 test_31f() { # bug 4554
2143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2145 test_mkdir $DIR/d31f
2146 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2147 cp /etc/hosts $DIR/d31f
2149 $GETSTRIPE $DIR/d31f/hosts
2150 multiop_bg_pause $DIR/d31f D_c || return 1
2153 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2154 test_mkdir $DIR/d31f
2155 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2156 cp /etc/hosts $DIR/d31f
2158 $GETSTRIPE $DIR/d31f/hosts
2159 multiop_bg_pause $DIR/d31f D_c || return 1
2162 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2163 wait $MULTIPID || error "first opendir $MULTIPID failed"
2167 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2168 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2171 run_test 31f "remove of open directory with open-unlink file ==="
2174 echo "-- cross directory link --"
2175 test_mkdir -c1 $DIR/${tdir}ga
2176 test_mkdir -c1 $DIR/${tdir}gb
2177 touch $DIR/${tdir}ga/f
2178 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2179 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2180 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2181 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2182 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2184 run_test 31g "cross directory link==============="
2187 echo "-- cross directory link --"
2188 test_mkdir -c1 $DIR/${tdir}
2189 test_mkdir -c1 $DIR/${tdir}/dir
2190 touch $DIR/${tdir}/f
2191 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2192 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2193 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2194 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2195 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2197 run_test 31h "cross directory link under child==============="
2200 echo "-- cross directory link --"
2201 test_mkdir -c1 $DIR/$tdir
2202 test_mkdir -c1 $DIR/$tdir/dir
2203 touch $DIR/$tdir/dir/f
2204 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2205 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2206 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2207 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2208 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2210 run_test 31i "cross directory link under parent==============="
2213 test_mkdir -c1 -p $DIR/$tdir
2214 test_mkdir -c1 -p $DIR/$tdir/dir1
2215 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2216 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2217 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2218 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2221 run_test 31j "link for directory==============="
2224 test_mkdir -c1 -p $DIR/$tdir
2226 touch $DIR/$tdir/exist
2227 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2228 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2229 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2230 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2231 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2232 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2233 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2236 run_test 31k "link to file: the same, non-existing, dir==============="
2242 touch $DIR/d31m2/exist
2243 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2244 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2245 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2246 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2247 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2248 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2251 run_test 31m "link to file: the same, non-existing, dir==============="
2254 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2255 nlink=$(stat --format=%h $DIR/$tfile)
2256 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2258 local cmd="exec $fd<$DIR/$tfile"
2261 trap "eval $cmd" EXIT
2262 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2263 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2264 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2265 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2266 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2269 run_test 31n "check link count of unlinked file"
2272 local TEMPNAME=$(mktemp $1_XXXXXX)
2273 mlink $TEMPNAME $1 2> /dev/null &&
2274 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2278 test_31o() { # LU-2901
2280 for LOOP in $(seq 100); do
2281 rm -f $DIR/$tdir/$tfile*
2282 for THREAD in $(seq 8); do
2283 link_one $DIR/$tdir/$tfile.$LOOP &
2286 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2287 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2288 error "$LINKS duplicate links to $tfile.$LOOP" &&
2292 run_test 31o "duplicate hard links with same filename"
2295 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2298 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2299 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2301 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2302 error "open unlink test1 failed"
2303 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2304 error "open unlink test2 failed"
2306 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2307 error "test1 still exists"
2308 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2309 error "test2 still exists"
2311 run_test 31p "remove of open striped directory"
2313 cleanup_test32_mount() {
2315 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2320 echo "== more mountpoints and symlinks ================="
2321 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2322 trap cleanup_test32_mount EXIT
2323 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2324 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2325 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2326 cleanup_test32_mount
2328 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2332 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2333 trap cleanup_test32_mount EXIT
2334 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2335 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2336 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2337 cleanup_test32_mount
2339 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2343 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2344 trap cleanup_test32_mount EXIT
2345 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2346 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2347 test_mkdir -p $DIR/$tdir/d2/test_dir
2348 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2349 cleanup_test32_mount
2351 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2355 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2356 trap cleanup_test32_mount EXIT
2357 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2358 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2359 test_mkdir -p $DIR/$tdir/d2/test_dir
2360 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2361 cleanup_test32_mount
2363 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2366 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2367 test_mkdir -p $DIR/d32e/tmp
2368 TMP_DIR=$DIR/d32e/tmp
2369 ln -s $DIR/d32e $TMP_DIR/symlink11
2370 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2371 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2372 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2374 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2377 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2378 test_mkdir -p $DIR/d32f/tmp
2379 TMP_DIR=$DIR/d32f/tmp
2380 ln -s $DIR/d32f $TMP_DIR/symlink11
2381 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2382 ls $DIR/d32f/tmp/symlink11 || error
2383 ls $DIR/d32f/symlink01 || error
2385 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2388 TMP_DIR=$DIR/$tdir/tmp
2389 test_mkdir -p $DIR/$tdir/tmp
2390 test_mkdir $DIR/${tdir}2
2391 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2392 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2393 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2394 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2395 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2396 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2398 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2401 rm -fr $DIR/$tdir $DIR/${tdir}2
2402 TMP_DIR=$DIR/$tdir/tmp
2403 test_mkdir -p $DIR/$tdir/tmp
2404 test_mkdir $DIR/${tdir}2
2405 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2406 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2407 ls $TMP_DIR/symlink12 || error
2408 ls $DIR/$tdir/symlink02 || error
2410 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2414 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2415 trap cleanup_test32_mount EXIT
2416 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2417 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2418 touch $DIR/$tdir/test_file
2419 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2420 cleanup_test32_mount
2422 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2426 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2427 trap cleanup_test32_mount EXIT
2428 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2429 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2430 touch $DIR/$tdir/test_file
2431 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2432 cleanup_test32_mount
2434 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2439 trap cleanup_test32_mount EXIT
2440 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2441 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2442 test_mkdir -p $DIR/$tdir/d2
2443 touch $DIR/$tdir/d2/test_file || error
2444 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2445 cleanup_test32_mount
2447 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2452 trap cleanup_test32_mount EXIT
2453 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2454 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2455 test_mkdir -p $DIR/$tdir/d2
2456 touch $DIR/$tdir/d2/test_file
2457 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2458 cleanup_test32_mount
2460 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2464 test_mkdir -p $DIR/d32m/tmp
2465 TMP_DIR=$DIR/d32m/tmp
2466 ln -s $DIR $TMP_DIR/symlink11
2467 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2468 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2469 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2471 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2475 test_mkdir -p $DIR/d32n/tmp
2476 TMP_DIR=$DIR/d32n/tmp
2477 ln -s $DIR $TMP_DIR/symlink11
2478 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2479 ls -l $DIR/d32n/tmp/symlink11 || error
2480 ls -l $DIR/d32n/symlink01 || error
2482 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2486 test_mkdir -p $DIR/d32o/tmp
2487 TMP_DIR=$DIR/d32o/tmp
2488 ln -s $DIR/$tfile $TMP_DIR/symlink12
2489 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2490 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2491 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2492 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2493 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2495 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2505 test_mkdir -p $DIR/d32p/tmp
2507 TMP_DIR=$DIR/d32p/tmp
2509 ln -s $DIR/$tfile $TMP_DIR/symlink12
2511 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2513 cat $DIR/d32p/tmp/symlink12 || error
2515 cat $DIR/d32p/symlink02 || error
2518 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2520 cleanup_testdir_mount() {
2522 $UMOUNT -d $DIR/$tdir
2526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2527 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2528 trap cleanup_testdir_mount EXIT
2529 test_mkdir -p $DIR/$tdir
2530 touch $DIR/$tdir/under_the_mount
2531 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2532 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2533 cleanup_testdir_mount
2535 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2539 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2540 trap cleanup_testdir_mount EXIT
2541 test_mkdir -p $DIR/$tdir
2542 touch $DIR/$tdir/under_the_mount
2543 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2544 ls $DIR/$tdir | grep -q under_the_mount && error || true
2545 cleanup_testdir_mount
2547 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2552 chmod 444 $DIR/$tfile
2553 chown $RUNAS_ID $DIR/$tfile
2555 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2558 run_test 33aa "write file with mode 444 (should return error) ===="
2562 test_mkdir -p $DIR/d33
2563 chown $RUNAS_ID $DIR/d33
2564 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2565 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2566 error "open RDWR" || true
2568 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2572 test_mkdir -p $DIR/d33
2573 chown $RUNAS_ID $DIR/d33
2574 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2576 run_test 33b "test open file with malformed flags (No panic)"
2579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2585 remote_ost_nodsh && skip "remote OST with nodsh" && return
2588 test_mkdir -p $DIR/d33
2589 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2592 for ostnum in $(seq $OSTCOUNT); do
2593 # test-framework's OST numbering is one-based, while Lustre's
2595 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2596 # Parsing llobdstat's output sucks; we could grep the /proc
2597 # path, but that's likely to not be as portable as using the
2598 # llobdstat utility. So we parse lctl output instead.
2599 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2600 obdfilter/$ostname/stats |
2601 awk '/^write_bytes/ {print $7}' )
2602 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2603 if (( ${write_bytes:-0} > 0 ))
2610 $all_zeros || return 0
2613 echo foo > $DIR/d33/bar
2617 # Total up write_bytes after writing. We'd better find non-zeros.
2618 for ostnum in $(seq $OSTCOUNT); do
2619 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2620 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2621 obdfilter/$ostname/stats |
2622 awk '/^write_bytes/ {print $7}' )
2623 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2624 if (( ${write_bytes:-0} > 0 ))
2633 for ostnum in $(seq $OSTCOUNT); do
2634 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2635 echo "Check that write_bytes is present in obdfilter/*/stats:"
2636 do_facet ost$ostnum lctl get_param -n \
2637 obdfilter/$ostname/stats
2639 error "OST not keeping write_bytes stats (b22312)"
2642 run_test 33c "test llobdstat and write_bytes"
2645 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2648 local remote_dir=$DIR/$tdir/remote_dir
2651 $LFS mkdir -i $MDTIDX $remote_dir ||
2652 error "create remote directory failed"
2654 touch $remote_dir/$tfile
2655 chmod 444 $remote_dir/$tfile
2656 chown $RUNAS_ID $remote_dir/$tfile
2658 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2660 chown $RUNAS_ID $remote_dir
2661 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2662 error "create" || true
2663 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2664 error "open RDWR" || true
2665 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2666 error "create" || true
2668 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2671 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2675 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2676 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2677 mkdir $DIR/$tdir/local_dir
2679 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2680 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2681 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2683 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2684 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2686 rmdir $DIR/$tdir/* || error "rmdir failed"
2689 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2690 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2691 mkdir $DIR/$tdir/local_dir
2693 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2694 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2695 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2697 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2698 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2700 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2703 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2704 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2705 mkdir $DIR/$tdir/local_dir
2707 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2708 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2709 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2711 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2712 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2714 run_test 33e "mkdir and striped directory should have same mode"
2716 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2719 $MCREATE $DIR/f34 || error
2720 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2721 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2722 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2723 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2725 run_test 34a "truncate file that has not been opened ==========="
2728 [ ! -f $DIR/f34 ] && test_34a
2729 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2730 $OPENFILE -f O_RDONLY $DIR/f34
2731 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2732 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2734 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2737 [ ! -f $DIR/f34 ] && test_34a
2738 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2739 $OPENFILE -f O_RDWR $DIR/f34
2740 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2741 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2743 run_test 34c "O_RDWR opening file-with-size works =============="
2746 [ ! -f $DIR/f34 ] && test_34a
2747 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2748 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2751 run_test 34d "write to sparse file ============================="
2755 $MCREATE $DIR/f34e || error
2756 $TRUNCATE $DIR/f34e 1000 || error
2757 $CHECKSTAT -s 1000 $DIR/f34e || error
2758 $OPENFILE -f O_RDWR $DIR/f34e
2759 $CHECKSTAT -s 1000 $DIR/f34e || error
2761 run_test 34e "create objects, some with size and some without =="
2763 test_34f() { # bug 6242, 6243
2764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2767 $MCREATE $DIR/f34f || error
2768 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2769 dd if=$DIR/f34f of=$TMP/f34f
2770 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2771 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2772 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2773 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2774 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2776 run_test 34f "read from a file with no objects until EOF ======="
2779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2780 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2781 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2782 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2783 cancel_lru_locks osc
2784 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2785 error "wrong size after lock cancel"
2787 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2788 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2789 error "expanding truncate failed"
2790 cancel_lru_locks osc
2791 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2792 error "wrong expanded size after lock cancel"
2794 run_test 34g "truncate long file ==============================="
2797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2801 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2802 sync # Flush the cache so that multiop below does not block on cache
2803 # flush when getting the group lock
2804 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2807 # Since just timed wait is not good enough, let's do a sync write
2808 # that way we are sure enough time for a roundtrip + processing
2809 # passed + 2 seconds of extra margin.
2810 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2814 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2815 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2819 local nsz=`stat -c %s $DIR/$tfile`
2820 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2822 run_test 34h "ftruncate file under grouplock should not block"
2825 cp /bin/sh $DIR/f35a
2827 chown $RUNAS_ID $DIR/f35a
2828 $RUNAS $DIR/f35a && error || true
2831 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2835 utime $DIR/f36 || error
2837 run_test 36a "MDS utime check (mknod, utime) ==================="
2841 utime $DIR/f36 || error
2843 run_test 36b "OST utime check (open, utime) ===================="
2848 chown $RUNAS_ID $DIR/d36
2849 $RUNAS utime $DIR/d36/f36 || error
2851 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2854 [ ! -d $DIR/d36 ] && test_36c
2855 echo "" > $DIR/d36/f36
2856 $RUNAS utime $DIR/d36/f36 || error
2858 run_test 36d "non-root OST utime check (open, utime) ==========="
2861 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2862 test_mkdir -p $DIR/$tdir
2863 touch $DIR/$tdir/$tfile
2864 $RUNAS utime $DIR/$tdir/$tfile && \
2865 error "utime worked, expected failure" || true
2867 run_test 36e "utime on non-owned file (should return error) ===="
2871 local LANG_SAVE=$LANG
2872 local LC_LANG_SAVE=$LC_LANG
2873 export LANG=C LC_LANG=C # for date language
2875 DATESTR="Dec 20 2000"
2876 test_mkdir -p $DIR/$tdir
2877 lctl set_param fail_loc=$fl
2879 cp /etc/hosts $DIR/$tdir/$tfile
2880 sync & # write RPC generated with "current" inode timestamp, but delayed
2882 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2883 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2884 cancel_lru_locks osc
2885 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2887 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2888 echo "BEFORE: $LS_BEFORE" && \
2889 echo "AFTER : $LS_AFTER" && \
2890 echo "WANT : $DATESTR" && \
2891 error "$DIR/$tdir/$tfile timestamps changed" || true
2893 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2898 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2899 subr_36fh "0x80000214"
2901 run_test 36f "utime on file racing with OST BRW write =========="
2904 remote_ost_nodsh && skip "remote OST with nodsh" && return
2905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2910 test_mkdir -p $DIR/$tdir
2911 fmd_max_age=$(do_facet ost1 \
2912 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2915 fmd_before=$(do_facet ost1 \
2916 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2917 touch $DIR/$tdir/$tfile
2918 sleep $((fmd_max_age + 12))
2919 fmd_after=$(do_facet ost1 \
2920 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2922 echo "fmd_before: $fmd_before"
2923 echo "fmd_after: $fmd_after"
2924 [[ $fmd_after -gt $fmd_before ]] &&
2925 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2926 error "fmd didn't expire after ping" || true
2928 run_test 36g "filter mod data cache expiry ====================="
2931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2933 subr_36fh "0x80000227"
2935 run_test 36h "utime on file racing with OST BRW write =========="
2938 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2941 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2943 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2944 local new_mtime=$((mtime + 200))
2946 #change Modify time of striped dir
2947 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2948 error "change mtime failed"
2950 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2952 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2954 run_test 36i "change mtime on striped directory"
2956 # test_37 - duplicate with tests 32q 32r
2959 local file=$DIR/$tfile
2961 openfile -f O_DIRECTORY $file
2964 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2965 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2967 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2971 touch $DIR/${tfile}2
2972 # ls -l $DIR/$tfile $DIR/${tfile}2
2973 # ls -lu $DIR/$tfile $DIR/${tfile}2
2974 # ls -lc $DIR/$tfile $DIR/${tfile}2
2976 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2977 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2979 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2981 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2983 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2984 error "O_TRUNC didn't change timestamps"
2987 run_test 39 "mtime changed on create ==========================="
2990 test_mkdir -p -c1 $DIR/$tdir
2991 cp -p /etc/passwd $DIR/$tdir/fopen
2992 cp -p /etc/passwd $DIR/$tdir/flink
2993 cp -p /etc/passwd $DIR/$tdir/funlink
2994 cp -p /etc/passwd $DIR/$tdir/frename
2995 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2998 echo "aaaaaa" >> $DIR/$tdir/fopen
2999 echo "aaaaaa" >> $DIR/$tdir/flink
3000 echo "aaaaaa" >> $DIR/$tdir/funlink
3001 echo "aaaaaa" >> $DIR/$tdir/frename
3003 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3004 local link_new=`stat -c %Y $DIR/$tdir/flink`
3005 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3006 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3008 cat $DIR/$tdir/fopen > /dev/null
3009 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3010 rm -f $DIR/$tdir/funlink2
3011 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3013 for (( i=0; i < 2; i++ )) ; do
3014 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3015 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3016 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3017 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3019 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3020 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3021 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3022 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3024 cancel_lru_locks osc
3025 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3028 run_test 39b "mtime change on open, link, unlink, rename ======"
3030 # this should be set to past
3031 TEST_39_MTIME=`date -d "1 year ago" +%s`
3037 local mtime0=`stat -c %Y $DIR1/$tfile`
3039 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3040 local mtime1=`stat -c %Y $DIR1/$tfile`
3041 [ "$mtime1" = $TEST_39_MTIME ] || \
3042 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3045 echo hello >> $DIR1/$tfile
3047 local mtime2=`stat -c %Y $DIR1/$tfile`
3048 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3049 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3051 mv $DIR1/$tfile $DIR1/$tfile-1
3053 for (( i=0; i < 2; i++ )) ; do
3054 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3055 [ "$mtime2" = "$mtime3" ] || \
3056 error "mtime ($mtime2) changed (to $mtime3) on rename"
3058 cancel_lru_locks osc
3059 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3062 run_test 39c "mtime change on rename ==========================="
3066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3069 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3071 for (( i=0; i < 2; i++ )) ; do
3072 local mtime=`stat -c %Y $DIR1/$tfile`
3073 [ $mtime = $TEST_39_MTIME ] || \
3074 error "mtime($mtime) is not set to $TEST_39_MTIME"
3076 cancel_lru_locks osc
3077 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3080 run_test 39d "create, utime, stat =============================="
3084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3086 local mtime1=`stat -c %Y $DIR1/$tfile`
3088 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3090 for (( i=0; i < 2; i++ )) ; do
3091 local mtime2=`stat -c %Y $DIR1/$tfile`
3092 [ $mtime2 = $TEST_39_MTIME ] || \
3093 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3095 cancel_lru_locks osc
3096 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3099 run_test 39e "create, stat, utime, stat ========================"
3103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3105 mtime1=`stat -c %Y $DIR1/$tfile`
3108 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3110 for (( i=0; i < 2; i++ )) ; do
3111 local mtime2=`stat -c %Y $DIR1/$tfile`
3112 [ $mtime2 = $TEST_39_MTIME ] || \
3113 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3115 cancel_lru_locks osc
3116 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3119 run_test 39f "create, stat, sleep, utime, stat ================="
3123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3124 echo hello >> $DIR1/$tfile
3125 local mtime1=`stat -c %Y $DIR1/$tfile`
3128 chmod o+r $DIR1/$tfile
3130 for (( i=0; i < 2; i++ )) ; do
3131 local mtime2=`stat -c %Y $DIR1/$tfile`
3132 [ "$mtime1" = "$mtime2" ] || \
3133 error "lost mtime: $mtime2, should be $mtime1"
3135 cancel_lru_locks osc
3136 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3139 run_test 39g "write, chmod, stat ==============================="
3143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3148 echo hello >> $DIR1/$tfile
3149 local mtime1=`stat -c %Y $DIR1/$tfile`
3151 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3153 if [ "$d1" != "$d2" ]; then
3154 echo "write and touch not within one second"
3156 for (( i=0; i < 2; i++ )) ; do
3157 local mtime2=`stat -c %Y $DIR1/$tfile`
3158 [ "$mtime2" = $TEST_39_MTIME ] || \
3159 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3161 cancel_lru_locks osc
3162 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3166 run_test 39h "write, utime within one second, stat ============="
3169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3173 echo hello >> $DIR1/$tfile
3174 local mtime1=`stat -c %Y $DIR1/$tfile`
3176 mv $DIR1/$tfile $DIR1/$tfile-1
3178 for (( i=0; i < 2; i++ )) ; do
3179 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3181 [ "$mtime1" = "$mtime2" ] || \
3182 error "lost mtime: $mtime2, should be $mtime1"
3184 cancel_lru_locks osc
3185 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3188 run_test 39i "write, rename, stat =============================="
3191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3192 start_full_debug_logging
3196 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3197 lctl set_param fail_loc=0x80000412
3198 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3199 error "multiop failed"
3201 local mtime1=`stat -c %Y $DIR1/$tfile`
3203 mv $DIR1/$tfile $DIR1/$tfile-1
3205 kill -USR1 $multipid
3206 wait $multipid || error "multiop close failed"
3208 for (( i=0; i < 2; i++ )) ; do
3209 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3210 [ "$mtime1" = "$mtime2" ] ||
3211 error "mtime is lost on close: $mtime2, " \
3214 cancel_lru_locks osc
3215 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3217 lctl set_param fail_loc=0
3218 stop_full_debug_logging
3220 run_test 39j "write, rename, close, stat ======================="
3223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3227 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3229 local mtime1=`stat -c %Y $DIR1/$tfile`
3231 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3233 kill -USR1 $multipid
3234 wait $multipid || error "multiop close failed"
3236 for (( i=0; i < 2; i++ )) ; do
3237 local mtime2=`stat -c %Y $DIR1/$tfile`
3239 [ "$mtime2" = $TEST_39_MTIME ] || \
3240 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3246 run_test 39k "write, utime, close, stat ========================"
3248 # this should be set to future
3249 TEST_39_ATIME=`date -d "1 year" +%s`
3252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3253 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3254 local atime_diff=$(do_facet $SINGLEMDS \
3255 lctl get_param -n mdd.*MDT0000*.atime_diff)
3259 # test setting directory atime to future
3260 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3261 local atime=$(stat -c %X $DIR/$tdir)
3262 [ "$atime" = $TEST_39_ATIME ] || \
3263 error "atime is not set to future: $atime, $TEST_39_ATIME"
3265 # test setting directory atime from future to now
3266 local d1=$(date +%s)
3268 local d2=$(date +%s)
3270 cancel_lru_locks mdc
3271 atime=$(stat -c %X $DIR/$tdir)
3272 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3273 error "atime is not updated from future: $atime, $d1<atime<$d2"
3275 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3278 # test setting directory atime when now > dir atime + atime_diff
3282 cancel_lru_locks mdc
3283 atime=$(stat -c %X $DIR/$tdir)
3284 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3285 error "atime is not updated : $atime, should be $d2"
3287 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3290 # test not setting directory atime when now < dir atime + atime_diff
3292 cancel_lru_locks mdc
3293 atime=$(stat -c %X $DIR/$tdir)
3294 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3295 error "atime is updated to $atime, should remain $d1<atime<$d2"
3297 do_facet $SINGLEMDS \
3298 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3300 run_test 39l "directory atime update ==========================="
3303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3306 local far_past_mtime=$(date -d "May 29 1953" +%s)
3307 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3309 touch -m -d @$far_past_mtime $DIR1/$tfile
3310 touch -a -d @$far_past_atime $DIR1/$tfile
3312 for (( i=0; i < 2; i++ )) ; do
3313 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3314 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3315 error "atime or mtime set incorrectly"
3317 cancel_lru_locks osc
3318 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3321 run_test 39m "test atime and mtime before 1970"
3323 test_39n() { # LU-3832
3324 local atime_diff=$(do_facet $SINGLEMDS \
3325 lctl get_param -n mdd.*MDT0000*.atime_diff)
3330 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3333 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3334 atime0=$(stat -c %X $DIR/$tfile)
3337 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3338 atime1=$(stat -c %X $DIR/$tfile)
3341 cancel_lru_locks mdc
3342 cancel_lru_locks osc
3343 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3344 atime2=$(stat -c %X $DIR/$tfile)
3346 do_facet $SINGLEMDS \
3347 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3349 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3350 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3352 run_test 39n "check that O_NOATIME is honored"
3355 TESTDIR=$DIR/$tdir/$tfile
3356 [ -e $TESTDIR ] && rm -rf $TESTDIR
3357 test_mkdir -p $TESTDIR
3363 links2=$(stat -c %h .)
3364 [ $(($links1 + 2)) != $links2 ] &&
3365 error "wrong links count $(($links1 + 2)) != $links2"
3367 links3=$(stat -c %h .)
3368 [ $(($links1 + 1)) != $links3 ] &&
3369 error "wrong links count $links1 != $links3"
3372 run_test 39o "directory cached attributes updated after create ========"
3375 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3377 TESTDIR=$DIR/$tdir/$tfile
3378 [ -e $TESTDIR ] && rm -rf $TESTDIR
3383 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3384 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3386 links2=$(stat -c %h .)
3387 [ $(($links1 + 2)) != $links2 ] &&
3388 error "wrong links count $(($links1 + 2)) != $links2"
3390 links3=$(stat -c %h .)
3391 [ $(($links1 + 1)) != $links3 ] &&
3392 error "wrong links count $links1 != $links3"
3395 run_test 39p "remote directory cached attributes updated after create ========"
3399 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3400 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3401 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3402 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3403 error "$tfile is not 4096 bytes in size"
3405 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3409 small_write $DIR/f41 18
3411 run_test 41 "test small file write + fstat ====================="
3413 count_ost_writes() {
3414 lctl get_param -n osc.*.stats |
3415 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3416 END { printf("%0.0f", writes) }'
3423 BG_DIRTY_RATIO_SAVE=10
3424 MAX_BG_DIRTY_RATIO=25
3428 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3429 # dirty_ratio, dirty_background_ratio
3430 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3431 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3432 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3433 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3435 # if file not here, we are a 2.4 kernel
3436 kill -CONT `pidof kupdated`
3441 # setup the trap first, so someone cannot exit the test at the
3442 # exact wrong time and mess up a machine
3443 trap start_writeback EXIT
3444 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3445 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3446 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3447 sysctl -w vm.dirty_writeback_centisecs=0
3448 sysctl -w vm.dirty_writeback_centisecs=0
3449 # save and increase /proc/sys/vm/dirty_ratio
3450 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3451 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3452 # save and increase /proc/sys/vm/dirty_background_ratio
3453 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3454 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3456 # if file not here, we are a 2.4 kernel
3457 kill -STOP `pidof kupdated`
3461 # ensure that all stripes have some grant before we test client-side cache
3463 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3464 dd if=/dev/zero of=$i bs=4k count=1
3469 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3470 # file truncation, and file removal.
3472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3474 cancel_lru_locks osc
3476 sync; sleep 1; sync # just to be safe
3477 BEFOREWRITES=`count_ost_writes`
3478 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3479 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3480 AFTERWRITES=`count_ost_writes`
3481 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3482 error "$BEFOREWRITES < $AFTERWRITES"
3485 run_test 42a "ensure that we don't flush on close =============="
3488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3490 cancel_lru_locks osc
3493 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3494 BEFOREWRITES=$(count_ost_writes)
3495 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3496 AFTERWRITES=$(count_ost_writes)
3497 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3498 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3500 BEFOREWRITES=$(count_ost_writes)
3501 sync || error "sync: $?"
3502 AFTERWRITES=$(count_ost_writes)
3503 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3504 error "$BEFOREWRITES < $AFTERWRITES on sync"
3506 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3510 run_test 42b "test destroy of file with cached dirty data ======"
3512 # if these tests just want to test the effect of truncation,
3513 # they have to be very careful. consider:
3514 # - the first open gets a {0,EOF}PR lock
3515 # - the first write conflicts and gets a {0, count-1}PW
3516 # - the rest of the writes are under {count,EOF}PW
3517 # - the open for truncate tries to match a {0,EOF}PR
3518 # for the filesize and cancels the PWs.
3519 # any number of fixes (don't get {0,EOF} on open, match
3520 # composite locks, do smarter file size management) fix
3521 # this, but for now we want these tests to verify that
3522 # the cancellation with truncate intent works, so we
3523 # start the file with a full-file pw lock to match against
3524 # until the truncate.
3529 cancel_lru_locks osc
3531 # prime the file with 0,EOF PW to match
3535 # now the real test..
3536 dd if=/dev/zero of=$file bs=1024 count=100
3537 BEFOREWRITES=`count_ost_writes`
3538 $TRUNCATE $file $offset
3539 cancel_lru_locks osc
3540 AFTERWRITES=`count_ost_writes`
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3547 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3548 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3551 run_test 42c "test partial truncate of file with cached dirty data"
3554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3556 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3557 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3560 run_test 42d "test complete truncate of file with cached dirty data"
3562 test_42e() { # bug22074
3563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3564 local TDIR=$DIR/${tdir}e
3565 local pagesz=$(page_size)
3566 local pages=16 # hardcoded 16 pages, don't change it.
3567 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3568 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3572 test_mkdir -p $DIR/${tdir}e
3573 $SETSTRIPE -c 1 $TDIR
3574 createmany -o $TDIR/f $files
3576 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3578 # we assume that with $OSTCOUNT files, at least one of them will
3579 # be allocated on OST0.
3580 warmup_files=$((OSTCOUNT * max_dirty_mb))
3581 createmany -o $TDIR/w $warmup_files
3583 # write a large amount of data into one file and sync, to get good
3584 # avail_grant number from OST.
3585 for ((i=0; i<$warmup_files; i++)); do
3586 idx=$($GETSTRIPE -i $TDIR/w$i)
3587 [ $idx -ne 0 ] && continue
3588 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3591 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3593 $LCTL get_param $proc_osc0/cur_dirty_bytes
3594 $LCTL get_param $proc_osc0/cur_grant_bytes
3596 # create as much dirty pages as we can while not to trigger the actual
3597 # RPCs directly. but depends on the env, VFS may trigger flush during this
3598 # period, hopefully we are good.
3599 for ((i=0; i<$warmup_files; i++)); do
3600 idx=$($GETSTRIPE -i $TDIR/w$i)
3601 [ $idx -ne 0 ] && continue
3602 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3604 $LCTL get_param $proc_osc0/cur_dirty_bytes
3605 $LCTL get_param $proc_osc0/cur_grant_bytes
3607 # perform the real test
3608 $LCTL set_param $proc_osc0/rpc_stats 0
3609 for ((;i<$files; i++)); do
3610 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3611 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3614 $LCTL get_param $proc_osc0/rpc_stats
3617 local have_ppr=false
3618 $LCTL get_param $proc_osc0/rpc_stats |
3619 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3620 # skip lines until we are at the RPC histogram data
3621 [ "$PPR" == "pages" ] && have_ppr=true && continue
3622 $have_ppr || continue
3624 # we only want the percent stat for < 16 pages
3625 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3627 percent=$((percent + WPCT))
3628 if [[ $percent -gt 15 ]]; then
3629 error "less than 16-pages write RPCs" \
3636 run_test 42e "verify sub-RPC writes are not done synchronously"
3639 test_mkdir -p $DIR/$tdir
3640 cp -p /bin/ls $DIR/$tdir/$tfile
3641 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3643 # give multiop a chance to open
3646 $DIR/$tdir/$tfile && error || true
3649 run_test 43 "execution of file opened for write should return -ETXTBSY"
3652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3653 test_mkdir -p $DIR/$tdir
3654 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3655 cp -p multiop $DIR/$tdir/multiop
3656 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3659 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3660 kill -USR1 $MULTIOP_PID || return 2
3661 wait $MULTIOP_PID || return 3
3662 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3664 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3668 test_mkdir -p $DIR/$tdir
3669 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3670 cp -p multiop $DIR/$tdir/multiop
3671 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3674 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3675 kill -USR1 $MULTIOP_PID || return 2
3676 wait $MULTIOP_PID || return 3
3677 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3679 run_test 43b "truncate of file being executed should return -ETXTBSY"
3682 local testdir="$DIR/$tdir"
3683 test_mkdir -p $DIR/$tdir
3685 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3686 ( cd $testdir && md5sum -c)
3688 run_test 43c "md5sum of copy into lustre========================"
3691 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3692 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3693 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3695 run_test 44 "zero length read from a sparse stripe ============="
3698 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3700 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3701 [[ $nstripe -gt $OSTCOUNT ]] &&
3702 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3704 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3706 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3707 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3711 OFFSETS="0 $((stride/2)) $((stride-1))"
3712 for offset in $OFFSETS; do
3713 for i in $(seq 0 $((nstripe-1))); do
3714 local GLOBALOFFSETS=""
3716 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3717 local myfn=$DIR/d44a-$size
3718 echo "--------writing $myfn at $size"
3719 ll_sparseness_write $myfn $size ||
3720 error "ll_sparseness_write"
3721 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3722 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3723 error "ll_sparseness_verify $GLOBALOFFSETS"
3725 for j in $(seq 0 $((nstripe-1))); do
3727 size=$((((j + $nstripe )*$stride + $offset)))
3728 ll_sparseness_write $myfn $size ||
3729 error "ll_sparseness_write"
3730 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3732 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3733 error "ll_sparseness_verify $GLOBALOFFSETS"
3738 run_test 44a "test sparse pwrite ==============================="
3742 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3748 before=`dirty_osc_total`
3749 echo executing "\"$*\""
3751 after=`dirty_osc_total`
3752 echo before $before, after $after
3755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3757 # Obtain grants from OST if it supports it
3758 echo blah > ${f}_grant
3761 do_dirty_record "echo blah > $f"
3762 [[ $before -eq $after ]] && error "write wasn't cached"
3763 do_dirty_record "> $f"
3764 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3765 do_dirty_record "echo blah > $f"
3766 [[ $before -eq $after ]] && error "write wasn't cached"
3767 do_dirty_record "sync"
3768 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3769 do_dirty_record "echo blah > $f"
3770 [[ $before -eq $after ]] && error "write wasn't cached"
3771 do_dirty_record "cancel_lru_locks osc"
3772 [[ $before -gt $after ]] ||
3773 error "lock cancellation didn't lower dirty count"
3776 run_test 45 "osc io page accounting ============================"
3778 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3779 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3780 # objects offset and an assert hit when an rpc was built with 1023's mapped
3781 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3787 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3789 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3790 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3794 run_test 46 "dirtying a previously written page ================"
3796 # test_47 is removed "Device nodes check" is moved to test_28
3798 test_48a() { # bug 2399
3799 check_kernel_version 34 || return 0
3800 test_mkdir -p $DIR/$tdir
3802 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3803 test_mkdir $DIR/$tdir || error "recreate directory failed"
3804 touch foo || error "'touch foo' failed after recreating cwd"
3805 test_mkdir $DIR/$tdir/bar ||
3806 error "'mkdir foo' failed after recreating cwd"
3807 if check_kernel_version 44; then
3808 touch .foo || error "'touch .foo' failed after recreating cwd"
3809 test_mkdir $DIR/$tdir/.bar ||
3810 error "'mkdir .foo' failed after recreating cwd"
3812 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3813 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3814 cd . || error "'cd .' failed after recreating cwd"
3815 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3816 rmdir . && error "'rmdir .' worked after recreating cwd"
3817 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3818 cd .. || error "'cd ..' failed after recreating cwd"
3820 run_test 48a "Access renamed working dir (should return errors)="
3822 test_48b() { # bug 2399
3823 check_kernel_version 34 || return 0
3825 test_mkdir -p $DIR/$tdir
3827 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3828 touch foo && error "'touch foo' worked after removing cwd"
3829 test_mkdir $DIR/$tdir/foo &&
3830 error "'mkdir foo' worked after removing cwd"
3831 if check_kernel_version 44; then
3832 touch .foo && error "'touch .foo' worked after removing cwd"
3833 test_mkdir $DIR/$tdir/.foo &&
3834 error "'mkdir .foo' worked after removing cwd"
3836 ls . > /dev/null && error "'ls .' worked after removing cwd"
3837 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3838 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3839 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3840 rmdir . && error "'rmdir .' worked after removing cwd"
3841 ln -s . foo && error "'ln -s .' worked after removing cwd"
3842 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3844 run_test 48b "Access removed working dir (should return errors)="
3846 test_48c() { # bug 2350
3847 check_kernel_version 36 || return 0
3848 #lctl set_param debug=-1
3851 test_mkdir -p $DIR/$tdir/dir
3853 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3854 $TRACE touch foo && error "touch foo worked after removing cwd"
3855 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3856 if check_kernel_version 44; then
3857 touch .foo && error "touch .foo worked after removing cwd"
3858 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3860 $TRACE ls . && error "'ls .' worked after removing cwd"
3861 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3862 is_patchless || ( $TRACE cd . &&
3863 error "'cd .' worked after removing cwd" )
3864 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3865 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3866 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3867 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3869 run_test 48c "Access removed working subdir (should return errors)"
3871 test_48d() { # bug 2350
3872 check_kernel_version 36 || return 0
3873 #lctl set_param debug=-1
3876 test_mkdir -p $DIR/$tdir/dir
3878 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3879 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3880 $TRACE touch foo && error "'touch foo' worked after removing parent"
3881 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3882 if check_kernel_version 44; then
3883 touch .foo && error "'touch .foo' worked after removing parent"
3885 error "mkdir .foo worked after removing parent"
3887 $TRACE ls . && error "'ls .' worked after removing parent"
3888 $TRACE ls .. && error "'ls ..' worked after removing parent"
3889 is_patchless || ( $TRACE cd . &&
3890 error "'cd .' worked after recreate parent" )
3891 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3892 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3893 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3894 is_patchless || ( $TRACE cd .. &&
3895 error "'cd ..' worked after removing parent" || true )
3897 run_test 48d "Access removed parent subdir (should return errors)"
3899 test_48e() { # bug 4134
3900 check_kernel_version 41 || return 0
3901 #lctl set_param debug=-1
3904 test_mkdir -p $DIR/$tdir/dir
3906 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3907 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3908 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3909 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3910 # On a buggy kernel addition of "touch foo" after cd .. will
3911 # produce kernel oops in lookup_hash_it