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 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
110 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
200 test_mkdir $DIR/$tdir ||
201 error "Create remote directory failed"
203 touch $DIR/$tdir/$tfile ||
204 error "Create file under remote directory failed"
207 error "Expect error removing in-use dir $DIR/$tdir"
209 test -d $DIR/$tdir || error "Remote directory disappeared"
211 rm -rf $DIR/$tdir || error "remove remote dir error"
213 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
216 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
217 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
218 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
219 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
220 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
222 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
225 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
226 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile does not have perm 0666 or UID $UID"
229 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile should be 0666 and owned by UID $UID"
233 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
238 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
241 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
245 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
250 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by GID $UID"
253 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
257 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
260 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
261 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
262 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
263 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
264 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
265 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
266 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
267 error "$tdir/d/subdir should be GID $RUNAS_GID"
269 run_test 6g "Is new dir in sgid dir inheriting group?"
271 test_6h() { # bug 7331
272 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
273 touch $DIR/$tfile || error "touch failed"
274 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
275 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
276 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
277 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
278 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
280 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
283 test_mkdir $DIR/$tdir
284 $MCREATE $DIR/$tdir/$tfile
285 chmod 0666 $DIR/$tdir/$tfile
286 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
287 error "$tdir/$tfile should be mode 0666"
289 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
292 if [ ! -d $DIR/$tdir ]; then
295 $MCREATE $DIR/$tdir/$tfile
296 echo -n foo > $DIR/$tdir/$tfile
297 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
298 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
300 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
303 test_mkdir $DIR/$tdir
304 touch $DIR/$tdir/$tfile
305 chmod 0666 $DIR/$tdir/$tfile
306 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
307 error "$tfile mode not 0666"
309 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 test_mkdir $DIR/$tdir/d2/d3
315 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
317 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
320 test_mkdir $DIR/$tdir
321 test_mkdir $DIR/$tdir/d2
322 touch $DIR/$tdir/d2/$tfile
323 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
324 error "$tdir/d2/$tfile not a file"
326 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 chmod 0666 $DIR/$tdir/d2
332 chmod 0705 $DIR/$tdir/d2
333 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
334 error "$tdir/d2 mode not 0705"
336 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
341 chmod 0666 $DIR/$tdir/$tfile
342 chmod 0654 $DIR/$tdir/$tfile
343 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
344 error "$tdir/d2 mode not 0654"
346 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
349 test_mkdir $DIR/$tdir
350 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
352 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
353 error "$tdir/$tfile size not 0 after truncate"
355 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
361 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
363 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
366 test_mkdir $DIR/$tdir
367 touch $DIR/$tdir/$tfile
368 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
369 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
370 error "$tdir/${tfile_2} not a file after rename"
372 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
377 rm -rf $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
383 test_mkdir -p $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
387 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not a symlink"
389 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not referencing a file"
391 rm -f $DIR/$tdir/l-exist
392 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
394 run_test 17a "symlinks: create, remove (real) =================="
397 test_mkdir -p $DIR/$tdir
398 ln -s no-such-file $DIR/$tdir/l-dangle
400 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing no-such-file"
402 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing non-existent file"
404 rm -f $DIR/$tdir/l-dangle
405 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
407 run_test 17b "symlinks: create, remove (dangling) =============="
409 test_17c() { # bug 3440 - don't save failed open RPC for replay
410 test_mkdir -p $DIR/$tdir
411 ln -s foo $DIR/$tdir/$tfile
412 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
414 run_test 17c "symlinks: open dangling (should return error) ===="
417 test_mkdir -p $DIR/$tdir
418 ln -s foo $DIR/$tdir/$tfile
419 touch $DIR/$tdir/$tfile || error "creating to new symlink"
421 run_test 17d "symlinks: create dangling ========================"
424 test_mkdir -p $DIR/$tdir
425 local foo=$DIR/$tdir/$tfile
426 ln -s $foo $foo || error "create symlink failed"
427 ls -l $foo || error "ls -l failed"
428 ls $foo && error "ls not failed" || true
430 run_test 17e "symlinks: create recursive symlink (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
442 run_test 17f "symlinks: long and very long symlink name ========================"
444 # str_repeat(S, N) generate a string that is string S repeated N times
449 while [ $((n -= 1)) -ge 0 ]; do
455 # Long symlinks and LU-2241
457 test_mkdir -p $DIR/$tdir
458 local TESTS="59 60 61 4094 4095"
460 # Fix for inode size boundary in 2.1.4
461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
464 # Patch not applied to 2.2 or 2.3 branches
465 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
466 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
469 # skip long symlink name for rhel6.5.
470 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
471 grep -q '6.5' /etc/redhat-release &>/dev/null &&
472 TESTS="59 60 61 4062 4063"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
486 test_mkdir -p $DIR/$tdir
487 if [[ $MDSCOUNT -gt 1 ]]; then
488 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
492 $SETSTRIPE -c -1 $DIR/$tdir
493 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
494 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
495 touch $DIR/$tdir/$tfile || true
497 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
499 test_17i() { #bug 20018
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -c1 $DIR/$tdir
503 local foo=$DIR/$tdir/$tfile
505 if [[ $MDSCOUNT -gt 1 ]]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 ln -s $foo $foo || error "create symlink failed"
511 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
513 ls -l $foo && error "error not detected"
516 run_test 17i "don't panic on short symlink"
518 test_17k() { #bug 22301
519 [[ -z "$(which rsync 2>/dev/null)" ]] &&
520 skip "no rsync command" && return 0
521 rsync --help | grep -q xattr ||
522 skip_env "$(rsync --version | head -n1) does not support xattrs"
523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
524 test_mkdir -p $DIR/$tdir
525 test_mkdir -p $DIR/$tdir.new
526 touch $DIR/$tdir/$tfile
527 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
528 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
529 error "rsync failed with xattrs enabled"
531 run_test 17k "symlinks: rsync with xattrs enabled ========================="
533 test_17l() { # LU-279
534 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
535 skip "no getfattr command" && return 0
537 touch $DIR/$tdir/$tfile
538 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
539 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
540 # -h to not follow symlinks. -m '' to list all the xattrs.
541 # grep to remove first line: '# file: $path'.
542 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
544 lgetxattr_size_check $path $xattr ||
545 error "lgetxattr_size_check $path $xattr failed"
549 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
553 local short_sym="0123456789"
554 local WDIR=$DIR/${tdir}m
561 remote_mds_nodsh && skip "remote MDS with nodsh" && return
562 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
563 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
564 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
566 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
567 skip "only for ldiskfs MDT" && return 0
569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
573 # create a long symlink file
574 for ((i = 0; i < 4; ++i)); do
575 long_sym=${long_sym}${long_sym}
578 echo "create 512 short and long symlink files under $WDIR"
579 for ((i = 0; i < 256; ++i)); do
580 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
581 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
587 wait_delete_completed
589 echo "recreate the 512 symlink files with a shorter string"
590 for ((i = 0; i < 512; ++i)); do
591 # rewrite the symlink file with a shorter string
592 ln -sf ${long_sym} $WDIR/long-$i
593 ln -sf ${short_sym} $WDIR/short-$i
596 mds_index=$($LFS getstripe -M $WDIR)
597 mds_index=$((mds_index+1))
598 devname=$(mdsdevname $mds_index)
599 cmd="$E2FSCK -fnvd $devname"
601 echo "stop and checking mds${mds_index}: $cmd"
602 # e2fsck should not return error
604 do_facet mds${mds_index} $cmd || rc=$?
606 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
607 df $MOUNT > /dev/null 2>&1
608 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
609 "short/long symlink MDT: rc=$rc"
612 run_test 17m "run e2fsck against MDT which contains short/long symlink"
614 check_fs_consistency_17n() {
620 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
621 # so it only check MDT1/MDT2 instead of all of MDTs.
622 for mdt_index in $(seq 1 2); do
623 devname=$(mdsdevname $mdt_index)
624 cmd="$E2FSCK -fnvd $devname"
626 echo "stop and checking mds${mdt_index}: $cmd"
627 # e2fsck should not return error
629 do_facet mds${mdt_index} $cmd || rc=$?
631 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
632 error "mount mds${mdt_index} failed"
633 df $MOUNT > /dev/null 2>&1
634 [ $rc -ne 0 ] && break
642 remote_mds_nodsh && skip "remote MDS with nodsh" && return
643 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
644 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
645 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
647 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
648 skip "only for ldiskfs MDT" && return 0
650 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
655 for ((i=0; i<10; i++)); do
656 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
657 error "create remote dir error $i"
658 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
659 error "create files under remote dir failed $i"
662 check_fs_consistency_17n ||
663 error "e2fsck report error after create files under remote dir"
665 for ((i=0;i<10;i++)); do
666 rm -rf $DIR/$tdir/remote_dir_${i} ||
667 error "destroy remote dir error $i"
670 check_fs_consistency_17n ||
671 error "e2fsck report error after unlink files under remote dir"
673 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
674 skip "lustre < 2.4.50 does not support migrate mv " && return
676 for ((i=0; i<10; i++)); do
677 mkdir -p $DIR/$tdir/remote_dir_${i}
678 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
679 error "create files under remote dir failed $i"
680 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
681 error "migrate remote dir error $i"
683 check_fs_consistency_17n || error "e2fsck report error after migration"
685 for ((i=0;i<10;i++)); do
686 rm -rf $DIR/$tdir/remote_dir_${i} ||
687 error "destroy remote dir error $i"
690 check_fs_consistency_17n || error "e2fsck report error after unlink"
692 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
695 remote_mds_nodsh && skip "remote MDS with nodsh" && return
696 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
697 skip "Need MDS version at least 2.3.64" && return
699 local WDIR=$DIR/${tdir}o
705 mdt_index=$($LFS getstripe -M $WDIR)
706 mdt_index=$((mdt_index+1))
707 mdtdevname=$(mdsdevname $mdt_index)
711 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
712 error "mount mds${mdt_index} failed"
714 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
715 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
716 ls -l $WDIR/$tfile && rc=1
717 do_facet mds${mdt_index} lctl set_param fail_loc=0
718 [[ $rc -ne 0 ]] && error "stat file should fail"
721 run_test 17o "stat file with incompat LMA feature"
724 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
725 ls $DIR || error "Failed to ls $DIR: $?"
727 run_test 18 "touch .../f ; ls ... =============================="
733 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
735 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
738 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
740 run_test 19b "ls -l .../f19 (should return error) =============="
743 [ $RUNAS_ID -eq $UID ] &&
744 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
745 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
747 run_test 19c "$RUNAS touch .../f19 (should return error) =="
750 cat $DIR/f19 && error || true
752 run_test 19d "cat .../f19 (should return error) =============="
764 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
766 run_test 20 "touch .../f ; ls -l ... ==========================="
769 test_mkdir -p $DIR/$tdir
770 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
771 ln -s dangle $DIR/$tdir/link
772 echo foo >> $DIR/$tdir/link
773 cat $DIR/$tdir/dangle
774 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
775 $CHECKSTAT -f -t file $DIR/$tdir/link ||
776 error "$tdir/link not linked to a file"
778 run_test 21 "write to dangling link ============================"
782 test_mkdir -p $DIR/$tdir
783 chown $RUNAS_ID:$RUNAS_GID $WDIR
784 (cd $WDIR || error "cd $WDIR failed";
785 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
787 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
788 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
789 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
791 run_test 22 "unpack tar archive as non-root user ==============="
795 test_mkdir -p $DIR/$tdir
796 local file=$DIR/$tdir/$tfile
798 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
799 openfile -f O_CREAT:O_EXCL $file &&
800 error "$file recreate succeeded" || true
802 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
804 test_23b() { # bug 18988
805 test_mkdir -p $DIR/$tdir
806 local file=$DIR/$tdir/$tfile
809 echo foo > $file || error "write filed"
810 echo bar >> $file || error "append filed"
811 $CHECKSTAT -s 8 $file || error "wrong size"
814 run_test 23b "O_APPEND check =========================="
818 echo '-- same directory rename'
819 test_mkdir $DIR/$tdir
820 touch $DIR/$tdir/$tfile.1
821 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
822 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
824 run_test 24a "rename file to non-existent target"
827 test_mkdir $DIR/$tdir
828 touch $DIR/$tdir/$tfile.{1,2}
829 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
830 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
831 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
833 run_test 24b "rename file to existing target"
836 test_mkdir $DIR/$tdir
837 test_mkdir $DIR/$tdir/d$testnum.1
838 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
839 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
840 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
842 run_test 24c "rename directory to non-existent target"
845 test_mkdir -c1 $DIR/$tdir
846 test_mkdir -c1 $DIR/$tdir/d$testnum.1
847 test_mkdir -c1 $DIR/$tdir/d$testnum.2
848 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
849 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
850 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
852 run_test 24d "rename directory to existing target"
855 echo '-- cross directory renames --'
859 mv $DIR/R5a/f $DIR/R5b/g
860 $CHECKSTAT -a $DIR/R5a/f || error
861 $CHECKSTAT -t file $DIR/R5b/g || error
863 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
868 touch $DIR/R6a/f $DIR/R6b/g
869 mv $DIR/R6a/f $DIR/R6b/g
870 $CHECKSTAT -a $DIR/R6a/f || error
871 $CHECKSTAT -t file $DIR/R6b/g || error
873 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
878 test_mkdir $DIR/R7a/d
879 mv $DIR/R7a/d $DIR/R7b/e
880 $CHECKSTAT -a $DIR/R7a/d || error
881 $CHECKSTAT -t dir $DIR/R7b/e || error
883 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
886 test_mkdir -c1 $DIR/R8a
887 test_mkdir -c1 $DIR/R8b
888 test_mkdir -c1 $DIR/R8a/d
889 test_mkdir -c1 $DIR/R8b/e
890 mrename $DIR/R8a/d $DIR/R8b/e
891 $CHECKSTAT -a $DIR/R8a/d || error
892 $CHECKSTAT -t dir $DIR/R8b/e || error
894 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
897 echo "-- rename error cases"
901 mrename $DIR/R9/f $DIR/R9/a
902 $CHECKSTAT -t file $DIR/R9/f || error
903 $CHECKSTAT -t dir $DIR/R9/a || error
904 $CHECKSTAT -a $DIR/R9/a/f || error
906 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
910 mrename $DIR/R10/f $DIR/R10/g
911 $CHECKSTAT -t dir $DIR/R10 || error
912 $CHECKSTAT -a $DIR/R10/f || error
913 $CHECKSTAT -a $DIR/R10/g || error
915 run_test 24j "source does not exist ============================"
919 test_mkdir $DIR/R11a/d
921 mv $DIR/R11a/f $DIR/R11a/d
922 $CHECKSTAT -a $DIR/R11a/f || error
923 $CHECKSTAT -t file $DIR/R11a/d/f || error
925 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
927 # bug 2429 - rename foo foo foo creates invalid file
930 $MULTIOP $f OcNs || error
932 run_test 24l "Renaming a file to itself ========================"
936 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
937 # on ext3 this does not remove either the source or target files
938 # though the "expected" operation would be to remove the source
939 $CHECKSTAT -t file ${f} || error "${f} missing"
940 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
942 run_test 24m "Renaming a file to a hard link to itself ========="
946 # this stats the old file after it was renamed, so it should fail
950 $CHECKSTAT ${f}.rename
953 run_test 24n "Statting the old file after renaming (Posix rename 2)"
956 check_kernel_version 37 || return 0
957 test_mkdir -p $DIR/d24o
958 rename_many -s random -v -n 10 $DIR/d24o
960 run_test 24o "rename of files during htree split ==============="
965 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
966 mrename $DIR/R12a $DIR/R12b
967 $CHECKSTAT -a $DIR/R12a || error
968 $CHECKSTAT -t dir $DIR/R12b || error
969 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
970 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
972 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
974 cleanup_multiop_pause() {
980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
983 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
984 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
987 trap cleanup_multiop_pause EXIT
988 mrename $DIR/R13a $DIR/R13b
989 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
990 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
991 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
992 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
993 cleanup_multiop_pause
994 wait $MULTIPID || error "multiop close failed"
996 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
998 test_24r() { #bug 3789
1000 test_mkdir $DIR/R14a/b
1001 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1002 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1003 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1005 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1008 test_mkdir $DIR/R15a
1009 test_mkdir $DIR/R15a/b
1010 test_mkdir $DIR/R15a/b/c
1011 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1012 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1013 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1015 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1017 test_mkdir $DIR/R16a
1018 test_mkdir $DIR/R16a/b
1019 test_mkdir $DIR/R16a/b/c
1020 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1021 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1022 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1024 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1026 test_24u() { # bug12192
1027 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1028 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1030 run_test 24u "create stripe file"
1036 simple_cleanup_common() {
1039 wait_delete_completed
1042 max_pages_per_rpc() {
1043 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1047 local NRFILES=100000
1048 local FREE_INODES=$(mdt_free_inodes 0)
1049 [[ $FREE_INODES -lt $NRFILES ]] &&
1050 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1054 trap simple_cleanup_common EXIT
1056 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1057 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1060 createmany -m $DIR/$tdir/$tfile $NRFILES
1062 cancel_lru_locks mdc
1063 lctl set_param mdc.*.stats clear
1065 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1067 # LU-5 large readdir
1068 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1069 # 8 bytes for name(filename is mostly 5 in this test) +
1070 # 8 bytes for luda_type
1071 # take into account of overhead in lu_dirpage header and end mark in
1072 # each page, plus one in RPC_NUM calculation.
1074 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1075 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1076 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1077 awk '/^mds_readpage/ {print $2}')
1078 [[ $mds_readpage -gt $RPC_NUM ]] &&
1079 error "large readdir doesn't take effect"
1081 simple_cleanup_common
1083 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1085 test_24w() { # bug21506
1087 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1088 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1089 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1090 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1091 [[ "$SZ1" -eq "$SZ2" ]] ||
1092 error "Error reading at the end of the file $tfile"
1094 run_test 24w "Reading a file larger than 4Gb"
1097 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1100 local remote_dir=$DIR/$tdir/remote_dir
1103 $LFS mkdir -i $MDTIDX $remote_dir ||
1104 error "create remote directory failed"
1106 mkdir -p $DIR/$tdir/src_dir
1107 touch $DIR/$tdir/src_file
1108 mkdir -p $remote_dir/tgt_dir
1109 touch $remote_dir/tgt_file
1111 mrename $remote_dir $DIR/ &&
1112 error "rename dir cross MDT works!"
1114 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1115 error "rename dir cross MDT works!"
1117 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1118 error "rename file cross MDT works!"
1120 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1121 error "ln file cross MDT should not work!"
1123 rm -rf $DIR/$tdir || error "Can not delete directories"
1125 run_test 24x "cross rename/link should be failed"
1128 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1131 local remote_dir=$DIR/$tdir/remote_dir
1134 $LFS mkdir -i $MDTIDX $remote_dir ||
1135 error "create remote directory failed"
1137 mkdir -p $remote_dir/src_dir
1138 touch $remote_dir/src_file
1139 mkdir -p $remote_dir/tgt_dir
1140 touch $remote_dir/tgt_file
1142 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1143 error "rename subdir in the same remote dir failed!"
1145 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1146 error "rename files in the same remote dir failed!"
1148 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1149 error "link files in the same remote dir failed!"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24y "rename/link on the same dir should succeed"
1156 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1159 local remote_src=$DIR/$tdir/remote_dir
1160 local remote_tgt=$DIR/$tdir/remote_tgt
1163 $LFS mkdir -i $MDTIDX $remote_src ||
1164 error "create remote directory failed"
1166 $LFS mkdir -i $MDTIDX $remote_tgt ||
1167 error "create remote directory failed"
1169 mrename $remote_src $remote_tgt &&
1170 error "rename remote dirs should not work!"
1172 # If target dir does not exists, it should succeed
1174 mrename $remote_src $remote_tgt ||
1175 error "rename remote dirs(tgt dir does not exists) failed!"
1177 rm -rf $DIR/$tdir || error "Can not delete directories"
1179 run_test 24z "rename one remote dir to another remote dir should fail"
1181 test_24A() { # LU-3182
1186 createmany -m $DIR/$tdir/$tfile $NFILES
1187 local t=$(ls $DIR/$tdir | wc -l)
1188 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1189 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1190 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1191 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1194 rm -rf $DIR/$tdir || error "Can not delete directories"
1196 run_test 24A "readdir() returns correct number of entries."
1198 test_24B() { # LU-4805
1199 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1203 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1204 error "create striped dir failed"
1206 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1207 [ $count -eq 2 ] || error "Expected 2, got $count"
1209 touch $DIR/$tdir/striped_dir/a
1211 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1212 [ $count -eq 3 ] || error "Expected 3, got $count"
1214 touch $DIR/$tdir/striped_dir/.f
1216 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1217 [ $count -eq 4 ] || error "Expected 4, got $count"
1219 rm -rf $DIR/$tdir || error "Can not delete directories"
1221 run_test 24B "readdir for striped dir return correct number of entries"
1224 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1230 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1231 error "create striped dir failed"
1233 cd $DIR/$tdir/d0/striped_dir
1235 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1236 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1237 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1239 [ "$d0_ino" = "$parent_ino" ] ||
1240 error ".. wrong, expect $d0_ino, get $parent_ino"
1242 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1243 error "mv striped dir failed"
1245 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1247 [ "$d1_ino" = "$parent_ino" ] ||
1248 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1250 run_test 24C "check .. in striped dir"
1253 echo '== symlink sanity ============================================='
1257 touch $DIR/s25/foo || error
1259 run_test 25a "create file in symlinked directory ==============="
1262 [ ! -d $DIR/d25 ] && test_25a
1263 $CHECKSTAT -t file $DIR/s25/foo || error
1265 run_test 25b "lookup file in symlinked directory ==============="
1269 test_mkdir $DIR/d26/d26-2
1270 ln -s d26/d26-2 $DIR/s26
1271 touch $DIR/s26/foo || error
1273 run_test 26a "multiple component symlink ======================="
1276 test_mkdir -p $DIR/d26b/d26-2
1277 ln -s d26b/d26-2/foo $DIR/s26-2
1278 touch $DIR/s26-2 || error
1280 run_test 26b "multiple component symlink at end of lookup ======"
1283 test_mkdir $DIR/d26.2
1284 touch $DIR/d26.2/foo
1285 ln -s d26.2 $DIR/s26.2-1
1286 ln -s s26.2-1 $DIR/s26.2-2
1287 ln -s s26.2-2 $DIR/s26.2-3
1288 chmod 0666 $DIR/s26.2-3/foo
1290 run_test 26c "chain of symlinks ================================"
1292 # recursive symlinks (bug 439)
1294 ln -s d26-3/foo $DIR/d26-3
1296 run_test 26d "create multiple component recursive symlink ======"
1299 [ ! -h $DIR/d26-3 ] && test_26d
1302 run_test 26e "unlink multiple component recursive symlink ======"
1304 # recursive symlinks (bug 7022)
1306 test_mkdir -p $DIR/$tdir
1307 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1308 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1309 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1310 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1311 cd $tfile || error "cd $tfile failed"
1312 ln -s .. dotdot || error "ln dotdot failed"
1313 ln -s dotdot/lndir lndir || error "ln lndir failed"
1314 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1315 output=`ls $tfile/$tfile/lndir/bar1`
1316 [ "$output" = bar1 ] && error "unexpected output"
1317 rm -r $tfile || error "rm $tfile failed"
1318 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1320 run_test 26f "rm -r of a directory which has recursive symlink ="
1323 echo '== stripe sanity =============================================='
1324 test_mkdir -p $DIR/d27 || error "mkdir failed"
1326 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1327 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1328 log "== test_27a: write to one stripe file ========================="
1329 cp /etc/hosts $DIR/d27/f0 || error
1331 run_test 27a "one stripe file =================================="
1334 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1335 test_mkdir -p $DIR/d27
1336 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1337 $GETSTRIPE -c $DIR/d27/f01
1338 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1339 error "two-stripe file doesn't have two stripes"
1341 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1343 run_test 27b "create and write to two stripe file"
1346 test_mkdir -p $DIR/d27
1347 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1348 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1349 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1351 run_test 27d "create file with default settings ================"
1354 test_mkdir -p $DIR/d27
1355 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1356 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1357 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1359 run_test 27e "setstripe existing file (should return error) ======"
1362 test_mkdir $DIR/$tdir
1363 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1364 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1365 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1366 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1367 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1368 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1370 run_test 27f "setstripe with bad stripe size (should return error)"
1373 test_mkdir -p $DIR/d27
1374 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1375 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1376 error "$DIR/d27/fnone has object"
1378 run_test 27g "$GETSTRIPE with no objects"
1381 touch $DIR/d27/fsome || error "touch failed"
1382 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1384 run_test 27i "$GETSTRIPE with some objects"
1387 test_mkdir -p $DIR/d27
1388 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1390 run_test 27j "setstripe with bad stripe offset (should return error)"
1392 test_27k() { # bug 2844
1393 test_mkdir -p $DIR/d27
1395 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1396 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1397 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1398 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1399 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1400 dd if=/dev/zero of=$FILE bs=4k count=1
1401 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1402 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1404 run_test 27k "limit i_blksize for broken user apps ============="
1407 test_mkdir -p $DIR/d27
1408 mcreate $DIR/f27l || error "creating file"
1409 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1410 error "setstripe should have failed" || true
1412 run_test 27l "check setstripe permissions (should return error)"
1415 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1417 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1418 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1421 trap simple_cleanup_common EXIT
1422 test_mkdir -p $DIR/$tdir
1423 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1424 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1425 error "dd should fill OST0"
1427 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1429 [ $i -gt 256 ] && break
1432 touch $DIR/$tdir/f27m_$i
1433 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1434 error "OST0 was full but new created file still use it"
1436 touch $DIR/$tdir/f27m_$i
1437 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1438 error "OST0 was full but new created file still use it"
1439 simple_cleanup_common
1441 run_test 27m "create file while OST0 was full =================="
1444 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1448 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1449 # if the OST isn't full anymore.
1451 local OSTIDX=${1:-""}
1453 local list=$(comma_list $(osts_nodes))
1454 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1456 do_nodes $list lctl set_param fail_loc=0
1457 sync # initiate all OST_DESTROYs from MDS to OST
1461 exhaust_precreations() {
1464 local FAILIDX=${3:-$OSTIDX}
1466 test_mkdir -p $DIR/$tdir
1467 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1468 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1470 local OST=$(ostname_from_index $OSTIDX)
1471 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1472 sed -e 's/_UUID$//;s/^.*-//')
1475 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1476 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1477 osc.$mdtosc_proc1.prealloc_last_id)
1478 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1479 osc.$mdtosc_proc1.prealloc_next_id)
1481 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1482 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1484 test_mkdir -p $DIR/$tdir/${OST}
1485 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1486 #define OBD_FAIL_OST_ENOSPC 0x215
1487 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1488 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1489 echo "Creating to objid $last_id on ost $OST..."
1490 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1491 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1492 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1496 exhaust_all_precreations() {
1498 for (( i=0; i < OSTCOUNT; i++ )) ; do
1499 exhaust_precreations $i $1 -1
1504 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1506 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1507 remote_ost_nodsh && skip "remote OST with nodsh" && return
1510 rm -f $DIR/$tdir/$tfile
1511 exhaust_precreations 0 0x80000215
1512 $SETSTRIPE -c -1 $DIR/$tdir
1513 touch $DIR/$tdir/$tfile || error
1514 $GETSTRIPE $DIR/$tdir/$tfile
1517 run_test 27n "create file with some full OSTs =================="
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1523 remote_ost_nodsh && skip "remote OST with nodsh" && return
1526 rm -f $DIR/$tdir/$tfile
1527 exhaust_all_precreations 0x215
1529 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1534 run_test 27o "create file with all full OSTs (should error) ===="
1537 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1540 remote_ost_nodsh && skip "remote OST with nodsh" && return
1543 rm -f $DIR/$tdir/$tfile
1544 test_mkdir -p $DIR/$tdir
1546 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1547 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1548 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1550 exhaust_precreations 0 0x80000215
1551 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1552 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1553 $GETSTRIPE $DIR/$tdir/$tfile
1557 run_test 27p "append to a truncated file with some full OSTs ==="
1560 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1562 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1563 remote_ost_nodsh && skip "remote OST with nodsh" && return
1566 rm -f $DIR/$tdir/$tfile
1568 test_mkdir -p $DIR/$tdir
1569 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1570 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1571 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1573 exhaust_all_precreations 0x215
1575 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1576 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1580 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1583 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1585 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1586 remote_ost_nodsh && skip "remote OST with nodsh" && return
1589 rm -f $DIR/$tdir/$tfile
1590 exhaust_precreations 0 0x80000215
1592 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1596 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1598 test_27s() { # bug 10725
1599 test_mkdir -p $DIR/$tdir
1600 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1601 local stripe_count=0
1602 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1603 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1604 error "stripe width >= 2^32 succeeded" || true
1607 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1609 test_27t() { # bug 10864
1614 $WLFS getstripe $tfile
1617 run_test 27t "check that utils parse path correctly"
1619 test_27u() { # bug 4900
1620 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1621 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1623 local list=$(comma_list $(mdts_nodes))
1625 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1626 do_nodes $list $LCTL set_param fail_loc=0x139
1627 test_mkdir -p $DIR/$tdir
1629 createmany -o $DIR/$tdir/t- 1000
1630 do_nodes $list $LCTL set_param fail_loc=0
1632 TLOG=$DIR/$tfile.getstripe
1633 $GETSTRIPE $DIR/$tdir > $TLOG
1634 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1635 unlinkmany $DIR/$tdir/t- 1000
1636 [[ $OBJS -gt 0 ]] &&
1637 error "$OBJS objects created on OST-0. See $TLOG" || pass
1639 run_test 27u "skip object creation on OSC w/o objects =========="
1641 test_27v() { # bug 4900
1642 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1645 remote_ost_nodsh && skip "remote OST with nodsh" && return
1647 exhaust_all_precreations 0x215
1650 test_mkdir -p $DIR/$tdir
1651 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1653 touch $DIR/$tdir/$tfile
1654 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1656 for (( i=1; i < OSTCOUNT; i++ )); do
1657 do_facet ost$i lctl set_param fail_loc=0x705
1659 local START=`date +%s`
1660 createmany -o $DIR/$tdir/$tfile 32
1662 local FINISH=`date +%s`
1663 local TIMEOUT=`lctl get_param -n timeout`
1664 local PROCESS=$((FINISH - START))
1665 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1666 error "$FINISH - $START >= $TIMEOUT / 2"
1667 sleep $((TIMEOUT / 2 - PROCESS))
1670 run_test 27v "skip object creation on slow OST ================="
1672 test_27w() { # bug 10997
1673 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1674 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1675 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1676 error "stripe size $size != 65536" || true
1677 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1678 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1680 run_test 27w "check $SETSTRIPE -S option"
1683 [[ $OSTCOUNT -lt 2 ]] &&
1684 skip_env "skipping multiple stripe count/offset test" && return
1686 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1687 for i in $(seq 1 $OSTCOUNT); do
1689 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1690 error "setstripe -c $i -i $offset failed"
1691 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1692 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1693 [ $count -ne $i ] && error "stripe count $count != $i" || true
1694 [ $index -ne $offset ] &&
1695 error "stripe offset $index != $offset" || true
1698 run_test 27wa "check $SETSTRIPE -c -i options"
1701 remote_ost_nodsh && skip "remote OST with nodsh" && return
1702 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1704 OFFSET=$(($OSTCOUNT - 1))
1706 local OST=$(ostname_from_index $OSTIDX)
1708 test_mkdir -p $DIR/$tdir
1709 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1710 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1712 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1713 for i in `seq 0 $OFFSET`; do
1714 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1715 error "OST0 was degraded but new created file still use it"
1717 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1719 run_test 27x "create files while OST0 is degraded"
1722 [[ $OSTCOUNT -lt 2 ]] &&
1723 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1724 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1725 remote_ost_nodsh && skip "remote OST with nodsh" && return
1726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1728 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1729 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1730 osc.$mdtosc.prealloc_last_id)
1731 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1732 osc.$mdtosc.prealloc_next_id)
1733 local fcount=$((last_id - next_id))
1734 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1735 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1737 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1738 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1739 local OST_DEACTIVE_IDX=-1
1744 for OSC in $MDS_OSCS; do
1745 OST=$(osc_to_ost $OSC)
1746 OSTIDX=$(index_from_ostuuid $OST)
1747 if [ $OST_DEACTIVE_IDX == -1 ]; then
1748 OST_DEACTIVE_IDX=$OSTIDX
1750 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1751 echo $OSC "is Deactivated:"
1752 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1756 OSTIDX=$(index_from_ostuuid $OST)
1758 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1760 for OSC in $MDS_OSCS; do
1761 OST=$(osc_to_ost $OSC)
1762 OSTIDX=$(index_from_ostuuid $OST)
1763 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1764 echo $OST "is degraded:"
1765 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1766 obdfilter.$OST.degraded=1
1771 createmany -o $DIR/$tdir/$tfile $fcount
1773 for OSC in $MDS_OSCS; do
1774 OST=$(osc_to_ost $OSC)
1775 OSTIDX=$(index_from_ostuuid $OST)
1776 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1777 echo $OST "is recovered from degraded:"
1778 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1779 obdfilter.$OST.degraded=0
1781 do_facet $SINGLEMDS lctl --device %$OSC activate
1785 # all osp devices get activated, hence -1 stripe count restored
1788 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1789 # devices get activated.
1791 $SETSTRIPE -c -1 $DIR/$tfile
1792 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1794 [ $stripecnt -ne $OSTCOUNT ] &&
1795 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1798 run_test 27y "create files while OST0 is degraded and the rest inactive"
1804 lmm_count=$($GETSTRIPE -c $1)
1805 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1806 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1808 local old_ifs="$IFS"
1810 fid=($($LFS path2fid $1))
1813 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1814 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1816 # compare lmm_seq and lu_fid->f_seq
1817 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1818 # compare lmm_object_id and lu_fid->oid
1819 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1821 # check the trusted.fid attribute of the OST objects of the file
1822 local have_obdidx=false
1824 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1825 # skip lines up to and including "obdidx"
1826 [ -z "$obdidx" ] && break
1827 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1828 $have_obdidx || continue
1830 local ost=$((obdidx + 1))
1831 local dev=$(ostdevname $ost)
1834 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1836 seq=$(echo $seq | sed -e "s/^0x//g")
1837 if [ $seq == 0 ]; then
1838 oid_hex=$(echo $oid)
1840 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1842 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1846 # Don't unmount/remount the OSTs if we don't need to do that.
1847 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1848 # update too, until that use mount/ll_decode_filter_fid/mount.
1849 # Re-enable when debugfs will understand new filter_fid.
1851 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1852 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1853 $dev 2>/dev/null" | grep "parent=")
1856 mount_fstype ost$ost
1857 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1858 $(facet_mntpt ost$ost)/$obj_file)
1859 unmount_fstype ost$ost
1860 start ost$ost $dev $OST_MOUNT_OPTS
1863 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1865 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1867 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1868 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1869 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1870 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1871 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1873 if echo $ff_parent | grep -q 'stripe='; then
1874 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1877 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1878 # into f_ver in this case. See the comment on
1881 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1885 # compare lmm_seq and filter_fid->ff_parent.f_seq
1886 [ $ff_pseq = $lmm_seq ] ||
1887 error "FF parent SEQ $ff_pseq != $lmm_seq"
1888 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1889 [ $ff_poid = $lmm_oid ] ||
1890 error "FF parent OID $ff_poid != $lmm_oid"
1891 (($ff_pstripe == $stripe_nr)) ||
1892 error "FF stripe $ff_pstripe != $stripe_nr"
1894 stripe_nr=$((stripe_nr + 1))
1899 remote_ost_nodsh && skip "remote OST with nodsh" && return
1900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1901 test_mkdir -p $DIR/$tdir
1903 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1904 { error "setstripe -c -1 failed"; return 1; }
1905 # We need to send a write to every object to get parent FID info set.
1906 # This _should_ also work for setattr, but does not currently.
1907 # touch $DIR/$tdir/$tfile-1 ||
1908 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1909 { error "dd $tfile-1 failed"; return 2; }
1910 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1911 { error "setstripe -c -1 failed"; return 3; }
1912 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1913 { error "dd $tfile-2 failed"; return 4; }
1915 # make sure write RPCs have been sent to OSTs
1918 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1919 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1921 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1923 test_27A() { # b=19102
1924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1925 local restore_size=$($GETSTRIPE -S $MOUNT)
1926 local restore_count=$($GETSTRIPE -c $MOUNT)
1927 local restore_offset=$($GETSTRIPE -i $MOUNT)
1928 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1929 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1930 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1931 local default_size=$($GETSTRIPE -S $MOUNT)
1932 local default_offset=$($GETSTRIPE -i $MOUNT)
1933 local dsize=$((1024 * 1024))
1934 [ $default_size -eq $dsize ] ||
1935 error "stripe size $default_size != $dsize"
1936 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1937 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1939 run_test 27A "check filesystem-wide default LOV EA values"
1941 test_27B() { # LU-2523
1942 test_mkdir -p $DIR/$tdir
1943 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1945 # open f1 with O_LOV_DELAY_CREATE
1947 # call setstripe ioctl on open file descriptor for f1
1949 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1953 # open f1 with O_LOV_DELAY_CREATE
1955 # call setstripe ioctl on open file descriptor for f1
1957 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1959 # Allow multiop to fail in imitation of NFS's busted semantics.
1962 run_test 27B "call setstripe on open unlinked file/rename victim"
1964 test_27C() { #LU-2871
1965 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1973 test_mkdir -p $DIR/$tdir
1975 for i in $(seq 0 $((OSTCOUNT - 1))); do
1976 # set stripe across all OSTs starting from OST$i
1977 $SETSTRIPE -i $i -c -1 $tfile$i
1978 # get striping information
1979 ost_idx=($($GETSTRIPE $tfile$i |
1980 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1984 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1985 error "${#ost_idx[@]} != $OSTCOUNT"
1987 for index in $(seq 0 $((OSTCOUNT - 1))); do
1989 for j in $(echo ${ost_idx[@]}); do
1990 if [ $index -eq $j ]; then
1996 error "Can not find $index in ${ost_idx[@]}"
2000 run_test 27C "check full striping across all OSTs"
2003 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2004 local POOL=${POOL:-testpool}
2006 local last_ost=$(($OSTCOUNT - 1))
2008 local ost_list=$(seq $first_ost $ost_step $last_ost)
2009 local ost_range="$first_ost $last_ost $ost_step"
2012 pool_add $POOL || error "pool_add failed"
2013 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2014 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2015 error "llapi_layout_test failed"
2016 cleanup_pools || error "cleanup_pools failed"
2018 run_test 27D "validate llapi_layout API"
2020 # createtest also checks that device nodes are created and
2021 # then visible correctly (#2091)
2022 test_28() { # bug 2091
2024 $CREATETEST $DIR/d28/ct || error
2026 run_test 28 "create/mknod/mkdir with bad file types ============"
2029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2030 cancel_lru_locks mdc
2036 declare -i LOCKCOUNTORIG=0
2037 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2038 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2040 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2042 declare -i LOCKUNUSEDCOUNTORIG=0
2043 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2044 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2051 declare -i LOCKCOUNTCURRENT=0
2052 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2053 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2056 declare -i LOCKUNUSEDCOUNTCURRENT=0
2057 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2058 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2061 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2062 $LCTL set_param -n ldlm.dump_namespaces ""
2063 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2064 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2065 log "dumped log to $TMP/test_29.dk (bug 5793)"
2068 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2069 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2070 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2071 log "dumped log to $TMP/test_29.dk (bug 5793)"
2075 run_test 29 "IT_GETATTR regression ============================"
2077 test_30a() { # was test_30
2078 cp $(which ls) $DIR || cp /bin/ls $DIR
2082 run_test 30a "execute binary from Lustre (execve) =============="
2085 cp `which ls` $DIR || cp /bin/ls $DIR
2087 $RUNAS $DIR/ls / || error
2090 run_test 30b "execute binary from Lustre as non-root ==========="
2092 test_30c() { # b=22376
2093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2094 cp `which ls` $DIR || cp /bin/ls $DIR
2096 cancel_lru_locks mdc
2097 cancel_lru_locks osc
2098 $RUNAS $DIR/ls / || error
2101 run_test 30c "execute binary from Lustre without read perms ===="
2104 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2105 $CHECKSTAT -a $DIR/f31 || error
2107 run_test 31a "open-unlink file =================================="
2110 touch $DIR/f31 || error
2111 ln $DIR/f31 $DIR/f31b || error
2112 $MULTIOP $DIR/f31b Ouc || error
2113 $CHECKSTAT -t file $DIR/f31 || error
2115 run_test 31b "unlink file with multiple links while open ======="
2118 touch $DIR/f31 || error
2119 ln $DIR/f31 $DIR/f31c || error
2120 multiop_bg_pause $DIR/f31 O_uc || return 1
2122 $MULTIOP $DIR/f31c Ouc
2123 kill -USR1 $MULTIPID
2126 run_test 31c "open-unlink file with multiple links ============="
2129 opendirunlink $DIR/d31d $DIR/d31d || error
2130 $CHECKSTAT -a $DIR/d31d || error
2132 run_test 31d "remove of open directory ========================="
2134 test_31e() { # bug 2904
2135 check_kernel_version 34 || return 0
2136 openfilleddirunlink $DIR/d31e || error
2138 run_test 31e "remove of open non-empty directory ==============="
2140 test_31f() { # bug 4554
2141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2143 test_mkdir $DIR/d31f
2144 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2145 cp /etc/hosts $DIR/d31f
2147 $GETSTRIPE $DIR/d31f/hosts
2148 multiop_bg_pause $DIR/d31f D_c || return 1
2151 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2152 test_mkdir $DIR/d31f
2153 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2154 cp /etc/hosts $DIR/d31f
2156 $GETSTRIPE $DIR/d31f/hosts
2157 multiop_bg_pause $DIR/d31f D_c || return 1
2160 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2161 wait $MULTIPID || error "first opendir $MULTIPID failed"
2165 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2166 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2169 run_test 31f "remove of open directory with open-unlink file ==="
2172 echo "-- cross directory link --"
2173 test_mkdir -c1 $DIR/${tdir}ga
2174 test_mkdir -c1 $DIR/${tdir}gb
2175 touch $DIR/${tdir}ga/f
2176 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2177 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2178 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2179 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2180 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2182 run_test 31g "cross directory link==============="
2185 echo "-- cross directory link --"
2186 test_mkdir -c1 $DIR/${tdir}
2187 test_mkdir -c1 $DIR/${tdir}/dir
2188 touch $DIR/${tdir}/f
2189 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2190 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2191 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2192 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2193 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2195 run_test 31h "cross directory link under child==============="
2198 echo "-- cross directory link --"
2199 test_mkdir -c1 $DIR/$tdir
2200 test_mkdir -c1 $DIR/$tdir/dir
2201 touch $DIR/$tdir/dir/f
2202 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2203 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2204 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2205 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2206 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2208 run_test 31i "cross directory link under parent==============="
2211 test_mkdir -c1 -p $DIR/$tdir
2212 test_mkdir -c1 -p $DIR/$tdir/dir1
2213 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2214 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2215 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2216 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2219 run_test 31j "link for directory==============="
2222 test_mkdir -c1 -p $DIR/$tdir
2224 touch $DIR/$tdir/exist
2225 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2226 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2227 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2228 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2229 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2230 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2231 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2234 run_test 31k "link to file: the same, non-existing, dir==============="
2240 touch $DIR/d31m2/exist
2241 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2242 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2243 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2244 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2245 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2246 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2249 run_test 31m "link to file: the same, non-existing, dir==============="
2252 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2253 nlink=$(stat --format=%h $DIR/$tfile)
2254 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2256 local cmd="exec $fd<$DIR/$tfile"
2259 trap "eval $cmd" EXIT
2260 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2261 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2262 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2263 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2264 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2267 run_test 31n "check link count of unlinked file"
2270 local TEMPNAME=$(mktemp $1_XXXXXX)
2271 mlink $TEMPNAME $1 2> /dev/null &&
2272 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2276 test_31o() { # LU-2901
2278 for LOOP in $(seq 100); do
2279 rm -f $DIR/$tdir/$tfile*
2280 for THREAD in $(seq 8); do
2281 link_one $DIR/$tdir/$tfile.$LOOP &
2284 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2285 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2286 error "$LINKS duplicate links to $tfile.$LOOP" &&
2290 run_test 31o "duplicate hard links with same filename"
2293 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2296 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2297 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2299 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2300 error "open unlink test1 failed"
2301 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2302 error "open unlink test2 failed"
2304 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2305 error "test1 still exists"
2306 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2307 error "test2 still exists"
2309 run_test 31p "remove of open striped directory"
2311 cleanup_test32_mount() {
2313 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2318 echo "== more mountpoints and symlinks ================="
2319 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2320 trap cleanup_test32_mount EXIT
2321 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2322 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2323 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2324 cleanup_test32_mount
2326 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2330 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2331 trap cleanup_test32_mount EXIT
2332 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2333 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2334 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2335 cleanup_test32_mount
2337 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2342 trap cleanup_test32_mount EXIT
2343 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2344 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2345 test_mkdir -p $DIR/$tdir/d2/test_dir
2346 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2347 cleanup_test32_mount
2349 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2353 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2354 trap cleanup_test32_mount EXIT
2355 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2356 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2357 test_mkdir -p $DIR/$tdir/d2/test_dir
2358 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2359 cleanup_test32_mount
2361 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2364 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2365 test_mkdir -p $DIR/d32e/tmp
2366 TMP_DIR=$DIR/d32e/tmp
2367 ln -s $DIR/d32e $TMP_DIR/symlink11
2368 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2369 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2370 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2372 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2375 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2376 test_mkdir -p $DIR/d32f/tmp
2377 TMP_DIR=$DIR/d32f/tmp
2378 ln -s $DIR/d32f $TMP_DIR/symlink11
2379 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2380 ls $DIR/d32f/tmp/symlink11 || error
2381 ls $DIR/d32f/symlink01 || error
2383 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2386 TMP_DIR=$DIR/$tdir/tmp
2387 test_mkdir -p $DIR/$tdir/tmp
2388 test_mkdir $DIR/${tdir}2
2389 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2390 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2391 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2392 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2393 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2394 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2396 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2399 rm -fr $DIR/$tdir $DIR/${tdir}2
2400 TMP_DIR=$DIR/$tdir/tmp
2401 test_mkdir -p $DIR/$tdir/tmp
2402 test_mkdir $DIR/${tdir}2
2403 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2404 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2405 ls $TMP_DIR/symlink12 || error
2406 ls $DIR/$tdir/symlink02 || error
2408 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2412 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2413 trap cleanup_test32_mount EXIT
2414 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2415 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2416 touch $DIR/$tdir/test_file
2417 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2418 cleanup_test32_mount
2420 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2424 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2425 trap cleanup_test32_mount EXIT
2426 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2427 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2428 touch $DIR/$tdir/test_file
2429 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2430 cleanup_test32_mount
2432 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2437 trap cleanup_test32_mount EXIT
2438 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2439 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2440 test_mkdir -p $DIR/$tdir/d2
2441 touch $DIR/$tdir/d2/test_file || error
2442 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2443 cleanup_test32_mount
2445 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 trap cleanup_test32_mount EXIT
2451 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2452 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2453 test_mkdir -p $DIR/$tdir/d2
2454 touch $DIR/$tdir/d2/test_file
2455 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2456 cleanup_test32_mount
2458 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2462 test_mkdir -p $DIR/d32m/tmp
2463 TMP_DIR=$DIR/d32m/tmp
2464 ln -s $DIR $TMP_DIR/symlink11
2465 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2466 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2467 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2469 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2473 test_mkdir -p $DIR/d32n/tmp
2474 TMP_DIR=$DIR/d32n/tmp
2475 ln -s $DIR $TMP_DIR/symlink11
2476 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2477 ls -l $DIR/d32n/tmp/symlink11 || error
2478 ls -l $DIR/d32n/symlink01 || error
2480 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2484 test_mkdir -p $DIR/d32o/tmp
2485 TMP_DIR=$DIR/d32o/tmp
2486 ln -s $DIR/$tfile $TMP_DIR/symlink12
2487 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2488 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2489 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2490 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2491 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2493 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2503 test_mkdir -p $DIR/d32p/tmp
2505 TMP_DIR=$DIR/d32p/tmp
2507 ln -s $DIR/$tfile $TMP_DIR/symlink12
2509 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2511 cat $DIR/d32p/tmp/symlink12 || error
2513 cat $DIR/d32p/symlink02 || error
2516 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2518 cleanup_testdir_mount() {
2520 $UMOUNT -d $DIR/$tdir
2524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2525 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2526 trap cleanup_testdir_mount EXIT
2527 test_mkdir -p $DIR/$tdir
2528 touch $DIR/$tdir/under_the_mount
2529 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2530 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2531 cleanup_testdir_mount
2533 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2537 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2538 trap cleanup_testdir_mount EXIT
2539 test_mkdir -p $DIR/$tdir
2540 touch $DIR/$tdir/under_the_mount
2541 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2542 ls $DIR/$tdir | grep -q under_the_mount && error || true
2543 cleanup_testdir_mount
2545 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2550 chmod 444 $DIR/$tfile
2551 chown $RUNAS_ID $DIR/$tfile
2553 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2556 run_test 33aa "write file with mode 444 (should return error) ===="
2560 test_mkdir -p $DIR/d33
2561 chown $RUNAS_ID $DIR/d33
2562 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2563 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2564 error "open RDWR" || true
2566 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2570 test_mkdir -p $DIR/d33
2571 chown $RUNAS_ID $DIR/d33
2572 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2574 run_test 33b "test open file with malformed flags (No panic)"
2577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2583 remote_ost_nodsh && skip "remote OST with nodsh" && return
2586 test_mkdir -p $DIR/d33
2587 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2590 for ostnum in $(seq $OSTCOUNT); do
2591 # test-framework's OST numbering is one-based, while Lustre's
2593 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2594 # Parsing llobdstat's output sucks; we could grep the /proc
2595 # path, but that's likely to not be as portable as using the
2596 # llobdstat utility. So we parse lctl output instead.
2597 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2598 obdfilter/$ostname/stats |
2599 awk '/^write_bytes/ {print $7}' )
2600 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2601 if (( ${write_bytes:-0} > 0 ))
2608 $all_zeros || return 0
2611 echo foo > $DIR/d33/bar
2615 # Total up write_bytes after writing. We'd better find non-zeros.
2616 for ostnum in $(seq $OSTCOUNT); do
2617 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2618 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2619 obdfilter/$ostname/stats |
2620 awk '/^write_bytes/ {print $7}' )
2621 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2622 if (( ${write_bytes:-0} > 0 ))
2631 for ostnum in $(seq $OSTCOUNT); do
2632 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2633 echo "Check that write_bytes is present in obdfilter/*/stats:"
2634 do_facet ost$ostnum lctl get_param -n \
2635 obdfilter/$ostname/stats
2637 error "OST not keeping write_bytes stats (b22312)"
2640 run_test 33c "test llobdstat and write_bytes"
2643 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2646 local remote_dir=$DIR/$tdir/remote_dir
2649 $LFS mkdir -i $MDTIDX $remote_dir ||
2650 error "create remote directory failed"
2652 touch $remote_dir/$tfile
2653 chmod 444 $remote_dir/$tfile
2654 chown $RUNAS_ID $remote_dir/$tfile
2656 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2658 chown $RUNAS_ID $remote_dir
2659 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2660 error "create" || true
2661 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2662 error "open RDWR" || true
2663 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2664 error "create" || true
2666 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2669 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2673 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2674 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2675 mkdir $DIR/$tdir/local_dir
2677 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2678 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2679 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2681 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2682 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2684 rmdir $DIR/$tdir/* || error "rmdir failed"
2687 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2688 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2689 mkdir $DIR/$tdir/local_dir
2691 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2692 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2693 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2695 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2696 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2698 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2701 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2702 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2703 mkdir $DIR/$tdir/local_dir
2705 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2706 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2707 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2709 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2710 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2712 run_test 33e "mkdir and striped directory should have same mode"
2714 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2717 $MCREATE $DIR/f34 || error
2718 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2719 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2720 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2721 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2723 run_test 34a "truncate file that has not been opened ==========="
2726 [ ! -f $DIR/f34 ] && test_34a
2727 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2728 $OPENFILE -f O_RDONLY $DIR/f34
2729 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2730 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2732 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2735 [ ! -f $DIR/f34 ] && test_34a
2736 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2737 $OPENFILE -f O_RDWR $DIR/f34
2738 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2739 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2741 run_test 34c "O_RDWR opening file-with-size works =============="
2744 [ ! -f $DIR/f34 ] && test_34a
2745 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2746 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2749 run_test 34d "write to sparse file ============================="
2753 $MCREATE $DIR/f34e || error
2754 $TRUNCATE $DIR/f34e 1000 || error
2755 $CHECKSTAT -s 1000 $DIR/f34e || error
2756 $OPENFILE -f O_RDWR $DIR/f34e
2757 $CHECKSTAT -s 1000 $DIR/f34e || error
2759 run_test 34e "create objects, some with size and some without =="
2761 test_34f() { # bug 6242, 6243
2762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2765 $MCREATE $DIR/f34f || error
2766 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2767 dd if=$DIR/f34f of=$TMP/f34f
2768 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2769 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2770 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2771 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2772 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2774 run_test 34f "read from a file with no objects until EOF ======="
2777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2778 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2779 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2780 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2781 cancel_lru_locks osc
2782 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2783 error "wrong size after lock cancel"
2785 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2786 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2787 error "expanding truncate failed"
2788 cancel_lru_locks osc
2789 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2790 error "wrong expanded size after lock cancel"
2792 run_test 34g "truncate long file ==============================="
2795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2799 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2800 sync # Flush the cache so that multiop below does not block on cache
2801 # flush when getting the group lock
2802 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2805 # Since just timed wait is not good enough, let's do a sync write
2806 # that way we are sure enough time for a roundtrip + processing
2807 # passed + 2 seconds of extra margin.
2808 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2812 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2813 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2817 local nsz=`stat -c %s $DIR/$tfile`
2818 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2820 run_test 34h "ftruncate file under grouplock should not block"
2823 cp /bin/sh $DIR/f35a
2825 chown $RUNAS_ID $DIR/f35a
2826 $RUNAS $DIR/f35a && error || true
2829 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2833 utime $DIR/f36 || error
2835 run_test 36a "MDS utime check (mknod, utime) ==================="
2839 utime $DIR/f36 || error
2841 run_test 36b "OST utime check (open, utime) ===================="
2846 chown $RUNAS_ID $DIR/d36
2847 $RUNAS utime $DIR/d36/f36 || error
2849 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2852 [ ! -d $DIR/d36 ] && test_36c
2853 echo "" > $DIR/d36/f36
2854 $RUNAS utime $DIR/d36/f36 || error
2856 run_test 36d "non-root OST utime check (open, utime) ==========="
2859 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2860 test_mkdir -p $DIR/$tdir
2861 touch $DIR/$tdir/$tfile
2862 $RUNAS utime $DIR/$tdir/$tfile && \
2863 error "utime worked, expected failure" || true
2865 run_test 36e "utime on non-owned file (should return error) ===="
2869 local LANG_SAVE=$LANG
2870 local LC_LANG_SAVE=$LC_LANG
2871 export LANG=C LC_LANG=C # for date language
2873 DATESTR="Dec 20 2000"
2874 test_mkdir -p $DIR/$tdir
2875 lctl set_param fail_loc=$fl
2877 cp /etc/hosts $DIR/$tdir/$tfile
2878 sync & # write RPC generated with "current" inode timestamp, but delayed
2880 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2881 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2882 cancel_lru_locks osc
2883 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2885 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2886 echo "BEFORE: $LS_BEFORE" && \
2887 echo "AFTER : $LS_AFTER" && \
2888 echo "WANT : $DATESTR" && \
2889 error "$DIR/$tdir/$tfile timestamps changed" || true
2891 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2896 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2897 subr_36fh "0x80000214"
2899 run_test 36f "utime on file racing with OST BRW write =========="
2902 remote_ost_nodsh && skip "remote OST with nodsh" && return
2903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2908 test_mkdir -p $DIR/$tdir
2909 fmd_max_age=$(do_facet ost1 \
2910 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2913 fmd_before=$(do_facet ost1 \
2914 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2915 touch $DIR/$tdir/$tfile
2916 sleep $((fmd_max_age + 12))
2917 fmd_after=$(do_facet ost1 \
2918 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2920 echo "fmd_before: $fmd_before"
2921 echo "fmd_after: $fmd_after"
2922 [[ $fmd_after -gt $fmd_before ]] &&
2923 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2924 error "fmd didn't expire after ping" || true
2926 run_test 36g "filter mod data cache expiry ====================="
2929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2930 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2931 subr_36fh "0x80000227"
2933 run_test 36h "utime on file racing with OST BRW write =========="
2936 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2939 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2941 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2942 local new_mtime=$((mtime + 200))
2944 #change Modify time of striped dir
2945 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2946 error "change mtime failed"
2948 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2950 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2952 run_test 36i "change mtime on striped directory"
2954 # test_37 - duplicate with tests 32q 32r
2957 local file=$DIR/$tfile
2959 openfile -f O_DIRECTORY $file
2962 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2963 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2965 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2969 touch $DIR/${tfile}2
2970 # ls -l $DIR/$tfile $DIR/${tfile}2
2971 # ls -lu $DIR/$tfile $DIR/${tfile}2
2972 # ls -lc $DIR/$tfile $DIR/${tfile}2
2974 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2975 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2977 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2979 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2981 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2982 error "O_TRUNC didn't change timestamps"
2985 run_test 39 "mtime changed on create ==========================="
2988 test_mkdir -p -c1 $DIR/$tdir
2989 cp -p /etc/passwd $DIR/$tdir/fopen
2990 cp -p /etc/passwd $DIR/$tdir/flink
2991 cp -p /etc/passwd $DIR/$tdir/funlink
2992 cp -p /etc/passwd $DIR/$tdir/frename
2993 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2996 echo "aaaaaa" >> $DIR/$tdir/fopen
2997 echo "aaaaaa" >> $DIR/$tdir/flink
2998 echo "aaaaaa" >> $DIR/$tdir/funlink
2999 echo "aaaaaa" >> $DIR/$tdir/frename
3001 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3002 local link_new=`stat -c %Y $DIR/$tdir/flink`
3003 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3004 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3006 cat $DIR/$tdir/fopen > /dev/null
3007 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3008 rm -f $DIR/$tdir/funlink2
3009 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3011 for (( i=0; i < 2; i++ )) ; do
3012 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3013 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3014 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3015 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3017 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3018 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3019 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3020 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3022 cancel_lru_locks osc
3023 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3026 run_test 39b "mtime change on open, link, unlink, rename ======"
3028 # this should be set to past
3029 TEST_39_MTIME=`date -d "1 year ago" +%s`
3035 local mtime0=`stat -c %Y $DIR1/$tfile`
3037 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3038 local mtime1=`stat -c %Y $DIR1/$tfile`
3039 [ "$mtime1" = $TEST_39_MTIME ] || \
3040 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3043 echo hello >> $DIR1/$tfile
3045 local mtime2=`stat -c %Y $DIR1/$tfile`
3046 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3047 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3049 mv $DIR1/$tfile $DIR1/$tfile-1
3051 for (( i=0; i < 2; i++ )) ; do
3052 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3053 [ "$mtime2" = "$mtime3" ] || \
3054 error "mtime ($mtime2) changed (to $mtime3) on rename"
3056 cancel_lru_locks osc
3057 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3060 run_test 39c "mtime change on rename ==========================="
3064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3067 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3069 for (( i=0; i < 2; i++ )) ; do
3070 local mtime=`stat -c %Y $DIR1/$tfile`
3071 [ $mtime = $TEST_39_MTIME ] || \
3072 error "mtime($mtime) is not set to $TEST_39_MTIME"
3074 cancel_lru_locks osc
3075 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3078 run_test 39d "create, utime, stat =============================="
3082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 local mtime1=`stat -c %Y $DIR1/$tfile`
3086 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3088 for (( i=0; i < 2; i++ )) ; do
3089 local mtime2=`stat -c %Y $DIR1/$tfile`
3090 [ $mtime2 = $TEST_39_MTIME ] || \
3091 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3093 cancel_lru_locks osc
3094 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3097 run_test 39e "create, stat, utime, stat ========================"
3101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3103 mtime1=`stat -c %Y $DIR1/$tfile`
3106 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3108 for (( i=0; i < 2; i++ )) ; do
3109 local mtime2=`stat -c %Y $DIR1/$tfile`
3110 [ $mtime2 = $TEST_39_MTIME ] || \
3111 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3113 cancel_lru_locks osc
3114 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3117 run_test 39f "create, stat, sleep, utime, stat ================="
3121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3122 echo hello >> $DIR1/$tfile
3123 local mtime1=`stat -c %Y $DIR1/$tfile`
3126 chmod o+r $DIR1/$tfile
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3130 [ "$mtime1" = "$mtime2" ] || \
3131 error "lost mtime: $mtime2, should be $mtime1"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3137 run_test 39g "write, chmod, stat ==============================="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3146 echo hello >> $DIR1/$tfile
3147 local mtime1=`stat -c %Y $DIR1/$tfile`
3149 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3151 if [ "$d1" != "$d2" ]; then
3152 echo "write and touch not within one second"
3154 for (( i=0; i < 2; i++ )) ; do
3155 local mtime2=`stat -c %Y $DIR1/$tfile`
3156 [ "$mtime2" = $TEST_39_MTIME ] || \
3157 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3159 cancel_lru_locks osc
3160 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3164 run_test 39h "write, utime within one second, stat ============="
3167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3171 echo hello >> $DIR1/$tfile
3172 local mtime1=`stat -c %Y $DIR1/$tfile`
3174 mv $DIR1/$tfile $DIR1/$tfile-1
3176 for (( i=0; i < 2; i++ )) ; do
3177 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3179 [ "$mtime1" = "$mtime2" ] || \
3180 error "lost mtime: $mtime2, should be $mtime1"
3182 cancel_lru_locks osc
3183 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3186 run_test 39i "write, rename, stat =============================="
3189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3190 start_full_debug_logging
3194 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3195 lctl set_param fail_loc=0x80000412
3196 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3197 error "multiop failed"
3199 local mtime1=`stat -c %Y $DIR1/$tfile`
3201 mv $DIR1/$tfile $DIR1/$tfile-1
3203 kill -USR1 $multipid
3204 wait $multipid || error "multiop close failed"
3206 for (( i=0; i < 2; i++ )) ; do
3207 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3208 [ "$mtime1" = "$mtime2" ] ||
3209 error "mtime is lost on close: $mtime2, " \
3212 cancel_lru_locks osc
3213 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3215 lctl set_param fail_loc=0
3216 stop_full_debug_logging
3218 run_test 39j "write, rename, close, stat ======================="
3221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3225 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3227 local mtime1=`stat -c %Y $DIR1/$tfile`
3229 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3231 kill -USR1 $multipid
3232 wait $multipid || error "multiop close failed"
3234 for (( i=0; i < 2; i++ )) ; do
3235 local mtime2=`stat -c %Y $DIR1/$tfile`
3237 [ "$mtime2" = $TEST_39_MTIME ] || \
3238 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3240 cancel_lru_locks osc
3241 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3244 run_test 39k "write, utime, close, stat ========================"
3246 # this should be set to future
3247 TEST_39_ATIME=`date -d "1 year" +%s`
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3251 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3252 local atime_diff=$(do_facet $SINGLEMDS \
3253 lctl get_param -n mdd.*MDT0000*.atime_diff)
3257 # test setting directory atime to future
3258 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3259 local atime=$(stat -c %X $DIR/$tdir)
3260 [ "$atime" = $TEST_39_ATIME ] || \
3261 error "atime is not set to future: $atime, $TEST_39_ATIME"
3263 # test setting directory atime from future to now
3264 local d1=$(date +%s)
3266 local d2=$(date +%s)
3268 cancel_lru_locks mdc
3269 atime=$(stat -c %X $DIR/$tdir)
3270 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3271 error "atime is not updated from future: $atime, $d1<atime<$d2"
3273 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3276 # test setting directory atime when now > dir atime + atime_diff
3280 cancel_lru_locks mdc
3281 atime=$(stat -c %X $DIR/$tdir)
3282 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3283 error "atime is not updated : $atime, should be $d2"
3285 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3288 # test not setting directory atime when now < dir atime + atime_diff
3290 cancel_lru_locks mdc
3291 atime=$(stat -c %X $DIR/$tdir)
3292 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3293 error "atime is updated to $atime, should remain $d1<atime<$d2"
3295 do_facet $SINGLEMDS \
3296 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3298 run_test 39l "directory atime update ==========================="
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3304 local far_past_mtime=$(date -d "May 29 1953" +%s)
3305 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3307 touch -m -d @$far_past_mtime $DIR1/$tfile
3308 touch -a -d @$far_past_atime $DIR1/$tfile
3310 for (( i=0; i < 2; i++ )) ; do
3311 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3312 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3313 error "atime or mtime set incorrectly"
3315 cancel_lru_locks osc
3316 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3319 run_test 39m "test atime and mtime before 1970"
3321 test_39n() { # LU-3832
3322 local atime_diff=$(do_facet $SINGLEMDS \
3323 lctl get_param -n mdd.*MDT0000*.atime_diff)
3328 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3331 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3332 atime0=$(stat -c %X $DIR/$tfile)
3335 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3336 atime1=$(stat -c %X $DIR/$tfile)
3339 cancel_lru_locks mdc
3340 cancel_lru_locks osc
3341 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3342 atime2=$(stat -c %X $DIR/$tfile)
3344 do_facet $SINGLEMDS \
3345 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3347 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3348 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3350 run_test 39n "check that O_NOATIME is honored"
3353 TESTDIR=$DIR/$tdir/$tfile
3354 [ -e $TESTDIR ] && rm -rf $TESTDIR
3355 test_mkdir -p $TESTDIR
3361 links2=$(stat -c %h .)
3362 [ $(($links1 + 2)) != $links2 ] &&
3363 error "wrong links count $(($links1 + 2)) != $links2"
3365 links3=$(stat -c %h .)
3366 [ $(($links1 + 1)) != $links3 ] &&
3367 error "wrong links count $links1 != $links3"
3370 run_test 39o "directory cached attributes updated after create ========"
3373 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3375 TESTDIR=$DIR/$tdir/$tfile
3376 [ -e $TESTDIR ] && rm -rf $TESTDIR
3381 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3382 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3384 links2=$(stat -c %h .)
3385 [ $(($links1 + 2)) != $links2 ] &&
3386 error "wrong links count $(($links1 + 2)) != $links2"
3388 links3=$(stat -c %h .)
3389 [ $(($links1 + 1)) != $links3 ] &&
3390 error "wrong links count $links1 != $links3"
3393 run_test 39p "remote directory cached attributes updated after create ========"
3397 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3398 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3399 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3400 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3401 error "$tfile is not 4096 bytes in size"
3403 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3407 small_write $DIR/f41 18
3409 run_test 41 "test small file write + fstat ====================="
3411 count_ost_writes() {
3412 lctl get_param -n osc.*.stats |
3413 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3414 END { printf("%0.0f", writes) }'
3421 BG_DIRTY_RATIO_SAVE=10
3422 MAX_BG_DIRTY_RATIO=25
3426 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3427 # dirty_ratio, dirty_background_ratio
3428 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3429 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3430 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3431 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3433 # if file not here, we are a 2.4 kernel
3434 kill -CONT `pidof kupdated`
3439 # setup the trap first, so someone cannot exit the test at the
3440 # exact wrong time and mess up a machine
3441 trap start_writeback EXIT
3442 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3443 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3444 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3445 sysctl -w vm.dirty_writeback_centisecs=0
3446 sysctl -w vm.dirty_writeback_centisecs=0
3447 # save and increase /proc/sys/vm/dirty_ratio
3448 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3449 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3450 # save and increase /proc/sys/vm/dirty_background_ratio
3451 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3452 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3454 # if file not here, we are a 2.4 kernel
3455 kill -STOP `pidof kupdated`
3459 # ensure that all stripes have some grant before we test client-side cache
3461 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3462 dd if=/dev/zero of=$i bs=4k count=1
3467 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3468 # file truncation, and file removal.
3470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3472 cancel_lru_locks osc
3474 sync; sleep 1; sync # just to be safe
3475 BEFOREWRITES=`count_ost_writes`
3476 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3477 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3478 AFTERWRITES=`count_ost_writes`
3479 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3480 error "$BEFOREWRITES < $AFTERWRITES"
3483 run_test 42a "ensure that we don't flush on close =============="
3486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3488 cancel_lru_locks osc
3491 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3492 BEFOREWRITES=$(count_ost_writes)
3493 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3494 AFTERWRITES=$(count_ost_writes)
3495 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3496 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3498 BEFOREWRITES=$(count_ost_writes)
3499 sync || error "sync: $?"
3500 AFTERWRITES=$(count_ost_writes)
3501 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3502 error "$BEFOREWRITES < $AFTERWRITES on sync"
3504 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3508 run_test 42b "test destroy of file with cached dirty data ======"
3510 # if these tests just want to test the effect of truncation,
3511 # they have to be very careful. consider:
3512 # - the first open gets a {0,EOF}PR lock
3513 # - the first write conflicts and gets a {0, count-1}PW
3514 # - the rest of the writes are under {count,EOF}PW
3515 # - the open for truncate tries to match a {0,EOF}PR
3516 # for the filesize and cancels the PWs.
3517 # any number of fixes (don't get {0,EOF} on open, match
3518 # composite locks, do smarter file size management) fix
3519 # this, but for now we want these tests to verify that
3520 # the cancellation with truncate intent works, so we
3521 # start the file with a full-file pw lock to match against
3522 # until the truncate.
3527 cancel_lru_locks osc
3529 # prime the file with 0,EOF PW to match
3533 # now the real test..
3534 dd if=/dev/zero of=$file bs=1024 count=100
3535 BEFOREWRITES=`count_ost_writes`
3536 $TRUNCATE $file $offset
3537 cancel_lru_locks osc
3538 AFTERWRITES=`count_ost_writes`
3543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3545 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3546 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3549 run_test 42c "test partial truncate of file with cached dirty data"
3552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3554 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3555 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3558 run_test 42d "test complete truncate of file with cached dirty data"
3560 test_42e() { # bug22074
3561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3562 local TDIR=$DIR/${tdir}e
3563 local pagesz=$(page_size)
3564 local pages=16 # hardcoded 16 pages, don't change it.
3565 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3566 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3570 test_mkdir -p $DIR/${tdir}e
3571 $SETSTRIPE -c 1 $TDIR
3572 createmany -o $TDIR/f $files
3574 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3576 # we assume that with $OSTCOUNT files, at least one of them will
3577 # be allocated on OST0.
3578 warmup_files=$((OSTCOUNT * max_dirty_mb))
3579 createmany -o $TDIR/w $warmup_files
3581 # write a large amount of data into one file and sync, to get good
3582 # avail_grant number from OST.
3583 for ((i=0; i<$warmup_files; i++)); do
3584 idx=$($GETSTRIPE -i $TDIR/w$i)
3585 [ $idx -ne 0 ] && continue
3586 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3589 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3591 $LCTL get_param $proc_osc0/cur_dirty_bytes
3592 $LCTL get_param $proc_osc0/cur_grant_bytes
3594 # create as much dirty pages as we can while not to trigger the actual
3595 # RPCs directly. but depends on the env, VFS may trigger flush during this
3596 # period, hopefully we are good.
3597 for ((i=0; i<$warmup_files; i++)); do
3598 idx=$($GETSTRIPE -i $TDIR/w$i)
3599 [ $idx -ne 0 ] && continue
3600 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3602 $LCTL get_param $proc_osc0/cur_dirty_bytes
3603 $LCTL get_param $proc_osc0/cur_grant_bytes
3605 # perform the real test
3606 $LCTL set_param $proc_osc0/rpc_stats 0
3607 for ((;i<$files; i++)); do
3608 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3609 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3612 $LCTL get_param $proc_osc0/rpc_stats
3615 local have_ppr=false
3616 $LCTL get_param $proc_osc0/rpc_stats |
3617 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3618 # skip lines until we are at the RPC histogram data
3619 [ "$PPR" == "pages" ] && have_ppr=true && continue
3620 $have_ppr || continue
3622 # we only want the percent stat for < 16 pages
3623 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3625 percent=$((percent + WPCT))
3626 if [[ $percent -gt 15 ]]; then
3627 error "less than 16-pages write RPCs" \
3634 run_test 42e "verify sub-RPC writes are not done synchronously"
3637 test_mkdir -p $DIR/$tdir
3638 cp -p /bin/ls $DIR/$tdir/$tfile
3639 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3641 # give multiop a chance to open
3644 $DIR/$tdir/$tfile && error || true
3647 run_test 43 "execution of file opened for write should return -ETXTBSY"
3650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3651 test_mkdir -p $DIR/$tdir
3652 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3653 cp -p multiop $DIR/$tdir/multiop
3654 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3657 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3658 kill -USR1 $MULTIOP_PID || return 2
3659 wait $MULTIOP_PID || return 3
3660 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3662 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3666 test_mkdir -p $DIR/$tdir
3667 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3668 cp -p multiop $DIR/$tdir/multiop
3669 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3672 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3673 kill -USR1 $MULTIOP_PID || return 2
3674 wait $MULTIOP_PID || return 3
3675 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3677 run_test 43b "truncate of file being executed should return -ETXTBSY"
3680 local testdir="$DIR/$tdir"
3681 test_mkdir -p $DIR/$tdir
3683 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3684 ( cd $testdir && md5sum -c)
3686 run_test 43c "md5sum of copy into lustre========================"
3689 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3690 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3691 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3693 run_test 44 "zero length read from a sparse stripe ============="
3696 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3698 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3699 [[ $nstripe -gt $OSTCOUNT ]] &&
3700 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3702 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3704 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3705 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3709 OFFSETS="0 $((stride/2)) $((stride-1))"
3710 for offset in $OFFSETS; do
3711 for i in $(seq 0 $((nstripe-1))); do
3712 local GLOBALOFFSETS=""
3714 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3715 local myfn=$DIR/d44a-$size
3716 echo "--------writing $myfn at $size"
3717 ll_sparseness_write $myfn $size ||
3718 error "ll_sparseness_write"
3719 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3720 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3721 error "ll_sparseness_verify $GLOBALOFFSETS"
3723 for j in $(seq 0 $((nstripe-1))); do
3725 size=$((((j + $nstripe )*$stride + $offset)))
3726 ll_sparseness_write $myfn $size ||
3727 error "ll_sparseness_write"
3728 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3730 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3731 error "ll_sparseness_verify $GLOBALOFFSETS"
3736 run_test 44a "test sparse pwrite ==============================="
3740 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3746 before=`dirty_osc_total`
3747 echo executing "\"$*\""
3749 after=`dirty_osc_total`
3750 echo before $before, after $after
3753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3755 # Obtain grants from OST if it supports it
3756 echo blah > ${f}_grant
3759 do_dirty_record "echo blah > $f"
3760 [[ $before -eq $after ]] && error "write wasn't cached"
3761 do_dirty_record "> $f"
3762 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3763 do_dirty_record "echo blah > $f"
3764 [[ $before -eq $after ]] && error "write wasn't cached"
3765 do_dirty_record "sync"
3766 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3767 do_dirty_record "echo blah > $f"
3768 [[ $before -eq $after ]] && error "write wasn't cached"
3769 do_dirty_record "cancel_lru_locks osc"
3770 [[ $before -gt $after ]] ||
3771 error "lock cancellation didn't lower dirty count"
3774 run_test 45 "osc io page accounting ============================"
3776 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3777 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3778 # objects offset and an assert hit when an rpc was built with 1023's mapped
3779 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3785 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3787 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3788 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3792 run_test 46 "dirtying a previously written page ================"
3794 # test_47 is removed "Device nodes check" is moved to test_28
3796 test_48a() { # bug 2399
3797 check_kernel_version 34 || return 0
3798 test_mkdir -p $DIR/$tdir
3800 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3801 test_mkdir $DIR/$tdir || error "recreate directory failed"
3802 touch foo || error "'touch foo' failed after recreating cwd"
3803 test_mkdir $DIR/$tdir/bar ||
3804 error "'mkdir foo' failed after recreating cwd"
3805 if check_kernel_version 44; then
3806 touch .foo || error "'touch .foo' failed after recreating cwd"
3807 test_mkdir $DIR/$tdir/.bar ||
3808 error "'mkdir .foo' failed after recreating cwd"
3810 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3811 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3812 cd . || error "'cd .' failed after recreating cwd"
3813 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3814 rmdir . && error "'rmdir .' worked after recreating cwd"
3815 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3816 cd .. || error "'cd ..' failed after recreating cwd"
3818 run_test 48a "Access renamed working dir (should return errors)="
3820 test_48b() { # bug 2399
3821 check_kernel_version 34 || return 0
3823 test_mkdir -p $DIR/$tdir
3825 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3826 touch foo && error "'touch foo' worked after removing cwd"
3827 test_mkdir $DIR/$tdir/foo &&
3828 error "'mkdir foo' worked after removing cwd"
3829 if check_kernel_version 44; then
3830 touch .foo && error "'touch .foo' worked after removing cwd"
3831 test_mkdir $DIR/$tdir/.foo &&
3832 error "'mkdir .foo' worked after removing cwd"
3834 ls . > /dev/null && error "'ls .' worked after removing cwd"
3835 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3836 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3837 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3838 rmdir . && error "'rmdir .' worked after removing cwd"
3839 ln -s . foo && error "'ln -s .' worked after removing cwd"
3840 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3842 run_test 48b "Access removed working dir (should return errors)="
3844 test_48c() { # bug 2350
3845 check_kernel_version 36 || return 0
3846 #lctl set_param debug=-1
3849 test_mkdir -p $DIR/$tdir/dir
3851 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3852 $TRACE touch foo && error "touch foo worked after removing cwd"
3853 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3854 if check_kernel_version 44; then
3855 touch .foo && error "touch .foo worked after removing cwd"
3856 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3858 $TRACE ls . && error "'ls .' worked after removing cwd"
3859 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3860 is_patchless || ( $TRACE cd . &&
3861 error "'cd .' worked after removing cwd" )
3862 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3863 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3864 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3865 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3867 run_test 48c "Access removed working subdir (should return errors)"
3869 test_48d() { # bug 2350
3870 check_kernel_version 36 || return 0
3871 #lctl set_param debug=-1
3874 test_mkdir -p $DIR/$tdir/dir
3876 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3877 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3878 $TRACE touch foo && error "'touch foo' worked after removing parent"
3879 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3880 if check_kernel_version 44; then
3881 touch .foo && error "'touch .foo' worked after removing parent"
3883 error "mkdir .foo worked after removing parent"
3885 $TRACE ls . && error "'ls .' worked after removing parent"
3886 $TRACE ls .. && error "'ls ..' worked after removing parent"
3887 is_patchless || ( $TRACE cd . &&
3888 error "'cd .' worked after recreate parent" )
3889 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3890 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3891 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3892 is_patchless || ( $TRACE cd .. &&
3893 error "'cd ..' worked after removing parent" || true )
3895 run_test 48d "Access removed parent subdir (should return errors)"
3897 test_48e() { # bug 4134
3898 check_kernel_version 41 || return 0
3899 #lctl set_param debug=-1
3902 test_mkdir -p $DIR/$tdir/dir
3904 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3905 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3906 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3907 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3908 # On a buggy kernel addition of "touch foo" after cd .. will
3909 # produce kernel oops in lookup_hash_it
3910 touch ../foo && error "'cd ..' worked after recreate parent"