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 0 "touch .../$tfile ; rm .../$tfile ====================="
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 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
199 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
200 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
202 run_test 4 "mkdir =============================================="
205 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
206 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
207 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
208 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
209 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
211 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
214 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
215 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
216 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
217 error "$tfile does not have perm 0666 or UID $UID"
219 run_test 6a "touch .../f6a; chmod .../f6a ======================"
222 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
223 if [ ! -f $DIR/$tfile ]; then
225 chmod 0666 $DIR/$tfile
227 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
228 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
229 error "$tfile should be 0666 and owned by UID $UID"
231 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by UID $RUNAS_ID"
240 run_test 6c "touch .../f6c; chown .../f6c ======================"
243 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
244 if [ ! -f $DIR/$tfile ]; then
246 chown $RUNAS_ID $DIR/$tfile
248 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
249 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
250 error "$tfile should be owned by UID $RUNAS_ID"
252 run_test 6d "$RUNAS chown .../f6c (should return error) =="
255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
257 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
258 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by GID $UID"
261 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
265 if [ ! -f $DIR/$tfile ]; then
267 chgrp $RUNAS_ID $DIR/$tfile
269 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
271 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
273 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
278 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
279 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
280 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
281 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
282 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
283 error "$tdir/d/subdir should be GID $RUNAS_GID"
285 run_test 6g "Is new dir in sgid dir inheriting group?"
287 test_6h() { # bug 7331
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 touch $DIR/$tfile || error "touch failed"
290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
291 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
292 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
293 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
294 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
296 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
299 test_mkdir $DIR/$tdir
300 $MCREATE $DIR/$tdir/$tfile
301 chmod 0666 $DIR/$tdir/$tfile
302 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
303 error "$tdir/$tfile should be mode 0666"
305 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
308 if [ ! -d $DIR/$tdir ]; then
311 $MCREATE $DIR/$tdir/$tfile
312 echo -n foo > $DIR/$tdir/$tfile
313 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
314 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
316 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
319 test_mkdir $DIR/$tdir
320 touch $DIR/$tdir/$tfile
321 chmod 0666 $DIR/$tdir/$tfile
322 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
323 error "$tfile mode not 0666"
325 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 test_mkdir $DIR/$tdir/d2/d3
331 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
333 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 touch $DIR/$tdir/d2/$tfile
339 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
340 error "$tdir/d2/$tfile not a file"
342 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
345 test_mkdir $DIR/$tdir
346 test_mkdir $DIR/$tdir/d2
347 chmod 0666 $DIR/$tdir/d2
348 chmod 0705 $DIR/$tdir/d2
349 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
350 error "$tdir/d2 mode not 0705"
352 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
357 chmod 0666 $DIR/$tdir/$tfile
358 chmod 0654 $DIR/$tdir/$tfile
359 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
360 error "$tdir/d2 mode not 0654"
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
365 test_mkdir $DIR/$tdir
366 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
368 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
369 error "$tdir/$tfile size not 0 after truncate"
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
382 test_mkdir $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
385 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
386 error "$tdir/${tfile_2} not a file after rename"
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
391 test_mkdir $DIR/$tdir
392 touch $DIR/$tdir/$tfile
393 rm -rf $DIR/$tdir/$tfile
394 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
399 test_mkdir -p $DIR/$tdir
400 touch $DIR/$tdir/$tfile
401 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
403 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
404 error "$tdir/l-exist not a symlink"
405 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
406 error "$tdir/l-exist not referencing a file"
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
417 error "$tdir/l-dangle not referencing no-such-file"
418 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
419 error "$tdir/l-dangle not referencing non-existent file"
420 rm -f $DIR/$tdir/l-dangle
421 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
423 run_test 17b "symlinks: create, remove (dangling) =============="
425 test_17c() { # bug 3440 - don't save failed open RPC for replay
426 test_mkdir -p $DIR/$tdir
427 ln -s foo $DIR/$tdir/$tfile
428 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
430 run_test 17c "symlinks: open dangling (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s foo $DIR/$tdir/$tfile
435 touch $DIR/$tdir/$tfile || error "creating to new symlink"
437 run_test 17d "symlinks: create dangling ========================"
440 test_mkdir -p $DIR/$tdir
441 local foo=$DIR/$tdir/$tfile
442 ln -s $foo $foo || error "create symlink failed"
443 ls -l $foo || error "ls -l failed"
444 ls $foo && error "ls not failed" || true
446 run_test 17e "symlinks: create recursive symlink (should return error) ===="
449 test_mkdir -p $DIR/d17f
450 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
455 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
458 run_test 17f "symlinks: long and very long symlink name ========================"
460 # str_repeat(S, N) generate a string that is string S repeated N times
465 while [ $((n -= 1)) -ge 0 ]; do
471 # Long symlinks and LU-2241
473 test_mkdir -p $DIR/$tdir
474 local TESTS="59 60 61 4094 4095"
476 # Fix for inode size boundary in 2.1.4
477 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
480 # Patch not applied to 2.2 or 2.3 branches
481 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
482 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
486 local SYMNAME=$(str_repeat 'x' $i)
487 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
488 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
491 run_test 17g "symlinks: really long symlink name and inode boundaries"
493 test_17h() { #bug 17378
494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
497 test_mkdir -p $DIR/$tdir
498 if [ $MDSCOUNT -gt 1 ]; then
499 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
503 $SETSTRIPE -c -1 $DIR/$tdir
504 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
505 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
506 touch $DIR/$tdir/$tfile || true
508 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
510 test_17i() { #bug 20018
511 remote_mds_nodsh && skip "remote MDS with nodsh" && return
512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
513 test_mkdir -p $DIR/$tdir
514 local foo=$DIR/$tdir/$tfile
516 if [ $MDSCOUNT -gt 1 ]; then
517 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
521 ln -s $foo $foo || error "create symlink failed"
522 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
523 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
524 ls -l $foo && error "error not detected"
527 run_test 17i "don't panic on short symlink"
529 test_17k() { #bug 22301
530 rsync --help | grep -q xattr ||
531 skip_env "$(rsync --version| head -1) does not support xattrs"
532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
533 test_mkdir -p $DIR/$tdir
534 test_mkdir -p $DIR/$tdir.new
535 touch $DIR/$tdir/$tfile
536 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
537 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
538 error "rsync failed with xattrs enabled"
540 run_test 17k "symlinks: rsync with xattrs enabled ========================="
542 test_17l() { # LU-279
544 touch $DIR/$tdir/$tfile
545 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
546 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
547 # -h to not follow symlinks. -m '' to list all the xattrs.
548 # grep to remove first line: '# file: $path'.
549 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
551 lgetxattr_size_check $path $xattr ||
552 error "lgetxattr_size_check $path $xattr failed"
556 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
560 local short_sym="0123456789"
561 local WDIR=$DIR/${tdir}m
568 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
569 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
570 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
572 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
573 skip "only for ldiskfs MDT" && return 0
575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
579 # create a long symlink file
580 for ((i = 0; i < 4; ++i)); do
581 long_sym=${long_sym}${long_sym}
584 echo "create 512 short and long symlink files under $WDIR"
585 for ((i = 0; i < 256; ++i)); do
586 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
587 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
593 wait_delete_completed
595 echo "recreate the 512 symlink files with a shorter string"
596 for ((i = 0; i < 512; ++i)); do
597 # rewrite the symlink file with a shorter string
598 ln -sf ${long_sym} $WDIR/long-$i
599 ln -sf ${short_sym} $WDIR/short-$i
602 mds_index=$($LFS getstripe -M $WDIR)
603 mds_index=$((mds_index+1))
604 devname=$(mdsdevname $mds_index)
605 cmd="$E2FSCK -fnvd $devname"
607 echo "stop and checking mds${mds_index}: $cmd"
608 # e2fsck should not return error
609 stop mds${mds_index} -f
610 do_facet mds${mds_index} $cmd || rc=$?
612 start mds${mds_index} $devname $MDS_MOUNT_OPTS
613 df $MOUNT > /dev/null 2>&1
614 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
615 "short/long symlink MDT: rc=$rc"
618 run_test 17m "run e2fsck against MDT which contains short/long symlink"
620 check_fs_consistency_17n() {
626 for mdt_index in $(seq 1 $MDSCOUNT); do
627 devname=$(mdsdevname $mdt_index)
628 cmd="$E2FSCK -fnvd $devname"
630 echo "stop and checking mds${mdt_index}: $cmd"
631 # e2fsck should not return error
633 do_facet mds${mdt_index} $cmd || rc=$?
635 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
636 df $MOUNT > /dev/null 2>&1
637 [ $rc -ne 0 ] && break
645 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
646 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
647 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
649 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
650 skip "only for ldiskfs MDT" && return 0
652 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
657 for ((i=0; i<10; i++)); do
658 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
659 error "create remote dir error $i"
660 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
661 error "create files under remote dir failed $i"
664 check_fs_consistency_17n || error "e2fsck report error"
666 for ((i=0;i<10;i++)); do
667 rm -rf $DIR/$tdir/remote_dir_${i} ||
668 error "destroy remote dir error $i"
671 check_fs_consistency_17n || error "e2fsck report error"
673 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
676 local WDIR=$DIR/${tdir}o
682 mdt_index=$($LFS getstripe -M $WDIR)
683 mdt_index=$((mdt_index+1))
684 mdtdevname=$(mdsdevname $mdt_index)
688 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
690 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
691 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
692 ls -l $WDIR/$tfile && rc=1
693 do_facet mds${mdt_index} lctl set_param fail_loc=0
694 [[ $rc -ne 0 ]] && error "stat file should fail"
697 run_test 17o "stat file with incompat LMA feature"
700 touch $DIR/f || error "Failed to touch $DIR/f: $?"
701 ls $DIR || error "Failed to ls $DIR: $?"
703 run_test 18 "touch .../f ; ls ... =============================="
709 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
711 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
714 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
716 run_test 19b "ls -l .../f19 (should return error) =============="
719 [ $RUNAS_ID -eq $UID ] &&
720 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
721 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
723 run_test 19c "$RUNAS touch .../f19 (should return error) =="
726 cat $DIR/f19 && error || true
728 run_test 19d "cat .../f19 (should return error) =============="
740 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
742 run_test 20 "touch .../f ; ls -l ... ==========================="
745 test_mkdir -p $DIR/$tdir
746 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
747 ln -s dangle $DIR/$tdir/link
748 echo foo >> $DIR/$tdir/link
749 cat $DIR/$tdir/dangle
750 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
751 $CHECKSTAT -f -t file $DIR/$tdir/link ||
752 error "$tdir/link not linked to a file"
754 run_test 21 "write to dangling link ============================"
758 test_mkdir -p $DIR/$tdir
759 chown $RUNAS_ID:$RUNAS_GID $WDIR
760 (cd $WDIR || error "cd $WDIR failed";
761 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
763 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
764 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
765 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
767 run_test 22 "unpack tar archive as non-root user ==============="
771 test_mkdir -p $DIR/$tdir
772 local file=$DIR/$tdir/$tfile
774 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
775 openfile -f O_CREAT:O_EXCL $file &&
776 error "$file recreate succeeded" || true
778 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
780 test_23b() { # bug 18988
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
785 echo foo > $file || error "write filed"
786 echo bar >> $file || error "append filed"
787 $CHECKSTAT -s 8 $file || error "wrong size"
790 run_test 23b "O_APPEND check =========================="
794 echo '-- same directory rename'
795 test_mkdir $DIR/$tdir
796 touch $DIR/$tdir/$tfile.1
797 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
798 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
800 run_test 24a "rename file to non-existent target"
803 test_mkdir $DIR/$tdir
804 touch $DIR/$tdir/$tfile.{1,2}
805 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
806 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
807 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
809 run_test 24b "rename file to existing target"
812 test_mkdir $DIR/$tdir
813 test_mkdir $DIR/$tdir/d$testnum.1
814 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
815 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
816 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
818 run_test 24c "rename directory to non-existent target"
821 test_mkdir $DIR/$tdir
822 test_mkdir $DIR/$tdir/d$testnum.1
823 test_mkdir $DIR/$tdir/d$ttestnum.2
824 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24d "rename directory to existing target"
831 echo '-- cross directory renames --'
835 mv $DIR/R5a/f $DIR/R5b/g
836 $CHECKSTAT -a $DIR/R5a/f || error
837 $CHECKSTAT -t file $DIR/R5b/g || error
839 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
844 touch $DIR/R6a/f $DIR/R6b/g
845 mv $DIR/R6a/f $DIR/R6b/g
846 $CHECKSTAT -a $DIR/R6a/f || error
847 $CHECKSTAT -t file $DIR/R6b/g || error
849 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
854 test_mkdir $DIR/R7a/d
855 mv $DIR/R7a/d $DIR/R7b/e
856 $CHECKSTAT -a $DIR/R7a/d || error
857 $CHECKSTAT -t dir $DIR/R7b/e || error
859 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
864 test_mkdir $DIR/R8a/d
865 test_mkdir $DIR/R8b/e
866 mrename $DIR/R8a/d $DIR/R8b/e
867 $CHECKSTAT -a $DIR/R8a/d || error
868 $CHECKSTAT -t dir $DIR/R8b/e || error
870 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
873 echo "-- rename error cases"
877 mrename $DIR/R9/f $DIR/R9/a
878 $CHECKSTAT -t file $DIR/R9/f || error
879 $CHECKSTAT -t dir $DIR/R9/a || error
880 $CHECKSTAT -a $DIR/R9/a/f || error
882 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
886 mrename $DIR/R10/f $DIR/R10/g
887 $CHECKSTAT -t dir $DIR/R10 || error
888 $CHECKSTAT -a $DIR/R10/f || error
889 $CHECKSTAT -a $DIR/R10/g || error
891 run_test 24j "source does not exist ============================"
895 test_mkdir $DIR/R11a/d
897 mv $DIR/R11a/f $DIR/R11a/d
898 $CHECKSTAT -a $DIR/R11a/f || error
899 $CHECKSTAT -t file $DIR/R11a/d/f || error
901 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
903 # bug 2429 - rename foo foo foo creates invalid file
906 $MULTIOP $f OcNs || error
908 run_test 24l "Renaming a file to itself ========================"
912 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
913 # on ext3 this does not remove either the source or target files
914 # though the "expected" operation would be to remove the source
915 $CHECKSTAT -t file ${f} || error "${f} missing"
916 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
918 run_test 24m "Renaming a file to a hard link to itself ========="
922 # this stats the old file after it was renamed, so it should fail
926 $CHECKSTAT ${f}.rename
929 run_test 24n "Statting the old file after renaming (Posix rename 2)"
932 check_kernel_version 37 || return 0
933 test_mkdir -p $DIR/d24o
934 rename_many -s random -v -n 10 $DIR/d24o
936 run_test 24o "rename of files during htree split ==============="
941 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
942 mrename $DIR/R12a $DIR/R12b
943 $CHECKSTAT -a $DIR/R12a || error
944 $CHECKSTAT -t dir $DIR/R12b || error
945 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
946 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
948 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
950 cleanup_multiop_pause() {
956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
959 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
960 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
963 trap cleanup_multiop_pause EXIT
964 mrename $DIR/R13a $DIR/R13b
965 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
966 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
967 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
968 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
969 cleanup_multiop_pause
970 wait $MULTIPID || error "multiop close failed"
972 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
974 test_24r() { #bug 3789
976 test_mkdir $DIR/R14a/b
977 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
978 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
979 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
981 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
985 test_mkdir $DIR/R15a/b
986 test_mkdir $DIR/R15a/b/c
987 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
988 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
989 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
991 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
994 test_mkdir $DIR/R16a/b
995 test_mkdir $DIR/R16a/b/c
996 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
998 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1000 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1002 test_24u() { # bug12192
1004 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1005 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1007 run_test 24u "create stripe file"
1013 simple_cleanup_common() {
1016 wait_delete_completed
1019 max_pages_per_rpc() {
1020 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1024 local NRFILES=100000
1025 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
1026 [ $FREE_INODES -lt $NRFILES ] && \
1027 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1031 trap simple_cleanup_common EXIT
1034 createmany -m $DIR/$tdir/$tfile $NRFILES
1036 cancel_lru_locks mdc
1037 lctl set_param mdc.*.stats clear
1039 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1041 # LU-5 large readdir
1042 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1043 # 8 bytes for name(filename is mostly 5 in this test) +
1044 # 8 bytes for luda_type
1045 # take into account of overhead in lu_dirpage header and end mark in
1046 # each page, plus one in RPC_NUM calculation.
1048 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1049 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1050 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1051 awk '/^mds_readpage/ {print $2}')
1052 [ $mds_readpage -gt $RPC_NUM ] && \
1053 error "large readdir doesn't take effect"
1055 simple_cleanup_common
1057 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1059 test_24w() { # bug21506
1061 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1062 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1063 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1064 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1065 [ "$SZ1" = "$SZ2" ] || \
1066 error "Error reading at the end of the file $tfile"
1068 run_test 24w "Reading a file larger than 4Gb"
1071 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1074 local remote_dir=$DIR/$tdir/remote_dir
1077 $LFS mkdir -i $MDTIDX $remote_dir ||
1078 error "create remote directory failed"
1080 mkdir -p $DIR/$tdir/src_dir
1081 touch $DIR/$tdir/src_file
1082 mkdir -p $remote_dir/tgt_dir
1083 touch $remote_dir/tgt_file
1085 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1086 error "rename dir cross MDT works!"
1088 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1089 error "rename file cross MDT works!"
1091 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1092 error "ln file cross MDT should not work!"
1094 rm -rf $DIR/$tdir || error "Can not delete directories"
1096 run_test 24x "cross rename/link should be failed"
1099 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 mkdir -p $remote_dir/src_dir
1109 touch $remote_dir/src_file
1110 mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1114 error "rename subdir in the same remote dir failed!"
1116 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1117 error "rename files in the same remote dir failed!"
1119 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1120 error "link files in the same remote dir failed!"
1122 rm -rf $DIR/$tdir || error "Can not delete directories"
1124 run_test 24y "rename/link on the same dir should succeed"
1127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1130 local remote_src=$DIR/$tdir/remote_dir
1131 local remote_tgt=$DIR/$tdir/remote_tgt
1134 $LFS mkdir -i $MDTIDX $remote_src ||
1135 error "create remote directory failed"
1137 $LFS mkdir -i $MDTIDX $remote_tgt ||
1138 error "create remote directory failed"
1140 mrename $remote_src $remote_tgt &&
1141 error "rename remote dirs should not work!"
1143 # If target dir does not exists, it should succeed
1145 mrename $remote_src $remote_tgt ||
1146 error "rename remote dirs(tgt dir does not exists) failed!"
1148 rm -rf $DIR/$tdir || error "Can not delete directories"
1150 run_test 24z "rename one remote dir to another remote dir should fail"
1153 echo '== symlink sanity ============================================='
1157 touch $DIR/s25/foo || error
1159 run_test 25a "create file in symlinked directory ==============="
1162 [ ! -d $DIR/d25 ] && test_25a
1163 $CHECKSTAT -t file $DIR/s25/foo || error
1165 run_test 25b "lookup file in symlinked directory ==============="
1169 test_mkdir $DIR/d26/d26-2
1170 ln -s d26/d26-2 $DIR/s26
1171 touch $DIR/s26/foo || error
1173 run_test 26a "multiple component symlink ======================="
1176 test_mkdir -p $DIR/d26b/d26-2
1177 ln -s d26b/d26-2/foo $DIR/s26-2
1178 touch $DIR/s26-2 || error
1180 run_test 26b "multiple component symlink at end of lookup ======"
1183 test_mkdir $DIR/d26.2
1184 touch $DIR/d26.2/foo
1185 ln -s d26.2 $DIR/s26.2-1
1186 ln -s s26.2-1 $DIR/s26.2-2
1187 ln -s s26.2-2 $DIR/s26.2-3
1188 chmod 0666 $DIR/s26.2-3/foo
1190 run_test 26c "chain of symlinks ================================"
1192 # recursive symlinks (bug 439)
1194 ln -s d26-3/foo $DIR/d26-3
1196 run_test 26d "create multiple component recursive symlink ======"
1199 [ ! -h $DIR/d26-3 ] && test_26d
1202 run_test 26e "unlink multiple component recursive symlink ======"
1204 # recursive symlinks (bug 7022)
1206 test_mkdir -p $DIR/$tdir
1207 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1208 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1209 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1210 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1211 cd $tfile || error "cd $tfile failed"
1212 ln -s .. dotdot || error "ln dotdot failed"
1213 ln -s dotdot/lndir lndir || error "ln lndir failed"
1214 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1215 output=`ls $tfile/$tfile/lndir/bar1`
1216 [ "$output" = bar1 ] && error "unexpected output"
1217 rm -r $tfile || error "rm $tfile failed"
1218 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1220 run_test 26f "rm -r of a directory which has recursive symlink ="
1223 echo '== stripe sanity =============================================='
1224 test_mkdir -p $DIR/d27 || error "mkdir failed"
1226 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1227 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1229 log "== test_27a: write to one stripe file ========================="
1230 cp /etc/hosts $DIR/d27/f0 || error
1232 run_test 27a "one stripe file =================================="
1235 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1236 test_mkdir -p $DIR/d27
1237 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1238 $GETSTRIPE -c $DIR/d27/f01
1239 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1240 error "two-stripe file doesn't have two stripes"
1242 run_test 27b "create two stripe file"
1245 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1247 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1249 run_test 27c "write to two stripe file"
1252 test_mkdir -p $DIR/d27
1253 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1254 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1255 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1257 run_test 27d "create file with default settings ================"
1260 test_mkdir -p $DIR/d27
1261 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1262 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1263 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1265 run_test 27e "setstripe existing file (should return error) ======"
1268 test_mkdir -p $DIR/d27
1269 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1270 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1271 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1273 run_test 27f "setstripe with bad stripe size (should return error)"
1276 test_mkdir -p $DIR/d27
1277 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1278 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1279 error "$DIR/d27/fnone has object"
1281 run_test 27g "$GETSTRIPE with no objects"
1284 touch $DIR/d27/fsome || error "touch failed"
1285 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1287 run_test 27i "$GETSTRIPE with some objects"
1290 test_mkdir -p $DIR/d27
1291 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1293 run_test 27j "setstripe with bad stripe offset (should return error)"
1295 test_27k() { # bug 2844
1296 test_mkdir -p $DIR/d27
1298 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1299 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1300 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1301 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1302 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1303 dd if=/dev/zero of=$FILE bs=4k count=1
1304 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1305 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1307 run_test 27k "limit i_blksize for broken user apps ============="
1310 test_mkdir -p $DIR/d27
1311 mcreate $DIR/f27l || error "creating file"
1312 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1313 error "setstripe should have failed" || true
1315 run_test 27l "check setstripe permissions (should return error)"
1318 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1320 if [ $ORIGFREE -gt $MAXFREE ]; then
1321 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1324 trap simple_cleanup_common EXIT
1325 test_mkdir -p $DIR/$tdir
1326 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1327 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1328 error "dd should fill OST0"
1330 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1332 [ $i -gt 256 ] && break
1335 touch $DIR/$tdir/f27m_$i
1336 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1337 error "OST0 was full but new created file still use it"
1339 touch $DIR/$tdir/f27m_$i
1340 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1341 error "OST0 was full but new created file still use it"
1342 simple_cleanup_common
1344 run_test 27m "create file while OST0 was full =================="
1347 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1351 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1352 # if the OST isn't full anymore.
1354 local OSTIDX=${1:-""}
1356 local list=$(comma_list $(osts_nodes))
1357 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1359 do_nodes $list lctl set_param fail_loc=0
1360 sync # initiate all OST_DESTROYs from MDS to OST
1364 exhaust_precreations() {
1367 local FAILIDX=${3:-$OSTIDX}
1369 test_mkdir -p $DIR/$tdir
1370 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1371 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1373 local OST=$(ostname_from_index $OSTIDX)
1374 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1375 sed -e 's/_UUID$//;s/^.*-//')
1378 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1379 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1380 osc.$mdtosc_proc1.prealloc_last_id)
1381 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1382 osc.$mdtosc_proc1.prealloc_next_id)
1384 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1385 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1387 test_mkdir -p $DIR/$tdir/${OST}
1388 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1389 #define OBD_FAIL_OST_ENOSPC 0x215
1390 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1391 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1392 echo "Creating to objid $last_id on ost $OST..."
1393 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1394 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1395 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1399 exhaust_all_precreations() {
1401 for (( i=0; i < OSTCOUNT; i++ )) ; do
1402 exhaust_precreations $i $1 -1
1407 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1410 remote_ost_nodsh && skip "remote OST with nodsh" && return
1413 rm -f $DIR/$tdir/$tfile
1414 exhaust_precreations 0 0x80000215
1415 $SETSTRIPE -c -1 $DIR/$tdir
1416 touch $DIR/$tdir/$tfile || error
1417 $GETSTRIPE $DIR/$tdir/$tfile
1420 run_test 27n "create file with some full OSTs =================="
1423 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1425 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1426 remote_ost_nodsh && skip "remote OST with nodsh" && return
1429 rm -f $DIR/$tdir/$tfile
1430 exhaust_all_precreations 0x215
1432 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1437 run_test 27o "create file with all full OSTs (should error) ===="
1440 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1442 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1443 remote_ost_nodsh && skip "remote OST with nodsh" && return
1446 rm -f $DIR/$tdir/$tfile
1447 test_mkdir -p $DIR/$tdir
1449 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1450 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1451 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1453 exhaust_precreations 0 0x80000215
1454 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1455 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1456 $GETSTRIPE $DIR/$tdir/$tfile
1460 run_test 27p "append to a truncated file with some full OSTs ==="
1463 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1465 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1466 remote_ost_nodsh && skip "remote OST with nodsh" && return
1469 rm -f $DIR/$tdir/$tfile
1471 test_mkdir -p $DIR/$tdir
1472 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1473 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1474 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1476 exhaust_all_precreations 0x215
1478 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1479 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1483 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1486 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1489 remote_ost_nodsh && skip "remote OST with nodsh" && return
1492 rm -f $DIR/$tdir/$tfile
1493 exhaust_precreations 0 0x80000215
1495 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1499 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1501 test_27s() { # bug 10725
1502 test_mkdir -p $DIR/$tdir
1503 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1504 local stripe_count=0
1505 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1506 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1507 error "stripe width >= 2^32 succeeded" || true
1510 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1512 test_27t() { # bug 10864
1517 $WLFS getstripe $tfile
1520 run_test 27t "check that utils parse path correctly"
1522 test_27u() { # bug 4900
1523 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1526 local list=$(comma_list $(mdts_nodes))
1528 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1529 do_nodes $list $LCTL set_param fail_loc=0x139
1530 test_mkdir -p $DIR/$tdir
1532 createmany -o $DIR/$tdir/t- 1000
1533 do_nodes $list $LCTL set_param fail_loc=0
1535 TLOG=$DIR/$tfile.getstripe
1536 $GETSTRIPE $DIR/$tdir > $TLOG
1537 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1538 unlinkmany $DIR/$tdir/t- 1000
1539 [ $OBJS -gt 0 ] && \
1540 error "$OBJS objects created on OST-0. See $TLOG" || pass
1542 run_test 27u "skip object creation on OSC w/o objects =========="
1544 test_27v() { # bug 4900
1545 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1548 remote_ost_nodsh && skip "remote OST with nodsh" && return
1550 exhaust_all_precreations 0x215
1553 test_mkdir -p $DIR/$tdir
1554 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1556 touch $DIR/$tdir/$tfile
1557 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1559 for (( i=1; i < OSTCOUNT; i++ )); do
1560 do_facet ost$i lctl set_param fail_loc=0x705
1562 local START=`date +%s`
1563 createmany -o $DIR/$tdir/$tfile 32
1565 local FINISH=`date +%s`
1566 local TIMEOUT=`lctl get_param -n timeout`
1567 local PROCESS=$((FINISH - START))
1568 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1569 error "$FINISH - $START >= $TIMEOUT / 2"
1570 sleep $((TIMEOUT / 2 - PROCESS))
1573 run_test 27v "skip object creation on slow OST ================="
1575 test_27w() { # bug 10997
1576 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1577 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1578 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1579 error "stripe size $size != 65536" || true
1580 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1581 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1583 run_test 27w "check $SETSTRIPE -S option"
1586 [ "$OSTCOUNT" -lt "2" ] &&
1587 skip_env "skipping multiple stripe count/offset test" && return
1589 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1590 for i in $(seq 1 $OSTCOUNT); do
1592 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1593 error "setstripe -c $i -i $offset failed"
1594 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1595 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1596 [ $count -ne $i ] && error "stripe count $count != $i" || true
1597 [ $index -ne $offset ] &&
1598 error "stripe offset $index != $offset" || true
1601 run_test 27wa "check $SETSTRIPE -c -i options"
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return
1605 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1607 OFFSET=$(($OSTCOUNT - 1))
1609 local OST=$(ostname_from_index $OSTIDX)
1611 test_mkdir -p $DIR/$tdir
1612 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1613 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1615 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1616 for i in `seq 0 $OFFSET`; do
1617 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1618 error "OST0 was degraded but new created file still use it"
1620 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1622 run_test 27x "create files while OST0 is degraded"
1625 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1626 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1627 remote_ost_nodsh && skip "remote OST with nodsh" && return
1628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1630 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1631 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1632 osc.$mdtosc.prealloc_last_id)
1633 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1634 osc.$mdtosc.prealloc_next_id)
1635 local fcount=$((last_id - next_id))
1636 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1637 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1639 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1640 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1641 local OST_DEACTIVE_IDX=-1
1646 for OSC in $MDS_OSCS; do
1647 OST=$(osc_to_ost $OSC)
1648 OSTIDX=$(index_from_ostuuid $OST)
1649 if [ $OST_DEACTIVE_IDX == -1 ]; then
1650 OST_DEACTIVE_IDX=$OSTIDX
1652 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1653 echo $OSC "is Deactivated:"
1654 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1658 OSTIDX=$(index_from_ostuuid $OST)
1660 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1662 for OSC in $MDS_OSCS; do
1663 OST=$(osc_to_ost $OSC)
1664 OSTIDX=$(index_from_ostuuid $OST)
1665 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1666 echo $OST "is degraded:"
1667 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1668 obdfilter.$OST.degraded=1
1673 createmany -o $DIR/$tdir/$tfile $fcount
1675 for OSC in $MDS_OSCS; do
1676 OST=$(osc_to_ost $OSC)
1677 OSTIDX=$(index_from_ostuuid $OST)
1678 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1679 echo $OST "is recovered from degraded:"
1680 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1681 obdfilter.$OST.degraded=0
1683 do_facet $SINGLEMDS lctl --device %$OSC activate
1687 # all osp devices get activated, hence -1 stripe count restored
1690 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1691 # devices get activated.
1693 $SETSTRIPE -c -1 $DIR/$tfile
1694 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1696 [ $stripecnt -ne $OSTCOUNT ] &&
1697 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1700 run_test 27y "create files while OST0 is degraded and the rest inactive"
1706 lmm_count=$($GETSTRIPE -c $1)
1707 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1708 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1710 local old_ifs="$IFS"
1712 fid=($($LFS path2fid $1))
1715 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1716 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1718 # compare lmm_seq and lu_fid->f_seq
1719 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1720 # compare lmm_object_id and lu_fid->oid
1721 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1723 # check the trusted.fid attribute of the OST objects of the file
1724 local have_obdidx=false
1726 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1727 # skip lines up to and including "obdidx"
1728 [ -z "$obdidx" ] && break
1729 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1730 $have_obdidx || continue
1732 local ost=$((obdidx + 1))
1733 local dev=$(ostdevname $ost)
1736 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1737 echo "Currently only works with ldiskfs-based OSTs"
1741 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1743 #don't unmount/remount the OSTs if we don't need to do that
1744 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1745 # update too, until that use mount/ll_decode_filter_fid/mount
1746 local dir=$(facet_mntpt ost$ost)
1747 local opts=${OST_MOUNT_OPTS}
1749 if ! do_facet ost$ost test -b ${dev}; then
1750 opts=$(csa_add "$opts" -o loop)
1754 do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir ||
1755 { error "mounting $dev as $FSTYPE failed"; return 3; }
1757 seq=$(echo $seq | sed -e "s/^0x//g")
1758 if [ $seq == 0 ]; then
1759 oid_hex=$(echo $oid)
1761 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1763 local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid_hex)
1764 local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1765 do_facet ost$ost umount -d $dir
1766 start ost$ost $dev $OST_MOUNT_OPTS
1768 # re-enable when debugfs will understand new filter_fid
1769 #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1770 # $dev 2>/dev/null" | grep "parent=")
1772 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1774 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1776 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1777 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1778 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1779 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1780 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1781 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1783 # compare lmm_seq and filter_fid->ff_parent.f_seq
1784 [ $ff_pseq = $lmm_seq ] ||
1785 error "FF parent SEQ $ff_pseq != $lmm_seq"
1786 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1787 [ $ff_poid = $lmm_oid ] ||
1788 error "FF parent OID $ff_poid != $lmm_oid"
1789 [ $ff_pstripe = $stripe_nr ] ||
1790 error "FF stripe $ff_pstripe != $stripe_nr"
1792 stripe_nr=$((stripe_nr + 1))
1797 remote_ost_nodsh && skip "remote OST with nodsh" && return
1798 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1799 test_mkdir -p $DIR/$tdir
1801 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1802 { error "setstripe -c -1 failed"; return 1; }
1803 # We need to send a write to every object to get parent FID info set.
1804 # This _should_ also work for setattr, but does not currently.
1805 # touch $DIR/$tdir/$tfile-1 ||
1806 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1807 { error "dd $tfile-1 failed"; return 2; }
1808 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1809 { error "setstripe -c -1 failed"; return 3; }
1810 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1811 { error "dd $tfile-2 failed"; return 4; }
1813 # make sure write RPCs have been sent to OSTs
1816 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1817 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1819 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1821 test_27A() { # b=19102
1822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1823 local restore_size=$($GETSTRIPE -S $MOUNT)
1824 local restore_count=$($GETSTRIPE -c $MOUNT)
1825 local restore_offset=$($GETSTRIPE -i $MOUNT)
1826 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1827 local default_size=$($GETSTRIPE -S $MOUNT)
1828 local default_count=$($GETSTRIPE -c $MOUNT)
1829 local default_offset=$($GETSTRIPE -i $MOUNT)
1830 local dsize=$((1024 * 1024))
1831 [ $default_size -eq $dsize ] ||
1832 error "stripe size $default_size != $dsize"
1833 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1834 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1835 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1837 run_test 27A "check filesystem-wide default LOV EA values"
1839 test_27B() { # LU-2523
1840 test_mkdir -p $DIR/$tdir
1841 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1843 # open f1 with O_LOV_DELAY_CREATE
1845 # call setstripe ioctl on open file descriptor for f1
1847 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1851 # open f1 with O_LOV_DELAY_CREATE
1853 # call setstripe ioctl on open file descriptor for f1
1855 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1857 # Allow multiop to fail in imitation of NFS's busted semantics.
1860 run_test 27B "call setstripe on open unlinked file/rename victim"
1862 test_27C() { #LU-2871
1863 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1871 test_mkdir -p $DIR/$tdir
1873 for i in $(seq 0 $((OSTCOUNT - 1))); do
1874 # set stripe across all OSTs starting from OST$i
1875 $SETSTRIPE -i $i -c -1 $tfile$i
1876 # get striping information
1877 ost_idx=($($GETSTRIPE $tfile$i |
1878 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1882 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1883 error "${#ost_idx[@]} != $OSTCOUNT"
1885 for index in $(seq 0 $((OSTCOUNT - 1))); do
1887 for j in $(echo ${ost_idx[@]}); do
1888 if [ $index -eq $j ]; then
1894 error "Can not find $index in ${ost_idx[@]}"
1898 run_test 27C "check full striping across all OSTs"
1900 # createtest also checks that device nodes are created and
1901 # then visible correctly (#2091)
1902 test_28() { # bug 2091
1904 $CREATETEST $DIR/d28/ct || error
1906 run_test 28 "create/mknod/mkdir with bad file types ============"
1909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1910 cancel_lru_locks mdc
1916 declare -i LOCKCOUNTORIG=0
1917 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1918 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1920 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1922 declare -i LOCKUNUSEDCOUNTORIG=0
1923 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1924 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1931 declare -i LOCKCOUNTCURRENT=0
1932 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1933 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1936 declare -i LOCKUNUSEDCOUNTCURRENT=0
1937 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1938 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1941 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1942 lctl set_param -n ldlm.dump_namespaces ""
1943 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1944 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1945 log "dumped log to $TMP/test_29.dk (bug 5793)"
1948 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1949 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1950 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1951 log "dumped log to $TMP/test_29.dk (bug 5793)"
1955 run_test 29 "IT_GETATTR regression ============================"
1957 test_30a() { # was test_30
1958 cp `which ls` $DIR || cp /bin/ls $DIR
1962 run_test 30a "execute binary from Lustre (execve) =============="
1965 cp `which ls` $DIR || cp /bin/ls $DIR
1967 $RUNAS $DIR/ls / || error
1970 run_test 30b "execute binary from Lustre as non-root ==========="
1972 test_30c() { # b=22376
1973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1974 cp `which ls` $DIR || cp /bin/ls $DIR
1976 cancel_lru_locks mdc
1977 cancel_lru_locks osc
1978 $RUNAS $DIR/ls / || error
1981 run_test 30c "execute binary from Lustre without read perms ===="
1984 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1985 $CHECKSTAT -a $DIR/f31 || error
1987 run_test 31a "open-unlink file =================================="
1990 touch $DIR/f31 || error
1991 ln $DIR/f31 $DIR/f31b || error
1992 $MULTIOP $DIR/f31b Ouc || error
1993 $CHECKSTAT -t file $DIR/f31 || error
1995 run_test 31b "unlink file with multiple links while open ======="
1998 touch $DIR/f31 || error
1999 ln $DIR/f31 $DIR/f31c || error
2000 multiop_bg_pause $DIR/f31 O_uc || return 1
2002 $MULTIOP $DIR/f31c Ouc
2003 kill -USR1 $MULTIPID
2006 run_test 31c "open-unlink file with multiple links ============="
2009 opendirunlink $DIR/d31d $DIR/d31d || error
2010 $CHECKSTAT -a $DIR/d31d || error
2012 run_test 31d "remove of open directory ========================="
2014 test_31e() { # bug 2904
2015 check_kernel_version 34 || return 0
2016 openfilleddirunlink $DIR/d31e || error
2018 run_test 31e "remove of open non-empty directory ==============="
2020 test_31f() { # bug 4554
2021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2023 test_mkdir $DIR/d31f
2024 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2025 cp /etc/hosts $DIR/d31f
2027 $GETSTRIPE $DIR/d31f/hosts
2028 multiop_bg_pause $DIR/d31f D_c || return 1
2031 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2032 test_mkdir $DIR/d31f
2033 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2034 cp /etc/hosts $DIR/d31f
2036 $GETSTRIPE $DIR/d31f/hosts
2037 multiop_bg_pause $DIR/d31f D_c || return 1
2040 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2041 wait $MULTIPID || error "first opendir $MULTIPID failed"
2045 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2046 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2049 run_test 31f "remove of open directory with open-unlink file ==="
2052 echo "-- cross directory link --"
2053 test_mkdir $DIR/d31ga
2054 test_mkdir $DIR/d31gb
2056 ln $DIR/d31ga/f $DIR/d31gb/g
2057 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2058 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2059 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2060 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2062 run_test 31g "cross directory link==============="
2065 echo "-- cross directory link --"
2066 test_mkdir $DIR/d31h
2067 test_mkdir $DIR/d31h/dir
2069 ln $DIR/d31h/f $DIR/d31h/dir/g
2070 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2071 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2072 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2073 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2075 run_test 31h "cross directory link under child==============="
2078 echo "-- cross directory link --"
2079 test_mkdir $DIR/d31i
2080 test_mkdir $DIR/d31i/dir
2081 touch $DIR/d31i/dir/f
2082 ln $DIR/d31i/dir/f $DIR/d31i/g
2083 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2084 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2085 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2086 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2088 run_test 31i "cross directory link under parent==============="
2092 test_mkdir $DIR/d31j
2093 test_mkdir $DIR/d31j/dir1
2094 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2095 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2096 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2097 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2100 run_test 31j "link for directory==============="
2104 test_mkdir $DIR/d31k
2106 touch $DIR/d31k/exist
2107 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2108 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2109 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2110 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2111 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2112 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2113 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2116 run_test 31k "link to file: the same, non-existing, dir==============="
2119 test_mkdir $DIR/d31m
2121 test_mkdir $DIR/d31m2
2122 touch $DIR/d31m2/exist
2123 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2124 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2125 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2126 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2127 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2128 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2131 run_test 31m "link to file: the same, non-existing, dir==============="
2134 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2135 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2136 nlink=$(stat --format=%h $DIR/$tfile)
2137 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2138 exec 173<$DIR/$tfile
2139 trap "exec 173<&-" EXIT
2140 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2141 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2142 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2143 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2144 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2147 run_test 31n "check link count of unlinked file"
2149 cleanup_test32_mount() {
2151 $UMOUNT $DIR/$tdir/ext2-mountpoint
2155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2156 echo "== more mountpoints and symlinks ================="
2157 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2158 trap cleanup_test32_mount EXIT
2159 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2160 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2161 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2162 cleanup_test32_mount
2164 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2168 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2169 trap cleanup_test32_mount EXIT
2170 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2171 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2172 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2173 cleanup_test32_mount
2175 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2179 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2180 trap cleanup_test32_mount EXIT
2181 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2182 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2183 test_mkdir -p $DIR/$tdir/d2/test_dir
2184 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2185 cleanup_test32_mount
2187 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2191 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2192 trap cleanup_test32_mount EXIT
2193 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2194 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2195 test_mkdir -p $DIR/$tdir/d2/test_dir
2196 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2197 cleanup_test32_mount
2199 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2202 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2203 test_mkdir -p $DIR/d32e/tmp
2204 TMP_DIR=$DIR/d32e/tmp
2205 ln -s $DIR/d32e $TMP_DIR/symlink11
2206 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2207 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2208 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2210 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2213 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2214 test_mkdir -p $DIR/d32f/tmp
2215 TMP_DIR=$DIR/d32f/tmp
2216 ln -s $DIR/d32f $TMP_DIR/symlink11
2217 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2218 ls $DIR/d32f/tmp/symlink11 || error
2219 ls $DIR/d32f/symlink01 || error
2221 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2224 TMP_DIR=$DIR/$tdir/tmp
2225 test_mkdir -p $DIR/$tdir/tmp
2226 test_mkdir $DIR/${tdir}2
2227 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2228 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2229 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2230 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2231 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2232 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2234 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2237 rm -fr $DIR/$tdir $DIR/${tdir}2
2238 TMP_DIR=$DIR/$tdir/tmp
2239 test_mkdir -p $DIR/$tdir/tmp
2240 test_mkdir $DIR/${tdir}2
2241 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2242 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2243 ls $TMP_DIR/symlink12 || error
2244 ls $DIR/$tdir/symlink02 || error
2246 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2250 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2251 trap cleanup_test32_mount EXIT
2252 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2253 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2254 touch $DIR/$tdir/test_file
2255 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2256 cleanup_test32_mount
2258 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2262 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2263 trap cleanup_test32_mount EXIT
2264 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2265 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2266 touch $DIR/$tdir/test_file
2267 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2268 cleanup_test32_mount
2270 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2275 trap cleanup_test32_mount EXIT
2276 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2277 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2278 test_mkdir -p $DIR/$tdir/d2
2279 touch $DIR/$tdir/d2/test_file || error
2280 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2281 cleanup_test32_mount
2283 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2288 trap cleanup_test32_mount EXIT
2289 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2290 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2291 test_mkdir -p $DIR/$tdir/d2
2292 touch $DIR/$tdir/d2/test_file
2293 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2294 cleanup_test32_mount
2296 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2300 test_mkdir -p $DIR/d32m/tmp
2301 TMP_DIR=$DIR/d32m/tmp
2302 ln -s $DIR $TMP_DIR/symlink11
2303 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2304 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2305 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2307 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2311 test_mkdir -p $DIR/d32n/tmp
2312 TMP_DIR=$DIR/d32n/tmp
2313 ln -s $DIR $TMP_DIR/symlink11
2314 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2315 ls -l $DIR/d32n/tmp/symlink11 || error
2316 ls -l $DIR/d32n/symlink01 || error
2318 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2321 rm -fr $DIR/d32o $DIR/$tfile
2323 test_mkdir -p $DIR/d32o/tmp
2324 TMP_DIR=$DIR/d32o/tmp
2325 ln -s $DIR/$tfile $TMP_DIR/symlink12
2326 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2327 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2328 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2329 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2330 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2332 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2342 test_mkdir -p $DIR/d32p/tmp
2344 TMP_DIR=$DIR/d32p/tmp
2346 ln -s $DIR/$tfile $TMP_DIR/symlink12
2348 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2350 cat $DIR/d32p/tmp/symlink12 || error
2352 cat $DIR/d32p/symlink02 || error
2355 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2357 cleanup_testdir_mount() {
2363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2364 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2365 trap cleanup_testdir_mount EXIT
2366 test_mkdir -p $DIR/$tdir
2367 touch $DIR/$tdir/under_the_mount
2368 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2369 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2370 cleanup_testdir_mount
2372 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2376 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2377 trap cleanup_testdir_mount EXIT
2378 test_mkdir -p $DIR/$tdir
2379 touch $DIR/$tdir/under_the_mount
2380 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2381 ls $DIR/$tdir | grep -q under_the_mount && error || true
2382 cleanup_testdir_mount
2384 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2389 chmod 444 $DIR/$tfile
2390 chown $RUNAS_ID $DIR/$tfile
2392 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2395 run_test 33aa "write file with mode 444 (should return error) ===="
2399 test_mkdir -p $DIR/d33
2400 chown $RUNAS_ID $DIR/d33
2401 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2402 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2403 error "open RDWR" || true
2405 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2409 test_mkdir -p $DIR/d33
2410 chown $RUNAS_ID $DIR/d33
2411 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2413 run_test 33b "test open file with malformed flags (No panic and return error)"
2416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2422 remote_ost_nodsh && skip "remote OST with nodsh" && return
2425 test_mkdir -p $DIR/d33
2426 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2429 for ostnum in $(seq $OSTCOUNT); do
2430 # test-framework's OST numbering is one-based, while Lustre's
2432 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2433 # Parsing llobdstat's output sucks; we could grep the /proc
2434 # path, but that's likely to not be as portable as using the
2435 # llobdstat utility. So we parse lctl output instead.
2436 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2437 obdfilter/$ostname/stats |
2438 awk '/^write_bytes/ {print $7}' )
2439 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2440 if (( ${write_bytes:-0} > 0 ))
2447 $all_zeros || return 0
2450 echo foo > $DIR/d33/bar
2454 # Total up write_bytes after writing. We'd better find non-zeros.
2455 for ostnum in $(seq $OSTCOUNT); do
2456 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2457 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2458 obdfilter/$ostname/stats |
2459 awk '/^write_bytes/ {print $7}' )
2460 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2461 if (( ${write_bytes:-0} > 0 ))
2470 for ostnum in $(seq $OSTCOUNT); do
2471 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2472 echo "Check that write_bytes is present in obdfilter/*/stats:"
2473 do_facet ost$ostnum lctl get_param -n \
2474 obdfilter/$ostname/stats
2476 error "OST not keeping write_bytes stats (b22312)"
2479 run_test 33c "test llobdstat and write_bytes"
2482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2485 local remote_dir=$DIR/$tdir/remote_dir
2488 $LFS mkdir -i $MDTIDX $remote_dir ||
2489 error "create remote directory failed"
2491 touch $remote_dir/$tfile
2492 chmod 444 $remote_dir/$tfile
2493 chown $RUNAS_ID $remote_dir/$tfile
2495 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2497 chown $RUNAS_ID $remote_dir
2498 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2499 error "create" || true
2500 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2501 error "open RDWR" || true
2502 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2503 error "create" || true
2505 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2507 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2510 $MCREATE $DIR/f34 || error
2511 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2512 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2513 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2514 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2516 run_test 34a "truncate file that has not been opened ==========="
2519 [ ! -f $DIR/f34 ] && test_34a
2520 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2521 $OPENFILE -f O_RDONLY $DIR/f34
2522 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2523 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2525 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2528 [ ! -f $DIR/f34 ] && test_34a
2529 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2530 $OPENFILE -f O_RDWR $DIR/f34
2531 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2532 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2534 run_test 34c "O_RDWR opening file-with-size works =============="
2537 [ ! -f $DIR/f34 ] && test_34a
2538 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2539 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2542 run_test 34d "write to sparse file ============================="
2546 $MCREATE $DIR/f34e || error
2547 $TRUNCATE $DIR/f34e 1000 || error
2548 $CHECKSTAT -s 1000 $DIR/f34e || error
2549 $OPENFILE -f O_RDWR $DIR/f34e
2550 $CHECKSTAT -s 1000 $DIR/f34e || error
2552 run_test 34e "create objects, some with size and some without =="
2554 test_34f() { # bug 6242, 6243
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2558 $MCREATE $DIR/f34f || error
2559 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2560 dd if=$DIR/f34f of=$TMP/f34f
2561 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2562 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2563 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2564 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2565 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2567 run_test 34f "read from a file with no objects until EOF ======="
2570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2571 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2572 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2573 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2574 cancel_lru_locks osc
2575 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2576 error "wrong size after lock cancel"
2578 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2579 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2580 error "expanding truncate failed"
2581 cancel_lru_locks osc
2582 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2583 error "wrong expanded size after lock cancel"
2585 run_test 34g "truncate long file ==============================="
2588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2592 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2593 sync # Flush the cache so that multiop below does not block on cache
2594 # flush when getting the group lock
2595 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2598 # Since just timed wait is not good enough, let's do a sync write
2599 # that way we are sure enough time for a roundtrip + processing
2600 # passed + 2 seconds of extra margin.
2601 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2605 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2606 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2610 local nsz=`stat -c %s $DIR/$tfile`
2611 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2613 run_test 34h "ftruncate file under grouplock should not block"
2616 cp /bin/sh $DIR/f35a
2618 chown $RUNAS_ID $DIR/f35a
2619 $RUNAS $DIR/f35a && error || true
2622 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2626 utime $DIR/f36 || error
2628 run_test 36a "MDS utime check (mknod, utime) ==================="
2632 utime $DIR/f36 || error
2634 run_test 36b "OST utime check (open, utime) ===================="
2639 chown $RUNAS_ID $DIR/d36
2640 $RUNAS utime $DIR/d36/f36 || error
2642 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2645 [ ! -d $DIR/d36 ] && test_36c
2646 echo "" > $DIR/d36/f36
2647 $RUNAS utime $DIR/d36/f36 || error
2649 run_test 36d "non-root OST utime check (open, utime) ==========="
2652 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2653 test_mkdir -p $DIR/$tdir
2654 touch $DIR/$tdir/$tfile
2655 $RUNAS utime $DIR/$tdir/$tfile && \
2656 error "utime worked, expected failure" || true
2658 run_test 36e "utime on non-owned file (should return error) ===="
2662 local LANG_SAVE=$LANG
2663 local LC_LANG_SAVE=$LC_LANG
2664 export LANG=C LC_LANG=C # for date language
2666 DATESTR="Dec 20 2000"
2667 test_mkdir -p $DIR/$tdir
2668 lctl set_param fail_loc=$fl
2670 cp /etc/hosts $DIR/$tdir/$tfile
2671 sync & # write RPC generated with "current" inode timestamp, but delayed
2673 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2674 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2675 cancel_lru_locks osc
2676 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2678 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2679 echo "BEFORE: $LS_BEFORE" && \
2680 echo "AFTER : $LS_AFTER" && \
2681 echo "WANT : $DATESTR" && \
2682 error "$DIR/$tdir/$tfile timestamps changed" || true
2684 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2689 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2690 subr_36fh "0x80000214"
2692 run_test 36f "utime on file racing with OST BRW write =========="
2695 remote_ost_nodsh && skip "remote OST with nodsh" && return
2696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2701 test_mkdir -p $DIR/$tdir
2702 fmd_max_age=$(do_facet ost1 \
2703 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2706 fmd_before=$(do_facet ost1 \
2707 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2708 touch $DIR/$tdir/$tfile
2709 sleep $((fmd_max_age + 12))
2710 fmd_after=$(do_facet ost1 \
2711 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2713 echo "fmd_before: $fmd_before"
2714 echo "fmd_after: $fmd_after"
2715 [ "$fmd_after" -gt "$fmd_before" ] && \
2716 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2717 error "fmd didn't expire after ping" || true
2719 run_test 36g "filter mod data cache expiry ====================="
2722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2723 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2724 subr_36fh "0x80000227"
2726 run_test 36h "utime on file racing with OST BRW write =========="
2728 # test_37 - duplicate with tests 32q 32r
2731 local file=$DIR/$tfile
2733 openfile -f O_DIRECTORY $file
2736 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2737 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2739 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2743 touch $DIR/${tfile}2
2744 # ls -l $DIR/$tfile $DIR/${tfile}2
2745 # ls -lu $DIR/$tfile $DIR/${tfile}2
2746 # ls -lc $DIR/$tfile $DIR/${tfile}2
2748 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2749 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2751 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2753 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2755 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2756 error "O_TRUNC didn't change timestamps"
2759 run_test 39 "mtime changed on create ==========================="
2762 test_mkdir -p $DIR/$tdir
2763 cp -p /etc/passwd $DIR/$tdir/fopen
2764 cp -p /etc/passwd $DIR/$tdir/flink
2765 cp -p /etc/passwd $DIR/$tdir/funlink
2766 cp -p /etc/passwd $DIR/$tdir/frename
2767 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2770 echo "aaaaaa" >> $DIR/$tdir/fopen
2771 echo "aaaaaa" >> $DIR/$tdir/flink
2772 echo "aaaaaa" >> $DIR/$tdir/funlink
2773 echo "aaaaaa" >> $DIR/$tdir/frename
2775 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2776 local link_new=`stat -c %Y $DIR/$tdir/flink`
2777 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2778 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2780 cat $DIR/$tdir/fopen > /dev/null
2781 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2782 rm -f $DIR/$tdir/funlink2
2783 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2785 for (( i=0; i < 2; i++ )) ; do
2786 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2787 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2788 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2789 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2791 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2792 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2793 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2794 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2796 cancel_lru_locks osc
2797 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2800 run_test 39b "mtime change on open, link, unlink, rename ======"
2802 # this should be set to past
2803 TEST_39_MTIME=`date -d "1 year ago" +%s`
2809 local mtime0=`stat -c %Y $DIR1/$tfile`
2811 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2812 local mtime1=`stat -c %Y $DIR1/$tfile`
2813 [ "$mtime1" = $TEST_39_MTIME ] || \
2814 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2817 echo hello >> $DIR1/$tfile
2819 local mtime2=`stat -c %Y $DIR1/$tfile`
2820 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2821 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2823 mv $DIR1/$tfile $DIR1/$tfile-1
2825 for (( i=0; i < 2; i++ )) ; do
2826 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2827 [ "$mtime2" = "$mtime3" ] || \
2828 error "mtime ($mtime2) changed (to $mtime3) on rename"
2830 cancel_lru_locks osc
2831 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2834 run_test 39c "mtime change on rename ==========================="
2838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2841 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2843 for (( i=0; i < 2; i++ )) ; do
2844 local mtime=`stat -c %Y $DIR1/$tfile`
2845 [ $mtime = $TEST_39_MTIME ] || \
2846 error "mtime($mtime) is not set to $TEST_39_MTIME"
2848 cancel_lru_locks osc
2849 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2852 run_test 39d "create, utime, stat =============================="
2856 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2858 local mtime1=`stat -c %Y $DIR1/$tfile`
2860 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2862 for (( i=0; i < 2; i++ )) ; do
2863 local mtime2=`stat -c %Y $DIR1/$tfile`
2864 [ $mtime2 = $TEST_39_MTIME ] || \
2865 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2867 cancel_lru_locks osc
2868 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2871 run_test 39e "create, stat, utime, stat ========================"
2875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2877 mtime1=`stat -c %Y $DIR1/$tfile`
2880 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2882 for (( i=0; i < 2; i++ )) ; do
2883 local mtime2=`stat -c %Y $DIR1/$tfile`
2884 [ $mtime2 = $TEST_39_MTIME ] || \
2885 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2887 cancel_lru_locks osc
2888 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2891 run_test 39f "create, stat, sleep, utime, stat ================="
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2896 echo hello >> $DIR1/$tfile
2897 local mtime1=`stat -c %Y $DIR1/$tfile`
2900 chmod o+r $DIR1/$tfile
2902 for (( i=0; i < 2; i++ )) ; do
2903 local mtime2=`stat -c %Y $DIR1/$tfile`
2904 [ "$mtime1" = "$mtime2" ] || \
2905 error "lost mtime: $mtime2, should be $mtime1"
2907 cancel_lru_locks osc
2908 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2911 run_test 39g "write, chmod, stat ==============================="
2915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2920 echo hello >> $DIR1/$tfile
2921 local mtime1=`stat -c %Y $DIR1/$tfile`
2923 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2925 if [ "$d1" != "$d2" ]; then
2926 echo "write and touch not within one second"
2928 for (( i=0; i < 2; i++ )) ; do
2929 local mtime2=`stat -c %Y $DIR1/$tfile`
2930 [ "$mtime2" = $TEST_39_MTIME ] || \
2931 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2933 cancel_lru_locks osc
2934 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2938 run_test 39h "write, utime within one second, stat ============="
2941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2945 echo hello >> $DIR1/$tfile
2946 local mtime1=`stat -c %Y $DIR1/$tfile`
2948 mv $DIR1/$tfile $DIR1/$tfile-1
2950 for (( i=0; i < 2; i++ )) ; do
2951 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2953 [ "$mtime1" = "$mtime2" ] || \
2954 error "lost mtime: $mtime2, should be $mtime1"
2956 cancel_lru_locks osc
2957 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2960 run_test 39i "write, rename, stat =============================="
2963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2964 start_full_debug_logging
2968 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2969 lctl set_param fail_loc=0x80000412
2970 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2971 error "multiop failed"
2973 local mtime1=`stat -c %Y $DIR1/$tfile`
2975 mv $DIR1/$tfile $DIR1/$tfile-1
2977 kill -USR1 $multipid
2978 wait $multipid || error "multiop close failed"
2980 for (( i=0; i < 2; i++ )) ; do
2981 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2982 [ "$mtime1" = "$mtime2" ] ||
2983 error "mtime is lost on close: $mtime2, " \
2986 cancel_lru_locks osc
2987 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2989 lctl set_param fail_loc=0
2990 stop_full_debug_logging
2992 run_test 39j "write, rename, close, stat ======================="
2995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2999 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3001 local mtime1=`stat -c %Y $DIR1/$tfile`
3003 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3005 kill -USR1 $multipid
3006 wait $multipid || error "multiop close failed"
3008 for (( i=0; i < 2; i++ )) ; do
3009 local mtime2=`stat -c %Y $DIR1/$tfile`
3011 [ "$mtime2" = $TEST_39_MTIME ] || \
3012 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3014 cancel_lru_locks osc
3015 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3018 run_test 39k "write, utime, close, stat ========================"
3020 # this should be set to future
3021 TEST_39_ATIME=`date -d "1 year" +%s`
3024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3026 local atime_diff=$(do_facet $SINGLEMDS \
3027 lctl get_param -n mdd.*MDT0000*.atime_diff)
3031 # test setting directory atime to future
3032 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3033 local atime=$(stat -c %X $DIR/$tdir)
3034 [ "$atime" = $TEST_39_ATIME ] || \
3035 error "atime is not set to future: $atime, $TEST_39_ATIME"
3037 # test setting directory atime from future to now
3038 local d1=$(date +%s)
3040 local d2=$(date +%s)
3042 cancel_lru_locks mdc
3043 atime=$(stat -c %X $DIR/$tdir)
3044 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3045 error "atime is not updated from future: $atime, $d1<atime<$d2"
3047 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3050 # test setting directory atime when now > dir atime + atime_diff
3054 cancel_lru_locks mdc
3055 atime=$(stat -c %X $DIR/$tdir)
3056 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3057 error "atime is not updated : $atime, should be $d2"
3059 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3062 # test not setting directory atime when now < dir atime + atime_diff
3064 cancel_lru_locks mdc
3065 atime=$(stat -c %X $DIR/$tdir)
3066 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3067 error "atime is updated to $atime, should remain $d1<atime<$d2"
3069 do_facet $SINGLEMDS \
3070 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3072 run_test 39l "directory atime update ==========================="
3075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 local far_past_mtime=$(date -d "May 29 1953" +%s)
3079 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3081 touch -m -d @$far_past_mtime $DIR1/$tfile
3082 touch -a -d @$far_past_atime $DIR1/$tfile
3084 for (( i=0; i < 2; i++ )) ; do
3085 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3086 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3087 error "atime or mtime set incorrectly"
3089 cancel_lru_locks osc
3090 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3093 run_test 39m "test atime and mtime before 1970"
3096 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3097 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3098 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3099 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3100 error "$tfile is not 4096 bytes in size"
3102 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3106 small_write $DIR/f41 18
3108 run_test 41 "test small file write + fstat ====================="
3110 count_ost_writes() {
3111 lctl get_param -n osc.*.stats |
3112 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3119 BG_DIRTY_RATIO_SAVE=10
3120 MAX_BG_DIRTY_RATIO=25
3124 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3125 # dirty_ratio, dirty_background_ratio
3126 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3127 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3128 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3129 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3131 # if file not here, we are a 2.4 kernel
3132 kill -CONT `pidof kupdated`
3137 # setup the trap first, so someone cannot exit the test at the
3138 # exact wrong time and mess up a machine
3139 trap start_writeback EXIT
3140 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3141 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3142 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3143 sysctl -w vm.dirty_writeback_centisecs=0
3144 sysctl -w vm.dirty_writeback_centisecs=0
3145 # save and increase /proc/sys/vm/dirty_ratio
3146 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3147 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3148 # save and increase /proc/sys/vm/dirty_background_ratio
3149 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3150 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3152 # if file not here, we are a 2.4 kernel
3153 kill -STOP `pidof kupdated`
3157 # ensure that all stripes have some grant before we test client-side cache
3159 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3160 dd if=/dev/zero of=$i bs=4k count=1
3165 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3166 # file truncation, and file removal.
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3170 cancel_lru_locks osc
3172 sync; sleep 1; sync # just to be safe
3173 BEFOREWRITES=`count_ost_writes`
3174 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3175 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3176 AFTERWRITES=`count_ost_writes`
3177 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3178 error "$BEFOREWRITES < $AFTERWRITES"
3181 run_test 42a "ensure that we don't flush on close =============="
3184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3186 cancel_lru_locks osc
3189 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3190 BEFOREWRITES=`count_ost_writes`
3191 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3192 AFTERWRITES=`count_ost_writes`
3193 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3194 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3196 BEFOREWRITES=`count_ost_writes`
3197 sync || error "sync: $?"
3198 AFTERWRITES=`count_ost_writes`
3199 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3200 error "$BEFOREWRITES < $AFTERWRITES on sync"
3202 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3206 run_test 42b "test destroy of file with cached dirty data ======"
3208 # if these tests just want to test the effect of truncation,
3209 # they have to be very careful. consider:
3210 # - the first open gets a {0,EOF}PR lock
3211 # - the first write conflicts and gets a {0, count-1}PW
3212 # - the rest of the writes are under {count,EOF}PW
3213 # - the open for truncate tries to match a {0,EOF}PR
3214 # for the filesize and cancels the PWs.
3215 # any number of fixes (don't get {0,EOF} on open, match
3216 # composite locks, do smarter file size management) fix
3217 # this, but for now we want these tests to verify that
3218 # the cancellation with truncate intent works, so we
3219 # start the file with a full-file pw lock to match against
3220 # until the truncate.
3225 cancel_lru_locks osc
3227 # prime the file with 0,EOF PW to match
3231 # now the real test..
3232 dd if=/dev/zero of=$file bs=1024 count=100
3233 BEFOREWRITES=`count_ost_writes`
3234 $TRUNCATE $file $offset
3235 cancel_lru_locks osc
3236 AFTERWRITES=`count_ost_writes`
3241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3243 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3244 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3247 run_test 42c "test partial truncate of file with cached dirty data"
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3252 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3253 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3256 run_test 42d "test complete truncate of file with cached dirty data"
3258 test_42e() { # bug22074
3259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3260 local TDIR=$DIR/${tdir}e
3261 local pagesz=$(page_size)
3262 local pages=16 # hardcoded 16 pages, don't change it.
3263 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3264 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3268 test_mkdir -p $DIR/${tdir}e
3269 $SETSTRIPE -c 1 $TDIR
3270 createmany -o $TDIR/f $files
3272 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3274 # we assume that with $OSTCOUNT files, at least one of them will
3275 # be allocated on OST0.
3276 warmup_files=$((OSTCOUNT * max_dirty_mb))
3277 createmany -o $TDIR/w $warmup_files
3279 # write a large amount of data into one file and sync, to get good
3280 # avail_grant number from OST.
3281 for ((i=0; i<$warmup_files; i++)); do
3282 idx=$($GETSTRIPE -i $TDIR/w$i)
3283 [ $idx -ne 0 ] && continue
3284 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3287 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3289 $LCTL get_param $proc_osc0/cur_dirty_bytes
3290 $LCTL get_param $proc_osc0/cur_grant_bytes
3292 # create as much dirty pages as we can while not to trigger the actual
3293 # RPCs directly. but depends on the env, VFS may trigger flush during this
3294 # period, hopefully we are good.
3295 for ((i=0; i<$warmup_files; i++)); do
3296 idx=$($GETSTRIPE -i $TDIR/w$i)
3297 [ $idx -ne 0 ] && continue
3298 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3300 $LCTL get_param $proc_osc0/cur_dirty_bytes
3301 $LCTL get_param $proc_osc0/cur_grant_bytes
3303 # perform the real test
3304 $LCTL set_param $proc_osc0/rpc_stats 0
3305 for ((;i<$files; i++)); do
3306 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3307 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3310 $LCTL get_param $proc_osc0/rpc_stats
3313 local have_ppr=false
3314 $LCTL get_param $proc_osc0/rpc_stats |
3315 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3316 # skip lines until we are at the RPC histogram data
3317 [ "$PPR" == "pages" ] && have_ppr=true && continue
3318 $have_ppr || continue
3320 # we only want the percent stat for < 16 pages
3321 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3323 percent=$((percent + WPCT))
3324 if [ $percent -gt 15 ]; then
3325 error "less than 16-pages write RPCs" \
3332 run_test 42e "verify sub-RPC writes are not done synchronously"
3335 test_mkdir -p $DIR/$tdir
3336 cp -p /bin/ls $DIR/$tdir/$tfile
3337 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3339 # give multiop a chance to open
3342 $DIR/$tdir/$tfile && error || true
3345 run_test 43 "execution of file opened for write should return -ETXTBSY"
3348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3349 test_mkdir -p $DIR/$tdir
3350 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3351 cp -p multiop $DIR/$tdir/multiop
3352 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3355 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3356 kill -USR1 $MULTIOP_PID || return 2
3357 wait $MULTIOP_PID || return 3
3360 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3364 test_mkdir -p $DIR/$tdir
3365 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3366 cp -p multiop $DIR/$tdir/multiop
3367 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3370 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3371 kill -USR1 $MULTIOP_PID || return 2
3372 wait $MULTIOP_PID || return 3
3375 run_test 43b "truncate of file being executed should return -ETXTBSY"
3378 local testdir="$DIR/$tdir"
3379 test_mkdir -p $DIR/$tdir
3381 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3382 ( cd $testdir && md5sum -c)
3384 run_test 43c "md5sum of copy into lustre========================"
3387 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3388 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3389 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3391 run_test 44 "zero length read from a sparse stripe ============="
3394 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3396 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3397 [ "$nstripe" -gt "$OSTCOUNT&