2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
63 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
64 # bug number for skipped test: LU-1593 LU-5242 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 132 180 184c"
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
73 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
74 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
83 check_kernel_version() {
85 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
87 patchless|patchless_client) return 0;;
88 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
90 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
94 check_swap_layouts_support()
96 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
97 { skip "Does not support layout lock."; return 0; }
101 if [ "$ONLY" == "cleanup" ]; then
106 check_and_setup_lustre
111 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
112 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
113 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
114 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
115 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
116 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
117 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
118 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
120 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
121 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
122 rm -rf $DIR/[Rdfs][0-9]*
124 # $RUNAS_ID may get set incorrectly somewhere else
125 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
127 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
131 if [ "${ONLY}" = "MOUNT" ] ; then
132 echo "Lustre is up, please go on"
136 echo "preparing for tests involving mounts"
137 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
139 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
140 echo # add a newline after mke2fs.
144 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
145 lctl set_param debug=-1 2> /dev/null || true
148 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
150 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
152 run_test 0a "touch; rm ====================="
155 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
156 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
158 run_test 0b "chmod 0755 $DIR ============================="
161 $LCTL get_param mdc.*.import | grep "state: FULL" ||
162 error "import not FULL"
163 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
166 run_test 0c "check import proc ============================="
169 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
170 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
171 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
172 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
175 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
177 run_test 1 "mkdir; remkdir; rmdir =============================="
180 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
181 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
182 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
184 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
186 run_test 2 "mkdir; touch; rmdir; check file ===================="
189 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
190 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
191 touch $DIR/$tdir/$tfile
192 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
194 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
196 run_test 3 "mkdir; touch; rmdir; check dir ====================="
198 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
202 test_mkdir $DIR/$tdir ||
203 error "Create remote directory failed"
205 touch $DIR/$tdir/$tfile ||
206 error "Create file under remote directory failed"
209 error "Expect error removing in-use dir $DIR/$tdir"
211 test -d $DIR/$tdir || error "Remote directory disappeared"
213 rm -rf $DIR/$tdir || error "remove remote dir error"
215 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
218 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
219 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
220 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
221 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
222 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
224 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
227 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
228 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile does not have perm 0666 or UID $UID"
231 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
233 error "$tfile should be 0666 and owned by UID $UID"
235 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
240 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
243 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
244 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
245 error "$tfile should be owned by UID $RUNAS_ID"
247 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
252 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by GID $UID"
255 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
256 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
257 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
259 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
262 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
263 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
264 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
265 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
266 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
267 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
268 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
269 error "$tdir/d/subdir should be GID $RUNAS_GID"
271 run_test 6g "Is new dir in sgid dir inheriting group?"
273 test_6h() { # bug 7331
274 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
275 touch $DIR/$tfile || error "touch failed"
276 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
277 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
278 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
279 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
280 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
282 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
285 test_mkdir $DIR/$tdir
286 $MCREATE $DIR/$tdir/$tfile
287 chmod 0666 $DIR/$tdir/$tfile
288 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
289 error "$tdir/$tfile should be mode 0666"
291 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
294 if [ ! -d $DIR/$tdir ]; then
297 $MCREATE $DIR/$tdir/$tfile
298 echo -n foo > $DIR/$tdir/$tfile
299 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
300 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
302 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
305 test_mkdir $DIR/$tdir
306 touch $DIR/$tdir/$tfile
307 chmod 0666 $DIR/$tdir/$tfile
308 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
309 error "$tfile mode not 0666"
311 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
314 test_mkdir $DIR/$tdir
315 test_mkdir $DIR/$tdir/d2
316 test_mkdir $DIR/$tdir/d2/d3
317 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
319 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
322 test_mkdir $DIR/$tdir
323 test_mkdir $DIR/$tdir/d2
324 touch $DIR/$tdir/d2/$tfile
325 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
326 error "$tdir/d2/$tfile not a file"
328 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 chmod 0666 $DIR/$tdir/d2
334 chmod 0705 $DIR/$tdir/d2
335 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
336 error "$tdir/d2 mode not 0705"
338 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
341 test_mkdir $DIR/$tdir
342 touch $DIR/$tdir/$tfile
343 chmod 0666 $DIR/$tdir/$tfile
344 chmod 0654 $DIR/$tdir/$tfile
345 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
346 error "$tdir/d2 mode not 0654"
348 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
351 test_mkdir $DIR/$tdir
352 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
354 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
355 error "$tdir/$tfile size not 0 after truncate"
357 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
360 test_mkdir $DIR/$tdir
361 touch $DIR/$tdir/$tfile
363 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
365 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
368 test_mkdir $DIR/$tdir
369 touch $DIR/$tdir/$tfile
370 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
371 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
372 error "$tdir/${tfile_2} not a file after rename"
374 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
379 rm -rf $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
382 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
385 test_mkdir -p $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
389 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not a symlink"
391 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
392 error "$tdir/l-exist not referencing a file"
393 rm -f $DIR/$tdir/l-exist
394 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
396 run_test 17a "symlinks: create, remove (real) =================="
399 test_mkdir -p $DIR/$tdir
400 ln -s no-such-file $DIR/$tdir/l-dangle
402 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing no-such-file"
404 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
405 error "$tdir/l-dangle not referencing non-existent file"
406 rm -f $DIR/$tdir/l-dangle
407 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
409 run_test 17b "symlinks: create, remove (dangling) =============="
411 test_17c() { # bug 3440 - don't save failed open RPC for replay
412 test_mkdir -p $DIR/$tdir
413 ln -s foo $DIR/$tdir/$tfile
414 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
416 run_test 17c "symlinks: open dangling (should return error) ===="
419 test_mkdir -p $DIR/$tdir
420 ln -s foo $DIR/$tdir/$tfile
421 touch $DIR/$tdir/$tfile || error "creating to new symlink"
423 run_test 17d "symlinks: create dangling ========================"
426 test_mkdir -p $DIR/$tdir
427 local foo=$DIR/$tdir/$tfile
428 ln -s $foo $foo || error "create symlink failed"
429 ls -l $foo || error "ls -l failed"
430 ls $foo && error "ls not failed" || true
432 run_test 17e "symlinks: create recursive symlink (should return error) ===="
435 test_mkdir -p $DIR/$tdir
436 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
441 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
444 run_test 17f "symlinks: long and very long symlink name ========================"
446 # str_repeat(S, N) generate a string that is string S repeated N times
451 while [ $((n -= 1)) -ge 0 ]; do
457 # Long symlinks and LU-2241
459 test_mkdir -p $DIR/$tdir
460 local TESTS="59 60 61 4094 4095"
462 # Fix for inode size boundary in 2.1.4
463 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
466 # Patch not applied to 2.2 or 2.3 branches
467 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
468 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
471 # skip long symlink name for rhel6.5.
472 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
473 grep -q '6.5' /etc/redhat-release &>/dev/null &&
474 TESTS="59 60 61 4062 4063"
477 local SYMNAME=$(str_repeat 'x' $i)
478 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
479 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
482 run_test 17g "symlinks: really long symlink name and inode boundaries"
484 test_17h() { #bug 17378
485 remote_mds_nodsh && skip "remote MDS with nodsh" && return
486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
488 test_mkdir -p $DIR/$tdir
489 if [[ $MDSCOUNT -gt 1 ]]; then
490 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
494 $SETSTRIPE -c -1 $DIR/$tdir
495 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
496 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
497 touch $DIR/$tdir/$tfile || true
499 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
501 test_17i() { #bug 20018
502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
504 test_mkdir -c1 $DIR/$tdir
505 local foo=$DIR/$tdir/$tfile
507 if [[ $MDSCOUNT -gt 1 ]]; then
508 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
512 ln -s $foo $foo || error "create symlink failed"
513 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
514 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
515 ls -l $foo && error "error not detected"
518 run_test 17i "don't panic on short symlink"
520 test_17k() { #bug 22301
521 [[ -z "$(which rsync 2>/dev/null)" ]] &&
522 skip "no rsync command" && return 0
523 rsync --help | grep -q xattr ||
524 skip_env "$(rsync --version | head -n1) does not support xattrs"
525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
526 test_mkdir -p $DIR/$tdir
527 test_mkdir -p $DIR/$tdir.new
528 touch $DIR/$tdir/$tfile
529 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
530 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
531 error "rsync failed with xattrs enabled"
533 run_test 17k "symlinks: rsync with xattrs enabled ========================="
535 test_17l() { # LU-279
536 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
537 skip "no getfattr command" && return 0
539 touch $DIR/$tdir/$tfile
540 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
541 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
542 # -h to not follow symlinks. -m '' to list all the xattrs.
543 # grep to remove first line: '# file: $path'.
544 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
546 lgetxattr_size_check $path $xattr ||
547 error "lgetxattr_size_check $path $xattr failed"
551 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
555 local short_sym="0123456789"
556 local WDIR=$DIR/${tdir}m
563 remote_mds_nodsh && skip "remote MDS with nodsh" && return
564 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
565 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
566 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
568 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
569 skip "only for ldiskfs MDT" && return 0
571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
575 # create a long symlink file
576 for ((i = 0; i < 4; ++i)); do
577 long_sym=${long_sym}${long_sym}
580 echo "create 512 short and long symlink files under $WDIR"
581 for ((i = 0; i < 256; ++i)); do
582 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
583 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
589 wait_delete_completed
591 echo "recreate the 512 symlink files with a shorter string"
592 for ((i = 0; i < 512; ++i)); do
593 # rewrite the symlink file with a shorter string
594 ln -sf ${long_sym} $WDIR/long-$i
595 ln -sf ${short_sym} $WDIR/short-$i
598 mds_index=$($LFS getstripe -M $WDIR)
599 mds_index=$((mds_index+1))
600 devname=$(mdsdevname $mds_index)
601 cmd="$E2FSCK -fnvd $devname"
603 echo "stop and checking mds${mds_index}: $cmd"
604 # e2fsck should not return error
606 do_facet mds${mds_index} $cmd || rc=$?
608 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
609 df $MOUNT > /dev/null 2>&1
610 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
611 "short/long symlink MDT: rc=$rc"
614 run_test 17m "run e2fsck against MDT which contains short/long symlink"
616 check_fs_consistency_17n() {
622 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
623 # so it only check MDT1/MDT2 instead of all of MDTs.
624 for mdt_index in $(seq 1 2); do
625 devname=$(mdsdevname $mdt_index)
626 cmd="$E2FSCK -fnvd $devname"
628 echo "stop and checking mds${mdt_index}: $cmd"
629 # e2fsck should not return error
631 do_facet mds${mdt_index} $cmd || rc=$?
633 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
634 error "mount mds${mdt_index} failed"
635 df $MOUNT > /dev/null 2>&1
636 [ $rc -ne 0 ] && break
644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
645 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
646 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
647 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
649 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
650 skip "only for ldiskfs MDT" && return 0
652 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
657 for ((i=0; i<10; i++)); do
658 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
659 error "create remote dir error $i"
660 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
661 error "create files under remote dir failed $i"
664 check_fs_consistency_17n ||
665 error "e2fsck report error after create files under remote dir"
667 for ((i=0;i<10;i++)); do
668 rm -rf $DIR/$tdir/remote_dir_${i} ||
669 error "destroy remote dir error $i"
672 check_fs_consistency_17n ||
673 error "e2fsck report error after unlink files under remote dir"
675 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
676 skip "lustre < 2.4.50 does not support migrate mv " && return
678 for ((i=0; i<10; i++)); do
679 mkdir -p $DIR/$tdir/remote_dir_${i}
680 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
681 error "create files under remote dir failed $i"
682 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
683 error "migrate remote dir error $i"
685 check_fs_consistency_17n || error "e2fsck report error after migration"
687 for ((i=0;i<10;i++)); do
688 rm -rf $DIR/$tdir/remote_dir_${i} ||
689 error "destroy remote dir error $i"
692 check_fs_consistency_17n || error "e2fsck report error after unlink"
694 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
697 remote_mds_nodsh && skip "remote MDS with nodsh" && return
698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
699 skip "Need MDS version at least 2.3.64" && return
701 local WDIR=$DIR/${tdir}o
707 mdt_index=$($LFS getstripe -M $WDIR)
708 mdt_index=$((mdt_index+1))
709 mdtdevname=$(mdsdevname $mdt_index)
713 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
714 error "mount mds${mdt_index} failed"
716 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
717 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
718 ls -l $WDIR/$tfile && rc=1
719 do_facet mds${mdt_index} lctl set_param fail_loc=0
720 [[ $rc -ne 0 ]] && error "stat file should fail"
723 run_test 17o "stat file with incompat LMA feature"
726 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
727 ls $DIR || error "Failed to ls $DIR: $?"
729 run_test 18 "touch .../f ; ls ... =============================="
735 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
737 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
740 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
742 run_test 19b "ls -l .../f19 (should return error) =============="
745 [ $RUNAS_ID -eq $UID ] &&
746 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
747 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
749 run_test 19c "$RUNAS touch .../f19 (should return error) =="
752 cat $DIR/f19 && error || true
754 run_test 19d "cat .../f19 (should return error) =============="
766 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
768 run_test 20 "touch .../f ; ls -l ... ==========================="
771 test_mkdir -p $DIR/$tdir
772 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
773 ln -s dangle $DIR/$tdir/link
774 echo foo >> $DIR/$tdir/link
775 cat $DIR/$tdir/dangle
776 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
777 $CHECKSTAT -f -t file $DIR/$tdir/link ||
778 error "$tdir/link not linked to a file"
780 run_test 21 "write to dangling link ============================"
784 test_mkdir -p $DIR/$tdir
785 chown $RUNAS_ID:$RUNAS_GID $WDIR
786 (cd $WDIR || error "cd $WDIR failed";
787 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
789 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
790 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
791 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
793 run_test 22 "unpack tar archive as non-root user ==============="
797 test_mkdir -p $DIR/$tdir
798 local file=$DIR/$tdir/$tfile
800 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
801 openfile -f O_CREAT:O_EXCL $file &&
802 error "$file recreate succeeded" || true
804 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
806 test_23b() { # bug 18988
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
811 echo foo > $file || error "write filed"
812 echo bar >> $file || error "append filed"
813 $CHECKSTAT -s 8 $file || error "wrong size"
816 run_test 23b "O_APPEND check =========================="
820 echo '-- same directory rename'
821 test_mkdir $DIR/$tdir
822 touch $DIR/$tdir/$tfile.1
823 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
824 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
826 run_test 24a "rename file to non-existent target"
829 test_mkdir $DIR/$tdir
830 touch $DIR/$tdir/$tfile.{1,2}
831 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
832 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
833 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
835 run_test 24b "rename file to existing target"
838 test_mkdir $DIR/$tdir
839 test_mkdir $DIR/$tdir/d$testnum.1
840 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
841 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
842 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
844 run_test 24c "rename directory to non-existent target"
847 test_mkdir -c1 $DIR/$tdir
848 test_mkdir -c1 $DIR/$tdir/d$testnum.1
849 test_mkdir -c1 $DIR/$tdir/d$testnum.2
850 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
851 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
852 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
854 run_test 24d "rename directory to existing target"
857 echo '-- cross directory renames --'
861 mv $DIR/R5a/f $DIR/R5b/g
862 $CHECKSTAT -a $DIR/R5a/f || error
863 $CHECKSTAT -t file $DIR/R5b/g || error
865 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
870 touch $DIR/R6a/f $DIR/R6b/g
871 mv $DIR/R6a/f $DIR/R6b/g
872 $CHECKSTAT -a $DIR/R6a/f || error
873 $CHECKSTAT -t file $DIR/R6b/g || error
875 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
880 test_mkdir $DIR/R7a/d
881 mv $DIR/R7a/d $DIR/R7b/e
882 $CHECKSTAT -a $DIR/R7a/d || error
883 $CHECKSTAT -t dir $DIR/R7b/e || error
885 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
888 test_mkdir -c1 $DIR/R8a
889 test_mkdir -c1 $DIR/R8b
890 test_mkdir -c1 $DIR/R8a/d
891 test_mkdir -c1 $DIR/R8b/e
892 mrename $DIR/R8a/d $DIR/R8b/e
893 $CHECKSTAT -a $DIR/R8a/d || error
894 $CHECKSTAT -t dir $DIR/R8b/e || error
896 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
899 echo "-- rename error cases"
903 mrename $DIR/R9/f $DIR/R9/a
904 $CHECKSTAT -t file $DIR/R9/f || error
905 $CHECKSTAT -t dir $DIR/R9/a || error
906 $CHECKSTAT -a $DIR/R9/a/f || error
908 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
912 mrename $DIR/R10/f $DIR/R10/g
913 $CHECKSTAT -t dir $DIR/R10 || error
914 $CHECKSTAT -a $DIR/R10/f || error
915 $CHECKSTAT -a $DIR/R10/g || error
917 run_test 24j "source does not exist ============================"
921 test_mkdir $DIR/R11a/d
923 mv $DIR/R11a/f $DIR/R11a/d
924 $CHECKSTAT -a $DIR/R11a/f || error
925 $CHECKSTAT -t file $DIR/R11a/d/f || error
927 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
929 # bug 2429 - rename foo foo foo creates invalid file
932 $MULTIOP $f OcNs || error
934 run_test 24l "Renaming a file to itself ========================"
938 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
939 # on ext3 this does not remove either the source or target files
940 # though the "expected" operation would be to remove the source
941 $CHECKSTAT -t file ${f} || error "${f} missing"
942 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
944 run_test 24m "Renaming a file to a hard link to itself ========="
948 # this stats the old file after it was renamed, so it should fail
952 $CHECKSTAT ${f}.rename
955 run_test 24n "Statting the old file after renaming (Posix rename 2)"
958 check_kernel_version 37 || return 0
959 test_mkdir -p $DIR/d24o
960 rename_many -s random -v -n 10 $DIR/d24o
962 run_test 24o "rename of files during htree split ==============="
967 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
968 mrename $DIR/R12a $DIR/R12b
969 $CHECKSTAT -a $DIR/R12a || error
970 $CHECKSTAT -t dir $DIR/R12b || error
971 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
972 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
974 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
976 cleanup_multiop_pause() {
982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
985 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
986 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
989 trap cleanup_multiop_pause EXIT
990 mrename $DIR/R13a $DIR/R13b
991 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
992 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
993 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
994 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
995 cleanup_multiop_pause
996 wait $MULTIPID || error "multiop close failed"
998 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1000 test_24r() { #bug 3789
1001 test_mkdir $DIR/R14a
1002 test_mkdir $DIR/R14a/b
1003 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1004 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1005 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1007 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1010 test_mkdir $DIR/R15a
1011 test_mkdir $DIR/R15a/b
1012 test_mkdir $DIR/R15a/b/c
1013 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1015 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1017 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1019 test_mkdir $DIR/R16a
1020 test_mkdir $DIR/R16a/b
1021 test_mkdir $DIR/R16a/b/c
1022 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1024 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1026 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1028 test_24u() { # bug12192
1029 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1030 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1032 run_test 24u "create stripe file"
1038 simple_cleanup_common() {
1041 wait_delete_completed
1044 max_pages_per_rpc() {
1045 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1049 local NRFILES=100000
1050 local FREE_INODES=$(mdt_free_inodes 0)
1051 [[ $FREE_INODES -lt $NRFILES ]] &&
1052 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1056 trap simple_cleanup_common EXIT
1058 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1059 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1062 createmany -m $DIR/$tdir/$tfile $NRFILES
1064 cancel_lru_locks mdc
1065 lctl set_param mdc.*.stats clear
1067 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1069 # LU-5 large readdir
1070 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1071 # 8 bytes for name(filename is mostly 5 in this test) +
1072 # 8 bytes for luda_type
1073 # take into account of overhead in lu_dirpage header and end mark in
1074 # each page, plus one in RPC_NUM calculation.
1076 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1077 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1078 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1079 awk '/^mds_readpage/ {print $2}')
1080 [[ $mds_readpage -gt $RPC_NUM ]] &&
1081 error "large readdir doesn't take effect"
1083 simple_cleanup_common
1085 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1087 test_24w() { # bug21506
1089 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1090 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1091 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1092 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1093 [[ "$SZ1" -eq "$SZ2" ]] ||
1094 error "Error reading at the end of the file $tfile"
1096 run_test 24w "Reading a file larger than 4Gb"
1099 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 mkdir -p $DIR/$tdir/src_dir
1109 touch $DIR/$tdir/src_file
1110 mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $remote_dir $DIR/ &&
1114 error "rename dir cross MDT works!"
1116 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1117 error "rename dir cross MDT works!"
1119 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1120 error "rename file cross MDT works!"
1122 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1123 error "ln file cross MDT should not work!"
1125 rm -rf $DIR/$tdir || error "Can not delete directories"
1127 run_test 24x "cross rename/link should be failed"
1130 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1133 local remote_dir=$DIR/$tdir/remote_dir
1136 $LFS mkdir -i $MDTIDX $remote_dir ||
1137 error "create remote directory failed"
1139 mkdir -p $remote_dir/src_dir
1140 touch $remote_dir/src_file
1141 mkdir -p $remote_dir/tgt_dir
1142 touch $remote_dir/tgt_file
1144 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1145 error "rename subdir in the same remote dir failed!"
1147 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1148 error "rename files in the same remote dir failed!"
1150 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1151 error "link files in the same remote dir failed!"
1153 rm -rf $DIR/$tdir || error "Can not delete directories"
1155 run_test 24y "rename/link on the same dir should succeed"
1158 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1161 local remote_src=$DIR/$tdir/remote_dir
1162 local remote_tgt=$DIR/$tdir/remote_tgt
1165 $LFS mkdir -i $MDTIDX $remote_src ||
1166 error "create remote directory failed"
1168 $LFS mkdir -i $MDTIDX $remote_tgt ||
1169 error "create remote directory failed"
1171 mrename $remote_src $remote_tgt &&
1172 error "rename remote dirs should not work!"
1174 # If target dir does not exists, it should succeed
1176 mrename $remote_src $remote_tgt ||
1177 error "rename remote dirs(tgt dir does not exists) failed!"
1179 rm -rf $DIR/$tdir || error "Can not delete directories"
1181 run_test 24z "rename one remote dir to another remote dir should fail"
1183 test_24A() { # LU-3182
1188 createmany -m $DIR/$tdir/$tfile $NFILES
1189 local t=$(ls $DIR/$tdir | wc -l)
1190 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1191 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1192 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1193 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1196 rm -rf $DIR/$tdir || error "Can not delete directories"
1198 run_test 24A "readdir() returns correct number of entries."
1200 test_24B() { # LU-4805
1201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1205 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1206 error "create striped dir failed"
1208 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1209 [ $count -eq 2 ] || error "Expected 2, got $count"
1211 touch $DIR/$tdir/striped_dir/a
1213 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1214 [ $count -eq 3 ] || error "Expected 3, got $count"
1216 touch $DIR/$tdir/striped_dir/.f
1218 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1219 [ $count -eq 4 ] || error "Expected 4, got $count"
1221 rm -rf $DIR/$tdir || error "Can not delete directories"
1223 run_test 24B "readdir for striped dir return correct number of entries"
1226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1232 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1233 error "create striped dir failed"
1235 cd $DIR/$tdir/d0/striped_dir
1237 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1238 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1239 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1241 [ "$d0_ino" = "$parent_ino" ] ||
1242 error ".. wrong, expect $d0_ino, get $parent_ino"
1244 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1245 error "mv striped dir failed"
1247 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1249 [ "$d1_ino" = "$parent_ino" ] ||
1250 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1252 run_test 24C "check .. in striped dir"
1255 echo '== symlink sanity ============================================='
1259 touch $DIR/s25/foo || error
1261 run_test 25a "create file in symlinked directory ==============="
1264 [ ! -d $DIR/d25 ] && test_25a
1265 $CHECKSTAT -t file $DIR/s25/foo || error
1267 run_test 25b "lookup file in symlinked directory ==============="
1271 test_mkdir $DIR/d26/d26-2
1272 ln -s d26/d26-2 $DIR/s26
1273 touch $DIR/s26/foo || error
1275 run_test 26a "multiple component symlink ======================="
1278 test_mkdir -p $DIR/d26b/d26-2
1279 ln -s d26b/d26-2/foo $DIR/s26-2
1280 touch $DIR/s26-2 || error
1282 run_test 26b "multiple component symlink at end of lookup ======"
1285 test_mkdir $DIR/d26.2
1286 touch $DIR/d26.2/foo
1287 ln -s d26.2 $DIR/s26.2-1
1288 ln -s s26.2-1 $DIR/s26.2-2
1289 ln -s s26.2-2 $DIR/s26.2-3
1290 chmod 0666 $DIR/s26.2-3/foo
1292 run_test 26c "chain of symlinks ================================"
1294 # recursive symlinks (bug 439)
1296 ln -s d26-3/foo $DIR/d26-3
1298 run_test 26d "create multiple component recursive symlink ======"
1301 [ ! -h $DIR/d26-3 ] && test_26d
1304 run_test 26e "unlink multiple component recursive symlink ======"
1306 # recursive symlinks (bug 7022)
1308 test_mkdir -p $DIR/$tdir
1309 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1310 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1311 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1312 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1313 cd $tfile || error "cd $tfile failed"
1314 ln -s .. dotdot || error "ln dotdot failed"
1315 ln -s dotdot/lndir lndir || error "ln lndir failed"
1316 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1317 output=`ls $tfile/$tfile/lndir/bar1`
1318 [ "$output" = bar1 ] && error "unexpected output"
1319 rm -r $tfile || error "rm $tfile failed"
1320 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1322 run_test 26f "rm -r of a directory which has recursive symlink ="
1325 echo '== stripe sanity =============================================='
1326 test_mkdir -p $DIR/d27 || error "mkdir failed"
1328 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1329 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1330 log "== test_27a: write to one stripe file ========================="
1331 cp /etc/hosts $DIR/d27/f0 || error
1333 run_test 27a "one stripe file =================================="
1336 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1337 test_mkdir -p $DIR/d27
1338 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1339 $GETSTRIPE -c $DIR/d27/f01
1340 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1341 error "two-stripe file doesn't have two stripes"
1343 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1345 run_test 27b "create and write to two stripe file"
1348 test_mkdir -p $DIR/d27
1349 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1350 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1351 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1353 run_test 27d "create file with default settings ================"
1356 test_mkdir -p $DIR/d27
1357 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1358 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1359 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1361 run_test 27e "setstripe existing file (should return error) ======"
1364 test_mkdir $DIR/$tdir
1365 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1366 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1367 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1368 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1369 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1370 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1372 run_test 27f "setstripe with bad stripe size (should return error)"
1375 test_mkdir -p $DIR/d27
1376 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1377 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1378 error "$DIR/d27/fnone has object"
1380 run_test 27g "$GETSTRIPE with no objects"
1383 touch $DIR/d27/fsome || error "touch failed"
1384 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1386 run_test 27i "$GETSTRIPE with some objects"
1389 test_mkdir -p $DIR/d27
1390 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1392 run_test 27j "setstripe with bad stripe offset (should return error)"
1394 test_27k() { # bug 2844
1395 test_mkdir -p $DIR/d27
1397 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1398 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1399 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1400 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1401 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1402 dd if=/dev/zero of=$FILE bs=4k count=1
1403 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1404 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1406 run_test 27k "limit i_blksize for broken user apps ============="
1409 test_mkdir -p $DIR/d27
1410 mcreate $DIR/f27l || error "creating file"
1411 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1412 error "setstripe should have failed" || true
1414 run_test 27l "check setstripe permissions (should return error)"
1417 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1419 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1420 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1423 trap simple_cleanup_common EXIT
1424 test_mkdir -p $DIR/$tdir
1425 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1426 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1427 error "dd should fill OST0"
1429 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1431 [ $i -gt 256 ] && break
1434 touch $DIR/$tdir/f27m_$i
1435 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1436 error "OST0 was full but new created file still use it"
1438 touch $DIR/$tdir/f27m_$i
1439 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1440 error "OST0 was full but new created file still use it"
1441 simple_cleanup_common
1443 run_test 27m "create file while OST0 was full =================="
1446 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1450 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1451 # if the OST isn't full anymore.
1453 local OSTIDX=${1:-""}
1455 local list=$(comma_list $(osts_nodes))
1456 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1458 do_nodes $list lctl set_param fail_loc=0
1459 sync # initiate all OST_DESTROYs from MDS to OST
1463 exhaust_precreations() {
1466 local FAILIDX=${3:-$OSTIDX}
1468 test_mkdir -p $DIR/$tdir
1469 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1470 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1472 local OST=$(ostname_from_index $OSTIDX)
1473 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1474 sed -e 's/_UUID$//;s/^.*-//')
1477 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1478 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1479 osc.$mdtosc_proc1.prealloc_last_id)
1480 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1481 osc.$mdtosc_proc1.prealloc_next_id)
1483 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1484 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1486 test_mkdir -p $DIR/$tdir/${OST}
1487 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1488 #define OBD_FAIL_OST_ENOSPC 0x215
1489 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1490 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1491 echo "Creating to objid $last_id on ost $OST..."
1492 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1493 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1494 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1498 exhaust_all_precreations() {
1500 for (( i=0; i < OSTCOUNT; i++ )) ; do
1501 exhaust_precreations $i $1 -1
1506 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1507 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1508 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1509 remote_ost_nodsh && skip "remote OST with nodsh" && return
1512 rm -f $DIR/$tdir/$tfile
1513 exhaust_precreations 0 0x80000215
1514 $SETSTRIPE -c -1 $DIR/$tdir
1515 touch $DIR/$tdir/$tfile || error
1516 $GETSTRIPE $DIR/$tdir/$tfile
1519 run_test 27n "create file with some full OSTs =================="
1522 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 remote_ost_nodsh && skip "remote OST with nodsh" && return
1528 rm -f $DIR/$tdir/$tfile
1529 exhaust_all_precreations 0x215
1531 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1536 run_test 27o "create file with all full OSTs (should error) ===="
1539 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1542 remote_ost_nodsh && skip "remote OST with nodsh" && return
1545 rm -f $DIR/$tdir/$tfile
1546 test_mkdir -p $DIR/$tdir
1548 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1549 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1550 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1552 exhaust_precreations 0 0x80000215
1553 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1554 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1555 $GETSTRIPE $DIR/$tdir/$tfile
1559 run_test 27p "append to a truncated file with some full OSTs ==="
1562 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1564 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1565 remote_ost_nodsh && skip "remote OST with nodsh" && return
1568 rm -f $DIR/$tdir/$tfile
1570 test_mkdir -p $DIR/$tdir
1571 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1572 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1573 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1575 exhaust_all_precreations 0x215
1577 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1578 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1582 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1585 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1586 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1587 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1588 remote_ost_nodsh && skip "remote OST with nodsh" && return
1591 rm -f $DIR/$tdir/$tfile
1592 exhaust_precreations 0 0x80000215
1594 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1598 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1600 test_27s() { # bug 10725
1601 test_mkdir -p $DIR/$tdir
1602 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1603 local stripe_count=0
1604 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1605 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1606 error "stripe width >= 2^32 succeeded" || true
1609 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1611 test_27t() { # bug 10864
1616 $WLFS getstripe $tfile
1619 run_test 27t "check that utils parse path correctly"
1621 test_27u() { # bug 4900
1622 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1623 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1625 local list=$(comma_list $(mdts_nodes))
1627 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1628 do_nodes $list $LCTL set_param fail_loc=0x139
1629 test_mkdir -p $DIR/$tdir
1631 createmany -o $DIR/$tdir/t- 1000
1632 do_nodes $list $LCTL set_param fail_loc=0
1634 TLOG=$DIR/$tfile.getstripe
1635 $GETSTRIPE $DIR/$tdir > $TLOG
1636 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1637 unlinkmany $DIR/$tdir/t- 1000
1638 [[ $OBJS -gt 0 ]] &&
1639 error "$OBJS objects created on OST-0. See $TLOG" || pass
1641 run_test 27u "skip object creation on OSC w/o objects =========="
1643 test_27v() { # bug 4900
1644 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1646 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1647 remote_ost_nodsh && skip "remote OST with nodsh" && return
1649 exhaust_all_precreations 0x215
1652 test_mkdir -p $DIR/$tdir
1653 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1655 touch $DIR/$tdir/$tfile
1656 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1658 for (( i=1; i < OSTCOUNT; i++ )); do
1659 do_facet ost$i lctl set_param fail_loc=0x705
1661 local START=`date +%s`
1662 createmany -o $DIR/$tdir/$tfile 32
1664 local FINISH=`date +%s`
1665 local TIMEOUT=`lctl get_param -n timeout`
1666 local PROCESS=$((FINISH - START))
1667 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1668 error "$FINISH - $START >= $TIMEOUT / 2"
1669 sleep $((TIMEOUT / 2 - PROCESS))
1672 run_test 27v "skip object creation on slow OST ================="
1674 test_27w() { # bug 10997
1675 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1676 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1677 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1678 error "stripe size $size != 65536" || true
1679 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1680 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1682 run_test 27w "check $SETSTRIPE -S option"
1685 [[ $OSTCOUNT -lt 2 ]] &&
1686 skip_env "skipping multiple stripe count/offset test" && return
1688 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1689 for i in $(seq 1 $OSTCOUNT); do
1691 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1692 error "setstripe -c $i -i $offset failed"
1693 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1694 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1695 [ $count -ne $i ] && error "stripe count $count != $i" || true
1696 [ $index -ne $offset ] &&
1697 error "stripe offset $index != $offset" || true
1700 run_test 27wa "check $SETSTRIPE -c -i options"
1703 remote_ost_nodsh && skip "remote OST with nodsh" && return
1704 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1706 OFFSET=$(($OSTCOUNT - 1))
1708 local OST=$(ostname_from_index $OSTIDX)
1710 test_mkdir -p $DIR/$tdir
1711 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1712 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1714 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1715 for i in `seq 0 $OFFSET`; do
1716 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1717 error "OST0 was degraded but new created file still use it"
1719 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1721 run_test 27x "create files while OST0 is degraded"
1724 [[ $OSTCOUNT -lt 2 ]] &&
1725 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1726 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1727 remote_ost_nodsh && skip "remote OST with nodsh" && return
1728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1730 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1731 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1732 osc.$mdtosc.prealloc_last_id)
1733 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1734 osc.$mdtosc.prealloc_next_id)
1735 local fcount=$((last_id - next_id))
1736 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1737 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1739 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1740 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1741 local OST_DEACTIVE_IDX=-1
1746 for OSC in $MDS_OSCS; do
1747 OST=$(osc_to_ost $OSC)
1748 OSTIDX=$(index_from_ostuuid $OST)
1749 if [ $OST_DEACTIVE_IDX == -1 ]; then
1750 OST_DEACTIVE_IDX=$OSTIDX
1752 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1753 echo $OSC "is Deactivated:"
1754 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1758 OSTIDX=$(index_from_ostuuid $OST)
1760 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1762 for OSC in $MDS_OSCS; do
1763 OST=$(osc_to_ost $OSC)
1764 OSTIDX=$(index_from_ostuuid $OST)
1765 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1766 echo $OST "is degraded:"
1767 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1768 obdfilter.$OST.degraded=1
1773 createmany -o $DIR/$tdir/$tfile $fcount
1775 for OSC in $MDS_OSCS; do
1776 OST=$(osc_to_ost $OSC)
1777 OSTIDX=$(index_from_ostuuid $OST)
1778 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1779 echo $OST "is recovered from degraded:"
1780 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1781 obdfilter.$OST.degraded=0
1783 do_facet $SINGLEMDS lctl --device %$OSC activate
1787 # all osp devices get activated, hence -1 stripe count restored
1790 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1791 # devices get activated.
1793 $SETSTRIPE -c -1 $DIR/$tfile
1794 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1796 [ $stripecnt -ne $OSTCOUNT ] &&
1797 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1800 run_test 27y "create files while OST0 is degraded and the rest inactive"
1806 lmm_count=$($GETSTRIPE -c $1)
1807 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1808 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1810 local old_ifs="$IFS"
1812 fid=($($LFS path2fid $1))
1815 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1816 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1818 # compare lmm_seq and lu_fid->f_seq
1819 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1820 # compare lmm_object_id and lu_fid->oid
1821 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1823 # check the trusted.fid attribute of the OST objects of the file
1824 local have_obdidx=false
1826 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1827 # skip lines up to and including "obdidx"
1828 [ -z "$obdidx" ] && break
1829 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1830 $have_obdidx || continue
1832 local ost=$((obdidx + 1))
1833 local dev=$(ostdevname $ost)
1836 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1838 seq=$(echo $seq | sed -e "s/^0x//g")
1839 if [ $seq == 0 ]; then
1840 oid_hex=$(echo $oid)
1842 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1844 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1848 # Don't unmount/remount the OSTs if we don't need to do that.
1849 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1850 # update too, until that use mount/ll_decode_filter_fid/mount.
1851 # Re-enable when debugfs will understand new filter_fid.
1853 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1854 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1855 $dev 2>/dev/null" | grep "parent=")
1858 mount_fstype ost$ost
1859 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1860 $(facet_mntpt ost$ost)/$obj_file)
1861 unmount_fstype ost$ost
1862 start ost$ost $dev $OST_MOUNT_OPTS
1865 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1867 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1869 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1870 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1871 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1872 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1873 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1875 if echo $ff_parent | grep -q 'stripe='; then
1876 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1879 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1880 # into f_ver in this case. See the comment on
1883 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1887 # compare lmm_seq and filter_fid->ff_parent.f_seq
1888 [ $ff_pseq = $lmm_seq ] ||
1889 error "FF parent SEQ $ff_pseq != $lmm_seq"
1890 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1891 [ $ff_poid = $lmm_oid ] ||
1892 error "FF parent OID $ff_poid != $lmm_oid"
1893 (($ff_pstripe == $stripe_nr)) ||
1894 error "FF stripe $ff_pstripe != $stripe_nr"
1896 stripe_nr=$((stripe_nr + 1))
1901 remote_ost_nodsh && skip "remote OST with nodsh" && return
1902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1903 test_mkdir -p $DIR/$tdir
1905 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1906 { error "setstripe -c -1 failed"; return 1; }
1907 # We need to send a write to every object to get parent FID info set.
1908 # This _should_ also work for setattr, but does not currently.
1909 # touch $DIR/$tdir/$tfile-1 ||
1910 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1911 { error "dd $tfile-1 failed"; return 2; }
1912 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1913 { error "setstripe -c -1 failed"; return 3; }
1914 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1915 { error "dd $tfile-2 failed"; return 4; }
1917 # make sure write RPCs have been sent to OSTs
1920 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1921 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1923 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1925 test_27A() { # b=19102
1926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1927 local restore_size=$($GETSTRIPE -S $MOUNT)
1928 local restore_count=$($GETSTRIPE -c $MOUNT)
1929 local restore_offset=$($GETSTRIPE -i $MOUNT)
1930 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1931 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1932 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1933 local default_size=$($GETSTRIPE -S $MOUNT)
1934 local default_offset=$($GETSTRIPE -i $MOUNT)
1935 local dsize=$((1024 * 1024))
1936 [ $default_size -eq $dsize ] ||
1937 error "stripe size $default_size != $dsize"
1938 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1939 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1941 run_test 27A "check filesystem-wide default LOV EA values"
1943 test_27B() { # LU-2523
1944 test_mkdir -p $DIR/$tdir
1945 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1947 # open f1 with O_LOV_DELAY_CREATE
1949 # call setstripe ioctl on open file descriptor for f1
1951 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1955 # open f1 with O_LOV_DELAY_CREATE
1957 # call setstripe ioctl on open file descriptor for f1
1959 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1961 # Allow multiop to fail in imitation of NFS's busted semantics.
1964 run_test 27B "call setstripe on open unlinked file/rename victim"
1966 test_27C() { #LU-2871
1967 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1975 test_mkdir -p $DIR/$tdir
1977 for i in $(seq 0 $((OSTCOUNT - 1))); do
1978 # set stripe across all OSTs starting from OST$i
1979 $SETSTRIPE -i $i -c -1 $tfile$i
1980 # get striping information
1981 ost_idx=($($GETSTRIPE $tfile$i |
1982 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1986 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1987 error "${#ost_idx[@]} != $OSTCOUNT"
1989 for index in $(seq 0 $((OSTCOUNT - 1))); do
1991 for j in $(echo ${ost_idx[@]}); do
1992 if [ $index -eq $j ]; then
1998 error "Can not find $index in ${ost_idx[@]}"
2002 run_test 27C "check full striping across all OSTs"
2005 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2006 local POOL=${POOL:-testpool}
2008 local last_ost=$(($OSTCOUNT - 1))
2010 local ost_list=$(seq $first_ost $ost_step $last_ost)
2011 local ost_range="$first_ost $last_ost $ost_step"
2014 pool_add $POOL || error "pool_add failed"
2015 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2016 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2017 error "llapi_layout_test failed"
2018 cleanup_pools || error "cleanup_pools failed"
2020 run_test 27D "validate llapi_layout API"
2022 # createtest also checks that device nodes are created and
2023 # then visible correctly (#2091)
2024 test_28() { # bug 2091
2026 $CREATETEST $DIR/d28/ct || error
2028 run_test 28 "create/mknod/mkdir with bad file types ============"
2031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2032 cancel_lru_locks mdc
2038 declare -i LOCKCOUNTORIG=0
2039 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2040 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2042 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2044 declare -i LOCKUNUSEDCOUNTORIG=0
2045 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2046 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2053 declare -i LOCKCOUNTCURRENT=0
2054 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2055 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2058 declare -i LOCKUNUSEDCOUNTCURRENT=0
2059 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2060 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2063 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2064 $LCTL set_param -n ldlm.dump_namespaces ""
2065 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2066 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2067 log "dumped log to $TMP/test_29.dk (bug 5793)"
2070 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2071 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2072 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2073 log "dumped log to $TMP/test_29.dk (bug 5793)"
2077 run_test 29 "IT_GETATTR regression ============================"
2079 test_30a() { # was test_30
2080 cp $(which ls) $DIR || cp /bin/ls $DIR
2084 run_test 30a "execute binary from Lustre (execve) =============="
2087 cp `which ls` $DIR || cp /bin/ls $DIR
2089 $RUNAS $DIR/ls / || error
2092 run_test 30b "execute binary from Lustre as non-root ==========="
2094 test_30c() { # b=22376
2095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2096 cp `which ls` $DIR || cp /bin/ls $DIR
2098 cancel_lru_locks mdc
2099 cancel_lru_locks osc
2100 $RUNAS $DIR/ls / || error
2103 run_test 30c "execute binary from Lustre without read perms ===="
2106 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2107 $CHECKSTAT -a $DIR/f31 || error
2109 run_test 31a "open-unlink file =================================="
2112 touch $DIR/f31 || error
2113 ln $DIR/f31 $DIR/f31b || error
2114 $MULTIOP $DIR/f31b Ouc || error
2115 $CHECKSTAT -t file $DIR/f31 || error
2117 run_test 31b "unlink file with multiple links while open ======="
2120 touch $DIR/f31 || error
2121 ln $DIR/f31 $DIR/f31c || error
2122 multiop_bg_pause $DIR/f31 O_uc || return 1
2124 $MULTIOP $DIR/f31c Ouc
2125 kill -USR1 $MULTIPID
2128 run_test 31c "open-unlink file with multiple links ============="
2131 opendirunlink $DIR/d31d $DIR/d31d || error
2132 $CHECKSTAT -a $DIR/d31d || error
2134 run_test 31d "remove of open directory ========================="
2136 test_31e() { # bug 2904
2137 check_kernel_version 34 || return 0
2138 openfilleddirunlink $DIR/d31e || error
2140 run_test 31e "remove of open non-empty directory ==============="
2142 test_31f() { # bug 4554
2143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2145 test_mkdir $DIR/d31f
2146 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2147 cp /etc/hosts $DIR/d31f
2149 $GETSTRIPE $DIR/d31f/hosts
2150 multiop_bg_pause $DIR/d31f D_c || return 1
2153 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2154 test_mkdir $DIR/d31f
2155 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2156 cp /etc/hosts $DIR/d31f
2158 $GETSTRIPE $DIR/d31f/hosts
2159 multiop_bg_pause $DIR/d31f D_c || return 1
2162 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2163 wait $MULTIPID || error "first opendir $MULTIPID failed"
2167 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2168 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2171 run_test 31f "remove of open directory with open-unlink file ==="
2174 echo "-- cross directory link --"
2175 test_mkdir -c1 $DIR/${tdir}ga
2176 test_mkdir -c1 $DIR/${tdir}gb
2177 touch $DIR/${tdir}ga/f
2178 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2179 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2180 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2181 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2182 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2184 run_test 31g "cross directory link==============="
2187 echo "-- cross directory link --"
2188 test_mkdir -c1 $DIR/${tdir}
2189 test_mkdir -c1 $DIR/${tdir}/dir
2190 touch $DIR/${tdir}/f
2191 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2192 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2193 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2194 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2195 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2197 run_test 31h "cross directory link under child==============="
2200 echo "-- cross directory link --"
2201 test_mkdir -c1 $DIR/$tdir
2202 test_mkdir -c1 $DIR/$tdir/dir
2203 touch $DIR/$tdir/dir/f
2204 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2205 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2206 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2207 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2208 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2210 run_test 31i "cross directory link under parent==============="
2213 test_mkdir -c1 -p $DIR/$tdir
2214 test_mkdir -c1 -p $DIR/$tdir/dir1
2215 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2216 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2217 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2218 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2221 run_test 31j "link for directory==============="
2224 test_mkdir -c1 -p $DIR/$tdir
2226 touch $DIR/$tdir/exist
2227 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2228 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2229 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2230 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2231 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2232 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2233 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2236 run_test 31k "link to file: the same, non-existing, dir==============="
2242 touch $DIR/d31m2/exist
2243 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2244 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2245 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2246 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2247 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2248 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2251 run_test 31m "link to file: the same, non-existing, dir==============="
2254 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2255 nlink=$(stat --format=%h $DIR/$tfile)
2256 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2258 local cmd="exec $fd<$DIR/$tfile"
2261 trap "eval $cmd" EXIT
2262 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2263 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2264 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2265 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2266 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2269 run_test 31n "check link count of unlinked file"
2272 local TEMPNAME=$(mktemp $1_XXXXXX)
2273 mlink $TEMPNAME $1 2> /dev/null &&
2274 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2278 test_31o() { # LU-2901
2280 for LOOP in $(seq 100); do
2281 rm -f $DIR/$tdir/$tfile*
2282 for THREAD in $(seq 8); do
2283 link_one $DIR/$tdir/$tfile.$LOOP &
2286 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2287 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2288 error "$LINKS duplicate links to $tfile.$LOOP" &&
2292 run_test 31o "duplicate hard links with same filename"
2295 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2298 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2299 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2301 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2302 error "open unlink test1 failed"
2303 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2304 error "open unlink test2 failed"
2306 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2307 error "test1 still exists"
2308 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2309 error "test2 still exists"
2311 run_test 31p "remove of open striped directory"
2313 cleanup_test32_mount() {
2315 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2319 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2320 echo "== more mountpoints and symlinks ================="
2321 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2322 trap cleanup_test32_mount EXIT
2323 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2324 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2325 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2326 cleanup_test32_mount
2328 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2331 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2332 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
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 || error
2336 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2337 cleanup_test32_mount
2339 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2343 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2344 trap cleanup_test32_mount EXIT
2345 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2346 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2347 test_mkdir -p $DIR/$tdir/d2/test_dir
2348 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2349 cleanup_test32_mount
2351 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2355 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2356 trap cleanup_test32_mount EXIT
2357 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2358 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2359 test_mkdir -p $DIR/$tdir/d2/test_dir
2360 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2361 cleanup_test32_mount
2363 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2366 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2367 test_mkdir -p $DIR/d32e/tmp
2368 TMP_DIR=$DIR/d32e/tmp
2369 ln -s $DIR/d32e $TMP_DIR/symlink11
2370 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2371 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2372 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2374 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2377 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2378 test_mkdir -p $DIR/d32f/tmp
2379 TMP_DIR=$DIR/d32f/tmp
2380 ln -s $DIR/d32f $TMP_DIR/symlink11
2381 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2382 ls $DIR/d32f/tmp/symlink11 || error
2383 ls $DIR/d32f/symlink01 || error
2385 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2388 TMP_DIR=$DIR/$tdir/tmp
2389 test_mkdir -p $DIR/$tdir/tmp
2390 test_mkdir $DIR/${tdir}2
2391 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2392 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2393 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2394 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2395 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2396 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2398 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2401 rm -fr $DIR/$tdir $DIR/${tdir}2
2402 TMP_DIR=$DIR/$tdir/tmp
2403 test_mkdir -p $DIR/$tdir/tmp
2404 test_mkdir $DIR/${tdir}2
2405 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2406 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2407 ls $TMP_DIR/symlink12 || error
2408 ls $DIR/$tdir/symlink02 || error
2410 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2414 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2415 trap cleanup_test32_mount EXIT
2416 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2417 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2418 touch $DIR/$tdir/test_file
2419 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2420 cleanup_test32_mount
2422 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2426 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2427 trap cleanup_test32_mount EXIT
2428 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2429 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2430 touch $DIR/$tdir/test_file
2431 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2432 cleanup_test32_mount
2434 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2439 trap cleanup_test32_mount EXIT
2440 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2441 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2442 test_mkdir -p $DIR/$tdir/d2
2443 touch $DIR/$tdir/d2/test_file || error
2444 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2445 cleanup_test32_mount
2447 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2452 trap cleanup_test32_mount EXIT
2453 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2454 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2455 test_mkdir -p $DIR/$tdir/d2
2456 touch $DIR/$tdir/d2/test_file
2457 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2458 cleanup_test32_mount
2460 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2464 test_mkdir -p $DIR/d32m/tmp
2465 TMP_DIR=$DIR/d32m/tmp
2466 ln -s $DIR $TMP_DIR/symlink11
2467 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2468 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2469 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2471 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2475 test_mkdir -p $DIR/d32n/tmp
2476 TMP_DIR=$DIR/d32n/tmp
2477 ln -s $DIR $TMP_DIR/symlink11
2478 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2479 ls -l $DIR/d32n/tmp/symlink11 || error
2480 ls -l $DIR/d32n/symlink01 || error
2482 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2486 test_mkdir -p $DIR/d32o/tmp
2487 TMP_DIR=$DIR/d32o/tmp
2488 ln -s $DIR/$tfile $TMP_DIR/symlink12
2489 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2490 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2491 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2492 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2493 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2495 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2505 test_mkdir -p $DIR/d32p/tmp
2507 TMP_DIR=$DIR/d32p/tmp
2509 ln -s $DIR/$tfile $TMP_DIR/symlink12
2511 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2513 cat $DIR/d32p/tmp/symlink12 || error
2515 cat $DIR/d32p/symlink02 || error
2518 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2520 cleanup_testdir_mount() {
2522 $UMOUNT -d $DIR/$tdir
2526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2527 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2528 trap cleanup_testdir_mount EXIT
2529 test_mkdir -p $DIR/$tdir
2530 touch $DIR/$tdir/under_the_mount
2531 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2532 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2533 cleanup_testdir_mount
2535 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2539 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2540 trap cleanup_testdir_mount EXIT
2541 test_mkdir -p $DIR/$tdir
2542 touch $DIR/$tdir/under_the_mount
2543 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2544 ls $DIR/$tdir | grep -q under_the_mount && error || true
2545 cleanup_testdir_mount
2547 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2552 chmod 444 $DIR/$tfile
2553 chown $RUNAS_ID $DIR/$tfile
2555 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2558 run_test 33aa "write file with mode 444 (should return error) ===="
2562 test_mkdir -p $DIR/d33
2563 chown $RUNAS_ID $DIR/d33
2564 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2565 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2566 error "open RDWR" || true
2568 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2572 test_mkdir -p $DIR/d33
2573 chown $RUNAS_ID $DIR/d33
2574 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2576 run_test 33b "test open file with malformed flags (No panic)"
2579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2585 remote_ost_nodsh && skip "remote OST with nodsh" && return
2588 test_mkdir -p $DIR/d33
2589 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2592 for ostnum in $(seq $OSTCOUNT); do
2593 # test-framework's OST numbering is one-based, while Lustre's
2595 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2596 # Parsing llobdstat's output sucks; we could grep the /proc
2597 # path, but that's likely to not be as portable as using the
2598 # llobdstat utility. So we parse lctl output instead.
2599 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2600 obdfilter/$ostname/stats |
2601 awk '/^write_bytes/ {print $7}' )
2602 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2603 if (( ${write_bytes:-0} > 0 ))
2610 $all_zeros || return 0
2613 echo foo > $DIR/d33/bar
2617 # Total up write_bytes after writing. We'd better find non-zeros.
2618 for ostnum in $(seq $OSTCOUNT); do
2619 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2620 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2621 obdfilter/$ostname/stats |
2622 awk '/^write_bytes/ {print $7}' )
2623 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2624 if (( ${write_bytes:-0} > 0 ))
2633 for ostnum in $(seq $OSTCOUNT); do
2634 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2635 echo "Check that write_bytes is present in obdfilter/*/stats:"
2636 do_facet ost$ostnum lctl get_param -n \
2637 obdfilter/$ostname/stats
2639 error "OST not keeping write_bytes stats (b22312)"
2642 run_test 33c "test llobdstat and write_bytes"
2645 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2646 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2648 local remote_dir=$DIR/$tdir/remote_dir
2651 $LFS mkdir -i $MDTIDX $remote_dir ||
2652 error "create remote directory failed"
2654 touch $remote_dir/$tfile
2655 chmod 444 $remote_dir/$tfile
2656 chown $RUNAS_ID $remote_dir/$tfile
2658 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2660 chown $RUNAS_ID $remote_dir
2661 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2662 error "create" || true
2663 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2664 error "open RDWR" || true
2665 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2666 error "create" || true
2668 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2671 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2675 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2676 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2677 mkdir $DIR/$tdir/local_dir
2679 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2680 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2681 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2683 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2684 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2686 rmdir $DIR/$tdir/* || error "rmdir failed"
2689 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2690 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2691 mkdir $DIR/$tdir/local_dir
2693 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2694 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2695 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2697 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2698 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2700 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2703 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2704 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2705 mkdir $DIR/$tdir/local_dir
2707 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2708 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2709 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2711 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2712 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2714 run_test 33e "mkdir and striped directory should have same mode"
2716 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2719 $MCREATE $DIR/f34 || error
2720 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2721 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2722 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2723 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2725 run_test 34a "truncate file that has not been opened ==========="
2728 [ ! -f $DIR/f34 ] && test_34a
2729 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2730 $OPENFILE -f O_RDONLY $DIR/f34
2731 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2732 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2734 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2737 [ ! -f $DIR/f34 ] && test_34a
2738 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2739 $OPENFILE -f O_RDWR $DIR/f34
2740 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2741 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2743 run_test 34c "O_RDWR opening file-with-size works =============="
2746 [ ! -f $DIR/f34 ] && test_34a
2747 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2748 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2751 run_test 34d "write to sparse file ============================="
2755 $MCREATE $DIR/f34e || error
2756 $TRUNCATE $DIR/f34e 1000 || error
2757 $CHECKSTAT -s 1000 $DIR/f34e || error
2758 $OPENFILE -f O_RDWR $DIR/f34e
2759 $CHECKSTAT -s 1000 $DIR/f34e || error
2761 run_test 34e "create objects, some with size and some without =="
2763 test_34f() { # bug 6242, 6243
2764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2767 $MCREATE $DIR/f34f || error
2768 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2769 dd if=$DIR/f34f of=$TMP/f34f
2770 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2771 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2772 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2773 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2774 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2776 run_test 34f "read from a file with no objects until EOF ======="
2779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2780 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2781 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2782 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2783 cancel_lru_locks osc
2784 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2785 error "wrong size after lock cancel"
2787 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2788 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2789 error "expanding truncate failed"
2790 cancel_lru_locks osc
2791 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2792 error "wrong expanded size after lock cancel"
2794 run_test 34g "truncate long file ==============================="
2797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2801 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2802 sync # Flush the cache so that multiop below does not block on cache
2803 # flush when getting the group lock
2804 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2807 # Since just timed wait is not good enough, let's do a sync write
2808 # that way we are sure enough time for a roundtrip + processing
2809 # passed + 2 seconds of extra margin.
2810 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2814 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2815 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2819 local nsz=`stat -c %s $DIR/$tfile`
2820 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2822 run_test 34h "ftruncate file under grouplock should not block"
2825 cp /bin/sh $DIR/f35a
2827 chown $RUNAS_ID $DIR/f35a
2828 $RUNAS $DIR/f35a && error || true
2831 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2835 utime $DIR/f36 || error
2837 run_test 36a "MDS utime check (mknod, utime) ==================="
2841 utime $DIR/f36 || error
2843 run_test 36b "OST utime check (open, utime) ===================="
2848 chown $RUNAS_ID $DIR/d36
2849 $RUNAS utime $DIR/d36/f36 || error
2851 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2854 [ ! -d $DIR/d36 ] && test_36c
2855 echo "" > $DIR/d36/f36
2856 $RUNAS utime $DIR/d36/f36 || error
2858 run_test 36d "non-root OST utime check (open, utime) ==========="
2861 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2862 test_mkdir -p $DIR/$tdir
2863 touch $DIR/$tdir/$tfile
2864 $RUNAS utime $DIR/$tdir/$tfile && \
2865 error "utime worked, expected failure" || true
2867 run_test 36e "utime on non-owned file (should return error) ===="
2871 local LANG_SAVE=$LANG
2872 local LC_LANG_SAVE=$LC_LANG
2873 export LANG=C LC_LANG=C # for date language
2875 DATESTR="Dec 20 2000"
2876 test_mkdir -p $DIR/$tdir
2877 lctl set_param fail_loc=$fl
2879 cp /etc/hosts $DIR/$tdir/$tfile
2880 sync & # write RPC generated with "current" inode timestamp, but delayed
2882 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2883 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2884 cancel_lru_locks osc
2885 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2887 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2888 echo "BEFORE: $LS_BEFORE" && \
2889 echo "AFTER : $LS_AFTER" && \
2890 echo "WANT : $DATESTR" && \
2891 error "$DIR/$tdir/$tfile timestamps changed" || true
2893 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2898 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2899 subr_36fh "0x80000214"
2901 run_test 36f "utime on file racing with OST BRW write =========="
2904 remote_ost_nodsh && skip "remote OST with nodsh" && return
2905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2910 test_mkdir -p $DIR/$tdir
2911 fmd_max_age=$(do_facet ost1 \
2912 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2915 fmd_before=$(do_facet ost1 \
2916 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2917 touch $DIR/$tdir/$tfile
2918 sleep $((fmd_max_age + 12))
2919 fmd_after=$(do_facet ost1 \
2920 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2922 echo "fmd_before: $fmd_before"
2923 echo "fmd_after: $fmd_after"
2924 [[ $fmd_after -gt $fmd_before ]] &&
2925 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2926 error "fmd didn't expire after ping" || true
2928 run_test 36g "filter mod data cache expiry ====================="
2931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2932 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2933 subr_36fh "0x80000227"
2935 run_test 36h "utime on file racing with OST BRW write =========="
2938 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2941 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2943 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2944 local new_mtime=$((mtime + 200))
2946 #change Modify time of striped dir
2947 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2948 error "change mtime failed"
2950 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2952 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2954 run_test 36i "change mtime on striped directory"
2956 # test_37 - duplicate with tests 32q 32r
2959 local file=$DIR/$tfile
2961 openfile -f O_DIRECTORY $file
2964 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2965 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2967 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2971 touch $DIR/${tfile}2
2972 # ls -l $DIR/$tfile $DIR/${tfile}2
2973 # ls -lu $DIR/$tfile $DIR/${tfile}2
2974 # ls -lc $DIR/$tfile $DIR/${tfile}2
2976 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2977 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2979 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2981 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2983 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2984 error "O_TRUNC didn't change timestamps"
2987 run_test 39 "mtime changed on create ==========================="
2990 test_mkdir -p -c1 $DIR/$tdir
2991 cp -p /etc/passwd $DIR/$tdir/fopen
2992 cp -p /etc/passwd $DIR/$tdir/flink
2993 cp -p /etc/passwd $DIR/$tdir/funlink
2994 cp -p /etc/passwd $DIR/$tdir/frename
2995 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2998 echo "aaaaaa" >> $DIR/$tdir/fopen
2999 echo "aaaaaa" >> $DIR/$tdir/flink
3000 echo "aaaaaa" >> $DIR/$tdir/funlink
3001 echo "aaaaaa" >> $DIR/$tdir/frename
3003 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3004 local link_new=`stat -c %Y $DIR/$tdir/flink`
3005 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3006 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3008 cat $DIR/$tdir/fopen > /dev/null
3009 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3010 rm -f $DIR/$tdir/funlink2
3011 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3013 for (( i=0; i < 2; i++ )) ; do
3014 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3015 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3016 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3017 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3019 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3020 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3021 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3022 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3024 cancel_lru_locks osc
3025 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3028 run_test 39b "mtime change on open, link, unlink, rename ======"
3030 # this should be set to past
3031 TEST_39_MTIME=`date -d "1 year ago" +%s`
3037 local mtime0=`stat -c %Y $DIR1/$tfile`
3039 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3040 local mtime1=`stat -c %Y $DIR1/$tfile`
3041 [ "$mtime1" = $TEST_39_MTIME ] || \
3042 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3045 echo hello >> $DIR1/$tfile
3047 local mtime2=`stat -c %Y $DIR1/$tfile`
3048 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3049 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3051 mv $DIR1/$tfile $DIR1/$tfile-1
3053 for (( i=0; i < 2; i++ )) ; do
3054 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3055 [ "$mtime2" = "$mtime3" ] || \
3056 error "mtime ($mtime2) changed (to $mtime3) on rename"
3058 cancel_lru_locks osc
3059 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3062 run_test 39c "mtime change on rename ==========================="
3066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3069 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3071 for (( i=0; i < 2; i++ )) ; do
3072 local mtime=`stat -c %Y $DIR1/$tfile`
3073 [ $mtime = $TEST_39_MTIME ] || \
3074 error "mtime($mtime) is not set to $TEST_39_MTIME"
3076 cancel_lru_locks osc
3077 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3080 run_test 39d "create, utime, stat =============================="
3084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3086 local mtime1=`stat -c %Y $DIR1/$tfile`
3088 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3090 for (( i=0; i < 2; i++ )) ; do
3091 local mtime2=`stat -c %Y $DIR1/$tfile`
3092 [ $mtime2 = $TEST_39_MTIME ] || \
3093 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3095 cancel_lru_locks osc
3096 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3099 run_test 39e "create, stat, utime, stat ========================"
3103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3105 mtime1=`stat -c %Y $DIR1/$tfile`
3108 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3110 for (( i=0; i < 2; i++ )) ; do
3111 local mtime2=`stat -c %Y $DIR1/$tfile`
3112 [ $mtime2 = $TEST_39_MTIME ] || \
3113 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3115 cancel_lru_locks osc
3116 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3119 run_test 39f "create, stat, sleep, utime, stat ================="
3123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3124 echo hello >> $DIR1/$tfile
3125 local mtime1=`stat -c %Y $DIR1/$tfile`
3128 chmod o+r $DIR1/$tfile
3130 for (( i=0; i < 2; i++ )) ; do
3131 local mtime2=`stat -c %Y $DIR1/$tfile`
3132 [ "$mtime1" = "$mtime2" ] || \
3133 error "lost mtime: $mtime2, should be $mtime1"
3135 cancel_lru_locks osc
3136 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3139 run_test 39g "write, chmod, stat ==============================="
3143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3148 echo hello >> $DIR1/$tfile
3149 local mtime1=`stat -c %Y $DIR1/$tfile`
3151 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3153 if [ "$d1" != "$d2" ]; then
3154 echo "write and touch not within one second"
3156 for (( i=0; i < 2; i++ )) ; do
3157 local mtime2=`stat -c %Y $DIR1/$tfile`
3158 [ "$mtime2" = $TEST_39_MTIME ] || \
3159 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3161 cancel_lru_locks osc
3162 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3166 run_test 39h "write, utime within one second, stat ============="
3169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3173 echo hello >> $DIR1/$tfile
3174 local mtime1=`stat -c %Y $DIR1/$tfile`
3176 mv $DIR1/$tfile $DIR1/$tfile-1
3178 for (( i=0; i < 2; i++ )) ; do
3179 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3181 [ "$mtime1" = "$mtime2" ] || \
3182 error "lost mtime: $mtime2, should be $mtime1"
3184 cancel_lru_locks osc
3185 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3188 run_test 39i "write, rename, stat =============================="
3191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3192 start_full_debug_logging
3196 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3197 lctl set_param fail_loc=0x80000412
3198 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3199 error "multiop failed"
3201 local mtime1=`stat -c %Y $DIR1/$tfile`
3203 mv $DIR1/$tfile $DIR1/$tfile-1
3205 kill -USR1 $multipid
3206 wait $multipid || error "multiop close failed"
3208 for (( i=0; i < 2; i++ )) ; do
3209 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3210 [ "$mtime1" = "$mtime2" ] ||
3211 error "mtime is lost on close: $mtime2, " \
3214 cancel_lru_locks osc
3215 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3217 lctl set_param fail_loc=0
3218 stop_full_debug_logging
3220 run_test 39j "write, rename, close, stat ======================="
3223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3227 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3229 local mtime1=`stat -c %Y $DIR1/$tfile`
3231 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3233 kill -USR1 $multipid
3234 wait $multipid || error "multiop close failed"
3236 for (( i=0; i < 2; i++ )) ; do
3237 local mtime2=`stat -c %Y $DIR1/$tfile`
3239 [ "$mtime2" = $TEST_39_MTIME ] || \
3240 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3242 cancel_lru_locks osc
3243 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3246 run_test 39k "write, utime, close, stat ========================"
3248 # this should be set to future
3249 TEST_39_ATIME=`date -d "1 year" +%s`
3252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3253 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3254 local atime_diff=$(do_facet $SINGLEMDS \
3255 lctl get_param -n mdd.*MDT0000*.atime_diff)
3259 # test setting directory atime to future
3260 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3261 local atime=$(stat -c %X $DIR/$tdir)
3262 [ "$atime" = $TEST_39_ATIME ] || \
3263 error "atime is not set to future: $atime, $TEST_39_ATIME"
3265 # test setting directory atime from future to now
3266 local d1=$(date +%s)
3268 local d2=$(date +%s)
3270 cancel_lru_locks mdc
3271 atime=$(stat -c %X $DIR/$tdir)
3272 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3273 error "atime is not updated from future: $atime, $d1<atime<$d2"
3275 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3278 # test setting directory atime when now > dir atime + atime_diff
3282 cancel_lru_locks mdc
3283 atime=$(stat -c %X $DIR/$tdir)
3284 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3285 error "atime is not updated : $atime, should be $d2"
3287 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3290 # test not setting directory atime when now < dir atime + atime_diff
3292 cancel_lru_locks mdc
3293 atime=$(stat -c %X $DIR/$tdir)
3294 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3295 error "atime is updated to $atime, should remain $d1<atime<$d2"
3297 do_facet $SINGLEMDS \
3298 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3300 run_test 39l "directory atime update ==========================="
3303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3306 local far_past_mtime=$(date -d "May 29 1953" +%s)
3307 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3309 touch -m -d @$far_past_mtime $DIR1/$tfile
3310 touch -a -d @$far_past_atime $DIR1/$tfile
3312 for (( i=0; i < 2; i++ )) ; do
3313 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3314 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3315 error "atime or mtime set incorrectly"
3317 cancel_lru_locks osc
3318 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3321 run_test 39m "test atime and mtime before 1970"
3323 test_39n() { # LU-3832
3324 local atime_diff=$(do_facet $SINGLEMDS \
3325 lctl get_param -n mdd.*MDT0000*.atime_diff)
3330 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3333 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3334 atime0=$(stat -c %X $DIR/$tfile)
3337 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3338 atime1=$(stat -c %X $DIR/$tfile)
3341 cancel_lru_locks mdc
3342 cancel_lru_locks osc
3343 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3344 atime2=$(stat -c %X $DIR/$tfile)
3346 do_facet $SINGLEMDS \
3347 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3349 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3350 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3352 run_test 39n "check that O_NOATIME is honored"
3355 TESTDIR=$DIR/$tdir/$tfile
3356 [ -e $TESTDIR ] && rm -rf $TESTDIR
3357 test_mkdir -p $TESTDIR
3363 links2=$(stat -c %h .)
3364 [ $(($links1 + 2)) != $links2 ] &&
3365 error "wrong links count $(($links1 + 2)) != $links2"
3367 links3=$(stat -c %h .)
3368 [ $(($links1 + 1)) != $links3 ] &&
3369 error "wrong links count $links1 != $links3"
3372 run_test 39o "directory cached attributes updated after create ========"
3375 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3377 TESTDIR=$DIR/$tdir/$tfile
3378 [ -e $TESTDIR ] && rm -rf $TESTDIR
3383 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3384 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3386 links2=$(stat -c %h .)
3387 [ $(($links1 + 2)) != $links2 ] &&
3388 error "wrong links count $(($links1 + 2)) != $links2"
3390 links3=$(stat -c %h .)
3391 [ $(($links1 + 1)) != $links3 ] &&
3392 error "wrong links count $links1 != $links3"
3395 run_test 39p "remote directory cached attributes updated after create ========"
3399 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3400 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3401 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3402 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3403 error "$tfile is not 4096 bytes in size"
3405 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3409 small_write $DIR/f41 18
3411 run_test 41 "test small file write + fstat ====================="
3413 count_ost_writes() {
3414 lctl get_param -n osc.*.stats |
3415 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3416 END { printf("%0.0f", writes) }'
3423 BG_DIRTY_RATIO_SAVE=10
3424 MAX_BG_DIRTY_RATIO=25
3428 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3429 # dirty_ratio, dirty_background_ratio
3430 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3431 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3432 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3433 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3435 # if file not here, we are a 2.4 kernel
3436 kill -CONT `pidof kupdated`
3441 # setup the trap first, so someone cannot exit the test at the
3442 # exact wrong time and mess up a machine
3443 trap start_writeback EXIT
3444 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3445 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3446 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3447 sysctl -w vm.dirty_writeback_centisecs=0
3448 sysctl -w vm.dirty_writeback_centisecs=0
3449 # save and increase /proc/sys/vm/dirty_ratio
3450 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3451 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3452 # save and increase /proc/sys/vm/dirty_background_ratio
3453 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3454 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3456 # if file not here, we are a 2.4 kernel
3457 kill -STOP `pidof kupdated`
3461 # ensure that all stripes have some grant before we test client-side cache
3463 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3464 dd if=/dev/zero of=$i bs=4k count=1
3469 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3470 # file truncation, and file removal.
3472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3474 cancel_lru_locks osc
3476 sync; sleep 1; sync # just to be safe
3477 BEFOREWRITES=`count_ost_writes`
3478 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3479 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3480 AFTERWRITES=`count_ost_writes`
3481 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3482 error "$BEFOREWRITES < $AFTERWRITES"
3485 run_test 42a "ensure that we don't flush on close =============="
3488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3490 cancel_lru_locks osc
3493 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3494 BEFOREWRITES=$(count_ost_writes)
3495 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3496 AFTERWRITES=$(count_ost_writes)
3497 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3498 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3500 BEFOREWRITES=$(count_ost_writes)
3501 sync || error "sync: $?"
3502 AFTERWRITES=$(count_ost_writes)
3503 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3504 error "$BEFOREWRITES < $AFTERWRITES on sync"
3506 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3510 run_test 42b "test destroy of file with cached dirty data ======"
3512 # if these tests just want to test the effect of truncation,
3513 # they have to be very careful. consider:
3514 # - the first open gets a {0,EOF}PR lock
3515 # - the first write conflicts and gets a {0, count-1}PW
3516 # - the rest of the writes are under {count,EOF}PW
3517 # - the open for truncate tries to match a {0,EOF}PR
3518 # for the filesize and cancels the PWs.
3519 # any number of fixes (don't get {0,EOF} on open, match
3520 # composite locks, do smarter file size management) fix
3521 # this, but for now we want these tests to verify that
3522 # the cancellation with truncate intent works, so we
3523 # start the file with a full-file pw lock to match against
3524 # until the truncate.
3529 cancel_lru_locks osc
3531 # prime the file with 0,EOF PW to match
3535 # now the real test..
3536 dd if=/dev/zero of=$file bs=1024 count=100
3537 BEFOREWRITES=`count_ost_writes`
3538 $TRUNCATE $file $offset
3539 cancel_lru_locks osc
3540 AFTERWRITES=`count_ost_writes`
3545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3547 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3548 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3551 run_test 42c "test partial truncate of file with cached dirty data"
3554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3556 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3557 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3560 run_test 42d "test complete truncate of file with cached dirty data"
3562 test_42e() { # bug22074
3563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3564 local TDIR=$DIR/${tdir}e
3565 local pagesz=$(page_size)
3566 local pages=16 # hardcoded 16 pages, don't change it.
3567 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3568 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3572 test_mkdir -p $DIR/${tdir}e
3573 $SETSTRIPE -c 1 $TDIR
3574 createmany -o $TDIR/f $files
3576 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3578 # we assume that with $OSTCOUNT files, at least one of them will
3579 # be allocated on OST0.
3580 warmup_files=$((OSTCOUNT * max_dirty_mb))
3581 createmany -o $TDIR/w $warmup_files
3583 # write a large amount of data into one file and sync, to get good
3584 # avail_grant number from OST.
3585 for ((i=0; i<$warmup_files; i++)); do
3586 idx=$($GETSTRIPE -i $TDIR/w$i)
3587 [ $idx -ne 0 ] && continue
3588 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3591 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3593 $LCTL get_param $proc_osc0/cur_dirty_bytes
3594 $LCTL get_param $proc_osc0/cur_grant_bytes
3596 # create as much dirty pages as we can while not to trigger the actual
3597 # RPCs directly. but depends on the env, VFS may trigger flush during this
3598 # period, hopefully we are good.
3599 for ((i=0; i<$warmup_files; i++)); do
3600 idx=$($GETSTRIPE -i $TDIR/w$i)
3601 [ $idx -ne 0 ] && continue
3602 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3604 $LCTL get_param $proc_osc0/cur_dirty_bytes
3605 $LCTL get_param $proc_osc0/cur_grant_bytes
3607 # perform the real test
3608 $LCTL set_param $proc_osc0/rpc_stats 0
3609 for ((;i<$files; i++)); do
3610 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3611 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3614 $LCTL get_param $proc_osc0/rpc_stats
3617 local have_ppr=false
3618 $LCTL get_param $proc_osc0/rpc_stats |
3619 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3620 # skip lines until we are at the RPC histogram data
3621 [ "$PPR" == "pages" ] && have_ppr=true && continue
3622 $have_ppr || continue
3624 # we only want the percent stat for < 16 pages
3625 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3627 percent=$((percent + WPCT))
3628 if [[ $percent -gt 15 ]]; then
3629 error "less than 16-pages write RPCs" \
3636 run_test 42e "verify sub-RPC writes are not done synchronously"
3639 test_mkdir -p $DIR/$tdir
3640 cp -p /bin/ls $DIR/$tdir/$tfile
3641 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3643 # give multiop a chance to open
3646 $DIR/$tdir/$tfile && error || true
3649 run_test 43 "execution of file opened for write should return -ETXTBSY"
3652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3653 test_mkdir -p $DIR/$tdir
3654 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3655 cp -p multiop $DIR/$tdir/multiop
3656 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3659 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3660 kill -USR1 $MULTIOP_PID || return 2
3661 wait $MULTIOP_PID || return 3
3662 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3664 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3668 test_mkdir -p $DIR/$tdir
3669 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3670 cp -p multiop $DIR/$tdir/multiop
3671 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3674 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3675 kill -USR1 $MULTIOP_PID || return 2
3676 wait $MULTIOP_PID || return 3
3677 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3679 run_test 43b "truncate of file being executed should return -ETXTBSY"
3682 local testdir="$DIR/$tdir"
3683 test_mkdir -p $DIR/$tdir
3685 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3686 ( cd $testdir && md5sum -c)
3688 run_test 43c "md5sum of copy into lustre========================"
3691 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3692 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3693 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3695 run_test 44 "zero length read from a sparse stripe ============="
3698 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3700 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3701 [[ $nstripe -gt $OSTCOUNT ]] &&
3702 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3704 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3706 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3707 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3711 OFFSETS="0 $((stride/2)) $((stride-1))"
3712 for offset in $OFFSETS; do
3713 for i in $(seq 0 $((nstripe-1))); do
3714 local GLOBALOFFSETS=""
3716 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3717 local myfn=$DIR/d44a-$size
3718 echo "--------writing $myfn at $size"
3719 ll_sparseness_write $myfn $size ||
3720 error "ll_sparseness_write"
3721 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3722 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3723 error "ll_sparseness_verify $GLOBALOFFSETS"
3725 for j in $(seq 0 $((nstripe-1))); do
3727 size=$((((j + $nstripe )*$stride + $offset)))
3728 ll_sparseness_write $myfn $size ||
3729 error "ll_sparseness_write"
3730 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3732 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3733 error "ll_sparseness_verify $GLOBALOFFSETS"
3738 run_test 44a "test sparse pwrite ==============================="
3742 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3748 before=`dirty_osc_total`
3749 echo executing "\"$*\""
3751 after=`dirty_osc_total`
3752 echo before $before, after $after
3755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3757 # Obtain grants from OST if it supports it
3758 echo blah > ${f}_grant
3761 do_dirty_record "echo blah > $f"
3762 [[ $before -eq $after ]] && error "write wasn't cached"
3763 do_dirty_record "> $f"
3764 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3765 do_dirty_record "echo blah > $f"
3766 [[ $before -eq $after ]] && error "write wasn't cached"
3767 do_dirty_record "sync"
3768 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3769 do_dirty_record "echo blah > $f"
3770 [[ $before -eq $after ]] && error "write wasn't cached"
3771 do_dirty_record "cancel_lru_locks osc"
3772 [[ $before -gt $after ]] ||
3773 error "lock cancellation didn't lower dirty count"
3776 run_test 45 "osc io page accounting ============================"
3778 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3779 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3780 # objects offset and an assert hit when an rpc was built with 1023's mapped
3781 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3787 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3789 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3790 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3794 run_test 46 "dirtying a previously written page ================"
3796 # test_47 is removed "Device nodes check" is moved to test_28
3798 test_48a() { # bug 2399
3799 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3800 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3801 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3803 check_kernel_version 34 || return 0
3804 test_mkdir -p $DIR/$tdir
3806 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3807 test_mkdir $DIR/$tdir || error "recreate directory failed"
3808 touch foo || error "'touch foo' failed after recreating cwd"
3809 test_mkdir $DIR/$tdir/bar ||
3810 error "'mkdir foo' failed after recreating cwd"
3811 if check_kernel_version 44; then
3812 touch .foo || error "'touch .foo' failed after recreating cwd"
3813 test_mkdir $DIR/$tdir/.bar ||
3814 error "'mkdir .foo' failed after recreating cwd"
3816 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3817 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3818 cd . || error "'cd .' failed after recreating cwd"
3819 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3820 rmdir . && error "'rmdir .' worked after recreating cwd"
3821 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3822 cd .. || error "'cd ..' failed after recreating cwd"
3824 run_test 48a "Access renamed working dir (should return errors)="
3826 test_48b() { # bug 2399
3827 check_kernel_version 34 || return 0
3829 test_mkdir -p $DIR/$tdir
3831 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3832 touch foo && error "'touch foo' worked after removing cwd"
3833 test_mkdir $DIR/$tdir/foo &&
3834 error "'mkdir foo' worked after removing cwd"
3835 if check_kernel_version 44; then
3836 touch .foo && error "'touch .foo' worked after removing cwd"
3837 test_mkdir $DIR/$tdir/.foo &&
3838 error "'mkdir .foo' worked after removing cwd"
3840 ls . > /dev/null && error "'ls .' worked after removing cwd"
3841 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3842 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3843 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3844 rmdir . && error "'rmdir .' worked after removing cwd"
3845 ln -s . foo && error "'ln -s .' worked after removing cwd"
3846 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3848 run_test 48b "Access removed working dir (should return errors)="
3850 test_48c() { # bug 2350
3851 check_kernel_version 36 || return 0
3852 #lctl set_param debug=-1
3855 test_mkdir -p $DIR/$tdir/dir
3857 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3858 $TRACE touch foo && error "touch foo worked after removing cwd"
3859 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3860 if check_kernel_version 44; then
3861 touch .foo && error "touch .foo worked after removing cwd"
3862 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3864 $TRACE ls . && error "'ls .' worked after removing cwd"
3865 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3866 is_patchless || ( $TRACE cd . &&
3867 error "'cd .' worked after removing cwd" )
3868 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3869 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3870 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3871 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3873 run_test 48c "Access removed working subdir (should return errors)"
3875 test_48d() { # bug 2350
3876 check_kernel_version 36 || return 0
3877 #lctl set_param debug=-1
3880 test_mkdir -p $DIR/$tdir/dir
3882 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3883 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3884 $TRACE touch foo && error "'touch foo' worked after removing parent"
3885 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3886 if check_kernel_version 44; then
3887 touch .foo && error "'touch .foo' worked after removing parent"
3889 error "mkdir .foo worked after removing parent"
3891 $TRACE ls . && error "'ls .' worked after removing parent"
3892 $TRACE ls .. && error "'ls ..' worked after removing parent"
3893 is_patchless || ( $TRACE cd . &&
3894 error "'cd .' worked after recreate parent" )
3895 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3896 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3897 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3898 is_patchless || ( $TRACE cd .. &&
3899 error "'cd ..' worked after removing parent" || true )
3901 run_test 48d "Access removed parent subdir (should return errors)"
3903 test_48e() { # bug 4134
3904 check_kernel_version 41 || return 0
3905 #lctl set_param debug=-1
3908 test_mkdir -p $DIR/$tdir/dir
3910 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3911 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3912 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3913 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3914 # On a buggy kernel addition of "touch foo" after cd .. will
3915 # produce kernel oops in lookup_hash_it
3916 touch ../foo && error "'cd ..' worked after recreate parent"
3918 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3920 run_test 48e "Access to recreated parent subdir (should return errors)"
3922 test_49() { # LU-1030
3923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3924 # get ost1 size - lustre-OST0000
3925 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3927 # write 800M at maximum
3928 [[ $ost1_size -lt 2 ]] && ost1_size=2
3929 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3931 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3932 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3935 # change max_pages_per_rpc while writing the file
3936 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3937 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3938 # loop until dd process exits
3939 while ps ax -opid | grep -wq $dd_pid; do
3940 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3941 sleep $((RANDOM % 5 + 1))
3943 # restore original max_pages_per_rpc
3944 $LCTL set_param $osc1_mppc=$orig_mppc
3945 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3947 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3951 test_mkdir $DIR/$tdir
3953 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3955 run_test 50 "special situations: /proc symlinks ==============="
3957 test_51a() { # was test_51
3958 # bug 1516 - create an empty entry right after ".." then split dir
3959 test_mkdir -c1 $DIR/$tdir
3960 touch $DIR/$tdir/foo
3961 $MCREATE $DIR/$tdir/bar
3963 createmany -m $DIR/$tdir/longfile 201
3965 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3966 $MCREATE $DIR/$tdir/longfile$FNUM
3971 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3973 run_test 51a "special situations: split htree with empty entry =="
3975 export NUMTEST=70000
3977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3978 local BASE=$DIR/d${base}.${TESTSUITE}
3980 # cleanup the directory
3983 test_mkdir -p -c1 $BASE
3987 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3988 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3989 [[ $numfree -lt 21000 ]] &&
3990 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
3993 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3994 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
3996 # need to check free space for the directories as well
3997 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3998 numfree=$((blkfree / 4))
3999 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4000 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4002 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4006 echo "failed" > $BASE/fnum
4007 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4010 run_test 51b "exceed 64k subdirectory nlink limit"
4012 test_51ba() { # LU-993
4013 local BASE=$DIR/d${base}.${TESTSUITE}
4014 # unlink all but 100 subdirectories, then check it still works
4016 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4018 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4019 local DELETE=$((NUMTEST - LEFT))
4021 # continue on to run this test even if 51b didn't finish,
4022 # just to delete the many subdirectories created.
4023 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4025 # for ldiskfs the nlink count should be 1, but this is OSD specific
4026 # and so this is listed for informational purposes only
4027 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4028 unlinkmany -d $BASE/d $DELETE
4031 if [ $RC -ne 0 ]; then
4032 if [ "$NUMPREV" == "failed" ]; then
4033 skip "previous setup failed"
4036 error "unlink of first $DELETE subdirs failed"
4041 echo "nlink between: $(stat -c %h $BASE)"
4042 # trim the first line of ls output
4043 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4044 [ $FOUND -ne $LEFT ] &&
4045 error "can't find subdirs: found only $FOUND/$LEFT"
4047 unlinkmany -d $BASE/d $DELETE $LEFT ||
4048 error "unlink of second $LEFT subdirs failed"
4049 # regardless of whether the backing filesystem tracks nlink accurately
4050 # or not, the nlink count shouldn't be more than "." and ".." here
4051 local AFTER=$(stat -c %h $BASE)
4052 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4053 echo "nlink after: $AFTER"
4055 run_test 51ba "verify nlink for many subdirectory cleanup"
4058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4059 [[ $OSTCOUNT -lt 3 ]] &&
4060 skip_env "skipping test with few OSTs" && return
4061 test_mkdir -p $DIR/$tdir
4062 createmany -o $DIR/$tdir/t- 1000
4063 $GETSTRIPE $DIR/$tdir > $TMP/files
4064 for N in $(seq 0 $((OSTCOUNT - 1))); do
4065 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4066 END { printf("%0.0f", objs) }' $TMP/files)
4067 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4068 '($1 == '$N') { objs += 1 } \
4069 END { printf("%0.0f", objs) }')
4070 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4072 unlinkmany $DIR/$tdir/t- 1000
4075 for N in $(seq 1 $((OSTCOUNT - 1))); do
4076 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4077 error "OST $N has less objects vs OST $NLAST" \
4078 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4079 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4080 error "OST $N has less objects vs OST $NLAST" \
4081 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4083 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4084 error "OST $N has less #0 objects vs OST $NLAST" \
4085 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4086 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4087 error "OST $N has less #0 objects vs OST $NLAST" \
4088 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4092 run_test 51d "check object distribution ===================="
4095 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4096 skip "Only applicable to ldiskfs-based MDTs"
4100 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4101 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4103 touch $DIR/$tdir/d0/foo
4104 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4105 error "file exceed 65000 nlink limit!"
4106 unlinkmany $DIR/$tdir/d0/f- 65001
4109 run_test 51e "check file nlink limit"
4112 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4113 test_mkdir -p $DIR/$tdir
4114 touch $DIR/$tdir/foo
4115 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4116 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4117 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4118 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4119 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4121 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4122 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4123 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4125 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4126 cp -r $DIR/$tdir /tmp/
4127 rm -fr $DIR/$tdir || error "cleanup rm failed"
4129 run_test 52a "append-only flag test (should return errors) ====="
4132 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4133 test_mkdir -p $DIR/$tdir
4134 touch $DIR/$tdir/foo
4135 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4136 cat test > $DIR/$tdir/foo && error "cat test worked"
4137 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4138 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4139 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4141 echo foo >> $DIR/$tdir/foo && error "echo worked"
4142 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4143 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4144 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4145 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4147 chattr -i $DIR/$tdir/foo || error "chattr failed"
4149 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4151 run_test 52b "immutable flag test (should return errors) ======="
4154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4155 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4156 remote_ost_nodsh && skip "remote OST with nodsh" && return
4169 local support_last_seq=true
4171 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4172 support_last_seq=false
4175 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4177 for value in $(do_facet $SINGLEMDS \
4178 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4179 param=$(echo ${value[0]} | cut -d "=" -f1)
4180 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4182 if $support_last_seq; then
4183 param_seq=$(echo $param |
4184 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4185 mds_last_seq=$(do_facet $SINGLEMDS \
4186 $LCTL get_param -n $param_seq)
4188 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4190 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4191 node=$(facet_active_host ost$((ostnum+1)))
4192 param="obdfilter.$ostname.last_id"
4193 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4194 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4195 ost_last_id=$ost_last
4197 if $support_last_seq; then
4198 ost_last_id=$(echo $ost_last |
4199 awk -F':' '{print $2}' |
4201 ost_last_seq=$(echo $ost_last |
4202 awk -F':' '{print $1}')
4203 [[ $ost_last_seq = $mds_last_seq ]] || continue
4206 if [[ $ost_last_id != $mds_last ]]; then
4207 error "$ost_last_id != $mds_last"
4214 $found || error "can not match last_seq/last_id for $mdtosc"
4217 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4220 $SOCKETSERVER $DIR/socket ||
4221 error "$SOCKETSERVER $DIR/socket failed: $?"
4222 $SOCKETCLIENT $DIR/socket ||
4223 error "$SOCKETCLIENT $DIR/socket failed: $?"
4224 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4226 run_test 54a "unix domain socket test =========================="
4232 dd if=/dev/zero of=$f bs=$(page_size) count=1
4234 run_test 54b "char device works in lustre ======================"
4237 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4238 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4239 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4241 for i in $(seq 3 7); do
4242 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4250 loopdev="$DIR/loop54c"
4253 $UMOUNT -d $DIR/$tdir || rc=$?
4254 losetup -d $loopdev || true
4255 losetup -d $LOOPDEV || true
4256 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4262 loopdev="$DIR/loop54c"
4265 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4266 trap cleanup_54c EXIT
4267 mknod $loopdev b 7 $LOOPNUM
4268 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4269 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4270 losetup $loopdev $DIR/$tfile ||
4271 error "can't set up $loopdev for $DIR/$tfile"
4272 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4273 test_mkdir -p $DIR/$tdir
4274 mount -t ext2 $loopdev $DIR/$tdir ||
4275 error "error mounting $loopdev on $DIR/$tdir"
4276 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4279 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4283 run_test 54c "block device works in lustre ====================="
4289 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4291 run_test 54d "fifo device works in lustre ======================"
4294 check_kernel_version 46 || return 0
4297 cp -aL /dev/console $f
4298 echo $string > $f || error "echo $string to $f failed"
4300 run_test 54e "console/tty device works in lustre ======================"
4302 #The test_55 used to be iopen test and it was removed by bz#24037.
4303 #run_test 55 "check iopen_connect_dentry() ======================"
4305 test_56a() { # was test_56
4308 test_mkdir -p $DIR/$tdir/dir
4310 NUMFILESx2=$(($NUMFILES * 2))
4311 for i in $(seq 1 $NUMFILES); do
4312 touch $DIR/$tdir/file$i
4313 touch $DIR/$tdir/dir/file$i
4316 # test lfs getstripe with --recursive
4317 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4318 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4319 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4320 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4321 [[ $FILENUM -eq $NUMFILES ]] ||
4322 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4323 echo "$GETSTRIPE --recursive passed."
4325 # test lfs getstripe with file instead of dir
4326 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4327 [[ $FILENUM -eq 1 ]] ||
4328 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4329 echo "$GETSTRIPE file1 passed."
4331 #test lfs getstripe with --verbose
4332 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4333 grep -c lmm_magic) -eq $NUMFILES ]] ||
4334 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4335 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4336 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4337 echo "$GETSTRIPE --verbose passed."
4339 #test lfs getstripe with --obd
4340 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4341 grep -q "unknown obduuid" ||
4342 error "$GETSTRIPE --obd wrong_uuid should return error message"
4344 [[ $OSTCOUNT -lt 2 ]] &&
4345 skip_env "skipping other $GETSTRIPE --obd test" && return
4348 OBDUUID=$(ostuuid_from_index $OSTIDX)
4349 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4350 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4351 [[ $FOUND -eq $FILENUM ]] ||
4352 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4353 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4354 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4355 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4356 error "$GETSTRIPE --obd: should not show file on other obd"
4357 echo "$GETSTRIPE --obd passed"
4359 run_test 56a "check $GETSTRIPE"
4364 local LOCAL_NUMFILES="$1"
4365 local LOCAL_NUMDIRS="$2"
4366 local MKDIR_PARAMS="$3"
4367 local DIR_STRIPE_PARAMS="$4"
4369 if [ ! -d "$TDIR" ] ; then
4370 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4371 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4372 for i in `seq 1 $LOCAL_NUMFILES` ; do
4375 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4376 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4377 for j in `seq 1 $LOCAL_NUMFILES` ; do
4378 touch $TDIR/dir$i/file$j
4384 setup_56_special() {
4388 if [ ! -e "$TDIR/loop1b" ] ; then
4389 for i in `seq 1 $LOCAL_NUMFILES` ; do
4390 mknod $TDIR/loop${i}b b 7 $i
4391 mknod $TDIR/null${i}c c 1 3
4392 ln -s $TDIR/file1 $TDIR/link${i}l
4394 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4395 mknod $TDIR/dir$i/loop${i}b b 7 $i
4396 mknod $TDIR/dir$i/null${i}c c 1 3
4397 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4406 setup_56 $NUMFILES $NUMDIRS
4408 EXPECTED=$(($NUMDIRS + 2))
4409 # test lfs find with -name
4410 for i in $(seq 1 $NUMFILES) ; do
4411 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4412 [ $NUMS -eq $EXPECTED ] ||
4413 error "lfs find -name \"*$i\" $TDIR wrong: "\
4414 "found $NUMS, expected $EXPECTED"
4417 run_test 56g "check lfs find -name ============================="
4423 setup_56 $NUMFILES $NUMDIRS
4425 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4426 # test lfs find with ! -name
4427 for i in $(seq 1 $NUMFILES) ; do
4428 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4429 [ $NUMS -eq $EXPECTED ] ||
4430 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4431 "found $NUMS, expected $EXPECTED"
4434 run_test 56h "check lfs find ! -name ============================="
4438 test_mkdir -p $DIR/$tdir
4439 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4440 CMD="$LFIND -ost $UUID $DIR/$tdir"
4442 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4444 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4448 setup_56_special $NUMFILES $NUMDIRS
4450 EXPECTED=$((NUMDIRS + 1))
4451 CMD="$LFIND -type d $TDIR"
4452 NUMS=$($CMD | wc -l)
4453 [ $NUMS -eq $EXPECTED ] ||
4454 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4456 run_test 56j "check lfs find -type d ============================="
4460 setup_56_special $NUMFILES $NUMDIRS
4462 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4463 CMD="$LFIND -type f $TDIR"
4464 NUMS=$($CMD | wc -l)
4465 [ $NUMS -eq $EXPECTED ] ||
4466 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4468 run_test 56k "check lfs find -type f ============================="
4472 setup_56_special $NUMFILES $NUMDIRS
4474 EXPECTED=$((NUMDIRS + NUMFILES))
4475 CMD="$LFIND -type b $TDIR"
4476 NUMS=$($CMD | wc -l)
4477 [ $NUMS -eq $EXPECTED ] ||
4478 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4480 run_test 56l "check lfs find -type b ============================="
4484 setup_56_special $NUMFILES $NUMDIRS
4486 EXPECTED=$((NUMDIRS + NUMFILES))
4487 CMD="$LFIND -type c $TDIR"
4488 NUMS=$($CMD | wc -l)
4489 [ $NUMS -eq $EXPECTED ] ||
4490 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4492 run_test 56m "check lfs find -type c ============================="
4496 setup_56_special $NUMFILES $NUMDIRS
4498 EXPECTED=$((NUMDIRS + NUMFILES))
4499 CMD="$LFIND -type l $TDIR"
4500 NUMS=$($CMD | wc -l)
4501 [ $NUMS -eq $EXPECTED ] ||
4502 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4504 run_test 56n "check lfs find -type l ============================="
4508 setup_56 $NUMFILES $NUMDIRS
4509 utime $TDIR/file1 > /dev/null || error "utime (1)"
4510 utime $TDIR/file2 > /dev/null || error "utime (2)"
4511 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4512 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4513 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4514 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4517 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4518 [ $NUMS -eq $EXPECTED ] || \
4519 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4522 CMD="$LFIND -mtime 0 $TDIR"
4523 NUMS=$($CMD | wc -l)
4524 [ $NUMS -eq $EXPECTED ] ||
4525 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4527 run_test 56o "check lfs find -mtime for old files =========================="
4530 [ $RUNAS_ID -eq $UID ] &&
4531 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4534 setup_56 $NUMFILES $NUMDIRS
4536 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4538 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4539 NUMS=$($CMD | wc -l)
4540 [ $NUMS -eq $EXPECTED ] || \
4541 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4543 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4544 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4545 NUMS=$($CMD | wc -l)
4546 [ $NUMS -eq $EXPECTED ] || \
4547 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 run_test 56p "check lfs find -uid and ! -uid ==============================="
4552 [ $RUNAS_ID -eq $UID ] &&
4553 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4556 setup_56 $NUMFILES $NUMDIRS
4558 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4561 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4562 NUMS=$($CMD | wc -l)
4563 [ $NUMS -eq $EXPECTED ] ||
4564 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4566 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4567 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4568 NUMS=$($CMD | wc -l)
4569 [ $NUMS -eq $EXPECTED ] ||
4570 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4572 run_test 56q "check lfs find -gid and ! -gid ==============================="
4576 setup_56 $NUMFILES $NUMDIRS
4579 CMD="$LFIND -size 0 -type f $TDIR"
4580 NUMS=$($CMD | wc -l)
4581 [ $NUMS -eq $EXPECTED ] ||
4582 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4584 CMD="$LFIND ! -size 0 -type f $TDIR"
4585 NUMS=$($CMD | wc -l)
4586 [ $NUMS -eq $EXPECTED ] ||
4587 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4588 echo "test" > $TDIR/$tfile
4589 echo "test2" > $TDIR/$tfile.2 && sync
4591 CMD="$LFIND -size 5 -type f $TDIR"
4592 NUMS=$($CMD | wc -l)
4593 [ $NUMS -eq $EXPECTED ] ||
4594 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4596 CMD="$LFIND -size +5 -type f $TDIR"
4597 NUMS=$($CMD | wc -l)
4598 [ $NUMS -eq $EXPECTED ] ||
4599 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4601 CMD="$LFIND -size +0 -type f $TDIR"
4602 NUMS=$($CMD | wc -l)
4603 [ $NUMS -eq $EXPECTED ] ||
4604 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4606 CMD="$LFIND ! -size -5 -type f $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] ||
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4611 CMD="$LFIND -size -5 -type f $TDIR"
4612 NUMS=$($CMD | wc -l)
4613 [ $NUMS -eq $EXPECTED ] ||
4614 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4616 run_test 56r "check lfs find -size works =========================="
4618 test_56s() { # LU-611
4620 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4622 if [[ $OSTCOUNT -gt 1 ]]; then
4623 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4627 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4631 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4632 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4633 NUMS=$($CMD | wc -l)
4634 [ $NUMS -eq $EXPECTED ] || {
4636 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4639 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4640 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4641 NUMS=$($CMD | wc -l)
4642 [ $NUMS -eq $EXPECTED ] || {
4644 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4648 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4649 NUMS=$($CMD | wc -l)
4650 [ $NUMS -eq $EXPECTED ] || {
4652 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4655 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4656 NUMS=$($CMD | wc -l)
4657 [ $NUMS -eq $EXPECTED ] || {
4659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4663 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4664 NUMS=$($CMD | wc -l)
4665 [ $NUMS -eq $EXPECTED ] || {
4667 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4670 run_test 56s "check lfs find -stripe-count works"
4672 test_56t() { # LU-611
4674 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4676 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4678 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4679 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4680 NUMS=$($CMD | wc -l)
4681 [ $NUMS -eq $EXPECTED ] ||
4682 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4684 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4685 NUMS=$($CMD | wc -l)
4686 [ $NUMS -eq $EXPECTED ] ||
4687 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4689 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4690 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4691 NUMS=$($CMD | wc -l)
4692 [ $NUMS -eq $EXPECTED ] ||
4693 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4695 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4696 NUMS=$($CMD | wc -l)
4697 [ $NUMS -eq $EXPECTED ] ||
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4701 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4702 NUMS=$($CMD | wc -l)
4703 [ $NUMS -eq $EXPECTED ] ||
4704 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4706 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4707 NUMS=$($CMD | wc -l)
4708 [ $NUMS -eq $EXPECTED ] ||
4709 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4712 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4713 NUMS=$($CMD | wc -l)
4714 [ $NUMS -eq $EXPECTED ] ||
4715 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4717 run_test 56t "check lfs find -stripe-size works"
4719 test_56u() { # LU-611
4721 setup_56 $NUMFILES $NUMDIRS "-i 0"
4723 if [[ $OSTCOUNT -gt 1 ]]; then
4724 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4730 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4731 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4732 NUMS=$($CMD | wc -l)
4733 [ $NUMS -eq $EXPECTED ] ||
4734 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4737 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4738 NUMS=$($CMD | wc -l)
4739 [ $NUMS -eq $EXPECTED ] ||
4740 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4742 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4743 NUMS=$($CMD | wc -l)
4744 [ $NUMS -eq $EXPECTED ] ||
4745 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4748 # This should produce an error and not return any files
4749 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4750 NUMS=$($CMD 2>/dev/null | wc -l)
4751 [ $NUMS -eq $EXPECTED ] ||
4752 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4754 if [[ $OSTCOUNT -gt 1 ]]; then
4755 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4756 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4757 NUMS=$($CMD | wc -l)
4758 [ $NUMS -eq $EXPECTED ] ||
4759 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4762 run_test 56u "check lfs find -stripe-index works"
4769 setup_56 $NUMFILES $NUMDIRS
4771 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4772 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4774 for file in $($LFIND -mdt $UUID $TDIR); do
4775 file_mdt_idx=$($GETSTRIPE -M $file)
4776 [ $file_mdt_idx -eq $MDT_IDX ] ||
4777 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4780 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4783 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4788 rm -rf $TDIR || error "remove $TDIR failed"
4789 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4792 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4793 error "$GETSTRIPE -S -d $TDIR failed"
4794 stripe_size=${stripe_size%% *}
4796 local file_size=$((stripe_size * OSTCOUNT))
4797 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4798 local required_space=$((file_num * file_size))
4799 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4800 [[ $free_space -le $((required_space / 1024)) ]] &&
4801 skip_env "need at least $required_space bytes free space," \
4802 "have $free_space kbytes" && return
4805 local dd_count=$((file_size / dd_bs))
4807 # write data into the files
4811 for i in $(seq 1 $NUMFILES); do
4813 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4814 error "write data into $file failed"
4816 for i in $(seq 1 $NUMDIRS); do
4817 for j in $(seq 1 $NUMFILES); do
4818 file=$TDIR/dir$i/file$j
4819 yes | dd bs=$dd_bs count=$dd_count of=$file \
4821 error "write data into $file failed"
4826 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4829 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4831 eval $cmd || error "$cmd failed"
4833 check_stripe_count $TDIR/file1 $expected
4835 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4837 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4838 # OST 1 if it is on OST 0. This file is small enough to
4839 # be on only one stripe.
4840 file=$TDIR/migr_1_ost
4841 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4842 error "write data into $file failed"
4843 local obdidx=$($LFS getstripe -i $file)
4844 local oldmd5=$(md5sum $file)
4846 [[ $obdidx -eq 0 ]] && newobdidx=1
4847 cmd="$LFS migrate -i $newobdidx $file"
4849 eval $cmd || error "$cmd failed"
4850 local realobdix=$($LFS getstripe -i $file)
4851 local newmd5=$(md5sum $file)
4852 [[ $newobdidx -ne $realobdix ]] &&
4853 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4854 [[ "$oldmd5" != "$newmd5" ]] &&
4855 error "md5sum differ: $oldmd5, $newmd5"
4859 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4861 eval $cmd || error "$cmd failed"
4863 for j in $(seq 1 $NUMFILES); do
4864 check_stripe_count $TDIR/dir1/file$j $expected
4867 # lfs_migrate works with lfs find
4868 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4869 $LFS_MIGRATE -y -c $expected"
4871 eval $cmd || error "$cmd failed"
4873 for i in $(seq 2 $NUMFILES); do
4874 check_stripe_count $TDIR/file$i $expected
4876 for i in $(seq 2 $NUMDIRS); do
4877 for j in $(seq 1 $NUMFILES); do
4878 check_stripe_count $TDIR/dir$i/file$j $expected
4882 run_test 56w "check lfs_migrate -c stripe_count works"
4885 check_swap_layouts_support && return 0
4886 [[ $OSTCOUNT -lt 2 ]] &&
4887 skip_env "need 2 OST, skipping test" && return
4889 local dir0=$DIR/$tdir/$testnum
4890 mkdir -p $dir0 || error "creating dir $dir0"
4892 local ref1=/etc/passwd
4893 local file1=$dir0/file1
4895 $SETSTRIPE -c 2 $file1
4897 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4898 stripe=$($GETSTRIPE -c $file1)
4899 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4900 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4905 run_test 56x "lfs migration support"
4908 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4909 skip "No HSM support on MDS of $(get_lustre_version)," \
4910 "need 2.4.53 at least" && return
4913 local dir0=$DIR/$tdir/$testnum
4914 mkdir -p $dir0 || error "creating dir $dir0"
4915 local f1=$dir0/file1
4916 local f2=$dir0/file2
4918 touch $f1 || error "creating std file $f1"
4919 $MULTIOP $f2 H2c || error "creating released file $f2"
4921 # a directory can be raid0, so ask only for files
4922 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4923 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4925 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4926 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4928 # only files can be released, so no need to force file search
4929 res=$($LFIND $dir0 -L released)
4930 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4932 res=$($LFIND $dir0 \! -L released)
4933 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4936 run_test 56y "lfs find -L raid0|released"
4938 test_56z() { # LU-4824
4939 # This checks to make sure 'lfs find' continues after errors
4940 # There are two classes of errors that should be caught:
4941 # - If multiple paths are provided, all should be searched even if one
4943 # - If errors are encountered during the search, it should not terminate
4946 test_mkdir $DIR/$tdir
4947 for i in d{0..9}; do
4948 test_mkdir $DIR/$tdir/$i
4950 touch $DIR/$tdir/d{0..9}/$tfile
4951 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4952 error "$LFS find did not return an error"
4953 # Make a directory unsearchable. This should NOT be the last entry in
4954 # directory order. Arbitrarily pick the 6th entry
4955 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
4956 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4957 # The user should be able to see 10 directories and 9 files
4958 [ $count == 19 ] || error "$LFS find did not continue after error"
4960 run_test 56z "lfs find should continue after an error"
4963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4964 # note test will not do anything if MDS is not local
4965 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4966 skip "Only applicable to ldiskfs-based MDTs"
4970 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4971 local MNTDEV="osd*.*MDT*.mntdev"
4972 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4973 [ -z "$DEV" ] && error "can't access $MNTDEV"
4974 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4975 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4976 error "can't access $DEV"
4977 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4978 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4982 run_test 57a "verify MDS filesystem created with large inodes =="
4985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4986 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4987 skip "Only applicable to ldiskfs-based MDTs"
4991 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4996 local FILEN=$dir/f$FILECOUNT
4998 rm -rf $dir || error "removing $dir"
4999 test_mkdir -p $dir || error "creating $dir"
5000 local num=$(get_mds_dir $dir)
5003 echo "mcreating $FILECOUNT files"
5004 createmany -m $dir/f 1 $FILECOUNT || \
5005 error "creating files in $dir"
5007 # verify that files do not have EAs yet
5008 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5009 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5013 df $dir #make sure we get new statfs data
5014 local MDSFREE=$(do_facet $mymds \
5015 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
5016 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5017 echo "opening files to create objects/EAs"
5019 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5020 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5023 # verify that files have EAs now
5024 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5025 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5027 sleep 1 #make sure we get new statfs data
5029 local MDSFREE2=$(do_facet $mymds \
5030 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
5031 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5032 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5033 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5034 error "MDC before $MDCFREE != after $MDCFREE2"
5036 echo "MDC before $MDCFREE != after $MDCFREE2"
5037 echo "unable to confirm if MDS has large inodes"
5042 run_test 57b "default LOV EAs are stored inside large inodes ==="
5045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5046 [ -z "$(which wiretest 2>/dev/null)" ] &&
5047 skip_env "could not find wiretest" && return
5050 run_test 58 "verify cross-platform wire constants =============="
5053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5054 echo "touch 130 files"
5055 createmany -o $DIR/f59- 130
5057 unlinkmany $DIR/f59- 130
5059 # wait for commitment of removal
5060 wait_delete_completed
5062 run_test 59 "verify cancellation of llog records async ========="
5064 TEST60_HEAD="test_60 run $RANDOM"
5066 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5067 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5068 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5069 skip_env "missing subtest run-llog.sh" && return
5070 log "$TEST60_HEAD - from kernel mode"
5071 do_facet mgs sh run-llog.sh
5073 run_test 60a "llog sanity tests run from kernel module =========="
5075 test_60b() { # bug 6411
5076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5078 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5090 [[ $LLOG_COUNT -gt 50 ]] &&
5091 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5093 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5096 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5097 echo "create 5000 files"
5098 createmany -o $DIR/f60c- 5000
5099 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5100 lctl set_param fail_loc=0x80000137
5101 unlinkmany $DIR/f60c- 5000
5102 lctl set_param fail_loc=0
5104 run_test 60c "unlink file when mds full"
5107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5108 SAVEPRINTK=$(lctl get_param -n printk)
5110 # verify "lctl mark" is even working"
5111 MESSAGE="test message ID $RANDOM $$"
5112 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5113 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5115 lctl set_param printk=0 || error "set lnet.printk failed"
5116 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5117 MESSAGE="new test message ID $RANDOM $$"
5118 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5119 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5120 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5122 lctl set_param -n printk="$SAVEPRINTK"
5124 run_test 60d "test printk console message masking"
5127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5129 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5130 cancel_lru_locks osc
5131 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5134 run_test 61 "mmap() writes don't make sync hang ================"
5136 # bug 2330 - insufficient obd_match error checking causes LBUG
5138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5141 cancel_lru_locks osc
5142 lctl set_param fail_loc=0x405
5143 cat $f && error "cat succeeded, expect -EIO"
5144 lctl set_param fail_loc=0
5146 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5147 # match every page all of the time.
5148 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5150 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5151 # Though this test is irrelevant anymore, it helped to reveal some
5152 # other grant bugs (LU-4482), let's keep it.
5153 test_63a() { # was test_63
5154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5155 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5156 for i in `seq 10` ; do
5157 dd if=/dev/zero of=$DIR/f63 bs=8k &
5163 rm -f $DIR/f63 || true
5165 run_test 63a "Verify oig_wait interruption does not crash ======="
5167 # bug 2248 - async write errors didn't return to application on sync
5168 # bug 3677 - async write errors left page locked
5170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5172 lctl set_param debug=-1
5174 # ensure we have a grant to do async writes
5175 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5178 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5179 lctl set_param fail_loc=0x80000406
5180 $MULTIOP $DIR/$tfile Owy && \
5181 error "sync didn't return ENOMEM"
5182 sync; sleep 2; sync # do a real sync this time to flush page
5183 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5184 error "locked page left in cache after async error" || true
5187 run_test 63b "async write errors should be returned to fsync ==="
5190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5192 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5194 run_test 64a "verify filter grant calculations (in kernel) ====="
5197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5198 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5200 run_test 64b "check out-of-space detection on client ==========="
5203 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5205 run_test 64c "verify grant shrink ========================------"
5207 # bug 1414 - set/get directories' stripe info
5209 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5210 test_mkdir -p $DIR/$tdir
5212 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5214 run_test 65a "directory with no stripe info ===================="
5217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5218 test_mkdir -p $DIR/$tdir
5219 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5222 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5224 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5228 if [[ $OSTCOUNT -gt 1 ]]; then
5229 test_mkdir -p $DIR/$tdir
5230 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5231 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5233 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5236 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5240 test_mkdir -p $DIR/$tdir
5241 if [[ $STRIPECOUNT -le 0 ]]; then
5243 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5244 #LOV_MAX_STRIPE_COUNT is 2000
5245 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5247 sc=$(($STRIPECOUNT - 1))
5249 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5250 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5251 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5252 error "lverify failed"
5254 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5257 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5258 test_mkdir -p $DIR/$tdir
5260 $SETSTRIPE $DIR/$tdir || error "setstripe"
5261 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5262 error "no stripe info failed"
5264 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5266 run_test 65e "directory setstripe defaults ======================="
5269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5270 test_mkdir -p $DIR/${tdir}f
5271 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5273 run_test 65f "dir setstripe permission (should return error) ==="
5276 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5277 test_mkdir -p $DIR/$tdir
5278 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5280 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5281 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5282 error "delete default stripe failed"
5284 run_test 65g "directory setstripe -d ==========================="
5287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5288 test_mkdir -p $DIR/$tdir
5289 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5291 test_mkdir -p $DIR/$tdir/dd1
5292 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5293 error "stripe info inherit failed"
5295 run_test 65h "directory stripe info inherit ===================="
5297 test_65i() { # bug6367
5298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5299 $SETSTRIPE -S 65536 -c -1 $MOUNT
5301 run_test 65i "set non-default striping on root directory (bug 6367)="
5303 test_65ia() { # bug12836
5304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5305 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5307 run_test 65ia "getstripe on -1 default directory striping"
5309 test_65ib() { # bug12836
5310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5311 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5313 run_test 65ib "getstripe -v on -1 default directory striping"
5315 test_65ic() { # bug12836
5316 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5317 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5319 run_test 65ic "new find on -1 default directory striping"
5321 test_65j() { # bug6367
5322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5324 # if we aren't already remounting for each test, do so for this test
5325 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5326 cleanup || error "failed to unmount"
5329 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5331 run_test 65j "set default striping on root directory (bug 6367)="
5333 test_65k() { # bug11679
5334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5335 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5336 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5338 echo "Check OST status: "
5339 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5340 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5342 for OSC in $MDS_OSCS; do
5343 echo $OSC "is activate"
5344 do_facet $SINGLEMDS lctl --device %$OSC activate
5348 for INACTIVE_OSC in $MDS_OSCS; do
5349 echo "Deactivate: " $INACTIVE_OSC
5350 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5351 for STRIPE_OSC in $MDS_OSCS; do
5352 OST=`osc_to_ost $STRIPE_OSC`
5353 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5354 awk -F: /$OST/'{ print $1 }' | head -n 1`
5356 [ -f $DIR/$tdir/$IDX ] && continue
5357 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5358 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5360 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5363 echo $INACTIVE_OSC "is Activate."
5364 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5367 run_test 65k "validate manual striping works properly with deactivated OSCs"
5369 test_65l() { # bug 12836
5370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5371 test_mkdir -p $DIR/$tdir/test_dir
5372 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5373 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5375 run_test 65l "lfs find on -1 stripe dir ========================"
5377 # bug 2543 - update blocks count on client
5379 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5381 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5382 sync; sync_all_data; sync; sync_all_data
5383 cancel_lru_locks osc
5384 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5385 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5387 run_test 66 "update inode blocks count on client ==============="
5392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5394 if [ ! -z "$LLOOP" ]; then
5395 if swapon -s | grep -q $LLOOP; then
5396 swapoff $LLOOP || error "swapoff failed"
5399 $LCTL blockdev_detach $LLOOP || error "detach failed"
5403 if [ ! -z "$LLITELOOPLOAD" ]; then
5411 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5415 swapon -s | awk '($1 == "'$1'") { print $4 }'
5418 # test case for lloop driver, basic function
5420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5421 [ "$UID" != 0 ] && skip_env "must run as root" && return
5422 llite_lloop_enabled || \
5423 { skip_env "llite_lloop module disabled" && return; }
5425 trap cleanup_68 EXIT
5427 if ! module_loaded llite_lloop; then
5428 if load_module llite/llite_lloop; then
5431 skip_env "can't find module llite_lloop"
5436 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5437 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5438 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5440 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5441 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5445 run_test 68a "lloop driver - basic test ========================"
5447 # excercise swapping to lustre by adding a high priority swapfile entry
5448 # and then consuming memory until it is used.
5449 test_68b() { # was test_68
5450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5451 [ "$UID" != 0 ] && skip_env "must run as root" && return
5452 lctl get_param -n devices | grep -q obdfilter && \
5453 skip "local OST" && return
5455 grep -q llite_lloop /proc/modules
5456 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5458 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5459 skip "can't reliably test swap with TCP" && return
5461 MEMTOTAL=`meminfo MemTotal`
5462 NR_BLOCKS=$((MEMTOTAL>>8))
5463 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5465 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5466 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5469 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5471 trap cleanup_68 EXIT
5473 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5475 echo "before: `swapon -s | grep $LLOOP`"
5476 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5477 echo "after: `swapon -s | grep $LLOOP`"
5478 SWAPUSED=`swap_used $LLOOP`
5482 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5484 run_test 68b "support swapping to Lustre ========================"
5486 # bug5265, obdfilter oa2dentry return -ENOENT
5487 # #define OBD_FAIL_OST_ENOENT 0x217
5489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5490 remote_ost_nodsh && skip "remote OST with nodsh" && return
5493 $SETSTRIPE -c 1 -i 0 $f
5495 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5497 do_facet ost1 lctl set_param fail_loc=0x217
5498 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5499 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5501 do_facet ost1 lctl set_param fail_loc=0
5502 $DIRECTIO write $f 0 2 || error "write error"
5504 cancel_lru_locks osc
5505 $DIRECTIO read $f 0 1 || error "read error"
5507 do_facet ost1 lctl set_param fail_loc=0x217
5508 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5510 do_facet ost1 lctl set_param fail_loc=0
5513 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5516 test_mkdir -p $DIR/$tdir
5517 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5519 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5521 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5523 [ "$RUNAS_ID" = "$UID" ] &&
5524 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5526 # Check that testing environment is properly set up. Skip if not
5527 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5528 skip_env "User $RUNAS_ID does not exist - skipping"
5532 chmod 777 $DIR/$tfile
5533 chmod ug+s $DIR/$tfile
5534 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5535 error "$RUNAS dd $DIR/$tfile failed"
5536 # See if we are still setuid/sgid
5537 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5538 error "S/gid is not dropped on write"
5539 # Now test that MDS is updated too
5540 cancel_lru_locks mdc
5541 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5542 error "S/gid is not dropped on MDS"
5545 run_test 72a "Test that remove suid works properly (bug5695) ===="
5547 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5550 [ "$RUNAS_ID" = "$UID" ] && \
5551 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5552 [ "$RUNAS_ID" -eq 0 ] && \
5553 skip_env "RUNAS_ID = 0 -- skipping" && return
5555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5556 # Check that testing environment is properly set up. Skip if not
5557 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5558 skip_env "User $RUNAS_ID does not exist - skipping"
5561 touch $DIR/${tfile}-f{g,u}
5562 test_mkdir $DIR/${tfile}-dg
5563 test_mkdir $DIR/${tfile}-du
5564 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5565 chmod g+s $DIR/${tfile}-{f,d}g
5566 chmod u+s $DIR/${tfile}-{f,d}u
5567 for perm in 777 2777 4777; do
5568 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5569 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5570 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5571 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5575 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5577 # bug 3462 - multiple simultaneous MDC requests
5579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5580 test_mkdir $DIR/d73-1
5581 test_mkdir $DIR/d73-2
5582 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5585 lctl set_param fail_loc=0x80000129
5586 $MULTIOP $DIR/d73-1/f73-2 Oc &
5588 lctl set_param fail_loc=0
5590 $MULTIOP $DIR/d73-2/f73-3 Oc &
5594 wait $pid1 || return 1
5598 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5599 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5600 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5604 run_test 73 "multiple MDC requests (should not deadlock)"
5606 test_74a() { # bug 6149, 6184
5607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5608 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5610 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5611 # will spin in a tight reconnection loop
5613 $LCTL set_param fail_loc=0x8000030e
5614 # get any lock that won't be difficult - lookup works.
5616 $LCTL set_param fail_loc=0
5620 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5622 test_74b() { # bug 13310
5623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5624 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5626 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5627 # will spin in a tight reconnection loop
5628 $LCTL set_param fail_loc=0x8000030e
5629 # get a "difficult" lock
5631 $LCTL set_param fail_loc=0
5635 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5638 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5639 #define OBD_FAIL_LDLM_NEW_LOCK
5640 $LCTL set_param fail_loc=0x319
5641 touch $DIR/$tfile && error "touch successful"
5642 $LCTL set_param fail_loc=0
5645 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5648 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5651 get_inode_slab_tunables() {
5652 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5655 set_inode_slab_tunables() {
5656 echo "lustre_inode_cache $1" > /proc/slabinfo
5659 test_76() { # Now for bug 20433, added originally in bug 1443
5660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5661 local SLAB_SETTINGS=`get_inode_slab_tunables`
5662 local CPUS=`getconf _NPROCESSORS_ONLN`
5663 # we cannot set limit below 1 which means 1 inode in each
5664 # per-cpu cache is still allowed
5665 set_inode_slab_tunables "1 1 0"
5666 cancel_lru_locks osc
5667 BEFORE_INODES=$(num_inodes)
5668 echo "before inodes: $BEFORE_INODES"
5670 [ "$SLOW" = "no" ] && COUNT=100
5671 for i in $(seq $COUNT); do
5675 cancel_lru_locks osc
5676 AFTER_INODES=$(num_inodes)
5677 echo "after inodes: $AFTER_INODES"
5679 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5681 AFTER_INODES=$(num_inodes)
5683 echo "wait $wait seconds inodes: $AFTER_INODES"
5684 if [ $wait -gt 30 ]; then
5685 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5688 set_inode_slab_tunables "$SLAB_SETTINGS"
5690 run_test 76 "confirm clients recycle inodes properly ===="
5696 # Note: in sptlrpc modes which enable its own bulk checksum, the
5697 # original crc32_le bulk checksum will be automatically disabled,
5698 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5699 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5700 # In this case set_checksums() will not be no-op, because sptlrpc
5701 # bulk checksum will be enabled all through the test.
5703 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5704 lctl set_param -n osc.*.checksums $1
5708 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5709 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5710 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5711 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5714 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5715 log "set checksum type to $1"
5718 F77_TMP=$TMP/f77-temp
5721 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5722 error "error writing to $F77_TMP"
5725 test_77a() { # bug 10889
5726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5727 $GSS && skip "could not run with gss" && return
5728 [ ! -f $F77_TMP ] && setup_f77
5730 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5734 run_test 77a "normal checksum read/write operation"
5736 test_77b() { # bug 10889
5737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5738 $GSS && skip "could not run with gss" && return
5739 [ ! -f $F77_TMP ] && setup_f77
5740 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5741 $LCTL set_param fail_loc=0x80000409
5744 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5745 error "dd error: $?"
5746 $LCTL set_param fail_loc=0
5748 for algo in $CKSUM_TYPES; do
5749 cancel_lru_locks osc
5750 set_checksum_type $algo
5751 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5752 $LCTL set_param fail_loc=0x80000408
5753 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5754 $LCTL set_param fail_loc=0
5757 set_checksum_type $ORIG_CSUM_TYPE
5760 run_test 77b "checksum error on client write, read"
5762 test_77d() { # bug 10889
5763 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5764 $GSS && skip "could not run with gss" && return
5765 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5766 $LCTL set_param fail_loc=0x80000409
5768 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5769 error "direct write: rc=$?"
5770 $LCTL set_param fail_loc=0
5773 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5774 $LCTL set_param fail_loc=0x80000408
5776 cancel_lru_locks osc
5777 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5778 error "direct read: rc=$?"
5779 $LCTL set_param fail_loc=0
5782 run_test 77d "checksum error on OST direct write, read"
5784 test_77f() { # bug 10889
5785 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5786 $GSS && skip "could not run with gss" && return
5788 for algo in $CKSUM_TYPES; do
5789 cancel_lru_locks osc
5790 set_checksum_type $algo
5791 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5792 $LCTL set_param fail_loc=0x409
5793 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5794 error "direct write succeeded"
5795 $LCTL set_param fail_loc=0
5797 set_checksum_type $ORIG_CSUM_TYPE
5800 run_test 77f "repeat checksum error on write (expect error)"
5802 test_77g() { # bug 10889
5803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5804 $GSS && skip "could not run with gss" && return
5805 remote_ost_nodsh && skip "remote OST with nodsh" && return
5807 [ ! -f $F77_TMP ] && setup_f77
5809 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5810 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5811 do_facet ost1 lctl set_param fail_loc=0x8000021a
5813 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5814 error "write error: rc=$?"
5815 do_facet ost1 lctl set_param fail_loc=0
5818 cancel_lru_locks osc
5819 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5820 do_facet ost1 lctl set_param fail_loc=0x8000021b
5822 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5823 do_facet ost1 lctl set_param fail_loc=0
5826 run_test 77g "checksum error on OST write, read"
5828 test_77i() { # bug 13805
5829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5830 $GSS && skip "could not run with gss" && return
5831 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5832 lctl set_param fail_loc=0x40b
5833 remount_client $MOUNT
5834 lctl set_param fail_loc=0
5835 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5836 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5837 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5838 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5840 remount_client $MOUNT
5842 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5844 test_77j() { # bug 13805
5845 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5846 $GSS && skip "could not run with gss" && return
5847 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5848 lctl set_param fail_loc=0x40c
5849 remount_client $MOUNT
5850 lctl set_param fail_loc=0
5851 sleep 2 # wait async osc connect to finish
5852 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5853 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5854 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5855 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5857 remount_client $MOUNT
5859 run_test 77j "client only supporting ADLER32"
5861 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5865 test_78() { # bug 10901
5866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5867 remote_ost || { skip_env "local OST" && return; }
5870 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5871 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5872 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5873 echo "MemTotal: $MEMTOTAL"
5875 # reserve 256MB of memory for the kernel and other running processes,
5876 # and then take 1/2 of the remaining memory for the read/write buffers.
5877 if [ $MEMTOTAL -gt 512 ] ;then
5878 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5880 # for those poor memory-starved high-end clusters...
5881 MEMTOTAL=$((MEMTOTAL / 2))
5883 echo "Mem to use for directio: $MEMTOTAL"
5885 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5886 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5887 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5888 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5890 echo "Smallest OST: $SMALLESTOST"
5891 [[ $SMALLESTOST -lt 10240 ]] &&
5892 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5894 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5895 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5897 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5898 echo "File size: $F78SIZE"
5899 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5900 for i in $(seq 1 $NSEQ); do
5901 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5902 echo directIO rdwr round $i of $NSEQ
5903 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5908 run_test 78 "handle large O_DIRECT writes correctly ============"
5910 test_79() { # bug 12743
5911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5912 wait_delete_completed
5914 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5915 BKFREE=$(calc_osc_kbytes kbytesfree)
5916 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5918 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5919 DFTOTAL=`echo $STRING | cut -d, -f1`
5920 DFUSED=`echo $STRING | cut -d, -f2`
5921 DFAVAIL=`echo $STRING | cut -d, -f3`
5922 DFFREE=$(($DFTOTAL - $DFUSED))
5924 ALLOWANCE=$((64 * $OSTCOUNT))
5926 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5927 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5928 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5930 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5931 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5932 error "df free($DFFREE) mismatch OST free($BKFREE)"
5934 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5935 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5936 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5939 run_test 79 "df report consistency check ======================="
5941 test_80() { # bug 10718
5942 remote_ost_nodsh && skip "remote OST with nodsh" && return
5943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5944 # relax strong synchronous semantics for slow backends like ZFS
5945 local soc="obdfilter.*.sync_on_lock_cancel"
5946 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5948 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5949 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5950 facet_active_host $host; done | sort -u)
5951 do_nodes $hosts lctl set_param $soc=never
5954 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5956 local BEFORE=`date +%s`
5957 cancel_lru_locks osc
5958 local AFTER=`date +%s`
5959 local DIFF=$((AFTER-BEFORE))
5960 if [ $DIFF -gt 1 ] ; then
5961 error "elapsed for 1M@1T = $DIFF"
5964 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5968 run_test 80 "Page eviction is equally fast at high offsets too ===="
5970 test_81a() { # LU-456
5971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5972 remote_ost_nodsh && skip "remote OST with nodsh" && return
5973 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5974 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5975 do_facet ost1 lctl set_param fail_loc=0x80000228
5977 # write should trigger a retry and success
5978 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5979 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5981 if [ $RC -ne 0 ] ; then
5982 error "write should success, but failed for $RC"
5985 run_test 81a "OST should retry write when get -ENOSPC ==============="
5987 test_81b() { # LU-456
5988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5989 remote_ost_nodsh && skip "remote OST with nodsh" && return
5990 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5991 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5992 do_facet ost1 lctl set_param fail_loc=0x228
5994 # write should retry several times and return -ENOSPC finally
5995 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5996 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5999 if [ $RC -ne $ENOSPC ] ; then
6000 error "dd should fail for -ENOSPC, but succeed."
6003 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6005 test_82() { # LU-1031
6006 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6010 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6012 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6014 kill -USR1 $MULTIPID2
6016 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6017 error "First grouplock does not block second one"
6019 echo "Second grouplock blocks first one"
6021 kill -USR1 $MULTIPID1
6025 run_test 82 "Basic grouplock test ==============================="
6028 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6030 test_mkdir -p $DIR/d99cvsroot
6031 chown $RUNAS_ID $DIR/d99cvsroot
6032 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6035 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6038 run_test 99a "cvs init ========================================="
6041 [ -z "$(which cvs 2>/dev/null)" ] &&
6042 skip_env "could not find cvs" && return
6043 [ ! -d $DIR/d99cvsroot ] && test_99a
6045 # some versions of cvs import exit(1) when asked to import links or
6046 # files they can't read. ignore those files.
6047 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6048 ! -perm +4 -printf '-I %f\n')
6049 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6050 d99reposname vtag rtag
6052 run_test 99b "cvs import ======================================="
6055 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6056 [ ! -d $DIR/d99cvsroot ] && test_99b
6058 test_mkdir -p $DIR/d99reposname
6059 chown $RUNAS_ID $DIR/d99reposname
6060 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6062 run_test 99c "cvs checkout ====================================="
6065 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6066 [ ! -d $DIR/d99cvsroot ] && test_99c
6067 cd $DIR/d99reposname
6069 $RUNAS cvs add -m 'addmsg' foo99
6071 run_test 99d "cvs add =========================================="
6074 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6075 [ ! -d $DIR/d99cvsroot ] && test_99c
6076 cd $DIR/d99reposname
6079 run_test 99e "cvs update ======================================="
6082 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6083 [ ! -d $DIR/d99cvsroot ] && test_99d
6084 cd $DIR/d99reposname
6085 $RUNAS cvs commit -m 'nomsg' foo99
6086 rm -fr $DIR/d99cvsroot
6088 run_test 99f "cvs commit ======================================="
6091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6092 [ "$NETTYPE" = tcp ] || \
6093 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6096 remote_ost_nodsh && skip "remote OST with nodsh" && return
6097 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6099 { skip "useless for local single node setup" && return; }
6101 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6102 [ "$PROT" != "tcp" ] && continue
6103 RPORT=$(echo $REMOTE | cut -d: -f2)
6104 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6107 LPORT=`echo $LOCAL | cut -d: -f2`
6108 if [ $LPORT -ge 1024 ]; then
6109 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6111 error_exit "local: $LPORT > 1024, remote: $RPORT"
6114 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6116 run_test 100 "check local port using privileged port ==========="
6118 function get_named_value()
6127 echo $line | sed "s/^$tag[ ]*//"
6134 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6135 awk '/^max_cached_mb/ { print $2 }')
6138 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6144 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6148 local cache_limit=32
6150 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6151 trap cleanup_101a EXIT
6152 $LCTL set_param -n llite.*.read_ahead_stats 0
6153 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6156 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6158 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6159 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6162 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6163 get_named_value 'read but discarded' | cut -d" " -f1); do
6164 discard=$(($discard + $s))
6168 if [[ $(($discard * 10)) -gt $nreads ]]; then
6169 $LCTL get_param osc.*-osc*.rpc_stats
6170 $LCTL get_param llite.*.read_ahead_stats
6171 error "too many ($discard) discarded pages"
6173 rm -f $DIR/$tfile || true
6175 run_test 101a "check read-ahead for random reads ================"
6178 test_mkdir -p $DIR/$tdir
6179 local STRIPE_SIZE=$1
6180 local FILE_LENGTH=$2
6183 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6185 local list=$(comma_list $(osts_nodes))
6186 set_osd_param $list '' read_cache_enable 0
6187 set_osd_param $list '' writethrough_cache_enable 0
6189 trap cleanup_test101bc EXIT
6190 # prepare the read-ahead file
6191 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6193 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6194 count=$FILE_SIZE_MB 2> /dev/null
6198 cleanup_test101bc() {
6203 local list=$(comma_list $(osts_nodes))
6204 set_osd_param $list '' read_cache_enable 1
6205 set_osd_param $list '' writethrough_cache_enable 1
6209 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6214 local STRIPE_SIZE=$2
6215 local FILE_LENGTH=$3
6216 local RA_INC=1048576
6217 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6218 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6219 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6220 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6221 get_named_value 'read but discarded' |
6222 cut -d" " -f1 | calc_total)
6223 if [[ $DISCARD -gt $discard_limit ]]; then
6224 $LCTL get_param llite.*.read_ahead_stats
6225 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6227 echo "Read-ahead success for size ${READ_SIZE}"
6232 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6233 [[ $OSTCOUNT -lt 2 ]] &&
6234 skip_env "skipping stride IO stride-ahead test" && return
6235 local STRIPE_SIZE=1048576
6236 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6237 if [ $SLOW == "yes" ]; then
6238 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6240 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6243 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6245 # prepare the read-ahead file
6246 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6247 cancel_lru_locks osc
6248 for BIDX in 2 4 8 16 32 64 128 256
6250 local BSIZE=$((BIDX*4096))
6251 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6252 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6253 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6254 $LCTL set_param -n llite.*.read_ahead_stats 0
6255 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6256 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6257 cancel_lru_locks osc
6258 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6263 run_test 101b "check stride-io mode read-ahead ================="
6266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6267 local STRIPE_SIZE=1048576
6268 local FILE_LENGTH=$((STRIPE_SIZE*100))
6272 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6274 cancel_lru_locks osc
6275 $LCTL set_param osc.*.rpc_stats 0
6276 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6277 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6278 local stats=$($LCTL get_param -n $osc_rpc_stats)
6279 local lines=$(echo "$stats" | awk 'END {print NR;}')
6282 if [ $lines -le 20 ]; then
6285 for size in 1 2 4 8; do
6286 local rpc=$(echo "$stats" |
6287 awk '($1 == "'$size':") {print $2; exit; }')
6289 error "Small $((size*4))k read IO $rpc !"
6291 echo "$osc_rpc_stats check passed!"
6296 run_test 101c "check stripe_size aligned read-ahead ================="
6299 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6300 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6305 local file=$DIR/$tfile
6306 local sz_MB=${FILESIZE_101d:-500}
6307 local ra_MB=${READAHEAD_MB:-40}
6309 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6310 [ $free_MB -lt $sz_MB ] &&
6311 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6313 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6314 $SETSTRIPE -c -1 $file || error "setstripe failed"
6316 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6317 echo Cancel LRU locks on lustre client to flush the client cache
6318 cancel_lru_locks osc
6320 echo Disable read-ahead
6321 local old_READAHEAD=$(set_read_ahead 0)
6323 echo Reading the test file $file with read-ahead disabled
6324 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6326 echo Cancel LRU locks on lustre client to flush the client cache
6327 cancel_lru_locks osc
6328 echo Enable read-ahead with ${ra_MB}MB
6329 set_read_ahead $ra_MB
6331 echo Reading the test file $file with read-ahead enabled
6332 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6334 echo "read-ahead disabled time read $raOFF"
6335 echo "read-ahead enabled time read $raON"
6337 set_read_ahead $old_READAHEAD
6339 wait_delete_completed
6341 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6342 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6344 run_test 101d "file read with and without read-ahead enabled"
6347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6348 local file=$DIR/$tfile
6349 local size_KB=500 #KB
6353 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6354 local need_KB=$((count * size_KB))
6355 [[ $free_KB -le $need_KB ]] &&
6356 skip_env "Need free space $need_KB, have $free_KB" && return
6358 echo "Creating $count ${size_KB}K test files"
6359 for ((i = 0; i < $count; i++)); do
6360 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6363 echo "Cancel LRU locks on lustre client to flush the client cache"
6364 cancel_lru_locks osc
6366 echo "Reset readahead stats"
6367 $LCTL set_param -n llite.*.read_ahead_stats 0
6369 for ((i = 0; i < $count; i++)); do
6370 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6373 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6374 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6376 for ((i = 0; i < $count; i++)); do
6377 rm -rf $file.$i 2>/dev/null
6380 #10000 means 20% reads are missing in readahead
6381 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6383 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6385 cleanup_test101f() {
6387 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6388 rm -rf $DIR/$tfile 2>/dev/null
6392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6393 local file=$DIR/$tfile
6396 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6397 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6398 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6399 trap cleanup_test101f EXIT
6401 echo Cancel LRU locks on lustre client to flush the client cache
6402 cancel_lru_locks osc
6404 echo Reset readahead stats
6405 $LCTL set_param -n llite.*.read_ahead_stats 0
6406 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6407 # readahead should read in 2M file on second read, so only miss
6409 echo Random 4K reads on 2M file for 1000 times
6410 $READS -f $file -s 2097152 -b 4096 -n $nreads
6412 echo checking missing pages
6413 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6414 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6416 [ $miss -lt 3 ] || error "misses too much pages!"
6419 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6422 test_mkdir -p $DIR/$tdir
6423 chown $RUNAS_ID $DIR/$tdir
6426 STRIPE_COUNT=$OSTCOUNT
6427 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6429 trap cleanup_test102 EXIT
6431 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6433 for num in 1 2 3 4; do
6434 for count in $(seq 1 $STRIPE_COUNT); do
6435 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6436 local size=`expr $STRIPE_SIZE \* $num`
6437 local file=file"$num-$idx-$count"
6438 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6444 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6450 rm -rf $DIR/d0.sanity/d102
6454 local testfile=$DIR/$tfile
6458 [ "$UID" != 0 ] && skip_env "must run as root" && return
6459 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6460 skip_env "must have user_xattr" && return
6462 [ -z "$(which setfattr 2>/dev/null)" ] &&
6463 skip_env "could not find setfattr" && return
6465 echo "set/get xattr..."
6466 setfattr -n trusted.name1 -v value1 $testfile ||
6467 error "setfattr -n trusted.name1=value1 $testfile failed"
6468 getfattr -n trusted.name1 $testfile 2> /dev/null |
6469 grep "trusted.name1=.value1" ||
6470 error "$testfile missing trusted.name1=value1"
6472 setfattr -n user.author1 -v author1 $testfile ||
6473 error "setfattr -n user.author1=author1 $testfile failed"
6474 getfattr -n user.author1 $testfile 2> /dev/null |
6475 grep "user.author1=.author1" ||
6476 error "$testfile missing trusted.author1=author1"
6479 setfattr -n trusted.name2 -v value2 $testfile ||
6480 error "$testfile unable to set trusted.name2"
6481 setfattr -n trusted.name3 -v value3 $testfile ||
6482 error "$testfile unable to set trusted.name3"
6483 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6484 grep "trusted.name" | wc -l) -eq 3 ] ||
6485 error "$testfile missing 3 trusted.name xattrs"
6487 setfattr -n user.author2 -v author2 $testfile ||
6488 error "$testfile unable to set user.author2"
6489 setfattr -n user.author3 -v author3 $testfile ||
6490 error "$testfile unable to set user.author3"
6491 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6492 grep "user.author" | wc -l) -eq 3 ] ||
6493 error "$testfile missing 3 user.author xattrs"
6495 echo "remove xattr..."
6496 setfattr -x trusted.name1 $testfile ||
6497 error "$testfile error deleting trusted.name1"
6498 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6499 error "$testfile did not delete trusted.name1 xattr"
6501 setfattr -x user.author1 $testfile ||
6502 error "$testfile error deleting user.author1"
6503 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6504 error "$testfile did not delete trusted.name1 xattr"
6506 # b10667: setting lustre special xattr be silently discarded
6507 echo "set lustre special xattr ..."
6508 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6509 error "$testfile allowed setting trusted.lov"
6511 run_test 102a "user xattr test =================================="
6514 [ -z "$(which setfattr 2>/dev/null)" ] &&
6515 skip_env "could not find setfattr" && return
6517 # b10930: get/set/list trusted.lov xattr
6518 echo "get/set/list trusted.lov xattr ..."
6519 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6520 local testfile=$DIR/$tfile
6521 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6522 error "setstripe failed"
6523 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6524 error "getstripe failed"
6525 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6526 error "can't get trusted.lov from $testfile"
6528 local testfile2=${testfile}2
6529 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6530 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6533 setfattr -n trusted.lov -v $value $testfile2
6534 local stripe_size=$($GETSTRIPE -S $testfile2)
6535 local stripe_count=$($GETSTRIPE -c $testfile2)
6536 [[ $stripe_size -eq 65536 ]] ||
6537 error "stripe size $stripe_size != 65536"
6538 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6539 error "stripe count $stripe_count != $STRIPECOUNT"
6542 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6545 [ -z "$(which setfattr 2>/dev/null)" ] &&
6546 skip_env "could not find setfattr" && return
6548 # b10930: get/set/list lustre.lov xattr
6549 echo "get/set/list lustre.lov xattr ..."
6550 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6551 test_mkdir -p $DIR/$tdir
6552 chown $RUNAS_ID $DIR/$tdir
6553 local testfile=$DIR/$tdir/$tfile
6554 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6555 error "setstripe failed"
6556 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6557 error "getstripe failed"
6558 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6559 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6561 local testfile2=${testfile}2
6562 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6563 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6565 $RUNAS $MCREATE $testfile2
6566 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6567 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6568 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6569 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6570 [ $stripe_count -eq $STRIPECOUNT ] ||
6571 error "stripe count $stripe_count != $STRIPECOUNT"
6573 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6575 compare_stripe_info1() {
6576 local stripe_index_all_zero=true
6578 for num in 1 2 3 4; do
6579 for count in $(seq 1 $STRIPE_COUNT); do
6580 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6581 local size=$((STRIPE_SIZE * num))
6582 local file=file"$num-$offset-$count"
6583 stripe_size=$(lfs getstripe -S $PWD/$file)
6584 [[ $stripe_size -ne $size ]] &&
6585 error "$file: size $stripe_size != $size"
6586 stripe_count=$(lfs getstripe -c $PWD/$file)
6587 # allow fewer stripes to be created, ORI-601
6588 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6589 error "$file: count $stripe_count != $count"
6590 stripe_index=$(lfs getstripe -i $PWD/$file)
6591 [[ $stripe_index -ne 0 ]] &&
6592 stripe_index_all_zero=false
6596 $stripe_index_all_zero &&
6597 error "all files are being extracted starting from OST index 0"
6602 [ -n "$(which tar 2>/dev/null)" ] &&
6603 strings $(which tar) | grep -q "lustre" && echo tar
6607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6608 # b10930: tar test for trusted.lov xattr
6609 TAR=$(find_lustre_tar)
6610 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6611 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6613 test_mkdir -p $DIR/d102d
6614 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6616 compare_stripe_info1
6618 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6622 # b10930: tar test for trusted.lov xattr
6623 TAR=$(find_lustre_tar)
6624 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6625 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6627 test_mkdir -p $DIR/d102f
6629 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6631 compare_stripe_info1
6633 run_test 102f "tar copy files, not keep osts ==========="
6636 local xsize=${1:-1024} # in bytes
6637 local file=$DIR/$tfile
6639 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6640 skip "must have user_xattr" && return 0
6641 [ -z "$(which setfattr 2>/dev/null)" ] &&
6642 skip_env "could not find setfattr" && return 0
6643 [ -z "$(which getfattr 2>/dev/null)" ] &&
6644 skip_env "could not find getfattr" && return 0
6648 local value="$(generate_string $xsize)"
6650 local xbig=trusted.big
6651 log "save $xbig on $file"
6652 setfattr -n $xbig -v $value $file ||
6653 error "saving $xbig on $file failed"
6655 local orig=$(get_xattr_value $xbig $file)
6656 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6658 local xsml=trusted.sml
6659 log "save $xsml on $file"
6660 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6662 local new=$(get_xattr_value $xbig $file)
6663 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6665 log "grow $xsml on $file"
6666 setfattr -n $xsml -v "$value" $file ||
6667 error "growing $xsml on $file failed"
6669 new=$(get_xattr_value $xbig $file)
6670 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6671 log "$xbig still valid after growing $xsml"
6676 test_102h() { # bug 15777
6679 run_test 102h "grow xattr from inside inode to external block"
6682 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6683 grow_xattr $(max_xattr_size)
6685 run_test 102ha "grow xattr from inside inode to external inode"
6687 test_102i() { # bug 17038
6688 [ -z "$(which getfattr 2>/dev/null)" ] &&
6689 skip "could not find getfattr" && return
6691 ln -s $DIR/$tfile $DIR/${tfile}link
6692 getfattr -n trusted.lov $DIR/$tfile ||
6693 error "lgetxattr on $DIR/$tfile failed"
6694 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6695 grep -i "no such attr" ||
6696 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6697 rm -f $DIR/$tfile $DIR/${tfile}link
6699 run_test 102i "lgetxattr test on symbolic link ============"
6702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6703 TAR=$(find_lustre_tar)
6704 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6705 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6706 setup_test102 "$RUNAS"
6707 test_mkdir -p $DIR/d102j
6708 chown $RUNAS_ID $DIR/d102j
6709 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6711 compare_stripe_info1 "$RUNAS"
6713 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6716 [ -z "$(which setfattr 2>/dev/null)" ] &&
6717 skip "could not find setfattr" && return
6719 # b22187 just check that does not crash for regular file.
6720 setfattr -n trusted.lov $DIR/$tfile
6721 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6722 local test_kdir=$DIR/d102k
6723 test_mkdir $test_kdir
6724 local default_size=`$GETSTRIPE -S $test_kdir`
6725 local default_count=`$GETSTRIPE -c $test_kdir`
6726 local default_offset=`$GETSTRIPE -i $test_kdir`
6727 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6728 error 'dir setstripe failed'
6729 setfattr -n trusted.lov $test_kdir
6730 local stripe_size=`$GETSTRIPE -S $test_kdir`
6731 local stripe_count=`$GETSTRIPE -c $test_kdir`
6732 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6733 [ $stripe_size -eq $default_size ] ||
6734 error "stripe size $stripe_size != $default_size"
6735 [ $stripe_count -eq $default_count ] ||
6736 error "stripe count $stripe_count != $default_count"
6737 [ $stripe_offset -eq $default_offset ] ||
6738 error "stripe offset $stripe_offset != $default_offset"
6739 rm -rf $DIR/$tfile $test_kdir
6741 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6744 [ -z "$(which getfattr 2>/dev/null)" ] &&
6745 skip "could not find getfattr" && return
6747 # LU-532 trusted. xattr is invisible to non-root
6748 local testfile=$DIR/$tfile
6752 echo "listxattr as user..."
6753 chown $RUNAS_ID $testfile
6754 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6755 grep -q "trusted" &&
6756 error "$testfile trusted xattrs are user visible"
6760 run_test 102l "listxattr size test =================================="
6762 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6763 local path=$DIR/$tfile
6766 listxattr_size_check $path || error "listattr_size_check $path failed"
6768 run_test 102m "Ensure listxattr fails on small bufffer ========"
6772 getxattr() { # getxattr path name
6773 # Return the base64 encoding of the value of xattr name on path.
6777 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6779 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6781 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6783 getfattr --absolute-names --encoding=base64 --name=$name $path |
6784 awk -F= -v name=$name '$1 == name {
6785 print substr($0, index($0, "=") + 1);
6789 test_102n() { # LU-4101 mdt: protect internal xattrs
6790 local file0=$DIR/$tfile.0
6791 local file1=$DIR/$tfile.1
6792 local xattr0=$TMP/$tfile.0
6793 local xattr1=$TMP/$tfile.1
6797 [ -z "$(which setfattr 2>/dev/null)" ] &&
6798 skip "could not find setfattr" && return
6800 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6802 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6806 rm -rf $file0 $file1 $xattr0 $xattr1
6809 # Get 'before' xattrs of $file1.
6810 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6812 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6813 # Try to copy xattr from $file0 to $file1.
6814 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6816 setfattr --name=trusted.$name --value="$value" $file1 ||
6817 error "setxattr 'trusted.$name' failed"
6819 # Try to set a garbage xattr.
6820 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6822 setfattr --name=trusted.$name --value="$value" $file1 ||
6823 error "setxattr 'trusted.$name' failed"
6825 # Try to remove the xattr from $file1. We don't care if this
6826 # appears to succeed or fail, we just don't want there to be
6827 # any changes or crashes.
6828 setfattr --remove=$trusted.$name $file1 2> /dev/null
6831 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6834 # Try to copy xattr from $file0 to $file1.
6835 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6837 setfattr --name=trusted.$name --value="$value" $file1 ||
6838 error "setxattr 'trusted.$name' failed"
6840 # Try to set a garbage xattr.
6841 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6843 setfattr --name=trusted.$name --value="$value" $file1 ||
6844 error "setxattr 'trusted.$name' failed"
6846 # Try to remove the xattr from $file1. We don't care if this
6847 # appears to succeed or fail, we just don't want there to be
6848 # any changes or crashes.
6849 setfattr --remove=$trusted.$name $file1 2> /dev/null
6852 # Get 'after' xattrs of file1.
6853 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6855 if ! diff $xattr0 $xattr1; then
6856 error "before and after xattrs of '$file1' differ"
6859 rm -rf $file0 $file1 $xattr0 $xattr1
6863 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6865 test_102p() { # LU-4703 setxattr did not check ownership
6866 local testfile=$DIR/$tfile
6868 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6869 skip "MDS needs to be at least 2.5.56" && return
6873 echo "setfacl as user..."
6874 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6875 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6877 echo "setfattr as user..."
6878 setfacl -m "u:$RUNAS_ID:---" $testfile
6879 $RUNAS setfattr -x system.posix_acl_access $testfile
6880 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6882 run_test 102p "check setxattr(2) correctly fails without permission"
6886 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6891 [ "$UID" != 0 ] && skip_env "must run as root" && return
6892 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6893 skip "must have acl enabled" && return
6894 [ -z "$(which setfacl 2>/dev/null)" ] &&
6895 skip_env "could not find setfacl" && return
6896 $GSS && skip "could not run under gss" && return
6898 gpasswd -a daemon bin # LU-5641
6899 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
6901 declare -a identity_old
6903 for num in $(seq $MDSCOUNT); do
6904 switch_identity $num true || identity_old[$num]=$?
6911 echo "performing cp ..."
6912 run_acl_subtest cp || error "run_acl_subtest cp failed"
6913 echo "performing getfacl-noacl..."
6914 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6915 echo "performing misc..."
6916 run_acl_subtest misc || error "misc test failed"
6917 echo "performing permissions..."
6918 run_acl_subtest permissions || error "permissions failed"
6919 echo "performing setfacl..."
6920 run_acl_subtest setfacl || error "setfacl test failed"
6922 # inheritance test got from HP
6923 echo "performing inheritance..."
6924 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6925 chmod +x make-tree || error "chmod +x failed"
6926 run_acl_subtest inheritance || error "inheritance test failed"
6929 echo "LU-974 ignore umask when acl is enabled..."
6930 run_acl_subtest 974 || error "LU-974 umask test failed"
6931 if [ $MDSCOUNT -ge 2 ]; then
6932 run_acl_subtest 974_remote ||
6933 error "LU-974 umask test failed under remote dir"
6936 echo "LU-2561 newly created file is same size as directory..."
6937 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6938 run_acl_subtest 2561 || error "LU-2561 test failed"
6940 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6943 run_acl_subtest 4924 || error "LU-4924 test failed"
6948 for num in $(seq $MDSCOUNT); do
6949 if [ "${identity_old[$num]}" = 1 ]; then
6950 switch_identity $num false || identity_old[$num]=$?
6954 run_test 103a "acl test ========================================="
6958 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
6959 local mountopts=$MDS_MOUNT_OPTS
6961 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
6965 stop $SINGLEMDS || error "failed to stop MDT."
6967 if [ -z "$MDS_MOUNT_OPTS" ]; then
6968 MDS_MOUNT_OPTS="-o noacl"
6970 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
6972 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6973 error "failed to start MDT."
6974 MDS_MOUNT_OPTS=$mountopts
6978 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
6982 stop $SINGLEMDS || error "failed to stop MDT."
6984 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6985 error "failed to start MDT."
6990 run_test 103b "MDS mount option 'noacl'"
6994 cp -rp $DIR/$tdir $DIR/$tdir.bak
6996 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
6997 error "$DIR/$tdir shouldn't contain default ACL"
6998 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
6999 error "$DIR/$tdir.bak shouldn't contain default ACL"
7002 run_test 103c "'cp -rp' won't set empty acl"
7005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7007 lfs df || error "lfs df failed"
7008 lfs df -ih || error "lfs df -ih failed"
7009 lfs df -h $DIR || error "lfs df -h $DIR failed"
7010 lfs df -i $DIR || error "lfs df -i $DIR failed"
7011 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7012 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7014 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7015 lctl --device %$OSC deactivate
7016 lfs df || error "lfs df with deactivated OSC failed"
7017 lctl --device %$OSC activate
7018 # wait the osc back to normal
7019 wait_osc_import_state client ost FULL
7021 lfs df || error "lfs df with reactivated OSC failed"
7024 run_test 104a "lfs df [-ih] [path] test ========================="
7027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7028 [ $RUNAS_ID -eq $UID ] &&
7029 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7031 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7032 grep "Permission denied" | wc -l)))
7033 if [ $denied_cnt -ne 0 ]; then
7034 error "lfs check servers test failed"
7037 run_test 104b "$RUNAS lfs check servers test ===================="
7040 # doesn't work on 2.4 kernels
7042 if $(flock_is_enabled); then
7043 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7045 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7049 run_test 105a "flock when mounted without -o flock test ========"
7053 if $(flock_is_enabled); then
7054 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7056 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7060 run_test 105b "fcntl when mounted without -o flock test ========"
7064 if $(flock_is_enabled); then
7065 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7067 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7071 run_test 105c "lockf when mounted without -o flock test ========"
7073 test_105d() { # bug 15924
7074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7075 test_mkdir -p $DIR/$tdir
7076 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7077 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7078 $LCTL set_param fail_loc=0x80000315
7079 flocks_test 2 $DIR/$tdir
7081 run_test 105d "flock race (should not freeze) ========"
7083 test_105e() { # bug 22660 && 22040
7084 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7086 flocks_test 3 $DIR/$tfile
7088 run_test 105e "Two conflicting flocks from same process ======="
7090 test_106() { #bug 10921
7091 test_mkdir -p $DIR/$tdir
7092 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7093 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7095 run_test 106 "attempt exec of dir followed by chown of that dir"
7098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7105 local save_pattern=$(sysctl -n kernel.core_pattern)
7106 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7107 sysctl -w kernel.core_pattern=$file
7108 sysctl -w kernel.core_uses_pid=0
7116 kill -s 11 $SLEEPPID
7118 if [ -e $file ]; then
7119 size=`stat -c%s $file`
7120 [ $size -eq 0 ] && error "Fail to create core file $file"
7122 error "Fail to create core file $file"
7125 sysctl -w kernel.core_pattern=$save_pattern
7126 sysctl -w kernel.core_uses_pid=$save_uses_pid
7129 run_test 107 "Coredump on SIG"
7132 test_mkdir -p $DIR/$tdir
7133 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7134 error "mkdir with 255 char failed"
7135 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7136 error "mkdir with 256 char should fail, but did not"
7137 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7138 error "create with 255 char failed"
7139 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7140 error "create with 256 char should fail, but did not"
7145 run_test 110 "filename length checking"
7148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7149 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7150 tail -1 | cut -c11-20)
7151 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7152 echo "Starting with $OSTIO_pre threads"
7155 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7156 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7157 echo "$NUMTEST creates/unlinks"
7158 test_mkdir -p $DIR/$tdir
7159 createmany -o $DIR/$tdir/$tfile $NUMTEST
7160 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7162 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7163 tail -1 | cut -c11-20)
7165 # don't return an error
7166 [ $OSTIO_post == $OSTIO_pre ] && echo \
7167 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7168 echo "This may be fine, depending on what ran before this test" &&
7169 echo "and how fast this system is." && return
7171 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7173 run_test 115 "verify dynamic thread creation===================="
7176 wait_delete_completed
7177 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7178 echo OST kbytes available: ${AVAIL[@]}
7179 MAXI=0; MAXV=${AVAIL[0]}
7180 MINI=0; MINV=${AVAIL[0]}
7181 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7182 #echo OST $i: ${AVAIL[i]}kb
7183 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7184 MAXV=${AVAIL[i]}; MAXI=$i
7186 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7187 MINV=${AVAIL[i]}; MINI=$i
7190 echo Min free space: OST $MINI: $MINV
7191 echo Max free space: OST $MAXI: $MAXV
7194 test_116a() { # was previously test_116()
7195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7196 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7198 echo -n "Free space priority "
7199 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7204 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7205 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7207 trap simple_cleanup_common EXIT
7210 # Check if we need to generate uneven OSTs
7211 test_mkdir -p $DIR/$tdir/OST${MINI}
7212 local FILL=$(($MINV / 4))
7213 local DIFF=$(($MAXV - $MINV))
7214 local DIFF2=$(($DIFF * 100 / $MINV))
7216 local threshold=$(do_facet $SINGLEMDS \
7217 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7218 threshold=${threshold%%%}
7219 echo -n "Check for uneven OSTs: "
7220 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7222 if [[ $DIFF2 -gt $threshold ]]; then
7224 echo "Don't need to fill OST$MINI"
7226 # generate uneven OSTs. Write 2% over the QOS threshold value
7228 DIFF=$(($threshold - $DIFF2 + 2))
7229 DIFF2=$(( ($MINV * $DIFF)/100 ))
7230 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7231 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7232 error "setstripe failed"
7233 DIFF=$(($DIFF2 / 2048))
7235 while [ $i -lt $DIFF ]; do
7237 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7238 bs=2M count=1 2>/dev/null
7247 DIFF=$(($MAXV - $MINV))
7248 DIFF2=$(($DIFF * 100 / $MINV))
7249 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7250 if [[ $DIFF2 -gt $threshold ]]; then
7253 echo "failed - QOS mode won't be used"
7254 skip "QOS imbalance criteria not met"
7255 simple_cleanup_common
7259 MINI1=$MINI; MINV1=$MINV
7260 MAXI1=$MAXI; MAXV1=$MAXV
7262 # now fill using QOS
7263 $SETSTRIPE -c 1 $DIR/$tdir
7264 FILL=$(($FILL / 200))
7265 if [ $FILL -gt 600 ]; then
7268 echo "writing $FILL files to QOS-assigned OSTs"
7270 while [ $i -lt $FILL ]; do
7272 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7276 echo "wrote $i 200k files"
7280 echo "Note: free space may not be updated, so measurements might be off"
7282 DIFF2=$(($MAXV - $MINV))
7283 echo "free space delta: orig $DIFF final $DIFF2"
7284 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7285 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7286 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7287 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7288 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7289 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7291 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7293 # Figure out which files were written where
7294 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7295 awk '/'$MINI1': / {print $2; exit}')
7297 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7298 echo "$MINC files created on smaller OST $MINI1"
7299 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7300 awk '/'$MAXI1': / {print $2; exit}')
7302 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7303 echo "$MAXC files created on larger OST $MAXI1"
7304 FILL=$(($MAXC * 100 / $MINC - 100))
7305 [[ $MINC -gt 0 ]] &&
7306 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7307 [[ $MAXC -gt $MINC ]] ||
7308 error_ignore LU-9 "stripe QOS didn't balance free space"
7309 simple_cleanup_common
7311 run_test 116a "stripe QOS: free space balance ==================="
7313 test_116b() { # LU-2093
7314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7315 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7316 head -1 2>/dev/null)" ] && skip "no QOS" && return
7317 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7319 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7320 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7321 do_facet $SINGLEMDS lctl set_param \
7322 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7324 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7325 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7326 do_facet $SINGLEMDS lctl set_param fail_loc=0
7328 do_facet $SINGLEMDS lctl set_param \
7329 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7331 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7333 test_117() # bug 10891
7335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7336 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7337 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7338 lctl set_param fail_loc=0x21e
7339 > $DIR/$tfile || error "truncate failed"
7340 lctl set_param fail_loc=0
7341 echo "Truncate succeeded."
7344 run_test 117 "verify osd extend =========="
7346 NO_SLOW_RESENDCOUNT=4
7347 export OLD_RESENDCOUNT=""
7348 set_resend_count () {
7349 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7350 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7351 lctl set_param -n $PROC_RESENDCOUNT $1
7352 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7355 # for reduce test_118* time (b=14842)
7356 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7358 # Reset async IO behavior after error case
7360 FILE=$DIR/reset_async
7362 # Ensure all OSCs are cleared
7363 $SETSTRIPE -c -1 $FILE
7364 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7369 test_118a() #bug 11710
7371 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7374 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7375 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7376 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7378 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7379 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7384 run_test 118a "verify O_SYNC works =========="
7388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7389 remote_ost_nodsh && skip "remote OST with nodsh" && return
7393 #define OBD_FAIL_OST_ENOENT 0x217
7394 set_nodes_failloc "$(osts_nodes)" 0x217
7395 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7397 set_nodes_failloc "$(osts_nodes)" 0
7398 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7399 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7402 if [[ $RC -eq 0 ]]; then
7403 error "Must return error due to dropped pages, rc=$RC"
7407 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7408 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7412 echo "Dirty pages not leaked on ENOENT"
7414 # Due to the above error the OSC will issue all RPCs syncronously
7415 # until a subsequent RPC completes successfully without error.
7416 $MULTIOP $DIR/$tfile Ow4096yc
7421 run_test 118b "Reclaim dirty pages on fatal error =========="
7425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7427 # for 118c, restore the original resend count, LU-1940
7428 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7429 set_resend_count $OLD_RESENDCOUNT
7430 remote_ost_nodsh && skip "remote OST with nodsh" && return
7434 #define OBD_FAIL_OST_EROFS 0x216
7435 set_nodes_failloc "$(osts_nodes)" 0x216
7437 # multiop should block due to fsync until pages are written
7438 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7442 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7443 error "Multiop failed to block on fsync, pid=$MULTIPID"
7446 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7448 if [[ $WRITEBACK -eq 0 ]]; then
7449 error "No page in writeback, writeback=$WRITEBACK"
7452 set_nodes_failloc "$(osts_nodes)" 0
7455 if [[ $RC -ne 0 ]]; then
7456 error "Multiop fsync failed, rc=$RC"
7459 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7460 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7462 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7463 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7467 echo "Dirty pages flushed via fsync on EROFS"
7470 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7472 # continue to use small resend count to reduce test_118* time (b=14842)
7473 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7478 remote_ost_nodsh && skip "remote OST with nodsh" && return
7482 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7483 set_nodes_failloc "$(osts_nodes)" 0x214
7484 # multiop should block due to fsync until pages are written
7485 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7489 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7490 error "Multiop failed to block on fsync, pid=$MULTIPID"
7493 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7495 if [[ $WRITEBACK -eq 0 ]]; then
7496 error "No page in writeback, writeback=$WRITEBACK"
7499 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7500 set_nodes_failloc "$(osts_nodes)" 0
7502 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7503 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7505 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7506 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7510 echo "Dirty pages gaurenteed flushed via fsync"
7513 run_test 118d "Fsync validation inject a delay of the bulk =========="
7516 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7519 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7520 lctl set_param fail_loc=0x8000040a
7522 # Should simulate EINVAL error which is fatal
7523 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7525 if [[ $RC -eq 0 ]]; then
7526 error "Must return error due to dropped pages, rc=$RC"
7529 lctl set_param fail_loc=0x0
7531 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7532 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7533 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7535 if [[ $LOCKED -ne 0 ]]; then
7536 error "Locked pages remain in cache, locked=$LOCKED"
7539 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7540 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7544 echo "No pages locked after fsync"
7549 run_test 118f "Simulate unrecoverable OSC side error =========="
7552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7555 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7556 lctl set_param fail_loc=0x406
7558 # simulate local -ENOMEM
7559 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7562 lctl set_param fail_loc=0
7563 if [[ $RC -eq 0 ]]; then
7564 error "Must return error due to dropped pages, rc=$RC"
7567 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7568 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7569 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7571 if [[ $LOCKED -ne 0 ]]; then
7572 error "Locked pages remain in cache, locked=$LOCKED"
7575 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7576 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7580 echo "No pages locked after fsync"
7585 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7589 remote_ost_nodsh && skip "remote OST with nodsh" && return
7593 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7594 set_nodes_failloc "$(osts_nodes)" 0x20e
7595 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7596 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7599 set_nodes_failloc "$(osts_nodes)" 0
7600 if [[ $RC -eq 0 ]]; then
7601 error "Must return error due to dropped pages, rc=$RC"
7604 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7605 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7606 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7608 if [[ $LOCKED -ne 0 ]]; then
7609 error "Locked pages remain in cache, locked=$LOCKED"
7612 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7613 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7617 echo "No pages locked after fsync"
7621 run_test 118h "Verify timeout in handling recoverables errors =========="
7623 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7627 remote_ost_nodsh && skip "remote OST with nodsh" && return
7631 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7632 set_nodes_failloc "$(osts_nodes)" 0x20e
7634 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7635 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7638 set_nodes_failloc "$(osts_nodes)" 0
7642 if [[ $RC -ne 0 ]]; then
7643 error "got error, but should be not, rc=$RC"
7646 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7647 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7648 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7649 if [[ $LOCKED -ne 0 ]]; then
7650 error "Locked pages remain in cache, locked=$LOCKED"
7653 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7654 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7658 echo "No pages locked after fsync"
7662 run_test 118i "Fix error before timeout in recoverable error =========="
7664 [ "$SLOW" = "no" ] && set_resend_count 4
7667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7668 remote_ost_nodsh && skip "remote OST with nodsh" && return
7672 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7673 set_nodes_failloc "$(osts_nodes)" 0x220
7675 # return -EIO from OST
7676 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7678 set_nodes_failloc "$(osts_nodes)" 0x0
7679 if [[ $RC -eq 0 ]]; then
7680 error "Must return error due to dropped pages, rc=$RC"
7683 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7684 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7685 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7686 if [[ $LOCKED -ne 0 ]]; then
7687 error "Locked pages remain in cache, locked=$LOCKED"
7690 # in recoverable error on OST we want resend and stay until it finished
7691 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7692 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7696 echo "No pages locked after fsync"
7700 run_test 118j "Simulate unrecoverable OST side error =========="
7704 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7705 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7707 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7708 set_nodes_failloc "$(osts_nodes)" 0x20e
7709 test_mkdir -p $DIR/$tdir
7711 for ((i=0;i<10;i++)); do
7712 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7713 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7720 set_nodes_failloc "$(osts_nodes)" 0
7723 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7729 test_mkdir -p $DIR/$tdir
7730 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7733 run_test 118l "fsync dir ========="
7735 test_118m() # LU-3066
7737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7738 test_mkdir -p $DIR/$tdir
7739 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7742 run_test 118m "fdatasync dir ========="
7744 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7746 test_119a() # bug 11737
7748 BSIZE=$((512 * 1024))
7749 directio write $DIR/$tfile 0 1 $BSIZE
7750 # We ask to read two blocks, which is more than a file size.
7751 # directio will indicate an error when requested and actual
7752 # sizes aren't equeal (a normal situation in this case) and
7753 # print actual read amount.
7754 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7755 if [ "$NOB" != "$BSIZE" ]; then
7756 error "read $NOB bytes instead of $BSIZE"
7760 run_test 119a "Short directIO read must return actual read amount"
7762 test_119b() # bug 11737
7764 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7766 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7767 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7769 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7770 error "direct read failed"
7773 run_test 119b "Sparse directIO read must return actual read amount"
7775 test_119c() # bug 13099
7778 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7779 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7782 run_test 119c "Testing for direct read hitting hole"
7784 test_119d() # bug 15950
7786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7787 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7788 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7790 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7791 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7792 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7793 lctl set_param fail_loc=0x40d
7794 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7797 cat $DIR/$tfile > /dev/null &
7798 lctl set_param fail_loc=0
7801 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7803 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7804 error "the read rpcs have not completed in 2s"
7806 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7808 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7811 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7812 test_mkdir -p $DIR/$tdir
7813 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7814 skip "no early lock cancel on server" && return 0
7816 lru_resize_disable mdc
7817 lru_resize_disable osc
7818 cancel_lru_locks mdc
7819 # asynchronous object destroy at MDT could cause bl ast to client
7820 cancel_lru_locks osc
7822 stat $DIR/$tdir > /dev/null
7823 can1=$(do_facet $SINGLEMDS \
7824 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7825 awk '/ldlm_cancel/ {print $2}')
7826 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7827 awk '/ldlm_bl_callback/ {print $2}')
7828 test_mkdir -c1 $DIR/$tdir/d1
7829 can2=$(do_facet $SINGLEMDS \
7830 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7831 awk '/ldlm_cancel/ {print $2}')
7832 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7833 awk '/ldlm_bl_callback/ {print $2}')
7834 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7835 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7836 lru_resize_enable mdc
7837 lru_resize_enable osc
7839 run_test 120a "Early Lock Cancel: mkdir test"
7842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7843 test_mkdir $DIR/$tdir
7844 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7845 skip "no early lock cancel on server" && return 0
7846 lru_resize_disable mdc
7847 lru_resize_disable osc
7848 cancel_lru_locks mdc
7849 stat $DIR/$tdir > /dev/null
7850 can1=$(do_facet $SINGLEMDS \
7851 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7852 awk '/ldlm_cancel/ {print $2}')
7853 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7854 awk '/ldlm_bl_callback/ {print $2}')
7856 can2=$(do_facet $SINGLEMDS \
7857 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7858 awk '/ldlm_cancel/ {print $2}')
7859 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7860 awk '/ldlm_bl_callback/ {print $2}')
7861 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7862 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7863 lru_resize_enable mdc
7864 lru_resize_enable osc
7866 run_test 120b "Early Lock Cancel: create test"
7869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7870 test_mkdir -c1 $DIR/$tdir
7871 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7872 skip "no early lock cancel on server" && return 0
7873 lru_resize_disable mdc
7874 lru_resize_disable osc
7875 test_mkdir -p -c1 $DIR/$tdir/d1
7876 test_mkdir -p -c1 $DIR/$tdir/d2
7877 touch $DIR/$tdir/d1/f1
7878 cancel_lru_locks mdc
7879 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7880 can1=$(do_facet $SINGLEMDS \
7881 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7882 awk '/ldlm_cancel/ {print $2}')
7883 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7884 awk '/ldlm_bl_callback/ {print $2}')
7885 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7886 can2=$(do_facet $SINGLEMDS \
7887 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7888 awk '/ldlm_cancel/ {print $2}')
7889 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7890 awk '/ldlm_bl_callback/ {print $2}')
7891 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7892 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7893 lru_resize_enable mdc
7894 lru_resize_enable osc
7896 run_test 120c "Early Lock Cancel: link test"
7899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7900 test_mkdir -p -c1 $DIR/$tdir
7901 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7902 skip "no early lock cancel on server" && return 0
7903 lru_resize_disable mdc
7904 lru_resize_disable osc
7906 cancel_lru_locks mdc
7907 stat $DIR/$tdir > /dev/null
7908 can1=$(do_facet $SINGLEMDS \
7909 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7910 awk '/ldlm_cancel/ {print $2}')
7911 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7912 awk '/ldlm_bl_callback/ {print $2}')
7913 chmod a+x $DIR/$tdir
7914 can2=$(do_facet $SINGLEMDS \
7915 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7916 awk '/ldlm_cancel/ {print $2}')
7917 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7918 awk '/ldlm_bl_callback/ {print $2}')
7919 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7920 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7921 lru_resize_enable mdc
7922 lru_resize_enable osc
7924 run_test 120d "Early Lock Cancel: setattr test"
7927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7928 test_mkdir -p -c1 $DIR/$tdir
7929 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7930 skip "no early lock cancel on server" && return 0
7931 lru_resize_disable mdc
7932 lru_resize_disable osc
7933 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7934 cancel_lru_locks mdc
7935 cancel_lru_locks osc
7936 dd if=$DIR/$tdir/f1 of=/dev/null
7937 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7938 # XXX client can not do early lock cancel of OST lock
7939 # during unlink (LU-4206), so cancel osc lock now.
7940 cancel_lru_locks osc
7941 can1=$(do_facet $SINGLEMDS \
7942 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7943 awk '/ldlm_cancel/ {print $2}')
7944 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7945 awk '/ldlm_bl_callback/ {print $2}')
7946 unlink $DIR/$tdir/f1
7948 can2=$(do_facet $SINGLEMDS \
7949 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7950 awk '/ldlm_cancel/ {print $2}')
7951 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7952 awk '/ldlm_bl_callback/ {print $2}')
7953 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7954 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7955 lru_resize_enable mdc
7956 lru_resize_enable osc
7958 run_test 120e "Early Lock Cancel: unlink test"
7961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7962 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7963 skip "no early lock cancel on server" && return 0
7964 test_mkdir -p -c1 $DIR/$tdir
7965 lru_resize_disable mdc
7966 lru_resize_disable osc
7967 test_mkdir -p -c1 $DIR/$tdir/d1
7968 test_mkdir -p -c1 $DIR/$tdir/d2
7969 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7970 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7971 cancel_lru_locks mdc
7972 cancel_lru_locks osc
7973 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7974 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7975 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7976 # XXX client can not do early lock cancel of OST lock
7977 # during rename (LU-4206), so cancel osc lock now.
7978 cancel_lru_locks osc
7979 can1=$(do_facet $SINGLEMDS \
7980 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7981 awk '/ldlm_cancel/ {print $2}')
7982 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7983 awk '/ldlm_bl_callback/ {print $2}')
7984 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7986 can2=$(do_facet $SINGLEMDS \
7987 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7988 awk '/ldlm_cancel/ {print $2}')
7989 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7990 awk '/ldlm_bl_callback/ {print $2}')
7991 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7992 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7993 lru_resize_enable mdc
7994 lru_resize_enable osc
7996 run_test 120f "Early Lock Cancel: rename test"
7999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8000 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8001 skip "no early lock cancel on server" && return 0
8002 lru_resize_disable mdc
8003 lru_resize_disable osc
8005 echo create $count files
8006 test_mkdir -p $DIR/$tdir
8007 cancel_lru_locks mdc
8008 cancel_lru_locks osc
8011 can0=$(do_facet $SINGLEMDS \
8012 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8013 awk '/ldlm_cancel/ {print $2}')
8014 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8015 awk '/ldlm_bl_callback/ {print $2}')
8016 createmany -o $DIR/$tdir/f $count
8018 can1=$(do_facet $SINGLEMDS \
8019 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8020 awk '/ldlm_cancel/ {print $2}')
8021 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8022 awk '/ldlm_bl_callback/ {print $2}')
8024 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8025 echo rm $count files
8028 can2=$(do_facet $SINGLEMDS \
8029 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8030 awk '/ldlm_cancel/ {print $2}')
8031 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8032 awk '/ldlm_bl_callback/ {print $2}')
8034 echo total: $count removes in $((t2-t1))
8035 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8037 # wait for commitment of removal
8038 lru_resize_enable mdc
8039 lru_resize_enable osc
8041 run_test 120g "Early Lock Cancel: performance test"
8043 test_121() { #bug #10589
8044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8046 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8047 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8048 lctl set_param fail_loc=0x310
8049 cancel_lru_locks osc > /dev/null
8050 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8051 lctl set_param fail_loc=0
8052 [[ $reads -eq $writes ]] ||
8053 error "read $reads blocks, must be $writes blocks"
8055 run_test 121 "read cancel race ========="
8057 test_123a() { # was test 123, statahead(bug 11401)
8058 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8060 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8061 log "testing on UP system. Performance may be not as good as expected."
8066 test_mkdir -p $DIR/$tdir
8067 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8068 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8070 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8071 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8073 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8074 lctl set_param -n llite.*.statahead_max 0
8075 lctl get_param llite.*.statahead_max
8076 cancel_lru_locks mdc
8077 cancel_lru_locks osc
8079 time ls -l $DIR/$tdir | wc -l
8081 delta=$((etime - stime))
8082 log "ls $i files without statahead: $delta sec"
8083 lctl set_param llite.*.statahead_max=$max
8085 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8086 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8087 cancel_lru_locks mdc
8088 cancel_lru_locks osc
8090 time ls -l $DIR/$tdir | wc -l
8092 delta_sa=$((etime - stime))
8093 log "ls $i files with statahead: $delta_sa sec"
8094 lctl get_param -n llite.*.statahead_stats
8095 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8097 [[ $swrong -lt $ewrong ]] &&
8098 log "statahead was stopped, maybe too many locks held!"
8099 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8101 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8102 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8103 lctl set_param -n llite.*.statahead_max 0
8104 lctl get_param llite.*.statahead_max
8105 cancel_lru_locks mdc
8106 cancel_lru_locks osc
8108 time ls -l $DIR/$tdir | wc -l
8110 delta=$((etime - stime))
8111 log "ls $i files again without statahead: $delta sec"
8112 lctl set_param llite.*.statahead_max=$max
8113 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8114 if [ $SLOWOK -eq 0 ]; then
8115 error "ls $i files is slower with statahead!"
8117 log "ls $i files is slower with statahead!"
8123 [ $delta -gt 20 ] && break
8124 [ $delta -gt 8 ] && MULT=$((50 / delta))
8125 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8133 delta=$((etime - stime))
8134 log "rm -r $DIR/$tdir/: $delta seconds"
8136 lctl get_param -n llite.*.statahead_stats
8138 run_test 123a "verify statahead work"
8140 test_123b () { # statahead(bug 15027)
8141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8142 test_mkdir -p $DIR/$tdir
8143 createmany -o $DIR/$tdir/$tfile-%d 1000
8145 cancel_lru_locks mdc
8146 cancel_lru_locks osc
8148 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8149 lctl set_param fail_loc=0x80000803
8150 ls -lR $DIR/$tdir > /dev/null
8152 lctl set_param fail_loc=0x0
8153 lctl get_param -n llite.*.statahead_stats
8158 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8161 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8162 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8163 skip "no lru resize on server" && return 0
8165 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8167 log "create $NR files at $DIR/$tdir"
8168 createmany -o $DIR/$tdir/f $NR ||
8169 error "failed to create $NR files in $DIR/$tdir"
8171 cancel_lru_locks mdc
8172 ls -l $DIR/$tdir > /dev/null
8176 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8177 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8178 LRU_SIZE=$($LCTL get_param -n $PARAM)
8179 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8180 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8182 log "NS=$(basename $NSDIR)"
8187 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8188 skip "Not enough cached locks created!"
8195 # We know that lru resize allows one client to hold $LIMIT locks
8196 # for 10h. After that locks begin to be killed by client.
8198 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8201 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8202 # killing locks. Some time was spent for creating locks. This means
8203 # that up to the moment of sleep finish we must have killed some of
8204 # them (10-100 locks). This depends on how fast ther were created.
8205 # Many of them were touched in almost the same moment and thus will
8206 # be killed in groups.
8207 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8209 # Use $LRU_SIZE_B here to take into account real number of locks
8210 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8211 local LRU_SIZE_B=$LRU_SIZE
8213 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8214 log "OLD_LVF=$OLD_LVF"
8215 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8217 # Let's make sure that we really have some margin. Client checks
8218 # cached locks every 10 sec.
8220 log "Sleep ${SLEEP} sec"
8222 while ((SEC<$SLEEP)); do
8226 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8230 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8231 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8233 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8234 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8235 unlinkmany $DIR/$tdir/f $NR
8239 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8240 log "unlink $NR files at $DIR/$tdir"
8241 unlinkmany $DIR/$tdir/f $NR
8243 run_test 124a "lru resize ======================================="
8245 get_max_pool_limit()
8247 local limit=$($LCTL get_param \
8248 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8251 if [[ $l -gt $max ]]; then
8259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8260 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8261 skip "no lru resize on server" && return 0
8263 LIMIT=$(get_max_pool_limit)
8265 NR=$(($(default_lru_size)*20))
8266 if [[ $NR -gt $LIMIT ]]; then
8267 log "Limit lock number by $LIMIT locks"
8270 lru_resize_disable mdc
8271 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8272 error "failed to create $DIR/$tdir/disable_lru_resize"
8274 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8275 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8276 cancel_lru_locks mdc
8279 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8282 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8285 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8289 nolruresize_delta=$((etime-stime))
8290 log "ls -la time: $nolruresize_delta seconds"
8291 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8292 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8294 lru_resize_enable mdc
8295 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8296 error "failed to create $DIR/$tdir/enable_lru_resize"
8298 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8299 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8300 cancel_lru_locks mdc
8303 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8306 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8309 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8313 lruresize_delta=$((etime-stime))
8314 log "ls -la time: $lruresize_delta seconds"
8315 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8317 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8318 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8319 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8320 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8322 log "lru resize performs the same with no lru resize"
8324 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8326 run_test 124b "lru resize (performance test) ======================="
8328 test_125() { # 13358
8329 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8330 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8331 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8332 test_mkdir -p $DIR/d125 || error "mkdir failed"
8333 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8334 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8335 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8337 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8339 test_126() { # bug 12829/13455
8340 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8341 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8342 $GSS && skip "must run as gss disabled" && return
8344 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8345 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8347 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8349 run_test 126 "check that the fsgid provided by the client is taken into account"
8351 test_127a() { # bug 15521
8352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8353 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8354 $LCTL set_param osc.*.stats=0
8355 FSIZE=$((2048 * 1024))
8356 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8357 cancel_lru_locks osc
8358 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8360 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8361 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8362 echo "got $COUNT $NAME"
8363 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8364 eval $NAME=$COUNT || error "Wrong proc format"
8367 read_bytes|write_bytes)
8368 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8369 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8370 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8371 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8372 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8373 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8374 error "sumsquare is too small: $SUMSQ"
8375 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8376 error "sumsquare is too big: $SUMSQ"
8380 done < $DIR/${tfile}.tmp
8382 #check that we actually got some stats
8383 [ "$read_bytes" ] || error "Missing read_bytes stats"
8384 [ "$write_bytes" ] || error "Missing write_bytes stats"
8385 [ "$read_bytes" != 0 ] || error "no read done"
8386 [ "$write_bytes" != 0 ] || error "no write done"
8388 run_test 127a "verify the client stats are sane"
8390 test_127b() { # bug LU-333
8391 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8392 $LCTL set_param llite.*.stats=0
8393 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8394 # perform 2 reads and writes so MAX is different from SUM.
8395 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8396 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8397 cancel_lru_locks osc
8398 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8399 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8401 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8402 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8403 echo "got $COUNT $NAME"
8404 eval $NAME=$COUNT || error "Wrong proc format"
8408 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8409 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8410 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8411 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8414 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8415 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8416 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8417 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8421 done < $TMP/${tfile}.tmp
8423 #check that we actually got some stats
8424 [ "$read_bytes" ] || error "Missing read_bytes stats"
8425 [ "$write_bytes" ] || error "Missing write_bytes stats"
8426 [ "$read_bytes" != 0 ] || error "no read done"
8427 [ "$write_bytes" != 0 ] || error "no write done"
8429 run_test 127b "verify the llite client stats are sane"
8431 test_128() { # bug 15212
8433 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8438 result=$(grep error $TMP/$tfile.log)
8440 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8442 run_test 128 "interactive lfs for 2 consecutive find's"
8449 local LDPROC=/proc/fs/ldiskfs
8450 local facets=$(get_facets MDS)
8452 for facet in ${facets//,/ }; do
8453 canondev=$(ldiskfs_canon \
8454 *.$(convert_facet2label $facet).mntdev $facet)
8455 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8456 LDPROC=/sys/fs/ldiskfs
8457 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8462 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8463 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8464 skip "Only applicable to ldiskfs-based MDTs"
8467 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8472 test_mkdir -p $DIR/$tdir
8474 # block size of mds1
8475 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8476 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8477 local MAX=$((MDSBLOCKSIZE * 3))
8479 local I=$(stat -c%s "$DIR/$tdir")
8481 local STRIPE_COUNT=1
8482 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8483 MAX=$((MAX*STRIPE_COUNT))
8484 while [[ $I -le $MAX ]]; do
8485 $MULTIOP $DIR/$tdir/$J Oc
8487 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8488 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8489 #and EFBIG for previous versions
8490 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8492 echo "return code $rc received as expected"
8493 multiop $DIR/$tdir/$J Oc ||
8494 error_exit "multiop failed w/o dir size limit"
8496 I=$(stat -c%s "$DIR/$tdir")
8498 if [ $(lustre_version_code $SINGLEMDS) -lt \
8499 $(version_code 2.4.51) ]
8501 [[ $I -eq $MAX ]] && return 0
8503 [[ $I -gt $MAX ]] && return 0
8505 error_exit "current dir size $I, previous limit $MAX"
8506 elif [ $rc -ne 0 ]; then
8508 error_exit "return code $rc received instead of expected " \
8509 "$EFBIG or $ENOSPC, files in dir $I"
8512 I=$(stat -c%s "$DIR/$tdir")
8516 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8518 run_test 129 "test directory size limit ========================"
8527 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8528 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8531 trap cleanup_130 EXIT RETURN
8533 local fm_file=$DIR/$tfile
8534 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8535 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8536 error "dd failed for $fm_file"
8538 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8539 filefrag -ves $fm_file
8541 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8542 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8543 [ $RC != 0 ] && error "filefrag $fm_file failed"
8545 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8546 grep -v "ext:" | grep -v "found")
8547 lun=$($GETSTRIPE -i $fm_file)
8549 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8552 for line in $filefrag_op
8554 frag_lun=`echo $line | cut -d: -f5`
8555 ext_len=`echo $line | cut -d: -f4`
8556 if (( $frag_lun != $lun )); then
8558 error "FIEMAP on 1-stripe file($fm_file) failed"
8561 (( tot_len += ext_len ))
8564 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8566 error "FIEMAP on 1-stripe file($fm_file) failed;"
8572 echo "FIEMAP on single striped file succeeded"
8574 run_test 130a "FIEMAP (1-stripe file)"
8577 [ "$OSTCOUNT" -lt "2" ] &&
8578 skip_env "skipping FIEMAP on 2-stripe file test" && return
8580 [ "$OSTCOUNT" -ge "10" ] &&
8581 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8583 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8584 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8587 trap cleanup_130 EXIT RETURN
8589 local fm_file=$DIR/$tfile
8590 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8591 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8592 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8594 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8595 error "dd failed on $fm_file"
8597 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8598 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8599 grep -v "ext:" | grep -v "found")
8601 last_lun=$(echo $filefrag_op | cut -d: -f5)
8606 for line in $filefrag_op
8608 frag_lun=`echo $line | cut -d: -f5`
8609 ext_len=`echo $line | cut -d: -f4`
8610 if (( $frag_lun != $last_lun )); then
8611 if (( tot_len != 1024 )); then
8613 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8620 (( tot_len += ext_len ))
8623 if (( num_luns != 2 || tot_len != 1024 )); then
8625 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8631 echo "FIEMAP on 2-stripe file succeeded"
8633 run_test 130b "FIEMAP (2-stripe file)"
8636 [ "$OSTCOUNT" -lt "2" ] &&
8637 skip_env "skipping FIEMAP on 2-stripe file" && return
8639 [ "$OSTCOUNT" -ge "10" ] &&
8640 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8642 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8643 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8646 trap cleanup_130 EXIT RETURN
8648 local fm_file=$DIR/$tfile
8649 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8650 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8651 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8653 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8655 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8656 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8658 last_lun=`echo $filefrag_op | cut -d: -f5`
8663 for line in $filefrag_op
8665 frag_lun=`echo $line | cut -d: -f5`
8666 ext_len=`echo $line | cut -d: -f4`
8667 if (( $frag_lun != $last_lun )); then
8668 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8669 if (( logical != 512 )); then
8671 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8674 if (( tot_len != 512 )); then
8676 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8683 (( tot_len += ext_len ))
8686 if (( num_luns != 2 || tot_len != 512 )); then
8688 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8694 echo "FIEMAP on 2-stripe file with hole succeeded"
8696 run_test 130c "FIEMAP (2-stripe file with hole)"
8699 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8701 [ "$OSTCOUNT" -ge "10" ] &&
8702 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8704 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8705 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8707 trap cleanup_130 EXIT RETURN
8709 local fm_file=$DIR/$tfile
8710 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8711 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8712 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8714 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8715 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8716 error "dd failed on $fm_file"
8718 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8719 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8720 grep -v "ext:" | grep -v "found"`
8722 last_lun=`echo $filefrag_op | cut -d: -f5`
8727 for line in $filefrag_op
8729 frag_lun=`echo $line | cut -d: -f5`
8730 ext_len=`echo $line | cut -d: -f4`
8731 if (( $frag_lun != $last_lun )); then
8732 if (( tot_len != 1024 )); then
8734 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8741 (( tot_len += ext_len ))
8744 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8746 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8752 echo "FIEMAP on N-stripe file succeeded"
8754 run_test 130d "FIEMAP (N-stripe file)"
8757 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8759 [ "$OSTCOUNT" -ge "10" ] &&
8760 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8762 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8763 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8765 trap cleanup_130 EXIT RETURN
8767 local fm_file=$DIR/$tfile
8768 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8769 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8770 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8773 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8774 for ((i = 0; i < $NUM_BLKS; i++))
8776 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8779 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8780 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8782 last_lun=`echo $filefrag_op | cut -d: -f5`
8787 for line in $filefrag_op
8789 frag_lun=`echo $line | cut -d: -f5`
8790 ext_len=`echo $line | cut -d: -f4`
8791 if (( $frag_lun != $last_lun )); then
8792 if (( tot_len != $EXPECTED_LEN )); then
8794 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8801 (( tot_len += ext_len ))
8804 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8806 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8812 echo "FIEMAP with continuation calls succeeded"
8814 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8816 # Test for writev/readv
8818 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8819 error "writev test failed"
8820 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8821 error "readv failed"
8824 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8827 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8828 error "append writev test failed"
8829 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8830 error "append writev test failed"
8833 run_test 131b "test append writev"
8836 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8839 run_test 131c "test read/write on file w/o objects"
8842 rwv -f $DIR/$tfile -w -n 1 1572864
8843 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8844 if [ "$NOB" != 1572864 ]; then
8845 error "Short read filed: read $NOB bytes instead of 1572864"
8849 run_test 131d "test short read"
8852 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8853 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8854 error "read hitting hole failed"
8857 run_test 131e "test read hitting hole"
8862 for node in $(osts_nodes); do
8863 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8864 [ x$gl = x"" ] && gl=0
8865 gl_sum=$((gl_sum + gl))
8875 if [ x$som = x"enabled" ]; then
8876 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8877 MOUNT_OPTS=`echo $MOUNT_OPTS |
8878 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8879 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8881 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8882 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8883 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8886 # do remount to make new mount-conf parameters actual
8893 test_132() { #1028, SOM
8894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8895 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8896 local num=$(get_mds_dir $DIR)
8897 local mymds=mds${num}
8898 local MOUNT_OPTS_SAVE=$MOUNT_OPTS
8900 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8901 cancel_lru_locks osc
8903 som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8905 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8906 stat $DIR/$tfile >/dev/null
8907 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8908 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8910 som_mode_switch $som1 $gl1 $gl2
8912 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8913 cancel_lru_locks osc
8915 som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8916 if [ $som1 == $som2 ]; then
8917 error "som is still "$som2
8918 if [ x$som2 = x"enabled" ]; then
8925 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8926 stat $DIR/$tfile >/dev/null
8927 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8928 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8929 som_mode_switch $som2 $gl1 $gl2
8930 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8932 run_test 132 "som avoids glimpse rpc"
8938 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8940 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8942 *) error "Wrong argument $1" ;;
8945 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8946 # if the argument $3 is zero, it means any stat increment is ok.
8947 if [[ $3 -gt 0 ]]; then
8948 count=$(echo $res | awk '{ print $2 }')
8949 [[ $count -ne $3 ]] &&
8950 error "The $2 counter on $1 is wrong - expected $3"
8955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8956 remote_ost_nodsh && skip "remote OST with nodsh" && return
8957 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8959 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8960 { skip "MDS doesn't support rename stats"; return; }
8961 local testdir=$DIR/${tdir}/stats_testdir
8962 mkdir -p $DIR/${tdir}
8965 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8966 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8968 # verify mdt stats first.
8969 mkdir ${testdir} || error "mkdir failed"
8970 check_stats $SINGLEMDS "mkdir" 1
8971 touch ${testdir}/${tfile} || "touch failed"
8972 check_stats $SINGLEMDS "open" 1
8973 check_stats $SINGLEMDS "close" 1
8974 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8975 check_stats $SINGLEMDS "mknod" 1
8976 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8977 check_stats $SINGLEMDS "unlink" 1
8978 rm -f ${testdir}/${tfile} || error "file remove failed"
8979 check_stats $SINGLEMDS "unlink" 2
8981 # remove working dir and check mdt stats again.
8982 rmdir ${testdir} || error "rmdir failed"
8983 check_stats $SINGLEMDS "rmdir" 1
8985 local testdir1=$DIR/${tdir}/stats_testdir1
8987 mkdir -p ${testdir1}
8988 touch ${testdir1}/test1
8989 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8990 check_stats $SINGLEMDS "crossdir_rename" 1
8992 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8993 check_stats $SINGLEMDS "samedir_rename" 1
8997 run_test 133a "Verifying MDT stats ========================================"
9000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9001 remote_ost_nodsh && skip "remote OST with nodsh" && return
9002 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9003 local testdir=$DIR/${tdir}/stats_testdir
9004 mkdir -p ${testdir} || error "mkdir failed"
9005 touch ${testdir}/${tfile} || "touch failed"
9006 cancel_lru_locks mdc
9009 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9010 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9012 # extra mdt stats verification.
9013 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9014 check_stats $SINGLEMDS "setattr" 1
9015 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9016 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9018 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9019 check_stats $SINGLEMDS "getattr" 1
9021 $LFS df || error "lfs failed"
9022 check_stats $SINGLEMDS "statfs" 1
9026 run_test 133b "Verifying extra MDT stats =================================="
9029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9030 remote_ost_nodsh && skip "remote OST with nodsh" && return
9031 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9032 local testdir=$DIR/${tdir}/stats_testdir
9033 test_mkdir -p ${testdir} || error "mkdir failed"
9035 # verify obdfilter stats.
9036 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9038 cancel_lru_locks osc
9039 wait_delete_completed
9042 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9043 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9045 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9047 cancel_lru_locks osc
9048 check_stats ost "write" 1
9050 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9051 check_stats ost "read" 1
9053 > ${testdir}/${tfile} || error "truncate failed"
9054 check_stats ost "punch" 1
9056 rm -f ${testdir}/${tfile} || error "file remove failed"
9057 wait_delete_completed
9058 check_stats ost "destroy" 1
9062 run_test 133c "Verifying OST stats ========================================"
9069 while [ $value -ge 2 ]; do
9074 if [ $orig -gt $order ]; then
9082 local size=('K' 'M' 'G' 'T');
9084 local size_string=$value
9086 while [ $value -ge 1024 ]; do
9087 if [ $i -gt 3 ]; then
9088 #T is the biggest unit we get here, if that is bigger,
9090 size_string=${value}T
9093 value=$((value >> 10))
9094 if [ $value -lt 1024 ]; then
9095 size_string=${value}${size[$i]}
9106 local context=${2:-.}
9107 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9109 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9115 remote_ost_nodsh && skip "remote OST with nodsh" && return
9116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9117 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9118 { skip "MDS doesn't support rename stats"; return; }
9120 local testdir1=$DIR/${tdir}/stats_testdir1
9121 local testdir2=$DIR/${tdir}/stats_testdir2
9123 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9125 mkdir -p ${testdir1} || error "mkdir failed"
9126 mkdir -p ${testdir2} || error "mkdir failed"
9128 createmany -o $testdir1/test 512 || error "createmany failed"
9130 # check samedir rename size
9131 mv ${testdir1}/test0 ${testdir1}/test_0
9133 local testdir1_size=$(ls -l $DIR/${tdir} |
9134 awk '/stats_testdir1/ {print $5}')
9135 local testdir2_size=$(ls -l $DIR/${tdir} |
9136 awk '/stats_testdir2/ {print $5}')
9138 testdir1_size=$(order_2 $testdir1_size)
9139 testdir2_size=$(order_2 $testdir2_size)
9141 testdir1_size=$(size_in_KMGT $testdir1_size)
9142 testdir2_size=$(size_in_KMGT $testdir2_size)
9144 echo "source rename dir size: ${testdir1_size}"
9145 echo "target rename dir size: ${testdir2_size}"
9147 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9148 eval $cmd || error "$cmd failed"
9149 local samedir=$($cmd | grep 'same_dir')
9150 local same_sample=$(get_rename_size $testdir1_size)
9151 [ -z "$samedir" ] && error "samedir_rename_size count error"
9152 [[ $same_sample -eq 1 ]] ||
9153 error "samedir_rename_size error $same_sample"
9154 echo "Check same dir rename stats success"
9156 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9158 # check crossdir rename size
9159 mv ${testdir1}/test_0 ${testdir2}/test_0
9161 testdir1_size=$(ls -l $DIR/${tdir} |
9162 awk '/stats_testdir1/ {print $5}')
9163 testdir2_size=$(ls -l $DIR/${tdir} |
9164 awk '/stats_testdir2/ {print $5}')
9166 testdir1_size=$(order_2 $testdir1_size)
9167 testdir2_size=$(order_2 $testdir2_size)
9169 testdir1_size=$(size_in_KMGT $testdir1_size)
9170 testdir2_size=$(size_in_KMGT $testdir2_size)
9172 echo "source rename dir size: ${testdir1_size}"
9173 echo "target rename dir size: ${testdir2_size}"
9175 eval $cmd || error "$cmd failed"
9176 local crossdir=$($cmd | grep 'crossdir')
9177 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9178 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9179 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9180 [[ $src_sample -eq 1 ]] ||
9181 error "crossdir_rename_size error $src_sample"
9182 [[ $tgt_sample -eq 1 ]] ||
9183 error "crossdir_rename_size error $tgt_sample"
9184 echo "Check cross dir rename stats success"
9187 run_test 133d "Verifying rename_stats ========================================"
9190 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9191 remote_ost_nodsh && skip "remote OST with nodsh" && return
9192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9193 local testdir=$DIR/${tdir}/stats_testdir
9194 local ctr f0 f1 bs=32768 count=42 sum
9196 mkdir -p ${testdir} || error "mkdir failed"
9198 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9200 for ctr in {write,read}_bytes; do
9202 cancel_lru_locks osc
9204 do_facet ost1 $LCTL set_param -n \
9205 "obdfilter.*.exports.clear=clear"
9207 if [ $ctr = write_bytes ]; then
9209 f1=${testdir}/${tfile}
9211 f0=${testdir}/${tfile}
9215 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9218 cancel_lru_locks osc
9220 sum=$(do_facet ost1 $LCTL get_param \
9221 "obdfilter.*.exports.*.stats" |
9222 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9223 $1 == ctr { sum += $7 }
9224 END { printf("%0.0f", sum) }')
9226 if ((sum != bs * count)); then
9227 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9233 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9238 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9239 /sys/fs/lustre/ /sys/fs/lnet/"
9241 for dir in $dirs; do
9242 if [ -d $dir ]; then
9243 proc_dirs="$proc_dirs $dir"
9249 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9250 remote_ost_nodsh && skip "remote OST with nodsh" && return
9251 # First without trusting modes.
9252 find $proc_dirs -exec cat '{}' \; &> /dev/null
9254 # Second verifying readability.
9257 -exec cat '{}' \; &> /dev/null ||
9258 error "proc file read failed"
9260 for facet in $SINGLEMDS ost1; do
9261 do_facet $facet find $proc_dirs \
9262 ! -name req_history \
9263 -exec cat '{}' \\\; &> /dev/null
9265 do_facet $facet find $proc_dirs \
9266 ! -name req_history \
9268 -exec cat '{}' \\\; &> /dev/null ||
9269 error "proc file read failed"
9272 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9277 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9278 /sys/fs/lustre/ /sys/fs/lnet/"
9280 for dir in $dirs; do
9281 if [ -d $dir ]; then
9282 proc_dirs="$proc_dirs $dir"
9288 # Second verifying readability.
9291 -not -name force_lbug \
9292 -not -name changelog_mask \
9293 -exec badarea_io '{}' \; &> /dev/null ||
9294 error "find $proc_dirs failed"
9296 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9297 skip "Too old lustre on MDS"
9299 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9300 skip "Too old lustre on ost1"
9302 for facet in $SINGLEMDS ost1; do
9303 do_facet $facet find $proc_dirs \
9305 -not -name force_lbug \
9306 -not -name changelog_mask \
9307 -exec badarea_io '{}' \\\; &> /dev/null ||
9308 error "$facet find $proc_dirs failed"
9312 # remount the FS in case writes/reads /proc break the FS
9313 cleanup || error "failed to unmount"
9314 setup || error "failed to setup"
9317 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9319 test_140() { #bug-17379
9320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9321 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9322 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9323 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9325 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9326 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9328 while i=`expr $i + 1`; do
9329 test_mkdir -p $i || error "Creating dir $i"
9330 cd $i || error "Changing to $i"
9331 ln -s ../stat stat || error "Creating stat symlink"
9332 # Read the symlink until ELOOP present,
9333 # not LBUGing the system is considered success,
9334 # we didn't overrun the stack.
9335 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9337 if [ $ret -eq 40 ]; then
9340 error "Open stat symlink"
9346 echo "The symlink depth = $i"
9347 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9348 error "Invalid symlink depth"
9350 # Test recursive symlink
9351 ln -s symlink_self symlink_self
9352 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9353 echo "open symlink_self returns $ret"
9354 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9356 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9360 local TF="$TMP/$tfile"
9362 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9364 cancel_lru_locks osc
9365 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9366 remount_client $MOUNT
9368 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9371 $TRUNCATE $DIR/$tfile 6000
9372 cancel_lru_locks osc
9373 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9376 echo "12345" >>$DIR/$tfile
9377 cancel_lru_locks osc
9378 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9381 echo "12345" >>$DIR/$tfile
9382 cancel_lru_locks osc
9383 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9388 run_test 150 "truncate/append tests"
9390 #LU-2902 roc_hit was not able to read all values from lproc
9391 function roc_hit_init() {
9392 local list=$(comma_list $(osts_nodes))
9393 local dir=$DIR/$tdir-check
9394 local file=$dir/file
9400 #use setstripe to do a write to every ost
9401 for i in $(seq 0 $((OSTCOUNT-1))); do
9402 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9403 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9404 idx=$(printf %04x $i)
9405 BEFORE=$(get_osd_param $list *OST*$idx stats |
9406 awk '$1 == "cache_access" {sum += $7}
9407 END { printf("%0.0f", sum) }')
9409 cancel_lru_locks osc
9410 cat $file >/dev/null
9412 AFTER=$(get_osd_param $list *OST*$idx stats |
9413 awk '$1 == "cache_access" {sum += $7}
9414 END { printf("%0.0f", sum) }')
9416 echo BEFORE:$BEFORE AFTER:$AFTER
9417 if ! let "AFTER - BEFORE == 4"; then
9419 error "roc_hit is not safe to use"
9427 function roc_hit() {
9428 local list=$(comma_list $(osts_nodes))
9429 echo $(get_osd_param $list '' stats |
9430 awk '$1 == "cache_hit" {sum += $7}
9431 END { printf("%0.0f", sum) }')
9434 function set_cache() {
9437 if [ "$2" == "off" ]; then
9440 local list=$(comma_list $(osts_nodes))
9441 set_osd_param $list '' $1_cache_enable $on
9443 cancel_lru_locks osc
9447 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9448 remote_ost_nodsh && skip "remote OST with nodsh" && return
9451 local list=$(comma_list $(osts_nodes))
9453 # check whether obdfilter is cache capable at all
9454 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9455 echo "not cache-capable obdfilter"
9459 # check cache is enabled on all obdfilters
9460 if get_osd_param $list '' read_cache_enable | grep 0; then
9461 echo "oss cache is disabled"
9465 set_osd_param $list '' writethrough_cache_enable 1
9467 # check write cache is enabled on all obdfilters
9468 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9469 echo "oss write cache is NOT enabled"
9475 #define OBD_FAIL_OBD_NO_LRU 0x609
9476 do_nodes $list $LCTL set_param fail_loc=0x609
9478 # pages should be in the case right after write
9479 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9482 local BEFORE=$(roc_hit)
9483 cancel_lru_locks osc
9484 cat $DIR/$tfile >/dev/null
9485 local AFTER=$(roc_hit)
9487 do_nodes $list $LCTL set_param fail_loc=0
9489 if ! let "AFTER - BEFORE == CPAGES"; then
9490 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9493 # the following read invalidates the cache
9494 cancel_lru_locks osc
9495 set_osd_param $list '' read_cache_enable 0
9496 cat $DIR/$tfile >/dev/null
9498 # now data shouldn't be found in the cache
9500 cancel_lru_locks osc
9501 cat $DIR/$tfile >/dev/null
9503 if let "AFTER - BEFORE != 0"; then
9504 error "IN CACHE: before: $BEFORE, after: $AFTER"
9507 set_osd_param $list '' read_cache_enable 1
9510 run_test 151 "test cache on oss and controls ==============================="
9513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9514 local TF="$TMP/$tfile"
9516 # simulate ENOMEM during write
9517 #define OBD_FAIL_OST_NOMEM 0x226
9518 lctl set_param fail_loc=0x80000226
9519 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9521 sync || error "sync failed"
9522 lctl set_param fail_loc=0
9524 # discard client's cache
9525 cancel_lru_locks osc
9527 # simulate ENOMEM during read
9528 lctl set_param fail_loc=0x80000226
9529 cmp $TF $DIR/$tfile || error "cmp failed"
9530 lctl set_param fail_loc=0
9534 run_test 152 "test read/write with enomem ============================"
9537 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9539 run_test 153 "test if fdatasync does not crash ======================="
9541 dot_lustre_fid_permission_check() {
9543 local ffid=$MOUNT/.lustre/fid/$fid
9546 echo "stat fid $fid"
9547 stat $ffid > /dev/null || error "stat $ffid failed."
9548 echo "touch fid $fid"
9549 touch $ffid || error "touch $ffid failed."
9550 echo "write to fid $fid"
9551 cat /etc/hosts > $ffid || error "write $ffid failed."
9552 echo "read fid $fid"
9553 diff /etc/hosts $ffid || error "read $ffid failed."
9554 echo "append write to fid $fid"
9555 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9556 echo "rename fid $fid"
9557 mv $ffid $test_dir/$tfile.1 &&
9558 error "rename $ffid to $tfile.1 should fail."
9559 touch $test_dir/$tfile.1
9560 mv $test_dir/$tfile.1 $ffid &&
9561 error "rename $tfile.1 to $ffid should fail."
9562 rm -f $test_dir/$tfile.1
9563 echo "truncate fid $fid"
9564 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9565 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9566 echo "link fid $fid"
9567 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9569 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9570 echo "setfacl fid $fid"
9571 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9572 echo "getfacl fid $fid"
9573 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9575 echo "unlink fid $fid"
9576 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9577 echo "mknod fid $fid"
9578 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9580 fid=[0xf00000400:0x1:0x0]
9581 ffid=$MOUNT/.lustre/fid/$fid
9583 echo "stat non-exist fid $fid"
9584 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9585 echo "write to non-exist fid $fid"
9586 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9587 echo "link new fid $fid"
9588 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9590 mkdir -p $test_dir/$tdir
9591 touch $test_dir/$tdir/$tfile
9592 fid=$($LFS path2fid $test_dir/$tdir)
9595 error "error: could not get fid for $test_dir/$dir/$tfile."
9597 ffid=$MOUNT/.lustre/fid/$fid
9600 ls $ffid > /dev/null || error "ls $ffid failed."
9601 echo "touch $fid/$tfile.1"
9602 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9604 echo "touch $MOUNT/.lustre/fid/$tfile"
9605 touch $MOUNT/.lustre/fid/$tfile && \
9606 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9608 echo "setxattr to $MOUNT/.lustre/fid"
9609 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9611 echo "listxattr for $MOUNT/.lustre/fid"
9612 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9614 echo "delxattr from $MOUNT/.lustre/fid"
9615 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9617 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9618 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9619 error "touch invalid fid should fail."
9621 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9622 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9623 error "touch non-normal fid should fail."
9625 echo "rename $tdir to $MOUNT/.lustre/fid"
9626 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9627 error "rename to $MOUNT/.lustre/fid should fail."
9629 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9631 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9632 local new_obf_mode=777
9634 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9635 chmod $new_obf_mode $DIR/.lustre/fid ||
9636 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9638 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9639 [ $obf_mode -eq $new_obf_mode ] ||
9640 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9642 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9643 chmod $old_obf_mode $DIR/.lustre/fid ||
9644 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9647 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9648 fid=$($LFS path2fid $test_dir/$tfile-2)
9650 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9652 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9653 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9654 error "create lov data thru .lustre failed"
9656 echo "cp /etc/passwd $test_dir/$tfile-2"
9657 cp /etc/passwd $test_dir/$tfile-2 ||
9658 error "copy to $test_dir/$tfile-2 failed."
9659 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9660 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9661 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9663 rm -rf $test_dir/tfile.lnk
9664 rm -rf $test_dir/$tfile-2
9668 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9669 skip "Need MDS version at least 2.4.1" && return
9672 local FID=$($LFS path2fid $DIR/$tfile)
9673 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9675 # check that we get the same pathname back
9676 local FOUND=$($LFS fid2path $MOUNT $FID)
9677 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9678 [ "$FOUND" != "$DIR/$tfile" ] &&
9679 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9683 run_test 154A "lfs path2fid and fid2path basic checks"
9686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9687 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9688 { skip "Need MDS version at least 2.2.51"; return 0; }
9689 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9691 cp /etc/hosts $DIR/$tfile
9693 fid=$($LFS path2fid $DIR/$tfile)
9695 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9697 dot_lustre_fid_permission_check "$fid" $DIR ||
9698 error "dot lustre permission check $fid failed"
9700 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9702 touch $MOUNT/.lustre/file &&
9703 error "creation is not allowed under .lustre"
9705 mkdir $MOUNT/.lustre/dir &&
9706 error "mkdir is not allowed under .lustre"
9710 run_test 154a "Open-by-FID"
9713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9714 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9715 { skip "Need MDS version at least 2.2.51"; return 0; }
9717 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9719 local remote_dir=$DIR/$tdir/remote_dir
9724 $LFS mkdir -i $MDTIDX $remote_dir ||
9725 error "create remote directory failed"
9727 cp /etc/hosts $remote_dir/$tfile
9729 fid=$($LFS path2fid $remote_dir/$tfile)
9731 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9733 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9734 error "dot lustre permission check $fid failed"
9737 run_test 154b "Open-by-FID for remote directory"
9740 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9741 skip "Need MDS version at least 2.4.1" && return
9743 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9744 local FID1=$($LFS path2fid $DIR/$tfile.1)
9745 local FID2=$($LFS path2fid $DIR/$tfile.2)
9746 local FID3=$($LFS path2fid $DIR/$tfile.3)
9749 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9750 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9751 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9753 [ "$FID" = "${!want}" ] ||
9754 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9758 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9759 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9760 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9764 run_test 154c "lfs path2fid and fid2path multiple arguments"
9767 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9768 skip "Need MDS version at least 2.5.53" && return
9771 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9775 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9782 fid=$($LFS path2fid $DIR/$tfile)
9785 cmd="exec $fd<$DIR/$tfile"
9787 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9788 echo $fid_list | grep $fid
9791 cmd="exec $fd>/dev/null"
9793 if [ $rc -ne 0 ]; then
9794 error "FID $fid not found in open files list $fid_list"
9797 run_test 154d "Verify open file fid"
9801 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9802 skip "Need MDS version at least 2.6.50" && return
9804 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9805 error ".lustre returned by readdir"
9808 run_test 154e ".lustre is not returned by readdir"
9811 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9812 test_mkdir -p -c1 $DIR/$tdir/d
9813 # test dirs inherit from its stripe
9814 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9815 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9816 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9817 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9820 # get fid of parents
9821 local FID0=$($LFS path2fid $DIR/$tdir/d)
9822 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9823 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9824 local FID3=$($LFS path2fid $DIR)
9826 # check that path2fid --parents returns expected <parent_fid>/name
9827 # 1) test for a directory (single parent)
9828 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9829 [ "$parent" == "$FID0/foo1" ] ||
9830 error "expected parent: $FID0/foo1, got: $parent"
9832 # 2) test for a file with nlink > 1 (multiple parents)
9833 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9834 echo "$parent" | grep -F "$FID1/$tfile" ||
9835 error "$FID1/$tfile not returned in parent list"
9836 echo "$parent" | grep -F "$FID2/link" ||
9837 error "$FID2/link not returned in parent list"
9839 # 3) get parent by fid
9840 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9841 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9842 echo "$parent" | grep -F "$FID1/$tfile" ||
9843 error "$FID1/$tfile not returned in parent list (by fid)"
9844 echo "$parent" | grep -F "$FID2/link" ||
9845 error "$FID2/link not returned in parent list (by fid)"
9847 # 4) test for entry in root directory
9848 parent=$($LFS path2fid --parents $DIR/f)
9849 echo "$parent" | grep -F "$FID3/f" ||
9850 error "$FID3/f not returned in parent list"
9852 # 5) test it on root directory
9853 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9854 error "$MOUNT should not have parents"
9856 # enable xattr caching and check that linkea is correctly updated
9857 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9858 save_lustre_params client "llite.*.xattr_cache" > $save
9859 lctl set_param llite.*.xattr_cache 1
9861 # 6.1) linkea update on rename
9862 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
9864 # get parents by fid
9865 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9866 # foo1 should no longer be returned in parent list
9867 echo "$parent" | grep -F "$FID1" &&
9868 error "$FID1 should no longer be in parent list"
9869 # the new path should appear
9870 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
9871 error "$FID2/$tfile.moved is not in parent list"
9873 # 6.2) linkea update on unlink
9874 rm -f $DIR/$tdir/d/foo2/link
9875 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9876 # foo2/link should no longer be returned in parent list
9877 echo "$parent" | grep -F "$FID2/link" &&
9878 error "$FID2/link should no longer be in parent list"
9882 restore_lustre_params < $save
9884 run_test 154f "get parent fids by reading link ea"
9886 test_155_small_load() {
9887 local temp=$TMP/$tfile
9888 local file=$DIR/$tfile
9890 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9891 error "dd of=$temp bs=6096 count=1 failed"
9893 cancel_lru_locks osc
9894 cmp $temp $file || error "$temp $file differ"
9896 $TRUNCATE $temp 6000
9897 $TRUNCATE $file 6000
9898 cmp $temp $file || error "$temp $file differ (truncate1)"
9900 echo "12345" >>$temp
9901 echo "12345" >>$file
9902 cmp $temp $file || error "$temp $file differ (append1)"
9904 echo "12345" >>$temp
9905 echo "12345" >>$file
9906 cmp $temp $file || error "$temp $file differ (append2)"
9912 test_155_big_load() {
9913 remote_ost_nodsh && skip "remote OST with nodsh" && return
9914 local temp=$TMP/$tfile
9915 local file=$DIR/$tfile
9918 local cache_size=$(do_facet ost$((MAXI+1)) \
9919 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9920 local large_file_size=$((cache_size * 2))
9922 echo "OSS cache size: $cache_size KB"
9923 echo "Large file size: $large_file_size KB"
9925 [ $MAXV -le $large_file_size ] && \
9926 skip_env "max available OST size needs > $large_file_size KB" && \
9929 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9931 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9932 error "dd of=$temp bs=$large_file_size count=1k failed"
9935 cancel_lru_locks osc
9936 cmp $temp $file || error "$temp $file differ"
9943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9945 set_cache writethrough on
9948 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9953 set_cache writethrough off
9956 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9961 set_cache writethrough on
9964 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9969 set_cache writethrough off
9972 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9977 set_cache writethrough on
9980 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9985 set_cache writethrough off
9988 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9993 set_cache writethrough on
9996 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10001 set_cache writethrough off
10004 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10007 remote_ost_nodsh && skip "remote OST with nodsh" && return
10008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10012 local file="$DIR/$tfile"
10014 [ "$(facet_fstype ost1)" = "zfs" ] &&
10015 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
10020 log "Turn on read and write cache"
10022 set_cache writethrough on
10024 log "Write data and read it back."
10025 log "Read should be satisfied from the cache."
10026 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10028 cancel_lru_locks osc
10029 cat $file >/dev/null
10031 if ! let "AFTER - BEFORE == CPAGES"; then
10032 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10034 log "cache hits:: before: $BEFORE, after: $AFTER"
10037 log "Read again; it should be satisfied from the cache."
10039 cancel_lru_locks osc
10040 cat $file >/dev/null
10042 if ! let "AFTER - BEFORE == CPAGES"; then
10043 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10045 log "cache hits:: before: $BEFORE, after: $AFTER"
10049 log "Turn off the read cache and turn on the write cache"
10051 set_cache writethrough on
10053 log "Read again; it should be satisfied from the cache."
10055 cancel_lru_locks osc
10056 cat $file >/dev/null
10058 if ! let "AFTER - BEFORE == CPAGES"; then
10059 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10061 log "cache hits:: before: $BEFORE, after: $AFTER"
10064 log "Read again; it should not be satisfied from the cache."
10066 cancel_lru_locks osc
10067 cat $file >/dev/null
10069 if ! let "AFTER - BEFORE == 0"; then
10070 error "IN CACHE: before: $BEFORE, after: $AFTER"
10072 log "cache hits:: before: $BEFORE, after: $AFTER"
10075 log "Write data and read it back."
10076 log "Read should be satisfied from the cache."
10077 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10079 cancel_lru_locks osc
10080 cat $file >/dev/null
10082 if ! let "AFTER - BEFORE == CPAGES"; then
10083 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10085 log "cache hits:: before: $BEFORE, after: $AFTER"
10088 log "Read again; it should not be satisfied from the cache."
10090 cancel_lru_locks osc
10091 cat $file >/dev/null
10093 if ! let "AFTER - BEFORE == 0"; then
10094 error "IN CACHE: before: $BEFORE, after: $AFTER"
10096 log "cache hits:: before: $BEFORE, after: $AFTER"
10100 log "Turn off read and write cache"
10102 set_cache writethrough off
10104 log "Write data and read it back"
10105 log "It should not be satisfied from the cache."
10107 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10108 cancel_lru_locks osc
10110 cat $file >/dev/null
10112 if ! let "AFTER - BEFORE == 0"; then
10113 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10115 log "cache hits:: before: $BEFORE, after: $AFTER"
10118 log "Turn on the read cache and turn off the write cache"
10120 set_cache writethrough off
10122 log "Write data and read it back"
10123 log "It should not be satisfied from the cache."
10125 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10127 cancel_lru_locks osc
10128 cat $file >/dev/null
10130 if ! let "AFTER - BEFORE == 0"; then
10131 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10133 log "cache hits:: before: $BEFORE, after: $AFTER"
10136 log "Read again; it should be satisfied from the cache."
10138 cancel_lru_locks osc
10139 cat $file >/dev/null
10141 if ! let "AFTER - BEFORE == CPAGES"; then
10142 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10144 log "cache hits:: before: $BEFORE, after: $AFTER"
10149 run_test 156 "Verification of tunables ============================"
10153 if [[ $MDSCOUNT -gt 1 ]]; then
10154 error_ignore bz17935 $*
10162 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10164 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10166 if [ $MASK -eq 1 ]; then
10167 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10169 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10173 changelog_extract_field() {
10177 local identifier=$4
10179 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10180 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10186 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10187 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10188 { skip "Need MDS version at least 2.2.0"; return; }
10190 local CL_USERS="mdd.$MDT0.changelog_users"
10191 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10192 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10193 echo "Registered as changelog user $USER"
10194 $GET_CL_USERS | grep -q $USER ||
10195 error "User $USER not found in changelog_users"
10198 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10199 touch $DIR/$tdir/pics/2008/zachy/timestamp
10200 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10201 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10202 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10203 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10204 rm $DIR/$tdir/pics/desktop.jpg
10206 $LFS changelog $MDT0 | tail -5
10208 echo "verifying changelog mask"
10209 changelog_chmask "MKDIR"
10210 changelog_chmask "CLOSE"
10212 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10213 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10215 changelog_chmask "MKDIR"
10216 changelog_chmask "CLOSE"
10218 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10219 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10221 $LFS changelog $MDT0
10222 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10223 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10224 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10225 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10228 echo "verifying target fid"
10229 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10230 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10231 [ "$fidc" == "$fidf" ] ||
10232 err17935 "fid in changelog $fidc != file fid $fidf"
10233 echo "verifying parent fid"
10234 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10235 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10236 [ "$fidc" == "$fidf" ] ||
10237 err17935 "pfid in changelog $fidc != dir fid $fidf"
10239 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10240 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10241 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10242 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10243 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10244 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10246 MIN_REC=$($GET_CL_USERS |
10247 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10248 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10249 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10250 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10251 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10253 # LU-3446 changelog index reset on MDT restart
10254 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10255 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10256 $LFS changelog_clear $MDT0 $USER 0
10257 stop $SINGLEMDS || error "Fail to stop MDT."
10258 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10259 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10260 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10261 [ $CUR_REC1 == $CUR_REC2 ] ||
10262 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10264 echo "verifying user deregister"
10265 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10266 $GET_CL_USERS | grep -q $USER &&
10267 error "User $USER still in changelog_users"
10269 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10270 if [ $USERS -eq 0 ]; then
10271 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10272 touch $DIR/$tdir/chloe
10273 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10274 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10275 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10277 echo "$USERS other changelog users; can't verify off"
10280 run_test 160a "changelog sanity"
10282 test_160b() { # LU-3587
10283 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10284 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10285 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10286 { skip "Need MDS version at least 2.2.0"; return; }
10288 local CL_USERS="mdd.$MDT0.changelog_users"
10289 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10290 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10291 echo "Registered as changelog user $USER"
10292 $GET_CL_USERS | grep -q $USER ||
10293 error "User $USER not found in changelog_users"
10295 local LONGNAME1=$(str_repeat a 255)
10296 local LONGNAME2=$(str_repeat b 255)
10299 echo "creating very long named file"
10300 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10301 echo "moving very long named file"
10302 mv $LONGNAME1 $LONGNAME2
10304 $LFS changelog $MDT0 | grep RENME
10306 echo "deregistering $USER"
10307 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10311 run_test 160b "Verify that very long rename doesn't crash in changelog"
10315 local server_version=$(lustre_version_code $SINGLEMDS)
10317 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10318 [[ $server_version -gt $(version_code 2.5.1) &&
10319 $server_version -lt $(version_code 2.5.50) ]] ||
10320 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10321 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10323 # Registration step
10324 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10325 changelog_register -n)
10328 mkdir -p $DIR/$tdir
10329 $MCREATE $DIR/$tdir/foo_160c
10330 changelog_chmask "TRUNC"
10331 $TRUNCATE $DIR/$tdir/foo_160c 200
10332 changelog_chmask "TRUNC"
10333 $TRUNCATE $DIR/$tdir/foo_160c 199
10334 $LFS changelog $MDT0
10335 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10336 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10337 $LFS changelog_clear $MDT0 $USER 0
10339 # Deregistration step
10340 echo "deregistering $USER"
10341 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10343 run_test 160c "verify that changelog log catch the truncate event"
10346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10347 test_mkdir -p -c1 $DIR/$tdir
10348 cp /etc/hosts $DIR/$tdir/$tfile
10349 test_mkdir -c1 $DIR/$tdir/foo1
10350 test_mkdir -c1 $DIR/$tdir/foo2
10351 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10352 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10353 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10354 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10355 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10356 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10357 $LFS fid2path $DIR $FID
10358 err17935 "bad link ea"
10361 rm $DIR/$tdir/foo2/zachary
10363 rm $DIR/$tdir/foo2/thor
10365 rm $DIR/$tdir/$tfile
10367 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10368 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10370 $LFS fid2path $DIR $FID
10371 err17935 "bad link rename"
10373 rm $DIR/$tdir/foo2/maggie
10376 local longname=filename_avg_len_is_thirty_two_
10377 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10378 error "failed to hardlink many files"
10379 links=$($LFS fid2path $DIR $FID | wc -l)
10380 echo -n "${links}/1000 links in link EA"
10381 [[ $links -gt 60 ]] ||
10382 err17935 "expected at least 60 links in link EA"
10383 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10384 error "failed to unlink many hardlinks"
10386 run_test 161a "link ea sanity"
10389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10390 [ $MDSCOUNT -lt 2 ] &&
10391 skip "skipping remote directory test" && return
10393 local remote_dir=$DIR/$tdir/remote_dir
10395 mkdir -p $DIR/$tdir
10396 $LFS mkdir -i $MDTIDX $remote_dir ||
10397 error "create remote directory failed"
10399 cp /etc/hosts $remote_dir/$tfile
10400 mkdir -p $remote_dir/foo1
10401 mkdir -p $remote_dir/foo2
10402 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10403 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10404 ln $remote_dir/$tfile $remote_dir/foo1/luna
10405 ln $remote_dir/$tfile $remote_dir/foo2/thor
10407 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10409 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10410 $LFS fid2path $DIR $FID
10411 err17935 "bad link ea"
10414 rm $remote_dir/foo2/zachary
10416 rm $remote_dir/foo2/thor
10418 rm $remote_dir/$tfile
10420 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10421 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10422 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10423 $LFS fid2path $DIR $FID
10424 err17935 "bad link rename"
10426 rm $remote_dir/foo2/maggie
10429 local longname=filename_avg_len_is_thirty_two_
10430 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10431 error "failed to hardlink many files"
10432 links=$($LFS fid2path $DIR $FID | wc -l)
10433 echo -n "${links}/1000 links in link EA"
10434 [[ ${links} -gt 60 ]] ||
10435 err17935 "expected at least 60 links in link EA"
10436 unlinkmany $remote_dir/foo2/$longname 1000 ||
10437 error "failed to unlink many hardlinks"
10439 run_test 161b "link ea sanity under remote directory"
10442 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10444 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10445 skip "Need MDS version at least 2.1.5" && return
10447 # define CLF_RENAME_LAST 0x0001
10448 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10449 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10450 changelog_register -n)
10452 mkdir -p $DIR/$tdir
10453 touch $DIR/$tdir/foo_161c
10454 touch $DIR/$tdir/bar_161c
10455 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10456 $LFS changelog $MDT0 | grep RENME
10457 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10459 $LFS changelog_clear $MDT0 $USER 0
10460 if [ x$flags != "x0x1" ]; then
10461 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10463 error "flag $flags is not 0x1"
10465 echo "rename overwrite a target having nlink = 1," \
10466 "changelog record has flags of $flags"
10468 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10469 touch $DIR/$tdir/foo_161c
10470 touch $DIR/$tdir/bar_161c
10471 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10472 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10473 $LFS changelog $MDT0 | grep RENME
10474 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10475 $LFS changelog_clear $MDT0 $USER 0
10476 if [ x$flags != "x0x0" ]; then
10477 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10479 error "flag $flags is not 0x0"
10481 echo "rename overwrite a target having nlink > 1," \
10482 "changelog record has flags of $flags"
10484 # rename doesn't overwrite a target (changelog flag 0x0)
10485 touch $DIR/$tdir/foo_161c
10486 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10487 $LFS changelog $MDT0 | grep RENME
10488 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10489 $LFS changelog_clear $MDT0 $USER 0
10490 if [ x$flags != "x0x0" ]; then
10491 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10493 error "flag $flags is not 0x0"
10495 echo "rename doesn't overwrite a target," \
10496 "changelog record has flags of $flags"
10498 # define CLF_UNLINK_LAST 0x0001
10499 # unlink a file having nlink = 1 (changelog flag 0x1)
10500 rm -f $DIR/$tdir/foo2_161c
10501 $LFS changelog $MDT0 | grep UNLNK
10502 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10503 $LFS changelog_clear $MDT0 $USER 0
10504 if [ x$flags != "x0x1" ]; then
10505 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10507 error "flag $flags is not 0x1"
10509 echo "unlink a file having nlink = 1," \
10510 "changelog record has flags of $flags"
10512 # unlink a file having nlink > 1 (changelog flag 0x0)
10513 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10514 rm -f $DIR/$tdir/foobar_161c
10515 $LFS changelog $MDT0 | grep UNLNK
10516 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10517 $LFS changelog_clear $MDT0 $USER 0
10518 if [ x$flags != "x0x0" ]; then
10519 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10521 error "flag $flags is not 0x0"
10523 echo "unlink a file having nlink > 1," \
10524 "changelog record has flags of $flags"
10525 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10527 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10534 local path=$(${LFS} fid2path $*)
10537 if [ $RC -ne 0 ]; then
10538 err17935 "path looked up of $expected failed. Error $RC"
10540 elif [ "${path}" != "${expected}" ]; then
10541 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10544 echo "fid $fid resolves to path $path (expected $expected)"
10548 # Make changes to filesystem
10549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10550 test_mkdir -p -c1 $DIR/$tdir/d2
10551 touch $DIR/$tdir/d2/$tfile
10552 touch $DIR/$tdir/d2/x1
10553 touch $DIR/$tdir/d2/x2
10554 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10555 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10557 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10558 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10559 error "check path $tdir/d2/$tfile failed"
10562 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10563 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10564 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10565 error "check path $tdir/d2/p/q/r/slink failed"
10567 # softlink to wrong file
10568 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10569 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10570 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10571 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10574 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10575 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10576 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10577 # fid2path dir/fsname should both work
10578 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10579 error "check path $tdir/d2/a/b/c/new_file failed"
10580 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10581 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10583 # hardlink count: check that there are 2 links
10584 # Doesnt work with CMD yet: 17935
10585 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10586 err17935 "expected 2 links"
10588 # hardlink indexing: remove the first link
10589 rm $DIR/$tdir/d2/p/q/r/hlink
10590 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10591 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10595 run_test 162 "path lookup sanity"
10598 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10599 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10602 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10603 error "create striped dir failed"
10605 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10606 tail -n 1 | awk '{print $2}')
10607 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10609 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10610 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10613 for ((i=0;i<5;i++)); do
10614 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10615 error "get fid for f$i failed"
10616 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10617 error "check path $tdir/striped_dir/f$i failed"
10619 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10620 error "get fid for d$i failed"
10621 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10622 error "check path $tdir/striped_dir/d$i failed"
10627 run_test 162b "striped directory path lookup sanity"
10630 # do directio so as not to populate the page cache
10631 log "creating a 10 Mb file"
10632 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10633 log "starting reads"
10634 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10635 log "truncating the file"
10636 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10638 kill %+ || true # reads might have finished
10639 echo "wait until dd is finished"
10641 log "removing the temporary file"
10642 rm -rf $DIR/$tfile || error "tmp file removal failed"
10644 run_test 169 "parallel read and truncate should not deadlock"
10647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10648 $LCTL clear # bug 18514
10649 $LCTL debug_daemon start $TMP/${tfile}_log_good
10651 $LCTL debug_daemon stop
10652 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10653 error "sed failed to read log_good"
10655 $LCTL debug_daemon start $TMP/${tfile}_log_good
10657 $LCTL debug_daemon stop
10659 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10660 error "lctl df log_bad failed"
10662 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10663 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10665 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10666 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10668 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10669 error "bad_line good_line1 good_line2 are empty"
10671 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10672 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10673 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10675 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10676 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10677 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10679 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10680 error "bad_line_new good_line_new are empty"
10682 local expected_good=$((good_line1 + good_line2*2))
10684 rm -f $TMP/${tfile}*
10685 # LU-231, short malformed line may not be counted into bad lines
10686 if [ $bad_line -ne $bad_line_new ] &&
10687 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10688 error "expected $bad_line bad lines, but got $bad_line_new"
10692 if [ $expected_good -ne $good_line_new ]; then
10693 error "expected $expected_good good lines, but got $good_line_new"
10698 run_test 170 "test lctl df to handle corrupted log ====================="
10700 test_171() { # bug20592
10701 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10702 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10703 $LCTL set_param fail_loc=0x50e
10704 $LCTL set_param fail_val=3000
10705 multiop_bg_pause $DIR/$tfile O_s || true
10707 kill -USR1 $MULTIPID
10711 if dmesg | grep "recursive fault"; then
10712 error "caught a recursive fault"
10714 $LCTL set_param fail_loc=0
10717 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10719 # it would be good to share it with obdfilter-survey/iokit-libecho code
10720 setup_obdecho_osc () {
10723 local obdfilter_name=$2
10724 echo "Creating new osc for $obdfilter_name on $ost_nid"
10725 # make sure we can find loopback nid
10726 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10728 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10729 ${obdfilter_name}_osc_UUID || rc=2; }
10730 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10731 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10735 cleanup_obdecho_osc () {
10736 local obdfilter_name=$1
10737 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10738 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10745 local pages=${3:-64}
10750 local obd_size=$(get_obd_size $node $OBD)
10751 local page_size=$(get_page_size $node)
10752 if [[ -n "$obd_size" ]]; then
10753 local new_count=$((obd_size / (pages * page_size / 1024)))
10754 [[ $new_count -ge $count ]] || count=$new_count
10757 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10758 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10760 if [ $rc -eq 0 ]; then
10761 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10762 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10764 echo "New object id is $id"
10765 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10767 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10768 "test_brw $count w v $pages $id" || rc=4; }
10769 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10771 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10772 "cleanup" || rc=5; }
10773 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10774 "detach" || rc=6; }
10775 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10780 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10781 remote_ost_nodsh && skip "remote OST with nodsh" && return
10783 local rmmod_local=0
10785 if ! module_loaded obdecho; then
10786 load_module obdecho/obdecho
10790 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10791 local host=$(lctl get_param -n osc.$osc.import |
10792 awk '/current_connection:/ {print $2}' )
10793 local target=$(lctl get_param -n osc.$osc.import |
10794 awk '/target:/ {print $2}' )
10795 target=${target%_UUID}
10797 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10798 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10799 [[ -n $target ]] && cleanup_obdecho_osc $target
10800 [ $rmmod_local -eq 1 ] && rmmod obdecho
10803 run_test 180a "test obdecho on osc"
10806 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10807 remote_ost_nodsh && skip "remote OST with nodsh" && return
10809 local rmmod_remote=0
10811 do_facet ost1 "lsmod | grep -q obdecho || " \
10812 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10813 "modprobe obdecho; }" && rmmod_remote=1
10814 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10815 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10816 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10819 run_test 180b "test obdecho directly on obdfilter"
10821 test_180c() { # LU-2598
10822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10823 remote_ost_nodsh && skip "remote OST with nodsh" && return
10824 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10825 skip "Need MDS version at least 2.4.0" && return
10828 local rmmod_remote=false
10829 local pages=16384 # 64MB bulk I/O RPC size
10832 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10833 rmmod_remote=true || error "failed to load module obdecho"
10835 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10837 if [ -n "$target" ]; then
10838 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10840 echo "there is no obdfilter target on ost1"
10843 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10846 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10848 test_181() { # bug 22177
10849 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10850 # create enough files to index the directory
10851 createmany -o $DIR/$tdir/foobar 4000
10852 # print attributes for debug purpose
10855 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10857 # remove the files & current working dir
10858 unlinkmany $DIR/$tdir/foobar 4000
10860 kill -USR1 $MULTIPID
10862 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10865 run_test 181 "Test open-unlinked dir ========================"
10868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10869 # disable MDC RPC lock wouldn't crash client
10873 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10874 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10875 $LCTL set_param fail_loc=0x804
10877 for (( i=0; i < $tcount; i++ )) ; do
10878 mkdir $DIR/$tdir/$i
10879 createmany -o $DIR/$tdir/$i/f- $fcount &
10883 for (( i=0; i < $tcount; i++ )) ; do
10884 unlinkmany $DIR/$tdir/$i/f- $fcount &
10890 $LCTL set_param fail_loc=0
10892 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10894 test_183() { # LU-2275
10895 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10896 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10897 skip "Need MDS version at least 2.3.56" && return
10899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10900 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10901 echo aaa > $DIR/$tdir/$tfile
10903 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10904 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10906 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10907 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10909 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10911 # Flush negative dentry cache
10912 touch $DIR/$tdir/$tfile
10914 # We are not checking for any leaked references here, they'll
10915 # become evident next time we do cleanup with module unload.
10918 run_test 183 "No crash or request leak in case of strange dispositions ========"
10920 # test suite 184 is for LU-2016, LU-2017
10922 check_swap_layouts_support && return 0
10924 dir0=$DIR/$tdir/$testnum
10925 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10930 $SETSTRIPE -c1 $file1
10932 $SETSTRIPE -c2 $file2
10934 gen1=$($GETSTRIPE -g $file1)
10935 gen2=$($GETSTRIPE -g $file2)
10937 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10938 gen=$($GETSTRIPE -g $file1)
10939 [[ $gen1 != $gen ]] ||
10940 "Layout generation on $file1 does not change"
10941 gen=$($GETSTRIPE -g $file2)
10942 [[ $gen2 != $gen ]] ||
10943 "Layout generation on $file2 does not change"
10945 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10946 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10948 run_test 184a "Basic layout swap"
10951 check_swap_layouts_support && return 0
10953 dir0=$DIR/$tdir/$testnum
10954 mkdir -p $dir0 || error "creating dir $dir0"
10961 $SETSTRIPE -c1 $file1
10962 $SETSTRIPE -c2 $file2
10963 $SETSTRIPE -c1 $file3
10964 chown $RUNAS_ID $file3
10965 gen1=$($GETSTRIPE -g $file1)
10966 gen2=$($GETSTRIPE -g $file2)
10968 $LFS swap_layouts $dir1 $dir2 &&
10969 error "swap of directories layouts should fail"
10970 $LFS swap_layouts $dir1 $file1 &&
10971 error "swap of directory and file layouts should fail"
10972 $RUNAS $LFS swap_layouts $file1 $file2 &&
10973 error "swap of file we cannot write should fail"
10974 $LFS swap_layouts $file1 $file3 &&
10975 error "swap of file with different owner should fail"
10976 /bin/true # to clear error code
10978 run_test 184b "Forbidden layout swap (will generate errors)"
10981 check_swap_layouts_support && return 0
10983 local dir0=$DIR/$tdir/$testnum
10984 mkdir -p $dir0 || error "creating dir $dir0"
10986 local ref1=$dir0/ref1
10987 local ref2=$dir0/ref2
10988 local file1=$dir0/file1
10989 local file2=$dir0/file2
10990 # create a file large enough for the concurent test
10991 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10992 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10993 echo "ref file size: ref1($(stat -c %s $ref1))," \
10994 "ref2($(stat -c %s $ref2))"
10997 dd if=$ref1 of=$file1 bs=16k &
11000 # Make sure dd starts to copy file
11001 while [ ! -f $file1 ]; do sleep 0.1; done
11003 $LFS swap_layouts $file1 $file2
11006 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11007 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11009 # how many bytes copied before swapping layout
11010 local copied=$(stat -c %s $file2)
11011 local remaining=$(stat -c %s $ref1)
11012 remaining=$((remaining - copied))
11013 echo "Copied $copied bytes before swapping layout..."
11015 cmp -n $copied $file1 $ref2 | grep differ &&
11016 error "Content mismatch [0, $copied) of ref2 and file1"
11017 cmp -n $copied $file2 $ref1 ||
11018 error "Content mismatch [0, $copied) of ref1 and file2"
11019 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11020 error "Content mismatch [$copied, EOF) of ref1 and file1"
11023 rm -f $ref1 $ref2 $file1 $file2
11025 run_test 184c "Concurrent write and layout swap"
11028 check_swap_layouts_support && return 0
11029 [ -z "$(which getfattr 2>/dev/null)" ] &&
11030 skip "no getfattr command" && return 0
11032 local file1=$DIR/$tdir/$tfile-1
11033 local file2=$DIR/$tdir/$tfile-2
11034 local file3=$DIR/$tdir/$tfile-3
11038 mkdir -p $DIR/$tdir
11039 touch $file1 || error "create $file1 failed"
11040 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11041 error "create $file2 failed"
11042 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11043 error "create $file3 failed"
11044 lovea1=$($LFS getstripe $file1 | sed 1d)
11046 $LFS swap_layouts $file2 $file3 ||
11047 error "swap $file2 $file3 layouts failed"
11048 $LFS swap_layouts $file1 $file2 ||
11049 error "swap $file1 $file2 layouts failed"
11051 lovea2=$($LFS getstripe $file2 | sed 1d)
11052 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11054 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11055 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11057 run_test 184d "allow stripeless layouts swap"
11060 test_185() { # LU-2441
11061 # LU-3553 - no volatile file support in old servers
11062 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11063 { skip "Need MDS version at least 2.3.60"; return 0; }
11065 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11066 touch $DIR/$tdir/spoo
11067 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11068 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11069 error "cannot create/write a volatile file"
11070 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11071 error "FID is still valid after close"
11073 multiop_bg_pause $DIR/$tdir vVw4096_c
11080 # assume that the next FID for this client is sequential, since stdout
11081 # is unfortunately eaten by multiop_bg_pause
11082 local n=$((${fidv[1]} + 1))
11083 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11084 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11085 error "FID is missing before close"
11086 kill -USR1 $multi_pid
11087 # 1 second delay, so if mtime change we will see it
11089 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11090 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11092 run_test 185 "Volatile file support"
11095 local dir0=$DIR/$tdir/$testnum
11096 mkdir -p $dir0 || error "creating dir $dir0"
11098 local file=$dir0/file1
11099 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11100 local dv1=$($LFS data_version $file)
11101 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11102 local dv2=$($LFS data_version $file)
11103 [[ $dv1 != $dv2 ]] ||
11104 error "data version did not change on write $dv1 == $dv2"
11109 run_test 187a "Test data version change"
11112 local dir0=$DIR/$tdir/$testnum
11113 mkdir -p $dir0 || error "creating dir $dir0"
11115 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11116 [[ ${DV[0]} != ${DV[1]} ]] ||
11117 error "data version did not change on write"\
11118 " ${DV[0]} == ${DV[1]}"
11123 run_test 187b "Test data version change on volatile file"
11126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11127 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11129 local POOL=${POOL:-cea1}
11130 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11131 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11134 local last_ost=$(($OSTCOUNT - 1))
11136 local ost_list=$(seq $first_ost $ost_step $last_ost)
11137 local ost_range="$first_ost $last_ost $ost_step"
11138 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11139 local file_dir=$POOL_ROOT/file_tst
11143 # former test_200a test_200b
11144 pool_add $POOL || { rc=$? ; break; }
11145 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11146 # former test_200c test_200d
11147 mkdir -p $test_path
11148 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11149 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11150 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11151 || { rc=$? ; break; }
11152 # former test_200e test_200f
11153 local files=$((OSTCOUNT*3))
11154 pool_alloc_files $POOL $test_path $files "$ost_list" \
11155 || { rc=$? ; break; }
11156 pool_create_files $POOL $file_dir $files "$ost_list" \
11157 || { rc=$? ; break; }
11158 # former test_200g test_200h
11159 pool_lfs_df $POOL || { rc=$? ; break; }
11160 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11162 # former test_201a test_201b test_201c
11163 pool_remove_first_target $POOL || { rc=$? ; break; }
11165 local f=$test_path/$tfile
11166 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11167 pool_remove $POOL $f || { rc=$? ; break; }
11174 run_test 200 "OST pools"
11176 # usage: default_attr <count | size | offset>
11178 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11181 # usage: check_default_stripe_attr
11182 check_default_stripe_attr() {
11183 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11185 --stripe-count|--count)
11186 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11187 --stripe-size|--size)
11188 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11189 --stripe-index|--index)
11192 error "unknown getstripe attr '$1'"
11195 [ $ACTUAL != $EXPECTED ] &&
11196 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11200 test_mkdir -p $DIR/$tdir
11201 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11203 check_default_stripe_attr --stripe-count
11204 check_default_stripe_attr --stripe-size
11205 check_default_stripe_attr --stripe-index
11209 run_test 204a "Print default stripe attributes ================="
11212 test_mkdir -p $DIR/$tdir
11213 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11215 check_default_stripe_attr --stripe-size
11216 check_default_stripe_attr --stripe-index
11220 run_test 204b "Print default stripe size and offset ==========="
11223 test_mkdir -p $DIR/$tdir
11224 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11226 check_default_stripe_attr --stripe-count
11227 check_default_stripe_attr --stripe-index
11231 run_test 204c "Print default stripe count and offset ==========="
11234 test_mkdir -p $DIR/$tdir
11235 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11237 check_default_stripe_attr --stripe-count
11238 check_default_stripe_attr --stripe-size
11242 run_test 204d "Print default stripe count and size ============="
11245 test_mkdir -p $DIR/$tdir
11246 $SETSTRIPE -d $DIR/$tdir
11248 check_default_stripe_attr --stripe-count --raw
11249 check_default_stripe_attr --stripe-size --raw
11250 check_default_stripe_attr --stripe-index --raw
11254 run_test 204e "Print raw stripe attributes ================="
11257 test_mkdir -p $DIR/$tdir
11258 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11260 check_default_stripe_attr --stripe-size --raw
11261 check_default_stripe_attr --stripe-index --raw
11265 run_test 204f "Print raw stripe size and offset ==========="
11268 test_mkdir -p $DIR/$tdir
11269 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11271 check_default_stripe_attr --stripe-count --raw
11272 check_default_stripe_attr --stripe-index --raw
11276 run_test 204g "Print raw stripe count and offset ==========="
11279 test_mkdir -p $DIR/$tdir
11280 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11282 check_default_stripe_attr --stripe-count --raw
11283 check_default_stripe_attr --stripe-size --raw
11287 run_test 204h "Print raw stripe count and size ============="
11289 # Figure out which job scheduler is being used, if any,
11290 # or use a fake one
11291 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11292 JOBENV=SLURM_JOB_ID
11293 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11295 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11297 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11298 JOBENV=LOADL_STEP_ID
11299 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11305 verify_jobstats() {
11309 # clear old jobstats
11310 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11311 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11313 # use a new JobID for this test, or we might see an old one
11314 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11318 log "Using JobID environment variable $JOBENV=$JOBVAL"
11320 if [ $JOBENV = "FAKE_JOBID" ]; then
11321 FAKE_JOBID=$JOBVAL $cmd
11326 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11327 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11328 do_facet $FACET lctl get_param mdt.*.job_stats |
11329 grep $JOBVAL || error "No job stats found on MDT $FACET"
11331 if [ "$target" = "ost" -o "$target" = "both" ]; then
11333 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11334 grep $JOBVAL || error "No job stats found on OST $FACET"
11340 NEW_JOBENV=${1:-$OLD_JOBENV}
11341 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11342 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11345 test_205() { # Job stats
11346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11347 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11348 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11349 skip "Server doesn't support jobstats" && return 0
11350 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11353 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11354 if [ $OLD_JOBENV != $JOBENV ]; then
11355 jobstats_set $JOBENV
11356 trap jobstats_set EXIT
11359 local user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11360 changelog_register -n)
11361 echo "Registered as changelog user $user"
11364 cmd="mkdir $DIR/$tfile"
11365 verify_jobstats "$cmd" "mdt"
11367 cmd="rm -fr $DIR/$tfile"
11368 verify_jobstats "$cmd" "mdt"
11370 cmd="mknod $DIR/$tfile c 1 3"
11371 verify_jobstats "$cmd" "mdt"
11373 cmd="rm -f $DIR/$tfile"
11374 verify_jobstats "$cmd" "mdt"
11376 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11377 verify_jobstats "$cmd" "mdt"
11379 cmd="touch $DIR/$tfile"
11380 verify_jobstats "$cmd" "both"
11382 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11383 verify_jobstats "$cmd" "ost"
11385 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11386 verify_jobstats "$cmd" "ost"
11388 cmd="$TRUNCATE $DIR/$tfile 0"
11389 verify_jobstats "$cmd" "both"
11391 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11392 verify_jobstats "$cmd" "mdt"
11394 # Ensure that jobid are present in changelog (if supported by MDS)
11395 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11397 $LFS changelog $MDT0 | tail -9
11398 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11399 [ $jobids -eq 9 ] ||
11400 error "Wrong changelog jobid count $jobids != 9"
11404 jobstats_set $JOBENV
11406 $LFS changelog $MDT0 | tail -1
11407 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11408 [ $jobids -eq 0 ] ||
11409 error "Unexpected jobids when jobid_var=$JOBENV"
11413 rm -f $DIR/jobstats_test_rename
11415 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11417 run_test 205 "Verify job stats"
11419 # LU-1480, LU-1773 and LU-1657
11421 mkdir -p $DIR/$tdir
11422 $SETSTRIPE -c -1 $DIR/$tdir
11423 #define OBD_FAIL_LOV_INIT 0x1403
11424 $LCTL set_param fail_loc=0xa0001403
11425 $LCTL set_param fail_val=1
11426 touch $DIR/$tdir/$tfile || true
11428 run_test 206 "fail lov_init_raid0() doesn't lbug"
11431 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11432 local fsz=`stat -c %s $DIR/$tfile`
11433 cancel_lru_locks mdc
11435 # do not return layout in getattr intent
11436 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11437 $LCTL set_param fail_loc=0x170
11438 local sz=`stat -c %s $DIR/$tfile`
11440 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11444 run_test 207a "can refresh layout at glimpse"
11447 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11448 local cksum=`md5sum $DIR/$tfile`
11449 local fsz=`stat -c %s $DIR/$tfile`
11450 cancel_lru_locks mdc
11451 cancel_lru_locks osc
11453 # do not return layout in getattr intent
11454 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11455 $LCTL set_param fail_loc=0x171
11457 # it will refresh layout after the file is opened but before read issues
11458 echo checksum is "$cksum"
11459 echo "$cksum" |md5sum -c --quiet || error "file differs"
11463 run_test 207b "can refresh layout at open"
11466 # FIXME: in this test suite, only RD lease is used. This is okay
11467 # for now as only exclusive open is supported. After generic lease
11468 # is done, this test suite should be revised. - Jinshan
11470 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11471 { skip "Need MDS version at least 2.4.52"; return 0; }
11472 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11474 echo "==== test 1: verify get lease work"
11475 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11477 echo "==== test 2: verify lease can be broken by upcoming open"
11478 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11482 $MULTIOP $DIR/$tfile oO_RDONLY:c
11483 kill -USR1 $PID && wait $PID || error "break lease error"
11485 echo "==== test 3: verify lease can't be granted if an open already exists"
11486 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11490 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11491 kill -USR1 $PID && wait $PID || error "open file error"
11493 echo "==== test 4: lease can sustain over recovery"
11494 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11500 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11502 echo "==== test 5: lease broken can't be regained by replay"
11503 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11507 # open file to break lease and then recovery
11508 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11511 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11515 run_test 208 "Exclusive open"
11518 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11519 skip_env "must have disp_stripe" && return
11522 sync; sleep 5; sync;
11524 echo 3 > /proc/sys/vm/drop_caches
11525 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11527 # open/close 500 times
11528 for i in $(seq 500); do
11532 echo 3 > /proc/sys/vm/drop_caches
11533 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11535 echo "before: $req_before, after: $req_after"
11536 [ $((req_after - req_before)) -ge 300 ] &&
11537 error "open/close requests are not freed"
11540 run_test 209 "read-only open/close requests should be freed promptly"
11544 size=$((size % 8192 + 1))
11545 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11546 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11547 rm -f $DIR/f212 $DIR/f212.xyz
11549 run_test 212 "Sendfile test ============================================"
11552 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11553 cancel_lru_locks osc
11554 lctl set_param fail_loc=0x8000040f
11555 # generate a read lock
11556 cat $DIR/$tfile > /dev/null
11557 # write to the file, it will try to cancel the above read lock.
11558 cat /etc/hosts >> $DIR/$tfile
11560 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11562 test_214() { # for bug 20133
11563 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11564 for (( i=0; i < 340; i++ )) ; do
11565 touch $DIR/$tdir/d214c/a$i
11568 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11569 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11570 ls $DIR/d214c || error "ls $DIR/d214c failed"
11571 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11572 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11574 run_test 214 "hash-indexed directory test - bug 20133"
11576 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11577 create_lnet_proc_files() {
11578 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11579 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11581 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11582 rm -f "$TMP/lnet_$1.sys_tmp"
11585 # counterpart of create_lnet_proc_files
11586 remove_lnet_proc_files() {
11587 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11590 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11591 # 3rd arg as regexp for body
11592 check_lnet_proc_stats() {
11593 local l=$(cat "$TMP/lnet_$1" |wc -l)
11594 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11596 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11599 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11600 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11601 # optional and can be regexp for 2nd line (lnet.routes case)
11602 check_lnet_proc_entry() {
11603 local blp=2 # blp stands for 'position of 1st line of body'
11604 [ -z "$5" ] || blp=3 # lnet.routes case
11606 local l=$(cat "$TMP/lnet_$1" |wc -l)
11607 # subtracting one from $blp because the body can be empty
11608 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11610 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11611 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11613 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11614 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11616 # bail out if any unexpected line happened
11617 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11618 [ "$?" != 0 ] || error "$2 misformatted"
11621 test_215() { # for bugs 18102, 21079, 21517
11622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11623 local N='(0|[1-9][0-9]*)' # non-negative numeric
11624 local P='[1-9][0-9]*' # positive numeric
11625 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11626 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11627 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11628 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11630 local L1 # regexp for 1st line
11631 local L2 # regexp for 2nd line (optional)
11632 local BR # regexp for the rest (body)
11634 # lnet.stats should look as 11 space-separated non-negative numerics
11635 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11636 create_lnet_proc_files "stats"
11637 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11638 remove_lnet_proc_files "stats"
11640 # lnet.routes should look like this:
11641 # Routing disabled/enabled
11642 # net hops priority state router
11643 # where net is a string like tcp0, hops > 0, priority >= 0,
11644 # state is up/down,
11645 # router is a string like 192.168.1.1@tcp2
11646 L1="^Routing (disabled|enabled)$"
11647 L2="^net +hops +priority +state +router$"
11648 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11649 create_lnet_proc_files "routes"
11650 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11651 remove_lnet_proc_files "routes"
11653 # lnet.routers should look like this:
11654 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11655 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11656 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11657 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11658 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11659 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11660 create_lnet_proc_files "routers"
11661 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11662 remove_lnet_proc_files "routers"
11664 # lnet.peers should look like this:
11665 # nid refs state last max rtr min tx min queue
11666 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11667 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11668 # numeric (0 or >0 or <0), queue >= 0.
11669 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11670 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11671 create_lnet_proc_files "peers"
11672 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11673 remove_lnet_proc_files "peers"
11675 # lnet.buffers should look like this:
11676 # pages count credits min
11677 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11678 L1="^pages +count +credits +min$"
11679 BR="^ +$N +$N +$I +$I$"
11680 create_lnet_proc_files "buffers"
11681 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11682 remove_lnet_proc_files "buffers"
11684 # lnet.nis should look like this:
11685 # nid status alive refs peer rtr max tx min
11686 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11687 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11688 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11689 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11690 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11691 create_lnet_proc_files "nis"
11692 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11693 remove_lnet_proc_files "nis"
11695 # can we successfully write to lnet.stats?
11696 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11697 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11699 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11701 test_216() { # bug 20317
11702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11703 remote_ost_nodsh && skip "remote OST with nodsh" && return
11706 local facets=$(get_facets OST)
11707 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11709 save_lustre_params client "osc.*.contention_seconds" > $p
11710 save_lustre_params $facets \
11711 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11712 save_lustre_params $facets \
11713 "ldlm.namespaces.filter-*.contended_locks" >> $p
11714 save_lustre_params $facets \
11715 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11718 # agressive lockless i/o settings
11719 for node in $(osts_nodes); do
11720 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'
11722 lctl set_param -n osc.*.contention_seconds 60
11724 $DIRECTIO write $DIR/$tfile 0 10 4096
11725 $CHECKSTAT -s 40960 $DIR/$tfile
11727 # disable lockless i/o
11728 for node in $(osts_nodes); do
11729 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'
11731 lctl set_param -n osc.*.contention_seconds 0
11734 dd if=/dev/zero of=$DIR/$tfile count=0
11735 $CHECKSTAT -s 0 $DIR/$tfile
11737 restore_lustre_params <$p
11741 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11743 test_217() { # bug 22430
11744 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11748 for node in $(nodes_list); do
11749 nid=$(host_nids_address $node $NETTYPE)
11750 if [[ $nid = *-* ]] ; then
11751 echo "lctl ping $nid@$NETTYPE"
11752 lctl ping $nid@$NETTYPE
11754 echo "skipping $node (no hyphen detected)"
11758 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11761 # do directio so as not to populate the page cache
11762 log "creating a 10 Mb file"
11763 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11764 log "starting reads"
11765 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11766 log "truncating the file"
11767 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11769 kill %+ || true # reads might have finished
11770 echo "wait until dd is finished"
11772 log "removing the temporary file"
11773 rm -rf $DIR/$tfile || error "tmp file removal failed"
11775 run_test 218 "parallel read and truncate should not deadlock ======================="
11778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11779 # write one partial page
11780 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11781 # set no grant so vvp_io_commit_write will do sync write
11782 $LCTL set_param fail_loc=0x411
11783 # write a full page at the end of file
11784 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11786 $LCTL set_param fail_loc=0
11787 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11788 $LCTL set_param fail_loc=0x411
11789 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11792 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11793 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11795 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11797 test_220() { #LU-325
11798 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11799 remote_ost_nodsh && skip "remote OST with nodsh" && return
11802 test_mkdir -p $DIR/$tdir
11803 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11804 awk '{print $2}' | sed -e 's/_UUID$//')
11807 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11808 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11809 osc.$mdtosc_proc1.prealloc_last_id)
11810 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11811 osc.$mdtosc_proc1.prealloc_next_id)
11815 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11816 #define OBD_FAIL_OST_ENOINO 0x229
11817 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11818 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11819 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11821 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11823 MDSOBJS=$((last_id - next_id))
11824 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11826 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11827 echo "OST still has $count kbytes free"
11829 echo "create $MDSOBJS files @next_id..."
11830 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11832 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11833 osc.$mdtosc_proc1.prealloc_last_id)
11834 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11835 osc.$mdtosc_proc1.prealloc_next_id)
11837 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11842 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11843 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11845 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11846 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11847 echo "unlink $MDSOBJS files @$next_id..."
11848 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11850 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11854 dd if=`which date` of=$MOUNT/date oflag=sync
11855 chmod +x $MOUNT/date
11857 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11858 $LCTL set_param fail_loc=0x80001401
11860 $MOUNT/date > /dev/null
11863 run_test 221 "make sure fault and truncate race to not cause OOM"
11866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11868 test_mkdir -p $DIR/$tdir
11869 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11870 createmany -o $DIR/$tdir/$tfile 10
11871 cancel_lru_locks mdc
11872 cancel_lru_locks osc
11873 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11874 $LCTL set_param fail_loc=0x31a
11875 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11876 $LCTL set_param fail_loc=0
11879 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11884 test_mkdir -p $DIR/$tdir
11885 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11886 createmany -o $DIR/$tdir/$tfile 10
11887 cancel_lru_locks mdc
11888 cancel_lru_locks osc
11889 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11890 $LCTL set_param fail_loc=0x31a
11891 rm -r $DIR/$tdir || "AGL for rmdir failed"
11892 $LCTL set_param fail_loc=0
11894 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11899 test_mkdir -p $DIR/$tdir
11900 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11901 createmany -o $DIR/$tdir/$tfile 10
11902 cancel_lru_locks mdc
11903 cancel_lru_locks osc
11904 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11905 $LCTL set_param fail_loc=0x31b
11906 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11907 $LCTL set_param fail_loc=0
11910 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11912 test_224a() { # LU-1039, MRP-303
11913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11914 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11915 $LCTL set_param fail_loc=0x508
11916 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11917 $LCTL set_param fail_loc=0
11920 run_test 224a "Don't panic on bulk IO failure"
11922 test_224b() { # LU-1039, MRP-303
11923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11924 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11925 cancel_lru_locks osc
11926 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11927 $LCTL set_param fail_loc=0x515
11928 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11929 $LCTL set_param fail_loc=0
11932 run_test 224b "Don't panic on bulk IO failure"
11934 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11937 if [ -z ${MDSSURVEY} ]; then
11938 skip_env "mds-survey not found" && return
11941 [ $MDSCOUNT -ge 2 ] &&
11942 skip "skipping now for more than one MDT" && return
11944 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11945 { skip "Need MDS version at least 2.2.51"; return; }
11947 local mds=$(facet_host $SINGLEMDS)
11948 local target=$(do_nodes $mds 'lctl dl' | \
11949 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11951 local cmd1="file_count=1000 thrhi=4"
11952 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11953 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11954 local cmd="$cmd1 $cmd2 $cmd3"
11956 rm -f ${TMP}/mds_survey*
11958 eval $cmd || error "mds-survey with zero-stripe failed"
11959 cat ${TMP}/mds_survey*
11960 rm -f ${TMP}/mds_survey*
11962 run_test 225a "Metadata survey sanity with zero-stripe"
11965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11967 if [ -z ${MDSSURVEY} ]; then
11968 skip_env "mds-survey not found" && return
11970 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11971 { skip "Need MDS version at least 2.2.51"; return; }
11973 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11974 skip_env "Need to mount OST to test" && return
11977 [ $MDSCOUNT -ge 2 ] &&
11978 skip "skipping now for more than one MDT" && return
11979 local mds=$(facet_host $SINGLEMDS)
11980 local target=$(do_nodes $mds 'lctl dl' | \
11981 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11983 local cmd1="file_count=1000 thrhi=4"
11984 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11985 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11986 local cmd="$cmd1 $cmd2 $cmd3"
11988 rm -f ${TMP}/mds_survey*
11990 eval $cmd || error "mds-survey with stripe_count failed"
11991 cat ${TMP}/mds_survey*
11992 rm -f ${TMP}/mds_survey*
11994 run_test 225b "Metadata survey sanity with stripe_count = 1"
11996 mcreate_path2fid () {
12002 local path=$DIR/$tdir/$name
12007 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12008 error "cannot create $desc"
12010 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12012 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12014 fid_path=$($LFS fid2path $MOUNT $fid)
12016 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12018 [ "$path" == "$fid_path" ] ||
12019 error "fid2path returned $fid_path, expected $path"
12021 echo "pass with $path and $fid"
12026 mkdir -p $DIR/$tdir
12028 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12029 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12030 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12031 mcreate_path2fid 0040666 0 0 dir "directory"
12032 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12033 mcreate_path2fid 0100666 0 0 file "regular file"
12034 mcreate_path2fid 0120666 0 0 link "symbolic link"
12035 mcreate_path2fid 0140666 0 0 sock "socket"
12037 run_test 226a "call path2fid and fid2path on files of all type"
12040 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12044 mkdir -p $DIR/$tdir
12045 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12046 error "create remote directory failed"
12047 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12048 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12049 "character special file (null)"
12050 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12051 "character special file (no device)"
12052 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12053 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12054 "block special file (loop)"
12055 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12056 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12057 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12059 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12061 # LU-1299 Executing or running ldd on a truncated executable does not
12062 # cause an out-of-memory condition.
12064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12065 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12066 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12067 chmod +x $MOUNT/date
12069 $MOUNT/date > /dev/null
12070 ldd $MOUNT/date > /dev/null
12073 run_test 227 "running truncated executable does not cause OOM"
12075 # LU-1512 try to reuse idle OI blocks
12077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12078 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12079 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12080 skip "non-ldiskfs backend" && return
12082 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12083 local myDIR=$DIR/$tdir
12086 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12087 $LCTL set_param fail_loc=0x80001002
12088 createmany -o $myDIR/t- 10000
12089 $LCTL set_param fail_loc=0
12090 # The guard is current the largest FID holder
12092 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12094 local IDX=$(($SEQ % 64))
12096 do_facet $SINGLEMDS sync
12097 # Make sure journal flushed.
12099 local blk1=$(do_facet $SINGLEMDS \
12100 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12101 grep Blockcount | awk '{print $4}')
12103 # Remove old files, some OI blocks will become idle.
12104 unlinkmany $myDIR/t- 10000
12105 # Create new files, idle OI blocks should be reused.
12106 createmany -o $myDIR/t- 2000
12107 do_facet $SINGLEMDS sync
12108 # Make sure journal flushed.
12110 local blk2=$(do_facet $SINGLEMDS \
12111 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12112 grep Blockcount | awk '{print $4}')
12114 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12116 run_test 228a "try to reuse idle OI blocks"
12119 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12120 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12121 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12122 skip "non-ldiskfs backend" && return
12124 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12125 local myDIR=$DIR/$tdir
12128 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12129 $LCTL set_param fail_loc=0x80001002
12130 createmany -o $myDIR/t- 10000
12131 $LCTL set_param fail_loc=0
12132 # The guard is current the largest FID holder
12134 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12136 local IDX=$(($SEQ % 64))
12138 do_facet $SINGLEMDS sync
12139 # Make sure journal flushed.
12141 local blk1=$(do_facet $SINGLEMDS \
12142 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12143 grep Blockcount | awk '{print $4}')
12145 # Remove old files, some OI blocks will become idle.
12146 unlinkmany $myDIR/t- 10000
12149 stop $SINGLEMDS || error "Fail to stop MDT."
12151 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12153 df $MOUNT || error "Fail to df."
12154 # Create new files, idle OI blocks should be reused.
12155 createmany -o $myDIR/t- 2000
12156 do_facet $SINGLEMDS sync
12157 # Make sure journal flushed.
12159 local blk2=$(do_facet $SINGLEMDS \
12160 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12161 grep Blockcount | awk '{print $4}')
12163 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12165 run_test 228b "idle OI blocks can be reused after MDT restart"
12169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12170 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12171 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12172 skip "non-ldiskfs backend" && return
12174 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12175 local myDIR=$DIR/$tdir
12178 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12179 $LCTL set_param fail_loc=0x80001002
12180 # 20000 files can guarantee there are index nodes in the OI file
12181 createmany -o $myDIR/t- 20000
12182 $LCTL set_param fail_loc=0
12183 # The guard is current the largest FID holder
12185 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12187 local IDX=$(($SEQ % 64))
12189 do_facet $SINGLEMDS sync
12190 # Make sure journal flushed.
12192 local blk1=$(do_facet $SINGLEMDS \
12193 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12194 grep Blockcount | awk '{print $4}')
12196 # Remove old files, some OI blocks will become idle.
12197 unlinkmany $myDIR/t- 20000
12199 # The OI file should become empty now
12201 # Create new files, idle OI blocks should be reused.
12202 createmany -o $myDIR/t- 2000
12203 do_facet $SINGLEMDS sync
12204 # Make sure journal flushed.
12206 local blk2=$(do_facet $SINGLEMDS \
12207 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12208 grep Blockcount | awk '{print $4}')
12210 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12212 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12214 test_229() { # LU-2482, LU-3448
12215 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12216 skip "No HSM support on MDS of $(get_lustre_version)," \
12217 "need 2.4.53 at least" && return
12218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12219 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12223 # Create a file with a released layout and stripe count 2.
12224 $MULTIOP $DIR/$tfile H2c ||
12225 error "failed to create file with released layout"
12227 $GETSTRIPE -v $DIR/$tfile
12229 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12230 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12232 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12233 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12234 stat $DIR/$tfile || error "failed to stat released file"
12236 chown $RUNAS_ID $DIR/$tfile ||
12237 error "chown $RUNAS_ID $DIR/$tfile failed"
12239 chgrp $RUNAS_ID $DIR/$tfile ||
12240 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12242 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12243 rm $DIR/$tfile || error "failed to remove released file"
12245 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12249 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12252 mkdir -p $DIR/$tdir/test_230_local
12253 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12254 [ $mdt_idx -ne 0 ] &&
12255 error "create local directory on wrong MDT $mdt_idx"
12257 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12258 error "create remote directory failed"
12259 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12260 [ $mdt_idx -ne $MDTIDX ] &&
12261 error "create remote directory on wrong MDT $mdt_idx"
12263 createmany -o $DIR/$tdir/test_230/t- 10 ||
12264 error "create files on remote directory failed"
12265 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12266 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12267 rm -r $DIR/$tdir || error "unlink remote directory failed"
12269 run_test 230a "Create remote directory and files under the remote directory"
12272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12273 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12280 local migrate_dir=$DIR/$tdir/migrate_dir
12281 local other_dir=$DIR/$tdir/other_dir
12283 mkdir -p $migrate_dir
12284 mkdir -p $other_dir
12285 for ((i=0; i<10; i++)); do
12286 mkdir -p $migrate_dir/dir_${i}
12287 createmany -o $migrate_dir/dir_${i}/f 10 ||
12288 error "create files under remote dir failed $i"
12291 cp /etc/passwd $migrate_dir/$tfile
12292 cp /etc/passwd $other_dir/$tfile
12293 chattr +SAD $migrate_dir
12294 chattr +SAD $migrate_dir/$tfile
12296 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12297 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12298 local old_dir_mode=$(stat -c%f $migrate_dir)
12299 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12301 mkdir -p $migrate_dir/dir_default_stripe2
12302 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12303 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12305 mkdir -p $other_dir
12306 ln $migrate_dir/$tfile $other_dir/luna
12307 ln $migrate_dir/$tfile $migrate_dir/sofia
12308 ln $other_dir/$tfile $migrate_dir/david
12309 ln -s $migrate_dir/$tfile $other_dir/zachary
12310 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12311 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12313 $LFS mv -v -M $MDTIDX $migrate_dir ||
12314 error "migrate remote dir error"
12316 echo "migratate to MDT1, then checking.."
12317 for ((i=0; i<10; i++)); do
12318 for file in $(find $migrate_dir/dir_${i}); do
12319 mdt_index=$($LFS getstripe -M $file)
12320 [ $mdt_index == $MDTIDX ] ||
12321 error "$file is not on MDT${MDTIDX}"
12325 # the multiple link file should still in MDT0
12326 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12327 [ $mdt_index == 0 ] ||
12328 error "$file is not on MDT${MDTIDX}"
12330 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12331 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12332 error " expect $old_dir_flag get $new_dir_flag"
12334 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12335 [ "$old_file_flag" = "$new_file_flag" ] ||
12336 error " expect $old_file_flag get $new_file_flag"
12338 local new_dir_mode=$(stat -c%f $migrate_dir)
12339 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12340 error "expect mode $old_dir_mode get $new_dir_mode"
12342 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12343 [ "$old_file_mode" = "$new_file_mode" ] ||
12344 error "expect mode $old_file_mode get $new_file_mode"
12346 diff /etc/passwd $migrate_dir/$tfile ||
12347 error "$tfile different after migration"
12349 diff /etc/passwd $other_dir/luna ||
12350 error "luna different after migration"
12352 diff /etc/passwd $migrate_dir/sofia ||
12353 error "sofia different after migration"
12355 diff /etc/passwd $migrate_dir/david ||
12356 error "david different after migration"
12358 diff /etc/passwd $other_dir/zachary ||
12359 error "zachary different after migration"
12361 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12362 error "${tfile}_ln different after migration"
12364 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12365 error "${tfile}_ln_other different after migration"
12367 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12368 [ $stripe_count = 2 ] ||
12369 error "dir strpe_count $d != 2 after migration."
12371 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12372 [ $stripe_count = 2 ] ||
12373 error "file strpe_count $d != 2 after migration."
12375 #migrate back to MDT0
12377 $LFS mv -v -M $MDTIDX $migrate_dir ||
12378 error "migrate remote dir error"
12380 echo "migrate back to MDT0, checking.."
12381 for file in $(find $migrate_dir); do
12382 mdt_index=$($LFS getstripe -M $file)
12383 [ $mdt_index == $MDTIDX ] ||
12384 error "$file is not on MDT${MDTIDX}"
12387 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12388 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12389 error " expect $old_dir_flag get $new_dir_flag"
12391 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12392 [ "$old_file_flag" = "$new_file_flag" ] ||
12393 error " expect $old_file_flag get $new_file_flag"
12395 local new_dir_mode=$(stat -c%f $migrate_dir)
12396 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12397 error "expect mode $old_dir_mode get $new_dir_mode"
12399 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12400 [ "$old_file_mode" = "$new_file_mode" ] ||
12401 error "expect mode $old_file_mode get $new_file_mode"
12403 diff /etc/passwd ${migrate_dir}/$tfile ||
12404 error "$tfile different after migration"
12406 diff /etc/passwd ${other_dir}/luna ||
12407 error "luna different after migration"
12409 diff /etc/passwd ${migrate_dir}/sofia ||
12410 error "sofia different after migration"
12412 diff /etc/passwd ${other_dir}/zachary ||
12413 error "zachary different after migration"
12415 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12416 error "${tfile}_ln different after migration"
12418 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12419 error "${tfile}_ln_other different after migration"
12421 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12422 [ $stripe_count = 2 ] ||
12423 error "dir strpe_count $d != 2 after migration."
12425 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12426 [ $stripe_count = 2 ] ||
12427 error "file strpe_count $d != 2 after migration."
12429 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12431 run_test 230b "migrate directory"
12434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12435 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12440 #If migrating directory fails in the middle, all entries of
12441 #the directory is still accessiable.
12442 mkdir -p $DIR/$tdir
12444 createmany -o $DIR/$tdir/f 10 ||
12445 error "create files under ${tdir} failed"
12447 #failed after migrating 5 entries
12448 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12449 do_facet mds1 lctl set_param fail_loc=0x20001801
12450 do_facet mds1 lctl set_param fail_val=5
12451 local t=`ls $DIR/$tdir | wc -l`
12452 $LFS mv -M $MDTIDX $DIR/$tdir &&
12453 error "migrate should failed after 5 entries"
12454 local u=`ls $DIR/$tdir | wc -l`
12455 [ "$u" == "$t" ] || error "$u != $t during migration"
12457 for file in $(find $DIR/$tdir); do
12458 stat $file || error "stat $file failed"
12461 do_facet mds1 lctl set_param fail_loc=0
12462 do_facet mds1 lctl set_param fail_val=0
12464 $LFS mv -M $MDTIDX $DIR/$tdir ||
12465 error "migrate open files should failed with open files"
12467 echo "Finish migration, then checking.."
12468 for file in $(find $DIR/$tdir); do
12469 mdt_index=$($LFS getstripe -M $file)
12470 [ $mdt_index == $MDTIDX ] ||
12471 error "$file is not on MDT${MDTIDX}"
12474 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12476 run_test 230c "check directory accessiblity if migration is failed"
12479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12480 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12486 mkdir -p $DIR/$tdir
12488 for ((i=0; i<100; i++)); do
12489 mkdir -p $DIR/$tdir/dir_${i}
12490 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12491 error "create files under remote dir failed $i"
12494 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12496 echo "Finish migration, then checking.."
12497 for file in $(find $DIR/$tdir); do
12498 mdt_index=$($LFS getstripe -M $file)
12499 [ $mdt_index == $MDTIDX ] ||
12500 error "$file is not on MDT${MDTIDX}"
12503 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12505 run_test 230d "check migrate big directory"
12509 # For simplicity this test assumes that max_pages_per_rpc
12510 # is the same across all OSCs
12511 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12512 local bulk_size=$((max_pages * 4096))
12514 mkdir -p $DIR/$tdir
12516 # clear the OSC stats
12517 $LCTL set_param osc.*.stats=0 &>/dev/null
12519 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12520 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12521 oflag=direct &>/dev/null || error "dd failed"
12523 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12524 if [ x$nrpcs != "x1" ]; then
12525 error "found $nrpc ost_write RPCs, not 1 as expected"
12528 # Drop the OSC cache, otherwise we will read from it
12529 cancel_lru_locks osc
12531 # clear the OSC stats
12532 $LCTL set_param osc.*.stats=0 &>/dev/null
12534 # Client reads $bulk_size.
12535 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12536 iflag=direct &>/dev/null || error "dd failed"
12538 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12539 if [ x$nrpcs != "x1" ]; then
12540 error "found $nrpc ost_read RPCs, not 1 as expected"
12543 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12546 mkdir -p $DIR/$tdir
12548 for i in {0..1023}; do
12549 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12550 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12551 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12555 run_test 231b "must not assert on fully utilized OST request buffer"
12558 mkdir -p $DIR/$tdir
12559 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12560 $LCTL set_param fail_loc=0x31c
12562 # ignore dd failure
12563 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12565 $LCTL set_param fail_loc=0
12566 umount_client $MOUNT || error "umount failed"
12567 mount_client $MOUNT || error "mount failed"
12569 run_test 232 "failed lock should not block umount"
12572 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12573 { skip "Need MDS version at least 2.3.64"; return; }
12575 local fid=$($LFS path2fid $MOUNT)
12576 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12577 error "cannot access $MOUNT using its FID '$fid'"
12579 run_test 233a "checking that OBF of the FS root succeeds"
12582 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12583 { skip "Need MDS version at least 2.5.90"; return; }
12585 local fid=$($LFS path2fid $MOUNT/.lustre)
12586 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12587 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12589 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12590 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12591 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12593 run_test 233b "checking that OBF of the FS .lustre succeeds"
12596 local p="$TMP/sanityN-$TESTNAME.parameters"
12597 save_lustre_params client "llite.*.xattr_cache" > $p
12598 lctl set_param llite.*.xattr_cache 1 ||
12599 { skip "xattr cache is not supported"; return 0; }
12601 mkdir -p $DIR/$tdir || error "mkdir failed"
12602 touch $DIR/$tdir/$tfile || error "touch failed"
12603 # OBD_FAIL_LLITE_XATTR_ENOMEM
12604 $LCTL set_param fail_loc=0x1405
12605 # output of the form: attr 2 4 44 3 fc13 x86_64
12606 V=($(IFS=".-" rpm -q attr))
12607 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12608 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12609 # attr pre-2.4.44-7 had a bug with rc
12610 # LU-3703 - SLES 11 and FC13 clients have older attr
12611 getfattr -n user.attr $DIR/$tdir/$tfile &&
12612 error "getfattr should have failed with ENOMEM"
12614 skip "LU-3703: attr version $(getfattr --version) too old"
12616 $LCTL set_param fail_loc=0x0
12619 restore_lustre_params < $p
12622 run_test 234 "xattr cache should not crash on ENOMEM"
12625 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12626 skip "Need MDS version at least 2.4.52" && return
12627 flock_deadlock $DIR/$tfile
12632 124) error "process hangs on a deadlock"
12634 *) error "error executing flock_deadlock $DIR/$tfile"
12638 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12642 check_swap_layouts_support && return 0
12643 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12645 local ref1=/etc/passwd
12646 local ref2=/etc/group
12647 local file1=$DIR/$tdir/f1
12648 local file2=$DIR/$tdir/f2
12650 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12651 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12652 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12653 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12654 local fd=$(free_fd)
12655 local cmd="exec $fd<>$file2"
12658 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12659 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12662 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12667 run_test 236 "Layout swap on open unlinked file"
12669 # test to verify file handle related system calls
12670 # (name_to_handle_at/open_by_handle_at)
12671 # The new system calls are supported in glibc >= 2.14.
12674 echo "Test file_handle syscalls" > $DIR/$tfile ||
12675 error "write failed"
12676 check_fhandle_syscalls $DIR/$tfile ||
12677 error "check_fhandle_syscalls failed"
12679 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12681 # LU-4659 linkea consistency
12683 local server_version=$(lustre_version_code $SINGLEMDS)
12685 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12686 [[ $server_version -gt $(version_code 2.5.1) &&
12687 $server_version -lt $(version_code 2.5.50) ]] ||
12688 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12691 ln $DIR/$tfile $DIR/$tfile.lnk
12692 touch $DIR/$tfile.new
12693 mv $DIR/$tfile.new $DIR/$tfile
12694 local fid1=$(lfs path2fid $DIR/$tfile)
12695 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12696 local path1=$(lfs fid2path $FSNAME $fid1)
12697 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12698 local path2=$(lfs fid2path $FSNAME $fid2)
12699 [ $tfile.lnk == $path2 ] ||
12700 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12703 run_test 238 "Verify linkea consistency"
12706 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
12707 skip "Need MDS version at least 2.5.60" && return
12708 local list=$(comma_list $(mdts_nodes))
12710 mkdir -p $DIR/$tdir
12711 createmany -o $DIR/$tdir/f- 5000
12712 unlinkmany $DIR/$tdir/f- 5000
12713 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12714 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12715 osc.*MDT*.sync_in_flight" | calc_sum)
12716 [ "$changes" -eq 0 ] || error "$changes not synced"
12718 run_test 239 "osp_sync test"
12721 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12723 mkdir -p $DIR/$tdir
12725 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12726 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12727 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12728 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12730 umount_client $MOUNT || error "umount failed"
12731 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12732 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12733 mount_client $MOUNT || error "failed to mount client"
12735 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12736 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12738 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12741 for LOOP in $(seq $1); do
12742 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12743 cancel_lru_locks osc
12748 for LOOP in $(seq $1); do
12749 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12750 iflag=direct 2>/dev/null
12755 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12757 cancel_lru_locks osc
12758 test_241_bio 1000 &
12763 run_test 241 "bio vs dio"
12765 cleanup_test_300() {
12769 test_striped_dir() {
12774 mkdir -p $DIR/$tdir
12776 SAVE_UMASK=$(umask)
12777 trap cleanup_test_300 RETURN EXIT
12779 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12780 $DIR/$tdir/striped_dir ||
12781 error "set striped dir error"
12783 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12784 [ "$mode" = "755" ] || error "expect 755 got $mode"
12786 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12787 if [ "$stripe_count" != "2" ]; then
12788 error "stripe_count is $stripe_count, expect 2"
12791 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12792 if [ "$stripe_index" != "$mdt_index" ]; then
12793 error "stripe_index is $stripe_index, expect $mdt_index"
12796 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12797 error "nlink error after create striped dir"
12799 mkdir $DIR/$tdir/striped_dir/a
12800 mkdir $DIR/$tdir/striped_dir/b
12802 stat $DIR/$tdir/striped_dir/a ||
12803 error "create dir under striped dir failed"
12804 stat $DIR/$tdir/striped_dir/b ||
12805 error "create dir under striped dir failed"
12807 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12808 error "nlink error after mkdir"
12810 rmdir $DIR/$tdir/striped_dir/a
12811 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12812 error "nlink error after rmdir"
12814 rmdir $DIR/$tdir/striped_dir/b
12815 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12816 error "nlink error after rmdir"
12818 rmdir $DIR/$tdir/striped_dir ||
12819 error "rmdir striped dir error"
12827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12828 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12830 test_striped_dir 0 || error "failed on striped dir on MDT0"
12831 test_striped_dir 1 || error "failed on striped dir on MDT0"
12833 run_test 300a "basic striped dir sanity test"
12836 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12837 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12843 test_mkdir $DIR/$tdir || error "mkdir fail"
12844 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12845 error "set striped dir error"
12846 for ((i=0; i<10; i++)); do
12847 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12849 touch $DIR/$tdir/striped_dir/file_$i ||
12850 error "touch error $i"
12851 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12852 [ $mtime1 -eq $mtime2 ] &&
12853 error "mtime not change after create"
12855 rm -f $DIR/$tdir/striped_dir/file_$i ||
12856 error "unlink error $i"
12857 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12858 [ $mtime2 -eq $mtime3 ] &&
12859 error "mtime did not change after unlink"
12863 run_test 300b "check ctime/mtime for striped dir"
12866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12867 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12870 mkdir -p $DIR/$tdir
12871 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12872 error "set striped dir error"
12874 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12875 error "chown striped dir failed"
12877 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12878 error "create 5k files failed"
12880 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12882 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12886 run_test 300c "chown && check ls under striped directory"
12889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12890 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12894 mkdir -p $DIR/$tdir
12895 $SETSTRIPE -c 2 $DIR/$tdir
12897 #local striped directory
12898 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12899 error "set striped dir error"
12900 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12901 error "create 10 files failed"
12903 #remote striped directory
12904 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12905 error "set striped dir error"
12906 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12907 error "create 10 files failed"
12909 for file in $(find $DIR/$tdir); do
12910 stripe_count=$($GETSTRIPE -c $file)
12911 [ $stripe_count -eq 2 ] ||
12912 error "wrong stripe $stripe_count for $file"
12917 run_test 300d "check default stripe under striped directory"
12920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12921 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12925 mkdir -p $DIR/$tdir
12927 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12928 error "set striped dir error"
12930 touch $DIR/$tdir/striped_dir/a
12931 touch $DIR/$tdir/striped_dir/b
12932 touch $DIR/$tdir/striped_dir/c
12934 mkdir $DIR/$tdir/striped_dir/dir_a
12935 mkdir $DIR/$tdir/striped_dir/dir_b
12936 mkdir $DIR/$tdir/striped_dir/dir_c
12938 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12939 error "set striped dir under striped dir error"
12941 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12942 error "set striped dir under striped dir error"
12944 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12945 error "set striped dir under striped dir error"
12947 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12948 error "rename file under striped dir should fail"
12950 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12951 error "rename dir under striped dir should fail"
12953 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12954 error "rename dir under different stripes should fail"
12956 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12957 error "rename file under striped dir should succeed"
12959 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12960 error "rename dir under striped dir should succeed"
12964 run_test 300e "check rename under striped directory"
12967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12968 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12973 mkdir -p $DIR/$tdir
12975 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12976 error "set striped dir error"
12978 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12979 error "set striped dir error"
12981 touch $DIR/$tdir/striped_dir/a
12982 mkdir $DIR/$tdir/striped_dir/dir_a
12983 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12984 error "create striped dir under striped dir fails"
12986 touch $DIR/$tdir/striped_dir1/b
12987 mkdir $DIR/$tdir/striped_dir1/dir_b
12988 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12989 error "create striped dir under striped dir fails"
12991 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12992 error "rename file under different striped dir should fail"
12994 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12995 error "rename dir under different striped dir should fail"
12997 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12998 error "rename striped dir under diff striped dir should fail"
13000 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13001 error "rename file under diff striped dirs fails"
13003 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
13004 error "rename dir under diff striped dirs fails"
13008 run_test 300f "check rename cross striped directory"
13011 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13016 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13017 $DIR/$tdir/striped_dir ||
13018 error "set striped dir error"
13020 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13021 error "set default stripe on striped dir error"
13023 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
13024 [ $stripe_count -eq $MDSCOUNT ] ||
13025 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
13027 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13029 for dir in $(find $DIR/$tdir/striped_dir/*); do
13030 stripe_count=$($LFS getdirstripe -c $dir)
13031 [ $stripe_count -eq $MDSCOUNT ] ||
13032 error "expect $MDSCOUNT get $stripe_count for $dir"
13035 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
13036 #change default stripe count to 2
13037 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
13038 error "set default stripe on striped dir error"
13040 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13042 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
13044 #change default stripe count to 1
13045 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
13046 error "set default stripe on striped dir error"
13048 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13049 for dir in $(find $DIR/$tdir/striped_dir/*); do
13050 stripe_count=$($LFS getdirstripe -c $dir)
13051 [ $stripe_count -eq 1 ] ||
13052 error "expect 1 get $stripe_count for $dir"
13054 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
13056 run_test 300g "check default striped directory for striped directory"
13059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13060 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13066 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13067 error "set striped dir error"
13069 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13070 error "create files under striped dir failed"
13072 # unfortunately, we need to umount to clear dir layout cache for now
13073 # once we fully implement dir layout, we can drop this
13074 umount_client $MOUNT || error "umount failed"
13075 mount_client $MOUNT || error "mount failed"
13077 #set the stripe to be unknown hash type
13078 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13079 $LCTL set_param fail_loc=0x1901
13080 for ((i = 0; i < 10; i++)); do
13081 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13082 error "stat f-$i failed"
13083 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13086 touch $DIR/$tdir/striped_dir/f0 &&
13087 error "create under striped dir with unknown hash should fail"
13089 $LCTL set_param fail_loc=0
13091 umount_client $MOUNT || error "umount failed"
13092 mount_client $MOUNT || error "mount failed"
13096 run_test 300h "client handle unknown hash type striped directory"
13098 test_400a() { # LU-1606, was conf-sanity test_74
13099 local extra_flags=''
13100 local out=$TMP/$tfile
13101 local prefix=/usr/include/lustre
13104 if ! which $CC > /dev/null 2>&1; then
13105 skip_env "$CC is not installed"
13109 if ! [[ -d $prefix ]]; then
13110 # Assume we're running in tree and fixup the include path.
13111 extra_flags+=" -I$LUSTRE/../libcfs/include"
13112 extra_flags+=" -I$LUSTRE/include"
13113 extra_flags+=" -L$LUSTRE/utils"
13116 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13117 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13118 error "client api broken"
13121 run_test 400a "Lustre client api program can compile and link"
13123 test_400b() { # LU-1606, LU-5011
13125 local out=$TMP/$tfile
13126 local prefix=/usr/include/lustre
13128 # We use a hard coded prefix so that this test will not fail
13129 # when run in tree. There are headers in lustre/include/lustre/
13130 # that are not packaged (like lustre_idl.h) and have more
13131 # complicated include dependencies (like config.h and lnet/types.h).
13132 # Since this test about correct packaging we just skip them when
13133 # they don't exist (see below) rather than try to fixup cppflags.
13135 if ! which $CC > /dev/null 2>&1; then
13136 skip_env "$CC is not installed"
13140 for header in $prefix/*.h; do
13141 if ! [[ -f "$header" ]]; then
13145 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13146 continue # liblustreapi.h is deprecated.
13149 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13150 error "cannot compile '$header'"
13153 run_test 400b "packaged headers can be compiled"
13156 # tests that do cleanup/setup should be run at the end
13160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13162 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13163 $LCTL set_param fail_loc=0x903
13165 cancel_lru_locks MGC
13167 FAIL_ON_ERROR=true cleanup
13168 FAIL_ON_ERROR=true setup
13170 run_test 900 "umount should not race with any mgc requeue thread"
13173 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13174 check_and_cleanup_lustre
13175 if [ "$I_MOUNTED" != "yes" ]; then
13176 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true