2 # -*- tab-width: 4; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
20 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
197 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
198 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
199 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
200 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
201 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
203 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
206 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
207 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
208 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
209 error "$tfile does not have perm 0666 or UID $UID"
210 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
211 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
212 error "$tfile should be 0666 and owned by UID $UID"
214 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
217 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
219 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
220 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
221 error "$tfile should be owned by UID $RUNAS_ID"
222 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
223 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
224 error "$tfile should be owned by UID $RUNAS_ID"
226 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
229 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
231 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
232 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
233 error "$tfile should be owned by GID $UID"
234 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
235 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
236 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
238 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
241 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
242 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
243 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
244 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
245 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
246 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
247 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
248 error "$tdir/d/subdir should be GID $RUNAS_GID"
250 run_test 6g "Is new dir in sgid dir inheriting group?"
252 test_6h() { # bug 7331
253 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 touch $DIR/$tfile || error "touch failed"
255 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
256 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
257 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
258 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
259 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
261 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
264 test_mkdir $DIR/$tdir
265 $MCREATE $DIR/$tdir/$tfile
266 chmod 0666 $DIR/$tdir/$tfile
267 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
268 error "$tdir/$tfile should be mode 0666"
270 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
273 if [ ! -d $DIR/$tdir ]; then
276 $MCREATE $DIR/$tdir/$tfile
277 echo -n foo > $DIR/$tdir/$tfile
278 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
279 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
281 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
284 test_mkdir $DIR/$tdir
285 touch $DIR/$tdir/$tfile
286 chmod 0666 $DIR/$tdir/$tfile
287 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
288 error "$tfile mode not 0666"
290 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
293 test_mkdir $DIR/$tdir
294 test_mkdir $DIR/$tdir/d2
295 test_mkdir $DIR/$tdir/d2/d3
296 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
298 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
301 test_mkdir $DIR/$tdir
302 test_mkdir $DIR/$tdir/d2
303 touch $DIR/$tdir/d2/$tfile
304 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
305 error "$tdir/d2/$tfile not a file"
307 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
310 test_mkdir $DIR/$tdir
311 test_mkdir $DIR/$tdir/d2
312 chmod 0666 $DIR/$tdir/d2
313 chmod 0705 $DIR/$tdir/d2
314 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
315 error "$tdir/d2 mode not 0705"
317 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
320 test_mkdir $DIR/$tdir
321 touch $DIR/$tdir/$tfile
322 chmod 0666 $DIR/$tdir/$tfile
323 chmod 0654 $DIR/$tdir/$tfile
324 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
325 error "$tdir/d2 mode not 0654"
327 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
330 test_mkdir $DIR/$tdir
331 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
333 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
334 error "$tdir/$tfile size not 0 after truncate"
336 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
342 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
344 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
347 test_mkdir $DIR/$tdir
348 touch $DIR/$tdir/$tfile
349 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
350 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
351 error "$tdir/${tfile_2} not a file after rename"
353 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
358 rm -rf $DIR/$tdir/$tfile
359 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
361 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
364 test_mkdir -p $DIR/$tdir
365 touch $DIR/$tdir/$tfile
366 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
368 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
369 error "$tdir/l-exist not a symlink"
370 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
371 error "$tdir/l-exist not referencing a file"
372 rm -f $DIR/$tdir/l-exist
373 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
375 run_test 17a "symlinks: create, remove (real) =================="
378 test_mkdir -p $DIR/$tdir
379 ln -s no-such-file $DIR/$tdir/l-dangle
381 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
382 error "$tdir/l-dangle not referencing no-such-file"
383 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
384 error "$tdir/l-dangle not referencing non-existent file"
385 rm -f $DIR/$tdir/l-dangle
386 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
388 run_test 17b "symlinks: create, remove (dangling) =============="
390 test_17c() { # bug 3440 - don't save failed open RPC for replay
391 test_mkdir -p $DIR/$tdir
392 ln -s foo $DIR/$tdir/$tfile
393 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
395 run_test 17c "symlinks: open dangling (should return error) ===="
398 test_mkdir -p $DIR/$tdir
399 ln -s foo $DIR/$tdir/$tfile
400 touch $DIR/$tdir/$tfile || error "creating to new symlink"
402 run_test 17d "symlinks: create dangling ========================"
405 test_mkdir -p $DIR/$tdir
406 local foo=$DIR/$tdir/$tfile
407 ln -s $foo $foo || error "create symlink failed"
408 ls -l $foo || error "ls -l failed"
409 ls $foo && error "ls not failed" || true
411 run_test 17e "symlinks: create recursive symlink (should return error) ===="
414 test_mkdir -p $DIR/d17f
415 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
416 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
417 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
418 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
419 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
420 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
423 run_test 17f "symlinks: long and very long symlink name ========================"
425 # str_repeat(S, N) generate a string that is string S repeated N times
430 while [ $((n -= 1)) -ge 0 ]; do
436 # Long symlinks and LU-2241
438 test_mkdir -p $DIR/$tdir
439 local TESTS="59 60 61 4094 4095"
441 # Fix for inode size boundary in 2.1.4
442 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
445 # Patch not applied to 2.2 or 2.3 branches
446 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
447 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
451 local SYMNAME=$(str_repeat 'x' $i)
452 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
453 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
456 run_test 17g "symlinks: really long symlink name and inode boundaries"
458 test_17h() { #bug 17378
459 remote_mds_nodsh && skip "remote MDS with nodsh" && return
460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
462 test_mkdir -p $DIR/$tdir
463 if [ $MDSCOUNT -gt 1 ]; then
464 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
468 $SETSTRIPE -c -1 $DIR/$tdir
469 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
470 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
471 touch $DIR/$tdir/$tfile || true
473 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
475 test_17i() { #bug 20018
476 remote_mds_nodsh && skip "remote MDS with nodsh" && return
477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
478 test_mkdir -p $DIR/$tdir
479 local foo=$DIR/$tdir/$tfile
481 if [ $MDSCOUNT -gt 1 ]; then
482 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
486 ln -s $foo $foo || error "create symlink failed"
487 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
488 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
489 ls -l $foo && error "error not detected"
492 run_test 17i "don't panic on short symlink"
494 test_17k() { #bug 22301
495 rsync --help | grep -q xattr ||
496 skip_env "$(rsync --version| head -1) does not support xattrs"
497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
498 test_mkdir -p $DIR/$tdir
499 test_mkdir -p $DIR/$tdir.new
500 touch $DIR/$tdir/$tfile
501 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
502 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
503 error "rsync failed with xattrs enabled"
505 run_test 17k "symlinks: rsync with xattrs enabled ========================="
507 test_17l() { # LU-279
509 touch $DIR/$tdir/$tfile
510 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
511 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
512 # -h to not follow symlinks. -m '' to list all the xattrs.
513 # grep to remove first line: '# file: $path'.
514 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
516 lgetxattr_size_check $path $xattr ||
517 error "lgetxattr_size_check $path $xattr failed"
521 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
525 local short_sym="0123456789"
526 local WDIR=$DIR/${tdir}m
533 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
534 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
535 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
537 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
538 skip "only for ldiskfs MDT" && return 0
540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
544 # create a long symlink file
545 for ((i = 0; i < 4; ++i)); do
546 long_sym=${long_sym}${long_sym}
549 echo "create 512 short and long symlink files under $WDIR"
550 for ((i = 0; i < 256; ++i)); do
551 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
552 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
558 wait_delete_completed
560 echo "recreate the 512 symlink files with a shorter string"
561 for ((i = 0; i < 512; ++i)); do
562 # rewrite the symlink file with a shorter string
563 ln -sf ${long_sym} $WDIR/long-$i
564 ln -sf ${short_sym} $WDIR/short-$i
567 mds_index=$($LFS getstripe -M $WDIR)
568 mds_index=$((mds_index+1))
569 devname=$(mdsdevname $mds_index)
570 cmd="$E2FSCK -fnvd $devname"
572 echo "stop and checking mds${mds_index}: $cmd"
573 # e2fsck should not return error
574 stop mds${mds_index} -f
575 do_facet mds${mds_index} $cmd || rc=$?
577 start mds${mds_index} $devname $MDS_MOUNT_OPTS
578 df $MOUNT > /dev/null 2>&1
579 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
580 "short/long symlink MDT: rc=$rc"
583 run_test 17m "run e2fsck against MDT which contains short/long symlink"
585 check_fs_consistency_17n() {
591 for mdt_index in $(seq 1 $MDSCOUNT); do
592 devname=$(mdsdevname $mdt_index)
593 cmd="$E2FSCK -fnvd $devname"
595 echo "stop and checking mds${mdt_index}: $cmd"
596 # e2fsck should not return error
598 do_facet mds${mdt_index} $cmd || rc=$?
600 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
601 df $MOUNT > /dev/null 2>&1
602 [ $rc -ne 0 ] && break
610 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
611 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
612 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
614 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
615 skip "only for ldiskfs MDT" && return 0
617 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
622 for ((i=0; i<10; i++)); do
623 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
624 error "create remote dir error $i"
625 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
626 error "create files under remote dir failed $i"
629 check_fs_consistency_17n || error "e2fsck report error"
631 for ((i=0;i<10;i++)); do
632 rm -rf $DIR/$tdir/remote_dir_${i} ||
633 error "destroy remote dir error $i"
636 check_fs_consistency_17n || error "e2fsck report error"
638 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
641 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
642 skip "Need MDS version at least 2.3.64" && return
644 local WDIR=$DIR/${tdir}o
650 mdt_index=$($LFS getstripe -M $WDIR)
651 mdt_index=$((mdt_index+1))
652 mdtdevname=$(mdsdevname $mdt_index)
656 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
658 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
659 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
660 ls -l $WDIR/$tfile && rc=1
661 do_facet mds${mdt_index} lctl set_param fail_loc=0
662 [[ $rc -ne 0 ]] && error "stat file should fail"
665 run_test 17o "stat file with incompat LMA feature"
668 touch $DIR/f || error "Failed to touch $DIR/f: $?"
669 ls $DIR || error "Failed to ls $DIR: $?"
671 run_test 18 "touch .../f ; ls ... =============================="
677 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
679 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
682 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
684 run_test 19b "ls -l .../f19 (should return error) =============="
687 [ $RUNAS_ID -eq $UID ] &&
688 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
689 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
691 run_test 19c "$RUNAS touch .../f19 (should return error) =="
694 cat $DIR/f19 && error || true
696 run_test 19d "cat .../f19 (should return error) =============="
708 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
710 run_test 20 "touch .../f ; ls -l ... ==========================="
713 test_mkdir -p $DIR/$tdir
714 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
715 ln -s dangle $DIR/$tdir/link
716 echo foo >> $DIR/$tdir/link
717 cat $DIR/$tdir/dangle
718 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
719 $CHECKSTAT -f -t file $DIR/$tdir/link ||
720 error "$tdir/link not linked to a file"
722 run_test 21 "write to dangling link ============================"
726 test_mkdir -p $DIR/$tdir
727 chown $RUNAS_ID:$RUNAS_GID $WDIR
728 (cd $WDIR || error "cd $WDIR failed";
729 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
731 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
732 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
733 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
735 run_test 22 "unpack tar archive as non-root user ==============="
739 test_mkdir -p $DIR/$tdir
740 local file=$DIR/$tdir/$tfile
742 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
743 openfile -f O_CREAT:O_EXCL $file &&
744 error "$file recreate succeeded" || true
746 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
748 test_23b() { # bug 18988
749 test_mkdir -p $DIR/$tdir
750 local file=$DIR/$tdir/$tfile
753 echo foo > $file || error "write filed"
754 echo bar >> $file || error "append filed"
755 $CHECKSTAT -s 8 $file || error "wrong size"
758 run_test 23b "O_APPEND check =========================="
762 echo '-- same directory rename'
763 test_mkdir $DIR/$tdir
764 touch $DIR/$tdir/$tfile.1
765 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
766 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
768 run_test 24a "rename file to non-existent target"
771 test_mkdir $DIR/$tdir
772 touch $DIR/$tdir/$tfile.{1,2}
773 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
774 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
775 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
777 run_test 24b "rename file to existing target"
780 test_mkdir $DIR/$tdir
781 test_mkdir $DIR/$tdir/d$testnum.1
782 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
783 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
784 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
786 run_test 24c "rename directory to non-existent target"
789 test_mkdir $DIR/$tdir
790 test_mkdir $DIR/$tdir/d$testnum.1
791 test_mkdir $DIR/$tdir/d$testnum.2
792 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
793 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
794 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
796 run_test 24d "rename directory to existing target"
799 echo '-- cross directory renames --'
803 mv $DIR/R5a/f $DIR/R5b/g
804 $CHECKSTAT -a $DIR/R5a/f || error
805 $CHECKSTAT -t file $DIR/R5b/g || error
807 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
812 touch $DIR/R6a/f $DIR/R6b/g
813 mv $DIR/R6a/f $DIR/R6b/g
814 $CHECKSTAT -a $DIR/R6a/f || error
815 $CHECKSTAT -t file $DIR/R6b/g || error
817 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
822 test_mkdir $DIR/R7a/d
823 mv $DIR/R7a/d $DIR/R7b/e
824 $CHECKSTAT -a $DIR/R7a/d || error
825 $CHECKSTAT -t dir $DIR/R7b/e || error
827 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
832 test_mkdir $DIR/R8a/d
833 test_mkdir $DIR/R8b/e
834 mrename $DIR/R8a/d $DIR/R8b/e
835 $CHECKSTAT -a $DIR/R8a/d || error
836 $CHECKSTAT -t dir $DIR/R8b/e || error
838 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
841 echo "-- rename error cases"
845 mrename $DIR/R9/f $DIR/R9/a
846 $CHECKSTAT -t file $DIR/R9/f || error
847 $CHECKSTAT -t dir $DIR/R9/a || error
848 $CHECKSTAT -a $DIR/R9/a/f || error
850 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
854 mrename $DIR/R10/f $DIR/R10/g
855 $CHECKSTAT -t dir $DIR/R10 || error
856 $CHECKSTAT -a $DIR/R10/f || error
857 $CHECKSTAT -a $DIR/R10/g || error
859 run_test 24j "source does not exist ============================"
863 test_mkdir $DIR/R11a/d
865 mv $DIR/R11a/f $DIR/R11a/d
866 $CHECKSTAT -a $DIR/R11a/f || error
867 $CHECKSTAT -t file $DIR/R11a/d/f || error
869 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
871 # bug 2429 - rename foo foo foo creates invalid file
874 $MULTIOP $f OcNs || error
876 run_test 24l "Renaming a file to itself ========================"
880 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
881 # on ext3 this does not remove either the source or target files
882 # though the "expected" operation would be to remove the source
883 $CHECKSTAT -t file ${f} || error "${f} missing"
884 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
886 run_test 24m "Renaming a file to a hard link to itself ========="
890 # this stats the old file after it was renamed, so it should fail
894 $CHECKSTAT ${f}.rename
897 run_test 24n "Statting the old file after renaming (Posix rename 2)"
900 check_kernel_version 37 || return 0
901 test_mkdir -p $DIR/d24o
902 rename_many -s random -v -n 10 $DIR/d24o
904 run_test 24o "rename of files during htree split ==============="
909 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
910 mrename $DIR/R12a $DIR/R12b
911 $CHECKSTAT -a $DIR/R12a || error
912 $CHECKSTAT -t dir $DIR/R12b || error
913 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
914 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
916 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
918 cleanup_multiop_pause() {
924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
927 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
928 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
931 trap cleanup_multiop_pause EXIT
932 mrename $DIR/R13a $DIR/R13b
933 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
934 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
935 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
936 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
937 cleanup_multiop_pause
938 wait $MULTIPID || error "multiop close failed"
940 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
942 test_24r() { #bug 3789
944 test_mkdir $DIR/R14a/b
945 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
946 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
947 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
949 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
953 test_mkdir $DIR/R15a/b
954 test_mkdir $DIR/R15a/b/c
955 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
956 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
957 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
959 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
962 test_mkdir $DIR/R16a/b
963 test_mkdir $DIR/R16a/b/c
964 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
965 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
966 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
968 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
970 test_24u() { # bug12192
972 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
973 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
975 run_test 24u "create stripe file"
981 simple_cleanup_common() {
984 wait_delete_completed
987 max_pages_per_rpc() {
988 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
993 local FREE_INODES=$(mdt_free_inodes 0)
994 [ $FREE_INODES -lt $NRFILES ] && \
995 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
999 trap simple_cleanup_common EXIT
1001 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1002 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1005 createmany -m $DIR/$tdir/$tfile $NRFILES
1007 cancel_lru_locks mdc
1008 lctl set_param mdc.*.stats clear
1010 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1012 # LU-5 large readdir
1013 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1014 # 8 bytes for name(filename is mostly 5 in this test) +
1015 # 8 bytes for luda_type
1016 # take into account of overhead in lu_dirpage header and end mark in
1017 # each page, plus one in RPC_NUM calculation.
1019 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1020 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1021 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1022 awk '/^mds_readpage/ {print $2}')
1023 [ $mds_readpage -gt $RPC_NUM ] && \
1024 error "large readdir doesn't take effect"
1026 simple_cleanup_common
1028 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1030 test_24w() { # bug21506
1032 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1033 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1034 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1035 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1036 [ "$SZ1" = "$SZ2" ] || \
1037 error "Error reading at the end of the file $tfile"
1039 run_test 24w "Reading a file larger than 4Gb"
1042 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1043 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1045 local remote_dir=$DIR/$tdir/remote_dir
1048 $LFS mkdir -i $MDTIDX $remote_dir ||
1049 error "create remote directory failed"
1051 mkdir -p $DIR/$tdir/src_dir
1052 touch $DIR/$tdir/src_file
1053 mkdir -p $remote_dir/tgt_dir
1054 touch $remote_dir/tgt_file
1056 mrename $remote_dir $DIR/ &&
1057 error "rename dir cross MDT works!"
1059 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1060 error "rename dir cross MDT works!"
1062 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1063 error "rename file cross MDT works!"
1065 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1066 error "ln file cross MDT should not work!"
1068 rm -rf $DIR/$tdir || error "Can not delete directories"
1070 run_test 24x "cross rename/link should be failed"
1073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1076 local remote_dir=$DIR/$tdir/remote_dir
1079 $LFS mkdir -i $MDTIDX $remote_dir ||
1080 error "create remote directory failed"
1082 mkdir -p $remote_dir/src_dir
1083 touch $remote_dir/src_file
1084 mkdir -p $remote_dir/tgt_dir
1085 touch $remote_dir/tgt_file
1087 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1088 error "rename subdir in the same remote dir failed!"
1090 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1091 error "rename files in the same remote dir failed!"
1093 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1094 error "link files in the same remote dir failed!"
1096 rm -rf $DIR/$tdir || error "Can not delete directories"
1098 run_test 24y "rename/link on the same dir should succeed"
1101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1104 local remote_src=$DIR/$tdir/remote_dir
1105 local remote_tgt=$DIR/$tdir/remote_tgt
1108 $LFS mkdir -i $MDTIDX $remote_src ||
1109 error "create remote directory failed"
1111 $LFS mkdir -i $MDTIDX $remote_tgt ||
1112 error "create remote directory failed"
1114 mrename $remote_src $remote_tgt &&
1115 error "rename remote dirs should not work!"
1117 # If target dir does not exists, it should succeed
1119 mrename $remote_src $remote_tgt ||
1120 error "rename remote dirs(tgt dir does not exists) failed!"
1122 rm -rf $DIR/$tdir || error "Can not delete directories"
1124 run_test 24z "rename one remote dir to another remote dir should fail"
1126 test_24A() { # LU-3182
1131 createmany -m $DIR/$tdir/$tfile $NFILES
1132 local t=`ls $DIR/$tdir | wc -l`
1133 local u=`ls $DIR/$tdir | sort -u | wc -l`
1134 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1135 error "Expected $NFILES files, got $t ($u unique)"
1138 rm -rf $DIR/$tdir || error "Can not delete directories"
1140 run_test 24A "readdir() returns correct number of entries."
1143 echo '== symlink sanity ============================================='
1147 touch $DIR/s25/foo || error
1149 run_test 25a "create file in symlinked directory ==============="
1152 [ ! -d $DIR/d25 ] && test_25a
1153 $CHECKSTAT -t file $DIR/s25/foo || error
1155 run_test 25b "lookup file in symlinked directory ==============="
1159 test_mkdir $DIR/d26/d26-2
1160 ln -s d26/d26-2 $DIR/s26
1161 touch $DIR/s26/foo || error
1163 run_test 26a "multiple component symlink ======================="
1166 test_mkdir -p $DIR/d26b/d26-2
1167 ln -s d26b/d26-2/foo $DIR/s26-2
1168 touch $DIR/s26-2 || error
1170 run_test 26b "multiple component symlink at end of lookup ======"
1173 test_mkdir $DIR/d26.2
1174 touch $DIR/d26.2/foo
1175 ln -s d26.2 $DIR/s26.2-1
1176 ln -s s26.2-1 $DIR/s26.2-2
1177 ln -s s26.2-2 $DIR/s26.2-3
1178 chmod 0666 $DIR/s26.2-3/foo
1180 run_test 26c "chain of symlinks ================================"
1182 # recursive symlinks (bug 439)
1184 ln -s d26-3/foo $DIR/d26-3
1186 run_test 26d "create multiple component recursive symlink ======"
1189 [ ! -h $DIR/d26-3 ] && test_26d
1192 run_test 26e "unlink multiple component recursive symlink ======"
1194 # recursive symlinks (bug 7022)
1196 test_mkdir -p $DIR/$tdir
1197 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1198 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1199 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1200 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1201 cd $tfile || error "cd $tfile failed"
1202 ln -s .. dotdot || error "ln dotdot failed"
1203 ln -s dotdot/lndir lndir || error "ln lndir failed"
1204 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1205 output=`ls $tfile/$tfile/lndir/bar1`
1206 [ "$output" = bar1 ] && error "unexpected output"
1207 rm -r $tfile || error "rm $tfile failed"
1208 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1210 run_test 26f "rm -r of a directory which has recursive symlink ="
1213 echo '== stripe sanity =============================================='
1214 test_mkdir -p $DIR/d27 || error "mkdir failed"
1216 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1217 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1219 log "== test_27a: write to one stripe file ========================="
1220 cp /etc/hosts $DIR/d27/f0 || error
1222 run_test 27a "one stripe file =================================="
1225 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1226 test_mkdir -p $DIR/d27
1227 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1228 $GETSTRIPE -c $DIR/d27/f01
1229 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1230 error "two-stripe file doesn't have two stripes"
1232 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1234 run_test 27b "create and write to two stripe file"
1237 test_mkdir -p $DIR/d27
1238 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1239 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1240 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1242 run_test 27d "create file with default settings ================"
1245 test_mkdir -p $DIR/d27
1246 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1247 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1248 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1250 run_test 27e "setstripe existing file (should return error) ======"
1253 test_mkdir -p $DIR/d27
1254 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1255 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1256 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1258 run_test 27f "setstripe with bad stripe size (should return error)"
1261 test_mkdir -p $DIR/d27
1262 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1263 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1264 error "$DIR/d27/fnone has object"
1266 run_test 27g "$GETSTRIPE with no objects"
1269 touch $DIR/d27/fsome || error "touch failed"
1270 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1272 run_test 27i "$GETSTRIPE with some objects"
1275 test_mkdir -p $DIR/d27
1276 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1278 run_test 27j "setstripe with bad stripe offset (should return error)"
1280 test_27k() { # bug 2844
1281 test_mkdir -p $DIR/d27
1283 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1284 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1285 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1286 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1287 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1288 dd if=/dev/zero of=$FILE bs=4k count=1
1289 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1290 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1292 run_test 27k "limit i_blksize for broken user apps ============="
1295 test_mkdir -p $DIR/d27
1296 mcreate $DIR/f27l || error "creating file"
1297 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1298 error "setstripe should have failed" || true
1300 run_test 27l "check setstripe permissions (should return error)"
1303 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1305 if [ $ORIGFREE -gt $MAXFREE ]; then
1306 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1309 trap simple_cleanup_common EXIT
1310 test_mkdir -p $DIR/$tdir
1311 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1312 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1313 error "dd should fill OST0"
1315 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1317 [ $i -gt 256 ] && break
1320 touch $DIR/$tdir/f27m_$i
1321 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1322 error "OST0 was full but new created file still use it"
1324 touch $DIR/$tdir/f27m_$i
1325 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1326 error "OST0 was full but new created file still use it"
1327 simple_cleanup_common
1329 run_test 27m "create file while OST0 was full =================="
1332 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1336 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1337 # if the OST isn't full anymore.
1339 local OSTIDX=${1:-""}
1341 local list=$(comma_list $(osts_nodes))
1342 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1344 do_nodes $list lctl set_param fail_loc=0
1345 sync # initiate all OST_DESTROYs from MDS to OST
1349 exhaust_precreations() {
1352 local FAILIDX=${3:-$OSTIDX}
1354 test_mkdir -p $DIR/$tdir
1355 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1356 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1358 local OST=$(ostname_from_index $OSTIDX)
1359 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1360 sed -e 's/_UUID$//;s/^.*-//')
1363 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1364 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1365 osc.$mdtosc_proc1.prealloc_last_id)
1366 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1367 osc.$mdtosc_proc1.prealloc_next_id)
1369 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1370 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1372 test_mkdir -p $DIR/$tdir/${OST}
1373 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1374 #define OBD_FAIL_OST_ENOSPC 0x215
1375 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1376 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1377 echo "Creating to objid $last_id on ost $OST..."
1378 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1379 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1380 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1384 exhaust_all_precreations() {
1386 for (( i=0; i < OSTCOUNT; i++ )) ; do
1387 exhaust_precreations $i $1 -1
1392 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1394 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1395 remote_ost_nodsh && skip "remote OST with nodsh" && return
1398 rm -f $DIR/$tdir/$tfile
1399 exhaust_precreations 0 0x80000215
1400 $SETSTRIPE -c -1 $DIR/$tdir
1401 touch $DIR/$tdir/$tfile || error
1402 $GETSTRIPE $DIR/$tdir/$tfile
1405 run_test 27n "create file with some full OSTs =================="
1408 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1410 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1411 remote_ost_nodsh && skip "remote OST with nodsh" && return
1414 rm -f $DIR/$tdir/$tfile
1415 exhaust_all_precreations 0x215
1417 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1422 run_test 27o "create file with all full OSTs (should error) ===="
1425 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1427 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1428 remote_ost_nodsh && skip "remote OST with nodsh" && return
1431 rm -f $DIR/$tdir/$tfile
1432 test_mkdir -p $DIR/$tdir
1434 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1435 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1436 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1438 exhaust_precreations 0 0x80000215
1439 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1440 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1441 $GETSTRIPE $DIR/$tdir/$tfile
1445 run_test 27p "append to a truncated file with some full OSTs ==="
1448 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1449 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1450 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1451 remote_ost_nodsh && skip "remote OST with nodsh" && return
1454 rm -f $DIR/$tdir/$tfile
1456 test_mkdir -p $DIR/$tdir
1457 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1458 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1459 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1461 exhaust_all_precreations 0x215
1463 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1464 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1468 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1471 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1473 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1474 remote_ost_nodsh && skip "remote OST with nodsh" && return
1477 rm -f $DIR/$tdir/$tfile
1478 exhaust_precreations 0 0x80000215
1480 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1484 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1486 test_27s() { # bug 10725
1487 test_mkdir -p $DIR/$tdir
1488 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1489 local stripe_count=0
1490 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1491 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1492 error "stripe width >= 2^32 succeeded" || true
1495 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1497 test_27t() { # bug 10864
1502 $WLFS getstripe $tfile
1505 run_test 27t "check that utils parse path correctly"
1507 test_27u() { # bug 4900
1508 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1509 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1511 local list=$(comma_list $(mdts_nodes))
1513 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1514 do_nodes $list $LCTL set_param fail_loc=0x139
1515 test_mkdir -p $DIR/$tdir
1517 createmany -o $DIR/$tdir/t- 1000
1518 do_nodes $list $LCTL set_param fail_loc=0
1520 TLOG=$DIR/$tfile.getstripe
1521 $GETSTRIPE $DIR/$tdir > $TLOG
1522 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1523 unlinkmany $DIR/$tdir/t- 1000
1524 [ $OBJS -gt 0 ] && \
1525 error "$OBJS objects created on OST-0. See $TLOG" || pass
1527 run_test 27u "skip object creation on OSC w/o objects =========="
1529 test_27v() { # bug 4900
1530 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1531 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1533 remote_ost_nodsh && skip "remote OST with nodsh" && return
1535 exhaust_all_precreations 0x215
1538 test_mkdir -p $DIR/$tdir
1539 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1541 touch $DIR/$tdir/$tfile
1542 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1544 for (( i=1; i < OSTCOUNT; i++ )); do
1545 do_facet ost$i lctl set_param fail_loc=0x705
1547 local START=`date +%s`
1548 createmany -o $DIR/$tdir/$tfile 32
1550 local FINISH=`date +%s`
1551 local TIMEOUT=`lctl get_param -n timeout`
1552 local PROCESS=$((FINISH - START))
1553 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1554 error "$FINISH - $START >= $TIMEOUT / 2"
1555 sleep $((TIMEOUT / 2 - PROCESS))
1558 run_test 27v "skip object creation on slow OST ================="
1560 test_27w() { # bug 10997
1561 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1562 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1563 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1564 error "stripe size $size != 65536" || true
1565 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1566 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1568 run_test 27w "check $SETSTRIPE -S option"
1571 [ "$OSTCOUNT" -lt "2" ] &&
1572 skip_env "skipping multiple stripe count/offset test" && return
1574 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1575 for i in $(seq 1 $OSTCOUNT); do
1577 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1578 error "setstripe -c $i -i $offset failed"
1579 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1580 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1581 [ $count -ne $i ] && error "stripe count $count != $i" || true
1582 [ $index -ne $offset ] &&
1583 error "stripe offset $index != $offset" || true
1586 run_test 27wa "check $SETSTRIPE -c -i options"
1589 remote_ost_nodsh && skip "remote OST with nodsh" && return
1590 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1592 OFFSET=$(($OSTCOUNT - 1))
1594 local OST=$(ostname_from_index $OSTIDX)
1596 test_mkdir -p $DIR/$tdir
1597 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1598 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1600 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1601 for i in `seq 0 $OFFSET`; do
1602 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1603 error "OST0 was degraded but new created file still use it"
1605 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1607 run_test 27x "create files while OST0 is degraded"
1610 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1611 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1612 remote_ost_nodsh && skip "remote OST with nodsh" && return
1613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1615 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1616 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1617 osc.$mdtosc.prealloc_last_id)
1618 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1619 osc.$mdtosc.prealloc_next_id)
1620 local fcount=$((last_id - next_id))
1621 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1622 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1624 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1625 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1626 local OST_DEACTIVE_IDX=-1
1631 for OSC in $MDS_OSCS; do
1632 OST=$(osc_to_ost $OSC)
1633 OSTIDX=$(index_from_ostuuid $OST)
1634 if [ $OST_DEACTIVE_IDX == -1 ]; then
1635 OST_DEACTIVE_IDX=$OSTIDX
1637 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1638 echo $OSC "is Deactivated:"
1639 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1643 OSTIDX=$(index_from_ostuuid $OST)
1645 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1647 for OSC in $MDS_OSCS; do
1648 OST=$(osc_to_ost $OSC)
1649 OSTIDX=$(index_from_ostuuid $OST)
1650 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1651 echo $OST "is degraded:"
1652 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1653 obdfilter.$OST.degraded=1
1658 createmany -o $DIR/$tdir/$tfile $fcount
1660 for OSC in $MDS_OSCS; do
1661 OST=$(osc_to_ost $OSC)
1662 OSTIDX=$(index_from_ostuuid $OST)
1663 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1664 echo $OST "is recovered from degraded:"
1665 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1666 obdfilter.$OST.degraded=0
1668 do_facet $SINGLEMDS lctl --device %$OSC activate
1672 # all osp devices get activated, hence -1 stripe count restored
1675 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1676 # devices get activated.
1678 $SETSTRIPE -c -1 $DIR/$tfile
1679 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1681 [ $stripecnt -ne $OSTCOUNT ] &&
1682 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1685 run_test 27y "create files while OST0 is degraded and the rest inactive"
1691 lmm_count=$($GETSTRIPE -c $1)
1692 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1693 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1695 local old_ifs="$IFS"
1697 fid=($($LFS path2fid $1))
1700 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1701 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1703 # compare lmm_seq and lu_fid->f_seq
1704 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1705 # compare lmm_object_id and lu_fid->oid
1706 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1708 # check the trusted.fid attribute of the OST objects of the file
1709 local have_obdidx=false
1711 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1712 # skip lines up to and including "obdidx"
1713 [ -z "$obdidx" ] && break
1714 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1715 $have_obdidx || continue
1717 local ost=$((obdidx + 1))
1718 local dev=$(ostdevname $ost)
1721 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1723 seq=$(echo $seq | sed -e "s/^0x//g")
1724 if [ $seq == 0 ]; then
1725 oid_hex=$(echo $oid)
1727 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1729 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1733 # Don't unmount/remount the OSTs if we don't need to do that.
1734 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1735 # update too, until that use mount/ll_decode_filter_fid/mount.
1736 # Re-enable when debugfs will understand new filter_fid.
1738 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1739 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1740 $dev 2>/dev/null" | grep "parent=")
1743 mount_fstype ost$ost
1744 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1745 $(facet_mntpt ost$ost)/$obj_file)
1746 unmount_fstype ost$ost
1747 start ost$ost $dev $OST_MOUNT_OPTS
1750 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1752 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1754 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1755 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1756 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1757 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1758 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1760 if echo $ff_parent | grep -q 'stripe='; then
1761 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1764 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1765 # into f_ver in this case. See the comment on
1768 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1772 # compare lmm_seq and filter_fid->ff_parent.f_seq
1773 [ $ff_pseq = $lmm_seq ] ||
1774 error "FF parent SEQ $ff_pseq != $lmm_seq"
1775 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1776 [ $ff_poid = $lmm_oid ] ||
1777 error "FF parent OID $ff_poid != $lmm_oid"
1778 (($ff_pstripe == $stripe_nr)) ||
1779 error "FF stripe $ff_pstripe != $stripe_nr"
1781 stripe_nr=$((stripe_nr + 1))
1786 remote_ost_nodsh && skip "remote OST with nodsh" && return
1787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1788 test_mkdir -p $DIR/$tdir
1790 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1791 { error "setstripe -c -1 failed"; return 1; }
1792 # We need to send a write to every object to get parent FID info set.
1793 # This _should_ also work for setattr, but does not currently.
1794 # touch $DIR/$tdir/$tfile-1 ||
1795 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1796 { error "dd $tfile-1 failed"; return 2; }
1797 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1798 { error "setstripe -c -1 failed"; return 3; }
1799 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1800 { error "dd $tfile-2 failed"; return 4; }
1802 # make sure write RPCs have been sent to OSTs
1805 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1806 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1808 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1810 test_27A() { # b=19102
1811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1812 local restore_size=$($GETSTRIPE -S $MOUNT)
1813 local restore_count=$($GETSTRIPE -c $MOUNT)
1814 local restore_offset=$($GETSTRIPE -i $MOUNT)
1815 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1816 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1817 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1818 local default_size=$($GETSTRIPE -S $MOUNT)
1819 local default_offset=$($GETSTRIPE -i $MOUNT)
1820 local dsize=$((1024 * 1024))
1821 [ $default_size -eq $dsize ] ||
1822 error "stripe size $default_size != $dsize"
1823 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1824 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1826 run_test 27A "check filesystem-wide default LOV EA values"
1828 test_27B() { # LU-2523
1829 test_mkdir -p $DIR/$tdir
1830 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1832 # open f1 with O_LOV_DELAY_CREATE
1834 # call setstripe ioctl on open file descriptor for f1
1836 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1840 # open f1 with O_LOV_DELAY_CREATE
1842 # call setstripe ioctl on open file descriptor for f1
1844 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1846 # Allow multiop to fail in imitation of NFS's busted semantics.
1849 run_test 27B "call setstripe on open unlinked file/rename victim"
1851 test_27C() { #LU-2871
1852 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1860 test_mkdir -p $DIR/$tdir
1862 for i in $(seq 0 $((OSTCOUNT - 1))); do
1863 # set stripe across all OSTs starting from OST$i
1864 $SETSTRIPE -i $i -c -1 $tfile$i
1865 # get striping information
1866 ost_idx=($($GETSTRIPE $tfile$i |
1867 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1871 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1872 error "${#ost_idx[@]} != $OSTCOUNT"
1874 for index in $(seq 0 $((OSTCOUNT - 1))); do
1876 for j in $(echo ${ost_idx[@]}); do
1877 if [ $index -eq $j ]; then
1883 error "Can not find $index in ${ost_idx[@]}"
1887 run_test 27C "check full striping across all OSTs"
1889 # createtest also checks that device nodes are created and
1890 # then visible correctly (#2091)
1891 test_28() { # bug 2091
1893 $CREATETEST $DIR/d28/ct || error
1895 run_test 28 "create/mknod/mkdir with bad file types ============"
1898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1899 cancel_lru_locks mdc
1905 declare -i LOCKCOUNTORIG=0
1906 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1907 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1909 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1911 declare -i LOCKUNUSEDCOUNTORIG=0
1912 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1913 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1920 declare -i LOCKCOUNTCURRENT=0
1921 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1922 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1925 declare -i LOCKUNUSEDCOUNTCURRENT=0
1926 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1927 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1930 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1931 lctl set_param -n ldlm.dump_namespaces ""
1932 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1933 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1934 log "dumped log to $TMP/test_29.dk (bug 5793)"
1937 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1938 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1939 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1940 log "dumped log to $TMP/test_29.dk (bug 5793)"
1944 run_test 29 "IT_GETATTR regression ============================"
1946 test_30a() { # was test_30
1947 cp `which ls` $DIR || cp /bin/ls $DIR
1951 run_test 30a "execute binary from Lustre (execve) =============="
1954 cp `which ls` $DIR || cp /bin/ls $DIR
1956 $RUNAS $DIR/ls / || error
1959 run_test 30b "execute binary from Lustre as non-root ==========="
1961 test_30c() { # b=22376
1962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1963 cp `which ls` $DIR || cp /bin/ls $DIR
1965 cancel_lru_locks mdc
1966 cancel_lru_locks osc
1967 $RUNAS $DIR/ls / || error
1970 run_test 30c "execute binary from Lustre without read perms ===="
1973 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1974 $CHECKSTAT -a $DIR/f31 || error
1976 run_test 31a "open-unlink file =================================="
1979 touch $DIR/f31 || error
1980 ln $DIR/f31 $DIR/f31b || error
1981 $MULTIOP $DIR/f31b Ouc || error
1982 $CHECKSTAT -t file $DIR/f31 || error
1984 run_test 31b "unlink file with multiple links while open ======="
1987 touch $DIR/f31 || error
1988 ln $DIR/f31 $DIR/f31c || error
1989 multiop_bg_pause $DIR/f31 O_uc || return 1
1991 $MULTIOP $DIR/f31c Ouc
1992 kill -USR1 $MULTIPID
1995 run_test 31c "open-unlink file with multiple links ============="
1998 opendirunlink $DIR/d31d $DIR/d31d || error
1999 $CHECKSTAT -a $DIR/d31d || error
2001 run_test 31d "remove of open directory ========================="
2003 test_31e() { # bug 2904
2004 check_kernel_version 34 || return 0
2005 openfilleddirunlink $DIR/d31e || error
2007 run_test 31e "remove of open non-empty directory ==============="
2009 test_31f() { # bug 4554
2010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2012 test_mkdir $DIR/d31f
2013 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2014 cp /etc/hosts $DIR/d31f
2016 $GETSTRIPE $DIR/d31f/hosts
2017 multiop_bg_pause $DIR/d31f D_c || return 1
2020 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2021 test_mkdir $DIR/d31f
2022 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2023 cp /etc/hosts $DIR/d31f
2025 $GETSTRIPE $DIR/d31f/hosts
2026 multiop_bg_pause $DIR/d31f D_c || return 1
2029 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2030 wait $MULTIPID || error "first opendir $MULTIPID failed"
2034 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2035 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2038 run_test 31f "remove of open directory with open-unlink file ==="
2041 echo "-- cross directory link --"
2042 test_mkdir $DIR/d31ga
2043 test_mkdir $DIR/d31gb
2045 ln $DIR/d31ga/f $DIR/d31gb/g
2046 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2047 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2048 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2049 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2051 run_test 31g "cross directory link==============="
2054 echo "-- cross directory link --"
2055 test_mkdir $DIR/d31h
2056 test_mkdir $DIR/d31h/dir
2058 ln $DIR/d31h/f $DIR/d31h/dir/g
2059 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2060 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2061 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2062 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2064 run_test 31h "cross directory link under child==============="
2067 echo "-- cross directory link --"
2068 test_mkdir $DIR/d31i
2069 test_mkdir $DIR/d31i/dir
2070 touch $DIR/d31i/dir/f
2071 ln $DIR/d31i/dir/f $DIR/d31i/g
2072 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2073 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2074 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2075 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2077 run_test 31i "cross directory link under parent==============="
2081 test_mkdir $DIR/d31j
2082 test_mkdir $DIR/d31j/dir1
2083 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2084 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2085 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2086 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2089 run_test 31j "link for directory==============="
2093 test_mkdir $DIR/d31k
2095 touch $DIR/d31k/exist
2096 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2097 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2098 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2099 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2100 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2101 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2102 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2105 run_test 31k "link to file: the same, non-existing, dir==============="
2108 test_mkdir $DIR/d31m
2110 test_mkdir $DIR/d31m2
2111 touch $DIR/d31m2/exist
2112 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2113 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2114 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2115 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2116 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2117 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2120 run_test 31m "link to file: the same, non-existing, dir==============="
2123 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2124 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2125 nlink=$(stat --format=%h $DIR/$tfile)
2126 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2128 local cmd="exec $fd<$DIR/$tfile"
2131 trap "eval $cmd" EXIT
2132 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2133 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2134 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2135 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2136 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2139 run_test 31n "check link count of unlinked file"
2142 local TEMPNAME=$(mktemp $1_XXXXXX)
2143 mlink $TEMPNAME $1 2> /dev/null &&
2144 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2148 test_31o() { # LU-2901
2150 for LOOP in $(seq 100); do
2151 rm -f $DIR/$tdir/$tfile*
2152 for THREAD in $(seq 8); do
2153 link_one $DIR/$tdir/$tfile.$LOOP &
2156 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2157 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2158 error "$LINKS duplicate links to $tfile.$LOOP" &&
2162 run_test 31o "duplicate hard links with same filename"
2164 cleanup_test32_mount() {
2166 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2171 echo "== more mountpoints and symlinks ================="
2172 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2173 trap cleanup_test32_mount EXIT
2174 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2175 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2176 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2177 cleanup_test32_mount
2179 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2183 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2184 trap cleanup_test32_mount EXIT
2185 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2186 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2187 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2188 cleanup_test32_mount
2190 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2193 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2194 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2195 trap cleanup_test32_mount EXIT
2196 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2197 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2198 test_mkdir -p $DIR/$tdir/d2/test_dir
2199 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2200 cleanup_test32_mount
2202 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2206 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2207 trap cleanup_test32_mount EXIT
2208 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2209 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2210 test_mkdir -p $DIR/$tdir/d2/test_dir
2211 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2212 cleanup_test32_mount
2214 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2217 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2218 test_mkdir -p $DIR/d32e/tmp
2219 TMP_DIR=$DIR/d32e/tmp
2220 ln -s $DIR/d32e $TMP_DIR/symlink11
2221 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2222 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2223 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2225 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2228 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2229 test_mkdir -p $DIR/d32f/tmp
2230 TMP_DIR=$DIR/d32f/tmp
2231 ln -s $DIR/d32f $TMP_DIR/symlink11
2232 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2233 ls $DIR/d32f/tmp/symlink11 || error
2234 ls $DIR/d32f/symlink01 || error
2236 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2239 TMP_DIR=$DIR/$tdir/tmp
2240 test_mkdir -p $DIR/$tdir/tmp
2241 test_mkdir $DIR/${tdir}2
2242 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2243 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2244 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2245 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2246 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2247 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2249 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2252 rm -fr $DIR/$tdir $DIR/${tdir}2
2253 TMP_DIR=$DIR/$tdir/tmp
2254 test_mkdir -p $DIR/$tdir/tmp
2255 test_mkdir $DIR/${tdir}2
2256 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2257 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2258 ls $TMP_DIR/symlink12 || error
2259 ls $DIR/$tdir/symlink02 || error
2261 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2264 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2265 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2266 trap cleanup_test32_mount EXIT
2267 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2268 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2269 touch $DIR/$tdir/test_file
2270 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2271 cleanup_test32_mount
2273 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2276 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2277 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2278 trap cleanup_test32_mount EXIT
2279 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2280 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2281 touch $DIR/$tdir/test_file
2282 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2283 cleanup_test32_mount
2285 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2290 trap cleanup_test32_mount EXIT
2291 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2292 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2293 test_mkdir -p $DIR/$tdir/d2
2294 touch $DIR/$tdir/d2/test_file || error
2295 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2296 cleanup_test32_mount
2298 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2303 trap cleanup_test32_mount EXIT
2304 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2305 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2306 test_mkdir -p $DIR/$tdir/d2
2307 touch $DIR/$tdir/d2/test_file
2308 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2309 cleanup_test32_mount
2311 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2315 test_mkdir -p $DIR/d32m/tmp
2316 TMP_DIR=$DIR/d32m/tmp
2317 ln -s $DIR $TMP_DIR/symlink11
2318 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2319 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2320 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2322 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2326 test_mkdir -p $DIR/d32n/tmp
2327 TMP_DIR=$DIR/d32n/tmp
2328 ln -s $DIR $TMP_DIR/symlink11
2329 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2330 ls -l $DIR/d32n/tmp/symlink11 || error
2331 ls -l $DIR/d32n/symlink01 || error
2333 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2336 rm -fr $DIR/d32o $DIR/$tfile
2338 test_mkdir -p $DIR/d32o/tmp
2339 TMP_DIR=$DIR/d32o/tmp
2340 ln -s $DIR/$tfile $TMP_DIR/symlink12
2341 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2342 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2343 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2344 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2345 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2347 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2357 test_mkdir -p $DIR/d32p/tmp
2359 TMP_DIR=$DIR/d32p/tmp
2361 ln -s $DIR/$tfile $TMP_DIR/symlink12
2363 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2365 cat $DIR/d32p/tmp/symlink12 || error
2367 cat $DIR/d32p/symlink02 || error
2370 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2372 cleanup_testdir_mount() {
2374 $UMOUNT -d $DIR/$tdir
2378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2379 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2380 trap cleanup_testdir_mount EXIT
2381 test_mkdir -p $DIR/$tdir
2382 touch $DIR/$tdir/under_the_mount
2383 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2384 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2385 cleanup_testdir_mount
2387 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2391 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2392 trap cleanup_testdir_mount EXIT
2393 test_mkdir -p $DIR/$tdir
2394 touch $DIR/$tdir/under_the_mount
2395 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2396 ls $DIR/$tdir | grep -q under_the_mount && error || true
2397 cleanup_testdir_mount
2399 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2404 chmod 444 $DIR/$tfile
2405 chown $RUNAS_ID $DIR/$tfile
2407 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2410 run_test 33aa "write file with mode 444 (should return error) ===="
2414 test_mkdir -p $DIR/d33
2415 chown $RUNAS_ID $DIR/d33
2416 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2417 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2418 error "open RDWR" || true
2420 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2424 test_mkdir -p $DIR/d33
2425 chown $RUNAS_ID $DIR/d33
2426 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2428 run_test 33b "test open file with malformed flags (No panic and return error)"
2431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2437 remote_ost_nodsh && skip "remote OST with nodsh" && return
2440 test_mkdir -p $DIR/d33
2441 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2444 for ostnum in $(seq $OSTCOUNT); do
2445 # test-framework's OST numbering is one-based, while Lustre's
2447 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2448 # Parsing llobdstat's output sucks; we could grep the /proc
2449 # path, but that's likely to not be as portable as using the
2450 # llobdstat utility. So we parse lctl output instead.
2451 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2452 obdfilter/$ostname/stats |
2453 awk '/^write_bytes/ {print $7}' )
2454 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2455 if (( ${write_bytes:-0} > 0 ))
2462 $all_zeros || return 0
2465 echo foo > $DIR/d33/bar
2469 # Total up write_bytes after writing. We'd better find non-zeros.
2470 for ostnum in $(seq $OSTCOUNT); do
2471 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2472 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2473 obdfilter/$ostname/stats |
2474 awk '/^write_bytes/ {print $7}' )
2475 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2476 if (( ${write_bytes:-0} > 0 ))
2485 for ostnum in $(seq $OSTCOUNT); do
2486 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2487 echo "Check that write_bytes is present in obdfilter/*/stats:"
2488 do_facet ost$ostnum lctl get_param -n \
2489 obdfilter/$ostname/stats
2491 error "OST not keeping write_bytes stats (b22312)"
2494 run_test 33c "test llobdstat and write_bytes"
2497 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2500 local remote_dir=$DIR/$tdir/remote_dir
2503 $LFS mkdir -i $MDTIDX $remote_dir ||
2504 error "create remote directory failed"
2506 touch $remote_dir/$tfile
2507 chmod 444 $remote_dir/$tfile
2508 chown $RUNAS_ID $remote_dir/$tfile
2510 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2512 chown $RUNAS_ID $remote_dir
2513 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2514 error "create" || true
2515 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2516 error "open RDWR" || true
2517 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2518 error "create" || true
2520 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2522 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2525 $MCREATE $DIR/f34 || error
2526 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2527 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2528 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2529 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2531 run_test 34a "truncate file that has not been opened ==========="
2534 [ ! -f $DIR/f34 ] && test_34a
2535 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2536 $OPENFILE -f O_RDONLY $DIR/f34
2537 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2538 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2540 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2543 [ ! -f $DIR/f34 ] && test_34a
2544 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2545 $OPENFILE -f O_RDWR $DIR/f34
2546 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2547 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2549 run_test 34c "O_RDWR opening file-with-size works =============="
2552 [ ! -f $DIR/f34 ] && test_34a
2553 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2554 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2557 run_test 34d "write to sparse file ============================="
2561 $MCREATE $DIR/f34e || error
2562 $TRUNCATE $DIR/f34e 1000 || error
2563 $CHECKSTAT -s 1000 $DIR/f34e || error
2564 $OPENFILE -f O_RDWR $DIR/f34e
2565 $CHECKSTAT -s 1000 $DIR/f34e || error
2567 run_test 34e "create objects, some with size and some without =="
2569 test_34f() { # bug 6242, 6243
2570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2573 $MCREATE $DIR/f34f || error
2574 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2575 dd if=$DIR/f34f of=$TMP/f34f
2576 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2577 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2578 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2579 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2580 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2582 run_test 34f "read from a file with no objects until EOF ======="
2585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2586 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2587 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2588 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2589 cancel_lru_locks osc
2590 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2591 error "wrong size after lock cancel"
2593 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2594 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2595 error "expanding truncate failed"
2596 cancel_lru_locks osc
2597 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2598 error "wrong expanded size after lock cancel"
2600 run_test 34g "truncate long file ==============================="
2603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2607 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2608 sync # Flush the cache so that multiop below does not block on cache
2609 # flush when getting the group lock
2610 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2613 # Since just timed wait is not good enough, let's do a sync write
2614 # that way we are sure enough time for a roundtrip + processing
2615 # passed + 2 seconds of extra margin.
2616 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2620 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2621 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2625 local nsz=`stat -c %s $DIR/$tfile`
2626 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2628 run_test 34h "ftruncate file under grouplock should not block"
2631 cp /bin/sh $DIR/f35a
2633 chown $RUNAS_ID $DIR/f35a
2634 $RUNAS $DIR/f35a && error || true
2637 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2641 utime $DIR/f36 || error
2643 run_test 36a "MDS utime check (mknod, utime) ==================="
2647 utime $DIR/f36 || error
2649 run_test 36b "OST utime check (open, utime) ===================="
2654 chown $RUNAS_ID $DIR/d36
2655 $RUNAS utime $DIR/d36/f36 || error
2657 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2660 [ ! -d $DIR/d36 ] && test_36c
2661 echo "" > $DIR/d36/f36
2662 $RUNAS utime $DIR/d36/f36 || error
2664 run_test 36d "non-root OST utime check (open, utime) ==========="
2667 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2668 test_mkdir -p $DIR/$tdir
2669 touch $DIR/$tdir/$tfile
2670 $RUNAS utime $DIR/$tdir/$tfile && \
2671 error "utime worked, expected failure" || true
2673 run_test 36e "utime on non-owned file (should return error) ===="
2677 local LANG_SAVE=$LANG
2678 local LC_LANG_SAVE=$LC_LANG
2679 export LANG=C LC_LANG=C # for date language
2681 DATESTR="Dec 20 2000"
2682 test_mkdir -p $DIR/$tdir
2683 lctl set_param fail_loc=$fl
2685 cp /etc/hosts $DIR/$tdir/$tfile
2686 sync & # write RPC generated with "current" inode timestamp, but delayed
2688 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2689 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2690 cancel_lru_locks osc
2691 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2693 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2694 echo "BEFORE: $LS_BEFORE" && \
2695 echo "AFTER : $LS_AFTER" && \
2696 echo "WANT : $DATESTR" && \
2697 error "$DIR/$tdir/$tfile timestamps changed" || true
2699 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2704 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2705 subr_36fh "0x80000214"
2707 run_test 36f "utime on file racing with OST BRW write =========="
2710 remote_ost_nodsh && skip "remote OST with nodsh" && return
2711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2716 test_mkdir -p $DIR/$tdir
2717 fmd_max_age=$(do_facet ost1 \
2718 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2721 fmd_before=$(do_facet ost1 \
2722 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2723 touch $DIR/$tdir/$tfile
2724 sleep $((fmd_max_age + 12))
2725 fmd_after=$(do_facet ost1 \
2726 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2728 echo "fmd_before: $fmd_before"
2729 echo "fmd_after: $fmd_after"
2730 [ "$fmd_after" -gt "$fmd_before" ] && \
2731 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2732 error "fmd didn't expire after ping" || true
2734 run_test 36g "filter mod data cache expiry ====================="
2737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2738 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2739 subr_36fh "0x80000227"
2741 run_test 36h "utime on file racing with OST BRW write =========="
2743 # test_37 - duplicate with tests 32q 32r
2746 local file=$DIR/$tfile
2748 openfile -f O_DIRECTORY $file
2751 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2752 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2754 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2758 touch $DIR/${tfile}2
2759 # ls -l $DIR/$tfile $DIR/${tfile}2
2760 # ls -lu $DIR/$tfile $DIR/${tfile}2
2761 # ls -lc $DIR/$tfile $DIR/${tfile}2
2763 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2764 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2766 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2768 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2770 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2771 error "O_TRUNC didn't change timestamps"
2774 run_test 39 "mtime changed on create ==========================="
2777 test_mkdir -p $DIR/$tdir
2778 cp -p /etc/passwd $DIR/$tdir/fopen
2779 cp -p /etc/passwd $DIR/$tdir/flink
2780 cp -p /etc/passwd $DIR/$tdir/funlink
2781 cp -p /etc/passwd $DIR/$tdir/frename
2782 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2785 echo "aaaaaa" >> $DIR/$tdir/fopen
2786 echo "aaaaaa" >> $DIR/$tdir/flink
2787 echo "aaaaaa" >> $DIR/$tdir/funlink
2788 echo "aaaaaa" >> $DIR/$tdir/frename
2790 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2791 local link_new=`stat -c %Y $DIR/$tdir/flink`
2792 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2793 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2795 cat $DIR/$tdir/fopen > /dev/null
2796 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2797 rm -f $DIR/$tdir/funlink2
2798 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2800 for (( i=0; i < 2; i++ )) ; do
2801 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2802 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2803 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2804 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2806 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2807 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2808 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2809 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2811 cancel_lru_locks osc
2812 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2815 run_test 39b "mtime change on open, link, unlink, rename ======"
2817 # this should be set to past
2818 TEST_39_MTIME=`date -d "1 year ago" +%s`
2824 local mtime0=`stat -c %Y $DIR1/$tfile`
2826 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2827 local mtime1=`stat -c %Y $DIR1/$tfile`
2828 [ "$mtime1" = $TEST_39_MTIME ] || \
2829 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2832 echo hello >> $DIR1/$tfile
2834 local mtime2=`stat -c %Y $DIR1/$tfile`
2835 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2836 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2838 mv $DIR1/$tfile $DIR1/$tfile-1
2840 for (( i=0; i < 2; i++ )) ; do
2841 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2842 [ "$mtime2" = "$mtime3" ] || \
2843 error "mtime ($mtime2) changed (to $mtime3) on rename"
2845 cancel_lru_locks osc
2846 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2849 run_test 39c "mtime change on rename ==========================="
2853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2856 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2858 for (( i=0; i < 2; i++ )) ; do
2859 local mtime=`stat -c %Y $DIR1/$tfile`
2860 [ $mtime = $TEST_39_MTIME ] || \
2861 error "mtime($mtime) is not set to $TEST_39_MTIME"
2863 cancel_lru_locks osc
2864 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2867 run_test 39d "create, utime, stat =============================="
2871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2873 local mtime1=`stat -c %Y $DIR1/$tfile`
2875 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2877 for (( i=0; i < 2; i++ )) ; do
2878 local mtime2=`stat -c %Y $DIR1/$tfile`
2879 [ $mtime2 = $TEST_39_MTIME ] || \
2880 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2882 cancel_lru_locks osc
2883 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2886 run_test 39e "create, stat, utime, stat ========================"
2890 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2892 mtime1=`stat -c %Y $DIR1/$tfile`
2895 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2897 for (( i=0; i < 2; i++ )) ; do
2898 local mtime2=`stat -c %Y $DIR1/$tfile`
2899 [ $mtime2 = $TEST_39_MTIME ] || \
2900 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2902 cancel_lru_locks osc
2903 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2906 run_test 39f "create, stat, sleep, utime, stat ================="
2910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2911 echo hello >> $DIR1/$tfile
2912 local mtime1=`stat -c %Y $DIR1/$tfile`
2915 chmod o+r $DIR1/$tfile
2917 for (( i=0; i < 2; i++ )) ; do
2918 local mtime2=`stat -c %Y $DIR1/$tfile`
2919 [ "$mtime1" = "$mtime2" ] || \
2920 error "lost mtime: $mtime2, should be $mtime1"
2922 cancel_lru_locks osc
2923 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2926 run_test 39g "write, chmod, stat ==============================="
2930 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2935 echo hello >> $DIR1/$tfile
2936 local mtime1=`stat -c %Y $DIR1/$tfile`
2938 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2940 if [ "$d1" != "$d2" ]; then
2941 echo "write and touch not within one second"
2943 for (( i=0; i < 2; i++ )) ; do
2944 local mtime2=`stat -c %Y $DIR1/$tfile`
2945 [ "$mtime2" = $TEST_39_MTIME ] || \
2946 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2948 cancel_lru_locks osc
2949 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2953 run_test 39h "write, utime within one second, stat ============="
2956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2960 echo hello >> $DIR1/$tfile
2961 local mtime1=`stat -c %Y $DIR1/$tfile`
2963 mv $DIR1/$tfile $DIR1/$tfile-1
2965 for (( i=0; i < 2; i++ )) ; do
2966 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2968 [ "$mtime1" = "$mtime2" ] || \
2969 error "lost mtime: $mtime2, should be $mtime1"
2971 cancel_lru_locks osc
2972 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2975 run_test 39i "write, rename, stat =============================="
2978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2979 start_full_debug_logging
2983 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2984 lctl set_param fail_loc=0x80000412
2985 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2986 error "multiop failed"
2988 local mtime1=`stat -c %Y $DIR1/$tfile`
2990 mv $DIR1/$tfile $DIR1/$tfile-1
2992 kill -USR1 $multipid
2993 wait $multipid || error "multiop close failed"
2995 for (( i=0; i < 2; i++ )) ; do
2996 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2997 [ "$mtime1" = "$mtime2" ] ||
2998 error "mtime is lost on close: $mtime2, " \
3001 cancel_lru_locks osc
3002 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3004 lctl set_param fail_loc=0
3005 stop_full_debug_logging
3007 run_test 39j "write, rename, close, stat ======================="
3010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3014 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3016 local mtime1=`stat -c %Y $DIR1/$tfile`
3018 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3020 kill -USR1 $multipid
3021 wait $multipid || error "multiop close failed"
3023 for (( i=0; i < 2; i++ )) ; do
3024 local mtime2=`stat -c %Y $DIR1/$tfile`
3026 [ "$mtime2" = $TEST_39_MTIME ] || \
3027 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3029 cancel_lru_locks osc
3030 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3033 run_test 39k "write, utime, close, stat ========================"
3035 # this should be set to future
3036 TEST_39_ATIME=`date -d "1 year" +%s`
3039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3040 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3041 local atime_diff=$(do_facet $SINGLEMDS \
3042 lctl get_param -n mdd.*MDT0000*.atime_diff)
3046 # test setting directory atime to future
3047 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3048 local atime=$(stat -c %X $DIR/$tdir)
3049 [ "$atime" = $TEST_39_ATIME ] || \
3050 error "atime is not set to future: $atime, $TEST_39_ATIME"
3052 # test setting directory atime from future to now
3053 local d1=$(date +%s)
3055 local d2=$(date +%s)
3057 cancel_lru_locks mdc
3058 atime=$(stat -c %X $DIR/$tdir)
3059 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3060 error "atime is not updated from future: $atime, $d1<atime<$d2"
3062 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3065 # test setting directory atime when now > dir atime + atime_diff
3069 cancel_lru_locks mdc
3070 atime=$(stat -c %X $DIR/$tdir)
3071 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3072 error "atime is not updated : $atime, should be $d2"
3074 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3077 # test not setting directory atime when now < dir atime + atime_diff
3079 cancel_lru_locks mdc
3080 atime=$(stat -c %X $DIR/$tdir)
3081 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3082 error "atime is updated to $atime, should remain $d1<atime<$d2"
3084 do_facet $SINGLEMDS \
3085 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3087 run_test 39l "directory atime update ==========================="
3090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3093 local far_past_mtime=$(date -d "May 29 1953" +%s)
3094 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3096 touch -m -d @$far_past_mtime $DIR1/$tfile
3097 touch -a -d @$far_past_atime $DIR1/$tfile
3099 for (( i=0; i < 2; i++ )) ; do
3100 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3101 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3102 error "atime or mtime set incorrectly"
3104 cancel_lru_locks osc
3105 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3108 run_test 39m "test atime and mtime before 1970"
3110 test_39n() { # LU-3832
3111 local atime_diff=$(do_facet $SINGLEMDS \
3112 lctl get_param -n mdd.*MDT0000*.atime_diff)
3117 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3120 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3121 atime0=$(stat -c %X $DIR/$tfile)
3124 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3125 atime1=$(stat -c %X $DIR/$tfile)
3128 cancel_lru_locks mdc
3129 cancel_lru_locks osc
3130 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3131 atime2=$(stat -c %X $DIR/$tfile)
3133 do_facet $SINGLEMDS \
3134 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3136 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3137 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3139 run_test 39n "check that O_NOATIME is honored"
3142 TESTDIR=$DIR/$tdir/$tfile
3143 [ -e $TESTDIR ] && rm -rf $TESTDIR
3144 test_mkdir -p $TESTDIR
3150 links2=$(stat -c %h .)
3151 [ $(($links1 + 2)) != $links2 ] &&
3152 error "wrong links count $(($links1 + 2)) != $links2"
3154 links3=$(stat -c %h .)
3155 [ $(($links1 + 1)) != $links3 ] &&
3156 error "wrong links count $links1 != $links3"
3159 run_test 39o "directory cached attributes updated after create ========"
3162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3164 TESTDIR=$DIR/$tdir/$tfile
3165 [ -e $TESTDIR ] && rm -rf $TESTDIR
3170 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3171 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3173 links2=$(stat -c %h .)
3174 [ $(($links1 + 2)) != $links2 ] &&
3175 error "wrong links count $(($links1 + 2)) != $links2"
3177 links3=$(stat -c %h .)
3178 [ $(($links1 + 1)) != $links3 ] &&
3179 error "wrong links count $links1 != $links3"
3182 run_test 39p "remote directory cached attributes updated after create ========"
3186 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3187 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3188 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3189 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3190 error "$tfile is not 4096 bytes in size"
3192 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3196 small_write $DIR/f41 18
3198 run_test 41 "test small file write + fstat ====================="
3200 count_ost_writes() {
3201 lctl get_param -n osc.*.stats |
3202 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3209 BG_DIRTY_RATIO_SAVE=10
3210 MAX_BG_DIRTY_RATIO=25
3214 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3215 # dirty_ratio, dirty_background_ratio
3216 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3217 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3218 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3219 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3221 # if file not here, we are a 2.4 kernel
3222 kill -CONT `pidof kupdated`
3227 # setup the trap first, so someone cannot exit the test at the
3228 # exact wrong time and mess up a machine
3229 trap start_writeback EXIT
3230 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3231 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3232 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3233 sysctl -w vm.dirty_writeback_centisecs=0
3234 sysctl -w vm.dirty_writeback_centisecs=0
3235 # save and increase /proc/sys/vm/dirty_ratio
3236 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3237 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3238 # save and increase /proc/sys/vm/dirty_background_ratio
3239 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3240 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3242 # if file not here, we are a 2.4 kernel
3243 kill -STOP `pidof kupdated`
3247 # ensure that all stripes have some grant before we test client-side cache
3249 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3250 dd if=/dev/zero of=$i bs=4k count=1
3255 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3256 # file truncation, and file removal.
3258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3260 cancel_lru_locks osc
3262 sync; sleep 1; sync # just to be safe
3263 BEFOREWRITES=`count_ost_writes`
3264 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3265 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3266 AFTERWRITES=`count_ost_writes`
3267 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3268 error "$BEFOREWRITES < $AFTERWRITES"
3271 run_test 42a "ensure that we don't flush on close =============="
3274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3276 cancel_lru_locks osc
3279 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3280 BEFOREWRITES=`count_ost_writes`
3281 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3282 AFTERWRITES=`count_ost_writes`
3283 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3284 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3286 BEFOREWRITES=`count_ost_writes`
3287 sync || error "sync: $?"
3288 AFTERWRITES=`count_ost_writes`
3289 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3290 error "$BEFOREWRITES < $AFTERWRITES on sync"
3292 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3296 run_test 42b "test destroy of file with cached dirty data ======"
3298 # if these tests just want to test the effect of truncation,
3299 # they have to be very careful. consider:
3300 # - the first open gets a {0,EOF}PR lock
3301 # - the first write conflicts and gets a {0, count-1}PW
3302 # - the rest of the writes are under {count,EOF}PW
3303 # - the open for truncate tries to match a {0,EOF}PR
3304 # for the filesize and cancels the PWs.
3305 # any number of fixes (don't get {0,EOF} on open, match
3306 # composite locks, do smarter file size management) fix
3307 # this, but for now we want these tests to verify that
3308 # the cancellation with truncate intent works, so we
3309 # start the file with a full-file pw lock to match against
3310 # until the truncate.
3315 cancel_lru_locks osc
3317 # prime the file with 0,EOF PW to match
3321 # now the real test..
3322 dd if=/dev/zero of=$file bs=1024 count=100
3323 BEFOREWRITES=`count_ost_writes`
3324 $TRUNCATE $file $offset
3325 cancel_lru_locks osc
3326 AFTERWRITES=`count_ost_writes`
3331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3333 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3334 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3337 run_test 42c "test partial truncate of file with cached dirty data"
3340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3342 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3343 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3346 run_test 42d "test complete truncate of file with cached dirty data"
3348 test_42e() { # bug22074
3349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3350 local TDIR=$DIR/${tdir}e
3351 local pagesz=$(page_size)
3352 local pages=16 # hardcoded 16 pages, don't change it.
3353 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3354 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3358 test_mkdir -p $DIR/${tdir}e
3359 $SETSTRIPE -c 1 $TDIR
3360 createmany -o $TDIR/f $files
3362 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3364 # we assume that with $OSTCOUNT files, at least one of them will
3365 # be allocated on OST0.
3366 warmup_files=$((OSTCOUNT * max_dirty_mb))
3367 createmany -o $TDIR/w $warmup_files
3369 # write a large amount of data into one file and sync, to get good
3370 # avail_grant number from OST.
3371 for ((i=0; i<$warmup_files; i++)); do
3372 idx=$($GETSTRIPE -i $TDIR/w$i)
3373 [ $idx -ne 0 ] && continue
3374 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3377 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3379 $LCTL get_param $proc_osc0/cur_dirty_bytes
3380 $LCTL get_param $proc_osc0/cur_grant_bytes
3382 # create as much dirty pages as we can while not to trigger the actual
3383 # RPCs directly. but depends on the env, VFS may trigger flush during this
3384 # period, hopefully we are good.
3385 for ((i=0; i<$warmup_files; i++)); do
3386 idx=$($GETSTRIPE -i $TDIR/w$i)
3387 [ $idx -ne 0 ] && continue
3388 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3390 $LCTL get_param $proc_osc0/cur_dirty_bytes
3391 $LCTL get_param $proc_osc0/cur_grant_bytes
3393 # perform the real test
3394 $LCTL set_param $proc_osc0/rpc_stats 0
3395 for ((;i<$files; i++)); do
3396 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3397 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null