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 230d"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
199 local remote_dir=remote_dir
201 [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4690" && return #LU-4690
202 test_mkdir $DIR/$remote_dir ||
203 error "Create remote directory failed"
205 touch $DIR/$remote_dir/$tfile ||
206 error "Create file under remote directory failed"
208 rmdir $DIR/$remote_dir &&
209 error "Expect error removing in-use dir $DIR/$remote_dir"
211 test -d $DIR/$remote_dir || error "Remote directory disappeared"
213 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
216 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
217 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
218 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
219 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
220 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
222 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
225 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
226 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile does not have perm 0666 or UID $UID"
229 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile should be 0666 and owned by UID $UID"
233 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
238 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
241 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
245 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
250 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by GID $UID"
253 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
257 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
260 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
261 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
262 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
263 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
264 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
265 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
266 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
267 error "$tdir/d/subdir should be GID $RUNAS_GID"
269 run_test 6g "Is new dir in sgid dir inheriting group?"
271 test_6h() { # bug 7331
272 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
273 touch $DIR/$tfile || error "touch failed"
274 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
275 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
276 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
277 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
278 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
280 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
283 test_mkdir $DIR/$tdir
284 $MCREATE $DIR/$tdir/$tfile
285 chmod 0666 $DIR/$tdir/$tfile
286 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
287 error "$tdir/$tfile should be mode 0666"
289 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
292 if [ ! -d $DIR/$tdir ]; then
295 $MCREATE $DIR/$tdir/$tfile
296 echo -n foo > $DIR/$tdir/$tfile
297 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
298 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
300 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
303 test_mkdir $DIR/$tdir
304 touch $DIR/$tdir/$tfile
305 chmod 0666 $DIR/$tdir/$tfile
306 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
307 error "$tfile mode not 0666"
309 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 test_mkdir $DIR/$tdir/d2/d3
315 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
317 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
320 test_mkdir $DIR/$tdir
321 test_mkdir $DIR/$tdir/d2
322 touch $DIR/$tdir/d2/$tfile
323 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
324 error "$tdir/d2/$tfile not a file"
326 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 chmod 0666 $DIR/$tdir/d2
332 chmod 0705 $DIR/$tdir/d2
333 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
334 error "$tdir/d2 mode not 0705"
336 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
341 chmod 0666 $DIR/$tdir/$tfile
342 chmod 0654 $DIR/$tdir/$tfile
343 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
344 error "$tdir/d2 mode not 0654"
346 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
349 test_mkdir $DIR/$tdir
350 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
352 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
353 error "$tdir/$tfile size not 0 after truncate"
355 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
361 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
363 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
366 test_mkdir $DIR/$tdir
367 touch $DIR/$tdir/$tfile
368 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
369 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
370 error "$tdir/${tfile_2} not a file after rename"
372 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
377 rm -rf $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
383 test_mkdir -p $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
387 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not a symlink"
389 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not referencing a file"
391 rm -f $DIR/$tdir/l-exist
392 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
394 run_test 17a "symlinks: create, remove (real) =================="
397 test_mkdir -p $DIR/$tdir
398 ln -s no-such-file $DIR/$tdir/l-dangle
400 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing no-such-file"
402 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing non-existent file"
404 rm -f $DIR/$tdir/l-dangle
405 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
407 run_test 17b "symlinks: create, remove (dangling) =============="
409 test_17c() { # bug 3440 - don't save failed open RPC for replay
410 test_mkdir -p $DIR/$tdir
411 ln -s foo $DIR/$tdir/$tfile
412 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
414 run_test 17c "symlinks: open dangling (should return error) ===="
417 test_mkdir -p $DIR/$tdir
418 ln -s foo $DIR/$tdir/$tfile
419 touch $DIR/$tdir/$tfile || error "creating to new symlink"
421 run_test 17d "symlinks: create dangling ========================"
424 test_mkdir -p $DIR/$tdir
425 local foo=$DIR/$tdir/$tfile
426 ln -s $foo $foo || error "create symlink failed"
427 ls -l $foo || error "ls -l failed"
428 ls $foo && error "ls not failed" || true
430 run_test 17e "symlinks: create recursive symlink (should return error) ===="
433 test_mkdir -p $DIR/d17f
434 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
442 run_test 17f "symlinks: long and very long symlink name ========================"
444 # str_repeat(S, N) generate a string that is string S repeated N times
449 while [ $((n -= 1)) -ge 0 ]; do
455 # Long symlinks and LU-2241
457 test_mkdir -p $DIR/$tdir
458 local TESTS="59 60 61 4094 4095"
460 # Fix for inode size boundary in 2.1.4
461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
464 # Patch not applied to 2.2 or 2.3 branches
465 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
466 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
469 # skip long symlink name for rhel6.5.
470 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
471 grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
474 local SYMNAME=$(str_repeat 'x' $i)
475 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
476 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
479 run_test 17g "symlinks: really long symlink name and inode boundaries"
481 test_17h() { #bug 17378
482 remote_mds_nodsh && skip "remote MDS with nodsh" && return
483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
485 test_mkdir -p $DIR/$tdir
486 if [ $MDSCOUNT -gt 1 ]; then
487 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
491 $SETSTRIPE -c -1 $DIR/$tdir
492 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
493 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
494 touch $DIR/$tdir/$tfile || true
496 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
498 test_17i() { #bug 20018
499 remote_mds_nodsh && skip "remote MDS with nodsh" && return
500 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
501 test_mkdir -p $DIR/$tdir
502 local foo=$DIR/$tdir/$tfile
504 if [ $MDSCOUNT -gt 1 ]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 ln -s $foo $foo || error "create symlink failed"
510 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
512 ls -l $foo && error "error not detected"
515 run_test 17i "don't panic on short symlink"
517 test_17k() { #bug 22301
518 rsync --help | grep -q xattr ||
519 skip_env "$(rsync --version| head -1) does not support xattrs"
520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
521 test_mkdir -p $DIR/$tdir
522 test_mkdir -p $DIR/$tdir.new
523 touch $DIR/$tdir/$tfile
524 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
525 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
526 error "rsync failed with xattrs enabled"
528 run_test 17k "symlinks: rsync with xattrs enabled ========================="
530 test_17l() { # LU-279
532 touch $DIR/$tdir/$tfile
533 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
534 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
535 # -h to not follow symlinks. -m '' to list all the xattrs.
536 # grep to remove first line: '# file: $path'.
537 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
539 lgetxattr_size_check $path $xattr ||
540 error "lgetxattr_size_check $path $xattr failed"
544 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
548 local short_sym="0123456789"
549 local WDIR=$DIR/${tdir}m
556 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
557 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
558 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
560 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
561 skip "only for ldiskfs MDT" && return 0
563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
567 # create a long symlink file
568 for ((i = 0; i < 4; ++i)); do
569 long_sym=${long_sym}${long_sym}
572 echo "create 512 short and long symlink files under $WDIR"
573 for ((i = 0; i < 256; ++i)); do
574 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
575 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
581 wait_delete_completed
583 echo "recreate the 512 symlink files with a shorter string"
584 for ((i = 0; i < 512; ++i)); do
585 # rewrite the symlink file with a shorter string
586 ln -sf ${long_sym} $WDIR/long-$i
587 ln -sf ${short_sym} $WDIR/short-$i
590 mds_index=$($LFS getstripe -M $WDIR)
591 mds_index=$((mds_index+1))
592 devname=$(mdsdevname $mds_index)
593 cmd="$E2FSCK -fnvd $devname"
595 echo "stop and checking mds${mds_index}: $cmd"
596 # e2fsck should not return error
598 do_facet mds${mds_index} $cmd || rc=$?
600 start mds${mds_index} $devname $MDS_MOUNT_OPTS
601 df $MOUNT > /dev/null 2>&1
602 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
603 "short/long symlink MDT: rc=$rc"
606 run_test 17m "run e2fsck against MDT which contains short/long symlink"
608 check_fs_consistency_17n() {
614 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
615 # so it only check MDT1/MDT2 instead of all of MDTs.
616 for mdt_index in $(seq 1 2); do
617 devname=$(mdsdevname $mdt_index)
618 cmd="$E2FSCK -fnvd $devname"
620 echo "stop and checking mds${mdt_index}: $cmd"
621 # e2fsck should not return error
623 do_facet mds${mdt_index} $cmd || rc=$?
625 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
626 df $MOUNT > /dev/null 2>&1
627 [ $rc -ne 0 ] && break
635 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
636 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
637 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
639 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
640 skip "only for ldiskfs MDT" && return 0
642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
647 for ((i=0; i<10; i++)); do
648 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
649 error "create remote dir error $i"
650 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
651 error "create files under remote dir failed $i"
654 check_fs_consistency_17n ||
655 error "e2fsck report error after create files under remote dir"
657 for ((i=0;i<10;i++)); do
658 rm -rf $DIR/$tdir/remote_dir_${i} ||
659 error "destroy remote dir error $i"
662 check_fs_consistency_17n ||
663 error "e2fsck report error after unlink files under remote dir"
665 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
666 skip "lustre < 2.4.50 does not support migrate mv " && return
668 for ((i=0; i<10; i++)); do
669 mkdir -p $DIR/$tdir/remote_dir_${i}
670 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
671 error "create files under remote dir failed $i"
672 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
673 error "migrate remote dir error $i"
675 check_fs_consistency_17n || error "e2fsck report error after migration"
677 for ((i=0;i<10;i++)); do
678 rm -rf $DIR/$tdir/remote_dir_${i} ||
679 error "destroy remote dir error $i"
682 check_fs_consistency_17n || error "e2fsck report error after unlink"
684 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
687 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
688 skip "Need MDS version at least 2.3.64" && return
690 local WDIR=$DIR/${tdir}o
696 mdt_index=$($LFS getstripe -M $WDIR)
697 mdt_index=$((mdt_index+1))
698 mdtdevname=$(mdsdevname $mdt_index)
702 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
704 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
705 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
706 ls -l $WDIR/$tfile && rc=1
707 do_facet mds${mdt_index} lctl set_param fail_loc=0
708 [[ $rc -ne 0 ]] && error "stat file should fail"
711 run_test 17o "stat file with incompat LMA feature"
714 touch $DIR/f || error "Failed to touch $DIR/f: $?"
715 ls $DIR || error "Failed to ls $DIR: $?"
717 run_test 18 "touch .../f ; ls ... =============================="
723 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
725 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
728 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
730 run_test 19b "ls -l .../f19 (should return error) =============="
733 [ $RUNAS_ID -eq $UID ] &&
734 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
735 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
737 run_test 19c "$RUNAS touch .../f19 (should return error) =="
740 cat $DIR/f19 && error || true
742 run_test 19d "cat .../f19 (should return error) =============="
754 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
756 run_test 20 "touch .../f ; ls -l ... ==========================="
759 test_mkdir -p $DIR/$tdir
760 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
761 ln -s dangle $DIR/$tdir/link
762 echo foo >> $DIR/$tdir/link
763 cat $DIR/$tdir/dangle
764 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
765 $CHECKSTAT -f -t file $DIR/$tdir/link ||
766 error "$tdir/link not linked to a file"
768 run_test 21 "write to dangling link ============================"
772 test_mkdir -p $DIR/$tdir
773 chown $RUNAS_ID:$RUNAS_GID $WDIR
774 (cd $WDIR || error "cd $WDIR failed";
775 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
777 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
778 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
779 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
781 run_test 22 "unpack tar archive as non-root user ==============="
785 test_mkdir -p $DIR/$tdir
786 local file=$DIR/$tdir/$tfile
788 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
789 openfile -f O_CREAT:O_EXCL $file &&
790 error "$file recreate succeeded" || true
792 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
794 test_23b() { # bug 18988
795 test_mkdir -p $DIR/$tdir
796 local file=$DIR/$tdir/$tfile
799 echo foo > $file || error "write filed"
800 echo bar >> $file || error "append filed"
801 $CHECKSTAT -s 8 $file || error "wrong size"
804 run_test 23b "O_APPEND check =========================="
808 echo '-- same directory rename'
809 test_mkdir $DIR/$tdir
810 touch $DIR/$tdir/$tfile.1
811 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
812 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
814 run_test 24a "rename file to non-existent target"
817 test_mkdir $DIR/$tdir
818 touch $DIR/$tdir/$tfile.{1,2}
819 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
820 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
821 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
823 run_test 24b "rename file to existing target"
826 test_mkdir $DIR/$tdir
827 test_mkdir $DIR/$tdir/d$testnum.1
828 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
829 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
830 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
832 run_test 24c "rename directory to non-existent target"
835 test_mkdir -c1 $DIR/$tdir
836 test_mkdir -c1 $DIR/$tdir/d$testnum.1
837 test_mkdir -c1 $DIR/$tdir/d$testnum.2
838 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
839 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
840 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
842 run_test 24d "rename directory to existing target"
845 echo '-- cross directory renames --'
849 mv $DIR/R5a/f $DIR/R5b/g
850 $CHECKSTAT -a $DIR/R5a/f || error
851 $CHECKSTAT -t file $DIR/R5b/g || error
853 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
858 touch $DIR/R6a/f $DIR/R6b/g
859 mv $DIR/R6a/f $DIR/R6b/g
860 $CHECKSTAT -a $DIR/R6a/f || error
861 $CHECKSTAT -t file $DIR/R6b/g || error
863 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
868 test_mkdir $DIR/R7a/d
869 mv $DIR/R7a/d $DIR/R7b/e
870 $CHECKSTAT -a $DIR/R7a/d || error
871 $CHECKSTAT -t dir $DIR/R7b/e || error
873 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
876 test_mkdir -c1 $DIR/R8a
877 test_mkdir -c1 $DIR/R8b
878 test_mkdir -c1 $DIR/R8a/d
879 test_mkdir -c1 $DIR/R8b/e
880 mrename $DIR/R8a/d $DIR/R8b/e
881 $CHECKSTAT -a $DIR/R8a/d || error
882 $CHECKSTAT -t dir $DIR/R8b/e || error
884 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
887 echo "-- rename error cases"
891 mrename $DIR/R9/f $DIR/R9/a
892 $CHECKSTAT -t file $DIR/R9/f || error
893 $CHECKSTAT -t dir $DIR/R9/a || error
894 $CHECKSTAT -a $DIR/R9/a/f || error
896 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
900 mrename $DIR/R10/f $DIR/R10/g
901 $CHECKSTAT -t dir $DIR/R10 || error
902 $CHECKSTAT -a $DIR/R10/f || error
903 $CHECKSTAT -a $DIR/R10/g || error
905 run_test 24j "source does not exist ============================"
909 test_mkdir $DIR/R11a/d
911 mv $DIR/R11a/f $DIR/R11a/d
912 $CHECKSTAT -a $DIR/R11a/f || error
913 $CHECKSTAT -t file $DIR/R11a/d/f || error
915 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
917 # bug 2429 - rename foo foo foo creates invalid file
920 $MULTIOP $f OcNs || error
922 run_test 24l "Renaming a file to itself ========================"
926 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
927 # on ext3 this does not remove either the source or target files
928 # though the "expected" operation would be to remove the source
929 $CHECKSTAT -t file ${f} || error "${f} missing"
930 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
932 run_test 24m "Renaming a file to a hard link to itself ========="
936 # this stats the old file after it was renamed, so it should fail
940 $CHECKSTAT ${f}.rename
943 run_test 24n "Statting the old file after renaming (Posix rename 2)"
946 check_kernel_version 37 || return 0
947 test_mkdir -p $DIR/d24o
948 rename_many -s random -v -n 10 $DIR/d24o
950 run_test 24o "rename of files during htree split ==============="
955 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
956 mrename $DIR/R12a $DIR/R12b
957 $CHECKSTAT -a $DIR/R12a || error
958 $CHECKSTAT -t dir $DIR/R12b || error
959 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
960 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
962 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
964 cleanup_multiop_pause() {
970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
973 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
974 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
977 trap cleanup_multiop_pause EXIT
978 mrename $DIR/R13a $DIR/R13b
979 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
980 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
981 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
982 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
983 cleanup_multiop_pause
984 wait $MULTIPID || error "multiop close failed"
986 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
988 test_24r() { #bug 3789
990 test_mkdir $DIR/R14a/b
991 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
992 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
993 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
995 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
999 test_mkdir $DIR/R15a/b
1000 test_mkdir $DIR/R15a/b/c
1001 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1002 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1003 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1005 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1007 test_mkdir $DIR/R16a
1008 test_mkdir $DIR/R16a/b
1009 test_mkdir $DIR/R16a/b/c
1010 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1011 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1012 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1014 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1016 test_24u() { # bug12192
1018 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1019 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1021 run_test 24u "create stripe file"
1027 simple_cleanup_common() {
1030 wait_delete_completed
1033 max_pages_per_rpc() {
1034 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1038 local NRFILES=100000
1039 local FREE_INODES=$(mdt_free_inodes 0)
1040 [ $FREE_INODES -lt $NRFILES ] && \
1041 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1045 trap simple_cleanup_common EXIT
1047 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1048 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1051 createmany -m $DIR/$tdir/$tfile $NRFILES
1053 cancel_lru_locks mdc
1054 lctl set_param mdc.*.stats clear
1056 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1058 # LU-5 large readdir
1059 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1060 # 8 bytes for name(filename is mostly 5 in this test) +
1061 # 8 bytes for luda_type
1062 # take into account of overhead in lu_dirpage header and end mark in
1063 # each page, plus one in RPC_NUM calculation.
1065 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1066 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1067 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1068 awk '/^mds_readpage/ {print $2}')
1069 [ $mds_readpage -gt $RPC_NUM ] && \
1070 error "large readdir doesn't take effect"
1072 simple_cleanup_common
1074 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1076 test_24w() { # bug21506
1078 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1079 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1080 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1081 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1082 [ "$SZ1" = "$SZ2" ] || \
1083 error "Error reading at the end of the file $tfile"
1085 run_test 24w "Reading a file larger than 4Gb"
1088 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1089 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1091 local remote_dir=$DIR/$tdir/remote_dir
1094 $LFS mkdir -i $MDTIDX $remote_dir ||
1095 error "create remote directory failed"
1097 mkdir -p $DIR/$tdir/src_dir
1098 touch $DIR/$tdir/src_file
1099 mkdir -p $remote_dir/tgt_dir
1100 touch $remote_dir/tgt_file
1102 mrename $remote_dir $DIR/ &&
1103 error "rename dir cross MDT works!"
1105 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1106 error "rename dir cross MDT works!"
1108 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1109 error "rename file cross MDT works!"
1111 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1112 error "ln file cross MDT should not work!"
1114 rm -rf $DIR/$tdir || error "Can not delete directories"
1116 run_test 24x "cross rename/link should be failed"
1119 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1122 local remote_dir=$DIR/$tdir/remote_dir
1125 $LFS mkdir -i $MDTIDX $remote_dir ||
1126 error "create remote directory failed"
1128 mkdir -p $remote_dir/src_dir
1129 touch $remote_dir/src_file
1130 mkdir -p $remote_dir/tgt_dir
1131 touch $remote_dir/tgt_file
1133 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1134 error "rename subdir in the same remote dir failed!"
1136 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1137 error "rename files in the same remote dir failed!"
1139 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1140 error "link files in the same remote dir failed!"
1142 rm -rf $DIR/$tdir || error "Can not delete directories"
1144 run_test 24y "rename/link on the same dir should succeed"
1147 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1150 local remote_src=$DIR/$tdir/remote_dir
1151 local remote_tgt=$DIR/$tdir/remote_tgt
1154 $LFS mkdir -i $MDTIDX $remote_src ||
1155 error "create remote directory failed"
1157 $LFS mkdir -i $MDTIDX $remote_tgt ||
1158 error "create remote directory failed"
1160 mrename $remote_src $remote_tgt &&
1161 error "rename remote dirs should not work!"
1163 # If target dir does not exists, it should succeed
1165 mrename $remote_src $remote_tgt ||
1166 error "rename remote dirs(tgt dir does not exists) failed!"
1168 rm -rf $DIR/$tdir || error "Can not delete directories"
1170 run_test 24z "rename one remote dir to another remote dir should fail"
1172 test_24A() { # LU-3182
1177 createmany -m $DIR/$tdir/$tfile $NFILES
1178 local t=`ls $DIR/$tdir | wc -l`
1179 local u=`ls $DIR/$tdir | sort -u | wc -l`
1180 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1181 error "Expected $NFILES files, got $t ($u unique)"
1184 rm -rf $DIR/$tdir || error "Can not delete directories"
1186 run_test 24A "readdir() returns correct number of entries."
1189 echo '== symlink sanity ============================================='
1193 touch $DIR/s25/foo || error
1195 run_test 25a "create file in symlinked directory ==============="
1198 [ ! -d $DIR/d25 ] && test_25a
1199 $CHECKSTAT -t file $DIR/s25/foo || error
1201 run_test 25b "lookup file in symlinked directory ==============="
1205 test_mkdir $DIR/d26/d26-2
1206 ln -s d26/d26-2 $DIR/s26
1207 touch $DIR/s26/foo || error
1209 run_test 26a "multiple component symlink ======================="
1212 test_mkdir -p $DIR/d26b/d26-2
1213 ln -s d26b/d26-2/foo $DIR/s26-2
1214 touch $DIR/s26-2 || error
1216 run_test 26b "multiple component symlink at end of lookup ======"
1219 test_mkdir $DIR/d26.2
1220 touch $DIR/d26.2/foo
1221 ln -s d26.2 $DIR/s26.2-1
1222 ln -s s26.2-1 $DIR/s26.2-2
1223 ln -s s26.2-2 $DIR/s26.2-3
1224 chmod 0666 $DIR/s26.2-3/foo
1226 run_test 26c "chain of symlinks ================================"
1228 # recursive symlinks (bug 439)
1230 ln -s d26-3/foo $DIR/d26-3
1232 run_test 26d "create multiple component recursive symlink ======"
1235 [ ! -h $DIR/d26-3 ] && test_26d
1238 run_test 26e "unlink multiple component recursive symlink ======"
1240 # recursive symlinks (bug 7022)
1242 test_mkdir -p $DIR/$tdir
1243 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1244 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1245 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1246 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1247 cd $tfile || error "cd $tfile failed"
1248 ln -s .. dotdot || error "ln dotdot failed"
1249 ln -s dotdot/lndir lndir || error "ln lndir failed"
1250 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1251 output=`ls $tfile/$tfile/lndir/bar1`
1252 [ "$output" = bar1 ] && error "unexpected output"
1253 rm -r $tfile || error "rm $tfile failed"
1254 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1256 run_test 26f "rm -r of a directory which has recursive symlink ="
1259 echo '== stripe sanity =============================================='
1260 test_mkdir -p $DIR/d27 || error "mkdir failed"
1262 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1263 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1265 log "== test_27a: write to one stripe file ========================="
1266 cp /etc/hosts $DIR/d27/f0 || error
1268 run_test 27a "one stripe file =================================="
1271 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1272 test_mkdir -p $DIR/d27
1273 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1274 $GETSTRIPE -c $DIR/d27/f01
1275 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1276 error "two-stripe file doesn't have two stripes"
1278 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1280 run_test 27b "create and write to two stripe file"
1283 test_mkdir -p $DIR/d27
1284 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1285 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1286 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1288 run_test 27d "create file with default settings ================"
1291 test_mkdir -p $DIR/d27
1292 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1293 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1294 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1296 run_test 27e "setstripe existing file (should return error) ======"
1299 test_mkdir -p $DIR/d27
1300 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1301 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1302 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1304 run_test 27f "setstripe with bad stripe size (should return error)"
1307 test_mkdir -p $DIR/d27
1308 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1309 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1310 error "$DIR/d27/fnone has object"
1312 run_test 27g "$GETSTRIPE with no objects"
1315 touch $DIR/d27/fsome || error "touch failed"
1316 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1318 run_test 27i "$GETSTRIPE with some objects"
1321 test_mkdir -p $DIR/d27
1322 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1324 run_test 27j "setstripe with bad stripe offset (should return error)"
1326 test_27k() { # bug 2844
1327 test_mkdir -p $DIR/d27
1329 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1330 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1331 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1332 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1333 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1334 dd if=/dev/zero of=$FILE bs=4k count=1
1335 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1336 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1338 run_test 27k "limit i_blksize for broken user apps ============="
1341 test_mkdir -p $DIR/d27
1342 mcreate $DIR/f27l || error "creating file"
1343 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1344 error "setstripe should have failed" || true
1346 run_test 27l "check setstripe permissions (should return error)"
1349 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1351 if [ $ORIGFREE -gt $MAXFREE ]; then
1352 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1355 trap simple_cleanup_common EXIT
1356 test_mkdir -p $DIR/$tdir
1357 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1358 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1359 error "dd should fill OST0"
1361 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1363 [ $i -gt 256 ] && break
1366 touch $DIR/$tdir/f27m_$i
1367 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1368 error "OST0 was full but new created file still use it"
1370 touch $DIR/$tdir/f27m_$i
1371 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1372 error "OST0 was full but new created file still use it"
1373 simple_cleanup_common
1375 run_test 27m "create file while OST0 was full =================="
1378 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1382 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1383 # if the OST isn't full anymore.
1385 local OSTIDX=${1:-""}
1387 local list=$(comma_list $(osts_nodes))
1388 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1390 do_nodes $list lctl set_param fail_loc=0
1391 sync # initiate all OST_DESTROYs from MDS to OST
1395 exhaust_precreations() {
1398 local FAILIDX=${3:-$OSTIDX}
1400 test_mkdir -p $DIR/$tdir
1401 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1402 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1404 local OST=$(ostname_from_index $OSTIDX)
1405 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1406 sed -e 's/_UUID$//;s/^.*-//')
1409 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1410 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1411 osc.$mdtosc_proc1.prealloc_last_id)
1412 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1413 osc.$mdtosc_proc1.prealloc_next_id)
1415 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1416 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1418 test_mkdir -p $DIR/$tdir/${OST}
1419 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1420 #define OBD_FAIL_OST_ENOSPC 0x215
1421 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1422 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1423 echo "Creating to objid $last_id on ost $OST..."
1424 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1425 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1426 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1430 exhaust_all_precreations() {
1432 for (( i=0; i < OSTCOUNT; i++ )) ; do
1433 exhaust_precreations $i $1 -1
1438 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1440 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1441 remote_ost_nodsh && skip "remote OST with nodsh" && return
1444 rm -f $DIR/$tdir/$tfile
1445 exhaust_precreations 0 0x80000215
1446 $SETSTRIPE -c -1 $DIR/$tdir
1447 touch $DIR/$tdir/$tfile || error
1448 $GETSTRIPE $DIR/$tdir/$tfile
1451 run_test 27n "create file with some full OSTs =================="
1454 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1455 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1456 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1457 remote_ost_nodsh && skip "remote OST with nodsh" && return
1460 rm -f $DIR/$tdir/$tfile
1461 exhaust_all_precreations 0x215
1463 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1468 run_test 27o "create file with all full OSTs (should error) ===="
1471 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1473 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1474 remote_ost_nodsh && skip "remote OST with nodsh" && return
1477 rm -f $DIR/$tdir/$tfile
1478 test_mkdir -p $DIR/$tdir
1480 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1481 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1482 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1484 exhaust_precreations 0 0x80000215
1485 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1486 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1487 $GETSTRIPE $DIR/$tdir/$tfile
1491 run_test 27p "append to a truncated file with some full OSTs ==="
1494 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1496 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1497 remote_ost_nodsh && skip "remote OST with nodsh" && return
1500 rm -f $DIR/$tdir/$tfile
1502 test_mkdir -p $DIR/$tdir
1503 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1504 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1505 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1507 exhaust_all_precreations 0x215
1509 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1510 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1514 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1517 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 remote_ost_nodsh && skip "remote OST with nodsh" && return
1523 rm -f $DIR/$tdir/$tfile
1524 exhaust_precreations 0 0x80000215
1526 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1530 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1532 test_27s() { # bug 10725
1533 test_mkdir -p $DIR/$tdir
1534 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1535 local stripe_count=0
1536 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1537 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1538 error "stripe width >= 2^32 succeeded" || true
1541 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1543 test_27t() { # bug 10864
1548 $WLFS getstripe $tfile
1551 run_test 27t "check that utils parse path correctly"
1553 test_27u() { # bug 4900
1554 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1557 local list=$(comma_list $(mdts_nodes))
1559 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1560 do_nodes $list $LCTL set_param fail_loc=0x139
1561 test_mkdir -p $DIR/$tdir
1563 createmany -o $DIR/$tdir/t- 1000
1564 do_nodes $list $LCTL set_param fail_loc=0
1566 TLOG=$DIR/$tfile.getstripe
1567 $GETSTRIPE $DIR/$tdir > $TLOG
1568 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1569 unlinkmany $DIR/$tdir/t- 1000
1570 [ $OBJS -gt 0 ] && \
1571 error "$OBJS objects created on OST-0. See $TLOG" || pass
1573 run_test 27u "skip object creation on OSC w/o objects =========="
1575 test_27v() { # bug 4900
1576 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1578 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1579 remote_ost_nodsh && skip "remote OST with nodsh" && return
1581 exhaust_all_precreations 0x215
1584 test_mkdir -p $DIR/$tdir
1585 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1587 touch $DIR/$tdir/$tfile
1588 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1590 for (( i=1; i < OSTCOUNT; i++ )); do
1591 do_facet ost$i lctl set_param fail_loc=0x705
1593 local START=`date +%s`
1594 createmany -o $DIR/$tdir/$tfile 32
1596 local FINISH=`date +%s`
1597 local TIMEOUT=`lctl get_param -n timeout`
1598 local PROCESS=$((FINISH - START))
1599 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1600 error "$FINISH - $START >= $TIMEOUT / 2"
1601 sleep $((TIMEOUT / 2 - PROCESS))
1604 run_test 27v "skip object creation on slow OST ================="
1606 test_27w() { # bug 10997
1607 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1608 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1609 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1610 error "stripe size $size != 65536" || true
1611 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1612 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1614 run_test 27w "check $SETSTRIPE -S option"
1617 [ "$OSTCOUNT" -lt "2" ] &&
1618 skip_env "skipping multiple stripe count/offset test" && return
1620 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1621 for i in $(seq 1 $OSTCOUNT); do
1623 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1624 error "setstripe -c $i -i $offset failed"
1625 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1626 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1627 [ $count -ne $i ] && error "stripe count $count != $i" || true
1628 [ $index -ne $offset ] &&
1629 error "stripe offset $index != $offset" || true
1632 run_test 27wa "check $SETSTRIPE -c -i options"
1635 remote_ost_nodsh && skip "remote OST with nodsh" && return
1636 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1638 OFFSET=$(($OSTCOUNT - 1))
1640 local OST=$(ostname_from_index $OSTIDX)
1642 test_mkdir -p $DIR/$tdir
1643 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1644 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1646 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1647 for i in `seq 0 $OFFSET`; do
1648 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1649 error "OST0 was degraded but new created file still use it"
1651 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1653 run_test 27x "create files while OST0 is degraded"
1656 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1657 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1658 remote_ost_nodsh && skip "remote OST with nodsh" && return
1659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1661 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1662 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1663 osc.$mdtosc.prealloc_last_id)
1664 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1665 osc.$mdtosc.prealloc_next_id)
1666 local fcount=$((last_id - next_id))
1667 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1668 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1670 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1671 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1672 local OST_DEACTIVE_IDX=-1
1677 for OSC in $MDS_OSCS; do
1678 OST=$(osc_to_ost $OSC)
1679 OSTIDX=$(index_from_ostuuid $OST)
1680 if [ $OST_DEACTIVE_IDX == -1 ]; then
1681 OST_DEACTIVE_IDX=$OSTIDX
1683 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1684 echo $OSC "is Deactivated:"
1685 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1689 OSTIDX=$(index_from_ostuuid $OST)
1691 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1693 for OSC in $MDS_OSCS; do
1694 OST=$(osc_to_ost $OSC)
1695 OSTIDX=$(index_from_ostuuid $OST)
1696 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1697 echo $OST "is degraded:"
1698 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1699 obdfilter.$OST.degraded=1
1704 createmany -o $DIR/$tdir/$tfile $fcount
1706 for OSC in $MDS_OSCS; do
1707 OST=$(osc_to_ost $OSC)
1708 OSTIDX=$(index_from_ostuuid $OST)
1709 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1710 echo $OST "is recovered from degraded:"
1711 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1712 obdfilter.$OST.degraded=0
1714 do_facet $SINGLEMDS lctl --device %$OSC activate
1718 # all osp devices get activated, hence -1 stripe count restored
1721 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1722 # devices get activated.
1724 $SETSTRIPE -c -1 $DIR/$tfile
1725 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1727 [ $stripecnt -ne $OSTCOUNT ] &&
1728 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1731 run_test 27y "create files while OST0 is degraded and the rest inactive"
1737 lmm_count=$($GETSTRIPE -c $1)
1738 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1739 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1741 local old_ifs="$IFS"
1743 fid=($($LFS path2fid $1))
1746 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1747 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1749 # compare lmm_seq and lu_fid->f_seq
1750 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1751 # compare lmm_object_id and lu_fid->oid
1752 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1754 # check the trusted.fid attribute of the OST objects of the file
1755 local have_obdidx=false
1757 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1758 # skip lines up to and including "obdidx"
1759 [ -z "$obdidx" ] && break
1760 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1761 $have_obdidx || continue
1763 local ost=$((obdidx + 1))
1764 local dev=$(ostdevname $ost)
1767 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1769 seq=$(echo $seq | sed -e "s/^0x//g")
1770 if [ $seq == 0 ]; then
1771 oid_hex=$(echo $oid)
1773 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1775 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1779 # Don't unmount/remount the OSTs if we don't need to do that.
1780 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1781 # update too, until that use mount/ll_decode_filter_fid/mount.
1782 # Re-enable when debugfs will understand new filter_fid.
1784 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1785 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1786 $dev 2>/dev/null" | grep "parent=")
1789 mount_fstype ost$ost
1790 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1791 $(facet_mntpt ost$ost)/$obj_file)
1792 unmount_fstype ost$ost
1793 start ost$ost $dev $OST_MOUNT_OPTS
1796 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1798 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1800 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1801 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1802 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1803 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1804 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1806 if echo $ff_parent | grep -q 'stripe='; then
1807 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1810 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1811 # into f_ver in this case. See the comment on
1814 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1818 # compare lmm_seq and filter_fid->ff_parent.f_seq
1819 [ $ff_pseq = $lmm_seq ] ||
1820 error "FF parent SEQ $ff_pseq != $lmm_seq"
1821 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1822 [ $ff_poid = $lmm_oid ] ||
1823 error "FF parent OID $ff_poid != $lmm_oid"
1824 (($ff_pstripe == $stripe_nr)) ||
1825 error "FF stripe $ff_pstripe != $stripe_nr"
1827 stripe_nr=$((stripe_nr + 1))
1832 remote_ost_nodsh && skip "remote OST with nodsh" && return
1833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1834 test_mkdir -p $DIR/$tdir
1836 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1837 { error "setstripe -c -1 failed"; return 1; }
1838 # We need to send a write to every object to get parent FID info set.
1839 # This _should_ also work for setattr, but does not currently.
1840 # touch $DIR/$tdir/$tfile-1 ||
1841 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1842 { error "dd $tfile-1 failed"; return 2; }
1843 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1844 { error "setstripe -c -1 failed"; return 3; }
1845 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1846 { error "dd $tfile-2 failed"; return 4; }
1848 # make sure write RPCs have been sent to OSTs
1851 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1852 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1854 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1856 test_27A() { # b=19102
1857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1858 local restore_size=$($GETSTRIPE -S $MOUNT)
1859 local restore_count=$($GETSTRIPE -c $MOUNT)
1860 local restore_offset=$($GETSTRIPE -i $MOUNT)
1861 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1862 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1863 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1864 local default_size=$($GETSTRIPE -S $MOUNT)
1865 local default_offset=$($GETSTRIPE -i $MOUNT)
1866 local dsize=$((1024 * 1024))
1867 [ $default_size -eq $dsize ] ||
1868 error "stripe size $default_size != $dsize"
1869 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1870 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1872 run_test 27A "check filesystem-wide default LOV EA values"
1874 test_27B() { # LU-2523
1875 test_mkdir -p $DIR/$tdir
1876 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1878 # open f1 with O_LOV_DELAY_CREATE
1880 # call setstripe ioctl on open file descriptor for f1
1882 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1886 # open f1 with O_LOV_DELAY_CREATE
1888 # call setstripe ioctl on open file descriptor for f1
1890 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1892 # Allow multiop to fail in imitation of NFS's busted semantics.
1895 run_test 27B "call setstripe on open unlinked file/rename victim"
1897 test_27C() { #LU-2871
1898 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1906 test_mkdir -p $DIR/$tdir
1908 for i in $(seq 0 $((OSTCOUNT - 1))); do
1909 # set stripe across all OSTs starting from OST$i
1910 $SETSTRIPE -i $i -c -1 $tfile$i
1911 # get striping information
1912 ost_idx=($($GETSTRIPE $tfile$i |
1913 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1917 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1918 error "${#ost_idx[@]} != $OSTCOUNT"
1920 for index in $(seq 0 $((OSTCOUNT - 1))); do
1922 for j in $(echo ${ost_idx[@]}); do
1923 if [ $index -eq $j ]; then
1929 error "Can not find $index in ${ost_idx[@]}"
1933 run_test 27C "check full striping across all OSTs"
1935 # createtest also checks that device nodes are created and
1936 # then visible correctly (#2091)
1937 test_28() { # bug 2091
1939 $CREATETEST $DIR/d28/ct || error
1941 run_test 28 "create/mknod/mkdir with bad file types ============"
1944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1945 cancel_lru_locks mdc
1951 declare -i LOCKCOUNTORIG=0
1952 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1953 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1955 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1957 declare -i LOCKUNUSEDCOUNTORIG=0
1958 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1959 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1966 declare -i LOCKCOUNTCURRENT=0
1967 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1968 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1971 declare -i LOCKUNUSEDCOUNTCURRENT=0
1972 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1973 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1976 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1977 lctl set_param -n ldlm.dump_namespaces ""
1978 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1979 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1980 log "dumped log to $TMP/test_29.dk (bug 5793)"
1983 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1984 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1985 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1986 log "dumped log to $TMP/test_29.dk (bug 5793)"
1990 run_test 29 "IT_GETATTR regression ============================"
1992 test_30a() { # was test_30
1993 cp `which ls` $DIR || cp /bin/ls $DIR
1997 run_test 30a "execute binary from Lustre (execve) =============="
2000 cp `which ls` $DIR || cp /bin/ls $DIR
2002 $RUNAS $DIR/ls / || error
2005 run_test 30b "execute binary from Lustre as non-root ==========="
2007 test_30c() { # b=22376
2008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2009 cp `which ls` $DIR || cp /bin/ls $DIR
2011 cancel_lru_locks mdc
2012 cancel_lru_locks osc
2013 $RUNAS $DIR/ls / || error
2016 run_test 30c "execute binary from Lustre without read perms ===="
2019 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2020 $CHECKSTAT -a $DIR/f31 || error
2022 run_test 31a "open-unlink file =================================="
2025 touch $DIR/f31 || error
2026 ln $DIR/f31 $DIR/f31b || error
2027 $MULTIOP $DIR/f31b Ouc || error
2028 $CHECKSTAT -t file $DIR/f31 || error
2030 run_test 31b "unlink file with multiple links while open ======="
2033 touch $DIR/f31 || error
2034 ln $DIR/f31 $DIR/f31c || error
2035 multiop_bg_pause $DIR/f31 O_uc || return 1
2037 $MULTIOP $DIR/f31c Ouc
2038 kill -USR1 $MULTIPID
2041 run_test 31c "open-unlink file with multiple links ============="
2044 opendirunlink $DIR/d31d $DIR/d31d || error
2045 $CHECKSTAT -a $DIR/d31d || error
2047 run_test 31d "remove of open directory ========================="
2049 test_31e() { # bug 2904
2050 check_kernel_version 34 || return 0
2051 openfilleddirunlink $DIR/d31e || error
2053 run_test 31e "remove of open non-empty directory ==============="
2055 test_31f() { # bug 4554
2056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2058 test_mkdir $DIR/d31f
2059 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2060 cp /etc/hosts $DIR/d31f
2062 $GETSTRIPE $DIR/d31f/hosts
2063 multiop_bg_pause $DIR/d31f D_c || return 1
2066 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2067 test_mkdir $DIR/d31f
2068 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2069 cp /etc/hosts $DIR/d31f
2071 $GETSTRIPE $DIR/d31f/hosts
2072 multiop_bg_pause $DIR/d31f D_c || return 1
2075 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2076 wait $MULTIPID || error "first opendir $MULTIPID failed"
2080 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2081 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2084 run_test 31f "remove of open directory with open-unlink file ==="
2087 echo "-- cross directory link --"
2088 test_mkdir -c1 $DIR/${tdir}ga
2089 test_mkdir -c1 $DIR/${tdir}gb
2090 touch $DIR/${tdir}ga/f
2091 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2092 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2093 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2094 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2095 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2097 run_test 31g "cross directory link==============="
2100 echo "-- cross directory link --"
2101 test_mkdir -c1 $DIR/${tdir}
2102 test_mkdir -c1 $DIR/${tdir}/dir
2103 touch $DIR/${tdir}/f
2104 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2105 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2106 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2107 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2108 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2110 run_test 31h "cross directory link under child==============="
2113 echo "-- cross directory link --"
2114 test_mkdir -c1 $DIR/$tdir
2115 test_mkdir -c1 $DIR/$tdir/dir
2116 touch $DIR/$tdir/dir/f
2117 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2118 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2119 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2120 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2121 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2123 run_test 31i "cross directory link under parent==============="
2126 test_mkdir -c1 -p $DIR/$tdir
2127 test_mkdir -c1 -p $DIR/$tdir/dir1
2128 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2129 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2130 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2131 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2134 run_test 31j "link for directory==============="
2137 test_mkdir -c1 -p $DIR/$tdir
2139 touch $DIR/$tdir/exist
2140 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2141 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2142 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2143 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2144 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2145 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2146 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2149 run_test 31k "link to file: the same, non-existing, dir==============="
2155 touch $DIR/d31m2/exist
2156 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2157 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2158 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2159 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2160 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2161 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2164 run_test 31m "link to file: the same, non-existing, dir==============="
2167 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2168 nlink=$(stat --format=%h $DIR/$tfile)
2169 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2171 local cmd="exec $fd<$DIR/$tfile"
2174 trap "eval $cmd" EXIT
2175 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2176 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2177 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2178 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2179 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2182 run_test 31n "check link count of unlinked file"
2185 local TEMPNAME=$(mktemp $1_XXXXXX)
2186 mlink $TEMPNAME $1 2> /dev/null &&
2187 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2191 test_31o() { # LU-2901
2193 for LOOP in $(seq 100); do
2194 rm -f $DIR/$tdir/$tfile*
2195 for THREAD in $(seq 8); do
2196 link_one $DIR/$tdir/$tfile.$LOOP &
2199 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2200 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2201 error "$LINKS duplicate links to $tfile.$LOOP" &&
2205 run_test 31o "duplicate hard links with same filename"
2207 cleanup_test32_mount() {
2209 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2214 echo "== more mountpoints and symlinks ================="
2215 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2216 trap cleanup_test32_mount EXIT
2217 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2218 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2219 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2220 cleanup_test32_mount
2222 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2225 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2226 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2227 trap cleanup_test32_mount EXIT
2228 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2229 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2230 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2231 cleanup_test32_mount
2233 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2237 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2238 trap cleanup_test32_mount EXIT
2239 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2240 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2241 test_mkdir -p $DIR/$tdir/d2/test_dir
2242 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2243 cleanup_test32_mount
2245 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2249 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2250 trap cleanup_test32_mount EXIT
2251 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2252 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2253 test_mkdir -p $DIR/$tdir/d2/test_dir
2254 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2255 cleanup_test32_mount
2257 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2260 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2261 test_mkdir -p $DIR/d32e/tmp
2262 TMP_DIR=$DIR/d32e/tmp
2263 ln -s $DIR/d32e $TMP_DIR/symlink11
2264 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2265 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2266 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2268 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2271 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2272 test_mkdir -p $DIR/d32f/tmp
2273 TMP_DIR=$DIR/d32f/tmp
2274 ln -s $DIR/d32f $TMP_DIR/symlink11
2275 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2276 ls $DIR/d32f/tmp/symlink11 || error
2277 ls $DIR/d32f/symlink01 || error
2279 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2282 TMP_DIR=$DIR/$tdir/tmp
2283 test_mkdir -p $DIR/$tdir/tmp
2284 test_mkdir $DIR/${tdir}2
2285 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2286 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2287 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2288 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2289 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2290 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2292 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2295 rm -fr $DIR/$tdir $DIR/${tdir}2
2296 TMP_DIR=$DIR/$tdir/tmp
2297 test_mkdir -p $DIR/$tdir/tmp
2298 test_mkdir $DIR/${tdir}2
2299 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2300 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2301 ls $TMP_DIR/symlink12 || error
2302 ls $DIR/$tdir/symlink02 || error
2304 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2308 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2309 trap cleanup_test32_mount EXIT
2310 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2311 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2312 touch $DIR/$tdir/test_file
2313 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2314 cleanup_test32_mount
2316 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2320 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2321 trap cleanup_test32_mount EXIT
2322 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2323 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2324 touch $DIR/$tdir/test_file
2325 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2326 cleanup_test32_mount
2328 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2333 trap cleanup_test32_mount EXIT
2334 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2335 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2336 test_mkdir -p $DIR/$tdir/d2
2337 touch $DIR/$tdir/d2/test_file || error
2338 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2339 cleanup_test32_mount
2341 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2346 trap cleanup_test32_mount EXIT
2347 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2348 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2349 test_mkdir -p $DIR/$tdir/d2
2350 touch $DIR/$tdir/d2/test_file
2351 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2352 cleanup_test32_mount
2354 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2358 test_mkdir -p $DIR/d32m/tmp
2359 TMP_DIR=$DIR/d32m/tmp
2360 ln -s $DIR $TMP_DIR/symlink11
2361 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2362 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2363 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2365 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2369 test_mkdir -p $DIR/d32n/tmp
2370 TMP_DIR=$DIR/d32n/tmp
2371 ln -s $DIR $TMP_DIR/symlink11
2372 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2373 ls -l $DIR/d32n/tmp/symlink11 || error
2374 ls -l $DIR/d32n/symlink01 || error
2376 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2379 rm -fr $DIR/d32o $DIR/$tfile
2381 test_mkdir -p $DIR/d32o/tmp
2382 TMP_DIR=$DIR/d32o/tmp
2383 ln -s $DIR/$tfile $TMP_DIR/symlink12
2384 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2385 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2386 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2387 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2388 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2390 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2400 test_mkdir -p $DIR/d32p/tmp
2402 TMP_DIR=$DIR/d32p/tmp
2404 ln -s $DIR/$tfile $TMP_DIR/symlink12
2406 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2408 cat $DIR/d32p/tmp/symlink12 || error
2410 cat $DIR/d32p/symlink02 || error
2413 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2415 cleanup_testdir_mount() {
2417 $UMOUNT -d $DIR/$tdir
2421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2422 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2423 trap cleanup_testdir_mount EXIT
2424 test_mkdir -p $DIR/$tdir
2425 touch $DIR/$tdir/under_the_mount
2426 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2427 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2428 cleanup_testdir_mount
2430 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2434 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2435 trap cleanup_testdir_mount EXIT
2436 test_mkdir -p $DIR/$tdir
2437 touch $DIR/$tdir/under_the_mount
2438 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2439 ls $DIR/$tdir | grep -q under_the_mount && error || true
2440 cleanup_testdir_mount
2442 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2447 chmod 444 $DIR/$tfile
2448 chown $RUNAS_ID $DIR/$tfile
2450 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2453 run_test 33aa "write file with mode 444 (should return error) ===="
2457 test_mkdir -p $DIR/d33
2458 chown $RUNAS_ID $DIR/d33
2459 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2460 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2461 error "open RDWR" || true
2463 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2467 test_mkdir -p $DIR/d33
2468 chown $RUNAS_ID $DIR/d33
2469 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2471 run_test 33b "test open file with malformed flags (No panic and return error)"
2474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2480 remote_ost_nodsh && skip "remote OST with nodsh" && return
2483 test_mkdir -p $DIR/d33
2484 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2487 for ostnum in $(seq $OSTCOUNT); do
2488 # test-framework's OST numbering is one-based, while Lustre's
2490 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2491 # Parsing llobdstat's output sucks; we could grep the /proc
2492 # path, but that's likely to not be as portable as using the
2493 # llobdstat utility. So we parse lctl output instead.
2494 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2495 obdfilter/$ostname/stats |
2496 awk '/^write_bytes/ {print $7}' )
2497 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2498 if (( ${write_bytes:-0} > 0 ))
2505 $all_zeros || return 0
2508 echo foo > $DIR/d33/bar
2512 # Total up write_bytes after writing. We'd better find non-zeros.
2513 for ostnum in $(seq $OSTCOUNT); do
2514 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2515 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2516 obdfilter/$ostname/stats |
2517 awk '/^write_bytes/ {print $7}' )
2518 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2519 if (( ${write_bytes:-0} > 0 ))
2528 for ostnum in $(seq $OSTCOUNT); do
2529 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2530 echo "Check that write_bytes is present in obdfilter/*/stats:"
2531 do_facet ost$ostnum lctl get_param -n \
2532 obdfilter/$ostname/stats
2534 error "OST not keeping write_bytes stats (b22312)"
2537 run_test 33c "test llobdstat and write_bytes"
2540 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2543 local remote_dir=$DIR/$tdir/remote_dir
2546 $LFS mkdir -i $MDTIDX $remote_dir ||
2547 error "create remote directory failed"
2549 touch $remote_dir/$tfile
2550 chmod 444 $remote_dir/$tfile
2551 chown $RUNAS_ID $remote_dir/$tfile
2553 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2555 chown $RUNAS_ID $remote_dir
2556 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2557 error "create" || true
2558 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2559 error "open RDWR" || true
2560 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2561 error "create" || true
2563 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2565 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2568 $MCREATE $DIR/f34 || error
2569 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2570 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2571 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2572 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2574 run_test 34a "truncate file that has not been opened ==========="
2577 [ ! -f $DIR/f34 ] && test_34a
2578 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2579 $OPENFILE -f O_RDONLY $DIR/f34
2580 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2581 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2583 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2586 [ ! -f $DIR/f34 ] && test_34a
2587 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2588 $OPENFILE -f O_RDWR $DIR/f34
2589 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2590 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2592 run_test 34c "O_RDWR opening file-with-size works =============="
2595 [ ! -f $DIR/f34 ] && test_34a
2596 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2597 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2600 run_test 34d "write to sparse file ============================="
2604 $MCREATE $DIR/f34e || error
2605 $TRUNCATE $DIR/f34e 1000 || error
2606 $CHECKSTAT -s 1000 $DIR/f34e || error
2607 $OPENFILE -f O_RDWR $DIR/f34e
2608 $CHECKSTAT -s 1000 $DIR/f34e || error
2610 run_test 34e "create objects, some with size and some without =="
2612 test_34f() { # bug 6242, 6243
2613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2616 $MCREATE $DIR/f34f || error
2617 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2618 dd if=$DIR/f34f of=$TMP/f34f
2619 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2620 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2621 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2622 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2623 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2625 run_test 34f "read from a file with no objects until EOF ======="
2628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2629 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2630 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2631 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2632 cancel_lru_locks osc
2633 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2634 error "wrong size after lock cancel"
2636 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2637 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2638 error "expanding truncate failed"
2639 cancel_lru_locks osc
2640 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2641 error "wrong expanded size after lock cancel"
2643 run_test 34g "truncate long file ==============================="
2646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2650 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2651 sync # Flush the cache so that multiop below does not block on cache
2652 # flush when getting the group lock
2653 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2656 # Since just timed wait is not good enough, let's do a sync write
2657 # that way we are sure enough time for a roundtrip + processing
2658 # passed + 2 seconds of extra margin.
2659 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2663 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2664 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2668 local nsz=`stat -c %s $DIR/$tfile`
2669 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2671 run_test 34h "ftruncate file under grouplock should not block"
2674 cp /bin/sh $DIR/f35a
2676 chown $RUNAS_ID $DIR/f35a
2677 $RUNAS $DIR/f35a && error || true
2680 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2684 utime $DIR/f36 || error
2686 run_test 36a "MDS utime check (mknod, utime) ==================="
2690 utime $DIR/f36 || error
2692 run_test 36b "OST utime check (open, utime) ===================="
2697 chown $RUNAS_ID $DIR/d36
2698 $RUNAS utime $DIR/d36/f36 || error
2700 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2703 [ ! -d $DIR/d36 ] && test_36c
2704 echo "" > $DIR/d36/f36
2705 $RUNAS utime $DIR/d36/f36 || error
2707 run_test 36d "non-root OST utime check (open, utime) ==========="
2710 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2711 test_mkdir -p $DIR/$tdir
2712 touch $DIR/$tdir/$tfile
2713 $RUNAS utime $DIR/$tdir/$tfile && \
2714 error "utime worked, expected failure" || true
2716 run_test 36e "utime on non-owned file (should return error) ===="
2720 local LANG_SAVE=$LANG
2721 local LC_LANG_SAVE=$LC_LANG
2722 export LANG=C LC_LANG=C # for date language
2724 DATESTR="Dec 20 2000"
2725 test_mkdir -p $DIR/$tdir
2726 lctl set_param fail_loc=$fl
2728 cp /etc/hosts $DIR/$tdir/$tfile
2729 sync & # write RPC generated with "current" inode timestamp, but delayed
2731 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2732 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2733 cancel_lru_locks osc
2734 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2736 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2737 echo "BEFORE: $LS_BEFORE" && \
2738 echo "AFTER : $LS_AFTER" && \
2739 echo "WANT : $DATESTR" && \
2740 error "$DIR/$tdir/$tfile timestamps changed" || true
2742 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2747 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2748 subr_36fh "0x80000214"
2750 run_test 36f "utime on file racing with OST BRW write =========="
2753 remote_ost_nodsh && skip "remote OST with nodsh" && return
2754 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2759 test_mkdir -p $DIR/$tdir
2760 fmd_max_age=$(do_facet ost1 \
2761 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2764 fmd_before=$(do_facet ost1 \
2765 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2766 touch $DIR/$tdir/$tfile
2767 sleep $((fmd_max_age + 12))
2768 fmd_after=$(do_facet ost1 \
2769 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2771 echo "fmd_before: $fmd_before"
2772 echo "fmd_after: $fmd_after"
2773 [ "$fmd_after" -gt "$fmd_before" ] && \
2774 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2775 error "fmd didn't expire after ping" || true
2777 run_test 36g "filter mod data cache expiry ====================="
2780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2781 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2782 subr_36fh "0x80000227"
2784 run_test 36h "utime on file racing with OST BRW write =========="
2786 # test_37 - duplicate with tests 32q 32r
2789 local file=$DIR/$tfile
2791 openfile -f O_DIRECTORY $file
2794 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2795 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2797 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2801 touch $DIR/${tfile}2
2802 # ls -l $DIR/$tfile $DIR/${tfile}2
2803 # ls -lu $DIR/$tfile $DIR/${tfile}2
2804 # ls -lc $DIR/$tfile $DIR/${tfile}2
2806 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2807 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2809 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2811 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2813 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2814 error "O_TRUNC didn't change timestamps"
2817 run_test 39 "mtime changed on create ==========================="
2820 test_mkdir -p $DIR/$tdir
2821 cp -p /etc/passwd $DIR/$tdir/fopen
2822 cp -p /etc/passwd $DIR/$tdir/flink
2823 cp -p /etc/passwd $DIR/$tdir/funlink
2824 cp -p /etc/passwd $DIR/$tdir/frename
2825 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2828 echo "aaaaaa" >> $DIR/$tdir/fopen
2829 echo "aaaaaa" >> $DIR/$tdir/flink
2830 echo "aaaaaa" >> $DIR/$tdir/funlink
2831 echo "aaaaaa" >> $DIR/$tdir/frename
2833 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2834 local link_new=`stat -c %Y $DIR/$tdir/flink`
2835 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2836 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2838 cat $DIR/$tdir/fopen > /dev/null
2839 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2840 rm -f $DIR/$tdir/funlink2
2841 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2843 for (( i=0; i < 2; i++ )) ; do
2844 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2845 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2846 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2847 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2849 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2850 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2851 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2852 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2854 cancel_lru_locks osc
2855 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2858 run_test 39b "mtime change on open, link, unlink, rename ======"
2860 # this should be set to past
2861 TEST_39_MTIME=`date -d "1 year ago" +%s`
2867 local mtime0=`stat -c %Y $DIR1/$tfile`
2869 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2870 local mtime1=`stat -c %Y $DIR1/$tfile`
2871 [ "$mtime1" = $TEST_39_MTIME ] || \
2872 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2875 echo hello >> $DIR1/$tfile
2877 local mtime2=`stat -c %Y $DIR1/$tfile`
2878 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2879 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2881 mv $DIR1/$tfile $DIR1/$tfile-1
2883 for (( i=0; i < 2; i++ )) ; do
2884 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2885 [ "$mtime2" = "$mtime3" ] || \
2886 error "mtime ($mtime2) changed (to $mtime3) on rename"
2888 cancel_lru_locks osc
2889 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2892 run_test 39c "mtime change on rename ==========================="
2896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2899 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2901 for (( i=0; i < 2; i++ )) ; do
2902 local mtime=`stat -c %Y $DIR1/$tfile`
2903 [ $mtime = $TEST_39_MTIME ] || \
2904 error "mtime($mtime) is not set to $TEST_39_MTIME"
2906 cancel_lru_locks osc
2907 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2910 run_test 39d "create, utime, stat =============================="
2914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2916 local mtime1=`stat -c %Y $DIR1/$tfile`
2918 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2920 for (( i=0; i < 2; i++ )) ; do
2921 local mtime2=`stat -c %Y $DIR1/$tfile`
2922 [ $mtime2 = $TEST_39_MTIME ] || \
2923 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2925 cancel_lru_locks osc
2926 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2929 run_test 39e "create, stat, utime, stat ========================"
2933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2935 mtime1=`stat -c %Y $DIR1/$tfile`
2938 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2940 for (( i=0; i < 2; i++ )) ; do
2941 local mtime2=`stat -c %Y $DIR1/$tfile`
2942 [ $mtime2 = $TEST_39_MTIME ] || \
2943 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2945 cancel_lru_locks osc
2946 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2949 run_test 39f "create, stat, sleep, utime, stat ================="
2953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2954 echo hello >> $DIR1/$tfile
2955 local mtime1=`stat -c %Y $DIR1/$tfile`
2958 chmod o+r $DIR1/$tfile
2960 for (( i=0; i < 2; i++ )) ; do
2961 local mtime2=`stat -c %Y $DIR1/$tfile`
2962 [ "$mtime1" = "$mtime2" ] || \
2963 error "lost mtime: $mtime2, should be $mtime1"
2965 cancel_lru_locks osc
2966 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2969 run_test 39g "write, chmod, stat ==============================="
2973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2978 echo hello >> $DIR1/$tfile
2979 local mtime1=`stat -c %Y $DIR1/$tfile`
2981 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2983 if [ "$d1" != "$d2" ]; then
2984 echo "write and touch not within one second"
2986 for (( i=0; i < 2; i++ )) ; do
2987 local mtime2=`stat -c %Y $DIR1/$tfile`
2988 [ "$mtime2" = $TEST_39_MTIME ] || \
2989 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2991 cancel_lru_locks osc
2992 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2996 run_test 39h "write, utime within one second, stat ============="
2999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3003 echo hello >> $DIR1/$tfile
3004 local mtime1=`stat -c %Y $DIR1/$tfile`
3006 mv $DIR1/$tfile $DIR1/$tfile-1
3008 for (( i=0; i < 2; i++ )) ; do
3009 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3011 [ "$mtime1" = "$mtime2" ] || \
3012 error "lost mtime: $mtime2, should be $mtime1"
3014 cancel_lru_locks osc
3015 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3018 run_test 39i "write, rename, stat =============================="
3021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3022 start_full_debug_logging
3026 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3027 lctl set_param fail_loc=0x80000412
3028 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3029 error "multiop failed"
3031 local mtime1=`stat -c %Y $DIR1/$tfile`
3033 mv $DIR1/$tfile $DIR1/$tfile-1
3035 kill -USR1 $multipid
3036 wait $multipid || error "multiop close failed"
3038 for (( i=0; i < 2; i++ )) ; do
3039 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3040 [ "$mtime1" = "$mtime2" ] ||
3041 error "mtime is lost on close: $mtime2, " \
3044 cancel_lru_locks osc
3045 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3047 lctl set_param fail_loc=0
3048 stop_full_debug_logging
3050 run_test 39j "write, rename, close, stat ======================="
3053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3057 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3059 local mtime1=`stat -c %Y $DIR1/$tfile`
3061 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3063 kill -USR1 $multipid
3064 wait $multipid || error "multiop close failed"
3066 for (( i=0; i < 2; i++ )) ; do
3067 local mtime2=`stat -c %Y $DIR1/$tfile`
3069 [ "$mtime2" = $TEST_39_MTIME ] || \
3070 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3072 cancel_lru_locks osc
3073 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3076 run_test 39k "write, utime, close, stat ========================"
3078 # this should be set to future
3079 TEST_39_ATIME=`date -d "1 year" +%s`
3082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3083 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3084 local atime_diff=$(do_facet $SINGLEMDS \
3085 lctl get_param -n mdd.*MDT0000*.atime_diff)
3089 # test setting directory atime to future
3090 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3091 local atime=$(stat -c %X $DIR/$tdir)
3092 [ "$atime" = $TEST_39_ATIME ] || \
3093 error "atime is not set to future: $atime, $TEST_39_ATIME"
3095 # test setting directory atime from future to now
3096 local d1=$(date +%s)
3098 local d2=$(date +%s)
3100 cancel_lru_locks mdc
3101 atime=$(stat -c %X $DIR/$tdir)
3102 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3103 error "atime is not updated from future: $atime, $d1<atime<$d2"
3105 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3108 # test setting directory atime when now > dir atime + atime_diff
3112 cancel_lru_locks mdc
3113 atime=$(stat -c %X $DIR/$tdir)
3114 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3115 error "atime is not updated : $atime, should be $d2"
3117 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3120 # test not setting directory atime when now < dir atime + atime_diff
3122 cancel_lru_locks mdc
3123 atime=$(stat -c %X $DIR/$tdir)
3124 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3125 error "atime is updated to $atime, should remain $d1<atime<$d2"
3127 do_facet $SINGLEMDS \
3128 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3130 run_test 39l "directory atime update ==========================="
3133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3136 local far_past_mtime=$(date -d "May 29 1953" +%s)
3137 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3139 touch -m -d @$far_past_mtime $DIR1/$tfile
3140 touch -a -d @$far_past_atime $DIR1/$tfile
3142 for (( i=0; i < 2; i++ )) ; do
3143 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3144 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3145 error "atime or mtime set incorrectly"
3147 cancel_lru_locks osc
3148 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3151 run_test 39m "test atime and mtime before 1970"
3153 test_39n() { # LU-3832
3154 local atime_diff=$(do_facet $SINGLEMDS \
3155 lctl get_param -n mdd.*MDT0000*.atime_diff)
3160 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3163 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3164 atime0=$(stat -c %X $DIR/$tfile)
3167 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3168 atime1=$(stat -c %X $DIR/$tfile)
3171 cancel_lru_locks mdc
3172 cancel_lru_locks osc
3173 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3174 atime2=$(stat -c %X $DIR/$tfile)
3176 do_facet $SINGLEMDS \
3177 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3179 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3180 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3182 run_test 39n "check that O_NOATIME is honored"
3185 TESTDIR=$DIR/$tdir/$tfile
3186 [ -e $TESTDIR ] && rm -rf $TESTDIR
3187 test_mkdir -p $TESTDIR
3193 links2=$(stat -c %h .)
3194 [ $(($links1 + 2)) != $links2 ] &&
3195 error "wrong links count $(($links1 + 2)) != $links2"
3197 links3=$(stat -c %h .)
3198 [ $(($links1 + 1)) != $links3 ] &&
3199 error "wrong links count $links1 != $links3"
3202 run_test 39o "directory cached attributes updated after create ========"
3205 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3207 TESTDIR=$DIR/$tdir/$tfile
3208 [ -e $TESTDIR ] && rm -rf $TESTDIR
3213 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3214 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3216 links2=$(stat -c %h .)
3217 [ $(($links1 + 2)) != $links2 ] &&
3218 error "wrong links count $(($links1 + 2)) != $links2"
3220 links3=$(stat -c %h .)
3221 [ $(($links1 + 1)) != $links3 ] &&
3222 error "wrong links count $links1 != $links3"
3225 run_test 39p "remote directory cached attributes updated after create ========"
3229 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3230 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3231 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3232 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3233 error "$tfile is not 4096 bytes in size"
3235 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3239 small_write $DIR/f41 18
3241 run_test 41 "test small file write + fstat ====================="
3243 count_ost_writes() {
3244 lctl get_param -n osc.*.stats |
3245 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3252 BG_DIRTY_RATIO_SAVE=10
3253 MAX_BG_DIRTY_RATIO=25
3257 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3258 # dirty_ratio, dirty_background_ratio
3259 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3260 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3261 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3262 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3264 # if file not here, we are a 2.4 kernel
3265 kill -CONT `pidof kupdated`
3270 # setup the trap first, so someone cannot exit the test at the
3271 # exact wrong time and mess up a machine
3272 trap start_writeback EXIT
3273 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3274 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3275 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3276 sysctl -w vm.dirty_writeback_centisecs=0
3277 sysctl -w vm.dirty_writeback_centisecs=0
3278 # save and increase /proc/sys/vm/dirty_ratio
3279 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3280 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3281 # save and increase /proc/sys/vm/dirty_background_ratio
3282 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3283 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3285 # if file not here, we are a 2.4 kernel
3286 kill -STOP `pidof kupdated`
3290 # ensure that all stripes have some grant before we test client-side cache
3292 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3293 dd if=/dev/zero of=$i bs=4k count=1
3298 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3299 # file truncation, and file removal.
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3303 cancel_lru_locks osc
3305 sync; sleep 1; sync # just to be safe
3306 BEFOREWRITES=`count_ost_writes`
3307 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3308 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3309 AFTERWRITES=`count_ost_writes`
3310 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3311 error "$BEFOREWRITES < $AFTERWRITES"
3314 run_test 42a "ensure that we don't flush on close =============="
3317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3319 cancel_lru_locks osc
3322 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3323 BEFOREWRITES=`count_ost_writes`
3324 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3325 AFTERWRITES=`count_ost_writes`
3326 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3327 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3329 BEFOREWRITES=`count_ost_writes`
3330 sync || error "sync: $?"
3331 AFTERWRITES=`count_ost_writes`
3332 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3333 error "$BEFOREWRITES < $AFTERWRITES on sync"
3335 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3339 run_test 42b "test destroy of file with cached dirty data ======"
3341 # if these tests just want to test the effect of truncation,
3342 # they have to be very careful. consider:
3343 # - the first open gets a {0,EOF}PR lock
3344 # - the first write conflicts and gets a {0, count-1}PW
3345 # - the rest of the writes are under {count,EOF}PW
3346 # - the open for truncate tries to match a {0,EOF}PR
3347 # for the filesize and cancels the PWs.
3348 # any number of fixes (don't get {0,EOF} on open, match
3349 # composite locks, do smarter file size management) fix
3350 # this, but for now we want these tests to verify that
3351 # the cancellation with truncate intent works, so we
3352 # start the file with a full-file pw lock to match against
3353 # until the truncate.
3358 cancel_lru_locks osc
3360 # prime the file with 0,EOF PW to match
3364 # now the real test..
3365 dd if=/dev/zero of=$file bs=1024 count=100
3366 BEFOREWRITES=`count_ost_writes`
3367 $TRUNCATE $file $offset
3368 cancel_lru_locks osc
3369 AFTERWRITES=`count_ost_writes`
3374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3376 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3377 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3380 run_test 42c "test partial truncate of file with cached dirty data"
3383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3385 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3386 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3389 run_test 42d "test complete truncate of file with cached dirty data"
3391 test_42e() { # bug22074
3392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3393 local TDIR=$DIR/${tdir}e
3394 local pagesz=$(page_size)
3395 local pages=16 # hardcoded 16 pages, don't change it.
3396 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3397 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3401 test_mkdir -p $DIR/${tdir}e
3402 $SETSTRIPE -c 1 $TDIR
3403 createmany -o $TDIR/f $files
3405 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3407 # we assume that with $OSTCOUNT files, at least one of them will
3408 # be allocated on OST0.
3409 warmup_files=$((OSTCOUNT * max_dirty_mb))
3410 createmany -o $TDIR/w $warmup_files
3412 # write a large amount of data into one file and sync, to get good
3413 # avail_grant number from OST.
3414 for ((i=0; i<$warmup_files; i++)); do
3415 idx=$($GETSTRIPE -i $TDIR/w$i)
3416 [ $idx -ne 0 ] && continue
3417 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3420 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3422 $LCTL get_param $proc_osc0/cur_dirty_bytes
3423 $LCTL get_param $proc_osc0/cur_grant_bytes
3425 # create as much dirty pages as we can while not to trigger the actual
3426 # RPCs directly. but depends on the env, VFS may trigger flush during this
3427 # period, hopefully we are good.
3428 for ((i=0; i<$warmup_files; i++)); do
3429 idx=$($GETSTRIPE -i $TDIR/w$i)
3430 [ $idx -ne 0 ] && continue
3431 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3433 $LCTL get_param $proc_osc0/cur_dirty_bytes
3434 $LCTL get_param $proc_osc0/cur_grant_bytes
3436 # perform the real test
3437 $LCTL set_param $proc_osc0/rpc_stats 0
3438 for ((;i<$files; i++)); do
3439 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3440 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3443 $LCTL get_param $proc_osc0/rpc_stats
3446 local have_ppr=false
3447 $LCTL get_param $proc_osc0/rpc_stats |
3448 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3449 # skip lines until we are at the RPC histogram data
3450 [ "$PPR" == "pages" ] && have_ppr=true && continue
3451 $have_ppr || continue
3453 # we only want the percent stat for < 16 pages
3454 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3456 percent=$((percent + WPCT))
3457 if [ $percent -gt 15 ]; then
3458 error "less than 16-pages write RPCs" \
3465 run_test 42e "verify sub-RPC writes are not done synchronously"
3468 test_mkdir -p $DIR/$tdir
3469 cp -p /bin/ls $DIR/$tdir/$tfile
3470 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3472 # give multiop a chance to open
3475 $DIR/$tdir/$tfile && error || true
3478 run_test 43 "execution of file opened for write should return -ETXTBSY"
3481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3482 test_mkdir -p $DIR/$tdir
3483 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3484 cp -p multiop $DIR/$tdir/multiop
3485 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3488 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3489 kill -USR1 $MULTIOP_PID || return 2
3490 wait $MULTIOP_PID || return 3
3491 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3493 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3497 test_mkdir -p $DIR/$tdir
3498 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3499 cp -p multiop $DIR/$tdir/multiop
3500 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3503 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3504 kill -USR1 $MULTIOP_PID || return 2
3505 wait $MULTIOP_PID || return 3
3506 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3508 run_test 43b "truncate of file being executed should return -ETXTBSY"
3511 local testdir="$DIR/$tdir"
3512 test_mkdir -p $DIR/$tdir
3514 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3515 ( cd $testdir && md5sum -c)
3517 run_test 43c "md5sum of copy into lustre========================"
3520 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3521 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3522 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3524 run_test 44 "zero length read from a sparse stripe ============="
3527 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3529 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3530 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3531 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3533 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3534 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3537 OFFSETS="0 $((stride/2)) $((stride-1))"
3538 for offset in $OFFSETS ; do
3539 for i in `seq 0 $((nstripe-1))`; do
3540 local GLOBALOFFSETS=""
3541 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3542 local myfn=$DIR/d44a-$size
3543 echo "--------writing $myfn at $size"
3544 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3545 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3546 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3547 || error "ll_sparseness_verify $GLOBALOFFSETS"
3549 for j in `seq 0 $((nstripe-1))`; do
3550 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3551 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3552 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3554 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3555 || error "ll_sparseness_verify $GLOBALOFFSETS"
3560 run_test 44a "test sparse pwrite ==============================="
3564 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3570 before=`dirty_osc_total`
3571 echo executing "\"$*\""
3573 after=`dirty_osc_total`
3574 echo before $before, after $after
3577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3579 # Obtain grants from OST if it supports it
3580 echo blah > ${f}_grant
3583 do_dirty_record "echo blah > $f"
3584 [ $before -eq $after ] && error "write wasn't cached"
3585 do_dirty_record "> $f"
3586 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3587 do_dirty_record "echo blah > $f"
3588 [ $before -eq $after ] && error "write wasn't cached"
3589 do_dirty_record "sync"
3590 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3591 do_dirty_record "echo blah > $f"
3592 [ $before -eq $after ] && error "write wasn't cached"
3593 do_dirty_record "cancel_lru_locks osc"
3594 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3597 run_test 45 "osc io page accounting ============================"
3599 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3600 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3601 # objects offset and an assert hit when an rpc was built with 1023's mapped
3602 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3608 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3610 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3611 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3615 run_test 46 "dirtying a previously written page ================"
3617 # test_47 is removed "Device nodes check" is moved to test_28
3619 test_48a() { # bug 2399
3620 check_kernel_version 34 || return 0
3621 test_mkdir -p $DIR/$tdir
3623 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3624 test_mkdir $DIR/$tdir || error "recreate directory failed"
3625 touch foo || error "'touch foo' failed after recreating cwd"
3626 test_mkdir $DIR/$tdir/bar ||
3627 error "'mkdir foo' failed after recreating cwd"
3628 if check_kernel_version 44; then
3629 touch .foo || error "'touch .foo' failed after recreating cwd"
3630 test_mkdir $DIR/$tdir/.bar ||
3631 error "'mkdir .foo' failed after recreating cwd"
3633 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3634 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3635 cd . || error "'cd .' failed after recreating cwd"
3636 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3637 rmdir . && error "'rmdir .' worked after recreating cwd"
3638 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3639 cd .. || error "'cd ..' failed after recreating cwd"
3641 run_test 48a "Access renamed working dir (should return errors)="
3643 test_48b() { # bug 2399
3644 check_kernel_version 34 || return 0
3646 test_mkdir -p $DIR/$tdir
3648 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3649 touch foo && error "'touch foo' worked after removing cwd"
3650 test_mkdir $DIR/$tdir/foo &&
3651 error "'mkdir foo' worked after removing cwd"
3652 if check_kernel_version 44; then
3653 touch .foo && error "'touch .foo' worked after removing cwd"
3654 test_mkdir $DIR/$tdir/.foo &&
3655 error "'mkdir .foo' worked after removing cwd"
3657 ls . > /dev/null && error "'ls .' worked after removing cwd"
3658 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3659 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3660 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3661 rmdir . && error "'rmdir .' worked after removing cwd"
3662 ln -s . foo && error "'ln -s .' worked after removing cwd"
3663 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3665 run_test 48b "Access removed working dir (should return errors)="
3667 test_48c() { # bug 2350
3668 check_kernel_version 36 || return 0
3669 #lctl set_param debug=-1
3672 test_mkdir -p $DIR/$tdir/dir
3674 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3675 $TRACE touch foo && error "touch foo worked after removing cwd"
3676 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3677 if check_kernel_version 44; then
3678 touch .foo && error "touch .foo worked after removing cwd"
3679 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3681 $TRACE ls . && error "'ls .' worked after removing cwd"
3682 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3683 is_patchless || ( $TRACE cd . &&
3684 error "'cd .' worked after removing cwd" )
3685 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3686 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3687 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3688 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3690 run_test 48c "Access removed working subdir (should return errors)"
3692 test_48d() { # bug 2350
3693 check_kernel_version 36 || return 0
3694 #lctl set_param debug=-1
3697 test_mkdir -p $DIR/$tdir/dir
3699 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3700 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3701 $TRACE touch foo && error "'touch foo' worked after removing parent"
3702 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3703 if check_kernel_version 44; then
3704 touch .foo && error "'touch .foo' worked after removing parent"
3706 error "mkdir .foo worked after removing parent"
3708 $TRACE ls . && error "'ls .' worked after removing parent"
3709 $TRACE ls .. && error "'ls ..' worked after removing parent"
3710 is_patchless || ( $TRACE cd . &&
3711 error "'cd .' worked after recreate parent" )
3712 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3713 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3714 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3715 is_patchless || ( $TRACE cd .. &&
3716 error "'cd ..' worked after removing parent" || true )
3718 run_test 48d "Access removed parent subdir (should return errors)"
3720 test_48e() { # bug 4134
3721 check_kernel_version 41 || return 0
3722 #lctl set_param debug=-1
3725 test_mkdir -p $DIR/$tdir/dir
3727 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3728 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3729 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3730 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3731 # On a buggy kernel addition of "touch foo" after cd .. will
3732 # produce kernel oops in lookup_hash_it
3733 touch ../foo && error "'cd ..' worked after recreate parent"
3735 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3737 run_test 48e "Access to recreated parent subdir (should return errors)"
3739 test_49() { # LU-1030
3740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3741 # get ost1 size - lustre-OST0000
3742 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3743 # write 800M at maximum
3744 [ $ost1_size -gt 819200 ] && ost1_size=819200
3746 lfs setstripe -c 1 -i 0 $DIR/$tfile
3747 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3750 # change max_pages_per_rpc while writing the file
3751 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3752 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3753 # loop until dd process exits
3754 while ps ax -opid | grep -wq $dd_pid; do
3755 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3756 sleep $((RANDOM % 5 + 1))
3758 # restore original max_pages_per_rpc
3759 $LCTL set_param $osc1_mppc=$orig_mppc
3760 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3762 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3766 test_mkdir $DIR/$tdir
3768 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3770 run_test 50 "special situations: /proc symlinks ==============="
3772 test_51a() { # was test_51
3773 # bug 1516 - create an empty entry right after ".." then split dir
3774 test_mkdir -p $DIR/$tdir
3775 touch $DIR/$tdir/foo
3776 $MCREATE $DIR/$tdir/bar
3778 createmany -m $DIR/$tdir/longfile 201
3780 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3781 $MCREATE $DIR/$tdir/longfile$FNUM
3786 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3788 run_test 51a "special situations: split htree with empty entry =="
3790 export NUMTEST=70000
3792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3793 local BASE=$DIR/d${base}.${TESTSUITE}
3795 # cleanup the directory
3800 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3801 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3802 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3805 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3806 echo "reduced count to $NUMTEST due to inodes"
3808 # need to check free space for the directories as well
3809 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3810 numfree=$((blkfree / 4))
3811 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3812 echo "reduced count to $NUMTEST due to blocks"
3814 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3815 echo "failed" > $BASE/fnum
3817 run_test 51b "exceed 64k subdirectory nlink limit"
3819 test_51ba() { # LU-993
3820 local BASE=$DIR/d${base}.${TESTSUITE}
3821 # unlink all but 100 subdirectories, then check it still works
3823 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3825 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3826 local DELETE=$((NUMTEST - LEFT))
3828 # continue on to run this test even if 51b didn't finish,
3829 # just to delete the many subdirectories created.
3830 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3832 # for ldiskfs the nlink count should be 1, but this is OSD specific
3833 # and so this is listed for informational purposes only
3834 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3835 unlinkmany -d $BASE/d $DELETE
3838 if [ $RC -ne 0 ]; then
3839 if [ "$NUMPREV" == "failed" ]; then
3840 skip "previous setup failed"
3843 error "unlink of first $DELETE subdirs failed"
3848 echo "nlink between: $(stat -c %h $BASE)"
3849 # trim the first line of ls output
3850 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3851 [ $FOUND -ne $LEFT ] &&
3852 error "can't find subdirs: found only $FOUND/$LEFT"
3854 unlinkmany -d $BASE/d $DELETE $LEFT ||
3855 error "unlink of second $LEFT subdirs failed"
3856 # regardless of whether the backing filesystem tracks nlink accurately
3857 # or not, the nlink count shouldn't be more than "." and ".." here
3858 local AFTER=$(stat -c %h $BASE)
3859 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3860 echo "nlink after: $AFTER"
3862 run_test 51ba "verify nlink for many subdirectory cleanup"
3865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3866 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3867 test_mkdir -p $DIR/$tdir
3868 createmany -o $DIR/$tdir/t- 1000
3869 $GETSTRIPE $DIR/$tdir > $TMP/files
3870 for N in `seq 0 $((OSTCOUNT - 1))`; do
3871 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3872 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3873 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3875 unlinkmany $DIR/$tdir/t- 1000
3878 for N in `seq 1 $((OSTCOUNT - 1))`; do
3879 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3880 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3881 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3882 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3884 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3885 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3886 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3887 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3891 run_test 51d "check object distribution ===================="
3894 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3895 test_mkdir -p $DIR/$tdir
3896 touch $DIR/$tdir/foo
3897 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3898 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3899 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3900 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3901 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3903 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3904 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3905 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3907 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3908 cp -r $DIR/$tdir /tmp/
3909 rm -fr $DIR/$tdir || error "cleanup rm failed"
3911 run_test 52a "append-only flag test (should return errors) ====="
3914 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3915 test_mkdir -p $DIR/$tdir
3916 touch $DIR/$tdir/foo
3917 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3918 cat test > $DIR/$tdir/foo && error "cat test worked"
3919 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3920 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3921 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3923 echo foo >> $DIR/$tdir/foo && error "echo worked"
3924 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3925 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3926 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3927 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3929 chattr -i $DIR/$tdir/foo || error "chattr failed"
3931 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3933 run_test 52b "immutable flag test (should return errors) ======="
3936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3937 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3938 remote_ost_nodsh && skip "remote OST with nodsh" && return
3951 local support_last_seq=true
3953 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
3954 support_last_seq=false
3957 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3959 for value in $(do_facet $SINGLEMDS \
3960 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
3961 param=$(echo ${value[0]} | cut -d "=" -f1)
3962 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3964 if $support_last_seq; then
3965 param_seq=$(echo $param |
3966 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3967 mds_last_seq=$(do_facet $SINGLEMDS \
3968 $LCTL get_param -n $param_seq)
3970 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
3972 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3973 node=$(facet_active_host ost$((ostnum+1)))
3974 param="obdfilter.$ostname.last_id"
3975 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
3976 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
3977 ost_last_id=$ost_last
3979 if $support_last_seq; then
3980 ost_last_id=$(echo $ost_last |
3981 awk -F':' '{print $2}' |
3983 ost_last_seq=$(echo $ost_last |
3984 awk -F':' '{print $1}')
3985 [[ $ost_last_seq = $mds_last_seq ]] || continue
3988 if [[ $ost_last_id != $mds_last ]]; then
3989 error "$ost_last_id != $mds_last"
3996 $found || error "can not match last_seq/last_id for $mdtosc"
3999 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4002 $SOCKETSERVER $DIR/socket ||
4003 error "$SOCKETSERVER $DIR/socket failed: $?"
4004 $SOCKETCLIENT $DIR/socket ||
4005 error "$SOCKETCLIENT $DIR/socket failed: $?"
4006 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4008 run_test 54a "unix domain socket test =========================="
4014 dd if=/dev/zero of=$f bs=$(page_size) count=1
4016 run_test 54b "char device works in lustre ======================"
4019 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4020 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4021 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4023 for i in $(seq 3 7); do
4024 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4032 loopdev="$DIR/loop54c"
4035 $UMOUNT -d $tdir || rc=$?
4036 losetup -d $loopdev || true
4042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4045 loopdev="$DIR/loop54c"
4048 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4049 mknod $loopdev b 7 $LOOPNUM
4050 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4051 dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4052 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4053 trap cleanup_54c EXIT
4054 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4056 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4057 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4059 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4062 run_test 54c "block device works in lustre ====================="
4068 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4070 run_test 54d "fifo device works in lustre ======================"
4073 check_kernel_version 46 || return 0
4076 cp -aL /dev/console $f
4077 echo $string > $f || error "echo $string to $f failed"
4079 run_test 54e "console/tty device works in lustre ======================"
4081 #The test_55 used to be iopen test and it was removed by bz#24037.
4082 #run_test 55 "check iopen_connect_dentry() ======================"
4084 test_56a() { # was test_56
4087 test_mkdir -p $DIR/$tdir/dir
4089 NUMFILESx2=$(($NUMFILES * 2))
4090 for i in `seq 1 $NUMFILES` ; do
4091 touch $DIR/$tdir/file$i
4092 touch $DIR/$tdir/dir/file$i
4095 # test lfs getstripe with --recursive
4096 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
4097 [ $FILENUM -eq $NUMFILESx2 ] ||
4098 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4099 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
4100 [ $FILENUM -eq $NUMFILES ] ||
4101 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4102 echo "$GETSTRIPE --recursive passed."
4104 # test lfs getstripe with file instead of dir
4105 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
4106 [ $FILENUM -eq 1 ] || error \
4107 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4108 echo "$GETSTRIPE file1 passed."
4110 #test lfs getstripe with --verbose
4111 [ `$GETSTRIPE --verbose $DIR/$tdir |
4112 grep -c lmm_magic` -eq $NUMFILES ] ||
4113 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4114 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
4115 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4116 echo "$GETSTRIPE --verbose passed."
4118 #test lfs getstripe with --obd
4119 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4120 grep -q "unknown obduuid" ||
4121 error "$GETSTRIPE --obd wrong_uuid should return error message"
4123 [ "$OSTCOUNT" -lt 2 ] &&
4124 skip_env "skipping other $GETSTRIPE --obd test" && return
4127 OBDUUID=$(ostuuid_from_index $OSTIDX)
4128 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
4129 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
4130 [ $FOUND -eq $FILENUM ] ||
4131 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4132 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4133 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4134 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
4135 error "$GETSTRIPE --obd: should not show file on other obd"
4136 echo "$GETSTRIPE --obd passed"
4138 run_test 56a "check $GETSTRIPE"
4143 local LOCAL_NUMFILES="$1"
4144 local LOCAL_NUMDIRS="$2"
4145 local MKDIR_PARAMS="$3"
4146 local DIR_STRIPE_PARAMS="$4"
4148 if [ ! -d "$TDIR" ] ; then
4149 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4150 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4151 for i in `seq 1 $LOCAL_NUMFILES` ; do
4154 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4155 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4156 for j in `seq 1 $LOCAL_NUMFILES` ; do
4157 touch $TDIR/dir$i/file$j
4163 setup_56_special() {
4167 if [ ! -e "$TDIR/loop1b" ] ; then
4168 for i in `seq 1 $LOCAL_NUMFILES` ; do
4169 mknod $TDIR/loop${i}b b 7 $i
4170 mknod $TDIR/null${i}c c 1 3
4171 ln -s $TDIR/file1 $TDIR/link${i}l
4173 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4174 mknod $TDIR/dir$i/loop${i}b b 7 $i
4175 mknod $TDIR/dir$i/null${i}c c 1 3
4176 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4185 setup_56 $NUMFILES $NUMDIRS
4187 EXPECTED=$(($NUMDIRS + 2))
4188 # test lfs find with -name
4189 for i in $(seq 1 $NUMFILES) ; do
4190 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4191 [ $NUMS -eq $EXPECTED ] ||
4192 error "lfs find -name \"*$i\" $TDIR wrong: "\
4193 "found $NUMS, expected $EXPECTED"
4196 run_test 56g "check lfs find -name ============================="
4202 setup_56 $NUMFILES $NUMDIRS
4204 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4205 # test lfs find with ! -name
4206 for i in $(seq 1 $NUMFILES) ; do
4207 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4208 [ $NUMS -eq $EXPECTED ] ||
4209 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4210 "found $NUMS, expected $EXPECTED"
4213 run_test 56h "check lfs find ! -name ============================="
4217 test_mkdir -p $DIR/$tdir
4218 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4219 CMD="$LFIND -ost $UUID $DIR/$tdir"
4221 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4223 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4227 setup_56_special $NUMFILES $NUMDIRS
4229 EXPECTED=$((NUMDIRS + 1))
4230 CMD="$LFIND -type d $TDIR"
4231 NUMS=$($CMD | wc -l)
4232 [ $NUMS -eq $EXPECTED ] ||
4233 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4235 run_test 56j "check lfs find -type d ============================="
4239 setup_56_special $NUMFILES $NUMDIRS
4241 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4242 CMD="$LFIND -type f $TDIR"
4243 NUMS=$($CMD | wc -l)
4244 [ $NUMS -eq $EXPECTED ] ||
4245 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4247 run_test 56k "check lfs find -type f ============================="
4251 setup_56_special $NUMFILES $NUMDIRS
4253 EXPECTED=$((NUMDIRS + NUMFILES))
4254 CMD="$LFIND -type b $TDIR"
4255 NUMS=$($CMD | wc -l)
4256 [ $NUMS -eq $EXPECTED ] ||
4257 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4259 run_test 56l "check lfs find -type b ============================="
4263 setup_56_special $NUMFILES $NUMDIRS
4265 EXPECTED=$((NUMDIRS + NUMFILES))
4266 CMD="$LFIND -type c $TDIR"
4267 NUMS=$($CMD | wc -l)
4268 [ $NUMS -eq $EXPECTED ] ||
4269 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4271 run_test 56m "check lfs find -type c ============================="
4275 setup_56_special $NUMFILES $NUMDIRS
4277 EXPECTED=$((NUMDIRS + NUMFILES))
4278 CMD="$LFIND -type l $TDIR"
4279 NUMS=$($CMD | wc -l)
4280 [ $NUMS -eq $EXPECTED ] ||
4281 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4283 run_test 56n "check lfs find -type l ============================="
4287 setup_56 $NUMFILES $NUMDIRS
4288 utime $TDIR/file1 > /dev/null || error "utime (1)"
4289 utime $TDIR/file2 > /dev/null || error "utime (2)"
4290 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4291 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4292 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4293 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4296 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4297 [ $NUMS -eq $EXPECTED ] || \
4298 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4301 CMD="$LFIND -mtime 0 $TDIR"
4302 NUMS=$($CMD | wc -l)
4303 [ $NUMS -eq $EXPECTED ] ||
4304 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4306 run_test 56o "check lfs find -mtime for old files =========================="
4309 [ $RUNAS_ID -eq $UID ] &&
4310 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4313 setup_56 $NUMFILES $NUMDIRS
4315 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4317 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4318 NUMS=$($CMD | wc -l)
4319 [ $NUMS -eq $EXPECTED ] || \
4320 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4322 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4323 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4324 NUMS=$($CMD | wc -l)
4325 [ $NUMS -eq $EXPECTED ] || \
4326 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4328 run_test 56p "check lfs find -uid and ! -uid ==============================="
4331 [ $RUNAS_ID -eq $UID ] &&
4332 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4335 setup_56 $NUMFILES $NUMDIRS
4337 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4340 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4341 NUMS=$($CMD | wc -l)
4342 [ $NUMS -eq $EXPECTED ] ||
4343 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4345 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4346 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4347 NUMS=$($CMD | wc -l)
4348 [ $NUMS -eq $EXPECTED ] ||
4349 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4351 run_test 56q "check lfs find -gid and ! -gid ==============================="
4355 setup_56 $NUMFILES $NUMDIRS
4358 CMD="$LFIND -size 0 -type f $TDIR"
4359 NUMS=$($CMD | wc -l)
4360 [ $NUMS -eq $EXPECTED ] ||
4361 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4363 CMD="$LFIND ! -size 0 -type f $TDIR"
4364 NUMS=$($CMD | wc -l)
4365 [ $NUMS -eq $EXPECTED ] ||
4366 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4367 echo "test" > $TDIR/$tfile
4368 echo "test2" > $TDIR/$tfile.2 && sync
4370 CMD="$LFIND -size 5 -type f $TDIR"
4371 NUMS=$($CMD | wc -l)
4372 [ $NUMS -eq $EXPECTED ] ||
4373 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4375 CMD="$LFIND -size +5 -type f $TDIR"
4376 NUMS=$($CMD | wc -l)
4377 [ $NUMS -eq $EXPECTED ] ||
4378 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4380 CMD="$LFIND -size +0 -type f $TDIR"
4381 NUMS=$($CMD | wc -l)
4382 [ $NUMS -eq $EXPECTED ] ||
4383 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4385 CMD="$LFIND ! -size -5 -type f $TDIR"
4386 NUMS=$($CMD | wc -l)
4387 [ $NUMS -eq $EXPECTED ] ||
4388 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4390 CMD="$LFIND -size -5 -type f $TDIR"
4391 NUMS=$($CMD | wc -l)
4392 [ $NUMS -eq $EXPECTED ] ||
4393 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4395 run_test 56r "check lfs find -size works =========================="
4397 test_56s() { # LU-611
4399 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4401 if [ $OSTCOUNT -gt 1 ]; then
4402 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4406 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4410 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4411 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4412 NUMS=$($CMD | wc -l)
4413 [ $NUMS -eq $EXPECTED ] ||
4414 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4416 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4417 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4418 NUMS=$($CMD | wc -l)
4419 [ $NUMS -eq $EXPECTED ] ||
4420 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4423 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4424 NUMS=$($CMD | wc -l)
4425 [ $NUMS -eq $EXPECTED ] ||
4426 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4428 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4429 NUMS=$($CMD | wc -l)
4430 [ $NUMS -eq $EXPECTED ] ||
4431 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4434 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4435 NUMS=$($CMD | wc -l)
4436 [ $NUMS -eq $EXPECTED ] ||
4437 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4439 run_test 56s "check lfs find -stripe-count works"
4441 test_56t() { # LU-611
4443 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4445 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4447 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4448 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4449 NUMS=$($CMD | wc -l)
4450 [ $NUMS -eq $EXPECTED ] ||
4451 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4453 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4454 NUMS=$($CMD | wc -l)
4455 [ $NUMS -eq $EXPECTED ] ||
4456 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4458 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4459 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4460 NUMS=$($CMD | wc -l)
4461 [ $NUMS -eq $EXPECTED ] ||
4462 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4464 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4465 NUMS=$($CMD | wc -l)
4466 [ $NUMS -eq $EXPECTED ] ||
4467 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4470 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4471 NUMS=$($CMD | wc -l)
4472 [ $NUMS -eq $EXPECTED ] ||
4473 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4475 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4476 NUMS=$($CMD | wc -l)
4477 [ $NUMS -eq $EXPECTED ] ||
4478 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4481 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4482 NUMS=$($CMD | wc -l)
4483 [ $NUMS -eq $EXPECTED ] ||
4484 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4486 run_test 56t "check lfs find -stripe-size works"
4488 test_56u() { # LU-611
4490 setup_56 $NUMFILES $NUMDIRS "-i 0"
4492 if [ $OSTCOUNT -gt 1 ]; then
4493 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4499 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4500 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4501 NUMS=$($CMD | wc -l)
4502 [ $NUMS -eq $EXPECTED ] ||
4503 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4506 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4507 NUMS=$($CMD | wc -l)
4508 [ $NUMS -eq $EXPECTED ] ||
4509 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4511 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4512 NUMS=$($CMD | wc -l)
4513 [ $NUMS -eq $EXPECTED ] ||
4514 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4517 # This should produce an error and not return any files
4518 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4519 NUMS=$($CMD 2>/dev/null | wc -l)
4520 [ $NUMS -eq $EXPECTED ] ||
4521 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4523 if [ $OSTCOUNT -gt 1 ]; then
4524 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4525 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4526 NUMS=$($CMD | wc -l)
4527 [ $NUMS -eq $EXPECTED ] ||
4528 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4531 run_test 56u "check lfs find -stripe-index works"
4538 setup_56 $NUMFILES $NUMDIRS
4540 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4541 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4543 for file in $($LFIND -mdt $UUID $TDIR); do
4544 file_mdt_idx=$($GETSTRIPE -M $file)
4545 [ $file_mdt_idx -eq $MDT_IDX ] ||
4546 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4549 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4551 # Get and check the actual stripe count of one file.
4552 # Usage: check_stripe_count <file> <expected_stripe_count>
4553 check_stripe_count() {
4558 [[ -z "$file" || -z "$expected" ]] &&
4559 error "check_stripe_count: invalid argument!"
4561 local cmd="$GETSTRIPE -c $file"
4562 actual=$($cmd) || error "$cmd failed"
4563 actual=${actual%% *}
4565 if [[ $actual -ne $expected ]]; then
4566 [[ $expected -eq -1 ]] ||
4567 error "$cmd wrong: found $actual, expected $expected"
4568 [[ $actual -eq $OSTCOUNT ]] ||
4569 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4577 rm -rf $TDIR || error "remove $TDIR failed"
4578 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4581 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4582 error "$GETSTRIPE -S -d $TDIR failed"
4583 stripe_size=${stripe_size%% *}
4585 local file_size=$((stripe_size * OSTCOUNT))
4586 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4587 local required_space=$((file_num * file_size))
4588 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4589 [[ $free_space -le $((required_space / 1024)) ]] &&
4590 skip_env "need at least $required_space bytes free space," \
4591 "have $free_space kbytes" && return
4594 local dd_count=$((file_size / dd_bs))
4596 # write data into the files
4600 for i in $(seq 1 $NUMFILES); do
4602 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4603 error "write data into $file failed"
4605 for i in $(seq 1 $NUMDIRS); do
4606 for j in $(seq 1 $NUMFILES); do
4607 file=$TDIR/dir$i/file$j
4608 yes | dd bs=$dd_bs count=$dd_count of=$file \
4610 error "write data into $file failed"
4615 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4618 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4620 eval $cmd || error "$cmd failed"
4622 check_stripe_count $TDIR/file1 $expected
4625 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4627 eval $cmd || error "$cmd failed"
4629 for j in $(seq 1 $NUMFILES); do
4630 check_stripe_count $TDIR/dir1/file$j $expected
4633 # lfs_migrate works with lfs find
4634 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4635 $LFS_MIGRATE -y -c $expected"
4637 eval $cmd || error "$cmd failed"
4639 for i in $(seq 2 $NUMFILES); do
4640 check_stripe_count $TDIR/file$i $expected
4642 for i in $(seq 2 $NUMDIRS); do
4643 for j in $(seq 1 $NUMFILES); do
4644 check_stripe_count $TDIR/dir$i/file$j $expected
4648 run_test 56w "check lfs_migrate -c stripe_count works"
4651 check_swap_layouts_support && return 0
4652 [ "$OSTCOUNT" -lt "2" ] &&
4653 skip_env "need 2 OST, skipping test" && return
4655 local dir0=$DIR/$tdir/$testnum
4656 mkdir -p $dir0 || error "creating dir $dir0"
4658 local ref1=/etc/passwd
4659 local file1=$dir0/file1
4661 $SETSTRIPE -c 2 $file1
4663 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4664 stripe=$($GETSTRIPE -c $file1)
4665 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4666 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4671 run_test 56x "lfs migration support"
4674 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4675 skip "No HSM support on MDS of $(get_lustre_version)," \
4676 "need 2.4.53 at least" && return
4679 local dir0=$DIR/$tdir/$testnum
4680 mkdir -p $dir0 || error "creating dir $dir0"
4681 local f1=$dir0/file1
4682 local f2=$dir0/file2
4684 touch $f1 || error "creating std file $f1"
4685 $MULTIOP $f2 H2c || error "creating released file $f2"
4687 # a directory can be raid0, so ask only for files
4688 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4689 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4691 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4692 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4694 # only files can be released, so no need to force file search
4695 res=$($LFIND $dir0 -L released)
4696 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4698 res=$($LFIND $dir0 \! -L released)
4699 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4702 run_test 56y "lfs find -L raid0|released"
4705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4706 # note test will not do anything if MDS is not local
4707 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4708 skip "Only applicable to ldiskfs-based MDTs"
4712 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4713 local MNTDEV="osd*.*MDT*.mntdev"
4714 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4715 [ -z "$DEV" ] && error "can't access $MNTDEV"
4716 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4717 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4718 error "can't access $DEV"
4719 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4720 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4724 run_test 57a "verify MDS filesystem created with large inodes =="
4727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4728 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4729 skip "Only applicable to ldiskfs-based MDTs"
4733 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4738 local FILEN=$dir/f$FILECOUNT
4740 rm -rf $dir || error "removing $dir"
4741 test_mkdir -p $dir || error "creating $dir"
4742 local num=$(get_mds_dir $dir)
4745 echo "mcreating $FILECOUNT files"
4746 createmany -m $dir/f 1 $FILECOUNT || \
4747 error "creating files in $dir"
4749 # verify that files do not have EAs yet
4750 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4751 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4755 df $dir #make sure we get new statfs data
4756 local MDSFREE=$(do_facet $mymds \
4757 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4758 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4759 echo "opening files to create objects/EAs"
4761 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4762 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4765 # verify that files have EAs now
4766 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4767 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4769 sleep 1 #make sure we get new statfs data
4771 local MDSFREE2=$(do_facet $mymds \
4772 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4773 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4774 if [ "$MDCFREE2" -lt "$((MDCFREE - 16))" ]; then
4775 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4776 error "MDC before $MDCFREE != after $MDCFREE2"
4778 echo "MDC before $MDCFREE != after $MDCFREE2"
4779 echo "unable to confirm if MDS has large inodes"
4784 run_test 57b "default LOV EAs are stored inside large inodes ==="
4787 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4788 [ -z "$(which wiretest 2>/dev/null)" ] &&
4789 skip_env "could not find wiretest" && return
4792 run_test 58 "verify cross-platform wire constants =============="
4795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4796 echo "touch 130 files"
4797 createmany -o $DIR/f59- 130
4799 unlinkmany $DIR/f59- 130
4801 # wait for commitment of removal
4802 wait_delete_completed
4804 run_test 59 "verify cancellation of llog records async ========="
4806 TEST60_HEAD="test_60 run $RANDOM"
4808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4809 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4810 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4811 skip_env "missing subtest run-llog.sh" && return
4812 log "$TEST60_HEAD - from kernel mode"
4813 do_facet mgs sh run-llog.sh
4815 run_test 60a "llog sanity tests run from kernel module =========="
4817 test_60b() { # bug 6411
4818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4820 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4832 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4834 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4837 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4838 echo "create 5000 files"
4839 createmany -o $DIR/f60c- 5000
4840 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4841 lctl set_param fail_loc=0x80000137
4842 unlinkmany $DIR/f60c- 5000
4843 lctl set_param fail_loc=0
4845 run_test 60c "unlink file when mds full"
4848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4849 SAVEPRINTK=$(lctl get_param -n printk)
4851 # verify "lctl mark" is even working"
4852 MESSAGE="test message ID $RANDOM $$"
4853 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4854 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4856 lctl set_param printk=0 || error "set lnet.printk failed"
4857 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4858 MESSAGE="new test message ID $RANDOM $$"
4859 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4860 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4861 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4863 lctl set_param -n printk="$SAVEPRINTK"
4865 run_test 60d "test printk console message masking"
4868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4870 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4871 cancel_lru_locks osc
4872 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4875 run_test 61 "mmap() writes don't make sync hang ================"
4877 # bug 2330 - insufficient obd_match error checking causes LBUG
4879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4882 cancel_lru_locks osc
4883 lctl set_param fail_loc=0x405
4884 cat $f && error "cat succeeded, expect -EIO"
4885 lctl set_param fail_loc=0
4887 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4888 # match every page all of the time.
4889 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4891 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4892 # Though this test is irrelevant anymore, it helped to reveal some
4893 # other grant bugs (LU-4482), let's keep it.
4894 test_63a() { # was test_63
4895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4896 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4897 for i in `seq 10` ; do
4898 dd if=/dev/zero of=$DIR/f63 bs=8k &
4904 rm -f $DIR/f63 || true
4906 run_test 63a "Verify oig_wait interruption does not crash ======="
4908 # bug 2248 - async write errors didn't return to application on sync
4909 # bug 3677 - async write errors left page locked
4911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4913 lctl set_param debug=-1
4915 # ensure we have a grant to do async writes
4916 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4919 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4920 lctl set_param fail_loc=0x80000406
4921 $MULTIOP $DIR/$tfile Owy && \
4922 error "sync didn't return ENOMEM"
4923 sync; sleep 2; sync # do a real sync this time to flush page
4924 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4925 error "locked page left in cache after async error" || true
4928 run_test 63b "async write errors should be returned to fsync ==="
4931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4933 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4935 run_test 64a "verify filter grant calculations (in kernel) ====="
4938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4939 sh oos.sh $MOUNT || error "oos.sh failed: $?"
4941 run_test 64b "check out-of-space detection on client ==========="
4944 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4946 run_test 64c "verify grant shrink ========================------"
4948 # bug 1414 - set/get directories' stripe info
4950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4951 test_mkdir -p $DIR/$tdir
4953 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4955 run_test 65a "directory with no stripe info ===================="
4958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4959 test_mkdir -p $DIR/$tdir
4960 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4963 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4965 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4969 if [ $OSTCOUNT -gt 1 ]; then
4970 test_mkdir -p $DIR/$tdir
4971 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4972 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4974 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4977 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4981 test_mkdir -p $DIR/$tdir
4982 if [ $STRIPECOUNT -le 0 ]; then
4984 elif [ $STRIPECOUNT -gt 2000 ]; then
4985 #LOV_MAX_STRIPE_COUNT is 2000
4986 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4988 sc=$(($STRIPECOUNT - 1))
4990 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4991 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4992 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4993 error "lverify failed"
4995 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4998 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4999 test_mkdir -p $DIR/$tdir
5001 $SETSTRIPE $DIR/$tdir || error "setstripe"
5002 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5003 error "no stripe info failed"
5005 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5007 run_test 65e "directory setstripe defaults ======================="
5010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5011 test_mkdir -p $DIR/${tdir}f
5012 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5014 run_test 65f "dir setstripe permission (should return error) ==="
5017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5018 test_mkdir -p $DIR/$tdir
5019 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5021 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5022 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5023 error "delete default stripe failed"
5025 run_test 65g "directory setstripe -d ==========================="
5028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5029 test_mkdir -p $DIR/$tdir
5030 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5032 test_mkdir -p $DIR/$tdir/dd1
5033 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5034 error "stripe info inherit failed"
5036 run_test 65h "directory stripe info inherit ===================="
5038 test_65i() { # bug6367
5039 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5040 $SETSTRIPE -S 65536 -c -1 $MOUNT
5042 run_test 65i "set non-default striping on root directory (bug 6367)="
5044 test_65ia() { # bug12836
5045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5046 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5048 run_test 65ia "getstripe on -1 default directory striping"
5050 test_65ib() { # bug12836
5051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5052 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5054 run_test 65ib "getstripe -v on -1 default directory striping"
5056 test_65ic() { # bug12836
5057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5058 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5060 run_test 65ic "new find on -1 default directory striping"
5062 test_65j() { # bug6367
5063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5065 # if we aren't already remounting for each test, do so for this test
5066 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5067 cleanup || error "failed to unmount"
5070 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5072 run_test 65j "set default striping on root directory (bug 6367)="
5074 test_65k() { # bug11679
5075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5076 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
5077 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5079 echo "Check OST status: "
5080 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5081 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5083 for OSC in $MDS_OSCS; do
5084 echo $OSC "is activate"
5085 do_facet $SINGLEMDS lctl --device %$OSC activate
5089 for INACTIVE_OSC in $MDS_OSCS; do
5090 echo "Deactivate: " $INACTIVE_OSC
5091 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5092 for STRIPE_OSC in $MDS_OSCS; do
5093 OST=`osc_to_ost $STRIPE_OSC`
5094 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5095 awk -F: /$OST/'{ print $1 }' | head -n 1`
5097 [ -f $DIR/$tdir/$IDX ] && continue
5098 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5099 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5101 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5104 echo $INACTIVE_OSC "is Activate."
5105 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5108 run_test 65k "validate manual striping works properly with deactivated OSCs"
5110 test_65l() { # bug 12836
5111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5112 test_mkdir -p $DIR/$tdir/test_dir
5113 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5114 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5116 run_test 65l "lfs find on -1 stripe dir ========================"
5118 # bug 2543 - update blocks count on client
5120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5122 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5123 sync; sync_all_data; sync; sync_all_data
5124 cancel_lru_locks osc
5125 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5126 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5128 run_test 66 "update inode blocks count on client ==============="
5133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5135 if [ ! -z "$LLOOP" ]; then
5136 if swapon -s | grep -q $LLOOP; then
5137 swapoff $LLOOP || error "swapoff failed"
5140 $LCTL blockdev_detach $LLOOP || error "detach failed"
5144 if [ ! -z "$LLITELOOPLOAD" ]; then
5152 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5156 swapon -s | awk '($1 == "'$1'") { print $4 }'
5159 # test case for lloop driver, basic function
5161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5162 [ "$UID" != 0 ] && skip_env "must run as root" && return
5163 llite_lloop_enabled || \
5164 { skip_env "llite_lloop module disabled" && return; }
5166 trap cleanup_68 EXIT
5168 if ! module_loaded llite_lloop; then
5169 if load_module llite/llite_lloop; then
5172 skip_env "can't find module llite_lloop"
5177 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5178 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5179 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5181 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5182 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5186 run_test 68a "lloop driver - basic test ========================"
5188 # excercise swapping to lustre by adding a high priority swapfile entry
5189 # and then consuming memory until it is used.
5190 test_68b() { # was test_68
5191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5192 [ "$UID" != 0 ] && skip_env "must run as root" && return
5193 lctl get_param -n devices | grep -q obdfilter && \
5194 skip "local OST" && return
5196 grep -q llite_lloop /proc/modules
5197 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5199 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5200 skip "can't reliably test swap with TCP" && return
5202 MEMTOTAL=`meminfo MemTotal`
5203 NR_BLOCKS=$((MEMTOTAL>>8))
5204 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5206 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5207 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5210 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5212 trap cleanup_68 EXIT
5214 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5216 echo "before: `swapon -s | grep $LLOOP`"
5217 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5218 echo "after: `swapon -s | grep $LLOOP`"
5219 SWAPUSED=`swap_used $LLOOP`
5223 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5225 run_test 68b "support swapping to Lustre ========================"
5227 # bug5265, obdfilter oa2dentry return -ENOENT
5228 # #define OBD_FAIL_OST_ENOENT 0x217
5230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5231 remote_ost_nodsh && skip "remote OST with nodsh" && return
5234 $SETSTRIPE -c 1 -i 0 $f
5236 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5238 do_facet ost1 lctl set_param fail_loc=0x217
5239 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5240 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5242 do_facet ost1 lctl set_param fail_loc=0
5243 $DIRECTIO write $f 0 2 || error "write error"
5245 cancel_lru_locks osc
5246 $DIRECTIO read $f 0 1 || error "read error"
5248 do_facet ost1 lctl set_param fail_loc=0x217
5249 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5251 do_facet ost1 lctl set_param fail_loc=0
5254 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5257 test_mkdir -p $DIR/$tdir
5258 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5260 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5262 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5264 [ "$RUNAS_ID" = "$UID" ] &&
5265 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5267 # Check that testing environment is properly set up. Skip if not
5268 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5269 skip_env "User $RUNAS_ID does not exist - skipping"
5272 # We had better clear the $DIR to get enough space for dd
5275 chmod 777 $DIR/$tfile
5276 chmod ug+s $DIR/$tfile
5277 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5278 error "$RUNAS dd $DIR/$tfile failed"
5279 # See if we are still setuid/sgid
5280 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5281 error "S/gid is not dropped on write"
5282 # Now test that MDS is updated too
5283 cancel_lru_locks mdc
5284 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5285 error "S/gid is not dropped on MDS"
5288 run_test 72a "Test that remove suid works properly (bug5695) ===="
5290 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5293 [ "$RUNAS_ID" = "$UID" ] && \
5294 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5295 [ "$RUNAS_ID" -eq 0 ] && \
5296 skip_env "RUNAS_ID = 0 -- skipping" && return
5298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5299 # Check that testing environment is properly set up. Skip if not
5300 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5301 skip_env "User $RUNAS_ID does not exist - skipping"
5304 touch $DIR/${tfile}-f{g,u}
5305 test_mkdir $DIR/${tfile}-dg
5306 test_mkdir $DIR/${tfile}-du
5307 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5308 chmod g+s $DIR/${tfile}-{f,d}g
5309 chmod u+s $DIR/${tfile}-{f,d}u
5310 for perm in 777 2777 4777; do
5311 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5312 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5313 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5314 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5318 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5320 # bug 3462 - multiple simultaneous MDC requests
5322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5323 test_mkdir $DIR/d73-1
5324 test_mkdir $DIR/d73-2
5325 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5328 lctl set_param fail_loc=0x80000129
5329 $MULTIOP $DIR/d73-1/f73-2 Oc &
5331 lctl set_param fail_loc=0
5333 $MULTIOP $DIR/d73-2/f73-3 Oc &
5337 wait $pid1 || return 1
5341 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5342 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5343 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5347 run_test 73 "multiple MDC requests (should not deadlock)"
5349 test_74a() { # bug 6149, 6184
5350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5351 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5353 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5354 # will spin in a tight reconnection loop
5356 lctl set_param fail_loc=0x8000030e
5357 # get any lock that won't be difficult - lookup works.
5359 lctl set_param fail_loc=0
5363 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5365 test_74b() { # bug 13310
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5369 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5370 # will spin in a tight reconnection loop
5371 lctl set_param fail_loc=0x8000030e
5372 # get a "difficult" lock
5374 lctl set_param fail_loc=0
5378 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5382 #define OBD_FAIL_LDLM_NEW_LOCK
5383 lctl set_param fail_loc=0x80000319
5384 touch $DIR/$tfile && error "Touch successful"
5387 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5390 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5393 get_inode_slab_tunables() {
5394 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5397 set_inode_slab_tunables() {
5398 echo "lustre_inode_cache $1" > /proc/slabinfo
5401 test_76() { # Now for bug 20433, added originally in bug 1443
5402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5403 local SLAB_SETTINGS=`get_inode_slab_tunables`
5404 local CPUS=`getconf _NPROCESSORS_ONLN`
5405 # we cannot set limit below 1 which means 1 inode in each
5406 # per-cpu cache is still allowed
5407 set_inode_slab_tunables "1 1 0"
5408 cancel_lru_locks osc
5409 BEFORE_INODES=`num_inodes`
5410 echo "before inodes: $BEFORE_INODES"
5412 [ "$SLOW" = "no" ] && COUNT=100
5413 for i in `seq $COUNT`; do
5417 cancel_lru_locks osc
5418 AFTER_INODES=`num_inodes`
5419 echo "after inodes: $AFTER_INODES"
5421 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5423 AFTER_INODES=`num_inodes`
5425 echo "wait $wait seconds inodes: $AFTER_INODES"
5426 if [ $wait -gt 30 ]; then
5427 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5430 set_inode_slab_tunables "$SLAB_SETTINGS"
5432 run_test 76 "confirm clients recycle inodes properly ===="
5438 # Note: in sptlrpc modes which enable its own bulk checksum, the
5439 # original crc32_le bulk checksum will be automatically disabled,
5440 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5441 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5442 # In this case set_checksums() will not be no-op, because sptlrpc
5443 # bulk checksum will be enabled all through the test.
5445 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5446 lctl set_param -n osc.*.checksums $1
5450 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5451 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5452 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5453 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5456 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5457 log "set checksum type to $1"
5460 F77_TMP=$TMP/f77-temp
5463 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5464 error "error writing to $F77_TMP"
5467 test_77a() { # bug 10889
5468 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5469 $GSS && skip "could not run with gss" && return
5470 [ ! -f $F77_TMP ] && setup_f77
5472 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5476 run_test 77a "normal checksum read/write operation"
5478 test_77b() { # bug 10889
5479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5480 $GSS && skip "could not run with gss" && return
5481 [ ! -f $F77_TMP ] && setup_f77
5482 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5483 $LCTL set_param fail_loc=0x80000409
5486 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5487 error "dd error: $?"
5488 $LCTL set_param fail_loc=0
5490 for algo in $CKSUM_TYPES; do
5491 cancel_lru_locks osc
5492 set_checksum_type $algo
5493 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5494 $LCTL set_param fail_loc=0x80000408
5495 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5496 $LCTL set_param fail_loc=0
5499 set_checksum_type $ORIG_CSUM_TYPE
5502 run_test 77b "checksum error on client write, read"
5504 test_77d() { # bug 10889
5505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5506 $GSS && skip "could not run with gss" && return
5507 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5508 $LCTL set_param fail_loc=0x80000409
5510 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5511 error "direct write: rc=$?"
5512 $LCTL set_param fail_loc=0
5515 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5516 $LCTL set_param fail_loc=0x80000408
5518 cancel_lru_locks osc
5519 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5520 error "direct read: rc=$?"
5521 $LCTL set_param fail_loc=0
5524 run_test 77d "checksum error on OST direct write, read"
5526 test_77f() { # bug 10889
5527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5528 $GSS && skip "could not run with gss" && return
5530 for algo in $CKSUM_TYPES; do
5531 cancel_lru_locks osc
5532 set_checksum_type $algo
5533 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5534 $LCTL set_param fail_loc=0x409
5535 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5536 error "direct write succeeded"
5537 $LCTL set_param fail_loc=0
5539 set_checksum_type $ORIG_CSUM_TYPE
5542 run_test 77f "repeat checksum error on write (expect error)"
5544 test_77g() { # bug 10889
5545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5546 $GSS && skip "could not run with gss" && return
5547 remote_ost_nodsh && skip "remote OST with nodsh" && return
5549 [ ! -f $F77_TMP ] && setup_f77
5551 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5552 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5553 do_facet ost1 lctl set_param fail_loc=0x8000021a
5555 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5556 error "write error: rc=$?"
5557 do_facet ost1 lctl set_param fail_loc=0
5560 cancel_lru_locks osc
5561 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5562 do_facet ost1 lctl set_param fail_loc=0x8000021b
5564 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5565 do_facet ost1 lctl set_param fail_loc=0
5568 run_test 77g "checksum error on OST write, read"
5570 test_77i() { # bug 13805
5571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5572 $GSS && skip "could not run with gss" && return
5573 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5574 lctl set_param fail_loc=0x40b
5575 remount_client $MOUNT
5576 lctl set_param fail_loc=0
5577 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5578 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5579 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5580 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5582 remount_client $MOUNT
5584 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5586 test_77j() { # bug 13805
5587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5588 $GSS && skip "could not run with gss" && return
5589 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5590 lctl set_param fail_loc=0x40c
5591 remount_client $MOUNT
5592 lctl set_param fail_loc=0
5593 sleep 2 # wait async osc connect to finish
5594 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5595 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5596 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5597 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5599 remount_client $MOUNT
5601 run_test 77j "client only supporting ADLER32"
5603 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5607 test_78() { # bug 10901
5608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5609 remote_ost || { skip_env "local OST" && return; }
5612 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5613 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5614 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5615 echo "MemTotal: $MEMTOTAL"
5616 # reserve 256MB of memory for the kernel and other running processes,
5617 # and then take 1/2 of the remaining memory for the read/write buffers.
5618 if [ $MEMTOTAL -gt 512 ] ;then
5619 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5621 # for those poor memory-starved high-end clusters...
5622 MEMTOTAL=$((MEMTOTAL / 2))
5624 echo "Mem to use for directio: $MEMTOTAL"
5625 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5626 [ $F78SIZE -gt 512 ] && F78SIZE=512
5627 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5628 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5629 echo "Smallest OST: $SMALLESTOST"
5630 [ $SMALLESTOST -lt 10240 ] && \
5631 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5633 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5634 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5636 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5637 echo "File size: $F78SIZE"
5638 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5639 for i in `seq 1 $NSEQ`
5641 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5642 echo directIO rdwr round $i of $NSEQ
5643 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5648 run_test 78 "handle large O_DIRECT writes correctly ============"
5650 test_79() { # bug 12743
5651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5652 wait_delete_completed
5654 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5655 BKFREE=$(calc_osc_kbytes kbytesfree)
5656 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5658 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5659 DFTOTAL=`echo $STRING | cut -d, -f1`
5660 DFUSED=`echo $STRING | cut -d, -f2`
5661 DFAVAIL=`echo $STRING | cut -d, -f3`
5662 DFFREE=$(($DFTOTAL - $DFUSED))
5664 ALLOWANCE=$((64 * $OSTCOUNT))
5666 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5667 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5668 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5670 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5671 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5672 error "df free($DFFREE) mismatch OST free($BKFREE)"
5674 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5675 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5676 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5679 run_test 79 "df report consistency check ======================="
5681 test_80() { # bug 10718
5682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5683 # relax strong synchronous semantics for slow backends like ZFS
5684 local soc="obdfilter.*.sync_on_lock_cancel"
5685 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5687 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5688 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5689 facet_active_host $host; done | sort -u)
5690 do_nodes $hosts lctl set_param $soc=never
5693 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5695 local BEFORE=`date +%s`
5696 cancel_lru_locks osc
5697 local AFTER=`date +%s`
5698 local DIFF=$((AFTER-BEFORE))
5699 if [ $DIFF -gt 1 ] ; then
5700 error "elapsed for 1M@1T = $DIFF"
5703 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5707 run_test 80 "Page eviction is equally fast at high offsets too ===="
5709 test_81a() { # LU-456
5710 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5711 remote_ost_nodsh && skip "remote OST with nodsh" && return
5712 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5713 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5714 do_facet ost1 lctl set_param fail_loc=0x80000228
5716 # write should trigger a retry and success
5717 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5718 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5720 if [ $RC -ne 0 ] ; then
5721 error "write should success, but failed for $RC"
5724 run_test 81a "OST should retry write when get -ENOSPC ==============="
5726 test_81b() { # LU-456
5727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5728 remote_ost_nodsh && skip "remote OST with nodsh" && return
5729 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5730 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5731 do_facet ost1 lctl set_param fail_loc=0x228
5733 # write should retry several times and return -ENOSPC finally
5734 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5735 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5738 if [ $RC -ne $ENOSPC ] ; then
5739 error "dd should fail for -ENOSPC, but succeed."
5742 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5744 test_82() { # LU-1031
5745 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5749 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5751 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5753 kill -USR1 $MULTIPID2
5755 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5756 error "First grouplock does not block second one"
5758 echo "Second grouplock blocks first one"
5760 kill -USR1 $MULTIPID1
5764 run_test 82 "Basic grouplock test ==============================="
5767 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5769 test_mkdir -p $DIR/d99cvsroot
5770 chown $RUNAS_ID $DIR/d99cvsroot
5771 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5774 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5777 run_test 99a "cvs init ========================================="
5780 [ -z "$(which cvs 2>/dev/null)" ] &&
5781 skip_env "could not find cvs" && return
5782 [ ! -d $DIR/d99cvsroot ] && test_99a
5784 # some versions of cvs import exit(1) when asked to import links or
5785 # files they can't read. ignore those files.
5786 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5787 ! -perm +4 -printf '-I %f\n')
5788 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5789 d99reposname vtag rtag
5791 run_test 99b "cvs import ======================================="
5794 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5795 [ ! -d $DIR/d99cvsroot ] && test_99b
5797 test_mkdir -p $DIR/d99reposname
5798 chown $RUNAS_ID $DIR/d99reposname
5799 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5801 run_test 99c "cvs checkout ====================================="
5804 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5805 [ ! -d $DIR/d99cvsroot ] && test_99c
5806 cd $DIR/d99reposname
5808 $RUNAS cvs add -m 'addmsg' foo99
5810 run_test 99d "cvs add =========================================="
5813 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5814 [ ! -d $DIR/d99cvsroot ] && test_99c
5815 cd $DIR/d99reposname
5818 run_test 99e "cvs update ======================================="
5821 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5822 [ ! -d $DIR/d99cvsroot ] && test_99d
5823 cd $DIR/d99reposname
5824 $RUNAS cvs commit -m 'nomsg' foo99
5825 rm -fr $DIR/d99cvsroot
5827 run_test 99f "cvs commit ======================================="
5830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5831 [ "$NETTYPE" = tcp ] || \
5832 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5835 remote_ost_nodsh && skip "remote OST with nodsh" && return
5836 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5838 { skip "useless for local single node setup" && return; }
5840 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5841 [ "$PROT" != "tcp" ] && continue
5842 RPORT=$(echo $REMOTE | cut -d: -f2)
5843 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5846 LPORT=`echo $LOCAL | cut -d: -f2`
5847 if [ $LPORT -ge 1024 ]; then
5848 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5850 error_exit "local: $LPORT > 1024, remote: $RPORT"
5853 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5855 run_test 100 "check local port using privileged port ==========="
5857 function get_named_value()
5866 echo $line | sed "s/^$tag[ ]*//"
5873 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5874 awk '/^max_cached_mb/ { print $2 }')
5877 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5883 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5887 local cache_limit=32
5889 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5890 trap cleanup_101a EXIT
5891 $LCTL set_param -n llite.*.read_ahead_stats 0
5892 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5895 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5897 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5898 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5901 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5902 get_named_value 'read but discarded' | cut -d" " -f1`; do
5903 discard=$(($discard + $s))
5907 if [ $(($discard * 10)) -gt $nreads ] ;then
5908 $LCTL get_param osc.*-osc*.rpc_stats
5909 $LCTL get_param llite.*.read_ahead_stats
5910 error "too many ($discard) discarded pages"
5912 rm -f $DIR/$tfile || true
5914 run_test 101a "check read-ahead for random reads ================"
5917 test_mkdir -p $DIR/$tdir
5919 STRIPE_COUNT=$OSTCOUNT
5922 local list=$(comma_list $(osts_nodes))
5923 set_osd_param $list '' read_cache_enable 0
5924 set_osd_param $list '' writethrough_cache_enable 0
5926 trap cleanup_test101bc EXIT
5927 # prepare the read-ahead file
5928 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5930 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5933 cleanup_test101bc() {
5938 local list=$(comma_list $(osts_nodes))
5939 set_osd_param $list '' read_cache_enable 1
5940 set_osd_param $list '' writethrough_cache_enable 1
5944 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5949 local STRIPE_SIZE=1048576
5950 local RA_INC=1048576
5951 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5952 local FILE_LENGTH=$((64*100))
5953 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5954 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5955 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5956 get_named_value 'read but discarded' | \
5957 cut -d" " -f1 | calc_total`
5958 if [ $DISCARD -gt $discard_limit ]; then
5959 $LCTL get_param llite.*.read_ahead_stats
5960 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5962 echo "Read-ahead success for size ${READ_SIZE}"
5967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5968 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5969 local STRIPE_SIZE=1048576
5970 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5971 local FILE_LENGTH=$((STRIPE_SIZE*100))
5972 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5973 # prepare the read-ahead file
5975 cancel_lru_locks osc
5976 for BIDX in 2 4 8 16 32 64 128 256
5978 local BSIZE=$((BIDX*4096))
5979 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5980 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5981 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5982 $LCTL set_param -n llite.*.read_ahead_stats 0
5983 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5984 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5985 cancel_lru_locks osc
5991 run_test 101b "check stride-io mode read-ahead ================="
5994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5995 local STRIPE_SIZE=1048576
5996 local FILE_LENGTH=$((STRIPE_SIZE*100))
6002 cancel_lru_locks osc
6003 $LCTL set_param osc.*.rpc_stats 0
6004 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6005 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6006 local stats=$($LCTL get_param -n $osc_rpc_stats)
6007 local lines=$(echo "$stats" | awk 'END {print NR;}')
6010 if [ $lines -le 20 ]; then
6013 for size in 1 2 4 8; do
6014 local rpc=$(echo "$stats" |
6015 awk '($1 == "'$size':") {print $2; exit; }')
6017 error "Small $((size*4))k read IO $rpc !"
6019 echo "$osc_rpc_stats check passed!"
6024 run_test 101c "check stripe_size aligned read-ahead ================="
6027 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6028 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6033 local file=$DIR/$tfile
6034 local sz_MB=${FILESIZE_101d:-500}
6035 local ra_MB=${READAHEAD_MB:-40}
6037 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6038 [ $free_MB -lt $sz_MB ] &&
6039 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6041 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6042 $SETSTRIPE -c -1 $file || error "setstripe failed"
6044 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6045 echo Cancel LRU locks on lustre client to flush the client cache
6046 cancel_lru_locks osc
6048 echo Disable read-ahead
6049 local old_READAHEAD=$(set_read_ahead 0)
6051 echo Reading the test file $file with read-ahead disabled
6052 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6054 echo Cancel LRU locks on lustre client to flush the client cache
6055 cancel_lru_locks osc
6056 echo Enable read-ahead with ${ra_MB}MB
6057 set_read_ahead $ra_MB
6059 echo Reading the test file $file with read-ahead enabled
6060 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6062 echo "read-ahead disabled time read $raOFF"
6063 echo "read-ahead enabled time read $raON"
6065 set_read_ahead $old_READAHEAD
6067 wait_delete_completed
6069 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6070 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6072 run_test 101d "file read with and without read-ahead enabled"
6075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6076 local file=$DIR/$tfile
6077 local size_KB=500 #KB
6081 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6082 local need_KB=$((count * size_KB))
6083 [ $free_KB -le $need_KB ] &&
6084 skip_env "Need free space $need_KB, have $free_KB" && return
6086 echo "Creating $count ${size_KB}K test files"
6087 for ((i = 0; i < $count; i++)); do
6088 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6091 echo "Cancel LRU locks on lustre client to flush the client cache"
6092 cancel_lru_locks osc
6094 echo "Reset readahead stats"
6095 $LCTL set_param -n llite.*.read_ahead_stats 0
6097 for ((i = 0; i < $count; i++)); do
6098 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6101 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6102 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6104 for ((i = 0; i < $count; i++)); do
6105 rm -rf $file.$i 2>/dev/null
6108 #10000 means 20% reads are missing in readahead
6109 [ $miss -lt 10000 ] || error "misses too much for small reads"
6111 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6113 cleanup_test101f() {
6115 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6116 rm -rf $DIR/$tfile 2>/dev/null
6120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6121 local file=$DIR/$tfile
6124 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6125 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6126 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6127 trap cleanup_test101f EXIT
6129 echo Cancel LRU locks on lustre client to flush the client cache
6130 cancel_lru_locks osc
6132 echo Reset readahead stats
6133 $LCTL set_param -n llite.*.read_ahead_stats 0
6134 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6135 # readahead should read in 2M file on second read, so only miss
6137 echo Random 4K reads on 2M file for 1000 times
6138 $READS -f $file -s 2097152 -b 4096 -n $nreads
6140 echo checking missing pages
6141 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6142 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6144 [ $miss -lt 3 ] || error "misses too much pages!"
6147 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6150 test_mkdir -p $DIR/$tdir
6151 chown $RUNAS_ID $DIR/$tdir
6154 STRIPE_COUNT=$OSTCOUNT
6155 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
6157 trap cleanup_test102 EXIT
6159 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6161 for num in 1 2 3 4; do
6162 for count in $(seq 1 $STRIPE_COUNT); do
6163 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6164 local size=`expr $STRIPE_SIZE \* $num`
6165 local file=file"$num-$idx-$count"
6166 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6172 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6178 rm -rf $DIR/d0.sanity/d102
6182 local testfile=$DIR/xattr_testfile
6186 [ "$UID" != 0 ] && skip_env "must run as root" && return
6187 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6188 skip_env "must have user_xattr" && return
6190 [ -z "$(which setfattr 2>/dev/null)" ] &&
6191 skip_env "could not find setfattr" && return
6193 echo "set/get xattr..."
6194 setfattr -n trusted.name1 -v value1 $testfile ||
6195 error "setfattr -n trusted.name1=value1 $testfile failed"
6196 getfattr -n trusted.name1 $testfile 2> /dev/null |
6197 grep "trusted.name1=.value1" ||
6198 error "$testfile missing trusted.name1=value1"
6200 setfattr -n user.author1 -v author1 $testfile ||
6201 error "setfattr -n user.author1=author1 $testfile failed"
6202 getfattr -n user.author1 $testfile 2> /dev/null |
6203 grep "user.author1=.author1" ||
6204 error "$testfile missing trusted.author1=author1"
6207 setfattr -n trusted.name2 -v value2 $testfile ||
6208 error "$testfile unable to set trusted.name2"
6209 setfattr -n trusted.name3 -v value3 $testfile ||
6210 error "$testfile unable to set trusted.name3"
6211 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6212 grep "trusted.name" | wc -l) -eq 3 ] ||
6213 error "$testfile missing 3 trusted.name xattrs"
6215 setfattr -n user.author2 -v author2 $testfile ||
6216 error "$testfile unable to set user.author2"
6217 setfattr -n user.author3 -v author3 $testfile ||
6218 error "$testfile unable to set user.author3"
6219 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6220 grep "user.author" | wc -l) -eq 3 ] ||
6221 error "$testfile missing 3 user.author xattrs"
6223 echo "remove xattr..."
6224 setfattr -x trusted.name1 $testfile ||
6225 error "$testfile error deleting trusted.name1"
6226 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6227 error "$testfile did not delete trusted.name1 xattr"
6229 setfattr -x user.author1 $testfile ||
6230 error "$testfile error deleting user.author1"
6231 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6232 error "$testfile did not delete trusted.name1 xattr"
6234 # b10667: setting lustre special xattr be silently discarded
6235 echo "set lustre special xattr ..."
6236 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6237 error "$testfile allowed setting trusted.lov"
6239 run_test 102a "user xattr test =================================="
6242 # b10930: get/set/list trusted.lov xattr
6243 echo "get/set/list trusted.lov xattr ..."
6244 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6245 local testfile=$DIR/$tfile
6246 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6247 error "setstripe failed"
6248 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6249 error "getstripe failed"
6250 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6251 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6253 local testfile2=${testfile}2
6254 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6255 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6258 setfattr -n trusted.lov -v $value $testfile2
6259 local stripe_size=$($GETSTRIPE -S $testfile2)
6260 local stripe_count=$($GETSTRIPE -c $testfile2)
6261 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6262 [ $stripe_count -eq $STRIPECOUNT ] ||
6263 error "stripe count $stripe_count != $STRIPECOUNT"
6266 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6269 # b10930: get/set/list lustre.lov xattr
6270 echo "get/set/list lustre.lov xattr ..."
6271 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6272 test_mkdir -p $DIR/$tdir
6273 chown $RUNAS_ID $DIR/$tdir
6274 local testfile=$DIR/$tdir/$tfile
6275 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6276 error "setstripe failed"
6277 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6278 error "getstripe failed"
6279 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6280 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6282 local testfile2=${testfile}2
6283 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6284 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6286 $RUNAS $MCREATE $testfile2
6287 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6288 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6289 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6290 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6291 [ $stripe_count -eq $STRIPECOUNT ] ||
6292 error "stripe count $stripe_count != $STRIPECOUNT"
6294 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6296 compare_stripe_info1() {
6297 local stripe_index_all_zero=true
6299 for num in 1 2 3 4; do
6300 for count in $(seq 1 $STRIPE_COUNT); do
6301 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6302 local size=$((STRIPE_SIZE * num))
6303 local file=file"$num-$offset-$count"
6304 stripe_size=$(lfs getstripe -S $PWD/$file)
6305 [ $stripe_size -ne $size ] &&
6306 error "$file: size $stripe_size != $size"
6307 stripe_count=$(lfs getstripe -c $PWD/$file)
6308 # allow fewer stripes to be created, ORI-601
6309 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6310 error "$file: count $stripe_count != $count"
6311 stripe_index=$(lfs getstripe -i $PWD/$file)
6312 [ $stripe_index -ne 0 ] &&
6313 stripe_index_all_zero=false
6317 $stripe_index_all_zero &&
6318 error "all files are being extracted starting from OST index 0"
6323 [ -n "$(which tar 2>/dev/null)" ] &&
6324 strings $(which tar) | grep -q "lustre" && echo tar
6328 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6329 # b10930: tar test for trusted.lov xattr
6330 TAR=$(find_lustre_tar)
6331 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6332 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6334 test_mkdir -p $DIR/d102d
6335 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6337 compare_stripe_info1
6339 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6343 # b10930: tar test for trusted.lov xattr
6344 TAR=$(find_lustre_tar)
6345 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6346 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6348 test_mkdir -p $DIR/d102f
6350 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6352 compare_stripe_info1
6354 run_test 102f "tar copy files, not keep osts ==========="
6357 local xsize=${1:-1024} # in bytes
6358 local file=$DIR/$tfile
6360 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6361 skip "must have user_xattr" && return 0
6362 [ -z "$(which setfattr 2>/dev/null)" ] &&
6363 skip_env "could not find setfattr" && return 0
6364 [ -z "$(which getfattr 2>/dev/null)" ] &&
6365 skip_env "could not find getfattr" && return 0
6369 local value="$(generate_string $xsize)"
6371 local xbig=trusted.big
6372 log "save $xbig on $file"
6373 setfattr -n $xbig -v $value $file ||
6374 error "saving $xbig on $file failed"
6376 local orig=$(get_xattr_value $xbig $file)
6377 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6379 local xsml=trusted.sml
6380 log "save $xsml on $file"
6381 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6383 local new=$(get_xattr_value $xbig $file)
6384 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6386 log "grow $xsml on $file"
6387 setfattr -n $xsml -v "$value" $file ||
6388 error "growing $xsml on $file failed"
6390 new=$(get_xattr_value $xbig $file)
6391 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6392 log "$xbig still valid after growing $xsml"
6397 test_102h() { # bug 15777
6400 run_test 102h "grow xattr from inside inode to external block"
6403 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6404 grow_xattr $(max_xattr_size)
6406 run_test 102ha "grow xattr from inside inode to external inode"
6408 test_102i() { # bug 17038
6410 ln -s $DIR/$tfile $DIR/${tfile}link
6411 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6412 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 | grep -i "no such attr" || error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6413 rm -f $DIR/$tfile $DIR/${tfile}link
6415 run_test 102i "lgetxattr test on symbolic link ============"
6418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6419 TAR=$(find_lustre_tar)
6420 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6421 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6422 setup_test102 "$RUNAS"
6423 test_mkdir -p $DIR/d102j
6424 chown $RUNAS_ID $DIR/d102j
6425 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6427 compare_stripe_info1 "$RUNAS"
6429 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6433 # b22187 just check that does not crash for regular file.
6434 setfattr -n trusted.lov $DIR/$tfile
6435 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6436 local test_kdir=$DIR/d102k
6437 test_mkdir $test_kdir
6438 local default_size=`$GETSTRIPE -S $test_kdir`
6439 local default_count=`$GETSTRIPE -c $test_kdir`
6440 local default_offset=`$GETSTRIPE -i $test_kdir`
6441 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6442 error 'dir setstripe failed'
6443 setfattr -n trusted.lov $test_kdir
6444 local stripe_size=`$GETSTRIPE -S $test_kdir`
6445 local stripe_count=`$GETSTRIPE -c $test_kdir`
6446 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6447 [ $stripe_size -eq $default_size ] ||
6448 error "stripe size $stripe_size != $default_size"
6449 [ $stripe_count -eq $default_count ] ||
6450 error "stripe count $stripe_count != $default_count"
6451 [ $stripe_offset -eq $default_offset ] ||
6452 error "stripe offset $stripe_offset != $default_offset"
6453 rm -rf $DIR/$tfile $test_kdir
6455 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6458 # LU-532 trusted. xattr is invisible to non-root
6459 local testfile=$DIR/$tfile
6463 echo "listxattr as user..."
6464 chown $RUNAS_ID $testfile
6465 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6466 grep -q "trusted" &&
6467 error "$testfile trusted xattrs are user visible"
6471 run_test 102l "listxattr size test =================================="
6473 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6474 local path=$DIR/$tfile
6477 listxattr_size_check $path || error "listattr_size_check $path failed"
6479 run_test 102m "Ensure listxattr fails on small bufffer ========"
6483 getxattr() { # getxattr path name
6484 # Return the base64 encoding of the value of xattr name on path.
6488 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6490 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6492 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6494 getfattr --absolute-names --encoding=base64 --name=$name $path |
6495 awk -F= -v name=$name '$1 == name {
6496 print substr($0, index($0, "=") + 1);
6500 test_102n() { # LU-4101 mdt: protect internal xattrs
6501 local file0=$DIR/$tfile.0
6502 local file1=$DIR/$tfile.1
6503 local xattr0=$TMP/$tfile.0
6504 local xattr1=$TMP/$tfile.1
6508 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6510 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6514 rm -rf $file0 $file1 $xattr0 $xattr1
6517 # Get 'before' xattrs of $file1.
6518 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6520 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6521 # Try to copy xattr from $file0 to $file1.
6522 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6524 setfattr --name=trusted.$name --value="$value" $file1 ||
6525 error "setxattr 'trusted.$name' failed"
6527 # Try to set a garbage xattr.
6528 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6530 setfattr --name=trusted.$name --value="$value" $file1 ||
6531 error "setxattr 'trusted.$name' failed"
6533 # Try to remove the xattr from $file1. We don't care if this
6534 # appears to succeed or fail, we just don't want there to be
6535 # any changes or crashes.
6536 setfattr --remove=$trusted.$name $file1 2> /dev/null
6539 # Get 'after' xattrs of file1.
6540 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6542 if ! diff $xattr0 $xattr1; then
6543 error "before and after xattrs of '$file1' differ"
6546 rm -rf $file0 $file1 $xattr0 $xattr1
6550 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6552 test_102p() { # LU-4703 setxattr did not check ownership
6553 local testfile=$DIR/$tfile
6555 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6556 skip "MDS needs to be at least 2.5.56" && return
6560 echo "setfacl as user..."
6561 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6562 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6564 echo "setfattr as user..."
6565 setfacl -m "u:$RUNAS_ID:---" $testfile
6566 $RUNAS setfattr -x system.posix_acl_access $testfile
6567 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6569 run_test 102p "check setxattr(2) correctly fails without permission"
6573 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6578 [ "$UID" != 0 ] && skip_env "must run as root" && return
6579 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6580 skip "must have acl enabled" && return
6581 [ -z "$(which setfacl 2>/dev/null)" ] &&
6582 skip_env "could not find setfacl" && return
6583 $GSS && skip "could not run under gss" && return
6585 declare -a identity_old
6587 for num in $(seq $MDSCOUNT); do
6588 switch_identity $num true || identity_old[$num]=$?
6595 echo "performing cp ..."
6596 run_acl_subtest cp || error "run_acl_subtest cp failed"
6597 echo "performing getfacl-noacl..."
6598 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6599 echo "performing misc..."
6600 run_acl_subtest misc || error "misc test failed"
6601 echo "performing permissions..."
6602 run_acl_subtest permissions || error "permissions failed"
6603 echo "performing setfacl..."
6604 run_acl_subtest setfacl || error "setfacl test failed"
6606 # inheritance test got from HP
6607 echo "performing inheritance..."
6608 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6609 chmod +x make-tree || error "chmod +x failed"
6610 run_acl_subtest inheritance || error "inheritance test failed"
6613 echo "LU-974 ignore umask when acl is enabled..."
6614 run_acl_subtest 974 || error "LU-974 umask test failed"
6615 if [ $MDSCOUNT -ge 2 ]; then
6616 run_acl_subtest 974_remote ||
6617 error "LU-974 umask test failed under remote dir"
6620 echo "LU-2561 newly created file is same size as directory..."
6621 run_acl_subtest 2561 || error "LU-2561 test failed"
6626 for num in $(seq $MDSCOUNT); do
6627 if [ "${identity_old[$num]}" = 1 ]; then
6628 switch_identity $num false || identity_old[$num]=$?
6632 run_test 103 "acl test ========================================="
6635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6637 lfs df || error "lfs df failed"
6638 lfs df -ih || error "lfs df -ih failed"
6639 lfs df -h $DIR || error "lfs df -h $DIR failed"
6640 lfs df -i $DIR || error "lfs df -i $DIR failed"
6641 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6642 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6644 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6645 lctl --device %$OSC deactivate
6646 lfs df || error "lfs df with deactivated OSC failed"
6647 lctl --device %$OSC activate
6648 # wait the osc back to normal
6649 wait_osc_import_state client ost FULL
6651 lfs df || error "lfs df with reactivated OSC failed"
6654 run_test 104a "lfs df [-ih] [path] test ========================="
6657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6658 [ $RUNAS_ID -eq $UID ] &&
6659 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6661 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6662 grep "Permission denied" | wc -l)))
6663 if [ $denied_cnt -ne 0 ]; then
6664 error "lfs check servers test failed"
6667 run_test 104b "$RUNAS lfs check servers test ===================="
6670 # doesn't work on 2.4 kernels
6672 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6673 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6675 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6679 run_test 105a "flock when mounted without -o flock test ========"
6683 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6684 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6686 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6690 run_test 105b "fcntl when mounted without -o flock test ========"
6694 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6695 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6697 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6701 run_test 105c "lockf when mounted without -o flock test ========"
6703 test_105d() { # bug 15924
6704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6705 test_mkdir -p $DIR/$tdir
6706 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6707 skip "mount w/o flock enabled" && return
6708 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6709 $LCTL set_param fail_loc=0x80000315
6710 flocks_test 2 $DIR/$tdir
6712 run_test 105d "flock race (should not freeze) ========"
6714 test_105e() { # bug 22660 && 22040
6715 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6716 skip "mount w/o flock enabled" && return
6718 flocks_test 3 $DIR/$tfile
6720 run_test 105e "Two conflicting flocks from same process ======="
6722 test_106() { #bug 10921
6723 test_mkdir -p $DIR/$tdir
6724 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6725 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6727 run_test 106 "attempt exec of dir followed by chown of that dir"
6730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6737 local save_pattern=$(sysctl -n kernel.core_pattern)
6738 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6739 sysctl -w kernel.core_pattern=$file
6740 sysctl -w kernel.core_uses_pid=0
6748 kill -s 11 $SLEEPPID
6750 if [ -e $file ]; then
6751 size=`stat -c%s $file`
6752 [ $size -eq 0 ] && error "Fail to create core file $file"
6754 error "Fail to create core file $file"
6757 sysctl -w kernel.core_pattern=$save_pattern
6758 sysctl -w kernel.core_uses_pid=$save_uses_pid
6761 run_test 107 "Coredump on SIG"
6764 test_mkdir -p $DIR/$tdir
6765 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6766 error "mkdir with 255 char failed"
6767 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6768 error "mkdir with 256 char should fail, but did not"
6769 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6770 error "create with 255 char failed"
6771 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6772 error "create with 256 char should fail, but did not"
6777 run_test 110 "filename length checking"
6780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6781 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6783 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6785 echo "Starting with $OSTIO_pre threads"
6788 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6789 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6790 echo "$NUMTEST creates/unlinks"
6791 test_mkdir -p $DIR/$tdir
6792 createmany -o $DIR/$tdir/$tfile $NUMTEST
6793 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6795 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6798 # don't return an error
6799 [ $OSTIO_post == $OSTIO_pre ] && echo \
6800 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6801 echo "This may be fine, depending on what ran before this test" &&
6802 echo "and how fast this system is." && return
6804 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6806 run_test 115 "verify dynamic thread creation===================="
6809 wait_delete_completed
6810 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6811 echo OST kbytes available: ${AVAIL[@]}
6812 MAXI=0; MAXV=${AVAIL[0]}
6813 MINI=0; MINV=${AVAIL[0]}
6814 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6815 #echo OST $i: ${AVAIL[i]}kb
6816 if [ ${AVAIL[i]} -gt $MAXV ]; then
6817 MAXV=${AVAIL[i]}; MAXI=$i
6819 if [ ${AVAIL[i]} -lt $MINV ]; then
6820 MINV=${AVAIL[i]}; MINI=$i
6823 echo Min free space: OST $MINI: $MINV
6824 echo Max free space: OST $MAXI: $MAXV
6827 test_116a() { # was previously test_116()
6828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6829 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6831 echo -n "Free space priority "
6832 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6837 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6838 trap simple_cleanup_common EXIT
6840 # Check if we need to generate uneven OSTs
6841 test_mkdir -p $DIR/$tdir/OST${MINI}
6842 local FILL=$(($MINV / 4))
6843 local DIFF=$(($MAXV - $MINV))
6844 local DIFF2=$(($DIFF * 100 / $MINV))
6846 local threshold=$(do_facet $SINGLEMDS \
6847 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -1)
6848 threshold=${threshold%%%}
6849 echo -n "Check for uneven OSTs: "
6850 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6852 if [ $DIFF2 -gt $threshold ]; then
6854 echo "Don't need to fill OST$MINI"
6856 # generate uneven OSTs. Write 2% over the QOS threshold value
6858 DIFF=$(($threshold - $DIFF2 + 2))
6859 DIFF2=$(( ($MINV * $DIFF)/100 ))
6860 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6861 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6862 error "setstripe failed"
6863 DIFF=$(($DIFF2 / 2048))
6865 while [ $i -lt $DIFF ]; do
6867 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6868 bs=2M count=1 2>/dev/null
6877 DIFF=$(($MAXV - $MINV))
6878 DIFF2=$(($DIFF * 100 / $MINV))
6879 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6880 if [ $DIFF2 -gt $threshold ]; then
6883 echo "failed - QOS mode won't be used"
6884 skip "QOS imbalance criteria not met"
6885 simple_cleanup_common
6889 MINI1=$MINI; MINV1=$MINV
6890 MAXI1=$MAXI; MAXV1=$MAXV
6892 # now fill using QOS
6893 $SETSTRIPE -c 1 $DIR/$tdir
6894 FILL=$(($FILL / 200))
6895 if [ $FILL -gt 600 ]; then
6898 echo "writing $FILL files to QOS-assigned OSTs"
6900 while [ $i -lt $FILL ]; do
6902 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
6906 echo "wrote $i 200k files"
6910 echo "Note: free space may not be updated, so measurements might be off"
6912 DIFF2=$(($MAXV - $MINV))
6913 echo "free space delta: orig $DIFF final $DIFF2"
6914 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6915 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6916 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
6917 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6918 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
6919 FILL=$(($DIFF2 * 100 / $DIFF - 100))
6921 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
6923 # Figure out which files were written where
6924 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6925 awk '/'$MINI1': / {print $2; exit}')
6927 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6928 echo "$MINC files created on smaller OST $MINI1"
6929 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6930 awk '/'$MAXI1': / {print $2; exit}')
6932 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6933 echo "$MAXC files created on larger OST $MAXI1"
6934 FILL=$(($MAXC * 100 / $MINC - 100))
6936 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
6937 [ $MAXC -gt $MINC ] ||
6938 error_ignore LU-9 "stripe QOS didn't balance free space"
6939 simple_cleanup_common
6941 run_test 116a "stripe QOS: free space balance ==================="
6943 test_116b() { # LU-2093
6944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6945 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6947 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6948 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6950 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6951 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6952 do_facet $SINGLEMDS lctl set_param fail_loc=0
6954 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6956 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6958 test_117() # bug 10891
6960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6961 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6962 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6963 lctl set_param fail_loc=0x21e
6964 > $DIR/$tfile || error "truncate failed"
6965 lctl set_param fail_loc=0
6966 echo "Truncate succeeded."
6969 run_test 117 "verify osd extend =========="
6971 NO_SLOW_RESENDCOUNT=4
6972 export OLD_RESENDCOUNT=""
6973 set_resend_count () {
6974 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6975 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6976 lctl set_param -n $PROC_RESENDCOUNT $1
6977 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6980 # for reduce test_118* time (b=14842)
6981 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6983 # Reset async IO behavior after error case
6985 FILE=$DIR/reset_async
6987 # Ensure all OSCs are cleared
6988 $SETSTRIPE -c -1 $FILE
6989 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6994 test_118a() #bug 11710
6996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6999 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7000 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7001 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7003 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7004 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7009 run_test 118a "verify O_SYNC works =========="
7013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7014 remote_ost_nodsh && skip "remote OST with nodsh" && return
7018 #define OBD_FAIL_OST_ENOENT 0x217
7019 set_nodes_failloc "$(osts_nodes)" 0x217
7020 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7022 set_nodes_failloc "$(osts_nodes)" 0
7023 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7024 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7027 if [[ $RC -eq 0 ]]; then
7028 error "Must return error due to dropped pages, rc=$RC"
7032 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7033 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7037 echo "Dirty pages not leaked on ENOENT"
7039 # Due to the above error the OSC will issue all RPCs syncronously
7040 # until a subsequent RPC completes successfully without error.
7041 $MULTIOP $DIR/$tfile Ow4096yc
7046 run_test 118b "Reclaim dirty pages on fatal error =========="
7050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7052 # for 118c, restore the original resend count, LU-1940
7053 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7054 set_resend_count $OLD_RESENDCOUNT
7055 remote_ost_nodsh && skip "remote OST with nodsh" && return
7059 #define OBD_FAIL_OST_EROFS 0x216
7060 set_nodes_failloc "$(osts_nodes)" 0x216
7062 # multiop should block due to fsync until pages are written
7063 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7067 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7068 error "Multiop failed to block on fsync, pid=$MULTIPID"
7071 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7073 if [[ $WRITEBACK -eq 0 ]]; then
7074 error "No page in writeback, writeback=$WRITEBACK"
7077 set_nodes_failloc "$(osts_nodes)" 0
7080 if [[ $RC -ne 0 ]]; then
7081 error "Multiop fsync failed, rc=$RC"
7084 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7085 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7087 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7088 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7092 echo "Dirty pages flushed via fsync on EROFS"
7095 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7097 # continue to use small resend count to reduce test_118* time (b=14842)
7098 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7103 remote_ost_nodsh && skip "remote OST with nodsh" && return
7107 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7108 set_nodes_failloc "$(osts_nodes)" 0x214
7109 # multiop should block due to fsync until pages are written
7110 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7114 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7115 error "Multiop failed to block on fsync, pid=$MULTIPID"
7118 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7120 if [[ $WRITEBACK -eq 0 ]]; then
7121 error "No page in writeback, writeback=$WRITEBACK"
7124 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7125 set_nodes_failloc "$(osts_nodes)" 0
7127 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7128 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7130 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7131 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7135 echo "Dirty pages gaurenteed flushed via fsync"
7138 run_test 118d "Fsync validation inject a delay of the bulk =========="
7141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7144 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7145 lctl set_param fail_loc=0x8000040a
7147 # Should simulate EINVAL error which is fatal
7148 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7150 if [[ $RC -eq 0 ]]; then
7151 error "Must return error due to dropped pages, rc=$RC"
7154 lctl set_param fail_loc=0x0
7156 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7157 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7158 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7160 if [[ $LOCKED -ne 0 ]]; then
7161 error "Locked pages remain in cache, locked=$LOCKED"
7164 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7165 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7169 echo "No pages locked after fsync"
7174 run_test 118f "Simulate unrecoverable OSC side error =========="
7177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7180 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7181 lctl set_param fail_loc=0x406
7183 # simulate local -ENOMEM
7184 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7187 lctl set_param fail_loc=0
7188 if [[ $RC -eq 0 ]]; then
7189 error "Must return error due to dropped pages, rc=$RC"
7192 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7193 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7194 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7196 if [[ $LOCKED -ne 0 ]]; then
7197 error "Locked pages remain in cache, locked=$LOCKED"
7200 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7201 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7205 echo "No pages locked after fsync"
7210 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7214 remote_ost_nodsh && skip "remote OST with nodsh" && return
7218 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7219 set_nodes_failloc "$(osts_nodes)" 0x20e
7220 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7221 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7224 set_nodes_failloc "$(osts_nodes)" 0
7225 if [[ $RC -eq 0 ]]; then
7226 error "Must return error due to dropped pages, rc=$RC"
7229 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7230 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7231 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7233 if [[ $LOCKED -ne 0 ]]; then
7234 error "Locked pages remain in cache, locked=$LOCKED"
7237 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7238 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7242 echo "No pages locked after fsync"
7246 run_test 118h "Verify timeout in handling recoverables errors =========="
7248 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7252 remote_ost_nodsh && skip "remote OST with nodsh" && return
7256 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7257 set_nodes_failloc "$(osts_nodes)" 0x20e
7259 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7260 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7263 set_nodes_failloc "$(osts_nodes)" 0
7267 if [[ $RC -ne 0 ]]; then
7268 error "got error, but should be not, rc=$RC"
7271 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7272 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7273 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7274 if [[ $LOCKED -ne 0 ]]; then
7275 error "Locked pages remain in cache, locked=$LOCKED"
7278 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7279 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7283 echo "No pages locked after fsync"
7287 run_test 118i "Fix error before timeout in recoverable error =========="
7289 [ "$SLOW" = "no" ] && set_resend_count 4
7292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7293 remote_ost_nodsh && skip "remote OST with nodsh" && return
7297 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7298 set_nodes_failloc "$(osts_nodes)" 0x220
7300 # return -EIO from OST
7301 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7303 set_nodes_failloc "$(osts_nodes)" 0x0
7304 if [[ $RC -eq 0 ]]; then
7305 error "Must return error due to dropped pages, rc=$RC"
7308 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7309 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7310 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7311 if [[ $LOCKED -ne 0 ]]; then
7312 error "Locked pages remain in cache, locked=$LOCKED"
7315 # in recoverable error on OST we want resend and stay until it finished
7316 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7317 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7321 echo "No pages locked after fsync"
7325 run_test 118j "Simulate unrecoverable OST side error =========="
7329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7330 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7332 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7333 set_nodes_failloc "$(osts_nodes)" 0x20e
7334 test_mkdir -p $DIR/$tdir
7336 for ((i=0;i<10;i++)); do
7337 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7338 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7345 set_nodes_failloc "$(osts_nodes)" 0
7348 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7354 test_mkdir -p $DIR/$tdir
7355 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7358 run_test 118l "fsync dir ========="
7360 test_118m() # LU-3066
7362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7363 test_mkdir -p $DIR/$tdir
7364 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7367 run_test 118m "fdatasync dir ========="
7369 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7371 test_119a() # bug 11737
7373 BSIZE=$((512 * 1024))
7374 directio write $DIR/$tfile 0 1 $BSIZE
7375 # We ask to read two blocks, which is more than a file size.
7376 # directio will indicate an error when requested and actual
7377 # sizes aren't equeal (a normal situation in this case) and
7378 # print actual read amount.
7379 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7380 if [ "$NOB" != "$BSIZE" ]; then
7381 error "read $NOB bytes instead of $BSIZE"
7385 run_test 119a "Short directIO read must return actual read amount"
7387 test_119b() # bug 11737
7389 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7391 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7392 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7394 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7395 error "direct read failed"
7398 run_test 119b "Sparse directIO read must return actual read amount"
7400 test_119c() # bug 13099
7403 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7404 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7407 run_test 119c "Testing for direct read hitting hole"
7409 test_119d() # bug 15950
7411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7412 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7413 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7415 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7416 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7417 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7418 lctl set_param fail_loc=0x40d
7419 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7422 cat $DIR/$tfile > /dev/null &
7423 lctl set_param fail_loc=0
7426 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7428 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7429 error "the read rpcs have not completed in 2s"
7431 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7433 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7437 test_mkdir -p $DIR/$tdir
7438 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7439 skip "no early lock cancel on server" && return 0
7441 lru_resize_disable mdc
7442 lru_resize_disable osc
7443 cancel_lru_locks mdc
7444 # asynchronous object destroy at MDT could cause bl ast to client
7445 cancel_lru_locks osc
7447 stat $DIR/$tdir > /dev/null
7448 can1=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
7449 awk '/ldlm_cancel/ {print $2}')
7450 blk1=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
7451 awk '/ldlm_bl_callback/ {print $2}')
7452 test_mkdir -c1 $DIR/$tdir/d1
7453 can2=$(lctl get_param -n ldlm.services.ldlm_canceld.stats |
7454 awk '/ldlm_cancel/ {print $2}')
7455 blk2=$(lctl get_param -n ldlm.services.ldlm_cbd.stats |
7456 awk '/ldlm_bl_callback/ {print $2}')
7457 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7458 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7459 lru_resize_enable mdc
7460 lru_resize_enable osc
7462 run_test 120a "Early Lock Cancel: mkdir test"
7465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7466 test_mkdir $DIR/$tdir
7467 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7468 skip "no early lock cancel on server" && return 0
7469 lru_resize_disable mdc
7470 lru_resize_disable osc
7471 cancel_lru_locks mdc
7472 stat $DIR/$tdir > /dev/null
7473 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7474 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7476 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7477 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7478 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7479 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7480 lru_resize_enable mdc
7481 lru_resize_enable osc
7483 run_test 120b "Early Lock Cancel: create test"
7486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7487 test_mkdir -c1 $DIR/$tdir
7488 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7489 skip "no early lock cancel on server" && return 0
7490 lru_resize_disable mdc
7491 lru_resize_disable osc
7492 test_mkdir -p -c1 $DIR/$tdir/d1
7493 test_mkdir -p -c1 $DIR/$tdir/d2
7494 touch $DIR/$tdir/d1/f1
7495 cancel_lru_locks mdc
7496 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7497 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7498 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7499 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7500 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7501 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7502 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7503 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7504 lru_resize_enable mdc
7505 lru_resize_enable osc
7507 run_test 120c "Early Lock Cancel: link test"
7510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7511 test_mkdir -p -c1 $DIR/$tdir
7512 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7513 skip "no early lock cancel on server" && return 0
7514 lru_resize_disable mdc
7515 lru_resize_disable osc
7517 cancel_lru_locks mdc
7518 stat $DIR/$tdir > /dev/null
7519 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7520 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7521 chmod a+x $DIR/$tdir
7522 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7523 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7524 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7525 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7526 lru_resize_enable mdc
7527 lru_resize_enable osc
7529 run_test 120d "Early Lock Cancel: setattr test"
7532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7533 test_mkdir -p -c1 $DIR/$tdir
7534 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7535 skip "no early lock cancel on server" && return 0
7536 lru_resize_disable mdc
7537 lru_resize_disable osc
7538 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7539 cancel_lru_locks mdc
7540 cancel_lru_locks osc
7541 dd if=$DIR/$tdir/f1 of=/dev/null
7542 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7543 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7544 awk '/ldlm_cancel/ {print $2}'`
7545 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7546 awk '/ldlm_bl_callback/ {print $2}'`
7547 unlink $DIR/$tdir/f1
7548 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7549 awk '/ldlm_cancel/ {print $2}'`
7550 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7551 awk '/ldlm_bl_callback/ {print $2}'`
7552 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7553 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7554 lru_resize_enable mdc
7555 lru_resize_enable osc
7557 run_test 120e "Early Lock Cancel: unlink test"
7560 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7561 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7562 skip "no early lock cancel on server" && return 0
7563 test_mkdir -p -c1 $DIR/$tdir
7564 lru_resize_disable mdc
7565 lru_resize_disable osc
7566 test_mkdir -p -c1 $DIR/$tdir/d1
7567 test_mkdir -p -c1 $DIR/$tdir/d2
7568 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7569 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7570 cancel_lru_locks mdc
7571 cancel_lru_locks osc
7572 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7573 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7574 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7575 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7576 awk '/ldlm_cancel/ {print $2}'`
7577 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7578 awk '/ldlm_bl_callback/ {print $2}'`
7579 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7580 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7581 awk '/ldlm_cancel/ {print $2}'`
7582 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7583 awk '/ldlm_bl_callback/ {print $2}'`
7584 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7585 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7586 lru_resize_enable mdc
7587 lru_resize_enable osc
7589 run_test 120f "Early Lock Cancel: rename test"
7592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7593 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7594 skip "no early lock cancel on server" && return 0
7595 lru_resize_disable mdc
7596 lru_resize_disable osc
7598 echo create $count files
7599 test_mkdir -p $DIR/$tdir
7600 cancel_lru_locks mdc
7601 cancel_lru_locks osc
7604 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7605 awk '/ldlm_cancel/ {print $2}'`
7606 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7607 awk '/ldlm_bl_callback/ {print $2}'`
7608 createmany -o $DIR/$tdir/f $count
7610 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7611 awk '/ldlm_cancel/ {print $2}'`
7612 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7613 awk '/ldlm_bl_callback/ {print $2}'`
7615 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7616 echo rm $count files
7619 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7620 awk '/ldlm_cancel/ {print $2}'`
7621 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7622 awk '/ldlm_bl_callback/ {print $2}'`
7624 echo total: $count removes in $((t2-t1))
7625 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7627 # wait for commitment of removal
7628 lru_resize_enable mdc
7629 lru_resize_enable osc
7631 run_test 120g "Early Lock Cancel: performance test"
7633 test_121() { #bug #10589
7634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7636 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7637 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7638 lctl set_param fail_loc=0x310
7639 cancel_lru_locks osc > /dev/null
7640 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7641 lctl set_param fail_loc=0
7642 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7644 run_test 121 "read cancel race ========="
7646 test_123a() { # was test 123, statahead(bug 11401)
7647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7649 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7650 log "testing on UP system. Performance may be not as good as expected."
7655 test_mkdir -p $DIR/$tdir
7656 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7657 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7659 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7660 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7662 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7663 lctl set_param -n llite.*.statahead_max 0
7664 lctl get_param llite.*.statahead_max
7665 cancel_lru_locks mdc
7666 cancel_lru_locks osc
7668 time ls -l $DIR/$tdir | wc -l
7670 delta=$((etime - stime))
7671 log "ls $i files without statahead: $delta sec"
7672 lctl set_param llite.*.statahead_max=$max
7674 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7675 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7676 cancel_lru_locks mdc
7677 cancel_lru_locks osc
7679 time ls -l $DIR/$tdir | wc -l
7681 delta_sa=$((etime - stime))
7682 log "ls $i files with statahead: $delta_sa sec"
7683 lctl get_param -n llite.*.statahead_stats
7684 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7686 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7687 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7689 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7690 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7691 lctl set_param -n llite.*.statahead_max 0
7692 lctl get_param llite.*.statahead_max
7693 cancel_lru_locks mdc
7694 cancel_lru_locks osc
7696 time ls -l $DIR/$tdir | wc -l
7698 delta=$((etime - stime))
7699 log "ls $i files again without statahead: $delta sec"
7700 lctl set_param llite.*.statahead_max=$max
7701 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7702 if [ $SLOWOK -eq 0 ]; then
7703 error "ls $i files is slower with statahead!"
7705 log "ls $i files is slower with statahead!"
7711 [ $delta -gt 20 ] && break
7712 [ $delta -gt 8 ] && MULT=$((50 / delta))
7713 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7721 delta=$((etime - stime))
7722 log "rm -r $DIR/$tdir/: $delta seconds"
7724 lctl get_param -n llite.*.statahead_stats
7726 run_test 123a "verify statahead work"
7728 test_123b () { # statahead(bug 15027)
7729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7730 test_mkdir -p $DIR/$tdir
7731 createmany -o $DIR/$tdir/$tfile-%d 1000
7733 cancel_lru_locks mdc
7734 cancel_lru_locks osc
7736 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7737 lctl set_param fail_loc=0x80000803
7738 ls -lR $DIR/$tdir > /dev/null
7740 lctl set_param fail_loc=0x0
7741 lctl get_param -n llite.*.statahead_stats
7746 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7750 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7751 skip "no lru resize on server" && return 0
7753 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7755 log "create $NR files at $DIR/$tdir"
7756 createmany -o $DIR/$tdir/f $NR ||
7757 error "failed to create $NR files in $DIR/$tdir"
7759 cancel_lru_locks mdc
7760 ls -l $DIR/$tdir > /dev/null
7764 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7765 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7766 LRU_SIZE=$(lctl get_param -n $PARAM)
7767 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7768 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7770 log "NS=$(basename $NSDIR)"
7775 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7776 skip "Not enough cached locks created!"
7783 # We know that lru resize allows one client to hold $LIMIT locks
7784 # for 10h. After that locks begin to be killed by client.
7786 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7789 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7790 # killing locks. Some time was spent for creating locks. This means
7791 # that up to the moment of sleep finish we must have killed some of
7792 # them (10-100 locks). This depends on how fast ther were created.
7793 # Many of them were touched in almost the same moment and thus will
7794 # be killed in groups.
7795 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7797 # Use $LRU_SIZE_B here to take into account real number of locks
7798 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7799 local LRU_SIZE_B=$LRU_SIZE
7801 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7802 log "OLD_LVF=$OLD_LVF"
7803 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7805 # Let's make sure that we really have some margin. Client checks
7806 # cached locks every 10 sec.
7808 log "Sleep ${SLEEP} sec"
7810 while ((SEC<$SLEEP)); do
7814 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7818 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7819 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7821 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7822 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7823 unlinkmany $DIR/$tdir/f $NR
7827 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7828 log "unlink $NR files at $DIR/$tdir"
7829 unlinkmany $DIR/$tdir/f $NR
7831 run_test 124a "lru resize ======================================="
7833 get_max_pool_limit()
7835 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7838 if test $l -gt $max; then
7846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7847 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7848 skip "no lru resize on server" && return 0
7850 LIMIT=`get_max_pool_limit`
7852 NR=$(($(default_lru_size)*20))
7853 if [ $NR -gt $LIMIT ]; then
7854 log "Limit lock number by $LIMIT locks"
7857 lru_resize_disable mdc
7858 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7859 error "failed to create $DIR/$tdir/disable_lru_resize"
7861 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7862 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7863 cancel_lru_locks mdc
7866 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7869 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7872 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7876 nolruresize_delta=$((etime-stime))
7877 log "ls -la time: $nolruresize_delta seconds"
7878 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7879 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7881 lru_resize_enable mdc
7882 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7883 error "failed to create $DIR/$tdir/enable_lru_resize"
7885 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7886 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7887 cancel_lru_locks mdc
7890 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7893 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7896 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7900 lruresize_delta=$((etime-stime))
7901 log "ls -la time: $lruresize_delta seconds"
7902 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7904 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7905 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7906 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7907 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7909 log "lru resize performs the same with no lru resize"
7911 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7913 run_test 124b "lru resize (performance test) ======================="
7915 test_125() { # 13358
7916 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7917 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7918 test_mkdir -p $DIR/d125 || error "mkdir failed"
7919 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7920 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7921 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7923 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7925 test_126() { # bug 12829/13455
7926 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7927 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7928 $GSS && skip "must run as gss disabled" && return
7930 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7931 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7933 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7935 run_test 126 "check that the fsgid provided by the client is taken into account"
7937 test_127a() { # bug 15521
7938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7939 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7940 $LCTL set_param osc.*.stats=0
7941 FSIZE=$((2048 * 1024))
7942 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7943 cancel_lru_locks osc
7944 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7946 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7947 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7948 echo "got $COUNT $NAME"
7949 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7950 eval $NAME=$COUNT || error "Wrong proc format"
7953 read_bytes|write_bytes)
7954 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7955 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7956 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7957 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7958 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7959 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7960 error "sumsquare is too small: $SUMSQ"
7961 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7962 error "sumsquare is too big: $SUMSQ"
7966 done < $DIR/${tfile}.tmp
7968 #check that we actually got some stats
7969 [ "$read_bytes" ] || error "Missing read_bytes stats"
7970 [ "$write_bytes" ] || error "Missing write_bytes stats"
7971 [ "$read_bytes" != 0 ] || error "no read done"
7972 [ "$write_bytes" != 0 ] || error "no write done"
7974 run_test 127a "verify the client stats are sane"
7976 test_127b() { # bug LU-333
7977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7978 $LCTL set_param llite.*.stats=0
7979 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7980 # perform 2 reads and writes so MAX is different from SUM.
7981 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7982 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7983 cancel_lru_locks osc
7984 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7985 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7987 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7988 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7989 echo "got $COUNT $NAME"
7990 eval $NAME=$COUNT || error "Wrong proc format"
7994 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7995 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7996 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7997 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8000 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8001 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8002 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8003 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8007 done < $TMP/${tfile}.tmp
8009 #check that we actually got some stats
8010 [ "$read_bytes" ] || error "Missing read_bytes stats"
8011 [ "$write_bytes" ] || error "Missing write_bytes stats"
8012 [ "$read_bytes" != 0 ] || error "no read done"
8013 [ "$write_bytes" != 0 ] || error "no write done"
8015 run_test 127b "verify the llite client stats are sane"
8017 test_128() { # bug 15212
8019 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8024 result=$(grep error $TMP/$tfile.log)
8026 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8028 run_test 128 "interactive lfs for 2 consecutive find's"
8035 local LDPROC=/proc/fs/ldiskfs
8036 local facets=$(get_facets MDS)
8038 for facet in ${facets//,/ }; do
8039 canondev=$(ldiskfs_canon \
8040 *.$(convert_facet2label $facet).mntdev $facet)
8041 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8042 LDPROC=/sys/fs/ldiskfs
8043 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8049 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8050 skip "Only applicable to ldiskfs-based MDTs"
8053 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8058 test_mkdir -p $DIR/$tdir
8060 # block size of mds1
8061 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8062 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8063 local MAX=$((MDSBLOCKSIZE * 3))
8065 local I=$(stat -c%s "$DIR/$tdir")
8067 local STRIPE_COUNT=1
8068 [ $MDSCOUNT -ge 2 ] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8069 MAX=$((MAX*STRIPE_COUNT))
8070 while [ ! $I -gt $MAX ]; do
8071 $MULTIOP $DIR/$tdir/$J Oc
8073 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8074 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8075 #and EFBIG for previous versions
8076 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8078 echo "return code $rc received as expected"
8079 multiop $DIR/$tdir/$J Oc ||
8080 error_exit "multiop failed w/o dir size limit"
8082 I=$(stat -c%s "$DIR/$tdir")
8084 if [ $(lustre_version_code $SINGLEMDS) -lt \
8085 $(version_code 2.4.51) ]
8087 [ $I -eq $MAX ] && return 0
8089 [ $I -gt $MAX ] && return 0
8091 error_exit "current dir size $I, previous limit $MAX"
8092 elif [ $rc -ne 0 ]; then
8094 error_exit "return code $rc received instead of expected " \
8095 "$EFBIG or $ENOSPC, files in dir $I"
8098 I=$(stat -c%s "$DIR/$tdir")
8102 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8104 run_test 129 "test directory size limit ========================"
8113 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8114 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8117 trap cleanup_130 EXIT RETURN
8119 local fm_file=$DIR/$tfile
8120 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8121 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8122 error "dd failed for $fm_file"
8124 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8125 filefrag -ves $fm_file
8127 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8128 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8129 [ $RC != 0 ] && error "filefrag $fm_file failed"
8131 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8132 grep -v "ext:" | grep -v "found")
8133 lun=$($GETSTRIPE -i $fm_file)
8135 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8138 for line in $filefrag_op
8140 frag_lun=`echo $line | cut -d: -f5`
8141 ext_len=`echo $line | cut -d: -f4`
8142 if (( $frag_lun != $lun )); then
8144 error "FIEMAP on 1-stripe file($fm_file) failed"
8147 (( tot_len += ext_len ))
8150 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8152 error "FIEMAP on 1-stripe file($fm_file) failed;"
8158 echo "FIEMAP on single striped file succeeded"
8160 run_test 130a "FIEMAP (1-stripe file)"
8163 [ "$OSTCOUNT" -lt "2" ] &&
8164 skip_env "skipping FIEMAP on 2-stripe file test" && return
8166 [ "$OSTCOUNT" -ge "10" ] &&
8167 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8169 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8170 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8173 trap cleanup_130 EXIT RETURN
8175 local fm_file=$DIR/$tfile
8176 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8177 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8178 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8180 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8181 error "dd failed on $fm_file"
8183 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8184 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8185 grep -v "ext:" | grep -v "found")
8187 last_lun=$(echo $filefrag_op | cut -d: -f5)
8192 for line in $filefrag_op
8194 frag_lun=`echo $line | cut -d: -f5`
8195 ext_len=`echo $line | cut -d: -f4`
8196 if (( $frag_lun != $last_lun )); then
8197 if (( tot_len != 1024 )); then
8199 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8206 (( tot_len += ext_len ))
8209 if (( num_luns != 2 || tot_len != 1024 )); then
8211 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8217 echo "FIEMAP on 2-stripe file succeeded"
8219 run_test 130b "FIEMAP (2-stripe file)"
8222 [ "$OSTCOUNT" -lt "2" ] &&
8223 skip_env "skipping FIEMAP on 2-stripe file" && return
8225 [ "$OSTCOUNT" -ge "10" ] &&
8226 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8228 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8229 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8232 trap cleanup_130 EXIT RETURN
8234 local fm_file=$DIR/$tfile
8235 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8236 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8237 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8239 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8241 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8242 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8244 last_lun=`echo $filefrag_op | cut -d: -f5`
8249 for line in $filefrag_op
8251 frag_lun=`echo $line | cut -d: -f5`
8252 ext_len=`echo $line | cut -d: -f4`
8253 if (( $frag_lun != $last_lun )); then
8254 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8255 if (( logical != 512 )); then
8257 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8260 if (( tot_len != 512 )); then
8262 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8269 (( tot_len += ext_len ))
8272 if (( num_luns != 2 || tot_len != 512 )); then
8274 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8280 echo "FIEMAP on 2-stripe file with hole succeeded"
8282 run_test 130c "FIEMAP (2-stripe file with hole)"
8285 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8287 [ "$OSTCOUNT" -ge "10" ] &&
8288 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8290 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8291 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8293 trap cleanup_130 EXIT RETURN
8295 local fm_file=$DIR/$tfile
8296 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8297 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8298 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8300 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8301 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8302 error "dd failed on $fm_file"
8304 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8305 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8306 grep -v "ext:" | grep -v "found"`
8308 last_lun=`echo $filefrag_op | cut -d: -f5`
8313 for line in $filefrag_op
8315 frag_lun=`echo $line | cut -d: -f5`
8316 ext_len=`echo $line | cut -d: -f4`
8317 if (( $frag_lun != $last_lun )); then
8318 if (( tot_len != 1024 )); then
8320 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8327 (( tot_len += ext_len ))
8330 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8332 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8338 echo "FIEMAP on N-stripe file succeeded"
8340 run_test 130d "FIEMAP (N-stripe file)"
8343 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8345 [ "$OSTCOUNT" -ge "10" ] &&
8346 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8348 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8349 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8351 trap cleanup_130 EXIT RETURN
8353 local fm_file=$DIR/$tfile
8354 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8355 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8356 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8359 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8360 for ((i = 0; i < $NUM_BLKS; i++))
8362 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8365 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8366 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8368 last_lun=`echo $filefrag_op | cut -d: -f5`
8373 for line in $filefrag_op
8375 frag_lun=`echo $line | cut -d: -f5`
8376 ext_len=`echo $line | cut -d: -f4`
8377 if (( $frag_lun != $last_lun )); then
8378 if (( tot_len != $EXPECTED_LEN )); then
8380 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8387 (( tot_len += ext_len ))
8390 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8392 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8398 echo "FIEMAP with continuation calls succeeded"
8400 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8402 # Test for writev/readv
8404 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8405 error "writev test failed"
8406 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8407 error "readv failed"
8410 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8413 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8414 error "append writev test failed"
8415 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8416 error "append writev test failed"
8419 run_test 131b "test append writev"
8422 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8425 run_test 131c "test read/write on file w/o objects"
8428 rwv -f $DIR/$tfile -w -n 1 1572864
8429 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8430 if [ "$NOB" != 1572864 ]; then
8431 error "Short read filed: read $NOB bytes instead of 1572864"
8435 run_test 131d "test short read"
8438 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8439 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8440 error "read hitting hole failed"
8443 run_test 131e "test read hitting hole"
8448 for node in $(osts_nodes); do
8449 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8450 [ x$gl = x"" ] && gl=0
8451 gl_sum=$((gl_sum + gl))
8461 if [ x$som = x"enabled" ]; then
8462 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8463 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8464 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8466 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8467 MOUNTOPT="$MOUNTOPT,som_preview"
8468 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8471 # do remount to make new mount-conf parameters actual
8478 test_132() { #1028, SOM
8479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8480 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8481 local num=$(get_mds_dir $DIR)
8482 local mymds=mds${num}
8483 local MOUNTOPT_SAVE=$MOUNTOPT
8485 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8486 cancel_lru_locks osc
8488 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8490 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8491 stat $DIR/$tfile >/dev/null
8492 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8493 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8495 som_mode_switch $som1 $gl1 $gl2
8497 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8498 cancel_lru_locks osc
8500 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8501 if [ $som1 == $som2 ]; then
8502 error "som is still "$som2
8503 if [ x$som2 = x"enabled" ]; then
8510 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8511 stat $DIR/$tfile >/dev/null
8512 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8513 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8514 som_mode_switch $som2 $gl1 $gl2
8515 MOUNTOPT=$MOUNTOPT_SAVE
8517 run_test 132 "som avoids glimpse rpc"
8523 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8525 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8527 *) error "Wrong argument $1" ;;
8530 count=`echo $res | awk '{print $2}'`
8531 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8532 # if the argument $3 is zero, it means any stat increment is ok.
8533 if [ $3 -gt 0 ] ; then
8534 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8540 remote_ost_nodsh && skip "remote OST with nodsh" && return
8541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8543 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8544 { skip "MDS doesn't support rename stats"; return; }
8545 local testdir=$DIR/${tdir}/stats_testdir
8546 mkdir -p $DIR/${tdir}
8549 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8550 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8552 # verify mdt stats first.
8553 mkdir ${testdir} || error "mkdir failed"
8554 check_stats $SINGLEMDS "mkdir" 1
8555 touch ${testdir}/${tfile} || "touch failed"
8556 check_stats $SINGLEMDS "open" 1
8557 check_stats $SINGLEMDS "close" 1
8558 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8559 check_stats $SINGLEMDS "mknod" 1
8560 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8561 check_stats $SINGLEMDS "unlink" 1
8562 rm -f ${testdir}/${tfile} || error "file remove failed"
8563 check_stats $SINGLEMDS "unlink" 2
8565 # remove working dir and check mdt stats again.
8566 rmdir ${testdir} || error "rmdir failed"
8567 check_stats $SINGLEMDS "rmdir" 1
8569 local testdir1=$DIR/${tdir}/stats_testdir1
8571 mkdir -p ${testdir1}
8572 touch ${testdir1}/test1
8573 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8574 check_stats $SINGLEMDS "crossdir_rename" 1
8576 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8577 check_stats $SINGLEMDS "samedir_rename" 1
8581 run_test 133a "Verifying MDT stats ========================================"
8584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8585 remote_ost_nodsh && skip "remote OST with nodsh" && return
8586 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8587 local testdir=$DIR/${tdir}/stats_testdir
8588 mkdir -p ${testdir} || error "mkdir failed"
8589 touch ${testdir}/${tfile} || "touch failed"
8590 cancel_lru_locks mdc
8593 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8594 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8596 # extra mdt stats verification.
8597 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8598 check_stats $SINGLEMDS "setattr" 1
8599 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8600 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8602 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8603 check_stats $SINGLEMDS "getattr" 1
8605 $LFS df || error "lfs failed"
8606 check_stats $SINGLEMDS "statfs" 1
8610 run_test 133b "Verifying extra MDT stats =================================="
8613 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8614 remote_ost_nodsh && skip "remote OST with nodsh" && return
8615 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8616 local testdir=$DIR/${tdir}/stats_testdir
8617 test_mkdir -p ${testdir} || error "mkdir failed"
8619 # verify obdfilter stats.
8620 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8622 cancel_lru_locks osc
8623 wait_delete_completed
8626 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8627 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8629 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8631 cancel_lru_locks osc
8632 check_stats ost "write" 1
8634 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8635 check_stats ost "read" 1
8637 > ${testdir}/${tfile} || error "truncate failed"
8638 check_stats ost "punch" 1
8640 rm -f ${testdir}/${tfile} || error "file remove failed"
8641 wait_delete_completed
8642 check_stats ost "destroy" 1
8646 run_test 133c "Verifying OST stats ========================================"
8653 while [ $value -ge 2 ]; do
8658 if [ $orig -gt $order ]; then
8666 local size=('K' 'M' 'G' 'T');
8668 local size_string=$value
8670 while [ $value -ge 1024 ]; do
8671 if [ $i -gt 3 ]; then
8672 #T is the biggest unit we get here, if that is bigger,
8674 size_string=${value}T
8677 value=$((value >> 10))
8678 if [ $value -lt 1024 ]; then
8679 size_string=${value}${size[$i]}
8690 local context=${2:-.}
8691 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8693 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8699 remote_ost_nodsh && skip "remote OST with nodsh" && return
8700 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8701 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8702 { skip "MDS doesn't support rename stats"; return; }
8704 local testdir1=$DIR/${tdir}/stats_testdir1
8705 local testdir2=$DIR/${tdir}/stats_testdir2
8707 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8709 mkdir -p ${testdir1} || error "mkdir failed"
8710 mkdir -p ${testdir2} || error "mkdir failed"
8712 createmany -o $testdir1/test 512 || error "createmany failed"
8714 # check samedir rename size
8715 mv ${testdir1}/test0 ${testdir1}/test_0
8717 local testdir1_size=$(ls -l $DIR/${tdir} |
8718 awk '/stats_testdir1/ {print $5}')
8719 local testdir2_size=$(ls -l $DIR/${tdir} |
8720 awk '/stats_testdir2/ {print $5}')
8722 testdir1_size=$(order_2 $testdir1_size)
8723 testdir2_size=$(order_2 $testdir2_size)
8725 testdir1_size=$(size_in_KMGT $testdir1_size)
8726 testdir2_size=$(size_in_KMGT $testdir2_size)
8728 echo "source rename dir size: ${testdir1_size}"
8729 echo "target rename dir size: ${testdir2_size}"
8731 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8732 eval $cmd || error "$cmd failed"
8733 local samedir=$($cmd | grep 'same_dir')
8734 local same_sample=$(get_rename_size $testdir1_size)
8735 [ -z "$samedir" ] && error "samedir_rename_size count error"
8736 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8737 echo "Check same dir rename stats success"
8739 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8741 # check crossdir rename size
8742 mv ${testdir1}/test_0 ${testdir2}/test_0
8744 testdir1_size=$(ls -l $DIR/${tdir} |
8745 awk '/stats_testdir1/ {print $5}')
8746 testdir2_size=$(ls -l $DIR/${tdir} |
8747 awk '/stats_testdir2/ {print $5}')
8749 testdir1_size=$(order_2 $testdir1_size)
8750 testdir2_size=$(order_2 $testdir2_size)
8752 testdir1_size=$(size_in_KMGT $testdir1_size)
8753 testdir2_size=$(size_in_KMGT $testdir2_size)
8755 echo "source rename dir size: ${testdir1_size}"
8756 echo "target rename dir size: ${testdir2_size}"
8758 eval $cmd || error "$cmd failed"
8759 local crossdir=$($cmd | grep 'crossdir')
8760 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8761 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8762 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8763 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8764 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8765 echo "Check cross dir rename stats success"
8768 run_test 133d "Verifying rename_stats ========================================"
8771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8772 local testdir=$DIR/${tdir}/stats_testdir
8773 local ctr f0 f1 bs=32768 count=42 sum
8775 remote_ost_nodsh && skip "remote OST with nodsh" && return
8776 mkdir -p ${testdir} || error "mkdir failed"
8778 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8780 for ctr in {write,read}_bytes; do
8782 cancel_lru_locks osc
8784 do_facet ost1 $LCTL set_param -n \
8785 "obdfilter.*.exports.clear=clear"
8787 if [ $ctr = write_bytes ]; then
8789 f1=${testdir}/${tfile}
8791 f0=${testdir}/${tfile}
8795 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8798 cancel_lru_locks osc
8800 sum=$(do_facet ost1 $LCTL get_param \
8801 "obdfilter.*.exports.*.stats" | \
8804 $1 == ctr { sum += $7 }
8807 if ((sum != bs * count)); then
8808 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8814 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8817 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8820 # First without trusting modes.
8822 -exec cat '{}' \; &> /dev/null
8824 # Second verifying readability.
8828 -exec cat '{}' \; > /dev/null ||
8829 error "proc file read failed"
8831 for facet in $SINGLEMDS ost1; do
8832 do_facet $facet find $proc_dirs \
8833 -not -name req_history \
8834 -exec cat '{}' \\\; &> /dev/null
8836 do_facet $facet find $proc_dirs \
8837 -not -name req_history \
8840 -exec cat '{}' \\\; > /dev/null ||
8841 error "proc file read failed"
8844 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8846 test_140() { #bug-17379
8847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8848 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8849 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8850 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8852 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8853 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8855 while i=`expr $i + 1`; do
8856 test_mkdir -p $i || error "Creating dir $i"
8857 cd $i || error "Changing to $i"
8858 ln -s ../stat stat || error "Creating stat symlink"
8859 # Read the symlink until ELOOP present,
8860 # not LBUGing the system is considered success,
8861 # we didn't overrun the stack.
8862 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8864 if [ $ret -eq 40 ]; then
8867 error "Open stat symlink"
8873 echo "The symlink depth = $i"
8874 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8875 error "Invalid symlink depth"
8877 # Test recursive symlink
8878 ln -s symlink_self symlink_self
8879 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8880 echo "open symlink_self returns $ret"
8881 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8883 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8887 local TF="$TMP/$tfile"
8889 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8891 cancel_lru_locks osc
8892 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8893 remount_client $MOUNT
8895 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8898 $TRUNCATE $DIR/$tfile 6000
8899 cancel_lru_locks osc
8900 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8903 echo "12345" >>$DIR/$tfile
8904 cancel_lru_locks osc
8905 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8908 echo "12345" >>$DIR/$tfile
8909 cancel_lru_locks osc
8910 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8915 run_test 150 "truncate/append tests"
8917 #LU-2902 roc_hit was not able to read all values from lproc
8918 function roc_hit_init() {
8919 local list=$(comma_list $(osts_nodes))
8920 local dir=$DIR/$tdir-check
8921 local file=$dir/file
8927 #use setstripe to do a write to every ost
8928 for i in $(seq 0 $((OSTCOUNT-1))); do
8929 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
8930 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
8931 idx=$(printf %04x $i)
8932 BEFORE=$(get_osd_param $list *OST*$idx stats |
8933 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8934 if [ -z "$BEFORE" ]; then
8938 cancel_lru_locks osc
8939 cat $file >/dev/null
8941 AFTER=$(get_osd_param $list *OST*$idx stats |
8942 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8944 echo BEFORE:$BEFORE AFTER:$AFTER
8945 if ! let "AFTER - BEFORE == 4"; then
8947 error "roc_hit is not safe to use"
8955 function roc_hit() {
8956 local list=$(comma_list $(osts_nodes))
8957 echo $(get_osd_param $list '' stats |
8958 awk '$1 == "cache_hit" {sum += $2} END { print sum }')
8961 function set_cache() {
8964 if [ "$2" == "off" ]; then
8967 local list=$(comma_list $(osts_nodes))
8968 set_osd_param $list '' $1_cache_enable $on
8970 cancel_lru_locks osc
8974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8975 remote_ost_nodsh && skip "remote OST with nodsh" && return
8978 local list=$(comma_list $(osts_nodes))
8980 # check whether obdfilter is cache capable at all
8981 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8982 echo "not cache-capable obdfilter"
8986 # check cache is enabled on all obdfilters
8987 if get_osd_param $list '' read_cache_enable | grep 0; then
8988 echo "oss cache is disabled"
8992 set_osd_param $list '' writethrough_cache_enable 1
8994 # check write cache is enabled on all obdfilters
8995 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8996 echo "oss write cache is NOT enabled"
9002 #define OBD_FAIL_OBD_NO_LRU 0x609
9003 do_nodes $list $LCTL set_param fail_loc=0x609
9005 # pages should be in the case right after write
9006 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9009 local BEFORE=$(roc_hit)
9010 cancel_lru_locks osc
9011 cat $DIR/$tfile >/dev/null
9012 local AFTER=$(roc_hit)
9014 do_nodes $list $LCTL set_param fail_loc=0
9016 if ! let "AFTER - BEFORE == CPAGES"; then
9017 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9020 # the following read invalidates the cache
9021 cancel_lru_locks osc
9022 set_osd_param $list '' read_cache_enable 0
9023 cat $DIR/$tfile >/dev/null
9025 # now data shouldn't be found in the cache
9027 cancel_lru_locks osc
9028 cat $DIR/$tfile >/dev/null
9030 if let "AFTER - BEFORE != 0"; then
9031 error "IN CACHE: before: $BEFORE, after: $AFTER"
9034 set_osd_param $list '' read_cache_enable 1
9037 run_test 151 "test cache on oss and controls ==============================="
9040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9041 local TF="$TMP/$tfile"
9043 # simulate ENOMEM during write
9044 #define OBD_FAIL_OST_NOMEM 0x226
9045 lctl set_param fail_loc=0x80000226
9046 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9048 sync || error "sync failed"
9049 lctl set_param fail_loc=0
9051 # discard client's cache
9052 cancel_lru_locks osc
9054 # simulate ENOMEM during read
9055 lctl set_param fail_loc=0x80000226
9056 cmp $TF $DIR/$tfile || error "cmp failed"
9057 lctl set_param fail_loc=0
9061 run_test 152 "test read/write with enomem ============================"
9064 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9066 run_test 153 "test if fdatasync does not crash ======================="
9068 dot_lustre_fid_permission_check() {
9070 local ffid=$MOUNT/.lustre/fid/$fid
9073 echo "stat fid $fid"
9074 stat $ffid > /dev/null || error "stat $ffid failed."
9075 echo "touch fid $fid"
9076 touch $ffid || error "touch $ffid failed."
9077 echo "write to fid $fid"
9078 cat /etc/hosts > $ffid || error "write $ffid failed."
9079 echo "read fid $fid"
9080 diff /etc/hosts $ffid || error "read $ffid failed."
9081 echo "append write to fid $fid"
9082 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9083 echo "rename fid $fid"
9084 mv $ffid $test_dir/$tfile.1 &&
9085 error "rename $ffid to $tfile.1 should fail."
9086 touch $test_dir/$tfile.1
9087 mv $test_dir/$tfile.1 $ffid &&
9088 error "rename $tfile.1 to $ffid should fail."
9089 rm -f $test_dir/$tfile.1
9090 echo "truncate fid $fid"
9091 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9092 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9093 echo "link fid $fid"
9094 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9096 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9097 echo "setfacl fid $fid"
9098 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9099 echo "getfacl fid $fid"
9100 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9102 echo "unlink fid $fid"
9103 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9104 echo "mknod fid $fid"
9105 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9107 fid=[0xf00000400:0x1:0x0]
9108 ffid=$MOUNT/.lustre/fid/$fid
9110 echo "stat non-exist fid $fid"
9111 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9112 echo "write to non-exist fid $fid"
9113 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9114 echo "link new fid $fid"
9115 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9117 mkdir -p $test_dir/$tdir
9118 touch $test_dir/$tdir/$tfile
9119 fid=$($LFS path2fid $test_dir/$tdir)
9122 error "error: could not get fid for $test_dir/$dir/$tfile."
9124 ffid=$MOUNT/.lustre/fid/$fid
9127 ls $ffid > /dev/null || error "ls $ffid failed."
9128 echo "touch $fid/$tfile.1"
9129 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9131 echo "touch $MOUNT/.lustre/fid/$tfile"
9132 touch $MOUNT/.lustre/fid/$tfile && \
9133 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9135 echo "setxattr to $MOUNT/.lustre/fid"
9136 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9138 echo "listxattr for $MOUNT/.lustre/fid"
9139 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9141 echo "delxattr from $MOUNT/.lustre/fid"
9142 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9144 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9145 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9146 error "touch invalid fid should fail."
9148 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9149 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9150 error "touch non-normal fid should fail."
9152 echo "rename $tdir to $MOUNT/.lustre/fid"
9153 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9154 error "rename to $MOUNT/.lustre/fid should fail."
9156 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9158 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9159 local new_obf_mode=777
9161 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9162 chmod $new_obf_mode $DIR/.lustre/fid ||
9163 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9165 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9166 [ $obf_mode -eq $new_obf_mode ] ||
9167 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9169 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9170 chmod $old_obf_mode $DIR/.lustre/fid ||
9171 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9174 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9175 fid=$($LFS path2fid $test_dir/$tfile-2)
9176 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9177 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9178 error "create lov data thru .lustre should fail."
9179 echo "cp /etc/passwd $test_dir/$tfile-2"
9180 cp /etc/passwd $test_dir/$tfile-2 ||
9181 error "copy to $test_dir/$tfile-2 failed."
9182 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9183 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9184 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9186 rm -rf $test_dir/tfile.lnk
9187 rm -rf $test_dir/$tfile-2
9191 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9192 skip "Need MDS version at least 2.4.1" && return
9195 local FID=$($LFS path2fid $DIR/$tfile)
9196 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9198 # check that we get the same pathname back
9199 local FOUND=$($LFS fid2path $MOUNT $FID)
9200 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9201 [ "$FOUND" != "$DIR/$tfile" ] &&
9202 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9206 run_test 154A "lfs path2fid and fid2path basic checks"
9209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9210 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9211 { skip "Need MDS version at least 2.2.51"; return 0; }
9213 cp /etc/hosts $DIR/$tfile
9215 fid=$($LFS path2fid $DIR/$tfile)
9217 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9219 dot_lustre_fid_permission_check "$fid" $DIR ||
9220 error "dot lustre permission check $fid failed"
9222 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9224 touch $MOUNT/.lustre/file &&
9225 error "creation is not allowed under .lustre"
9227 mkdir $MOUNT/.lustre/dir &&
9228 error "mkdir is not allowed under .lustre"
9232 run_test 154a "Open-by-FID"
9235 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9236 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9237 { skip "Need MDS version at least 2.2.51"; return 0; }
9239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9241 local remote_dir=$DIR/$tdir/remote_dir
9246 $LFS mkdir -i $MDTIDX -c $MDSCOUNT $remote_dir ||
9247 error "create remote directory failed"
9249 cp /etc/hosts $remote_dir/$tfile
9251 fid=$($LFS path2fid $remote_dir/$tfile)
9253 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9255 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9256 error "dot lustre permission check $fid failed"
9259 run_test 154b "Open-by-FID for remote directory"
9262 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9263 skip "Need MDS version at least 2.4.1" && return
9265 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9266 local FID1=$($LFS path2fid $DIR/$tfile.1)
9267 local FID2=$($LFS path2fid $DIR/$tfile.2)
9268 local FID3=$($LFS path2fid $DIR/$tfile.3)
9271 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9272 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9273 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9275 [ "$FID" = "${!want}" ] ||
9276 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9280 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9281 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9282 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9286 run_test 154c "lfs path2fid and fid2path multiple arguments"
9289 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9290 skip "Need MDS version at least 2.5.53" && return
9293 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9297 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9304 fid=$($LFS path2fid $DIR/$tfile)
9307 cmd="exec $fd<$DIR/$tfile"
9309 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9310 echo $fid_list | grep $fid
9313 cmd="exec $fd>/dev/null"
9315 if [ $rc -ne 0 ]; then
9316 error "FID $fid not found in open files list $fid_list"
9319 run_test 154d "Verify open file fid"
9321 test_155_small_load() {
9322 local temp=$TMP/$tfile
9323 local file=$DIR/$tfile
9325 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9326 error "dd of=$temp bs=6096 count=1 failed"
9328 cancel_lru_locks osc
9329 cmp $temp $file || error "$temp $file differ"
9331 $TRUNCATE $temp 6000
9332 $TRUNCATE $file 6000
9333 cmp $temp $file || error "$temp $file differ (truncate1)"
9335 echo "12345" >>$temp
9336 echo "12345" >>$file
9337 cmp $temp $file || error "$temp $file differ (append1)"
9339 echo "12345" >>$temp
9340 echo "12345" >>$file
9341 cmp $temp $file || error "$temp $file differ (append2)"
9347 test_155_big_load() {
9348 remote_ost_nodsh && skip "remote OST with nodsh" && return
9349 local temp=$TMP/$tfile
9350 local file=$DIR/$tfile
9353 local cache_size=$(do_facet ost$((MAXI+1)) \
9354 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9355 local large_file_size=$((cache_size * 2))
9357 echo "OSS cache size: $cache_size KB"
9358 echo "Large file size: $large_file_size KB"
9360 [ $MAXV -le $large_file_size ] && \
9361 skip_env "max available OST size needs > $large_file_size KB" && \
9364 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9366 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9367 error "dd of=$temp bs=$large_file_size count=1k failed"
9370 cancel_lru_locks osc
9371 cmp $temp $file || error "$temp $file differ"
9378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9380 set_cache writethrough on
9383 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9388 set_cache writethrough off
9391 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9396 set_cache writethrough on
9399 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9404 set_cache writethrough off
9407 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9410 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9412 set_cache writethrough on
9415 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9420 set_cache writethrough off
9423 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9428 set_cache writethrough on
9431 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9436 set_cache writethrough off
9439 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9446 local file="$DIR/$tfile"
9448 [ "$(facet_fstype ost1)" = "zfs" ] &&
9449 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9454 log "Turn on read and write cache"
9456 set_cache writethrough on
9458 log "Write data and read it back."
9459 log "Read should be satisfied from the cache."
9460 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9462 cancel_lru_locks osc
9463 cat $file >/dev/null
9465 if ! let "AFTER - BEFORE == CPAGES"; then
9466 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9468 log "cache hits:: before: $BEFORE, after: $AFTER"
9471 log "Read again; it should be satisfied from the cache."
9473 cancel_lru_locks osc
9474 cat $file >/dev/null
9476 if ! let "AFTER - BEFORE == CPAGES"; then
9477 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9479 log "cache hits:: before: $BEFORE, after: $AFTER"
9483 log "Turn off the read cache and turn on the write cache"
9485 set_cache writethrough on
9487 log "Read again; it should be satisfied from the cache."
9489 cancel_lru_locks osc
9490 cat $file >/dev/null
9492 if ! let "AFTER - BEFORE == CPAGES"; then
9493 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9495 log "cache hits:: before: $BEFORE, after: $AFTER"
9498 log "Read again; it should not be satisfied from the cache."
9500 cancel_lru_locks osc
9501 cat $file >/dev/null
9503 if ! let "AFTER - BEFORE == 0"; then
9504 error "IN CACHE: before: $BEFORE, after: $AFTER"
9506 log "cache hits:: before: $BEFORE, after: $AFTER"
9509 log "Write data and read it back."
9510 log "Read should be satisfied from the cache."
9511 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9513 cancel_lru_locks osc
9514 cat $file >/dev/null
9516 if ! let "AFTER - BEFORE == CPAGES"; then
9517 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9519 log "cache hits:: before: $BEFORE, after: $AFTER"
9522 log "Read again; it should not be satisfied from the cache."
9524 cancel_lru_locks osc
9525 cat $file >/dev/null
9527 if ! let "AFTER - BEFORE == 0"; then
9528 error "IN CACHE: before: $BEFORE, after: $AFTER"
9530 log "cache hits:: before: $BEFORE, after: $AFTER"
9534 log "Turn off read and write cache"
9536 set_cache writethrough off
9538 log "Write data and read it back"
9539 log "It should not be satisfied from the cache."
9541 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9542 cancel_lru_locks osc
9544 cat $file >/dev/null
9546 if ! let "AFTER - BEFORE == 0"; then
9547 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9549 log "cache hits:: before: $BEFORE, after: $AFTER"
9552 log "Turn on the read cache and turn off the write cache"
9554 set_cache writethrough off
9556 log "Write data and read it back"
9557 log "It should not be satisfied from the cache."
9559 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9561 cancel_lru_locks osc
9562 cat $file >/dev/null
9564 if ! let "AFTER - BEFORE == 0"; then
9565 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9567 log "cache hits:: before: $BEFORE, after: $AFTER"
9570 log "Read again; it should be satisfied from the cache."
9572 cancel_lru_locks osc
9573 cat $file >/dev/null
9575 if ! let "AFTER - BEFORE == CPAGES"; then
9576 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9578 log "cache hits:: before: $BEFORE, after: $AFTER"
9583 run_test 156 "Verification of tunables ============================"
9587 if [ $MDSCOUNT -gt 1 ]; then
9588 error_ignore bz17935 $*
9596 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9598 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9600 if [ $MASK -eq 1 ]; then
9601 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9603 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9607 changelog_extract_field() {
9613 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9614 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9619 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9620 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9621 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9622 { skip "Need MDS version at least 2.2.0"; return; }
9624 local CL_USERS="mdd.$MDT0.changelog_users"
9625 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9626 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9627 echo "Registered as changelog user $USER"
9628 $GET_CL_USERS | grep -q $USER ||
9629 error "User $USER not found in changelog_users"
9632 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9633 touch $DIR/$tdir/pics/2008/zachy/timestamp
9634 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9635 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9636 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9637 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9638 rm $DIR/$tdir/pics/desktop.jpg
9640 $LFS changelog $MDT0 | tail -5
9642 echo "verifying changelog mask"
9643 changelog_chmask "MKDIR"
9644 changelog_chmask "CLOSE"
9646 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9647 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9649 changelog_chmask "MKDIR"
9650 changelog_chmask "CLOSE"
9652 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9653 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9655 $LFS changelog $MDT0
9656 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9657 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9658 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9659 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9662 echo "verifying target fid"
9663 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9664 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9665 [ "$fidc" == "$fidf" ] ||
9666 err17935 "fid in changelog $fidc != file fid $fidf"
9667 echo "verifying parent fid"
9668 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9669 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9670 [ "$fidc" == "$fidf" ] ||
9671 err17935 "pfid in changelog $fidc != dir fid $fidf"
9673 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9674 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9675 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9676 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9677 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9678 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9680 MIN_REC=$($GET_CL_USERS |
9681 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9682 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9683 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9684 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9685 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9687 # LU-3446 changelog index reset on MDT restart
9688 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9689 CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9690 $LFS changelog_clear $MDT0 $USER 0
9691 stop $SINGLEMDS || error "Fail to stop MDT."
9692 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9693 CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9694 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9695 [ $CUR_REC1 == $CUR_REC2 ] ||
9696 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9698 echo "verifying user deregister"
9699 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9700 $GET_CL_USERS | grep -q $USER &&
9701 error "User $USER still in changelog_users"
9703 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9704 if [ $USERS -eq 0 ]; then
9705 LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9706 touch $DIR/$tdir/chloe
9707 LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9708 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9709 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9711 echo "$USERS other changelog users; can't verify off"
9714 run_test 160a "changelog sanity"
9716 test_160b() { # LU-3587
9717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9718 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9719 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9720 { skip "Need MDS version at least 2.2.0"; return; }
9722 local CL_USERS="mdd.$MDT0.changelog_users"
9723 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9724 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9725 echo "Registered as changelog user $USER"
9726 $GET_CL_USERS | grep -q $USER ||
9727 error "User $USER not found in changelog_users"
9729 local LONGNAME1=$(str_repeat a 255)
9730 local LONGNAME2=$(str_repeat b 255)
9733 echo "creating very long named file"
9734 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9735 echo "moving very long named file"
9736 mv $LONGNAME1 $LONGNAME2
9738 $LFS changelog $MDT0 | grep RENME
9740 echo "deregistering $USER"
9741 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9745 run_test 160b "Verify that very long rename doesn't crash in changelog"
9748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9749 test_mkdir -p -c1 $DIR/$tdir
9750 cp /etc/hosts $DIR/$tdir/$tfile
9751 test_mkdir -c1 $DIR/$tdir/foo1
9752 test_mkdir -c1 $DIR/$tdir/foo2
9753 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9754 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9755 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9756 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9757 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9758 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9759 $LFS fid2path $DIR $FID
9760 err17935 "bad link ea"
9763 rm $DIR/$tdir/foo2/zachary
9765 rm $DIR/$tdir/foo2/thor
9767 rm $DIR/$tdir/$tfile
9769 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9770 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9772 $LFS fid2path $DIR $FID
9773 err17935 "bad link rename"
9775 rm $DIR/$tdir/foo2/maggie
9778 local longname=filename_avg_len_is_thirty_two_
9779 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9780 error "failed to hardlink many files"
9781 links=$($LFS fid2path $DIR $FID | wc -l)
9782 echo -n "${links}/1000 links in link EA"
9783 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9784 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9785 error "failed to unlink many hardlinks"
9787 run_test 161a "link ea sanity"
9790 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9791 [ $MDSCOUNT -lt 2 ] &&
9792 skip "skipping remote directory test" && return
9794 local remote_dir=$DIR/$tdir/remote_dir
9797 $LFS mkdir -i $MDTIDX $remote_dir ||
9798 error "create remote directory failed"
9800 cp /etc/hosts $remote_dir/$tfile
9801 mkdir -p $remote_dir/foo1
9802 mkdir -p $remote_dir/foo2
9803 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9804 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9805 ln $remote_dir/$tfile $remote_dir/foo1/luna
9806 ln $remote_dir/$tfile $remote_dir/foo2/thor
9808 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9810 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9811 $LFS fid2path $DIR $FID
9812 err17935 "bad link ea"
9815 rm $remote_dir/foo2/zachary
9817 rm $remote_dir/foo2/thor
9819 rm $remote_dir/$tfile
9821 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9822 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9823 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9824 $LFS fid2path $DIR $FID
9825 err17935 "bad link rename"
9827 rm $remote_dir/foo2/maggie
9830 local longname=filename_avg_len_is_thirty_two_
9831 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9832 error "failed to hardlink many files"
9833 links=$($LFS fid2path $DIR $FID | wc -l)
9834 echo -n "${links}/1000 links in link EA"
9835 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9836 unlinkmany $remote_dir/foo2/$longname 1000 ||
9837 error "failed to unlink many hardlinks"
9839 run_test 161b "link ea sanity under remote directory"
9842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9843 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
9844 skip "Need MDS version at least 2.1.5" && return
9846 # define CLF_RENAME_LAST 0x0001
9847 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
9848 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9849 changelog_register -n)
9852 touch $DIR/$tdir/foo_161c
9853 touch $DIR/$tdir/bar_161c
9854 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9855 $LFS changelog $MDT0 | grep RENME
9856 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
9858 $LFS changelog_clear $MDT0 $USER 0
9859 if [ x$flags != "x0x1" ]; then
9860 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9862 error "flag $flags is not 0x1"
9864 echo "rename overwrite a target having nlink = 1," \
9865 "changelog record has flags of $flags"
9867 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
9868 touch $DIR/$tdir/foo_161c
9869 touch $DIR/$tdir/bar_161c
9870 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9871 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9872 $LFS changelog $MDT0 | grep RENME
9873 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9874 $LFS changelog_clear $MDT0 $USER 0
9875 if [ x$flags != "x0x0" ]; then
9876 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9878 error "flag $flags is not 0x0"
9880 echo "rename overwrite a target having nlink > 1," \
9881 "changelog record has flags of $flags"
9883 # rename doesn't overwrite a target (changelog flag 0x0)
9884 touch $DIR/$tdir/foo_161c
9885 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
9886 $LFS changelog $MDT0 | grep RENME
9887 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9888 $LFS changelog_clear $MDT0 $USER 0
9889 if [ x$flags != "x0x0" ]; then
9890 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9892 error "flag $flags is not 0x0"
9894 echo "rename doesn't overwrite a target," \
9895 "changelog record has flags of $flags"
9897 # define CLF_UNLINK_LAST 0x0001
9898 # unlink a file having nlink = 1 (changelog flag 0x1)
9899 rm -f $DIR/$tdir/foo2_161c
9900 $LFS changelog $MDT0 | grep UNLNK
9901 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9902 $LFS changelog_clear $MDT0 $USER 0
9903 if [ x$flags != "x0x1" ]; then
9904 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9906 error "flag $flags is not 0x1"
9908 echo "unlink a file having nlink = 1," \
9909 "changelog record has flags of $flags"
9911 # unlink a file having nlink > 1 (changelog flag 0x0)
9912 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9913 rm -f $DIR/$tdir/foobar_161c
9914 $LFS changelog $MDT0 | grep UNLNK
9915 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9916 $LFS changelog_clear $MDT0 $USER 0
9917 if [ x$flags != "x0x0" ]; then
9918 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9920 error "flag $flags is not 0x0"
9922 echo "unlink a file having nlink > 1," \
9923 "changelog record has flags of $flags"
9924 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9926 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
9933 local path=$(${LFS} fid2path $*)
9936 if [ $RC -ne 0 ]; then
9937 err17935 "path looked up of $expected failed. Error $RC"
9939 elif [ "${path}" != "${expected}" ]; then
9940 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9943 echo "fid $fid resolves to path $path (expected $expected)"
9947 # Make changes to filesystem
9948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9949 test_mkdir -p $DIR/$tdir/d2
9950 touch $DIR/$tdir/d2/$tfile
9951 touch $DIR/$tdir/d2/x1
9952 touch $DIR/$tdir/d2/x2
9953 test_mkdir -p $DIR/$tdir/d2/a/b/c
9954 test_mkdir -p $DIR/$tdir/d2/p/q/r
9956 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9957 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9960 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9961 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9962 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9964 # softlink to wrong file
9965 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9966 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9967 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9970 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9971 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9972 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9973 # fid2path dir/fsname should both work
9974 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9975 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9977 # hardlink count: check that there are 2 links
9978 # Doesnt work with CMD yet: 17935
9979 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9980 err17935 "expected 2 links"
9982 # hardlink indexing: remove the first link
9983 rm $DIR/$tdir/d2/p/q/r/hlink
9984 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9988 run_test 162 "path lookup sanity"
9991 # do directio so as not to populate the page cache
9992 log "creating a 10 Mb file"
9993 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9994 log "starting reads"
9995 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9996 log "truncating the file"
9997 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9999 kill %+ || true # reads might have finished
10000 echo "wait until dd is finished"
10002 log "removing the temporary file"
10003 rm -rf $DIR/$tfile || error "tmp file removal failed"
10005 run_test 169 "parallel read and truncate should not deadlock"
10008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10009 $LCTL clear # bug 18514
10010 $LCTL debug_daemon start $TMP/${tfile}_log_good
10012 $LCTL debug_daemon stop
10013 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10014 error "sed failed to read log_good"
10016 $LCTL debug_daemon start $TMP/${tfile}_log_good
10018 $LCTL debug_daemon stop
10020 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10021 error "lctl df log_bad failed"
10023 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10024 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10026 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10027 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10029 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10030 error "bad_line good_line1 good_line2 are empty"
10032 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10033 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10034 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10036 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10037 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10038 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10040 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10041 error "bad_line_new good_line_new are empty"
10043 local expected_good=$((good_line1 + good_line2*2))
10045 rm -f $TMP/${tfile}*
10046 # LU-231, short malformed line may not be counted into bad lines
10047 if [ $bad_line -ne $bad_line_new ] &&
10048 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10049 error "expected $bad_line bad lines, but got $bad_line_new"
10053 if [ $expected_good -ne $good_line_new ]; then
10054 error "expected $expected_good good lines, but got $good_line_new"
10059 run_test 170 "test lctl df to handle corrupted log ====================="
10061 test_171() { # bug20592
10062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10063 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10064 $LCTL set_param fail_loc=0x50e
10065 $LCTL set_param fail_val=3000
10066 multiop_bg_pause $DIR/$tfile O_s || true
10068 kill -USR1 $MULTIPID
10072 if dmesg | grep "recursive fault"; then
10073 error "caught a recursive fault"
10075 $LCTL set_param fail_loc=0
10078 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10080 # it would be good to share it with obdfilter-survey/libecho code
10081 setup_obdecho_osc () {
10084 local obdfilter_name=$2
10085 echo "Creating new osc for $obdfilter_name on $ost_nid"
10086 # make sure we can find loopback nid
10087 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10089 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10090 ${obdfilter_name}_osc_UUID || rc=2; }
10091 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10092 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10096 cleanup_obdecho_osc () {
10097 local obdfilter_name=$1
10098 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10099 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10106 local pages=${3:-64}
10111 local obd_size=$(get_obd_size $node $OBD)
10112 local page_size=$(get_page_size $node)
10113 if [[ -n "$obd_size" ]]; then
10114 local new_count=$((obd_size / (pages * page_size / 1024)))
10115 [[ $new_count -ge $count ]] || count=$new_count
10118 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10119 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10121 if [ $rc -eq 0 ]; then
10122 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10123 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10125 echo "New object id is $id"
10126 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10128 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10129 "test_brw $count w v $pages $id" || rc=4; }
10130 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10132 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10133 "cleanup" || rc=5; }
10134 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10135 "detach" || rc=6; }
10136 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10142 remote_ost_nodsh && skip "remote OST with nodsh" && return
10144 local rmmod_local=0
10146 if ! module_loaded obdecho; then
10147 load_module obdecho/obdecho
10151 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10152 local host=$(lctl get_param -n osc.$osc.import |
10153 awk '/current_connection:/ {print $2}' )
10154 local target=$(lctl get_param -n osc.$osc.import |
10155 awk '/target:/ {print $2}' )
10156 target=${target%_UUID}
10158 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10159 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10160 [[ -n $target ]] && cleanup_obdecho_osc $target
10161 [ $rmmod_local -eq 1 ] && rmmod obdecho
10164 run_test 180a "test obdecho on osc"
10167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10168 remote_ost_nodsh && skip "remote OST with nodsh" && return
10170 local rmmod_remote=0
10172 do_facet ost1 "lsmod | grep -q obdecho || " \
10173 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10174 "modprobe obdecho; }" && rmmod_remote=1
10175 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10176 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10177 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10180 run_test 180b "test obdecho directly on obdfilter"
10182 test_180c() { # LU-2598
10183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10184 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10185 skip "Need MDS version at least 2.4.0" && return
10188 local rmmod_remote=false
10189 local pages=16384 # 64MB bulk I/O RPC size
10192 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10193 rmmod_remote=true || error "failed to load module obdecho"
10195 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4}'|head -1)
10196 if [[ -n $target ]]; then
10197 obdecho_test "$target" ost1 "$pages" ||
10198 rc=${PIPESTATUS[0]}
10200 echo "there is no obdfilter target on ost1"
10203 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10206 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10208 test_181() { # bug 22177
10209 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10210 # create enough files to index the directory
10211 createmany -o $DIR/$tdir/foobar 4000
10212 # print attributes for debug purpose
10215 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10217 # remove the files & current working dir
10218 unlinkmany $DIR/$tdir/foobar 4000
10220 kill -USR1 $MULTIPID
10222 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10225 run_test 181 "Test open-unlinked dir ========================"
10228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10229 # disable MDC RPC lock wouldn't crash client
10233 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10234 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10235 $LCTL set_param fail_loc=0x804
10237 for (( i=0; i < $tcount; i++ )) ; do
10238 mkdir $DIR/$tdir/$i
10239 createmany -o $DIR/$tdir/$i/f- $fcount &
10243 for (( i=0; i < $tcount; i++ )) ; do
10244 unlinkmany $DIR/$tdir/$i/f- $fcount &
10250 $LCTL set_param fail_loc=0
10252 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10254 test_183() { # LU-2275
10255 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10256 skip "Need MDS version at least 2.3.56" && return
10258 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10259 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10260 echo aaa > $DIR/$tdir/$tfile
10262 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10263 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10265 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10266 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10268 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10270 # Flush negative dentry cache
10271 touch $DIR/$tdir/$tfile
10273 # We are not checking for any leaked references here, they'll
10274 # become evident next time we do cleanup with module unload.
10277 run_test 183 "No crash or request leak in case of strange dispositions ========"
10279 # test suite 184 is for LU-2016, LU-2017
10281 check_swap_layouts_support && return 0
10283 dir0=$DIR/$tdir/$testnum
10284 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10289 $SETSTRIPE -c1 $file1
10291 $SETSTRIPE -c2 $file2
10293 gen1=$($GETSTRIPE -g $file1)
10294 gen2=$($GETSTRIPE -g $file2)
10296 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10297 gen=$($GETSTRIPE -g $file1)
10298 [[ $gen1 != $gen ]] ||
10299 "Layout generation on $file1 does not change"
10300 gen=$($GETSTRIPE -g $file2)
10301 [[ $gen2 != $gen ]] ||
10302 "Layout generation on $file2 does not change"
10304 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10305 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10307 run_test 184a "Basic layout swap"
10310 check_swap_layouts_support && return 0
10312 dir0=$DIR/$tdir/$testnum
10313 mkdir -p $dir0 || error "creating dir $dir0"
10320 $SETSTRIPE -c1 $file1
10321 $SETSTRIPE -c2 $file2
10322 $SETSTRIPE -c1 $file3
10323 chown $RUNAS_ID $file3
10324 gen1=$($GETSTRIPE -g $file1)
10325 gen2=$($GETSTRIPE -g $file2)
10327 $LFS swap_layouts $dir1 $dir2 &&
10328 error "swap of directories layouts should fail"
10329 $LFS swap_layouts $dir1 $file1 &&
10330 error "swap of directory and file layouts should fail"
10331 $RUNAS $LFS swap_layouts $file1 $file2 &&
10332 error "swap of file we cannot write should fail"
10333 $LFS swap_layouts $file1 $file3 &&
10334 error "swap of file with different owner should fail"
10335 /bin/true # to clear error code
10337 run_test 184b "Forbidden layout swap (will generate errors)"
10340 check_swap_layouts_support && return 0
10342 local dir0=$DIR/$tdir/$testnum
10343 mkdir -p $dir0 || error "creating dir $dir0"
10345 local ref1=$dir0/ref1
10346 local ref2=$dir0/ref2
10347 local file1=$dir0/file1
10348 local file2=$dir0/file2
10349 # create a file large enough for the concurent test
10350 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10351 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10352 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
10355 dd if=$ref1 of=$file1 bs=16k &
10358 # Make sure dd starts to copy file
10359 while [ ! -f $file1 ]; do sleep 0.1; done
10361 $LFS swap_layouts $file1 $file2
10364 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10365 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10367 # how many bytes copied before swapping layout
10368 local copied=`stat -c %s $file2`
10369 local remaining=`stat -c %s $ref1`
10370 remaining=$((remaining - copied))
10371 echo "Copied $copied bytes before swapping layout..."
10373 cmp -n $copied $file1 $ref2 | grep differ &&
10374 error "Content mismatch [0, $copied) of ref2 and file1"
10375 cmp -n $copied $file2 $ref1 ||
10376 error "Content mismatch [0, $copied) of ref1 and file2"
10377 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10378 error "Content mismatch [$copied, EOF) of ref1 and file1"
10381 rm -f $ref1 $ref2 $file1 $file2
10383 run_test 184c "Concurrent write and layout swap"
10386 check_swap_layouts_support && return 0
10388 local file1=$DIR/$tdir/$tfile-1
10389 local file2=$DIR/$tdir/$tfile-2
10390 local file3=$DIR/$tdir/$tfile-3
10394 mkdir -p $DIR/$tdir
10395 touch $file1 || error "create $file1 failed"
10396 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10397 error "create $file2 failed"
10398 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10399 error "create $file3 failed"
10400 lovea1=$($LFS getstripe $file1 | sed 1d)
10402 $LFS swap_layouts $file2 $file3 ||
10403 error "swap $file2 $file3 layouts failed"
10404 $LFS swap_layouts $file1 $file2 ||
10405 error "swap $file1 $file2 layouts failed"
10407 lovea2=$($LFS getstripe $file2 | sed 1d)
10408 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10410 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10411 [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
10413 run_test 184d "allow stripeless layouts swap"
10416 test_185() { # LU-2441
10417 # LU-3553 - no volatile file support in old servers
10418 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10419 { skip "Need MDS version at least 2.3.60"; return 0; }
10421 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10422 touch $DIR/$tdir/spoo
10423 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10424 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10425 error "cannot create/write a volatile file"
10426 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10427 error "FID is still valid after close"
10429 multiop_bg_pause $DIR/$tdir vVw4096_c
10436 # assume that the next FID for this client is sequential, since stdout
10437 # is unfortunately eaten by multiop_bg_pause
10438 local n=$((${fidv[1]} + 1))
10439 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10440 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10441 error "FID is missing before close"
10442 kill -USR1 $multi_pid
10443 # 1 second delay, so if mtime change we will see it
10445 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10446 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10448 run_test 185 "Volatile file support"
10451 local dir0=$DIR/$tdir/$testnum
10452 mkdir -p $dir0 || error "creating dir $dir0"
10454 local file=$dir0/file1
10455 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10456 local dv1=$($LFS data_version $file)
10457 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10458 local dv2=$($LFS data_version $file)
10459 [[ $dv1 != $dv2 ]] ||
10460 error "data version did not change on write $dv1 == $dv2"
10465 run_test 187a "Test data version change"
10468 local dir0=$DIR/$tdir/$testnum
10469 mkdir -p $dir0 || error "creating dir $dir0"
10471 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10472 [[ ${DV[0]} != ${DV[1]} ]] ||
10473 error "data version did not change on write"\
10474 " ${DV[0]} == ${DV[1]}"
10479 run_test 187b "Test data version change on volatile file"
10482 check_file_in_pool()
10487 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10490 for t in $tlist ; do
10491 [ "$i" -eq "$t" ] && continue 2
10494 echo "pool list: $tlist"
10495 echo "striping: $res"
10496 error_noexit "$file not allocated in $pool"
10503 echo "Creating new pool"
10506 create_pool $FSNAME.$pool ||
10507 { error_noexit "No pool created, result code $?"; return 1; }
10508 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10509 { error_noexit "$pool not in lfs pool_list"; return 2; }
10512 pool_add_targets() {
10513 echo "Adding targets to pool"
10519 local list=$(seq $first $step $last)
10521 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10522 do_facet mgs $LCTL pool_add \
10523 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10524 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10525 | sort -u | tr '\n' ' ' " "$t" || {
10526 error_noexit "Add to pool failed"
10529 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10530 local addcount=$(((last - first) / step + 1))
10531 [ $lfscount -eq $addcount ] || {
10532 error_noexit "lfs pool_list bad ost count" \
10533 "$lfscount != $addcount"
10541 echo "Setting pool on directory $tdir"
10543 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10545 error_noexit "Cannot set pool $pool to $tdir"
10552 echo "Checking pool on directory $tdir"
10554 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10555 [ "$res" = "$pool" ] && return 0
10557 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10561 pool_dir_rel_path() {
10562 echo "Testing relative path works well"
10567 mkdir -p $root/$tdir/$tdir
10569 pool_set_dir $pool $tdir || return 1
10570 pool_set_dir $pool ./$tdir || return 2
10571 pool_set_dir $pool ../$tdir || return 3
10572 pool_set_dir $pool ../$tdir/$tdir || return 4
10573 rm -rf $tdir; cd - > /dev/null
10576 pool_alloc_files() {
10577 echo "Checking files allocation from directory pool"
10584 for i in $(seq -w 1 $count)
10586 local file=$tdir/file-$i
10588 check_file_in_pool $file $pool "$tlist" || \
10589 failed=$((failed + 1))
10591 [ "$failed" = 0 ] && return 0
10593 error_noexit "$failed files not allocated in $pool"
10597 pool_create_files() {
10598 echo "Creating files in pool"
10606 for i in $(seq -w 1 $count)
10608 local file=$tdir/spoo-$i
10609 $SETSTRIPE -p $pool $file
10610 check_file_in_pool $file $pool "$tlist" || \
10611 failed=$((failed + 1))
10613 [ "$failed" = 0 ] && return 0
10615 error_noexit "$failed files not allocated in $pool"
10620 echo "Checking 'lfs df' output"
10623 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10625 local res=$($LFS df --pool $FSNAME.$pool |
10627 grep "$FSNAME-OST" |
10629 [ "$res" = "$t" ] && return 0
10631 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10635 pool_file_rel_path() {
10636 echo "Creating files in a pool with relative pathname"
10641 { error_noexit "unable to create $tdir"; return 1 ; }
10642 local file="/..$tdir/$tfile-1"
10643 $SETSTRIPE -p $pool $file ||
10644 { error_noexit "unable to create $file" ; return 2 ; }
10647 $SETSTRIPE -p $pool $tfile-2 || {
10648 error_noexit "unable to create $tfile-2 in $tdir"
10653 pool_remove_first_target() {
10654 echo "Removing first target from a pool"
10657 local pname="lov.$FSNAME-*.pools.$pool"
10658 local t=$($LCTL get_param -n $pname | head -1)
10659 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10660 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10661 error_noexit "$t not removed from $FSNAME.$pool"
10666 pool_remove_all_targets() {
10667 echo "Removing all targets from pool"
10670 local pname="lov.$FSNAME-*.pools.$pool"
10671 for t in $($LCTL get_param -n $pname | sort -u)
10673 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10675 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10676 error_noexit "Pool $FSNAME.$pool cannot be drained"
10679 # striping on an empty/nonexistant pool should fall back
10680 # to "pool of everything"
10682 error_noexit "failed to use fallback striping for empty pool"
10685 # setstripe on an empty pool should fail
10686 $SETSTRIPE -p $pool $file 2>/dev/null && {
10687 error_noexit "expected failure when creating file" \
10695 echo "Destroying pool"
10699 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10702 # striping on an empty/nonexistant pool should fall back
10703 # to "pool of everything"
10705 error_noexit "failed to use fallback striping for missing pool"
10708 # setstripe on an empty pool should fail
10709 $SETSTRIPE -p $pool $file 2>/dev/null && {
10710 error_noexit "expected failure when creating file" \
10711 "with missing pool"
10715 # get param should return err once pool is gone
10716 if wait_update $HOSTNAME "lctl get_param -n \
10717 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10719 remove_pool_from_list $FSNAME.$pool
10722 error_noexit "Pool $FSNAME.$pool is not destroyed"
10727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10728 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10730 local POOL=${POOL:-cea1}
10731 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10732 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10735 local last_ost=$(($OSTCOUNT - 1))
10737 local ost_list=$(seq $first_ost $ost_step $last_ost)
10738 local ost_range="$first_ost $last_ost $ost_step"
10739 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10740 local file_dir=$POOL_ROOT/file_tst
10744 # former test_200a test_200b
10745 pool_add $POOL || { rc=$? ; break; }
10746 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10747 # former test_200c test_200d
10748 mkdir -p $test_path
10749 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10750 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10751 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10752 || { rc=$? ; break; }
10753 # former test_200e test_200f
10754 local files=$((OSTCOUNT*3))
10755 pool_alloc_files $POOL $test_path $files "$ost_list" \
10756 || { rc=$? ; break; }
10757 pool_create_files $POOL $file_dir $files "$ost_list" \
10758 || { rc=$? ; break; }
10759 # former test_200g test_200h
10760 pool_lfs_df $POOL || { rc=$? ; break; }
10761 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10763 # former test_201a test_201b test_201c
10764 pool_remove_first_target $POOL || { rc=$? ; break; }
10766 local f=$test_path/$tfile
10767 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10768 pool_remove $POOL $f || { rc=$? ; break; }
10775 run_test 200 "OST pools"
10777 # usage: default_attr <count | size | offset>
10779 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10782 # usage: check_default_stripe_attr
10783 check_default_stripe_attr() {
10784 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10786 --stripe-count|--count)
10787 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10788 --stripe-size|--size)
10789 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10790 --stripe-index|--index)
10793 error "unknown getstripe attr '$1'"
10796 [ $ACTUAL != $EXPECTED ] &&
10797 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10801 test_mkdir -p $DIR/$tdir
10802 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10804 check_default_stripe_attr --stripe-count
10805 check_default_stripe_attr --stripe-size
10806 check_default_stripe_attr --stripe-index
10810 run_test 204a "Print default stripe attributes ================="
10813 test_mkdir -p $DIR/$tdir
10814 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10816 check_default_stripe_attr --stripe-size
10817 check_default_stripe_attr --stripe-index
10821 run_test 204b "Print default stripe size and offset ==========="
10824 test_mkdir -p $DIR/$tdir
10825 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10827 check_default_stripe_attr --stripe-count
10828 check_default_stripe_attr --stripe-index
10832 run_test 204c "Print default stripe count and offset ==========="
10835 test_mkdir -p $DIR/$tdir
10836 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10838 check_default_stripe_attr --stripe-count
10839 check_default_stripe_attr --stripe-size
10843 run_test 204d "Print default stripe count and size ============="
10846 test_mkdir -p $DIR/$tdir
10847 $SETSTRIPE -d $DIR/$tdir
10849 check_default_stripe_attr --stripe-count --raw
10850 check_default_stripe_attr --stripe-size --raw
10851 check_default_stripe_attr --stripe-index --raw
10855 run_test 204e "Print raw stripe attributes ================="
10858 test_mkdir -p $DIR/$tdir
10859 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10861 check_default_stripe_attr --stripe-size --raw
10862 check_default_stripe_attr --stripe-index --raw
10866 run_test 204f "Print raw stripe size and offset ==========="
10869 test_mkdir -p $DIR/$tdir
10870 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10872 check_default_stripe_attr --stripe-count --raw
10873 check_default_stripe_attr --stripe-index --raw
10877 run_test 204g "Print raw stripe count and offset ==========="
10880 test_mkdir -p $DIR/$tdir
10881 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10883 check_default_stripe_attr --stripe-count --raw
10884 check_default_stripe_attr --stripe-size --raw
10888 run_test 204h "Print raw stripe count and size ============="
10890 # Figure out which job scheduler is being used, if any,
10891 # or use a fake one
10892 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10893 JOBENV=SLURM_JOB_ID
10894 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10896 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10898 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10899 JOBENV=LOADL_STEP_ID
10900 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10906 verify_jobstats() {
10910 # clear old jobstats
10911 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10912 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10914 # use a new JobID for this test, or we might see an old one
10915 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10919 log "Using JobID environment variable $JOBENV=$JOBVAL"
10921 if [ $JOBENV = "FAKE_JOBID" ]; then
10922 FAKE_JOBID=$JOBVAL $cmd
10927 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10928 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10929 do_facet $FACET lctl get_param mdt.*.job_stats |
10930 grep $JOBVAL || error "No job stats found on MDT $FACET"
10932 if [ "$target" = "ost" -o "$target" = "both" ]; then
10934 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10935 grep $JOBVAL || error "No job stats found on OST $FACET"
10941 NEW_JOBENV=${1:-$OLD_JOBENV}
10942 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10943 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10946 test_205() { # Job stats
10947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10948 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10949 skip "Server doesn't support jobstats" && return 0
10952 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10953 if [ $OLD_JOBENV != $JOBENV ]; then
10954 jobstats_set $JOBENV
10955 trap jobstats_set EXIT
10959 cmd="mkdir $DIR/$tfile"
10960 verify_jobstats "$cmd" "mdt"
10962 cmd="rm -fr $DIR/$tfile"
10963 verify_jobstats "$cmd" "mdt"
10965 cmd="mknod $DIR/$tfile c 1 3"
10966 verify_jobstats "$cmd" "mdt"
10968 cmd="rm -f $DIR/$tfile"
10969 verify_jobstats "$cmd" "mdt"
10971 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10972 verify_jobstats "$cmd" "mdt"
10974 cmd="touch $DIR/$tfile"
10975 verify_jobstats "$cmd" "both"
10977 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10978 verify_jobstats "$cmd" "ost"
10980 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10981 verify_jobstats "$cmd" "ost"
10983 cmd="$TRUNCATE $DIR/$tfile 0"
10984 verify_jobstats "$cmd" "both"
10986 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10987 verify_jobstats "$cmd" "mdt"
10990 rm -f $DIR/jobstats_test_rename
10992 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10994 run_test 205 "Verify job stats"
10996 # LU-1480, LU-1773 and LU-1657
10998 mkdir -p $DIR/$tdir
10999 lfs setstripe -c -1 $DIR/$tdir
11000 #define OBD_FAIL_LOV_INIT 0x1403
11001 $LCTL set_param fail_loc=0xa0001403
11002 $LCTL set_param fail_val=1
11003 touch $DIR/$tdir/$tfile || true
11005 run_test 206 "fail lov_init_raid0() doesn't lbug"
11008 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11009 local fsz=`stat -c %s $DIR/$tfile`
11010 cancel_lru_locks mdc
11012 # do not return layout in getattr intent
11013 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11014 $LCTL set_param fail_loc=0x170
11015 local sz=`stat -c %s $DIR/$tfile`
11017 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11021 run_test 207a "can refresh layout at glimpse"
11024 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11025 local cksum=`md5sum $DIR/$tfile`
11026 local fsz=`stat -c %s $DIR/$tfile`
11027 cancel_lru_locks mdc
11028 cancel_lru_locks osc
11030 # do not return layout in getattr intent
11031 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11032 $LCTL set_param fail_loc=0x171
11034 # it will refresh layout after the file is opened but before read issues
11035 echo checksum is "$cksum"
11036 echo "$cksum" |md5sum -c --quiet || error "file differs"
11040 run_test 207b "can refresh layout at open"
11043 # FIXME: in this test suite, only RD lease is used. This is okay
11044 # for now as only exclusive open is supported. After generic lease
11045 # is done, this test suite should be revised. - Jinshan
11047 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11048 { skip "Need MDS version at least 2.4.52"; return 0; }
11050 echo "==== test 1: verify get lease work"
11051 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11053 echo "==== test 2: verify lease can be broken by upcoming open"
11054 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11058 $MULTIOP $DIR/$tfile oO_RDONLY:c
11059 kill -USR1 $PID && wait $PID || error "break lease error"
11061 echo "==== test 3: verify lease can't be granted if an open already exists"
11062 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11066 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11067 kill -USR1 $PID && wait $PID || error "open file error"
11069 echo "==== test 4: lease can sustain over recovery"
11070 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11076 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11078 echo "==== test 5: lease broken can't be regained by replay"
11079 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11083 # open file to break lease and then recovery
11084 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11087 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11091 run_test 208 "Exclusive open"
11094 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11095 skip_env "must have disp_stripe" && return
11098 sync; sleep 5; sync;
11100 echo 3 > /proc/sys/vm/drop_caches
11101 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11103 # open/close 500 times
11104 for i in $(seq 500); do
11108 echo 3 > /proc/sys/vm/drop_caches
11109 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11111 echo "before: $req_before, after: $req_after"
11112 [ $((req_after - req_before)) -ge 300 ] &&
11113 error "open/close requests are not freed"
11116 run_test 209 "read-only open/close requests should be freed promptly"
11120 size=$((size % 8192 + 1))
11121 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11122 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11123 rm -f $DIR/f212 $DIR/f212.xyz
11125 run_test 212 "Sendfile test ============================================"
11128 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11129 cancel_lru_locks osc
11130 lctl set_param fail_loc=0x8000040f
11131 # generate a read lock
11132 cat $DIR/$tfile > /dev/null
11133 # write to the file, it will try to cancel the above read lock.
11134 cat /etc/hosts >> $DIR/$tfile
11136 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11138 test_214() { # for bug 20133
11139 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11140 for (( i=0; i < 340; i++ )) ; do
11141 touch $DIR/$tdir/d214c/a$i
11144 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11145 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11146 ls $DIR/d214c || error "ls $DIR/d214c failed"
11147 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11148 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11150 run_test 214 "hash-indexed directory test - bug 20133"
11152 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11153 create_lnet_proc_files() {
11154 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11155 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11157 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11158 rm -f "$TMP/lnet_$1.sys_tmp"
11161 # counterpart of create_lnet_proc_files
11162 remove_lnet_proc_files() {
11163 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11166 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11167 # 3rd arg as regexp for body
11168 check_lnet_proc_stats() {
11169 local l=$(cat "$TMP/lnet_$1" |wc -l)
11170 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11172 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11175 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11176 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11177 # optional and can be regexp for 2nd line (lnet.routes case)
11178 check_lnet_proc_entry() {
11179 local blp=2 # blp stands for 'position of 1st line of body'
11180 [ "$5" = "" ] || blp=3 # lnet.routes case
11182 local l=$(cat "$TMP/lnet_$1" |wc -l)
11183 # subtracting one from $blp because the body can be empty
11184 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11186 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11187 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11189 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11190 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11192 # bail out if any unexpected line happened
11193 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
11194 [ "$?" != 0 ] || error "$2 misformatted"
11197 test_215() { # for bugs 18102, 21079, 21517
11198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11199 local N='(0|[1-9][0-9]*)' # non-negative numeric
11200 local P='[1-9][0-9]*' # positive numeric
11201 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11202 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11203 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11204 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11206 local L1 # regexp for 1st line
11207 local L2 # regexp for 2nd line (optional)
11208 local BR # regexp for the rest (body)
11210 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11211 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11212 create_lnet_proc_files "stats"
11213 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11214 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11215 remove_lnet_proc_files "stats"
11217 # /proc/sys/lnet/routes should look like this:
11218 # Routing disabled/enabled
11219 # net hops priority state router
11220 # where net is a string like tcp0, hops > 0, priority >= 0,
11221 # state is up/down,
11222 # router is a string like 192.168.1.1@tcp2
11223 L1="^Routing (disabled|enabled)$"
11224 L2="^net +hops +priority +state +router$"
11225 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11226 create_lnet_proc_files "routes"
11227 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11228 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11229 remove_lnet_proc_files "routes"
11231 # /proc/sys/lnet/routers should look like this:
11232 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11233 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11234 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11235 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11236 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11237 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11238 create_lnet_proc_files "routers"
11239 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11240 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11241 remove_lnet_proc_files "routers"
11243 # /proc/sys/lnet/peers should look like this:
11244 # nid refs state last max rtr min tx min queue
11245 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11246 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11247 # numeric (0 or >0 or <0), queue >= 0.
11248 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11249 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11250 create_lnet_proc_files "peers"
11251 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11252 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11253 remove_lnet_proc_files "peers"
11255 # /proc/sys/lnet/buffers should look like this:
11256 # pages count credits min
11257 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11258 L1="^pages +count +credits +min$"
11259 BR="^ +$N +$N +$I +$I$"
11260 create_lnet_proc_files "buffers"
11261 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11262 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11263 remove_lnet_proc_files "buffers"
11265 # /proc/sys/lnet/nis should look like this:
11266 # nid status alive refs peer rtr max tx min
11267 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11268 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11269 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11270 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11271 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11272 create_lnet_proc_files "nis"
11273 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11274 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11275 remove_lnet_proc_files "nis"
11277 # can we successfully write to /proc/sys/lnet/stats?
11278 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11279 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11281 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11283 test_216() { # bug 20317
11284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11285 remote_ost_nodsh && skip "remote OST with nodsh" && return
11288 local facets=$(get_facets OST)
11289 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11291 save_lustre_params client "osc.*.contention_seconds" > $p
11292 save_lustre_params $facets \
11293 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11294 save_lustre_params $facets \
11295 "ldlm.namespaces.filter-*.contended_locks" >> $p
11296 save_lustre_params $facets \
11297 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11300 # agressive lockless i/o settings
11301 for node in $(osts_nodes); do
11302 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
11304 lctl set_param -n osc.*.contention_seconds 60
11306 $DIRECTIO write $DIR/$tfile 0 10 4096
11307 $CHECKSTAT -s 40960 $DIR/$tfile
11309 # disable lockless i/o
11310 for node in $(osts_nodes); do
11311 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
11313 lctl set_param -n osc.*.contention_seconds 0
11316 dd if=/dev/zero of=$DIR/$tfile count=0
11317 $CHECKSTAT -s 0 $DIR/$tfile
11319 restore_lustre_params <$p
11323 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11325 test_217() { # bug 22430
11326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11330 for node in $(nodes_list); do
11331 nid=$(host_nids_address $node $NETTYPE)
11332 if [[ $nid = *-* ]] ; then
11333 echo "lctl ping $nid@$NETTYPE"
11334 lctl ping $nid@$NETTYPE
11336 echo "skipping $node (no hyphen detected)"
11340 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11343 # do directio so as not to populate the page cache
11344 log "creating a 10 Mb file"
11345 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11346 log "starting reads"
11347 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11348 log "truncating the file"
11349 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11351 kill %+ || true # reads might have finished
11352 echo "wait until dd is finished"
11354 log "removing the temporary file"
11355 rm -rf $DIR/$tfile || error "tmp file removal failed"
11357 run_test 218 "parallel read and truncate should not deadlock ======================="
11360 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11361 # write one partial page
11362 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11363 # set no grant so vvp_io_commit_write will do sync write
11364 $LCTL set_param fail_loc=0x411
11365 # write a full page at the end of file
11366 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11368 $LCTL set_param fail_loc=0
11369 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11370 $LCTL set_param fail_loc=0x411
11371 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11374 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11375 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11377 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11379 test_220() { #LU-325
11380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11381 remote_ost_nodsh && skip "remote OST with nodsh" && return
11384 test_mkdir -p $DIR/$tdir
11385 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11386 awk '{print $2}' | sed -e 's/_UUID$//')
11389 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11390 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11391 osc.$mdtosc_proc1.prealloc_last_id)
11392 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11393 osc.$mdtosc_proc1.prealloc_next_id)
11397 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11398 #define OBD_FAIL_OST_ENOINO 0x229
11399 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11400 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11401 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11403 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11405 MDSOBJS=$((last_id - next_id))
11406 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11408 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11409 echo "OST still has $count kbytes free"
11411 echo "create $MDSOBJS files @next_id..."
11412 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11414 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11415 osc.$mdtosc_proc1.prealloc_last_id)
11416 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11417 osc.$mdtosc_proc1.prealloc_next_id)
11419 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11424 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11425 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11427 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11428 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11429 echo "unlink $MDSOBJS files @$next_id..."
11430 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11432 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11436 dd if=`which date` of=$MOUNT/date oflag=sync
11437 chmod +x $MOUNT/date
11439 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11440 $LCTL set_param fail_loc=0x80001401
11442 $MOUNT/date > /dev/null
11445 run_test 221 "make sure fault and truncate race to not cause OOM"
11448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11450 test_mkdir -p $DIR/$tdir
11451 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11452 createmany -o $DIR/$tdir/$tfile 10
11453 cancel_lru_locks mdc
11454 cancel_lru_locks osc
11455 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11456 $LCTL set_param fail_loc=0x31a
11457 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11458 $LCTL set_param fail_loc=0
11461 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11466 test_mkdir -p $DIR/$tdir
11467 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11468 createmany -o $DIR/$tdir/$tfile 10
11469 cancel_lru_locks mdc
11470 cancel_lru_locks osc
11471 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11472 $LCTL set_param fail_loc=0x31a
11473 rm -r $DIR/$tdir || "AGL for rmdir failed"
11474 $LCTL set_param fail_loc=0
11476 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11481 test_mkdir -p $DIR/$tdir
11482 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11483 createmany -o $DIR/$tdir/$tfile 10
11484 cancel_lru_locks mdc
11485 cancel_lru_locks osc
11486 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11487 $LCTL set_param fail_loc=0x31b
11488 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11489 $LCTL set_param fail_loc=0
11492 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11494 test_224a() { # LU-1039, MRP-303
11495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11496 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11497 $LCTL set_param fail_loc=0x508
11498 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11499 $LCTL set_param fail_loc=0
11502 run_test 224a "Don't panic on bulk IO failure"
11504 test_224b() { # LU-1039, MRP-303
11505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11506 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11507 cancel_lru_locks osc
11508 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11509 $LCTL set_param fail_loc=0x515
11510 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11511 $LCTL set_param fail_loc=0
11514 run_test 224b "Don't panic on bulk IO failure"
11516 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11519 if [ -z ${MDSSURVEY} ]; then
11520 skip_env "mds-survey not found" && return
11523 [ $MDSCOUNT -ge 2 ] &&
11524 skip "skipping now for more than one MDT" && return
11526 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11527 { skip "Need MDS version at least 2.2.51"; return; }
11529 local mds=$(facet_host $SINGLEMDS)
11530 local target=$(do_nodes $mds 'lctl dl' | \
11531 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11533 local cmd1="file_count=1000 thrhi=4"
11534 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11535 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11536 local cmd="$cmd1 $cmd2 $cmd3"
11538 rm -f ${TMP}/mds_survey*
11540 eval $cmd || error "mds-survey with zero-stripe failed"
11541 cat ${TMP}/mds_survey*
11542 rm -f ${TMP}/mds_survey*
11544 run_test 225a "Metadata survey sanity with zero-stripe"
11547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11549 if [ -z ${MDSSURVEY} ]; then
11550 skip_env "mds-survey not found" && return
11552 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11553 { skip "Need MDS version at least 2.2.51"; return; }
11555 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11556 skip_env "Need to mount OST to test" && return
11559 [ $MDSCOUNT -ge 2 ] &&
11560 skip "skipping now for more than one MDT" && return
11561 local mds=$(facet_host $SINGLEMDS)
11562 local target=$(do_nodes $mds 'lctl dl' | \
11563 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11565 local cmd1="file_count=1000 thrhi=4"
11566 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11567 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11568 local cmd="$cmd1 $cmd2 $cmd3"
11570 rm -f ${TMP}/mds_survey*
11572 eval $cmd || error "mds-survey with stripe_count failed"
11573 cat ${TMP}/mds_survey*
11574 rm -f ${TMP}/mds_survey*
11576 run_test 225b "Metadata survey sanity with stripe_count = 1"
11578 mcreate_path2fid () {
11584 local path=$DIR/$tdir/$name
11589 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11590 error "cannot create $desc"
11592 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11594 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11596 fid_path=$($LFS fid2path $MOUNT $fid)
11598 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11600 [ "$path" == "$fid_path" ] ||
11601 error "fid2path returned $fid_path, expected $path"
11603 echo "pass with $path and $fid"
11608 mkdir -p $DIR/$tdir
11610 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11611 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11612 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11613 mcreate_path2fid 0040666 0 0 dir "directory"
11614 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11615 mcreate_path2fid 0100666 0 0 file "regular file"
11616 mcreate_path2fid 0120666 0 0 link "symbolic link"
11617 mcreate_path2fid 0140666 0 0 sock "socket"
11619 run_test 226a "call path2fid and fid2path on files of all type"
11622 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11626 mkdir -p $DIR/$tdir
11627 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11628 error "create remote directory failed"
11629 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11630 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11631 "character special file (null)"
11632 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11633 "character special file (no device)"
11634 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11635 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11636 "block special file (loop)"
11637 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11638 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11639 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11641 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11643 # LU-1299 Executing or running ldd on a truncated executable does not
11644 # cause an out-of-memory condition.
11646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11647 dd if=`which date` of=$MOUNT/date bs=1k count=1
11648 chmod +x $MOUNT/date
11650 $MOUNT/date > /dev/null
11651 ldd $MOUNT/date > /dev/null
11654 run_test 227 "running truncated executable does not cause OOM"
11656 # LU-1512 try to reuse idle OI blocks
11658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11659 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11660 skip "non-ldiskfs backend" && return
11662 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11663 local myDIR=$DIR/$tdir
11666 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11667 $LCTL set_param fail_loc=0x80001002
11668 createmany -o $myDIR/t- 10000
11669 $LCTL set_param fail_loc=0
11670 # The guard is current the largest FID holder
11672 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11674 local IDX=$(($SEQ % 64))
11676 do_facet $SINGLEMDS sync
11677 # Make sure journal flushed.
11679 local blk1=$(do_facet $SINGLEMDS \
11680 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11681 grep Blockcount | awk '{print $4}')
11683 # Remove old files, some OI blocks will become idle.
11684 unlinkmany $myDIR/t- 10000
11685 # Create new files, idle OI blocks should be reused.
11686 createmany -o $myDIR/t- 2000
11687 do_facet $SINGLEMDS sync
11688 # Make sure journal flushed.
11690 local blk2=$(do_facet $SINGLEMDS \
11691 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11692 grep Blockcount | awk '{print $4}')
11694 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11696 run_test 228a "try to reuse idle OI blocks"
11699 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11700 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11701 skip "non-ldiskfs backend" && return
11703 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11704 local myDIR=$DIR/$tdir
11707 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11708 $LCTL set_param fail_loc=0x80001002
11709 createmany -o $myDIR/t- 10000
11710 $LCTL set_param fail_loc=0
11711 # The guard is current the largest FID holder
11713 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11715 local IDX=$(($SEQ % 64))
11717 do_facet $SINGLEMDS sync
11718 # Make sure journal flushed.
11720 local blk1=$(do_facet $SINGLEMDS \
11721 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11722 grep Blockcount | awk '{print $4}')
11724 # Remove old files, some OI blocks will become idle.
11725 unlinkmany $myDIR/t- 10000
11728 stop $SINGLEMDS || error "Fail to stop MDT."
11730 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11732 df $MOUNT || error "Fail to df."
11733 # Create new files, idle OI blocks should be reused.
11734 createmany -o $myDIR/t- 2000
11735 do_facet $SINGLEMDS sync
11736 # Make sure journal flushed.
11738 local blk2=$(do_facet $SINGLEMDS \
11739 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11740 grep Blockcount | awk '{print $4}')
11742 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11744 run_test 228b "idle OI blocks can be reused after MDT restart"
11748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11749 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11750 skip "non-ldiskfs backend" && return
11752 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11753 local myDIR=$DIR/$tdir
11756 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11757 $LCTL set_param fail_loc=0x80001002
11758 # 20000 files can guarantee there are index nodes in the OI file
11759 createmany -o $myDIR/t- 20000
11760 $LCTL set_param fail_loc=0
11761 # The guard is current the largest FID holder
11763 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11765 local IDX=$(($SEQ % 64))
11767 do_facet $SINGLEMDS sync
11768 # Make sure journal flushed.
11770 local blk1=$(do_facet $SINGLEMDS \
11771 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11772 grep Blockcount | awk '{print $4}')
11774 # Remove old files, some OI blocks will become idle.
11775 unlinkmany $myDIR/t- 20000
11777 # The OI file should become empty now
11779 # Create new files, idle OI blocks should be reused.
11780 createmany -o $myDIR/t- 2000
11781 do_facet $SINGLEMDS sync
11782 # Make sure journal flushed.
11784 local blk2=$(do_facet $SINGLEMDS \
11785 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11786 grep Blockcount | awk '{print $4}')
11788 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11790 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11792 test_229() { # LU-2482, LU-3448
11793 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
11794 skip "No HSM support on MDS of $(get_lustre_version)," \
11795 "need 2.4.53 at least" && return
11796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11797 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
11801 # Create a file with a released layout and stripe count 2.
11802 $MULTIOP $DIR/$tfile H2c ||
11803 error "failed to create file with released layout"
11805 $GETSTRIPE -v $DIR/$tfile
11807 local pattern=$($GETSTRIPE -L $DIR/$tfile)
11808 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
11810 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
11811 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
11812 stat $DIR/$tfile || error "failed to stat released file"
11814 chown $RUNAS_ID $DIR/$tfile ||
11815 error "chown $RUNAS_ID $DIR/$tfile failed"
11817 chgrp $RUNAS_ID $DIR/$tfile ||
11818 error "chgrp $RUNAS_ID $DIR/$tfile failed"
11820 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
11821 rm $DIR/$tfile || error "failed to remove released file"
11823 run_test 229 "getstripe/stat/rm/attr changes work on released files"
11826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11827 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11830 mkdir -p $DIR/$tdir/test_230_local
11831 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11832 [ $mdt_idx -ne 0 ] &&
11833 error "create local directory on wrong MDT $mdt_idx"
11835 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11836 error "create remote directory failed"
11837 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11838 [ $mdt_idx -ne $MDTIDX ] &&
11839 error "create remote directory on wrong MDT $mdt_idx"
11841 createmany -o $DIR/$tdir/test_230/t- 10 ||
11842 error "create files on remote directory failed"
11843 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11844 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11845 rm -r $DIR/$tdir || error "unlink remote directory failed"
11847 run_test 230a "Create remote directory and files under the remote directory"
11850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11851 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11858 local migrate_dir=$DIR/$tdir/migrate_dir
11859 local other_dir=$DIR/$tdir/other_dir
11861 mkdir -p $migrate_dir
11862 mkdir -p $other_dir
11863 for ((i=0; i<10; i++)); do
11864 mkdir -p $migrate_dir/dir_${i}
11865 createmany -o $migrate_dir/dir_${i}/f 10 ||
11866 error "create files under remote dir failed $i"
11869 cp /etc/passwd $migrate_dir/$tfile
11870 cp /etc/passwd $other_dir/$tfile
11871 mkdir -p $migrate_dir/dir_default_stripe2
11872 $LFS setstripe -c 2 $migrate_dir/dir_default_stripe2
11873 $LFS setstripe -c 2 $migrate_dir/${tfile}_stripe2
11875 mkdir -p $other_dir
11876 ln $migrate_dir/$tfile $other_dir/luna
11877 ln $migrate_dir/$tfile $migrate_dir/sofia
11878 ln $other_dir/$tfile $migrate_dir/david
11879 ln -s $migrate_dir/$tfile $other_dir/zachary
11880 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
11881 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
11883 $LFS mv -v -M $MDTIDX $migrate_dir ||
11884 error "migrate remote dir error"
11886 echo "migratate to MDT1, then checking.."
11887 for ((i=0; i<10; i++)); do
11888 for file in $(find $migrate_dir/dir_${i}); do
11889 mdt_index=$($LFS getstripe -M $file)
11890 [ $mdt_index == $MDTIDX ] ||
11891 error "$file is not on MDT${MDTIDX}"
11895 # the multiple link file should still in MDT0
11896 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
11897 [ $mdt_index == 0 ] ||
11898 error "$file is not on MDT${MDTIDX}"
11900 diff /etc/passwd $migrate_dir/$tfile ||
11901 error "$tfile different after migration"
11903 diff /etc/passwd $other_dir/luna ||
11904 error "luna different after migration"
11906 diff /etc/passwd $migrate_dir/sofia ||
11907 error "sofia different after migration"
11909 diff /etc/passwd $migrate_dir/david ||
11910 error "david different after migration"
11912 diff /etc/passwd $other_dir/zachary ||
11913 error "zachary different after migration"
11915 diff /etc/passwd $migrate_dir/${tfile}_ln ||
11916 error "${tfile}_ln different after migration"
11918 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
11919 error "${tfile}_ln_other different after migration"
11921 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
11922 [ $stripe_count = 2 ] ||
11923 error "dir strpe_count $d != 2 after migration."
11925 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
11926 [ $stripe_count = 2 ] ||
11927 error "file strpe_count $d != 2 after migration."
11929 #migrate back to MDT0
11931 $LFS mv -v -M $MDTIDX $migrate_dir ||
11932 error "migrate remote dir error"
11934 echo "migrate back to MDT0, checking.."
11935 for file in $(find $migrate_dir); do
11936 mdt_index=$($LFS getstripe -M $file)
11937 [ $mdt_index == $MDTIDX ] ||
11938 error "$file is not on MDT${MDTIDX}"
11941 diff /etc/passwd ${migrate_dir}/$tfile ||
11942 error "$tfile different after migration"
11944 diff /etc/passwd ${other_dir}/luna ||
11945 error "luna different after migration"
11947 diff /etc/passwd ${migrate_dir}/sofia ||
11948 error "sofia different after migration"
11950 diff /etc/passwd ${other_dir}/zachary ||
11951 error "zachary different after migration"
11953 diff /etc/passwd $migrate_dir/${tfile}_ln ||
11954 error "${tfile}_ln different after migration"
11956 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
11957 error "${tfile}_ln_other different after migration"
11959 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
11960 [ $stripe_count = 2 ] ||
11961 error "dir strpe_count $d != 2 after migration."
11963 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
11964 [ $stripe_count = 2 ] ||
11965 error "file strpe_count $d != 2 after migration."
11967 rm -rf $DIR/$tdir || error "rm dir failed after migration"
11969 run_test 230b "migrate directory"
11972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11973 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11978 #If migrating directory fails in the middle, all entries of
11979 #the directory is still accessiable.
11980 mkdir -p $DIR/$tdir
11982 createmany -o $DIR/$tdir/f 10 ||
11983 error "create files under ${tdir} failed"
11985 #failed after migrating 5 entries
11986 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
11987 do_facet mds1 lctl set_param fail_loc=0x20001801
11988 do_facet mds1 lctl set_param fail_val=5
11989 local t=`ls $DIR/$tdir | wc -l`
11990 $LFS mv -M $MDTIDX $DIR/$tdir &&
11991 error "migrate should failed after 5 entries"
11992 local u=`ls $DIR/$tdir | wc -l`
11993 [ "$u" == "$t" ] || error "$u != $t during migration"
11995 for file in $(find $DIR/$tdir); do
11996 stat $file || error "stat $file failed"
11999 do_facet mds1 lctl set_param fail_loc=0
12000 do_facet mds1 lctl set_param fail_val=0
12002 $LFS mv -M $MDTIDX $DIR/$tdir ||
12003 error "migrate open files should failed with open files"
12005 echo "Finish migration, then checking.."
12006 for file in $(find $DIR/$tdir); do
12007 mdt_index=$($LFS getstripe -M $file)
12008 [ $mdt_index == $MDTIDX ] ||
12009 error "$file is not on MDT${MDTIDX}"
12012 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12014 run_test 230c "check directory accessiblity if migration is failed"
12017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12024 mkdir -p $DIR/$tdir
12026 for ((i=0; i<100; i++)); do
12027 mkdir -p $DIR/$tdir/dir_${i}
12028 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12029 error "create files under remote dir failed $i"
12032 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12034 echo "Finish migration, then checking.."
12035 for file in $(find $DIR/$tdir); do
12036 mdt_index=$($LFS getstripe -M $file)
12037 [ $mdt_index == $MDTIDX ] ||
12038 error "$file is not on MDT${MDTIDX}"
12041 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12043 run_test 230d "check migrate big directory"
12047 # For simplicity this test assumes that max_pages_per_rpc
12048 # is the same across all OSCs
12049 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
12050 local bulk_size=$((max_pages * 4096))
12052 mkdir -p $DIR/$tdir
12054 # clear the OSC stats
12055 $LCTL set_param osc.*.stats=0 &>/dev/null
12057 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12058 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12059 oflag=direct &>/dev/null || error "dd failed"
12061 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12062 if [ x$nrpcs != "x1" ]; then
12063 error "found $nrpc ost_write RPCs, not 1 as expected"
12066 # Drop the OSC cache, otherwise we will read from it
12067 cancel_lru_locks osc
12069 # clear the OSC stats
12070 $LCTL set_param osc.*.stats=0 &>/dev/null
12072 # Client reads $bulk_size.
12073 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12074 iflag=direct &>/dev/null || error "dd failed"
12076 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12077 if [ x$nrpcs != "x1" ]; then
12078 error "found $nrpc ost_read RPCs, not 1 as expected"
12081 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12084 mkdir -p $DIR/$tdir
12086 for i in {0..1023}; do
12087 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12088 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12089 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12093 run_test 231b "must not assert on fully utilized OST request buffer"
12096 mkdir -p $DIR/$tdir
12097 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12098 $LCTL set_param fail_loc=0x31c
12100 # ignore dd failure
12101 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12103 $LCTL set_param fail_loc=0
12104 umount_client $MOUNT || error "umount failed"
12105 mount_client $MOUNT || error "mount failed"
12107 run_test 232 "failed lock should not block umount"
12110 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12111 { skip "Need MDS version at least 2.3.64"; return; }
12113 local fid=$($LFS path2fid $MOUNT)
12114 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12115 error "cannot access $MOUNT using its FID '$fid'"
12117 run_test 233a "checking that OBF of the FS root succeeds"
12120 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12121 { skip "Need MDS version at least 2.5.90"; return; }
12123 local fid=$($LFS path2fid $MOUNT/.lustre)
12124 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12125 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12127 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12128 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12129 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12131 run_test 233b "checking that OBF of the FS .lustre succeeds"
12134 local p="$TMP/sanityN-$TESTNAME.parameters"
12135 save_lustre_params client "llite.*.xattr_cache" > $p
12136 lctl set_param llite.*.xattr_cache 1 ||
12137 { skip "xattr cache is not supported"; return 0; }
12139 mkdir -p $DIR/$tdir || error "mkdir failed"
12140 touch $DIR/$tdir/$tfile || error "touch failed"
12141 # OBD_FAIL_LLITE_XATTR_ENOMEM
12142 $LCTL set_param fail_loc=0x1405
12143 if [ ! -f /etc/SuSE-release ]; then
12144 # attr pre-2.4.44-7 had a bug with rc
12145 # LU-3703 - SLES clients have older attr
12146 getfattr -n user.attr $DIR/$tdir/$tfile &&
12147 error "getfattr should have failed with ENOMEM"
12149 $LCTL set_param fail_loc=0x0
12152 restore_lustre_params < $p
12155 run_test 234 "xattr cache should not crash on ENOMEM"
12158 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12159 skip "Need MDS version at least 2.4.52" && return
12160 flock_deadlock $DIR/$tfile
12165 124) error "process hangs on a deadlock"
12167 *) error "error executing flock_deadlock $DIR/$tfile"
12171 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12175 check_swap_layouts_support && return 0
12176 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12178 local ref1=/etc/passwd
12179 local ref2=/etc/group
12180 local file1=$DIR/$tdir/f1
12181 local file2=$DIR/$tdir/f2
12183 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12184 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12185 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12186 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12187 local fd=$(free_fd)
12188 local cmd="exec $fd<>$file2"
12191 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12192 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12195 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12200 run_test 236 "Layout swap on open unlinked file"
12202 # test to verify file handle related system calls
12203 # (name_to_handle_at/open_by_handle_at)
12204 # The new system calls are supported in glibc >= 2.14.
12207 echo "Test file_handle syscalls" > $DIR/$tfile
12208 check_fhandle_syscalls $DIR/$tfile ||
12209 error "check_fhandle_syscalls failed"
12211 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12213 test_striped_dir() {
12218 mkdir -p $DIR/$tdir
12219 $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
12220 error "set striped dir error"
12222 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12223 if [ "$stripe_count" != "2" ]; then
12224 error "stripe_count is $stripe_count, expect 2"
12227 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12228 if [ "$stripe_index" != "$mdt_index" ]; then
12229 error "stripe_index is $stripe_index, expect $mdt_index"
12232 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12233 error "nlink error after create striped dir"
12235 mkdir $DIR/$tdir/striped_dir/a
12236 mkdir $DIR/$tdir/striped_dir/b
12238 stat $DIR/$tdir/striped_dir/a ||
12239 error "create dir under striped dir failed"
12240 stat $DIR/$tdir/striped_dir/b ||
12241 error "create dir under striped dir failed"
12243 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12244 error "nlink error after mkdir"
12246 rmdir $DIR/$tdir/striped_dir/a
12247 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12248 error "nlink error after rmdir"
12250 rmdir $DIR/$tdir/striped_dir/b
12251 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12252 error "nlink error after rmdir"
12254 rmdir $DIR/$tdir/striped_dir ||
12255 error "rmdir striped dir error"
12260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12261 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12263 test_striped_dir 0 || error "failed on striped dir on MDT0"
12264 test_striped_dir 1 || error "failed on striped dir on MDT0"
12266 run_test 300a "basic striped dir sanity test"
12269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12270 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12276 test_mkdir $DIR/$tdir || error "mkdir fail"
12277 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12278 error "set striped dir error"
12279 for ((i=0; i<10; i++)); do
12280 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12282 touch $DIR/$tdir/striped_dir/file_$i ||
12283 error "touch error $i"
12284 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12285 [ $mtime1 -eq $mtime2 ] &&
12286 error "mtime not change after create"
12288 rm -f $DIR/$tdir/striped_dir/file_$i ||
12289 error "unlink error $i"
12290 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12291 [ $mtime2 -eq $mtime3 ] &&
12292 error "mtime did not change after unlink"
12296 run_test 300b "check ctime/mtime for striped dir"
12299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12300 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12303 mkdir -p $DIR/$tdir
12304 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12305 error "set striped dir error"
12307 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12308 error "chown striped dir failed"
12310 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12311 error "create 5k files failed"
12313 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12315 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12319 run_test 300c "chown && check ls under striped directory"
12322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12323 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12327 mkdir -p $DIR/$tdir
12328 $SETSTRIPE -c 2 $DIR/$tdir
12330 #local striped directory
12331 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12332 error "set striped dir error"
12333 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12334 error "create 10 files failed"
12336 #remote striped directory
12337 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12338 error "set striped dir error"
12339 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12340 error "create 10 files failed"
12342 for file in $(find $DIR/$tdir); do
12343 stripe_count=$($GETSTRIPE -c $file)
12344 [ $stripe_count -eq 2 ] ||
12345 error "wrong stripe $stripe_count for $file"
12350 run_test 300d "check default stripe under striped directory"
12353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12354 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12358 mkdir -p $DIR/$tdir
12360 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12361 error "set striped dir error"
12363 touch $DIR/$tdir/striped_dir/a
12364 touch $DIR/$tdir/striped_dir/b
12365 touch $DIR/$tdir/striped_dir/c
12367 mkdir $DIR/$tdir/striped_dir/dir_a
12368 mkdir $DIR/$tdir/striped_dir/dir_b
12369 mkdir $DIR/$tdir/striped_dir/dir_c
12371 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12372 error "set striped dir under striped dir error"
12374 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12375 error "set striped dir under striped dir error"
12377 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12378 error "set striped dir under striped dir error"
12380 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12381 error "rename file under striped dir should fail"
12383 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12384 error "rename dir under striped dir should fail"
12386 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12387 error "rename dir under different stripes should fail"
12389 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12390 error "rename file under striped dir should succeed"
12392 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12393 error "rename dir under striped dir should succeed"
12397 run_test 300e "check rename under striped directory"
12400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12401 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12406 mkdir -p $DIR/$tdir
12408 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12409 error "set striped dir error"
12411 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12412 error "set striped dir error"
12414 touch $DIR/$tdir/striped_dir/a
12415 mkdir $DIR/$tdir/striped_dir/dir_a
12416 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12417 error "create striped dir under striped dir fails"
12419 touch $DIR/$tdir/striped_dir1/b
12420 mkdir $DIR/$tdir/striped_dir1/dir_b
12421 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12422 error "create striped dir under striped dir fails"
12424 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12425 error "rename file under different striped dir should fail"
12427 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12428 error "rename dir under different striped dir should fail"
12430 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12431 error "rename striped dir under diff striped dir should fail"
12433 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12434 error "rename file under diff striped dirs fails"
12436 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12437 error "rename dir under diff striped dirs fails"
12441 run_test 300f "check rename cross striped directory"
12444 # tests that do cleanup/setup should be run at the end
12448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12450 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
12451 $LCTL set_param fail_loc=0x903
12452 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
12453 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
12456 FAIL_ON_ERROR=true cleanup
12457 FAIL_ON_ERROR=true setup
12459 run_test 900 "umount should not race with any mgc requeue thread"
12462 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
12463 check_and_cleanup_lustre
12464 if [ "$I_MOUNTED" != "yes" ]; then
12465 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true