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-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
110 awk '{ gsub(/_UUID/,""); print $1 }' | head -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 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
562 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
563 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
565 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
566 skip "only for ldiskfs MDT" && return 0
568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
572 # create a long symlink file
573 for ((i = 0; i < 4; ++i)); do
574 long_sym=${long_sym}${long_sym}
577 echo "create 512 short and long symlink files under $WDIR"
578 for ((i = 0; i < 256; ++i)); do
579 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
580 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
586 wait_delete_completed
588 echo "recreate the 512 symlink files with a shorter string"
589 for ((i = 0; i < 512; ++i)); do
590 # rewrite the symlink file with a shorter string
591 ln -sf ${long_sym} $WDIR/long-$i
592 ln -sf ${short_sym} $WDIR/short-$i
595 mds_index=$($LFS getstripe -M $WDIR)
596 mds_index=$((mds_index+1))
597 devname=$(mdsdevname $mds_index)
598 cmd="$E2FSCK -fnvd $devname"
600 echo "stop and checking mds${mds_index}: $cmd"
601 # e2fsck should not return error
603 do_facet mds${mds_index} $cmd || rc=$?
605 start mds${mds_index} $devname $MDS_MOUNT_OPTS
606 df $MOUNT > /dev/null 2>&1
607 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
608 "short/long symlink MDT: rc=$rc"
611 run_test 17m "run e2fsck against MDT which contains short/long symlink"
613 check_fs_consistency_17n() {
619 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
620 # so it only check MDT1/MDT2 instead of all of MDTs.
621 for mdt_index in $(seq 1 2); do
622 devname=$(mdsdevname $mdt_index)
623 cmd="$E2FSCK -fnvd $devname"
625 echo "stop and checking mds${mdt_index}: $cmd"
626 # e2fsck should not return error
628 do_facet mds${mdt_index} $cmd || rc=$?
630 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
631 df $MOUNT > /dev/null 2>&1
632 [ $rc -ne 0 ] && break
640 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
641 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
642 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
644 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
645 skip "only for ldiskfs MDT" && return 0
647 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
652 for ((i=0; i<10; i++)); do
653 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
654 error "create remote dir error $i"
655 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
656 error "create files under remote dir failed $i"
659 check_fs_consistency_17n ||
660 error "e2fsck report error after create files under remote dir"
662 for ((i=0;i<10;i++)); do
663 rm -rf $DIR/$tdir/remote_dir_${i} ||
664 error "destroy remote dir error $i"
667 check_fs_consistency_17n ||
668 error "e2fsck report error after unlink files under remote dir"
670 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
671 skip "lustre < 2.4.50 does not support migrate mv " && return
673 for ((i=0; i<10; i++)); do
674 mkdir -p $DIR/$tdir/remote_dir_${i}
675 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
676 error "create files under remote dir failed $i"
677 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
678 error "migrate remote dir error $i"
680 check_fs_consistency_17n || error "e2fsck report error after migration"
682 for ((i=0;i<10;i++)); do
683 rm -rf $DIR/$tdir/remote_dir_${i} ||
684 error "destroy remote dir error $i"
687 check_fs_consistency_17n || error "e2fsck report error after unlink"
689 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
692 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
693 skip "Need MDS version at least 2.3.64" && return
695 local WDIR=$DIR/${tdir}o
701 mdt_index=$($LFS getstripe -M $WDIR)
702 mdt_index=$((mdt_index+1))
703 mdtdevname=$(mdsdevname $mdt_index)
707 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
709 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
710 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
711 ls -l $WDIR/$tfile && rc=1
712 do_facet mds${mdt_index} lctl set_param fail_loc=0
713 [[ $rc -ne 0 ]] && error "stat file should fail"
716 run_test 17o "stat file with incompat LMA feature"
719 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
720 ls $DIR || error "Failed to ls $DIR: $?"
722 run_test 18 "touch .../f ; ls ... =============================="
728 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
730 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
733 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
735 run_test 19b "ls -l .../f19 (should return error) =============="
738 [ $RUNAS_ID -eq $UID ] &&
739 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
740 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
742 run_test 19c "$RUNAS touch .../f19 (should return error) =="
745 cat $DIR/f19 && error || true
747 run_test 19d "cat .../f19 (should return error) =============="
759 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
761 run_test 20 "touch .../f ; ls -l ... ==========================="
764 test_mkdir -p $DIR/$tdir
765 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
766 ln -s dangle $DIR/$tdir/link
767 echo foo >> $DIR/$tdir/link
768 cat $DIR/$tdir/dangle
769 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
770 $CHECKSTAT -f -t file $DIR/$tdir/link ||
771 error "$tdir/link not linked to a file"
773 run_test 21 "write to dangling link ============================"
777 test_mkdir -p $DIR/$tdir
778 chown $RUNAS_ID:$RUNAS_GID $WDIR
779 (cd $WDIR || error "cd $WDIR failed";
780 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
782 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
783 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
784 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
786 run_test 22 "unpack tar archive as non-root user ==============="
790 test_mkdir -p $DIR/$tdir
791 local file=$DIR/$tdir/$tfile
793 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
794 openfile -f O_CREAT:O_EXCL $file &&
795 error "$file recreate succeeded" || true
797 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
799 test_23b() { # bug 18988
800 test_mkdir -p $DIR/$tdir
801 local file=$DIR/$tdir/$tfile
804 echo foo > $file || error "write filed"
805 echo bar >> $file || error "append filed"
806 $CHECKSTAT -s 8 $file || error "wrong size"
809 run_test 23b "O_APPEND check =========================="
813 echo '-- same directory rename'
814 test_mkdir $DIR/$tdir
815 touch $DIR/$tdir/$tfile.1
816 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24a "rename file to non-existent target"
822 test_mkdir $DIR/$tdir
823 touch $DIR/$tdir/$tfile.{1,2}
824 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
825 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
826 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
828 run_test 24b "rename file to existing target"
831 test_mkdir $DIR/$tdir
832 test_mkdir $DIR/$tdir/d$testnum.1
833 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
834 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
835 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
837 run_test 24c "rename directory to non-existent target"
840 test_mkdir -c1 $DIR/$tdir
841 test_mkdir -c1 $DIR/$tdir/d$testnum.1
842 test_mkdir -c1 $DIR/$tdir/d$testnum.2
843 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
844 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
845 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
847 run_test 24d "rename directory to existing target"
850 echo '-- cross directory renames --'
854 mv $DIR/R5a/f $DIR/R5b/g
855 $CHECKSTAT -a $DIR/R5a/f || error
856 $CHECKSTAT -t file $DIR/R5b/g || error
858 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
863 touch $DIR/R6a/f $DIR/R6b/g
864 mv $DIR/R6a/f $DIR/R6b/g
865 $CHECKSTAT -a $DIR/R6a/f || error
866 $CHECKSTAT -t file $DIR/R6b/g || error
868 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
873 test_mkdir $DIR/R7a/d
874 mv $DIR/R7a/d $DIR/R7b/e
875 $CHECKSTAT -a $DIR/R7a/d || error
876 $CHECKSTAT -t dir $DIR/R7b/e || error
878 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
881 test_mkdir -c1 $DIR/R8a
882 test_mkdir -c1 $DIR/R8b
883 test_mkdir -c1 $DIR/R8a/d
884 test_mkdir -c1 $DIR/R8b/e
885 mrename $DIR/R8a/d $DIR/R8b/e
886 $CHECKSTAT -a $DIR/R8a/d || error
887 $CHECKSTAT -t dir $DIR/R8b/e || error
889 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
892 echo "-- rename error cases"
896 mrename $DIR/R9/f $DIR/R9/a
897 $CHECKSTAT -t file $DIR/R9/f || error
898 $CHECKSTAT -t dir $DIR/R9/a || error
899 $CHECKSTAT -a $DIR/R9/a/f || error
901 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
905 mrename $DIR/R10/f $DIR/R10/g
906 $CHECKSTAT -t dir $DIR/R10 || error
907 $CHECKSTAT -a $DIR/R10/f || error
908 $CHECKSTAT -a $DIR/R10/g || error
910 run_test 24j "source does not exist ============================"
914 test_mkdir $DIR/R11a/d
916 mv $DIR/R11a/f $DIR/R11a/d
917 $CHECKSTAT -a $DIR/R11a/f || error
918 $CHECKSTAT -t file $DIR/R11a/d/f || error
920 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
922 # bug 2429 - rename foo foo foo creates invalid file
925 $MULTIOP $f OcNs || error
927 run_test 24l "Renaming a file to itself ========================"
931 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
932 # on ext3 this does not remove either the source or target files
933 # though the "expected" operation would be to remove the source
934 $CHECKSTAT -t file ${f} || error "${f} missing"
935 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
937 run_test 24m "Renaming a file to a hard link to itself ========="
941 # this stats the old file after it was renamed, so it should fail
945 $CHECKSTAT ${f}.rename
948 run_test 24n "Statting the old file after renaming (Posix rename 2)"
951 check_kernel_version 37 || return 0
952 test_mkdir -p $DIR/d24o
953 rename_many -s random -v -n 10 $DIR/d24o
955 run_test 24o "rename of files during htree split ==============="
960 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
961 mrename $DIR/R12a $DIR/R12b
962 $CHECKSTAT -a $DIR/R12a || error
963 $CHECKSTAT -t dir $DIR/R12b || error
964 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
965 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
967 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
969 cleanup_multiop_pause() {
975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
978 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
979 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
982 trap cleanup_multiop_pause EXIT
983 mrename $DIR/R13a $DIR/R13b
984 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
985 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
986 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
987 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
988 cleanup_multiop_pause
989 wait $MULTIPID || error "multiop close failed"
991 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
993 test_24r() { #bug 3789
995 test_mkdir $DIR/R14a/b
996 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
997 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
998 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1000 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1003 test_mkdir $DIR/R15a
1004 test_mkdir $DIR/R15a/b
1005 test_mkdir $DIR/R15a/b/c
1006 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1007 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1008 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1010 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1012 test_mkdir $DIR/R16a
1013 test_mkdir $DIR/R16a/b
1014 test_mkdir $DIR/R16a/b/c
1015 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1016 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1017 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1019 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1021 test_24u() { # bug12192
1022 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1023 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1025 run_test 24u "create stripe file"
1031 simple_cleanup_common() {
1034 wait_delete_completed
1037 max_pages_per_rpc() {
1038 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1042 local NRFILES=100000
1043 local FREE_INODES=$(mdt_free_inodes 0)
1044 [[ $FREE_INODES -lt $NRFILES ]] &&
1045 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1049 trap simple_cleanup_common EXIT
1051 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1052 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1055 createmany -m $DIR/$tdir/$tfile $NRFILES
1057 cancel_lru_locks mdc
1058 lctl set_param mdc.*.stats clear
1060 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1062 # LU-5 large readdir
1063 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1064 # 8 bytes for name(filename is mostly 5 in this test) +
1065 # 8 bytes for luda_type
1066 # take into account of overhead in lu_dirpage header and end mark in
1067 # each page, plus one in RPC_NUM calculation.
1069 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1070 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1071 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1072 awk '/^mds_readpage/ {print $2}')
1073 [[ $mds_readpage -gt $RPC_NUM ]] &&
1074 error "large readdir doesn't take effect"
1076 simple_cleanup_common
1078 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1080 test_24w() { # bug21506
1082 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1083 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1084 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1085 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1086 [[ "$SZ1" -eq "$SZ2" ]] ||
1087 error "Error reading at the end of the file $tfile"
1089 run_test 24w "Reading a file larger than 4Gb"
1092 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1095 local remote_dir=$DIR/$tdir/remote_dir
1098 $LFS mkdir -i $MDTIDX $remote_dir ||
1099 error "create remote directory failed"
1101 mkdir -p $DIR/$tdir/src_dir
1102 touch $DIR/$tdir/src_file
1103 mkdir -p $remote_dir/tgt_dir
1104 touch $remote_dir/tgt_file
1106 mrename $remote_dir $DIR/ &&
1107 error "rename dir cross MDT works!"
1109 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1110 error "rename dir cross MDT works!"
1112 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1113 error "rename file cross MDT works!"
1115 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1116 error "ln file cross MDT should not work!"
1118 rm -rf $DIR/$tdir || error "Can not delete directories"
1120 run_test 24x "cross rename/link should be failed"
1123 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1126 local remote_dir=$DIR/$tdir/remote_dir
1129 $LFS mkdir -i $MDTIDX $remote_dir ||
1130 error "create remote directory failed"
1132 mkdir -p $remote_dir/src_dir
1133 touch $remote_dir/src_file
1134 mkdir -p $remote_dir/tgt_dir
1135 touch $remote_dir/tgt_file
1137 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1138 error "rename subdir in the same remote dir failed!"
1140 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1141 error "rename files in the same remote dir failed!"
1143 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1144 error "link files in the same remote dir failed!"
1146 rm -rf $DIR/$tdir || error "Can not delete directories"
1148 run_test 24y "rename/link on the same dir should succeed"
1151 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1154 local remote_src=$DIR/$tdir/remote_dir
1155 local remote_tgt=$DIR/$tdir/remote_tgt
1158 $LFS mkdir -i $MDTIDX $remote_src ||
1159 error "create remote directory failed"
1161 $LFS mkdir -i $MDTIDX $remote_tgt ||
1162 error "create remote directory failed"
1164 mrename $remote_src $remote_tgt &&
1165 error "rename remote dirs should not work!"
1167 # If target dir does not exists, it should succeed
1169 mrename $remote_src $remote_tgt ||
1170 error "rename remote dirs(tgt dir does not exists) failed!"
1172 rm -rf $DIR/$tdir || error "Can not delete directories"
1174 run_test 24z "rename one remote dir to another remote dir should fail"
1176 test_24A() { # LU-3182
1181 createmany -m $DIR/$tdir/$tfile $NFILES
1182 local t=$(ls $DIR/$tdir | wc -l)
1183 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1185 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1186 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1189 rm -rf $DIR/$tdir || error "Can not delete directories"
1191 run_test 24A "readdir() returns correct number of entries."
1193 test_24B() { # LU-4805
1194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1198 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1199 error "create striped dir failed"
1201 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1202 [ $count -eq 2 ] || error "Expected 2, got $count"
1204 touch $DIR/$tdir/striped_dir/a
1206 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1207 [ $count -eq 3 ] || error "Expected 3, got $count"
1209 touch $DIR/$tdir/striped_dir/.f
1211 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1212 [ $count -eq 4 ] || error "Expected 4, got $count"
1214 rm -rf $DIR/$tdir || error "Can not delete directories"
1216 run_test 24B "readdir for striped dir return correct number of entries"
1219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1225 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1226 error "create striped dir failed"
1228 cd $DIR/$tdir/d0/striped_dir
1230 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1231 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1232 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1234 [ "$d0_ino" = "$parent_ino" ] ||
1235 error ".. wrong, expect $d0_ino, get $parent_ino"
1237 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1238 error "mv striped dir failed"
1240 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1242 [ "$d1_ino" = "$parent_ino" ] ||
1243 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1245 run_test 24C "check .. in striped dir"
1248 echo '== symlink sanity ============================================='
1252 touch $DIR/s25/foo || error
1254 run_test 25a "create file in symlinked directory ==============="
1257 [ ! -d $DIR/d25 ] && test_25a
1258 $CHECKSTAT -t file $DIR/s25/foo || error
1260 run_test 25b "lookup file in symlinked directory ==============="
1264 test_mkdir $DIR/d26/d26-2
1265 ln -s d26/d26-2 $DIR/s26
1266 touch $DIR/s26/foo || error
1268 run_test 26a "multiple component symlink ======================="
1271 test_mkdir -p $DIR/d26b/d26-2
1272 ln -s d26b/d26-2/foo $DIR/s26-2
1273 touch $DIR/s26-2 || error
1275 run_test 26b "multiple component symlink at end of lookup ======"
1278 test_mkdir $DIR/d26.2
1279 touch $DIR/d26.2/foo
1280 ln -s d26.2 $DIR/s26.2-1
1281 ln -s s26.2-1 $DIR/s26.2-2
1282 ln -s s26.2-2 $DIR/s26.2-3
1283 chmod 0666 $DIR/s26.2-3/foo
1285 run_test 26c "chain of symlinks ================================"
1287 # recursive symlinks (bug 439)
1289 ln -s d26-3/foo $DIR/d26-3
1291 run_test 26d "create multiple component recursive symlink ======"
1294 [ ! -h $DIR/d26-3 ] && test_26d
1297 run_test 26e "unlink multiple component recursive symlink ======"
1299 # recursive symlinks (bug 7022)
1301 test_mkdir -p $DIR/$tdir
1302 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1303 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1304 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1305 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1306 cd $tfile || error "cd $tfile failed"
1307 ln -s .. dotdot || error "ln dotdot failed"
1308 ln -s dotdot/lndir lndir || error "ln lndir failed"
1309 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1310 output=`ls $tfile/$tfile/lndir/bar1`
1311 [ "$output" = bar1 ] && error "unexpected output"
1312 rm -r $tfile || error "rm $tfile failed"
1313 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1315 run_test 26f "rm -r of a directory which has recursive symlink ="
1318 echo '== stripe sanity =============================================='
1319 test_mkdir -p $DIR/d27 || error "mkdir failed"
1321 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1322 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1323 log "== test_27a: write to one stripe file ========================="
1324 cp /etc/hosts $DIR/d27/f0 || error
1326 run_test 27a "one stripe file =================================="
1329 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1330 test_mkdir -p $DIR/d27
1331 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1332 $GETSTRIPE -c $DIR/d27/f01
1333 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1334 error "two-stripe file doesn't have two stripes"
1336 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1338 run_test 27b "create and write to two stripe file"
1341 test_mkdir -p $DIR/d27
1342 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1343 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1344 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1346 run_test 27d "create file with default settings ================"
1349 test_mkdir -p $DIR/d27
1350 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1351 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1352 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1354 run_test 27e "setstripe existing file (should return error) ======"
1357 test_mkdir -p $DIR/d27
1358 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1359 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1360 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1362 run_test 27f "setstripe with bad stripe size (should return error)"
1365 test_mkdir -p $DIR/d27
1366 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1367 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1368 error "$DIR/d27/fnone has object"
1370 run_test 27g "$GETSTRIPE with no objects"
1373 touch $DIR/d27/fsome || error "touch failed"
1374 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1376 run_test 27i "$GETSTRIPE with some objects"
1379 test_mkdir -p $DIR/d27
1380 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1382 run_test 27j "setstripe with bad stripe offset (should return error)"
1384 test_27k() { # bug 2844
1385 test_mkdir -p $DIR/d27
1387 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1388 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1389 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1390 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1391 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1392 dd if=/dev/zero of=$FILE bs=4k count=1
1393 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1394 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1396 run_test 27k "limit i_blksize for broken user apps ============="
1399 test_mkdir -p $DIR/d27
1400 mcreate $DIR/f27l || error "creating file"
1401 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1402 error "setstripe should have failed" || true
1404 run_test 27l "check setstripe permissions (should return error)"
1407 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1409 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1410 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1413 trap simple_cleanup_common EXIT
1414 test_mkdir -p $DIR/$tdir
1415 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1416 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1417 error "dd should fill OST0"
1419 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1421 [ $i -gt 256 ] && break
1424 touch $DIR/$tdir/f27m_$i
1425 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1426 error "OST0 was full but new created file still use it"
1428 touch $DIR/$tdir/f27m_$i
1429 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1430 error "OST0 was full but new created file still use it"
1431 simple_cleanup_common
1433 run_test 27m "create file while OST0 was full =================="
1436 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1440 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1441 # if the OST isn't full anymore.
1443 local OSTIDX=${1:-""}
1445 local list=$(comma_list $(osts_nodes))
1446 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1448 do_nodes $list lctl set_param fail_loc=0
1449 sync # initiate all OST_DESTROYs from MDS to OST
1453 exhaust_precreations() {
1456 local FAILIDX=${3:-$OSTIDX}
1458 test_mkdir -p $DIR/$tdir
1459 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1460 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1462 local OST=$(ostname_from_index $OSTIDX)
1463 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1464 sed -e 's/_UUID$//;s/^.*-//')
1467 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1468 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1469 osc.$mdtosc_proc1.prealloc_last_id)
1470 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1471 osc.$mdtosc_proc1.prealloc_next_id)
1473 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1474 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1476 test_mkdir -p $DIR/$tdir/${OST}
1477 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1478 #define OBD_FAIL_OST_ENOSPC 0x215
1479 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1480 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1481 echo "Creating to objid $last_id on ost $OST..."
1482 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1483 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1484 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1488 exhaust_all_precreations() {
1490 for (( i=0; i < OSTCOUNT; i++ )) ; do
1491 exhaust_precreations $i $1 -1
1496 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1499 remote_ost_nodsh && skip "remote OST with nodsh" && return
1502 rm -f $DIR/$tdir/$tfile
1503 exhaust_precreations 0 0x80000215
1504 $SETSTRIPE -c -1 $DIR/$tdir
1505 touch $DIR/$tdir/$tfile || error
1506 $GETSTRIPE $DIR/$tdir/$tfile
1509 run_test 27n "create file with some full OSTs =================="
1512 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1515 remote_ost_nodsh && skip "remote OST with nodsh" && return
1518 rm -f $DIR/$tdir/$tfile
1519 exhaust_all_precreations 0x215
1521 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1526 run_test 27o "create file with all full OSTs (should error) ===="
1529 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1532 remote_ost_nodsh && skip "remote OST with nodsh" && return
1535 rm -f $DIR/$tdir/$tfile
1536 test_mkdir -p $DIR/$tdir
1538 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1539 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1540 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1542 exhaust_precreations 0 0x80000215
1543 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1544 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1545 $GETSTRIPE $DIR/$tdir/$tfile
1549 run_test 27p "append to a truncated file with some full OSTs ==="
1552 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1555 remote_ost_nodsh && skip "remote OST with nodsh" && return
1558 rm -f $DIR/$tdir/$tfile
1560 test_mkdir -p $DIR/$tdir
1561 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1562 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1563 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1565 exhaust_all_precreations 0x215
1567 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1568 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1572 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1575 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 remote_ost_nodsh && skip "remote OST with nodsh" && return
1581 rm -f $DIR/$tdir/$tfile
1582 exhaust_precreations 0 0x80000215
1584 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1588 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1590 test_27s() { # bug 10725
1591 test_mkdir -p $DIR/$tdir
1592 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1593 local stripe_count=0
1594 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1595 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1596 error "stripe width >= 2^32 succeeded" || true
1599 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1601 test_27t() { # bug 10864
1606 $WLFS getstripe $tfile
1609 run_test 27t "check that utils parse path correctly"
1611 test_27u() { # bug 4900
1612 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1615 local list=$(comma_list $(mdts_nodes))
1617 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1618 do_nodes $list $LCTL set_param fail_loc=0x139
1619 test_mkdir -p $DIR/$tdir
1621 createmany -o $DIR/$tdir/t- 1000
1622 do_nodes $list $LCTL set_param fail_loc=0
1624 TLOG=$DIR/$tfile.getstripe
1625 $GETSTRIPE $DIR/$tdir > $TLOG
1626 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1627 unlinkmany $DIR/$tdir/t- 1000
1628 [[ $OBJS -gt 0 ]] &&
1629 error "$OBJS objects created on OST-0. See $TLOG" || pass
1631 run_test 27u "skip object creation on OSC w/o objects =========="
1633 test_27v() { # bug 4900
1634 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1636 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1637 remote_ost_nodsh && skip "remote OST with nodsh" && return
1639 exhaust_all_precreations 0x215
1642 test_mkdir -p $DIR/$tdir
1643 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1645 touch $DIR/$tdir/$tfile
1646 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1648 for (( i=1; i < OSTCOUNT; i++ )); do
1649 do_facet ost$i lctl set_param fail_loc=0x705
1651 local START=`date +%s`
1652 createmany -o $DIR/$tdir/$tfile 32
1654 local FINISH=`date +%s`
1655 local TIMEOUT=`lctl get_param -n timeout`
1656 local PROCESS=$((FINISH - START))
1657 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1658 error "$FINISH - $START >= $TIMEOUT / 2"
1659 sleep $((TIMEOUT / 2 - PROCESS))
1662 run_test 27v "skip object creation on slow OST ================="
1664 test_27w() { # bug 10997
1665 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1666 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1667 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1668 error "stripe size $size != 65536" || true
1669 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1670 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1672 run_test 27w "check $SETSTRIPE -S option"
1675 [[ $OSTCOUNT -lt 2 ]] &&
1676 skip_env "skipping multiple stripe count/offset test" && return
1678 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1679 for i in $(seq 1 $OSTCOUNT); do
1681 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1682 error "setstripe -c $i -i $offset failed"
1683 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1684 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1685 [ $count -ne $i ] && error "stripe count $count != $i" || true
1686 [ $index -ne $offset ] &&
1687 error "stripe offset $index != $offset" || true
1690 run_test 27wa "check $SETSTRIPE -c -i options"
1693 remote_ost_nodsh && skip "remote OST with nodsh" && return
1694 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1695 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1696 OFFSET=$(($OSTCOUNT - 1))
1698 local OST=$(ostname_from_index $OSTIDX)
1700 test_mkdir -p $DIR/$tdir
1701 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1702 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1704 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1705 for i in `seq 0 $OFFSET`; do
1706 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1707 error "OST0 was degraded but new created file still use it"
1709 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1711 run_test 27x "create files while OST0 is degraded"
1714 [[ $OSTCOUNT -lt 2 ]] &&
1715 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1716 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1717 remote_ost_nodsh && skip "remote OST with nodsh" && return
1718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1720 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1721 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1722 osc.$mdtosc.prealloc_last_id)
1723 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1724 osc.$mdtosc.prealloc_next_id)
1725 local fcount=$((last_id - next_id))
1726 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1727 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1729 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1730 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1731 local OST_DEACTIVE_IDX=-1
1736 for OSC in $MDS_OSCS; do
1737 OST=$(osc_to_ost $OSC)
1738 OSTIDX=$(index_from_ostuuid $OST)
1739 if [ $OST_DEACTIVE_IDX == -1 ]; then
1740 OST_DEACTIVE_IDX=$OSTIDX
1742 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1743 echo $OSC "is Deactivated:"
1744 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1748 OSTIDX=$(index_from_ostuuid $OST)
1750 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1752 for OSC in $MDS_OSCS; do
1753 OST=$(osc_to_ost $OSC)
1754 OSTIDX=$(index_from_ostuuid $OST)
1755 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1756 echo $OST "is degraded:"
1757 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1758 obdfilter.$OST.degraded=1
1763 createmany -o $DIR/$tdir/$tfile $fcount
1765 for OSC in $MDS_OSCS; do
1766 OST=$(osc_to_ost $OSC)
1767 OSTIDX=$(index_from_ostuuid $OST)
1768 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1769 echo $OST "is recovered from degraded:"
1770 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1771 obdfilter.$OST.degraded=0
1773 do_facet $SINGLEMDS lctl --device %$OSC activate
1777 # all osp devices get activated, hence -1 stripe count restored
1780 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1781 # devices get activated.
1783 $SETSTRIPE -c -1 $DIR/$tfile
1784 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1786 [ $stripecnt -ne $OSTCOUNT ] &&
1787 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1790 run_test 27y "create files while OST0 is degraded and the rest inactive"
1796 lmm_count=$($GETSTRIPE -c $1)
1797 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1798 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1800 local old_ifs="$IFS"
1802 fid=($($LFS path2fid $1))
1805 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1806 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1808 # compare lmm_seq and lu_fid->f_seq
1809 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1810 # compare lmm_object_id and lu_fid->oid
1811 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1813 # check the trusted.fid attribute of the OST objects of the file
1814 local have_obdidx=false
1816 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1817 # skip lines up to and including "obdidx"
1818 [ -z "$obdidx" ] && break
1819 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1820 $have_obdidx || continue
1822 local ost=$((obdidx + 1))
1823 local dev=$(ostdevname $ost)
1826 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1828 seq=$(echo $seq | sed -e "s/^0x//g")
1829 if [ $seq == 0 ]; then
1830 oid_hex=$(echo $oid)
1832 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1834 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1838 # Don't unmount/remount the OSTs if we don't need to do that.
1839 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1840 # update too, until that use mount/ll_decode_filter_fid/mount.
1841 # Re-enable when debugfs will understand new filter_fid.
1843 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1844 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1845 $dev 2>/dev/null" | grep "parent=")
1848 mount_fstype ost$ost
1849 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1850 $(facet_mntpt ost$ost)/$obj_file)
1851 unmount_fstype ost$ost
1852 start ost$ost $dev $OST_MOUNT_OPTS
1855 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1857 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1859 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1860 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1861 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1862 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1863 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1865 if echo $ff_parent | grep -q 'stripe='; then
1866 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1869 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1870 # into f_ver in this case. See the comment on
1873 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1877 # compare lmm_seq and filter_fid->ff_parent.f_seq
1878 [ $ff_pseq = $lmm_seq ] ||
1879 error "FF parent SEQ $ff_pseq != $lmm_seq"
1880 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1881 [ $ff_poid = $lmm_oid ] ||
1882 error "FF parent OID $ff_poid != $lmm_oid"
1883 (($ff_pstripe == $stripe_nr)) ||
1884 error "FF stripe $ff_pstripe != $stripe_nr"
1886 stripe_nr=$((stripe_nr + 1))
1891 remote_ost_nodsh && skip "remote OST with nodsh" && return
1892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1893 test_mkdir -p $DIR/$tdir
1895 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1896 { error "setstripe -c -1 failed"; return 1; }
1897 # We need to send a write to every object to get parent FID info set.
1898 # This _should_ also work for setattr, but does not currently.
1899 # touch $DIR/$tdir/$tfile-1 ||
1900 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1901 { error "dd $tfile-1 failed"; return 2; }
1902 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1903 { error "setstripe -c -1 failed"; return 3; }
1904 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1905 { error "dd $tfile-2 failed"; return 4; }
1907 # make sure write RPCs have been sent to OSTs
1910 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1911 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1913 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1915 test_27A() { # b=19102
1916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1917 local restore_size=$($GETSTRIPE -S $MOUNT)
1918 local restore_count=$($GETSTRIPE -c $MOUNT)
1919 local restore_offset=$($GETSTRIPE -i $MOUNT)
1920 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1921 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1922 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1923 local default_size=$($GETSTRIPE -S $MOUNT)
1924 local default_offset=$($GETSTRIPE -i $MOUNT)
1925 local dsize=$((1024 * 1024))
1926 [ $default_size -eq $dsize ] ||
1927 error "stripe size $default_size != $dsize"
1928 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1929 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1931 run_test 27A "check filesystem-wide default LOV EA values"
1933 test_27B() { # LU-2523
1934 test_mkdir -p $DIR/$tdir
1935 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1937 # open f1 with O_LOV_DELAY_CREATE
1939 # call setstripe ioctl on open file descriptor for f1
1941 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
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:uB1c
1951 # Allow multiop to fail in imitation of NFS's busted semantics.
1954 run_test 27B "call setstripe on open unlinked file/rename victim"
1956 test_27C() { #LU-2871
1957 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1965 test_mkdir -p $DIR/$tdir
1967 for i in $(seq 0 $((OSTCOUNT - 1))); do
1968 # set stripe across all OSTs starting from OST$i
1969 $SETSTRIPE -i $i -c -1 $tfile$i
1970 # get striping information
1971 ost_idx=($($GETSTRIPE $tfile$i |
1972 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1976 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1977 error "${#ost_idx[@]} != $OSTCOUNT"
1979 for index in $(seq 0 $((OSTCOUNT - 1))); do
1981 for j in $(echo ${ost_idx[@]}); do
1982 if [ $index -eq $j ]; then
1988 error "Can not find $index in ${ost_idx[@]}"
1992 run_test 27C "check full striping across all OSTs"
1994 # createtest also checks that device nodes are created and
1995 # then visible correctly (#2091)
1996 test_28() { # bug 2091
1998 $CREATETEST $DIR/d28/ct || error
2000 run_test 28 "create/mknod/mkdir with bad file types ============"
2003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2004 cancel_lru_locks mdc
2010 declare -i LOCKCOUNTORIG=0
2011 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2012 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2014 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2016 declare -i LOCKUNUSEDCOUNTORIG=0
2017 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2018 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2025 declare -i LOCKCOUNTCURRENT=0
2026 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2027 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2030 declare -i LOCKUNUSEDCOUNTCURRENT=0
2031 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2032 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2035 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2036 $LCTL set_param -n ldlm.dump_namespaces ""
2037 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2038 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2039 log "dumped log to $TMP/test_29.dk (bug 5793)"
2042 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2043 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2044 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2045 log "dumped log to $TMP/test_29.dk (bug 5793)"
2049 run_test 29 "IT_GETATTR regression ============================"
2051 test_30a() { # was test_30
2052 cp $(which ls) $DIR || cp /bin/ls $DIR
2056 run_test 30a "execute binary from Lustre (execve) =============="
2059 cp `which ls` $DIR || cp /bin/ls $DIR
2061 $RUNAS $DIR/ls / || error
2064 run_test 30b "execute binary from Lustre as non-root ==========="
2066 test_30c() { # b=22376
2067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2068 cp `which ls` $DIR || cp /bin/ls $DIR
2070 cancel_lru_locks mdc
2071 cancel_lru_locks osc
2072 $RUNAS $DIR/ls / || error
2075 run_test 30c "execute binary from Lustre without read perms ===="
2078 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2079 $CHECKSTAT -a $DIR/f31 || error
2081 run_test 31a "open-unlink file =================================="
2084 touch $DIR/f31 || error
2085 ln $DIR/f31 $DIR/f31b || error
2086 $MULTIOP $DIR/f31b Ouc || error
2087 $CHECKSTAT -t file $DIR/f31 || error
2089 run_test 31b "unlink file with multiple links while open ======="
2092 touch $DIR/f31 || error
2093 ln $DIR/f31 $DIR/f31c || error
2094 multiop_bg_pause $DIR/f31 O_uc || return 1
2096 $MULTIOP $DIR/f31c Ouc
2097 kill -USR1 $MULTIPID
2100 run_test 31c "open-unlink file with multiple links ============="
2103 opendirunlink $DIR/d31d $DIR/d31d || error
2104 $CHECKSTAT -a $DIR/d31d || error
2106 run_test 31d "remove of open directory ========================="
2108 test_31e() { # bug 2904
2109 check_kernel_version 34 || return 0
2110 openfilleddirunlink $DIR/d31e || error
2112 run_test 31e "remove of open non-empty directory ==============="
2114 test_31f() { # bug 4554
2115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2117 test_mkdir $DIR/d31f
2118 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2119 cp /etc/hosts $DIR/d31f
2121 $GETSTRIPE $DIR/d31f/hosts
2122 multiop_bg_pause $DIR/d31f D_c || return 1
2125 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2126 test_mkdir $DIR/d31f
2127 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2128 cp /etc/hosts $DIR/d31f
2130 $GETSTRIPE $DIR/d31f/hosts
2131 multiop_bg_pause $DIR/d31f D_c || return 1
2134 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2135 wait $MULTIPID || error "first opendir $MULTIPID failed"
2139 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2140 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2143 run_test 31f "remove of open directory with open-unlink file ==="
2146 echo "-- cross directory link --"
2147 test_mkdir -c1 $DIR/${tdir}ga
2148 test_mkdir -c1 $DIR/${tdir}gb
2149 touch $DIR/${tdir}ga/f
2150 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2151 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2152 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2153 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2154 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2156 run_test 31g "cross directory link==============="
2159 echo "-- cross directory link --"
2160 test_mkdir -c1 $DIR/${tdir}
2161 test_mkdir -c1 $DIR/${tdir}/dir
2162 touch $DIR/${tdir}/f
2163 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2164 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2165 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2166 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2167 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2169 run_test 31h "cross directory link under child==============="
2172 echo "-- cross directory link --"
2173 test_mkdir -c1 $DIR/$tdir
2174 test_mkdir -c1 $DIR/$tdir/dir
2175 touch $DIR/$tdir/dir/f
2176 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2177 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2178 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2179 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2180 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2182 run_test 31i "cross directory link under parent==============="
2185 test_mkdir -c1 -p $DIR/$tdir
2186 test_mkdir -c1 -p $DIR/$tdir/dir1
2187 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2188 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2189 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2190 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2193 run_test 31j "link for directory==============="
2196 test_mkdir -c1 -p $DIR/$tdir
2198 touch $DIR/$tdir/exist
2199 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2200 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2201 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2202 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2203 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2204 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2205 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2208 run_test 31k "link to file: the same, non-existing, dir==============="
2214 touch $DIR/d31m2/exist
2215 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2216 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2217 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2218 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2219 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2220 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2223 run_test 31m "link to file: the same, non-existing, dir==============="
2226 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2227 nlink=$(stat --format=%h $DIR/$tfile)
2228 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2230 local cmd="exec $fd<$DIR/$tfile"
2233 trap "eval $cmd" EXIT
2234 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2235 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2236 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2237 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2238 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2241 run_test 31n "check link count of unlinked file"
2244 local TEMPNAME=$(mktemp $1_XXXXXX)
2245 mlink $TEMPNAME $1 2> /dev/null &&
2246 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2250 test_31o() { # LU-2901
2252 for LOOP in $(seq 100); do
2253 rm -f $DIR/$tdir/$tfile*
2254 for THREAD in $(seq 8); do
2255 link_one $DIR/$tdir/$tfile.$LOOP &
2258 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2259 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2260 error "$LINKS duplicate links to $tfile.$LOOP" &&
2264 run_test 31o "duplicate hard links with same filename"
2267 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2270 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2271 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2273 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2274 error "open unlink test1 failed"
2275 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2276 error "open unlink test2 failed"
2278 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2279 error "test1 still exists"
2280 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2281 error "test2 still exists"
2283 run_test 31p "remove of open striped directory"
2285 cleanup_test32_mount() {
2287 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2292 echo "== more mountpoints and symlinks ================="
2293 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2294 trap cleanup_test32_mount EXIT
2295 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2296 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2297 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2298 cleanup_test32_mount
2300 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2304 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2305 trap cleanup_test32_mount EXIT
2306 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2307 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2308 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2309 cleanup_test32_mount
2311 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2315 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2316 trap cleanup_test32_mount EXIT
2317 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2318 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2319 test_mkdir -p $DIR/$tdir/d2/test_dir
2320 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2321 cleanup_test32_mount
2323 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2327 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2328 trap cleanup_test32_mount EXIT
2329 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2330 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2331 test_mkdir -p $DIR/$tdir/d2/test_dir
2332 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2333 cleanup_test32_mount
2335 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2338 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2339 test_mkdir -p $DIR/d32e/tmp
2340 TMP_DIR=$DIR/d32e/tmp
2341 ln -s $DIR/d32e $TMP_DIR/symlink11
2342 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2343 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2344 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2346 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2349 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2350 test_mkdir -p $DIR/d32f/tmp
2351 TMP_DIR=$DIR/d32f/tmp
2352 ln -s $DIR/d32f $TMP_DIR/symlink11
2353 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2354 ls $DIR/d32f/tmp/symlink11 || error
2355 ls $DIR/d32f/symlink01 || error
2357 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2360 TMP_DIR=$DIR/$tdir/tmp
2361 test_mkdir -p $DIR/$tdir/tmp
2362 test_mkdir $DIR/${tdir}2
2363 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2364 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2365 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2366 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2367 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2368 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2370 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2373 rm -fr $DIR/$tdir $DIR/${tdir}2
2374 TMP_DIR=$DIR/$tdir/tmp
2375 test_mkdir -p $DIR/$tdir/tmp
2376 test_mkdir $DIR/${tdir}2
2377 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2378 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2379 ls $TMP_DIR/symlink12 || error
2380 ls $DIR/$tdir/symlink02 || error
2382 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2386 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2387 trap cleanup_test32_mount EXIT
2388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2390 touch $DIR/$tdir/test_file
2391 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2392 cleanup_test32_mount
2394 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2398 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2399 trap cleanup_test32_mount EXIT
2400 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2401 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2402 touch $DIR/$tdir/test_file
2403 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2404 cleanup_test32_mount
2406 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2411 trap cleanup_test32_mount EXIT
2412 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2413 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2414 test_mkdir -p $DIR/$tdir/d2
2415 touch $DIR/$tdir/d2/test_file || error
2416 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2417 cleanup_test32_mount
2419 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2424 trap cleanup_test32_mount EXIT
2425 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2426 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2427 test_mkdir -p $DIR/$tdir/d2
2428 touch $DIR/$tdir/d2/test_file
2429 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2430 cleanup_test32_mount
2432 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2436 test_mkdir -p $DIR/d32m/tmp
2437 TMP_DIR=$DIR/d32m/tmp
2438 ln -s $DIR $TMP_DIR/symlink11
2439 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2440 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2441 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2443 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2447 test_mkdir -p $DIR/d32n/tmp
2448 TMP_DIR=$DIR/d32n/tmp
2449 ln -s $DIR $TMP_DIR/symlink11
2450 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2451 ls -l $DIR/d32n/tmp/symlink11 || error
2452 ls -l $DIR/d32n/symlink01 || error
2454 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2458 test_mkdir -p $DIR/d32o/tmp
2459 TMP_DIR=$DIR/d32o/tmp
2460 ln -s $DIR/$tfile $TMP_DIR/symlink12
2461 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2462 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2463 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2464 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2465 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2467 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2477 test_mkdir -p $DIR/d32p/tmp
2479 TMP_DIR=$DIR/d32p/tmp
2481 ln -s $DIR/$tfile $TMP_DIR/symlink12
2483 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2485 cat $DIR/d32p/tmp/symlink12 || error
2487 cat $DIR/d32p/symlink02 || error
2490 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2492 cleanup_testdir_mount() {
2494 $UMOUNT -d $DIR/$tdir
2498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2499 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2500 trap cleanup_testdir_mount EXIT
2501 test_mkdir -p $DIR/$tdir
2502 touch $DIR/$tdir/under_the_mount
2503 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2504 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2505 cleanup_testdir_mount
2507 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2511 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2512 trap cleanup_testdir_mount EXIT
2513 test_mkdir -p $DIR/$tdir
2514 touch $DIR/$tdir/under_the_mount
2515 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2516 ls $DIR/$tdir | grep -q under_the_mount && error || true
2517 cleanup_testdir_mount
2519 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2524 chmod 444 $DIR/$tfile
2525 chown $RUNAS_ID $DIR/$tfile
2527 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2530 run_test 33aa "write file with mode 444 (should return error) ===="
2534 test_mkdir -p $DIR/d33
2535 chown $RUNAS_ID $DIR/d33
2536 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2537 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2538 error "open RDWR" || true
2540 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2544 test_mkdir -p $DIR/d33
2545 chown $RUNAS_ID $DIR/d33
2546 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2548 run_test 33b "test open file with malformed flags (No panic)"
2551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2557 remote_ost_nodsh && skip "remote OST with nodsh" && return
2560 test_mkdir -p $DIR/d33
2561 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2564 for ostnum in $(seq $OSTCOUNT); do
2565 # test-framework's OST numbering is one-based, while Lustre's
2567 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2568 # Parsing llobdstat's output sucks; we could grep the /proc
2569 # path, but that's likely to not be as portable as using the
2570 # llobdstat utility. So we parse lctl output instead.
2571 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2572 obdfilter/$ostname/stats |
2573 awk '/^write_bytes/ {print $7}' )
2574 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2575 if (( ${write_bytes:-0} > 0 ))
2582 $all_zeros || return 0
2585 echo foo > $DIR/d33/bar
2589 # Total up write_bytes after writing. We'd better find non-zeros.
2590 for ostnum in $(seq $OSTCOUNT); do
2591 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2592 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2593 obdfilter/$ostname/stats |
2594 awk '/^write_bytes/ {print $7}' )
2595 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2596 if (( ${write_bytes:-0} > 0 ))
2605 for ostnum in $(seq $OSTCOUNT); do
2606 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2607 echo "Check that write_bytes is present in obdfilter/*/stats:"
2608 do_facet ost$ostnum lctl get_param -n \
2609 obdfilter/$ostname/stats
2611 error "OST not keeping write_bytes stats (b22312)"
2614 run_test 33c "test llobdstat and write_bytes"
2617 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2620 local remote_dir=$DIR/$tdir/remote_dir
2623 $LFS mkdir -i $MDTIDX $remote_dir ||
2624 error "create remote directory failed"
2626 touch $remote_dir/$tfile
2627 chmod 444 $remote_dir/$tfile
2628 chown $RUNAS_ID $remote_dir/$tfile
2630 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2632 chown $RUNAS_ID $remote_dir
2633 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2634 error "create" || true
2635 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2636 error "open RDWR" || true
2637 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2638 error "create" || true
2640 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2647 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2648 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2649 mkdir $DIR/$tdir/local_dir
2651 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2652 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2653 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2655 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2656 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2658 rmdir $DIR/$tdir/* || error "rmdir failed"
2661 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2662 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2663 mkdir $DIR/$tdir/local_dir
2665 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2666 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2667 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2669 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2670 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2672 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2675 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2676 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2677 mkdir $DIR/$tdir/local_dir
2679 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2680 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2681 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2683 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2684 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2686 run_test 33e "mkdir and striped directory should have same mode"
2688 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2691 $MCREATE $DIR/f34 || error
2692 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2693 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2694 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2695 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2697 run_test 34a "truncate file that has not been opened ==========="
2700 [ ! -f $DIR/f34 ] && test_34a
2701 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2702 $OPENFILE -f O_RDONLY $DIR/f34
2703 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2704 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2706 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2709 [ ! -f $DIR/f34 ] && test_34a
2710 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2711 $OPENFILE -f O_RDWR $DIR/f34
2712 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2713 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2715 run_test 34c "O_RDWR opening file-with-size works =============="
2718 [ ! -f $DIR/f34 ] && test_34a
2719 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2720 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2723 run_test 34d "write to sparse file ============================="
2727 $MCREATE $DIR/f34e || error
2728 $TRUNCATE $DIR/f34e 1000 || error
2729 $CHECKSTAT -s 1000 $DIR/f34e || error
2730 $OPENFILE -f O_RDWR $DIR/f34e
2731 $CHECKSTAT -s 1000 $DIR/f34e || error
2733 run_test 34e "create objects, some with size and some without =="
2735 test_34f() { # bug 6242, 6243
2736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2739 $MCREATE $DIR/f34f || error
2740 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2741 dd if=$DIR/f34f of=$TMP/f34f
2742 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2743 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2744 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2745 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2746 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2748 run_test 34f "read from a file with no objects until EOF ======="
2751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2752 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2753 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2754 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2755 cancel_lru_locks osc
2756 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2757 error "wrong size after lock cancel"
2759 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2760 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2761 error "expanding truncate failed"
2762 cancel_lru_locks osc
2763 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2764 error "wrong expanded size after lock cancel"
2766 run_test 34g "truncate long file ==============================="
2769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2773 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2774 sync # Flush the cache so that multiop below does not block on cache
2775 # flush when getting the group lock
2776 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2779 # Since just timed wait is not good enough, let's do a sync write
2780 # that way we are sure enough time for a roundtrip + processing
2781 # passed + 2 seconds of extra margin.
2782 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2786 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2787 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2791 local nsz=`stat -c %s $DIR/$tfile`
2792 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2794 run_test 34h "ftruncate file under grouplock should not block"
2797 cp /bin/sh $DIR/f35a
2799 chown $RUNAS_ID $DIR/f35a
2800 $RUNAS $DIR/f35a && error || true
2803 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2807 utime $DIR/f36 || error
2809 run_test 36a "MDS utime check (mknod, utime) ==================="
2813 utime $DIR/f36 || error
2815 run_test 36b "OST utime check (open, utime) ===================="
2820 chown $RUNAS_ID $DIR/d36
2821 $RUNAS utime $DIR/d36/f36 || error
2823 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2826 [ ! -d $DIR/d36 ] && test_36c
2827 echo "" > $DIR/d36/f36
2828 $RUNAS utime $DIR/d36/f36 || error
2830 run_test 36d "non-root OST utime check (open, utime) ==========="
2833 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2834 test_mkdir -p $DIR/$tdir
2835 touch $DIR/$tdir/$tfile
2836 $RUNAS utime $DIR/$tdir/$tfile && \
2837 error "utime worked, expected failure" || true
2839 run_test 36e "utime on non-owned file (should return error) ===="
2843 local LANG_SAVE=$LANG
2844 local LC_LANG_SAVE=$LC_LANG
2845 export LANG=C LC_LANG=C # for date language
2847 DATESTR="Dec 20 2000"
2848 test_mkdir -p $DIR/$tdir
2849 lctl set_param fail_loc=$fl
2851 cp /etc/hosts $DIR/$tdir/$tfile
2852 sync & # write RPC generated with "current" inode timestamp, but delayed
2854 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2855 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2856 cancel_lru_locks osc
2857 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2859 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2860 echo "BEFORE: $LS_BEFORE" && \
2861 echo "AFTER : $LS_AFTER" && \
2862 echo "WANT : $DATESTR" && \
2863 error "$DIR/$tdir/$tfile timestamps changed" || true
2865 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2870 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2871 subr_36fh "0x80000214"
2873 run_test 36f "utime on file racing with OST BRW write =========="
2876 remote_ost_nodsh && skip "remote OST with nodsh" && return
2877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2882 test_mkdir -p $DIR/$tdir
2883 fmd_max_age=$(do_facet ost1 \
2884 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2887 fmd_before=$(do_facet ost1 \
2888 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2889 touch $DIR/$tdir/$tfile
2890 sleep $((fmd_max_age + 12))
2891 fmd_after=$(do_facet ost1 \
2892 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2894 echo "fmd_before: $fmd_before"
2895 echo "fmd_after: $fmd_after"
2896 [[ $fmd_after -gt $fmd_before ]] &&
2897 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2898 error "fmd didn't expire after ping" || true
2900 run_test 36g "filter mod data cache expiry ====================="
2903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2904 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2905 subr_36fh "0x80000227"
2907 run_test 36h "utime on file racing with OST BRW write =========="
2910 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2913 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2915 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2916 local new_mtime=$((mtime + 200))
2918 #change Modify time of striped dir
2919 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2920 error "change mtime failed"
2922 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2924 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2926 run_test 36i "change mtime on striped directory"
2928 # test_37 - duplicate with tests 32q 32r
2931 local file=$DIR/$tfile
2933 openfile -f O_DIRECTORY $file
2936 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2937 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2939 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2943 touch $DIR/${tfile}2
2944 # ls -l $DIR/$tfile $DIR/${tfile}2
2945 # ls -lu $DIR/$tfile $DIR/${tfile}2
2946 # ls -lc $DIR/$tfile $DIR/${tfile}2
2948 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2949 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2951 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2953 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2955 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2956 error "O_TRUNC didn't change timestamps"
2959 run_test 39 "mtime changed on create ==========================="
2962 test_mkdir -p -c1 $DIR/$tdir
2963 cp -p /etc/passwd $DIR/$tdir/fopen
2964 cp -p /etc/passwd $DIR/$tdir/flink
2965 cp -p /etc/passwd $DIR/$tdir/funlink
2966 cp -p /etc/passwd $DIR/$tdir/frename
2967 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2970 echo "aaaaaa" >> $DIR/$tdir/fopen
2971 echo "aaaaaa" >> $DIR/$tdir/flink
2972 echo "aaaaaa" >> $DIR/$tdir/funlink
2973 echo "aaaaaa" >> $DIR/$tdir/frename
2975 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2976 local link_new=`stat -c %Y $DIR/$tdir/flink`
2977 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2978 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2980 cat $DIR/$tdir/fopen > /dev/null
2981 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2982 rm -f $DIR/$tdir/funlink2
2983 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2985 for (( i=0; i < 2; i++ )) ; do
2986 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2987 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2988 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2989 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2991 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2992 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2993 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2994 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2996 cancel_lru_locks osc
2997 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3000 run_test 39b "mtime change on open, link, unlink, rename ======"
3002 # this should be set to past
3003 TEST_39_MTIME=`date -d "1 year ago" +%s`
3009 local mtime0=`stat -c %Y $DIR1/$tfile`
3011 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3012 local mtime1=`stat -c %Y $DIR1/$tfile`
3013 [ "$mtime1" = $TEST_39_MTIME ] || \
3014 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3017 echo hello >> $DIR1/$tfile
3019 local mtime2=`stat -c %Y $DIR1/$tfile`
3020 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3021 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3023 mv $DIR1/$tfile $DIR1/$tfile-1
3025 for (( i=0; i < 2; i++ )) ; do
3026 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3027 [ "$mtime2" = "$mtime3" ] || \
3028 error "mtime ($mtime2) changed (to $mtime3) on rename"
3030 cancel_lru_locks osc
3031 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3034 run_test 39c "mtime change on rename ==========================="
3038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3041 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3043 for (( i=0; i < 2; i++ )) ; do
3044 local mtime=`stat -c %Y $DIR1/$tfile`
3045 [ $mtime = $TEST_39_MTIME ] || \
3046 error "mtime($mtime) is not set to $TEST_39_MTIME"
3048 cancel_lru_locks osc
3049 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3052 run_test 39d "create, utime, stat =============================="
3056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3058 local mtime1=`stat -c %Y $DIR1/$tfile`
3060 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3062 for (( i=0; i < 2; i++ )) ; do
3063 local mtime2=`stat -c %Y $DIR1/$tfile`
3064 [ $mtime2 = $TEST_39_MTIME ] || \
3065 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3067 cancel_lru_locks osc
3068 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3071 run_test 39e "create, stat, utime, stat ========================"
3075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3077 mtime1=`stat -c %Y $DIR1/$tfile`
3080 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3082 for (( i=0; i < 2; i++ )) ; do
3083 local mtime2=`stat -c %Y $DIR1/$tfile`
3084 [ $mtime2 = $TEST_39_MTIME ] || \
3085 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3087 cancel_lru_locks osc
3088 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3091 run_test 39f "create, stat, sleep, utime, stat ================="
3095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3096 echo hello >> $DIR1/$tfile
3097 local mtime1=`stat -c %Y $DIR1/$tfile`
3100 chmod o+r $DIR1/$tfile
3102 for (( i=0; i < 2; i++ )) ; do
3103 local mtime2=`stat -c %Y $DIR1/$tfile`
3104 [ "$mtime1" = "$mtime2" ] || \
3105 error "lost mtime: $mtime2, should be $mtime1"
3107 cancel_lru_locks osc
3108 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3111 run_test 39g "write, chmod, stat ==============================="
3115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3120 echo hello >> $DIR1/$tfile
3121 local mtime1=`stat -c %Y $DIR1/$tfile`
3123 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3125 if [ "$d1" != "$d2" ]; then
3126 echo "write and touch not within one second"
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3130 [ "$mtime2" = $TEST_39_MTIME ] || \
3131 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39h "write, utime within one second, stat ============="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3145 echo hello >> $DIR1/$tfile
3146 local mtime1=`stat -c %Y $DIR1/$tfile`
3148 mv $DIR1/$tfile $DIR1/$tfile-1
3150 for (( i=0; i < 2; i++ )) ; do
3151 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3153 [ "$mtime1" = "$mtime2" ] || \
3154 error "lost mtime: $mtime2, should be $mtime1"
3156 cancel_lru_locks osc
3157 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3160 run_test 39i "write, rename, stat =============================="
3163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3164 start_full_debug_logging
3168 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3169 lctl set_param fail_loc=0x80000412
3170 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3171 error "multiop failed"
3173 local mtime1=`stat -c %Y $DIR1/$tfile`
3175 mv $DIR1/$tfile $DIR1/$tfile-1
3177 kill -USR1 $multipid
3178 wait $multipid || error "multiop close failed"
3180 for (( i=0; i < 2; i++ )) ; do
3181 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3182 [ "$mtime1" = "$mtime2" ] ||
3183 error "mtime is lost on close: $mtime2, " \
3186 cancel_lru_locks osc
3187 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3189 lctl set_param fail_loc=0
3190 stop_full_debug_logging
3192 run_test 39j "write, rename, close, stat ======================="
3195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3199 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3201 local mtime1=`stat -c %Y $DIR1/$tfile`
3203 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3205 kill -USR1 $multipid
3206 wait $multipid || error "multiop close failed"
3208 for (( i=0; i < 2; i++ )) ; do
3209 local mtime2=`stat -c %Y $DIR1/$tfile`
3211 [ "$mtime2" = $TEST_39_MTIME ] || \
3212 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3214 cancel_lru_locks osc
3215 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3218 run_test 39k "write, utime, close, stat ========================"
3220 # this should be set to future
3221 TEST_39_ATIME=`date -d "1 year" +%s`
3224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3225 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3226 local atime_diff=$(do_facet $SINGLEMDS \
3227 lctl get_param -n mdd.*MDT0000*.atime_diff)
3231 # test setting directory atime to future
3232 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3233 local atime=$(stat -c %X $DIR/$tdir)
3234 [ "$atime" = $TEST_39_ATIME ] || \
3235 error "atime is not set to future: $atime, $TEST_39_ATIME"
3237 # test setting directory atime from future to now
3238 local d1=$(date +%s)
3240 local d2=$(date +%s)
3242 cancel_lru_locks mdc
3243 atime=$(stat -c %X $DIR/$tdir)
3244 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3245 error "atime is not updated from future: $atime, $d1<atime<$d2"
3247 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3250 # test setting directory atime when now > dir atime + atime_diff
3254 cancel_lru_locks mdc
3255 atime=$(stat -c %X $DIR/$tdir)
3256 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3257 error "atime is not updated : $atime, should be $d2"
3259 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3262 # test not setting directory atime when now < dir atime + atime_diff
3264 cancel_lru_locks mdc
3265 atime=$(stat -c %X $DIR/$tdir)
3266 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3267 error "atime is updated to $atime, should remain $d1<atime<$d2"
3269 do_facet $SINGLEMDS \
3270 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3272 run_test 39l "directory atime update ==========================="
3275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3278 local far_past_mtime=$(date -d "May 29 1953" +%s)
3279 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3281 touch -m -d @$far_past_mtime $DIR1/$tfile
3282 touch -a -d @$far_past_atime $DIR1/$tfile
3284 for (( i=0; i < 2; i++ )) ; do
3285 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3286 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3287 error "atime or mtime set incorrectly"
3289 cancel_lru_locks osc
3290 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3293 run_test 39m "test atime and mtime before 1970"
3295 test_39n() { # LU-3832
3296 local atime_diff=$(do_facet $SINGLEMDS \
3297 lctl get_param -n mdd.*MDT0000*.atime_diff)
3302 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3305 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3306 atime0=$(stat -c %X $DIR/$tfile)
3309 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3310 atime1=$(stat -c %X $DIR/$tfile)
3313 cancel_lru_locks mdc
3314 cancel_lru_locks osc
3315 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3316 atime2=$(stat -c %X $DIR/$tfile)
3318 do_facet $SINGLEMDS \
3319 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3321 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3322 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3324 run_test 39n "check that O_NOATIME is honored"
3327 TESTDIR=$DIR/$tdir/$tfile
3328 [ -e $TESTDIR ] && rm -rf $TESTDIR
3329 test_mkdir -p $TESTDIR
3335 links2=$(stat -c %h .)
3336 [ $(($links1 + 2)) != $links2 ] &&
3337 error "wrong links count $(($links1 + 2)) != $links2"
3339 links3=$(stat -c %h .)
3340 [ $(($links1 + 1)) != $links3 ] &&
3341 error "wrong links count $links1 != $links3"
3344 run_test 39o "directory cached attributes updated after create ========"
3347 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3349 TESTDIR=$DIR/$tdir/$tfile
3350 [ -e $TESTDIR ] && rm -rf $TESTDIR
3355 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3356 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3358 links2=$(stat -c %h .)
3359 [ $(($links1 + 2)) != $links2 ] &&
3360 error "wrong links count $(($links1 + 2)) != $links2"
3362 links3=$(stat -c %h .)
3363 [ $(($links1 + 1)) != $links3 ] &&
3364 error "wrong links count $links1 != $links3"
3367 run_test 39p "remote directory cached attributes updated after create ========"
3371 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3372 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3373 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3374 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3375 error "$tfile is not 4096 bytes in size"
3377 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3381 small_write $DIR/f41 18
3383 run_test 41 "test small file write + fstat ====================="
3385 count_ost_writes() {
3386 lctl get_param -n osc.*.stats |
3387 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3388 END { printf("%0.0f", writes) }'
3395 BG_DIRTY_RATIO_SAVE=10
3396 MAX_BG_DIRTY_RATIO=25
3400 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3401 # dirty_ratio, dirty_background_ratio
3402 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3403 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3404 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3405 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3407 # if file not here, we are a 2.4 kernel
3408 kill -CONT `pidof kupdated`
3413 # setup the trap first, so someone cannot exit the test at the
3414 # exact wrong time and mess up a machine
3415 trap start_writeback EXIT
3416 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3417 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3418 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3419 sysctl -w vm.dirty_writeback_centisecs=0
3420 sysctl -w vm.dirty_writeback_centisecs=0
3421 # save and increase /proc/sys/vm/dirty_ratio
3422 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3423 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3424 # save and increase /proc/sys/vm/dirty_background_ratio
3425 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3426 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3428 # if file not here, we are a 2.4 kernel
3429 kill -STOP `pidof kupdated`
3433 # ensure that all stripes have some grant before we test client-side cache
3435 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3436 dd if=/dev/zero of=$i bs=4k count=1
3441 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3442 # file truncation, and file removal.
3444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3446 cancel_lru_locks osc
3448 sync; sleep 1; sync # just to be safe
3449 BEFOREWRITES=`count_ost_writes`
3450 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3451 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3452 AFTERWRITES=`count_ost_writes`
3453 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3454 error "$BEFOREWRITES < $AFTERWRITES"
3457 run_test 42a "ensure that we don't flush on close =============="
3460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3462 cancel_lru_locks osc
3465 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3466 BEFOREWRITES=$(count_ost_writes)
3467 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3468 AFTERWRITES=$(count_ost_writes)
3469 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3470 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3472 BEFOREWRITES=$(count_ost_writes)
3473 sync || error "sync: $?"
3474 AFTERWRITES=$(count_ost_writes)
3475 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3476 error "$BEFOREWRITES < $AFTERWRITES on sync"
3478 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3482 run_test 42b "test destroy of file with cached dirty data ======"
3484 # if these tests just want to test the effect of truncation,
3485 # they have to be very careful. consider:
3486 # - the first open gets a {0,EOF}PR lock
3487 # - the first write conflicts and gets a {0, count-1}PW
3488 # - the rest of the writes are under {count,EOF}PW
3489 # - the open for truncate tries to match a {0,EOF}PR
3490 # for the filesize and cancels the PWs.
3491 # any number of fixes (don't get {0,EOF} on open, match
3492 # composite locks, do smarter file size management) fix
3493 # this, but for now we want these tests to verify that
3494 # the cancellation with truncate intent works, so we
3495 # start the file with a full-file pw lock to match against
3496 # until the truncate.
3501 cancel_lru_locks osc
3503 # prime the file with 0,EOF PW to match
3507 # now the real test..
3508 dd if=/dev/zero of=$file bs=1024 count=100
3509 BEFOREWRITES=`count_ost_writes`
3510 $TRUNCATE $file $offset
3511 cancel_lru_locks osc
3512 AFTERWRITES=`count_ost_writes`
3517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3519 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3520 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3523 run_test 42c "test partial truncate of file with cached dirty data"
3526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3528 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3529 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3532 run_test 42d "test complete truncate of file with cached dirty data"
3534 test_42e() { # bug22074
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3536 local TDIR=$DIR/${tdir}e
3537 local pagesz=$(page_size)
3538 local pages=16 # hardcoded 16 pages, don't change it.
3539 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3540 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3544 test_mkdir -p $DIR/${tdir}e
3545 $SETSTRIPE -c 1 $TDIR
3546 createmany -o $TDIR/f $files
3548 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3550 # we assume that with $OSTCOUNT files, at least one of them will
3551 # be allocated on OST0.
3552 warmup_files=$((OSTCOUNT * max_dirty_mb))
3553 createmany -o $TDIR/w $warmup_files
3555 # write a large amount of data into one file and sync, to get good
3556 # avail_grant number from OST.
3557 for ((i=0; i<$warmup_files; i++)); do
3558 idx=$($GETSTRIPE -i $TDIR/w$i)
3559 [ $idx -ne 0 ] && continue
3560 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3563 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3565 $LCTL get_param $proc_osc0/cur_dirty_bytes
3566 $LCTL get_param $proc_osc0/cur_grant_bytes
3568 # create as much dirty pages as we can while not to trigger the actual
3569 # RPCs directly. but depends on the env, VFS may trigger flush during this
3570 # period, hopefully we are good.
3571 for ((i=0; i<$warmup_files; i++)); do
3572 idx=$($GETSTRIPE -i $TDIR/w$i)
3573 [ $idx -ne 0 ] && continue
3574 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3576 $LCTL get_param $proc_osc0/cur_dirty_bytes
3577 $LCTL get_param $proc_osc0/cur_grant_bytes
3579 # perform the real test
3580 $LCTL set_param $proc_osc0/rpc_stats 0
3581 for ((;i<$files; i++)); do
3582 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3583 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3586 $LCTL get_param $proc_osc0/rpc_stats
3589 local have_ppr=false
3590 $LCTL get_param $proc_osc0/rpc_stats |
3591 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3592 # skip lines until we are at the RPC histogram data
3593 [ "$PPR" == "pages" ] && have_ppr=true && continue
3594 $have_ppr || continue
3596 # we only want the percent stat for < 16 pages
3597 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3599 percent=$((percent + WPCT))
3600 if [[ $percent -gt 15 ]]; then
3601 error "less than 16-pages write RPCs" \
3608 run_test 42e "verify sub-RPC writes are not done synchronously"
3611 test_mkdir -p $DIR/$tdir
3612 cp -p /bin/ls $DIR/$tdir/$tfile
3613 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3615 # give multiop a chance to open
3618 $DIR/$tdir/$tfile && error || true
3621 run_test 43 "execution of file opened for write should return -ETXTBSY"
3624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3625 test_mkdir -p $DIR/$tdir
3626 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3627 cp -p multiop $DIR/$tdir/multiop
3628 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3631 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3632 kill -USR1 $MULTIOP_PID || return 2
3633 wait $MULTIOP_PID || return 3
3634 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3636 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3640 test_mkdir -p $DIR/$tdir
3641 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3642 cp -p multiop $DIR/$tdir/multiop
3643 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3646 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3647 kill -USR1 $MULTIOP_PID || return 2
3648 wait $MULTIOP_PID || return 3
3649 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3651 run_test 43b "truncate of file being executed should return -ETXTBSY"
3654 local testdir="$DIR/$tdir"
3655 test_mkdir -p $DIR/$tdir
3657 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3658 ( cd $testdir && md5sum -c)
3660 run_test 43c "md5sum of copy into lustre========================"
3663 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3664 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3665 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3667 run_test 44 "zero length read from a sparse stripe ============="
3670 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3672 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3673 [[ $nstripe -gt $OSTCOUNT ]] &&
3674 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3676 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3678 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3679 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3683 OFFSETS="0 $((stride/2)) $((stride-1))"
3684 for offset in $OFFSETS; do
3685 for i in $(seq 0 $((nstripe-1))); do
3686 local GLOBALOFFSETS=""
3688 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3689 local myfn=$DIR/d44a-$size
3690 echo "--------writing $myfn at $size"
3691 ll_sparseness_write $myfn $size ||
3692 error "ll_sparseness_write"
3693 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3694 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3695 error "ll_sparseness_verify $GLOBALOFFSETS"
3697 for j in $(seq 0 $((nstripe-1))); do
3699 size=$((((j + $nstripe )*$stride + $offset)))
3700 ll_sparseness_write $myfn $size ||
3701 error "ll_sparseness_write"
3702 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3704 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3705 error "ll_sparseness_verify $GLOBALOFFSETS"
3710 run_test 44a "test sparse pwrite ==============================="
3714 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3720 before=`dirty_osc_total`
3721 echo executing "\"$*\""
3723 after=`dirty_osc_total`
3724 echo before $before, after $after
3727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3729 # Obtain grants from OST if it supports it
3730 echo blah > ${f}_grant
3733 do_dirty_record "echo blah > $f"
3734 [[ $before -eq $after ]] && error "write wasn't cached"
3735 do_dirty_record "> $f"
3736 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3737 do_dirty_record "echo blah > $f"
3738 [[ $before -eq $after ]] && error "write wasn't cached"
3739 do_dirty_record "sync"
3740 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3741 do_dirty_record "echo blah > $f"
3742 [[ $before -eq $after ]] && error "write wasn't cached"
3743 do_dirty_record "cancel_lru_locks osc"
3744 [[ $before -gt $after ]] ||
3745 error "lock cancellation didn't lower dirty count"
3748 run_test 45 "osc io page accounting ============================"
3750 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3751 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3752 # objects offset and an assert hit when an rpc was built with 1023's mapped
3753 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3759 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3761 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3762 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3766 run_test 46 "dirtying a previously written page ================"
3768 # test_47 is removed "Device nodes check" is moved to test_28
3770 test_48a() { # bug 2399
3771 check_kernel_version 34 || return 0
3772 test_mkdir -p $DIR/$tdir
3774 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3775 test_mkdir $DIR/$tdir || error "recreate directory failed"
3776 touch foo || error "'touch foo' failed after recreating cwd"
3777 test_mkdir $DIR/$tdir/bar ||
3778 error "'mkdir foo' failed after recreating cwd"
3779 if check_kernel_version 44; then
3780 touch .foo || error "'touch .foo' failed after recreating cwd"
3781 test_mkdir $DIR/$tdir/.bar ||
3782 error "'mkdir .foo' failed after recreating cwd"
3784 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3785 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3786 cd . || error "'cd .' failed after recreating cwd"
3787 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3788 rmdir . && error "'rmdir .' worked after recreating cwd"
3789 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3790 cd .. || error "'cd ..' failed after recreating cwd"
3792 run_test 48a "Access renamed working dir (should return errors)="
3794 test_48b() { # bug 2399
3795 check_kernel_version 34 || return 0
3797 test_mkdir -p $DIR/$tdir
3799 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3800 touch foo && error "'touch foo' worked after removing cwd"
3801 test_mkdir $DIR/$tdir/foo &&
3802 error "'mkdir foo' worked after removing cwd"
3803 if check_kernel_version 44; then
3804 touch .foo && error "'touch .foo' worked after removing cwd"
3805 test_mkdir $DIR/$tdir/.foo &&
3806 error "'mkdir .foo' worked after removing cwd"
3808 ls . > /dev/null && error "'ls .' worked after removing cwd"
3809 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3810 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3811 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3812 rmdir . && error "'rmdir .' worked after removing cwd"
3813 ln -s . foo && error "'ln -s .' worked after removing cwd"
3814 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3816 run_test 48b "Access removed working dir (should return errors)="
3818 test_48c() { # bug 2350
3819 check_kernel_version 36 || return 0
3820 #lctl set_param debug=-1
3823 test_mkdir -p $DIR/$tdir/dir
3825 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3826 $TRACE touch foo && error "touch foo worked after removing cwd"
3827 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3828 if check_kernel_version 44; then
3829 touch .foo && error "touch .foo worked after removing cwd"
3830 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3832 $TRACE ls . && error "'ls .' worked after removing cwd"
3833 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3834 is_patchless || ( $TRACE cd . &&
3835 error "'cd .' worked after removing cwd" )
3836 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3837 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3838 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3839 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3841 run_test 48c "Access removed working subdir (should return errors)"
3843 test_48d() { # bug 2350
3844 check_kernel_version 36 || return 0
3845 #lctl set_param debug=-1
3848 test_mkdir -p $DIR/$tdir/dir
3850 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3851 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3852 $TRACE touch foo && error "'touch foo' worked after removing parent"
3853 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3854 if check_kernel_version 44; then
3855 touch .foo && error "'touch .foo' worked after removing parent"
3857 error "mkdir .foo worked after removing parent"
3859 $TRACE ls . && error "'ls .' worked after removing parent"
3860 $TRACE ls .. && error "'ls ..' worked after removing parent"
3861 is_patchless || ( $TRACE cd . &&
3862 error "'cd .' worked after recreate parent" )
3863 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3864 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3865 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3866 is_patchless || ( $TRACE cd .. &&
3867 error "'cd ..' worked after removing parent" || true )
3869 run_test 48d "Access removed parent subdir (should return errors)"
3871 test_48e() { # bug 4134
3872 check_kernel_version 41 || return 0
3873 #lctl set_param debug=-1
3876 test_mkdir -p $DIR/$tdir/dir
3878 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3879 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3880 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3881 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3882 # On a buggy kernel addition of "touch foo" after cd .. will
3883 # produce kernel oops in lookup_hash_it
3884 touch ../foo && error "'cd ..' worked after recreate parent"
3886 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3888 run_test 48e "Access to recreated parent subdir (should return errors)"
3890 test_49() { # LU-1030
3891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3892 # get ost1 size - lustre-OST0000
3893 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3895 # write 800M at maximum
3896 [[ $ost1_size -lt 2 ]] && ost1_size=2
3897 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3899 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3900 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3903 # change max_pages_per_rpc while writing the file
3904 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3905 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3906 # loop until dd process exits
3907 while ps ax -opid | grep -wq $dd_pid; do
3908 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3909 sleep $((RANDOM % 5 + 1))
3911 # restore original max_pages_per_rpc
3912 $LCTL set_param $osc1_mppc=$orig_mppc