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"
21 if [ -r /etc/SuSE-release ]
23 local vers=`grep VERSION /etc/SuSE-release | awk '{print $3}'`
32 if is_sles11; then # LU-4351
33 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 54c"
36 SRCDIR=$(cd $(dirname $0); echo $PWD)
37 export PATH=$PATH:/sbin
42 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
43 CREATETEST=${CREATETEST:-createtest}
45 LFIND=${LFIND:-"$LFS find"}
46 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
48 OPENFILE=${OPENFILE:-openfile}
49 OPENUNLINK=${OPENUNLINK:-openunlink}
50 export MULTIOP=${MULTIOP:-multiop}
51 READS=${READS:-"reads"}
52 MUNLINK=${MUNLINK:-munlink}
53 SOCKETSERVER=${SOCKETSERVER:-socketserver}
54 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
55 MEMHOG=${MEMHOG:-memhog}
56 DIRECTIO=${DIRECTIO:-directio}
57 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
58 UMOUNT=${UMOUNT:-"umount -d"}
60 CHECK_GRANT=${CHECK_GRANT:-"yes"}
61 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
62 export PARALLEL=${PARALLEL:-"no"}
64 export NAME=${NAME:-local}
71 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
72 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
73 . $LUSTRE/tests/test-framework.sh
75 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
78 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
80 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
81 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
82 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
88 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
89 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
98 check_kernel_version() {
100 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
102 patchless|patchless_client) return 0;;
103 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
105 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
109 check_swap_layouts_support()
111 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
112 { skip "Does not support layout lock."; return 0; }
116 if [ "$ONLY" == "cleanup" ]; then
121 check_and_setup_lustre
126 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
127 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
128 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
129 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
130 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
131 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
132 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
133 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
135 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
136 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
137 rm -rf $DIR/[Rdfs][0-9]*
139 # $RUNAS_ID may get set incorrectly somewhere else
140 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
142 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
146 if [ "${ONLY}" = "MOUNT" ] ; then
147 echo "Lustre is up, please go on"
151 echo "preparing for tests involving mounts"
152 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
154 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
155 echo # add a newline after mke2fs.
159 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
160 lctl set_param debug=-1 2> /dev/null || true
163 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
165 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
167 run_test 0a "touch; rm ====================="
170 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
171 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
173 run_test 0b "chmod 0755 $DIR ============================="
176 $LCTL get_param mdc.*.import | grep "state: FULL" ||
177 error "import not FULL"
178 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
181 run_test 0c "check import proc ============================="
184 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
185 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
186 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
187 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
190 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
192 run_test 1 "mkdir; remkdir; rmdir =============================="
195 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
196 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
197 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
199 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
201 run_test 2 "mkdir; touch; rmdir; check file ===================="
204 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
205 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
206 touch $DIR/$tdir/$tfile
207 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
209 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
211 run_test 3 "mkdir; touch; rmdir; check dir ====================="
213 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
217 test_mkdir $DIR/$tdir ||
218 error "Create remote directory failed"
220 touch $DIR/$tdir/$tfile ||
221 error "Create file under remote directory failed"
224 error "Expect error removing in-use dir $DIR/$tdir"
226 test -d $DIR/$tdir || error "Remote directory disappeared"
228 rm -rf $DIR/$tdir || error "remove remote dir error"
230 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
233 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
234 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
235 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
236 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
237 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
239 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
242 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
243 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
244 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
245 error "$tfile does not have perm 0666 or UID $UID"
246 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
247 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
248 error "$tfile should be 0666 and owned by UID $UID"
250 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
253 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
255 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
256 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
257 error "$tfile should be owned by UID $RUNAS_ID"
258 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
259 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
260 error "$tfile should be owned by UID $RUNAS_ID"
262 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
265 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
267 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
268 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
269 error "$tfile should be owned by GID $UID"
270 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
271 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
272 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
274 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
277 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
278 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
279 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
280 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
281 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
282 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
283 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
284 error "$tdir/d/subdir should be GID $RUNAS_GID"
286 run_test 6g "Is new dir in sgid dir inheriting group?"
288 test_6h() { # bug 7331
289 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
290 touch $DIR/$tfile || error "touch failed"
291 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
292 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
293 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
294 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
295 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
297 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
300 test_mkdir $DIR/$tdir
301 $MCREATE $DIR/$tdir/$tfile
302 chmod 0666 $DIR/$tdir/$tfile
303 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
304 error "$tdir/$tfile should be mode 0666"
306 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
309 if [ ! -d $DIR/$tdir ]; then
312 $MCREATE $DIR/$tdir/$tfile
313 echo -n foo > $DIR/$tdir/$tfile
314 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
315 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
317 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
320 test_mkdir $DIR/$tdir
321 touch $DIR/$tdir/$tfile
322 chmod 0666 $DIR/$tdir/$tfile
323 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
324 error "$tfile mode not 0666"
326 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 test_mkdir $DIR/$tdir/d2/d3
332 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
334 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
337 test_mkdir $DIR/$tdir
338 test_mkdir $DIR/$tdir/d2
339 touch $DIR/$tdir/d2/$tfile
340 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
341 error "$tdir/d2/$tfile not a file"
343 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
346 test_mkdir $DIR/$tdir
347 test_mkdir $DIR/$tdir/d2
348 chmod 0666 $DIR/$tdir/d2
349 chmod 0705 $DIR/$tdir/d2
350 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
351 error "$tdir/d2 mode not 0705"
353 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
358 chmod 0666 $DIR/$tdir/$tfile
359 chmod 0654 $DIR/$tdir/$tfile
360 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
361 error "$tdir/d2 mode not 0654"
363 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
366 test_mkdir $DIR/$tdir
367 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
369 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
370 error "$tdir/$tfile size not 0 after truncate"
372 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
383 test_mkdir $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
386 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
387 error "$tdir/${tfile_2} not a file after rename"
389 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
392 test_mkdir $DIR/$tdir
393 touch $DIR/$tdir/$tfile
394 rm -rf $DIR/$tdir/$tfile
395 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
397 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
400 test_mkdir -p $DIR/$tdir
401 touch $DIR/$tdir/$tfile
402 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
404 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
405 error "$tdir/l-exist not a symlink"
406 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
407 error "$tdir/l-exist not referencing a file"
408 rm -f $DIR/$tdir/l-exist
409 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
411 run_test 17a "symlinks: create, remove (real) =================="
414 test_mkdir -p $DIR/$tdir
415 ln -s no-such-file $DIR/$tdir/l-dangle
417 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
418 error "$tdir/l-dangle not referencing no-such-file"
419 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
420 error "$tdir/l-dangle not referencing non-existent file"
421 rm -f $DIR/$tdir/l-dangle
422 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
424 run_test 17b "symlinks: create, remove (dangling) =============="
426 test_17c() { # bug 3440 - don't save failed open RPC for replay
427 test_mkdir -p $DIR/$tdir
428 ln -s foo $DIR/$tdir/$tfile
429 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
431 run_test 17c "symlinks: open dangling (should return error) ===="
434 test_mkdir -p $DIR/$tdir
435 ln -s foo $DIR/$tdir/$tfile
436 touch $DIR/$tdir/$tfile || error "creating to new symlink"
438 run_test 17d "symlinks: create dangling ========================"
441 test_mkdir -p $DIR/$tdir
442 local foo=$DIR/$tdir/$tfile
443 ln -s $foo $foo || error "create symlink failed"
444 ls -l $foo || error "ls -l failed"
445 ls $foo && error "ls not failed" || true
447 run_test 17e "symlinks: create recursive symlink (should return error) ===="
450 test_mkdir -p $DIR/$tdir
451 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
455 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
456 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
459 run_test 17f "symlinks: long and very long symlink name ========================"
461 # str_repeat(S, N) generate a string that is string S repeated N times
466 while [ $((n -= 1)) -ge 0 ]; do
472 # Long symlinks and LU-2241
474 test_mkdir -p $DIR/$tdir
475 local TESTS="59 60 61 4094 4095"
477 # Fix for inode size boundary in 2.1.4
478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
481 # Patch not applied to 2.2 or 2.3 branches
482 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
483 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
486 # skip long symlink name for rhel6.5.
487 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
488 grep -q '6.5' /etc/redhat-release &>/dev/null &&
489 TESTS="59 60 61 4062 4063"
492 local SYMNAME=$(str_repeat 'x' $i)
493 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
494 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
497 run_test 17g "symlinks: really long symlink name and inode boundaries"
499 test_17h() { #bug 17378
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
503 test_mkdir -p $DIR/$tdir
504 if [[ $MDSCOUNT -gt 1 ]]; then
505 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
509 $SETSTRIPE -c -1 $DIR/$tdir
510 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
511 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
512 touch $DIR/$tdir/$tfile || true
514 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
516 test_17i() { #bug 20018
517 remote_mds_nodsh && skip "remote MDS with nodsh" && return
518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
519 test_mkdir -c1 $DIR/$tdir
520 local foo=$DIR/$tdir/$tfile
522 if [[ $MDSCOUNT -gt 1 ]]; then
523 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
527 ln -s $foo $foo || error "create symlink failed"
528 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
529 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
530 ls -l $foo && error "error not detected"
533 run_test 17i "don't panic on short symlink"
535 test_17k() { #bug 22301
536 [[ -z "$(which rsync 2>/dev/null)" ]] &&
537 skip "no rsync command" && return 0
538 rsync --help | grep -q xattr ||
539 skip_env "$(rsync --version | head -n1) does not support xattrs"
540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
541 test_mkdir -p $DIR/$tdir
542 test_mkdir -p $DIR/$tdir.new
543 touch $DIR/$tdir/$tfile
544 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
545 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
546 error "rsync failed with xattrs enabled"
548 run_test 17k "symlinks: rsync with xattrs enabled ========================="
550 test_17l() { # LU-279
551 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
552 skip "no getfattr command" && return 0
554 touch $DIR/$tdir/$tfile
555 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
556 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
557 # -h to not follow symlinks. -m '' to list all the xattrs.
558 # grep to remove first line: '# file: $path'.
559 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
561 lgetxattr_size_check $path $xattr ||
562 error "lgetxattr_size_check $path $xattr failed"
566 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
570 local short_sym="0123456789"
571 local WDIR=$DIR/${tdir}m
578 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
579 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
580 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
582 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
583 skip "only for ldiskfs MDT" && return 0
585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
589 # create a long symlink file
590 for ((i = 0; i < 4; ++i)); do
591 long_sym=${long_sym}${long_sym}
594 echo "create 512 short and long symlink files under $WDIR"
595 for ((i = 0; i < 256; ++i)); do
596 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
597 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
603 wait_delete_completed
605 echo "recreate the 512 symlink files with a shorter string"
606 for ((i = 0; i < 512; ++i)); do
607 # rewrite the symlink file with a shorter string
608 ln -sf ${long_sym} $WDIR/long-$i
609 ln -sf ${short_sym} $WDIR/short-$i
612 mds_index=$($LFS getstripe -M $WDIR)
613 mds_index=$((mds_index+1))
614 devname=$(mdsdevname $mds_index)
615 cmd="$E2FSCK -fnvd $devname"
617 echo "stop and checking mds${mds_index}: $cmd"
618 # e2fsck should not return error
620 do_facet mds${mds_index} $cmd || rc=$?
622 start mds${mds_index} $devname $MDS_MOUNT_OPTS
623 df $MOUNT > /dev/null 2>&1
624 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
625 "short/long symlink MDT: rc=$rc"
628 run_test 17m "run e2fsck against MDT which contains short/long symlink"
630 check_fs_consistency_17n() {
636 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
637 # so it only check MDT1/MDT2 instead of all of MDTs.
638 for mdt_index in $(seq 1 2); do
639 devname=$(mdsdevname $mdt_index)
640 cmd="$E2FSCK -fnvd $devname"
642 echo "stop and checking mds${mdt_index}: $cmd"
643 # e2fsck should not return error
645 do_facet mds${mdt_index} $cmd || rc=$?
647 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
648 df $MOUNT > /dev/null 2>&1
649 [ $rc -ne 0 ] && break
657 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
658 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
659 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
661 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
662 skip "only for ldiskfs MDT" && return 0
664 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
666 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
669 for ((i=0; i<10; i++)); do
670 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
671 error "create remote dir error $i"
672 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
673 error "create files under remote dir failed $i"
676 check_fs_consistency_17n ||
677 error "e2fsck report error after create files under remote dir"
679 for ((i=0;i<10;i++)); do
680 rm -rf $DIR/$tdir/remote_dir_${i} ||
681 error "destroy remote dir error $i"
684 check_fs_consistency_17n ||
685 error "e2fsck report error after unlink files under remote dir"
687 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
688 skip "lustre < 2.4.50 does not support migrate mv " && return
690 for ((i=0; i<10; i++)); do
691 mkdir -p $DIR/$tdir/remote_dir_${i}
692 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
693 error "create files under remote dir failed $i"
694 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
695 error "migrate remote dir error $i"
697 check_fs_consistency_17n || error "e2fsck report error after migration"
699 for ((i=0;i<10;i++)); do
700 rm -rf $DIR/$tdir/remote_dir_${i} ||
701 error "destroy remote dir error $i"
704 check_fs_consistency_17n || error "e2fsck report error after unlink"
706 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
709 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
710 skip "Need MDS version at least 2.3.64" && return
712 local WDIR=$DIR/${tdir}o
718 mdt_index=$($LFS getstripe -M $WDIR)
719 mdt_index=$((mdt_index+1))
720 mdtdevname=$(mdsdevname $mdt_index)
724 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
726 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
727 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
728 ls -l $WDIR/$tfile && rc=1
729 do_facet mds${mdt_index} lctl set_param fail_loc=0
730 [[ $rc -ne 0 ]] && error "stat file should fail"
733 run_test 17o "stat file with incompat LMA feature"
736 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
737 ls $DIR || error "Failed to ls $DIR: $?"
739 run_test 18 "touch .../f ; ls ... =============================="
745 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
747 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
750 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
752 run_test 19b "ls -l .../f19 (should return error) =============="
755 [ $RUNAS_ID -eq $UID ] &&
756 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
757 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
759 run_test 19c "$RUNAS touch .../f19 (should return error) =="
762 cat $DIR/f19 && error || true
764 run_test 19d "cat .../f19 (should return error) =============="
776 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
778 run_test 20 "touch .../f ; ls -l ... ==========================="
781 test_mkdir -p $DIR/$tdir
782 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
783 ln -s dangle $DIR/$tdir/link
784 echo foo >> $DIR/$tdir/link
785 cat $DIR/$tdir/dangle
786 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
787 $CHECKSTAT -f -t file $DIR/$tdir/link ||
788 error "$tdir/link not linked to a file"
790 run_test 21 "write to dangling link ============================"
794 test_mkdir -p $DIR/$tdir
795 chown $RUNAS_ID:$RUNAS_GID $WDIR
796 (cd $WDIR || error "cd $WDIR failed";
797 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
799 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
800 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
801 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
803 run_test 22 "unpack tar archive as non-root user ==============="
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
810 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
811 openfile -f O_CREAT:O_EXCL $file &&
812 error "$file recreate succeeded" || true
814 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
816 test_23b() { # bug 18988
817 test_mkdir -p $DIR/$tdir
818 local file=$DIR/$tdir/$tfile
821 echo foo > $file || error "write filed"
822 echo bar >> $file || error "append filed"
823 $CHECKSTAT -s 8 $file || error "wrong size"
826 run_test 23b "O_APPEND check =========================="
830 echo '-- same directory rename'
831 test_mkdir $DIR/$tdir
832 touch $DIR/$tdir/$tfile.1
833 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
834 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
836 run_test 24a "rename file to non-existent target"
839 test_mkdir $DIR/$tdir
840 touch $DIR/$tdir/$tfile.{1,2}
841 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
842 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
843 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
845 run_test 24b "rename file to existing target"
848 test_mkdir $DIR/$tdir
849 test_mkdir $DIR/$tdir/d$testnum.1
850 mv $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 24c "rename directory to non-existent target"
857 test_mkdir -c1 $DIR/$tdir
858 test_mkdir -c1 $DIR/$tdir/d$testnum.1
859 test_mkdir -c1 $DIR/$tdir/d$testnum.2
860 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
861 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
862 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
864 run_test 24d "rename directory to existing target"
867 echo '-- cross directory renames --'
871 mv $DIR/R5a/f $DIR/R5b/g
872 $CHECKSTAT -a $DIR/R5a/f || error
873 $CHECKSTAT -t file $DIR/R5b/g || error
875 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
880 touch $DIR/R6a/f $DIR/R6b/g
881 mv $DIR/R6a/f $DIR/R6b/g
882 $CHECKSTAT -a $DIR/R6a/f || error
883 $CHECKSTAT -t file $DIR/R6b/g || error
885 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
890 test_mkdir $DIR/R7a/d
891 mv $DIR/R7a/d $DIR/R7b/e
892 $CHECKSTAT -a $DIR/R7a/d || error
893 $CHECKSTAT -t dir $DIR/R7b/e || error
895 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
898 test_mkdir -c1 $DIR/R8a
899 test_mkdir -c1 $DIR/R8b
900 test_mkdir -c1 $DIR/R8a/d
901 test_mkdir -c1 $DIR/R8b/e
902 mrename $DIR/R8a/d $DIR/R8b/e
903 $CHECKSTAT -a $DIR/R8a/d || error
904 $CHECKSTAT -t dir $DIR/R8b/e || error
906 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
909 echo "-- rename error cases"
913 mrename $DIR/R9/f $DIR/R9/a
914 $CHECKSTAT -t file $DIR/R9/f || error
915 $CHECKSTAT -t dir $DIR/R9/a || error
916 $CHECKSTAT -a $DIR/R9/a/f || error
918 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
922 mrename $DIR/R10/f $DIR/R10/g
923 $CHECKSTAT -t dir $DIR/R10 || error
924 $CHECKSTAT -a $DIR/R10/f || error
925 $CHECKSTAT -a $DIR/R10/g || error
927 run_test 24j "source does not exist ============================"
931 test_mkdir $DIR/R11a/d
933 mv $DIR/R11a/f $DIR/R11a/d
934 $CHECKSTAT -a $DIR/R11a/f || error
935 $CHECKSTAT -t file $DIR/R11a/d/f || error
937 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
939 # bug 2429 - rename foo foo foo creates invalid file
942 $MULTIOP $f OcNs || error
944 run_test 24l "Renaming a file to itself ========================"
948 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
949 # on ext3 this does not remove either the source or target files
950 # though the "expected" operation would be to remove the source
951 $CHECKSTAT -t file ${f} || error "${f} missing"
952 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
954 run_test 24m "Renaming a file to a hard link to itself ========="
958 # this stats the old file after it was renamed, so it should fail
962 $CHECKSTAT ${f}.rename
965 run_test 24n "Statting the old file after renaming (Posix rename 2)"
968 check_kernel_version 37 || return 0
969 test_mkdir -p $DIR/d24o
970 rename_many -s random -v -n 10 $DIR/d24o
972 run_test 24o "rename of files during htree split ==============="
977 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
978 mrename $DIR/R12a $DIR/R12b
979 $CHECKSTAT -a $DIR/R12a || error
980 $CHECKSTAT -t dir $DIR/R12b || error
981 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
982 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
984 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
986 cleanup_multiop_pause() {
992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
995 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
996 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
999 trap cleanup_multiop_pause EXIT
1000 mrename $DIR/R13a $DIR/R13b
1001 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
1002 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
1003 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
1004 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
1005 cleanup_multiop_pause
1006 wait $MULTIPID || error "multiop close failed"
1008 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1010 test_24r() { #bug 3789
1011 test_mkdir $DIR/R14a
1012 test_mkdir $DIR/R14a/b
1013 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1015 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1017 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1020 test_mkdir $DIR/R15a
1021 test_mkdir $DIR/R15a/b
1022 test_mkdir $DIR/R15a/b/c
1023 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1024 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1025 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1027 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1029 test_mkdir $DIR/R16a
1030 test_mkdir $DIR/R16a/b
1031 test_mkdir $DIR/R16a/b/c
1032 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1033 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1034 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1036 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1038 test_24u() { # bug12192
1039 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1040 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1042 run_test 24u "create stripe file"
1048 simple_cleanup_common() {
1051 wait_delete_completed
1054 max_pages_per_rpc() {
1055 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1059 local NRFILES=100000
1060 local FREE_INODES=$(mdt_free_inodes 0)
1061 [[ $FREE_INODES -lt $NRFILES ]] &&
1062 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1066 trap simple_cleanup_common EXIT
1068 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1069 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1072 createmany -m $DIR/$tdir/$tfile $NRFILES
1074 cancel_lru_locks mdc
1075 lctl set_param mdc.*.stats clear
1077 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1079 # LU-5 large readdir
1080 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1081 # 8 bytes for name(filename is mostly 5 in this test) +
1082 # 8 bytes for luda_type
1083 # take into account of overhead in lu_dirpage header and end mark in
1084 # each page, plus one in RPC_NUM calculation.
1086 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1087 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1088 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1089 awk '/^mds_readpage/ {print $2}')
1090 [[ $mds_readpage -gt $RPC_NUM ]] &&
1091 error "large readdir doesn't take effect"
1093 simple_cleanup_common
1095 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1097 test_24w() { # bug21506
1099 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1100 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1101 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1102 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1103 [[ "$SZ1" -eq "$SZ2" ]] ||
1104 error "Error reading at the end of the file $tfile"
1106 run_test 24w "Reading a file larger than 4Gb"
1109 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1112 local remote_dir=$DIR/$tdir/remote_dir
1115 $LFS mkdir -i $MDTIDX $remote_dir ||
1116 error "create remote directory failed"
1118 mkdir -p $DIR/$tdir/src_dir
1119 touch $DIR/$tdir/src_file
1120 mkdir -p $remote_dir/tgt_dir
1121 touch $remote_dir/tgt_file
1123 mrename $remote_dir $DIR/ &&
1124 error "rename dir cross MDT works!"
1126 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1127 error "rename dir cross MDT works!"
1129 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1130 error "rename file cross MDT works!"
1132 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1133 error "ln file cross MDT should not work!"
1135 rm -rf $DIR/$tdir || error "Can not delete directories"
1137 run_test 24x "cross rename/link should be failed"
1140 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1143 local remote_dir=$DIR/$tdir/remote_dir
1146 $LFS mkdir -i $MDTIDX $remote_dir ||
1147 error "create remote directory failed"
1149 mkdir -p $remote_dir/src_dir
1150 touch $remote_dir/src_file
1151 mkdir -p $remote_dir/tgt_dir
1152 touch $remote_dir/tgt_file
1154 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1155 error "rename subdir in the same remote dir failed!"
1157 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1158 error "rename files in the same remote dir failed!"
1160 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1161 error "link files in the same remote dir failed!"
1163 rm -rf $DIR/$tdir || error "Can not delete directories"
1165 run_test 24y "rename/link on the same dir should succeed"
1168 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1171 local remote_src=$DIR/$tdir/remote_dir
1172 local remote_tgt=$DIR/$tdir/remote_tgt
1175 $LFS mkdir -i $MDTIDX $remote_src ||
1176 error "create remote directory failed"
1178 $LFS mkdir -i $MDTIDX $remote_tgt ||
1179 error "create remote directory failed"
1181 mrename $remote_src $remote_tgt &&
1182 error "rename remote dirs should not work!"
1184 # If target dir does not exists, it should succeed
1186 mrename $remote_src $remote_tgt ||
1187 error "rename remote dirs(tgt dir does not exists) failed!"
1189 rm -rf $DIR/$tdir || error "Can not delete directories"
1191 run_test 24z "rename one remote dir to another remote dir should fail"
1193 test_24A() { # LU-3182
1198 createmany -m $DIR/$tdir/$tfile $NFILES
1199 local t=$(ls $DIR/$tdir | wc -l)
1200 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1201 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1202 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1203 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1206 rm -rf $DIR/$tdir || error "Can not delete directories"
1208 run_test 24A "readdir() returns correct number of entries."
1210 test_24B() { # LU-4805
1211 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1215 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1216 error "create striped dir failed"
1218 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1219 [ $count -eq 2 ] || error "Expected 2, got $count"
1221 touch $DIR/$tdir/striped_dir/a
1223 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1224 [ $count -eq 3 ] || error "Expected 3, got $count"
1226 touch $DIR/$tdir/striped_dir/.f
1228 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1229 [ $count -eq 4 ] || error "Expected 4, got $count"
1231 rm -rf $DIR/$tdir || error "Can not delete directories"
1233 run_test 24B "readdir for striped dir return correct number of entries"
1236 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1242 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1243 error "create striped dir failed"
1245 cd $DIR/$tdir/d0/striped_dir
1247 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1248 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1249 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1251 [ "$d0_ino" = "$parent_ino" ] ||
1252 error ".. wrong, expect $d0_ino, get $parent_ino"
1254 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1255 error "mv striped dir failed"
1257 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1259 [ "$d1_ino" = "$parent_ino" ] ||
1260 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1262 run_test 24C "check .. in striped dir"
1265 echo '== symlink sanity ============================================='
1269 touch $DIR/s25/foo || error
1271 run_test 25a "create file in symlinked directory ==============="
1274 [ ! -d $DIR/d25 ] && test_25a
1275 $CHECKSTAT -t file $DIR/s25/foo || error
1277 run_test 25b "lookup file in symlinked directory ==============="
1281 test_mkdir $DIR/d26/d26-2
1282 ln -s d26/d26-2 $DIR/s26
1283 touch $DIR/s26/foo || error
1285 run_test 26a "multiple component symlink ======================="
1288 test_mkdir -p $DIR/d26b/d26-2
1289 ln -s d26b/d26-2/foo $DIR/s26-2
1290 touch $DIR/s26-2 || error
1292 run_test 26b "multiple component symlink at end of lookup ======"
1295 test_mkdir $DIR/d26.2
1296 touch $DIR/d26.2/foo
1297 ln -s d26.2 $DIR/s26.2-1
1298 ln -s s26.2-1 $DIR/s26.2-2
1299 ln -s s26.2-2 $DIR/s26.2-3
1300 chmod 0666 $DIR/s26.2-3/foo
1302 run_test 26c "chain of symlinks ================================"
1304 # recursive symlinks (bug 439)
1306 ln -s d26-3/foo $DIR/d26-3
1308 run_test 26d "create multiple component recursive symlink ======"
1311 [ ! -h $DIR/d26-3 ] && test_26d
1314 run_test 26e "unlink multiple component recursive symlink ======"
1316 # recursive symlinks (bug 7022)
1318 test_mkdir -p $DIR/$tdir
1319 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1320 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1321 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1322 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1323 cd $tfile || error "cd $tfile failed"
1324 ln -s .. dotdot || error "ln dotdot failed"
1325 ln -s dotdot/lndir lndir || error "ln lndir failed"
1326 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1327 output=`ls $tfile/$tfile/lndir/bar1`
1328 [ "$output" = bar1 ] && error "unexpected output"
1329 rm -r $tfile || error "rm $tfile failed"
1330 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1332 run_test 26f "rm -r of a directory which has recursive symlink ="
1335 echo '== stripe sanity =============================================='
1336 test_mkdir -p $DIR/d27 || error "mkdir failed"
1338 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1339 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1340 log "== test_27a: write to one stripe file ========================="
1341 cp /etc/hosts $DIR/d27/f0 || error
1343 run_test 27a "one stripe file =================================="
1346 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1347 test_mkdir -p $DIR/d27
1348 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1349 $GETSTRIPE -c $DIR/d27/f01
1350 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1351 error "two-stripe file doesn't have two stripes"
1353 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1355 run_test 27b "create and write to two stripe file"
1358 test_mkdir -p $DIR/d27
1359 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1360 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1361 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1363 run_test 27d "create file with default settings ================"
1366 test_mkdir -p $DIR/d27
1367 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1368 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1369 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1371 run_test 27e "setstripe existing file (should return error) ======"
1374 test_mkdir -p $DIR/d27
1375 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1376 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1377 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1379 run_test 27f "setstripe with bad stripe size (should return error)"
1382 test_mkdir -p $DIR/d27
1383 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1384 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1385 error "$DIR/d27/fnone has object"
1387 run_test 27g "$GETSTRIPE with no objects"
1390 touch $DIR/d27/fsome || error "touch failed"
1391 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1393 run_test 27i "$GETSTRIPE with some objects"
1396 test_mkdir -p $DIR/d27
1397 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1399 run_test 27j "setstripe with bad stripe offset (should return error)"
1401 test_27k() { # bug 2844
1402 test_mkdir -p $DIR/d27
1404 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1405 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1406 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1407 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1408 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1409 dd if=/dev/zero of=$FILE bs=4k count=1
1410 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1411 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1413 run_test 27k "limit i_blksize for broken user apps ============="
1416 test_mkdir -p $DIR/d27
1417 mcreate $DIR/f27l || error "creating file"
1418 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1419 error "setstripe should have failed" || true
1421 run_test 27l "check setstripe permissions (should return error)"
1424 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1426 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1427 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1430 trap simple_cleanup_common EXIT
1431 test_mkdir -p $DIR/$tdir
1432 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1433 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1434 error "dd should fill OST0"
1436 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1438 [ $i -gt 256 ] && break
1441 touch $DIR/$tdir/f27m_$i
1442 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1443 error "OST0 was full but new created file still use it"
1445 touch $DIR/$tdir/f27m_$i
1446 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1447 error "OST0 was full but new created file still use it"
1448 simple_cleanup_common
1450 run_test 27m "create file while OST0 was full =================="
1453 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1457 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1458 # if the OST isn't full anymore.
1460 local OSTIDX=${1:-""}
1462 local list=$(comma_list $(osts_nodes))
1463 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1465 do_nodes $list lctl set_param fail_loc=0
1466 sync # initiate all OST_DESTROYs from MDS to OST
1470 exhaust_precreations() {
1473 local FAILIDX=${3:-$OSTIDX}
1475 test_mkdir -p $DIR/$tdir
1476 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1477 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1479 local OST=$(ostname_from_index $OSTIDX)
1480 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1481 sed -e 's/_UUID$//;s/^.*-//')
1484 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1485 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1486 osc.$mdtosc_proc1.prealloc_last_id)
1487 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1488 osc.$mdtosc_proc1.prealloc_next_id)
1490 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1491 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1493 test_mkdir -p $DIR/$tdir/${OST}
1494 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1495 #define OBD_FAIL_OST_ENOSPC 0x215
1496 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1497 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1498 echo "Creating to objid $last_id on ost $OST..."
1499 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1500 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1501 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1505 exhaust_all_precreations() {
1507 for (( i=0; i < OSTCOUNT; i++ )) ; do
1508 exhaust_precreations $i $1 -1
1513 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1514 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1515 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1516 remote_ost_nodsh && skip "remote OST with nodsh" && return
1519 rm -f $DIR/$tdir/$tfile
1520 exhaust_precreations 0 0x80000215
1521 $SETSTRIPE -c -1 $DIR/$tdir
1522 touch $DIR/$tdir/$tfile || error
1523 $GETSTRIPE $DIR/$tdir/$tfile
1526 run_test 27n "create file with some full OSTs =================="
1529 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1531 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1532 remote_ost_nodsh && skip "remote OST with nodsh" && return
1535 rm -f $DIR/$tdir/$tfile
1536 exhaust_all_precreations 0x215
1538 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1543 run_test 27o "create file with all full OSTs (should error) ===="
1546 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1548 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1549 remote_ost_nodsh && skip "remote OST with nodsh" && return
1552 rm -f $DIR/$tdir/$tfile
1553 test_mkdir -p $DIR/$tdir
1555 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1556 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1557 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1559 exhaust_precreations 0 0x80000215
1560 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1561 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1562 $GETSTRIPE $DIR/$tdir/$tfile
1566 run_test 27p "append to a truncated file with some full OSTs ==="
1569 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1571 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1572 remote_ost_nodsh && skip "remote OST with nodsh" && return
1575 rm -f $DIR/$tdir/$tfile
1577 test_mkdir -p $DIR/$tdir
1578 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1579 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1580 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1582 exhaust_all_precreations 0x215
1584 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1585 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1589 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1592 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1593 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1594 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1595 remote_ost_nodsh && skip "remote OST with nodsh" && return
1598 rm -f $DIR/$tdir/$tfile
1599 exhaust_precreations 0 0x80000215
1601 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1605 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1607 test_27s() { # bug 10725
1608 test_mkdir -p $DIR/$tdir
1609 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1610 local stripe_count=0
1611 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1612 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1613 error "stripe width >= 2^32 succeeded" || true
1616 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1618 test_27t() { # bug 10864
1623 $WLFS getstripe $tfile
1626 run_test 27t "check that utils parse path correctly"
1628 test_27u() { # bug 4900
1629 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1630 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1632 local list=$(comma_list $(mdts_nodes))
1634 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1635 do_nodes $list $LCTL set_param fail_loc=0x139
1636 test_mkdir -p $DIR/$tdir
1638 createmany -o $DIR/$tdir/t- 1000
1639 do_nodes $list $LCTL set_param fail_loc=0
1641 TLOG=$DIR/$tfile.getstripe
1642 $GETSTRIPE $DIR/$tdir > $TLOG
1643 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1644 unlinkmany $DIR/$tdir/t- 1000
1645 [[ $OBJS -gt 0 ]] &&
1646 error "$OBJS objects created on OST-0. See $TLOG" || pass
1648 run_test 27u "skip object creation on OSC w/o objects =========="
1650 test_27v() { # bug 4900
1651 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1653 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1654 remote_ost_nodsh && skip "remote OST with nodsh" && return
1656 exhaust_all_precreations 0x215
1659 test_mkdir -p $DIR/$tdir
1660 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1662 touch $DIR/$tdir/$tfile
1663 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1665 for (( i=1; i < OSTCOUNT; i++ )); do
1666 do_facet ost$i lctl set_param fail_loc=0x705
1668 local START=`date +%s`
1669 createmany -o $DIR/$tdir/$tfile 32
1671 local FINISH=`date +%s`
1672 local TIMEOUT=`lctl get_param -n timeout`
1673 local PROCESS=$((FINISH - START))
1674 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1675 error "$FINISH - $START >= $TIMEOUT / 2"
1676 sleep $((TIMEOUT / 2 - PROCESS))
1679 run_test 27v "skip object creation on slow OST ================="
1681 test_27w() { # bug 10997
1682 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1683 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1684 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1685 error "stripe size $size != 65536" || true
1686 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1687 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1689 run_test 27w "check $SETSTRIPE -S option"
1692 [[ $OSTCOUNT -lt 2 ]] &&
1693 skip_env "skipping multiple stripe count/offset test" && return
1695 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1696 for i in $(seq 1 $OSTCOUNT); do
1698 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1699 error "setstripe -c $i -i $offset failed"
1700 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1701 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1702 [ $count -ne $i ] && error "stripe count $count != $i" || true
1703 [ $index -ne $offset ] &&
1704 error "stripe offset $index != $offset" || true
1707 run_test 27wa "check $SETSTRIPE -c -i options"
1710 remote_ost_nodsh && skip "remote OST with nodsh" && return
1711 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1713 OFFSET=$(($OSTCOUNT - 1))
1715 local OST=$(ostname_from_index $OSTIDX)
1717 test_mkdir -p $DIR/$tdir
1718 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1719 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1721 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1722 for i in `seq 0 $OFFSET`; do
1723 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1724 error "OST0 was degraded but new created file still use it"
1726 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1728 run_test 27x "create files while OST0 is degraded"
1731 [[ $OSTCOUNT -lt 2 ]] &&
1732 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1733 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1734 remote_ost_nodsh && skip "remote OST with nodsh" && return
1735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1737 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1738 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1739 osc.$mdtosc.prealloc_last_id)
1740 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1741 osc.$mdtosc.prealloc_next_id)
1742 local fcount=$((last_id - next_id))
1743 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1744 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1746 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1747 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1748 local OST_DEACTIVE_IDX=-1
1753 for OSC in $MDS_OSCS; do
1754 OST=$(osc_to_ost $OSC)
1755 OSTIDX=$(index_from_ostuuid $OST)
1756 if [ $OST_DEACTIVE_IDX == -1 ]; then
1757 OST_DEACTIVE_IDX=$OSTIDX
1759 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1760 echo $OSC "is Deactivated:"
1761 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1765 OSTIDX=$(index_from_ostuuid $OST)
1767 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1769 for OSC in $MDS_OSCS; do
1770 OST=$(osc_to_ost $OSC)
1771 OSTIDX=$(index_from_ostuuid $OST)
1772 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1773 echo $OST "is degraded:"
1774 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1775 obdfilter.$OST.degraded=1
1780 createmany -o $DIR/$tdir/$tfile $fcount
1782 for OSC in $MDS_OSCS; do
1783 OST=$(osc_to_ost $OSC)
1784 OSTIDX=$(index_from_ostuuid $OST)
1785 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1786 echo $OST "is recovered from degraded:"
1787 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1788 obdfilter.$OST.degraded=0
1790 do_facet $SINGLEMDS lctl --device %$OSC activate
1794 # all osp devices get activated, hence -1 stripe count restored
1797 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1798 # devices get activated.
1800 $SETSTRIPE -c -1 $DIR/$tfile
1801 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1803 [ $stripecnt -ne $OSTCOUNT ] &&
1804 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1807 run_test 27y "create files while OST0 is degraded and the rest inactive"
1813 lmm_count=$($GETSTRIPE -c $1)
1814 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1815 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1817 local old_ifs="$IFS"
1819 fid=($($LFS path2fid $1))
1822 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1823 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1825 # compare lmm_seq and lu_fid->f_seq
1826 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1827 # compare lmm_object_id and lu_fid->oid
1828 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1830 # check the trusted.fid attribute of the OST objects of the file
1831 local have_obdidx=false
1833 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1834 # skip lines up to and including "obdidx"
1835 [ -z "$obdidx" ] && break
1836 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1837 $have_obdidx || continue
1839 local ost=$((obdidx + 1))
1840 local dev=$(ostdevname $ost)
1843 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1845 seq=$(echo $seq | sed -e "s/^0x//g")
1846 if [ $seq == 0 ]; then
1847 oid_hex=$(echo $oid)
1849 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1851 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1855 # Don't unmount/remount the OSTs if we don't need to do that.
1856 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1857 # update too, until that use mount/ll_decode_filter_fid/mount.
1858 # Re-enable when debugfs will understand new filter_fid.
1860 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1861 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1862 $dev 2>/dev/null" | grep "parent=")
1865 mount_fstype ost$ost
1866 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1867 $(facet_mntpt ost$ost)/$obj_file)
1868 unmount_fstype ost$ost
1869 start ost$ost $dev $OST_MOUNT_OPTS
1872 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1874 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1876 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1877 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1878 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1879 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1880 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1882 if echo $ff_parent | grep -q 'stripe='; then
1883 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1886 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1887 # into f_ver in this case. See the comment on
1890 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1894 # compare lmm_seq and filter_fid->ff_parent.f_seq
1895 [ $ff_pseq = $lmm_seq ] ||
1896 error "FF parent SEQ $ff_pseq != $lmm_seq"
1897 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1898 [ $ff_poid = $lmm_oid ] ||
1899 error "FF parent OID $ff_poid != $lmm_oid"
1900 (($ff_pstripe == $stripe_nr)) ||
1901 error "FF stripe $ff_pstripe != $stripe_nr"
1903 stripe_nr=$((stripe_nr + 1))
1908 remote_ost_nodsh && skip "remote OST with nodsh" && return
1909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1910 test_mkdir -p $DIR/$tdir
1912 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1913 { error "setstripe -c -1 failed"; return 1; }
1914 # We need to send a write to every object to get parent FID info set.
1915 # This _should_ also work for setattr, but does not currently.
1916 # touch $DIR/$tdir/$tfile-1 ||
1917 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1918 { error "dd $tfile-1 failed"; return 2; }
1919 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1920 { error "setstripe -c -1 failed"; return 3; }
1921 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1922 { error "dd $tfile-2 failed"; return 4; }
1924 # make sure write RPCs have been sent to OSTs
1927 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1928 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1930 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1932 test_27A() { # b=19102
1933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1934 local restore_size=$($GETSTRIPE -S $MOUNT)
1935 local restore_count=$($GETSTRIPE -c $MOUNT)
1936 local restore_offset=$($GETSTRIPE -i $MOUNT)
1937 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1938 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1939 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1940 local default_size=$($GETSTRIPE -S $MOUNT)
1941 local default_offset=$($GETSTRIPE -i $MOUNT)
1942 local dsize=$((1024 * 1024))
1943 [ $default_size -eq $dsize ] ||
1944 error "stripe size $default_size != $dsize"
1945 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1946 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1948 run_test 27A "check filesystem-wide default LOV EA values"
1950 test_27B() { # LU-2523
1951 test_mkdir -p $DIR/$tdir
1952 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1954 # open f1 with O_LOV_DELAY_CREATE
1956 # call setstripe ioctl on open file descriptor for f1
1958 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1962 # open f1 with O_LOV_DELAY_CREATE
1964 # call setstripe ioctl on open file descriptor for f1
1966 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1968 # Allow multiop to fail in imitation of NFS's busted semantics.
1971 run_test 27B "call setstripe on open unlinked file/rename victim"
1973 test_27C() { #LU-2871
1974 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1982 test_mkdir -p $DIR/$tdir
1984 for i in $(seq 0 $((OSTCOUNT - 1))); do
1985 # set stripe across all OSTs starting from OST$i
1986 $SETSTRIPE -i $i -c -1 $tfile$i
1987 # get striping information
1988 ost_idx=($($GETSTRIPE $tfile$i |
1989 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1993 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1994 error "${#ost_idx[@]} != $OSTCOUNT"
1996 for index in $(seq 0 $((OSTCOUNT - 1))); do
1998 for j in $(echo ${ost_idx[@]}); do
1999 if [ $index -eq $j ]; then
2005 error "Can not find $index in ${ost_idx[@]}"
2009 run_test 27C "check full striping across all OSTs"
2011 # createtest also checks that device nodes are created and
2012 # then visible correctly (#2091)
2013 test_28() { # bug 2091
2015 $CREATETEST $DIR/d28/ct || error
2017 run_test 28 "create/mknod/mkdir with bad file types ============"
2020 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2021 cancel_lru_locks mdc
2027 declare -i LOCKCOUNTORIG=0
2028 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2029 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2031 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2033 declare -i LOCKUNUSEDCOUNTORIG=0
2034 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2035 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2042 declare -i LOCKCOUNTCURRENT=0
2043 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2044 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2047 declare -i LOCKUNUSEDCOUNTCURRENT=0
2048 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2049 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2052 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2053 $LCTL set_param -n ldlm.dump_namespaces ""
2054 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2055 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2056 log "dumped log to $TMP/test_29.dk (bug 5793)"
2059 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2060 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2061 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2062 log "dumped log to $TMP/test_29.dk (bug 5793)"
2066 run_test 29 "IT_GETATTR regression ============================"
2068 test_30a() { # was test_30
2069 cp $(which ls) $DIR || cp /bin/ls $DIR
2073 run_test 30a "execute binary from Lustre (execve) =============="
2076 cp `which ls` $DIR || cp /bin/ls $DIR
2078 $RUNAS $DIR/ls / || error
2081 run_test 30b "execute binary from Lustre as non-root ==========="
2083 test_30c() { # b=22376
2084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2085 cp `which ls` $DIR || cp /bin/ls $DIR
2087 cancel_lru_locks mdc
2088 cancel_lru_locks osc
2089 $RUNAS $DIR/ls / || error
2092 run_test 30c "execute binary from Lustre without read perms ===="
2095 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2096 $CHECKSTAT -a $DIR/f31 || error
2098 run_test 31a "open-unlink file =================================="
2101 touch $DIR/f31 || error
2102 ln $DIR/f31 $DIR/f31b || error
2103 $MULTIOP $DIR/f31b Ouc || error
2104 $CHECKSTAT -t file $DIR/f31 || error
2106 run_test 31b "unlink file with multiple links while open ======="
2109 touch $DIR/f31 || error
2110 ln $DIR/f31 $DIR/f31c || error
2111 multiop_bg_pause $DIR/f31 O_uc || return 1
2113 $MULTIOP $DIR/f31c Ouc
2114 kill -USR1 $MULTIPID
2117 run_test 31c "open-unlink file with multiple links ============="
2120 opendirunlink $DIR/d31d $DIR/d31d || error
2121 $CHECKSTAT -a $DIR/d31d || error
2123 run_test 31d "remove of open directory ========================="
2125 test_31e() { # bug 2904
2126 check_kernel_version 34 || return 0
2127 openfilleddirunlink $DIR/d31e || error
2129 run_test 31e "remove of open non-empty directory ==============="
2131 test_31f() { # bug 4554
2132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2134 test_mkdir $DIR/d31f
2135 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2136 cp /etc/hosts $DIR/d31f
2138 $GETSTRIPE $DIR/d31f/hosts
2139 multiop_bg_pause $DIR/d31f D_c || return 1
2142 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2143 test_mkdir $DIR/d31f
2144 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2145 cp /etc/hosts $DIR/d31f
2147 $GETSTRIPE $DIR/d31f/hosts
2148 multiop_bg_pause $DIR/d31f D_c || return 1
2151 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2152 wait $MULTIPID || error "first opendir $MULTIPID failed"
2156 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2157 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2160 run_test 31f "remove of open directory with open-unlink file ==="
2163 echo "-- cross directory link --"
2164 test_mkdir -c1 $DIR/${tdir}ga
2165 test_mkdir -c1 $DIR/${tdir}gb
2166 touch $DIR/${tdir}ga/f
2167 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2168 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2169 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2170 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2171 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2173 run_test 31g "cross directory link==============="
2176 echo "-- cross directory link --"
2177 test_mkdir -c1 $DIR/${tdir}
2178 test_mkdir -c1 $DIR/${tdir}/dir
2179 touch $DIR/${tdir}/f
2180 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2181 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2182 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2183 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2184 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2186 run_test 31h "cross directory link under child==============="
2189 echo "-- cross directory link --"
2190 test_mkdir -c1 $DIR/$tdir
2191 test_mkdir -c1 $DIR/$tdir/dir
2192 touch $DIR/$tdir/dir/f
2193 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2194 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2195 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2196 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2197 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2199 run_test 31i "cross directory link under parent==============="
2202 test_mkdir -c1 -p $DIR/$tdir
2203 test_mkdir -c1 -p $DIR/$tdir/dir1
2204 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2205 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2206 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2207 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2210 run_test 31j "link for directory==============="
2213 test_mkdir -c1 -p $DIR/$tdir
2215 touch $DIR/$tdir/exist
2216 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2217 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2218 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2219 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2220 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2221 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2222 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2225 run_test 31k "link to file: the same, non-existing, dir==============="
2231 touch $DIR/d31m2/exist
2232 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2233 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2234 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2235 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2236 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2237 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2240 run_test 31m "link to file: the same, non-existing, dir==============="
2243 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2244 nlink=$(stat --format=%h $DIR/$tfile)
2245 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2247 local cmd="exec $fd<$DIR/$tfile"
2250 trap "eval $cmd" EXIT
2251 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2252 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2253 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2254 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2255 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2258 run_test 31n "check link count of unlinked file"
2261 local TEMPNAME=$(mktemp $1_XXXXXX)
2262 mlink $TEMPNAME $1 2> /dev/null &&
2263 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2267 test_31o() { # LU-2901
2269 for LOOP in $(seq 100); do
2270 rm -f $DIR/$tdir/$tfile*
2271 for THREAD in $(seq 8); do
2272 link_one $DIR/$tdir/$tfile.$LOOP &
2275 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2276 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2277 error "$LINKS duplicate links to $tfile.$LOOP" &&
2281 run_test 31o "duplicate hard links with same filename"
2284 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2287 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2288 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2290 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2291 error "open unlink test1 failed"
2292 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2293 error "open unlink test2 failed"
2295 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2296 error "test1 still exists"
2297 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2298 error "test2 still exists"
2300 run_test 31p "remove of open striped directory"
2302 cleanup_test32_mount() {
2304 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2309 echo "== more mountpoints and symlinks ================="
2310 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2311 trap cleanup_test32_mount EXIT
2312 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2313 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2314 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2315 cleanup_test32_mount
2317 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
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 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2326 cleanup_test32_mount
2328 run_test 32b "open d32b/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 test_mkdir -p $DIR/$tdir/d2/test_dir
2337 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2338 cleanup_test32_mount
2340 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2344 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2345 trap cleanup_test32_mount EXIT
2346 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2347 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2348 test_mkdir -p $DIR/$tdir/d2/test_dir
2349 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2350 cleanup_test32_mount
2352 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2355 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2356 test_mkdir -p $DIR/d32e/tmp
2357 TMP_DIR=$DIR/d32e/tmp
2358 ln -s $DIR/d32e $TMP_DIR/symlink11
2359 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2360 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2361 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2363 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2366 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2367 test_mkdir -p $DIR/d32f/tmp
2368 TMP_DIR=$DIR/d32f/tmp
2369 ln -s $DIR/d32f $TMP_DIR/symlink11
2370 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2371 ls $DIR/d32f/tmp/symlink11 || error
2372 ls $DIR/d32f/symlink01 || error
2374 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2377 TMP_DIR=$DIR/$tdir/tmp
2378 test_mkdir -p $DIR/$tdir/tmp
2379 test_mkdir $DIR/${tdir}2
2380 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2381 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2382 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2383 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2384 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2385 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2387 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2390 rm -fr $DIR/$tdir $DIR/${tdir}2
2391 TMP_DIR=$DIR/$tdir/tmp
2392 test_mkdir -p $DIR/$tdir/tmp
2393 test_mkdir $DIR/${tdir}2
2394 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2395 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2396 ls $TMP_DIR/symlink12 || error
2397 ls $DIR/$tdir/symlink02 || error
2399 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2402 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2403 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2404 trap cleanup_test32_mount EXIT
2405 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2406 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2407 touch $DIR/$tdir/test_file
2408 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2409 cleanup_test32_mount
2411 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2415 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2416 trap cleanup_test32_mount EXIT
2417 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2418 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2419 touch $DIR/$tdir/test_file
2420 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2421 cleanup_test32_mount
2423 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2428 trap cleanup_test32_mount EXIT
2429 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2430 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2431 test_mkdir -p $DIR/$tdir/d2
2432 touch $DIR/$tdir/d2/test_file || error
2433 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2434 cleanup_test32_mount
2436 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2441 trap cleanup_test32_mount EXIT
2442 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2443 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2444 test_mkdir -p $DIR/$tdir/d2
2445 touch $DIR/$tdir/d2/test_file
2446 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2447 cleanup_test32_mount
2449 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2453 test_mkdir -p $DIR/d32m/tmp
2454 TMP_DIR=$DIR/d32m/tmp
2455 ln -s $DIR $TMP_DIR/symlink11
2456 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2457 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2458 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2460 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2464 test_mkdir -p $DIR/d32n/tmp
2465 TMP_DIR=$DIR/d32n/tmp
2466 ln -s $DIR $TMP_DIR/symlink11
2467 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2468 ls -l $DIR/d32n/tmp/symlink11 || error
2469 ls -l $DIR/d32n/symlink01 || error
2471 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2475 test_mkdir -p $DIR/d32o/tmp
2476 TMP_DIR=$DIR/d32o/tmp
2477 ln -s $DIR/$tfile $TMP_DIR/symlink12
2478 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2479 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2480 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2481 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2482 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2484 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2494 test_mkdir -p $DIR/d32p/tmp
2496 TMP_DIR=$DIR/d32p/tmp
2498 ln -s $DIR/$tfile $TMP_DIR/symlink12
2500 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2502 cat $DIR/d32p/tmp/symlink12 || error
2504 cat $DIR/d32p/symlink02 || error
2507 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2509 cleanup_testdir_mount() {
2511 $UMOUNT -d $DIR/$tdir
2515 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2516 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2517 trap cleanup_testdir_mount EXIT
2518 test_mkdir -p $DIR/$tdir
2519 touch $DIR/$tdir/under_the_mount
2520 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2521 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2522 cleanup_testdir_mount
2524 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2528 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2529 trap cleanup_testdir_mount EXIT
2530 test_mkdir -p $DIR/$tdir
2531 touch $DIR/$tdir/under_the_mount
2532 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2533 ls $DIR/$tdir | grep -q under_the_mount && error || true
2534 cleanup_testdir_mount
2536 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2541 chmod 444 $DIR/$tfile
2542 chown $RUNAS_ID $DIR/$tfile
2544 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2547 run_test 33aa "write file with mode 444 (should return error) ===="
2551 test_mkdir -p $DIR/d33
2552 chown $RUNAS_ID $DIR/d33
2553 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2554 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2555 error "open RDWR" || true
2557 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2561 test_mkdir -p $DIR/d33
2562 chown $RUNAS_ID $DIR/d33
2563 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2565 run_test 33b "test open file with malformed flags (No panic)"
2568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2574 remote_ost_nodsh && skip "remote OST with nodsh" && return
2577 test_mkdir -p $DIR/d33
2578 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2581 for ostnum in $(seq $OSTCOUNT); do
2582 # test-framework's OST numbering is one-based, while Lustre's
2584 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2585 # Parsing llobdstat's output sucks; we could grep the /proc
2586 # path, but that's likely to not be as portable as using the
2587 # llobdstat utility. So we parse lctl output instead.
2588 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2589 obdfilter/$ostname/stats |
2590 awk '/^write_bytes/ {print $7}' )
2591 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2592 if (( ${write_bytes:-0} > 0 ))
2599 $all_zeros || return 0
2602 echo foo > $DIR/d33/bar
2606 # Total up write_bytes after writing. We'd better find non-zeros.
2607 for ostnum in $(seq $OSTCOUNT); do
2608 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2609 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2610 obdfilter/$ostname/stats |
2611 awk '/^write_bytes/ {print $7}' )
2612 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2613 if (( ${write_bytes:-0} > 0 ))
2622 for ostnum in $(seq $OSTCOUNT); do
2623 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2624 echo "Check that write_bytes is present in obdfilter/*/stats:"
2625 do_facet ost$ostnum lctl get_param -n \
2626 obdfilter/$ostname/stats
2628 error "OST not keeping write_bytes stats (b22312)"
2631 run_test 33c "test llobdstat and write_bytes"
2634 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2637 local remote_dir=$DIR/$tdir/remote_dir
2640 $LFS mkdir -i $MDTIDX $remote_dir ||
2641 error "create remote directory failed"
2643 touch $remote_dir/$tfile
2644 chmod 444 $remote_dir/$tfile
2645 chown $RUNAS_ID $remote_dir/$tfile
2647 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2649 chown $RUNAS_ID $remote_dir
2650 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2651 error "create" || true
2652 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2653 error "open RDWR" || true
2654 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2655 error "create" || true
2657 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2660 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2664 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2665 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2666 mkdir $DIR/$tdir/local_dir
2668 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2669 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2670 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2672 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2673 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2675 rmdir $DIR/$tdir/* || error "rmdir failed"
2678 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2679 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2680 mkdir $DIR/$tdir/local_dir
2682 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2683 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2684 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2686 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2687 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2689 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2692 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2693 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2694 mkdir $DIR/$tdir/local_dir
2696 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2697 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2698 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2700 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2701 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2703 run_test 33e "mkdir and striped directory should have same mode"
2705 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2708 $MCREATE $DIR/f34 || error
2709 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2710 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2711 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2712 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2714 run_test 34a "truncate file that has not been opened ==========="
2717 [ ! -f $DIR/f34 ] && test_34a
2718 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2719 $OPENFILE -f O_RDONLY $DIR/f34
2720 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2721 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2723 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2726 [ ! -f $DIR/f34 ] && test_34a
2727 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2728 $OPENFILE -f O_RDWR $DIR/f34
2729 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2730 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2732 run_test 34c "O_RDWR opening file-with-size works =============="
2735 [ ! -f $DIR/f34 ] && test_34a
2736 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2737 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2740 run_test 34d "write to sparse file ============================="
2744 $MCREATE $DIR/f34e || error
2745 $TRUNCATE $DIR/f34e 1000 || error
2746 $CHECKSTAT -s 1000 $DIR/f34e || error
2747 $OPENFILE -f O_RDWR $DIR/f34e
2748 $CHECKSTAT -s 1000 $DIR/f34e || error
2750 run_test 34e "create objects, some with size and some without =="
2752 test_34f() { # bug 6242, 6243
2753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2756 $MCREATE $DIR/f34f || error
2757 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2758 dd if=$DIR/f34f of=$TMP/f34f
2759 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2760 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2761 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2762 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2763 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2765 run_test 34f "read from a file with no objects until EOF ======="
2768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2769 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2770 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2771 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2772 cancel_lru_locks osc
2773 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2774 error "wrong size after lock cancel"
2776 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2777 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2778 error "expanding truncate failed"
2779 cancel_lru_locks osc
2780 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2781 error "wrong expanded size after lock cancel"
2783 run_test 34g "truncate long file ==============================="
2786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2790 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2791 sync # Flush the cache so that multiop below does not block on cache
2792 # flush when getting the group lock
2793 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2796 # Since just timed wait is not good enough, let's do a sync write
2797 # that way we are sure enough time for a roundtrip + processing
2798 # passed + 2 seconds of extra margin.
2799 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2803 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2804 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2808 local nsz=`stat -c %s $DIR/$tfile`
2809 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2811 run_test 34h "ftruncate file under grouplock should not block"
2814 cp /bin/sh $DIR/f35a
2816 chown $RUNAS_ID $DIR/f35a
2817 $RUNAS $DIR/f35a && error || true
2820 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2824 utime $DIR/f36 || error
2826 run_test 36a "MDS utime check (mknod, utime) ==================="
2830 utime $DIR/f36 || error
2832 run_test 36b "OST utime check (open, utime) ===================="
2837 chown $RUNAS_ID $DIR/d36
2838 $RUNAS utime $DIR/d36/f36 || error
2840 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2843 [ ! -d $DIR/d36 ] && test_36c
2844 echo "" > $DIR/d36/f36
2845 $RUNAS utime $DIR/d36/f36 || error
2847 run_test 36d "non-root OST utime check (open, utime) ==========="
2850 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2851 test_mkdir -p $DIR/$tdir
2852 touch $DIR/$tdir/$tfile
2853 $RUNAS utime $DIR/$tdir/$tfile && \
2854 error "utime worked, expected failure" || true
2856 run_test 36e "utime on non-owned file (should return error) ===="
2860 local LANG_SAVE=$LANG
2861 local LC_LANG_SAVE=$LC_LANG
2862 export LANG=C LC_LANG=C # for date language
2864 DATESTR="Dec 20 2000"
2865 test_mkdir -p $DIR/$tdir
2866 lctl set_param fail_loc=$fl
2868 cp /etc/hosts $DIR/$tdir/$tfile
2869 sync & # write RPC generated with "current" inode timestamp, but delayed
2871 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2872 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2873 cancel_lru_locks osc
2874 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2876 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2877 echo "BEFORE: $LS_BEFORE" && \
2878 echo "AFTER : $LS_AFTER" && \
2879 echo "WANT : $DATESTR" && \
2880 error "$DIR/$tdir/$tfile timestamps changed" || true
2882 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2887 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2888 subr_36fh "0x80000214"
2890 run_test 36f "utime on file racing with OST BRW write =========="
2893 remote_ost_nodsh && skip "remote OST with nodsh" && return
2894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2899 test_mkdir -p $DIR/$tdir
2900 fmd_max_age=$(do_facet ost1 \
2901 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2904 fmd_before=$(do_facet ost1 \
2905 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2906 touch $DIR/$tdir/$tfile
2907 sleep $((fmd_max_age + 12))
2908 fmd_after=$(do_facet ost1 \
2909 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2911 echo "fmd_before: $fmd_before"
2912 echo "fmd_after: $fmd_after"
2913 [[ $fmd_after -gt $fmd_before ]] &&
2914 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2915 error "fmd didn't expire after ping" || true
2917 run_test 36g "filter mod data cache expiry ====================="
2920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2921 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2922 subr_36fh "0x80000227"
2924 run_test 36h "utime on file racing with OST BRW write =========="
2927 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2930 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2932 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2933 local new_mtime=$((mtime + 200))
2935 #change Modify time of striped dir
2936 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2937 error "change mtime failed"
2939 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2941 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2943 run_test 36i "change mtime on striped directory"
2945 # test_37 - duplicate with tests 32q 32r
2948 local file=$DIR/$tfile
2950 openfile -f O_DIRECTORY $file
2953 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2954 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2956 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2960 touch $DIR/${tfile}2
2961 # ls -l $DIR/$tfile $DIR/${tfile}2
2962 # ls -lu $DIR/$tfile $DIR/${tfile}2
2963 # ls -lc $DIR/$tfile $DIR/${tfile}2
2965 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2966 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2968 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2970 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2972 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2973 error "O_TRUNC didn't change timestamps"
2976 run_test 39 "mtime changed on create ==========================="
2979 test_mkdir -p -c1 $DIR/$tdir
2980 cp -p /etc/passwd $DIR/$tdir/fopen
2981 cp -p /etc/passwd $DIR/$tdir/flink
2982 cp -p /etc/passwd $DIR/$tdir/funlink
2983 cp -p /etc/passwd $DIR/$tdir/frename
2984 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2987 echo "aaaaaa" >> $DIR/$tdir/fopen
2988 echo "aaaaaa" >> $DIR/$tdir/flink
2989 echo "aaaaaa" >> $DIR/$tdir/funlink
2990 echo "aaaaaa" >> $DIR/$tdir/frename
2992 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2993 local link_new=`stat -c %Y $DIR/$tdir/flink`
2994 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2995 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2997 cat $DIR/$tdir/fopen > /dev/null
2998 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2999 rm -f $DIR/$tdir/funlink2
3000 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3002 for (( i=0; i < 2; i++ )) ; do
3003 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3004 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3005 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3006 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3008 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3009 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3010 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3011 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3013 cancel_lru_locks osc
3014 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3017 run_test 39b "mtime change on open, link, unlink, rename ======"
3019 # this should be set to past
3020 TEST_39_MTIME=`date -d "1 year ago" +%s`
3026 local mtime0=`stat -c %Y $DIR1/$tfile`
3028 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3029 local mtime1=`stat -c %Y $DIR1/$tfile`
3030 [ "$mtime1" = $TEST_39_MTIME ] || \
3031 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3034 echo hello >> $DIR1/$tfile
3036 local mtime2=`stat -c %Y $DIR1/$tfile`
3037 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3038 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3040 mv $DIR1/$tfile $DIR1/$tfile-1
3042 for (( i=0; i < 2; i++ )) ; do
3043 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3044 [ "$mtime2" = "$mtime3" ] || \
3045 error "mtime ($mtime2) changed (to $mtime3) on rename"
3047 cancel_lru_locks osc
3048 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3051 run_test 39c "mtime change on rename ==========================="
3055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3058 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3060 for (( i=0; i < 2; i++ )) ; do
3061 local mtime=`stat -c %Y $DIR1/$tfile`
3062 [ $mtime = $TEST_39_MTIME ] || \
3063 error "mtime($mtime) is not set to $TEST_39_MTIME"
3065 cancel_lru_locks osc
3066 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3069 run_test 39d "create, utime, stat =============================="
3073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3075 local mtime1=`stat -c %Y $DIR1/$tfile`
3077 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3079 for (( i=0; i < 2; i++ )) ; do
3080 local mtime2=`stat -c %Y $DIR1/$tfile`
3081 [ $mtime2 = $TEST_39_MTIME ] || \
3082 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3084 cancel_lru_locks osc
3085 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3088 run_test 39e "create, stat, utime, stat ========================"
3092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3094 mtime1=`stat -c %Y $DIR1/$tfile`
3097 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3099 for (( i=0; i < 2; i++ )) ; do
3100 local mtime2=`stat -c %Y $DIR1/$tfile`
3101 [ $mtime2 = $TEST_39_MTIME ] || \
3102 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3104 cancel_lru_locks osc
3105 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3108 run_test 39f "create, stat, sleep, utime, stat ================="
3112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3113 echo hello >> $DIR1/$tfile
3114 local mtime1=`stat -c %Y $DIR1/$tfile`
3117 chmod o+r $DIR1/$tfile
3119 for (( i=0; i < 2; i++ )) ; do
3120 local mtime2=`stat -c %Y $DIR1/$tfile`
3121 [ "$mtime1" = "$mtime2" ] || \
3122 error "lost mtime: $mtime2, should be $mtime1"
3124 cancel_lru_locks osc
3125 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3128 run_test 39g "write, chmod, stat ==============================="
3132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3137 echo hello >> $DIR1/$tfile
3138 local mtime1=`stat -c %Y $DIR1/$tfile`
3140 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3142 if [ "$d1" != "$d2" ]; then
3143 echo "write and touch not within one second"
3145 for (( i=0; i < 2; i++ )) ; do
3146 local mtime2=`stat -c %Y $DIR1/$tfile`
3147 [ "$mtime2" = $TEST_39_MTIME ] || \
3148 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3150 cancel_lru_locks osc
3151 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3155 run_test 39h "write, utime within one second, stat ============="
3158 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3162 echo hello >> $DIR1/$tfile
3163 local mtime1=`stat -c %Y $DIR1/$tfile`
3165 mv $DIR1/$tfile $DIR1/$tfile-1
3167 for (( i=0; i < 2; i++ )) ; do
3168 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3170 [ "$mtime1" = "$mtime2" ] || \
3171 error "lost mtime: $mtime2, should be $mtime1"
3173 cancel_lru_locks osc
3174 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3177 run_test 39i "write, rename, stat =============================="
3180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3181 start_full_debug_logging
3185 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3186 lctl set_param fail_loc=0x80000412
3187 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3188 error "multiop failed"
3190 local mtime1=`stat -c %Y $DIR1/$tfile`
3192 mv $DIR1/$tfile $DIR1/$tfile-1
3194 kill -USR1 $multipid
3195 wait $multipid || error "multiop close failed"
3197 for (( i=0; i < 2; i++ )) ; do
3198 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3199 [ "$mtime1" = "$mtime2" ] ||
3200 error "mtime is lost on close: $mtime2, " \
3203 cancel_lru_locks osc
3204 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3206 lctl set_param fail_loc=0
3207 stop_full_debug_logging
3209 run_test 39j "write, rename, close, stat ======================="
3212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3216 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3218 local mtime1=`stat -c %Y $DIR1/$tfile`
3220 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3222 kill -USR1 $multipid
3223 wait $multipid || error "multiop close failed"
3225 for (( i=0; i < 2; i++ )) ; do
3226 local mtime2=`stat -c %Y $DIR1/$tfile`
3228 [ "$mtime2" = $TEST_39_MTIME ] || \
3229 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3231 cancel_lru_locks osc
3232 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3235 run_test 39k "write, utime, close, stat ========================"
3237 # this should be set to future
3238 TEST_39_ATIME=`date -d "1 year" +%s`
3241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3242 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3243 local atime_diff=$(do_facet $SINGLEMDS \
3244 lctl get_param -n mdd.*MDT0000*.atime_diff)
3248 # test setting directory atime to future
3249 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3250 local atime=$(stat -c %X $DIR/$tdir)
3251 [ "$atime" = $TEST_39_ATIME ] || \
3252 error "atime is not set to future: $atime, $TEST_39_ATIME"
3254 # test setting directory atime from future to now
3255 local d1=$(date +%s)
3257 local d2=$(date +%s)
3259 cancel_lru_locks mdc
3260 atime=$(stat -c %X $DIR/$tdir)
3261 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3262 error "atime is not updated from future: $atime, $d1<atime<$d2"
3264 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3267 # test setting directory atime when now > dir atime + atime_diff
3271 cancel_lru_locks mdc
3272 atime=$(stat -c %X $DIR/$tdir)
3273 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3274 error "atime is not updated : $atime, should be $d2"
3276 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3279 # test not setting directory atime when now < dir atime + atime_diff
3281 cancel_lru_locks mdc
3282 atime=$(stat -c %X $DIR/$tdir)
3283 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3284 error "atime is updated to $atime, should remain $d1<atime<$d2"
3286 do_facet $SINGLEMDS \
3287 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3289 run_test 39l "directory atime update ==========================="
3292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3295 local far_past_mtime=$(date -d "May 29 1953" +%s)
3296 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3298 touch -m -d @$far_past_mtime $DIR1/$tfile
3299 touch -a -d @$far_past_atime $DIR1/$tfile
3301 for (( i=0; i < 2; i++ )) ; do
3302 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3303 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3304 error "atime or mtime set incorrectly"
3306 cancel_lru_locks osc
3307 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3310 run_test 39m "test atime and mtime before 1970"
3312 test_39n() { # LU-3832
3313 local atime_diff=$(do_facet $SINGLEMDS \
3314 lctl get_param -n mdd.*MDT0000*.atime_diff)
3319 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3322 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3323 atime0=$(stat -c %X $DIR/$tfile)
3326 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3327 atime1=$(stat -c %X $DIR/$tfile)
3330 cancel_lru_locks mdc
3331 cancel_lru_locks osc
3332 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3333 atime2=$(stat -c %X $DIR/$tfile)
3335 do_facet $SINGLEMDS \
3336 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3338 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3339 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3341 run_test 39n "check that O_NOATIME is honored"
3344 TESTDIR=$DIR/$tdir/$tfile
3345 [ -e $TESTDIR ] && rm -rf $TESTDIR
3346 test_mkdir -p $TESTDIR
3352 links2=$(stat -c %h .)
3353 [ $(($links1 + 2)) != $links2 ] &&
3354 error "wrong links count $(($links1 + 2)) != $links2"
3356 links3=$(stat -c %h .)
3357 [ $(($links1 + 1)) != $links3 ] &&
3358 error "wrong links count $links1 != $links3"
3361 run_test 39o "directory cached attributes updated after create ========"
3364 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3366 TESTDIR=$DIR/$tdir/$tfile
3367 [ -e $TESTDIR ] && rm -rf $TESTDIR
3372 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3373 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3375 links2=$(stat -c %h .)
3376 [ $(($links1 + 2)) != $links2 ] &&
3377 error "wrong links count $(($links1 + 2)) != $links2"
3379 links3=$(stat -c %h .)
3380 [ $(($links1 + 1)) != $links3 ] &&
3381 error "wrong links count $links1 != $links3"
3384 run_test 39p "remote directory cached attributes updated after create ========"
3388 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3389 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3390 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3391 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3392 error "$tfile is not 4096 bytes in size"
3394 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3398 small_write $DIR/f41 18
3400 run_test 41 "test small file write + fstat ====================="
3402 count_ost_writes() {
3403 lctl get_param -n osc.*.stats |
3404 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3405 END { printf("%0.0f", writes) }'
3412 BG_DIRTY_RATIO_SAVE=10
3413 MAX_BG_DIRTY_RATIO=25
3417 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3418 # dirty_ratio, dirty_background_ratio
3419 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3420 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3421 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3422 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3424 # if file not here, we are a 2.4 kernel
3425 kill -CONT `pidof kupdated`
3430 # setup the trap first, so someone cannot exit the test at the
3431 # exact wrong time and mess up a machine
3432 trap start_writeback EXIT
3433 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3434 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3435 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3436 sysctl -w vm.dirty_writeback_centisecs=0
3437 sysctl -w vm.dirty_writeback_centisecs=0
3438 # save and increase /proc/sys/vm/dirty_ratio
3439 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3440 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3441 # save and increase /proc/sys/vm/dirty_background_ratio
3442 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3443 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3445 # if file not here, we are a 2.4 kernel
3446 kill -STOP `pidof kupdated`
3450 # ensure that all stripes have some grant before we test client-side cache
3452 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3453 dd if=/dev/zero of=$i bs=4k count=1
3458 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3459 # file truncation, and file removal.
3461 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3463 cancel_lru_locks osc
3465 sync; sleep 1; sync # just to be safe
3466 BEFOREWRITES=`count_ost_writes`
3467 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3468 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3469 AFTERWRITES=`count_ost_writes`
3470 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3471 error "$BEFOREWRITES < $AFTERWRITES"
3474 run_test 42a "ensure that we don't flush on close =============="
3477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3479 cancel_lru_locks osc
3482 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3483 BEFOREWRITES=$(count_ost_writes)
3484 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3485 AFTERWRITES=$(count_ost_writes)
3486 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3487 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3489 BEFOREWRITES=$(count_ost_writes)
3490 sync || error "sync: $?"
3491 AFTERWRITES=$(count_ost_writes)
3492 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3493 error "$BEFOREWRITES < $AFTERWRITES on sync"
3495 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3499 run_test 42b "test destroy of file with cached dirty data ======"
3501 # if these tests just want to test the effect of truncation,
3502 # they have to be very careful. consider:
3503 # - the first open gets a {0,EOF}PR lock
3504 # - the first write conflicts and gets a {0, count-1}PW
3505 # - the rest of the writes are under {count,EOF}PW
3506 # - the open for truncate tries to match a {0,EOF}PR
3507 # for the filesize and cancels the PWs.
3508 # any number of fixes (don't get {0,EOF} on open, match
3509 # composite locks, do smarter file size management) fix
3510 # this, but for now we want these tests to verify that
3511 # the cancellation with truncate intent works, so we
3512 # start the file with a full-file pw lock to match against
3513 # until the truncate.
3518 cancel_lru_locks osc
3520 # prime the file with 0,EOF PW to match
3524 # now the real test..
3525 dd if=/dev/zero of=$file bs=1024 count=100
3526 BEFOREWRITES=`count_ost_writes`
3527 $TRUNCATE $file $offset
3528 cancel_lru_locks osc
3529 AFTERWRITES=`count_ost_writes`
3534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3536 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3537 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3540 run_test 42c "test partial truncate of file with cached dirty data"
3543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3545 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3546 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3549 run_test 42d "test complete truncate of file with cached dirty data"
3551 test_42e() { # bug22074
3552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3553 local TDIR=$DIR/${tdir}e
3554 local pagesz=$(page_size)
3555 local pages=16 # hardcoded 16 pages, don't change it.
3556 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3557 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3561 test_mkdir -p $DIR/${tdir}e
3562 $SETSTRIPE -c 1 $TDIR
3563 createmany -o $TDIR/f $files
3565 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3567 # we assume that with $OSTCOUNT files, at least one of them will
3568 # be allocated on OST0.
3569 warmup_files=$((OSTCOUNT * max_dirty_mb))
3570 createmany -o $TDIR/w $warmup_files
3572 # write a large amount of data into one file and sync, to get good
3573 # avail_grant number from OST.
3574 for ((i=0; i<$warmup_files; i++)); do
3575 idx=$($GETSTRIPE -i $TDIR/w$i)
3576 [ $idx -ne 0 ] && continue
3577 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3580 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3582 $LCTL get_param $proc_osc0/cur_dirty_bytes
3583 $LCTL get_param $proc_osc0/cur_grant_bytes
3585 # create as much dirty pages as we can while not to trigger the actual
3586 # RPCs directly. but depends on the env, VFS may trigger flush during this
3587 # period, hopefully we are good.
3588 for ((i=0; i<$warmup_files; i++)); do
3589 idx=$($GETSTRIPE -i $TDIR/w$i)
3590 [ $idx -ne 0 ] && continue
3591 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3593 $LCTL get_param $proc_osc0/cur_dirty_bytes
3594 $LCTL get_param $proc_osc0/cur_grant_bytes
3596 # perform the real test
3597 $LCTL set_param $proc_osc0/rpc_stats 0
3598 for ((;i<$files; i++)); do
3599 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3600 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3603 $LCTL get_param $proc_osc0/rpc_stats
3606 local have_ppr=false
3607 $LCTL get_param $proc_osc0/rpc_stats |
3608 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3609 # skip lines until we are at the RPC histogram data
3610 [ "$PPR" == "pages" ] && have_ppr=true && continue
3611 $have_ppr || continue
3613 # we only want the percent stat for < 16 pages
3614 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3616 percent=$((percent + WPCT))
3617 if [[ $percent -gt 15 ]]; then
3618 error "less than 16-pages write RPCs" \
3625 run_test 42e "verify sub-RPC writes are not done synchronously"
3628 test_mkdir -p $DIR/$tdir
3629 cp -p /bin/ls $DIR/$tdir/$tfile
3630 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3632 # give multiop a chance to open
3635 $DIR/$tdir/$tfile && error || true
3638 run_test 43 "execution of file opened for write should return -ETXTBSY"
3641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3642 test_mkdir -p $DIR/$tdir
3643 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3644 cp -p multiop $DIR/$tdir/multiop
3645 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3648 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3649 kill -USR1 $MULTIOP_PID || return 2
3650 wait $MULTIOP_PID || return 3
3651 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3653 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3657 test_mkdir -p $DIR/$tdir
3658 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3659 cp -p multiop $DIR/$tdir/multiop
3660 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3663 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3664 kill -USR1 $MULTIOP_PID || return 2
3665 wait $MULTIOP_PID || return 3
3666 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3668 run_test 43b "truncate of file being executed should return -ETXTBSY"
3671 local testdir="$DIR/$tdir"
3672 test_mkdir -p $DIR/$tdir
3674 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3675 ( cd $testdir && md5sum -c)
3677 run_test 43c "md5sum of copy into lustre========================"
3680 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3681 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3682 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3684 run_test 44 "zero length read from a sparse stripe ============="
3687 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3689 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3690 [[ $nstripe -gt $OSTCOUNT ]] &&
3691 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3693 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3695 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3696 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3700 OFFSETS="0 $((stride/2)) $((stride-1))"
3701 for offset in $OFFSETS; do
3702 for i in $(seq 0 $((nstripe-1))); do
3703 local GLOBALOFFSETS=""
3705 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3706 local myfn=$DIR/d44a-$size
3707 echo "--------writing $myfn at $size"
3708 ll_sparseness_write $myfn $size ||
3709 error "ll_sparseness_write"
3710 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3711 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3712 error "ll_sparseness_verify $GLOBALOFFSETS"
3714 for j in $(seq 0 $((nstripe-1))); do
3716 size=$((((j + $nstripe )*$stride + $offset)))
3717 ll_sparseness_write $myfn $size ||
3718 error "ll_sparseness_write"
3719 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3721 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3722 error "ll_sparseness_verify $GLOBALOFFSETS"
3727 run_test 44a "test sparse pwrite ==============================="
3731 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3737 before=`dirty_osc_total`
3738 echo executing "\"$*\""
3740 after=`dirty_osc_total`
3741 echo before $before, after $after
3744 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3746 # Obtain grants from OST if it supports it
3747 echo blah > ${f}_grant
3750 do_dirty_record "echo blah > $f"
3751 [[ $before -eq $after ]] && error "write wasn't cached"
3752 do_dirty_record "> $f"
3753 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3754 do_dirty_record "echo blah > $f"
3755 [[ $before -eq $after ]] && error "write wasn't cached"
3756 do_dirty_record "sync"
3757 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3758 do_dirty_record "echo blah > $f"
3759 [[ $before -eq $after ]] && error "write wasn't cached"
3760 do_dirty_record "cancel_lru_locks osc"
3761 [[ $before -gt $after ]] ||
3762 error "lock cancellation didn't lower dirty count"
3765 run_test 45 "osc io page accounting ============================"
3767 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3768 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3769 # objects offset and an assert hit when an rpc was built with 1023's mapped
3770 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3776 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3778 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3779 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3783 run_test 46 "dirtying a previously written page ================"
3785 # test_47 is removed "Device nodes check" is moved to test_28
3787 test_48a() { # bug 2399
3788 check_kernel_version 34 || return 0
3789 test_mkdir -p $DIR/$tdir
3791 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3792 test_mkdir $DIR/$tdir || error "recreate directory failed"
3793 touch foo || error "'touch foo' failed after recreating cwd"
3794 test_mkdir $DIR/$tdir/bar ||
3795 error "'mkdir foo' failed after recreating cwd"
3796 if check_kernel_version 44; then
3797 touch .foo || error "'touch .foo' failed after recreating cwd"
3798 test_mkdir $DIR/$tdir/.bar ||
3799 error "'mkdir .foo' failed after recreating cwd"
3801 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3802 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3803 cd . || error "'cd .' failed after recreating cwd"
3804 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3805 rmdir . && error "'rmdir .' worked after recreating cwd"
3806 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3807 cd .. || error "'cd ..' failed after recreating cwd"
3809 run_test 48a "Access renamed working dir (should return errors)="
3811 test_48b() { # bug 2399
3812 check_kernel_version 34 || return 0
3814 test_mkdir -p $DIR/$tdir
3816 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3817 touch foo && error "'touch foo' worked after removing cwd"
3818 test_mkdir $DIR/$tdir/foo &&
3819 error "'mkdir foo' worked after removing cwd"
3820 if check_kernel_version 44; then
3821 touch .foo && error "'touch .foo' worked after removing cwd"
3822 test_mkdir $DIR/$tdir/.foo &&
3823 error "'mkdir .foo' worked after removing cwd"
3825 ls . > /dev/null && error "'ls .' worked after removing cwd"
3826 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3827 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3828 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3829 rmdir . && error "'rmdir .' worked after removing cwd"
3830 ln -s . foo && error "'ln -s .' worked after removing cwd"
3831 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3833 run_test 48b "Access removed working dir (should return errors)="
3835 test_48c() { # bug 2350
3836 check_kernel_version 36 || return 0
3837 #lctl set_param debug=-1
3840 test_mkdir -p $DIR/$tdir/dir
3842 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3843 $TRACE touch foo && error "touch foo worked after removing cwd"
3844 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3845 if check_kernel_version 44; then
3846 touch .foo && error "touch .foo worked after removing cwd"
3847 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3849 $TRACE ls . && error "'ls .' worked after removing cwd"
3850 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3851 is_patchless || ( $TRACE cd . &&
3852 error "'cd .' worked after removing cwd" )
3853 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3854 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3855 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3856 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3858 run_test 48c "Access removed working subdir (should return errors)"
3860 test_48d() { # bug 2350
3861 check_kernel_version 36 || return 0
3862 #lctl set_param debug=-1
3865 test_mkdir -p $DIR/$tdir/dir
3867 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3868 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3869 $TRACE touch foo && error "'touch foo' worked after removing parent"
3870 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3871 if check_kernel_version 44; then
3872 touch .foo && error "'touch .foo' worked after removing parent"
3874 error "mkdir .foo worked after removing parent"
3876 $TRACE ls . && error "'ls .' worked after removing parent"
3877 $TRACE ls .. && error "'ls ..' worked after removing parent"
3878 is_patchless || ( $TRACE cd . &&
3879 error "'cd .' worked after recreate parent" )
3880 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3881 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3882 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3883 is_patchless || ( $TRACE cd .. &&
3884 error "'cd ..' worked after removing parent" || true )
3886 run_test 48d "Access removed parent subdir (should return errors)"
3888 test_48e() { # bug 4134
3889 check_kernel_version 41 || return 0
3890 #lctl set_param debug=-1
3893 test_mkdir -p $DIR/$tdir/dir
3895 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3896 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3897 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3898 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3899 # On a buggy kernel addition of "touch foo" after cd .. will
3900 # produce kernel oops in lookup_hash_it
3901 touch ../foo && error "'cd ..' worked after recreate parent"
3903 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3905 run_test 48e "Access to recreated parent subdir (should return errors)"
3907 test_49() { # LU-1030
3908 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3909 # get ost1 size - lustre-OST0000
3910 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3912 # write 800M at maximum
3913 [[ $ost1_size -lt 2 ]] && ost1_size=2
3914 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3916 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3917 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3920 # change max_pages_per_rpc while writing the file
3921 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3922 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3923 # loop until dd process exits
3924 while ps ax -opid | grep -wq $dd_pid; do
3925 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3926 sleep $((RANDOM % 5 + 1))
3928 # restore original max_pages_per_rpc
3929 $LCTL set_param $osc1_mppc=$orig_mppc
3930 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3932 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3936 test_mkdir $DIR/$tdir
3938 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3940 run_test 50 "special situations: /proc symlinks ==============="
3942 test_51a() { # was test_51
3943 # bug 1516 - create an empty entry right after ".." then split dir
3944 test_mkdir -c1 $DIR/$tdir
3945 touch $DIR/$tdir/foo
3946 $MCREATE $DIR/$tdir/bar
3948 createmany -m $DIR/$tdir/longfile 201
3950 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3951 $MCREATE $DIR/$tdir/longfile$FNUM
3956 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3958 run_test 51a "special situations: split htree with empty entry =="
3960 export NUMTEST=70000
3962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3963 local BASE=$DIR/d${base}.${TESTSUITE}
3965 # cleanup the directory
3968 test_mkdir -p -c1 $BASE
3970 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3971 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3972 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3975 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3976 echo "reduced count to $NUMTEST due to inodes"
3978 # need to check free space for the directories as well
3979 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3980 numfree=$((blkfree / 4))
3981 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3982 echo "reduced count to $NUMTEST due to blocks"
3984 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3985 echo "failed" > $BASE/fnum
3987 run_test 51b "exceed 64k subdirectory nlink limit"
3989 test_51ba() { # LU-993
3990 local BASE=$DIR/d${base}.${TESTSUITE}
3991 # unlink all but 100 subdirectories, then check it still works
3993 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3995 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3996 local DELETE=$((NUMTEST - LEFT))
3998 # continue on to run this test even if 51b didn't finish,
3999 # just to delete the many subdirectories created.
4000 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4002 # for ldiskfs the nlink count should be 1, but this is OSD specific
4003 # and so this is listed for informational purposes only
4004 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4005 unlinkmany -d $BASE/d $DELETE
4008 if [ $RC -ne 0 ]; then
4009 if [ "$NUMPREV" == "failed" ]; then
4010 skip "previous setup failed"
4013 error "unlink of first $DELETE subdirs failed"
4018 echo "nlink between: $(stat -c %h $BASE)"
4019 # trim the first line of ls output
4020 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4021 [ $FOUND -ne $LEFT ] &&
4022 error "can't find subdirs: found only $FOUND/$LEFT"
4024 unlinkmany -d $BASE/d $DELETE $LEFT ||
4025 error "unlink of second $LEFT subdirs failed"
4026 # regardless of whether the backing filesystem tracks nlink accurately
4027 # or not, the nlink count shouldn't be more than "." and ".." here
4028 local AFTER=$(stat -c %h $BASE)
4029 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4030 echo "nlink after: $AFTER"
4032 run_test 51ba "verify nlink for many subdirectory cleanup"
4035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4036 [[ $OSTCOUNT -lt 3 ]] &&
4037 skip_env "skipping test with few OSTs" && return
4038 test_mkdir -p $DIR/$tdir
4039 createmany -o $DIR/$tdir/t- 1000
4040 $GETSTRIPE $DIR/$tdir > $TMP/files
4041 for N in $(seq 0 $((OSTCOUNT - 1))); do
4042 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4043 END { printf("%0.0f", objs) }' $TMP/files)
4044 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4045 '($1 == '$N') { objs += 1 } \
4046 END { printf("%0.0f", objs) }')
4047 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4049 unlinkmany $DIR/$tdir/t- 1000
4052 for N in $(seq 1 $((OSTCOUNT - 1))); do
4053 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4054 error "OST $N has less objects vs OST $NLAST" \
4055 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4056 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4057 error "OST $N has less objects vs OST $NLAST" \
4058 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4060 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4061 error "OST $N has less #0 objects vs OST $NLAST" \
4062 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4063 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4064 error "OST $N has less #0 objects vs OST $NLAST" \
4065 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4069 run_test 51d "check object distribution ===================="
4072 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4073 skip "Only applicable to ldiskfs-based MDTs"
4077 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4078 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4080 touch $DIR/$tdir/d0/foo
4081 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4082 error "file exceed 65000 nlink limit!"
4083 unlinkmany $DIR/$tdir/d0/f- 65001
4086 run_test 51e "check file nlink limit"
4089 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4090 test_mkdir -p $DIR/$tdir
4091 touch $DIR/$tdir/foo
4092 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4093 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4094 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4095 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4096 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4098 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4099 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4100 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4102 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4103 cp -r $DIR/$tdir /tmp/
4104 rm -fr $DIR/$tdir || error "cleanup rm failed"
4106 run_test 52a "append-only flag test (should return errors) ====="
4109 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4110 test_mkdir -p $DIR/$tdir
4111 touch $DIR/$tdir/foo
4112 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4113 cat test > $DIR/$tdir/foo && error "cat test worked"
4114 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4115 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4116 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4118 echo foo >> $DIR/$tdir/foo && error "echo worked"
4119 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4120 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4121 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4122 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4124 chattr -i $DIR/$tdir/foo || error "chattr failed"
4126 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4128 run_test 52b "immutable flag test (should return errors) ======="
4131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4132 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4133 remote_ost_nodsh && skip "remote OST with nodsh" && return
4146 local support_last_seq=true
4148 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4149 support_last_seq=false
4152 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4154 for value in $(do_facet $SINGLEMDS \
4155 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4156 param=$(echo ${value[0]} | cut -d "=" -f1)
4157 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4159 if $support_last_seq; then
4160 param_seq=$(echo $param |
4161 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4162 mds_last_seq=$(do_facet $SINGLEMDS \
4163 $LCTL get_param -n $param_seq)
4165 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4167 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4168 node=$(facet_active_host ost$((ostnum+1)))
4169 param="obdfilter.$ostname.last_id"
4170 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4171 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4172 ost_last_id=$ost_last
4174 if $support_last_seq; then
4175 ost_last_id=$(echo $ost_last |
4176 awk -F':' '{print $2}' |
4178 ost_last_seq=$(echo $ost_last |
4179 awk -F':' '{print $1}')
4180 [[ $ost_last_seq = $mds_last_seq ]] || continue
4183 if [[ $ost_last_id != $mds_last ]]; then
4184 error "$ost_last_id != $mds_last"
4191 $found || error "can not match last_seq/last_id for $mdtosc"
4194 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4197 $SOCKETSERVER $DIR/socket ||
4198 error "$SOCKETSERVER $DIR/socket failed: $?"
4199 $SOCKETCLIENT $DIR/socket ||
4200 error "$SOCKETCLIENT $DIR/socket failed: $?"
4201 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4203 run_test 54a "unix domain socket test =========================="
4209 dd if=/dev/zero of=$f bs=$(page_size) count=1
4211 run_test 54b "char device works in lustre ======================"
4214 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4215 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4216 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4218 for i in $(seq 3 7); do
4219 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4227 loopdev="$DIR/loop54c"
4230 $UMOUNT -d $DIR/$tdir || rc=$?
4231 losetup -d $loopdev || true
4232 losetup -d $LOOPDEV || true
4233 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4239 loopdev="$DIR/loop54c"
4242 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4243 trap cleanup_54c EXIT
4244 mknod $loopdev b 7 $LOOPNUM
4245 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4246 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4247 losetup $loopdev $DIR/$tfile ||
4248 error "can't set up $loopdev for $DIR/$tfile"
4249 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4250 test_mkdir -p $DIR/$tdir
4251 mount -t ext2 $loopdev $DIR/$tdir ||
4252 error "error mounting $loopdev on $DIR/$tdir"
4253 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4256 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4260 run_test 54c "block device works in lustre ====================="
4266 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4268 run_test 54d "fifo device works in lustre ======================"
4271 check_kernel_version 46 || return 0
4274 cp -aL /dev/console $f
4275 echo $string > $f || error "echo $string to $f failed"
4277 run_test 54e "console/tty device works in lustre ======================"
4279 #The test_55 used to be iopen test and it was removed by bz#24037.
4280 #run_test 55 "check iopen_connect_dentry() ======================"
4282 test_56a() { # was test_56
4285 test_mkdir -p $DIR/$tdir/dir
4287 NUMFILESx2=$(($NUMFILES * 2))
4288 for i in $(seq 1 $NUMFILES); do
4289 touch $DIR/$tdir/file$i
4290 touch $DIR/$tdir/dir/file$i
4293 # test lfs getstripe with --recursive
4294 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4295 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4296 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4297 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4298 [[ $FILENUM -eq $NUMFILES ]] ||
4299 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4300 echo "$GETSTRIPE --recursive passed."
4302 # test lfs getstripe with file instead of dir
4303 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4304 [[ $FILENUM -eq 1 ]] ||
4305 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4306 echo "$GETSTRIPE file1 passed."
4308 #test lfs getstripe with --verbose
4309 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4310 grep -c lmm_magic) -eq $NUMFILES ]] ||
4311 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4312 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4313 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4314 echo "$GETSTRIPE --verbose passed."
4316 #test lfs getstripe with --obd
4317 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4318 grep -q "unknown obduuid" ||
4319 error "$GETSTRIPE --obd wrong_uuid should return error message"
4321 [[ $OSTCOUNT -lt 2 ]] &&
4322 skip_env "skipping other $GETSTRIPE --obd test" && return
4325 OBDUUID=$(ostuuid_from_index $OSTIDX)
4326 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4327 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4328 [[ $FOUND -eq $FILENUM ]] ||
4329 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4330 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4331 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4332 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4333 error "$GETSTRIPE --obd: should not show file on other obd"
4334 echo "$GETSTRIPE --obd passed"
4336 run_test 56a "check $GETSTRIPE"
4341 local LOCAL_NUMFILES="$1"
4342 local LOCAL_NUMDIRS="$2"
4343 local MKDIR_PARAMS="$3"
4344 local DIR_STRIPE_PARAMS="$4"
4346 if [ ! -d "$TDIR" ] ; then
4347 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4348 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4349 for i in `seq 1 $LOCAL_NUMFILES` ; do
4352 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4353 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4354 for j in `seq 1 $LOCAL_NUMFILES` ; do
4355 touch $TDIR/dir$i/file$j
4361 setup_56_special() {
4365 if [ ! -e "$TDIR/loop1b" ] ; then
4366 for i in `seq 1 $LOCAL_NUMFILES` ; do
4367 mknod $TDIR/loop${i}b b 7 $i
4368 mknod $TDIR/null${i}c c 1 3
4369 ln -s $TDIR/file1 $TDIR/link${i}l
4371 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4372 mknod $TDIR/dir$i/loop${i}b b 7 $i
4373 mknod $TDIR/dir$i/null${i}c c 1 3
4374 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4383 setup_56 $NUMFILES $NUMDIRS
4385 EXPECTED=$(($NUMDIRS + 2))
4386 # test lfs find with -name
4387 for i in $(seq 1 $NUMFILES) ; do
4388 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4389 [ $NUMS -eq $EXPECTED ] ||
4390 error "lfs find -name \"*$i\" $TDIR wrong: "\
4391 "found $NUMS, expected $EXPECTED"
4394 run_test 56g "check lfs find -name ============================="
4400 setup_56 $NUMFILES $NUMDIRS
4402 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4403 # test lfs find with ! -name
4404 for i in $(seq 1 $NUMFILES) ; do
4405 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4406 [ $NUMS -eq $EXPECTED ] ||
4407 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4408 "found $NUMS, expected $EXPECTED"
4411 run_test 56h "check lfs find ! -name ============================="
4415 test_mkdir -p $DIR/$tdir
4416 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4417 CMD="$LFIND -ost $UUID $DIR/$tdir"
4419 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4421 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4425 setup_56_special $NUMFILES $NUMDIRS
4427 EXPECTED=$((NUMDIRS + 1))
4428 CMD="$LFIND -type d $TDIR"
4429 NUMS=$($CMD | wc -l)
4430 [ $NUMS -eq $EXPECTED ] ||
4431 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4433 run_test 56j "check lfs find -type d ============================="
4437 setup_56_special $NUMFILES $NUMDIRS
4439 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4440 CMD="$LFIND -type f $TDIR"
4441 NUMS=$($CMD | wc -l)
4442 [ $NUMS -eq $EXPECTED ] ||
4443 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4445 run_test 56k "check lfs find -type f ============================="
4449 setup_56_special $NUMFILES $NUMDIRS
4451 EXPECTED=$((NUMDIRS + NUMFILES))
4452 CMD="$LFIND -type b $TDIR"
4453 NUMS=$($CMD | wc -l)
4454 [ $NUMS -eq $EXPECTED ] ||
4455 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4457 run_test 56l "check lfs find -type b ============================="
4461 setup_56_special $NUMFILES $NUMDIRS
4463 EXPECTED=$((NUMDIRS + NUMFILES))
4464 CMD="$LFIND -type c $TDIR"
4465 NUMS=$($CMD | wc -l)
4466 [ $NUMS -eq $EXPECTED ] ||
4467 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4469 run_test 56m "check lfs find -type c ============================="
4473 setup_56_special $NUMFILES $NUMDIRS
4475 EXPECTED=$((NUMDIRS + NUMFILES))
4476 CMD="$LFIND -type l $TDIR"
4477 NUMS=$($CMD | wc -l)
4478 [ $NUMS -eq $EXPECTED ] ||
4479 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4481 run_test 56n "check lfs find -type l ============================="
4485 setup_56 $NUMFILES $NUMDIRS
4486 utime $TDIR/file1 > /dev/null || error "utime (1)"
4487 utime $TDIR/file2 > /dev/null || error "utime (2)"
4488 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4489 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4490 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4491 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4494 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4495 [ $NUMS -eq $EXPECTED ] || \
4496 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4499 CMD="$LFIND -mtime 0 $TDIR"
4500 NUMS=$($CMD | wc -l)
4501 [ $NUMS -eq $EXPECTED ] ||
4502 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4504 run_test 56o "check lfs find -mtime for old files =========================="
4507 [ $RUNAS_ID -eq $UID ] &&
4508 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4511 setup_56 $NUMFILES $NUMDIRS
4513 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4515 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4516 NUMS=$($CMD | wc -l)
4517 [ $NUMS -eq $EXPECTED ] || \
4518 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4520 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4521 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4522 NUMS=$($CMD | wc -l)
4523 [ $NUMS -eq $EXPECTED ] || \
4524 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4526 run_test 56p "check lfs find -uid and ! -uid ==============================="
4529 [ $RUNAS_ID -eq $UID ] &&
4530 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4533 setup_56 $NUMFILES $NUMDIRS
4535 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4538 CMD="$LFIND -gid $RUNAS_GID $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 ! -gid $RUNAS_GID $TDIR"
4545 NUMS=$($CMD | wc -l)
4546 [ $NUMS -eq $EXPECTED ] ||
4547 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 run_test 56q "check lfs find -gid and ! -gid ==============================="
4553 setup_56 $NUMFILES $NUMDIRS
4556 CMD="$LFIND -size 0 -type f $TDIR"
4557 NUMS=$($CMD | wc -l)
4558 [ $NUMS -eq $EXPECTED ] ||
4559 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4561 CMD="$LFIND ! -size 0 -type f $TDIR"
4562 NUMS=$($CMD | wc -l)
4563 [ $NUMS -eq $EXPECTED ] ||
4564 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4565 echo "test" > $TDIR/$tfile
4566 echo "test2" > $TDIR/$tfile.2 && sync
4568 CMD="$LFIND -size 5 -type f $TDIR"
4569 NUMS=$($CMD | wc -l)
4570 [ $NUMS -eq $EXPECTED ] ||
4571 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4573 CMD="$LFIND -size +5 -type f $TDIR"
4574 NUMS=$($CMD | wc -l)
4575 [ $NUMS -eq $EXPECTED ] ||
4576 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4578 CMD="$LFIND -size +0 -type f $TDIR"
4579 NUMS=$($CMD | wc -l)
4580 [ $NUMS -eq $EXPECTED ] ||
4581 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4583 CMD="$LFIND ! -size -5 -type f $TDIR"
4584 NUMS=$($CMD | wc -l)
4585 [ $NUMS -eq $EXPECTED ] ||
4586 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4588 CMD="$LFIND -size -5 -type f $TDIR"
4589 NUMS=$($CMD | wc -l)
4590 [ $NUMS -eq $EXPECTED ] ||
4591 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4593 run_test 56r "check lfs find -size works =========================="
4595 test_56s() { # LU-611
4597 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4599 if [[ $OSTCOUNT -gt 1 ]]; then
4600 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4604 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4608 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4609 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4610 NUMS=$($CMD | wc -l)
4611 [ $NUMS -eq $EXPECTED ] || {
4613 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4616 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4617 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4618 NUMS=$($CMD | wc -l)
4619 [ $NUMS -eq $EXPECTED ] || {
4621 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4625 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4626 NUMS=$($CMD | wc -l)
4627 [ $NUMS -eq $EXPECTED ] || {
4629 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4632 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4633 NUMS=$($CMD | wc -l)
4634 [ $NUMS -eq $EXPECTED ] || {
4636 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4640 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4641 NUMS=$($CMD | wc -l)
4642 [ $NUMS -eq $EXPECTED ] || {
4644 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4647 run_test 56s "check lfs find -stripe-count works"
4649 test_56t() { # LU-611
4651 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4653 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4655 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4656 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4657 NUMS=$($CMD | wc -l)
4658 [ $NUMS -eq $EXPECTED ] ||
4659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4661 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4662 NUMS=$($CMD | wc -l)
4663 [ $NUMS -eq $EXPECTED ] ||
4664 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4666 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4667 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4668 NUMS=$($CMD | wc -l)
4669 [ $NUMS -eq $EXPECTED ] ||
4670 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4672 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4673 NUMS=$($CMD | wc -l)
4674 [ $NUMS -eq $EXPECTED ] ||
4675 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4678 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4679 NUMS=$($CMD | wc -l)
4680 [ $NUMS -eq $EXPECTED ] ||
4681 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4683 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4684 NUMS=$($CMD | wc -l)
4685 [ $NUMS -eq $EXPECTED ] ||
4686 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4689 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4690 NUMS=$($CMD | wc -l)
4691 [ $NUMS -eq $EXPECTED ] ||
4692 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4694 run_test 56t "check lfs find -stripe-size works"
4696 test_56u() { # LU-611
4698 setup_56 $NUMFILES $NUMDIRS "-i 0"
4700 if [[ $OSTCOUNT -gt 1 ]]; then
4701 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4707 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4708 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4709 NUMS=$($CMD | wc -l)
4710 [ $NUMS -eq $EXPECTED ] ||
4711 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4714 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4715 NUMS=$($CMD | wc -l)
4716 [ $NUMS -eq $EXPECTED ] ||
4717 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4719 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4720 NUMS=$($CMD | wc -l)
4721 [ $NUMS -eq $EXPECTED ] ||
4722 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4725 # This should produce an error and not return any files
4726 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4727 NUMS=$($CMD 2>/dev/null | wc -l)
4728 [ $NUMS -eq $EXPECTED ] ||
4729 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4731 if [[ $OSTCOUNT -gt 1 ]]; then
4732 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4733 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4734 NUMS=$($CMD | wc -l)
4735 [ $NUMS -eq $EXPECTED ] ||
4736 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4739 run_test 56u "check lfs find -stripe-index works"
4746 setup_56 $NUMFILES $NUMDIRS
4748 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4749 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4751 for file in $($LFIND -mdt $UUID $TDIR); do
4752 file_mdt_idx=$($GETSTRIPE -M $file)
4753 [ $file_mdt_idx -eq $MDT_IDX ] ||
4754 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4757 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4759 # Get and check the actual stripe count of one file.
4760 # Usage: check_stripe_count <file> <expected_stripe_count>
4761 check_stripe_count() {
4766 [[ -z "$file" || -z "$expected" ]] &&
4767 error "check_stripe_count: invalid argument!"
4769 local cmd="$GETSTRIPE -c $file"
4770 actual=$($cmd) || error "$cmd failed"
4771 actual=${actual%% *}
4773 if [[ $actual -ne $expected ]]; then
4774 [[ $expected -eq -1 ]] ||
4775 error "$cmd wrong: found $actual, expected $expected"
4776 [[ $actual -eq $OSTCOUNT ]] ||
4777 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4785 rm -rf $TDIR || error "remove $TDIR failed"
4786 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4789 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4790 error "$GETSTRIPE -S -d $TDIR failed"
4791 stripe_size=${stripe_size%% *}
4793 local file_size=$((stripe_size * OSTCOUNT))
4794 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4795 local required_space=$((file_num * file_size))
4796 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4797 [[ $free_space -le $((required_space / 1024)) ]] &&
4798 skip_env "need at least $required_space bytes free space," \
4799 "have $free_space kbytes" && return
4802 local dd_count=$((file_size / dd_bs))
4804 # write data into the files
4808 for i in $(seq 1 $NUMFILES); do
4810 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4811 error "write data into $file failed"
4813 for i in $(seq 1 $NUMDIRS); do
4814 for j in $(seq 1 $NUMFILES); do
4815 file=$TDIR/dir$i/file$j
4816 yes | dd bs=$dd_bs count=$dd_count of=$file \
4818 error "write data into $file failed"
4823 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4826 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4828 eval $cmd || error "$cmd failed"
4830 check_stripe_count $TDIR/file1 $expected
4833 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4835 eval $cmd || error "$cmd failed"
4837 for j in $(seq 1 $NUMFILES); do
4838 check_stripe_count $TDIR/dir1/file$j $expected
4841 # lfs_migrate works with lfs find
4842 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4843 $LFS_MIGRATE -y -c $expected"
4845 eval $cmd || error "$cmd failed"
4847 for i in $(seq 2 $NUMFILES); do
4848 check_stripe_count $TDIR/file$i $expected
4850 for i in $(seq 2 $NUMDIRS); do
4851 for j in $(seq 1 $NUMFILES); do
4852 check_stripe_count $TDIR/dir$i/file$j $expected
4856 run_test 56w "check lfs_migrate -c stripe_count works"
4859 check_swap_layouts_support && return 0
4860 [[ $OSTCOUNT -lt 2 ]] &&
4861 skip_env "need 2 OST, skipping test" && return
4863 local dir0=$DIR/$tdir/$testnum
4864 mkdir -p $dir0 || error "creating dir $dir0"
4866 local ref1=/etc/passwd
4867 local file1=$dir0/file1
4869 $SETSTRIPE -c 2 $file1
4871 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4872 stripe=$($GETSTRIPE -c $file1)
4873 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4874 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4879 run_test 56x "lfs migration support"
4882 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4883 skip "No HSM support on MDS of $(get_lustre_version)," \
4884 "need 2.4.53 at least" && return
4887 local dir0=$DIR/$tdir/$testnum
4888 mkdir -p $dir0 || error "creating dir $dir0"
4889 local f1=$dir0/file1
4890 local f2=$dir0/file2
4892 touch $f1 || error "creating std file $f1"
4893 $MULTIOP $f2 H2c || error "creating released file $f2"
4895 # a directory can be raid0, so ask only for files
4896 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4897 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4899 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4900 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4902 # only files can be released, so no need to force file search
4903 res=$($LFIND $dir0 -L released)
4904 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4906 res=$($LFIND $dir0 \! -L released)
4907 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4910 run_test 56y "lfs find -L raid0|released"
4912 test_56z() { # LU-4824
4913 # This checks to make sure 'lfs find' continues after errors
4914 # There are two classes of errors that should be caught:
4915 # - If multiple paths are provided, all should be searched even if one
4917 # - If errors are encountered during the search, it should not terminate
4920 test_mkdir $DIR/$tdir
4921 for i in d{0..9}; do
4922 test_mkdir $DIR/$tdir/$i
4924 touch $DIR/$tdir/d{0..9}/$tfile
4925 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4926 error "$LFS find did not return an error"
4927 # Make a directory unsearchable. This should NOT be the last entry in
4928 # directory order. Arbitrarily pick the 6th entry
4929 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
4930 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4931 # The user should be able to see 10 directories and 9 files
4932 [ $count == 19 ] || error "$LFS find did not continue after error"
4934 run_test 56z "lfs find should continue after an error"
4937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4938 # note test will not do anything if MDS is not local
4939 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4940 skip "Only applicable to ldiskfs-based MDTs"
4944 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4945 local MNTDEV="osd*.*MDT*.mntdev"
4946 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4947 [ -z "$DEV" ] && error "can't access $MNTDEV"
4948 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4949 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4950 error "can't access $DEV"
4951 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4952 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4956 run_test 57a "verify MDS filesystem created with large inodes =="
4959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4960 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4961 skip "Only applicable to ldiskfs-based MDTs"
4965 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4970 local FILEN=$dir/f$FILECOUNT
4972 rm -rf $dir || error "removing $dir"
4973 test_mkdir -p $dir || error "creating $dir"
4974 local num=$(get_mds_dir $dir)
4977 echo "mcreating $FILECOUNT files"
4978 createmany -m $dir/f 1 $FILECOUNT || \
4979 error "creating files in $dir"
4981 # verify that files do not have EAs yet
4982 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4983 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4987 df $dir #make sure we get new statfs data
4988 local MDSFREE=$(do_facet $mymds \
4989 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4990 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4991 echo "opening files to create objects/EAs"
4993 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4994 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4997 # verify that files have EAs now
4998 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4999 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5001 sleep 1 #make sure we get new statfs data
5003 local MDSFREE2=$(do_facet $mymds \
5004 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
5005 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5006 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5007 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5008 error "MDC before $MDCFREE != after $MDCFREE2"
5010 echo "MDC before $MDCFREE != after $MDCFREE2"
5011 echo "unable to confirm if MDS has large inodes"
5016 run_test 57b "default LOV EAs are stored inside large inodes ==="
5019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5020 [ -z "$(which wiretest 2>/dev/null)" ] &&
5021 skip_env "could not find wiretest" && return
5024 run_test 58 "verify cross-platform wire constants =============="
5027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5028 echo "touch 130 files"
5029 createmany -o $DIR/f59- 130
5031 unlinkmany $DIR/f59- 130
5033 # wait for commitment of removal
5034 wait_delete_completed
5036 run_test 59 "verify cancellation of llog records async ========="
5038 TEST60_HEAD="test_60 run $RANDOM"
5040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5041 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5042 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5043 skip_env "missing subtest run-llog.sh" && return
5044 log "$TEST60_HEAD - from kernel mode"
5045 do_facet mgs sh run-llog.sh
5047 run_test 60a "llog sanity tests run from kernel module =========="
5049 test_60b() { # bug 6411
5050 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5052 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5064 [[ $LLOG_COUNT -gt 50 ]] &&
5065 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5067 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5071 echo "create 5000 files"
5072 createmany -o $DIR/f60c- 5000
5073 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5074 lctl set_param fail_loc=0x80000137
5075 unlinkmany $DIR/f60c- 5000
5076 lctl set_param fail_loc=0
5078 run_test 60c "unlink file when mds full"
5081 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5082 SAVEPRINTK=$(lctl get_param -n printk)
5084 # verify "lctl mark" is even working"
5085 MESSAGE="test message ID $RANDOM $$"
5086 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5087 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5089 lctl set_param printk=0 || error "set lnet.printk failed"
5090 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5091 MESSAGE="new test message ID $RANDOM $$"
5092 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5093 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5094 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5096 lctl set_param -n printk="$SAVEPRINTK"
5098 run_test 60d "test printk console message masking"
5101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5103 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5104 cancel_lru_locks osc
5105 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5108 run_test 61 "mmap() writes don't make sync hang ================"
5110 # bug 2330 - insufficient obd_match error checking causes LBUG
5112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5115 cancel_lru_locks osc
5116 lctl set_param fail_loc=0x405
5117 cat $f && error "cat succeeded, expect -EIO"
5118 lctl set_param fail_loc=0
5120 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5121 # match every page all of the time.
5122 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5124 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5125 # Though this test is irrelevant anymore, it helped to reveal some
5126 # other grant bugs (LU-4482), let's keep it.
5127 test_63a() { # was test_63
5128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5129 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5130 for i in `seq 10` ; do
5131 dd if=/dev/zero of=$DIR/f63 bs=8k &
5137 rm -f $DIR/f63 || true
5139 run_test 63a "Verify oig_wait interruption does not crash ======="
5141 # bug 2248 - async write errors didn't return to application on sync
5142 # bug 3677 - async write errors left page locked
5144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5146 lctl set_param debug=-1
5148 # ensure we have a grant to do async writes
5149 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5152 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5153 lctl set_param fail_loc=0x80000406
5154 $MULTIOP $DIR/$tfile Owy && \
5155 error "sync didn't return ENOMEM"
5156 sync; sleep 2; sync # do a real sync this time to flush page
5157 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5158 error "locked page left in cache after async error" || true
5161 run_test 63b "async write errors should be returned to fsync ==="
5164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5166 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5168 run_test 64a "verify filter grant calculations (in kernel) ====="
5171 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5172 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5174 run_test 64b "check out-of-space detection on client ==========="
5177 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5179 run_test 64c "verify grant shrink ========================------"
5181 # bug 1414 - set/get directories' stripe info
5183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5184 test_mkdir -p $DIR/$tdir
5186 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5188 run_test 65a "directory with no stripe info ===================="
5191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5192 test_mkdir -p $DIR/$tdir
5193 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5196 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5198 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5202 if [[ $OSTCOUNT -gt 1 ]]; then
5203 test_mkdir -p $DIR/$tdir
5204 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5205 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5207 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5210 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5213 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5214 test_mkdir -p $DIR/$tdir
5215 if [[ $STRIPECOUNT -le 0 ]]; then
5217 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5218 #LOV_MAX_STRIPE_COUNT is 2000
5219 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5221 sc=$(($STRIPECOUNT - 1))
5223 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5224 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5225 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5226 error "lverify failed"
5228 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5232 test_mkdir -p $DIR/$tdir
5234 $SETSTRIPE $DIR/$tdir || error "setstripe"
5235 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5236 error "no stripe info failed"
5238 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5240 run_test 65e "directory setstripe defaults ======================="
5243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5244 test_mkdir -p $DIR/${tdir}f
5245 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5247 run_test 65f "dir setstripe permission (should return error) ==="
5250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5251 test_mkdir -p $DIR/$tdir
5252 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5254 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5255 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5256 error "delete default stripe failed"
5258 run_test 65g "directory setstripe -d ==========================="
5261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5262 test_mkdir -p $DIR/$tdir
5263 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5265 test_mkdir -p $DIR/$tdir/dd1
5266 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5267 error "stripe info inherit failed"
5269 run_test 65h "directory stripe info inherit ===================="
5271 test_65i() { # bug6367
5272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5273 $SETSTRIPE -S 65536 -c -1 $MOUNT
5275 run_test 65i "set non-default striping on root directory (bug 6367)="
5277 test_65ia() { # bug12836
5278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5279 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5281 run_test 65ia "getstripe on -1 default directory striping"
5283 test_65ib() { # bug12836
5284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5285 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5287 run_test 65ib "getstripe -v on -1 default directory striping"
5289 test_65ic() { # bug12836
5290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5291 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5293 run_test 65ic "new find on -1 default directory striping"
5295 test_65j() { # bug6367
5296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5298 # if we aren't already remounting for each test, do so for this test
5299 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5300 cleanup || error "failed to unmount"
5303 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5305 run_test 65j "set default striping on root directory (bug 6367)="
5307 test_65k() { # bug11679
5308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5309 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5310 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5312 echo "Check OST status: "
5313 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5314 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5316 for OSC in $MDS_OSCS; do
5317 echo $OSC "is activate"
5318 do_facet $SINGLEMDS lctl --device %$OSC activate
5322 for INACTIVE_OSC in $MDS_OSCS; do
5323 echo "Deactivate: " $INACTIVE_OSC
5324 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5325 for STRIPE_OSC in $MDS_OSCS; do
5326 OST=`osc_to_ost $STRIPE_OSC`
5327 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5328 awk -F: /$OST/'{ print $1 }' | head -n 1`
5330 [ -f $DIR/$tdir/$IDX ] && continue
5331 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5332 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5334 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5337 echo $INACTIVE_OSC "is Activate."
5338 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5341 run_test 65k "validate manual striping works properly with deactivated OSCs"
5343 test_65l() { # bug 12836
5344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5345 test_mkdir -p $DIR/$tdir/test_dir
5346 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5347 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5349 run_test 65l "lfs find on -1 stripe dir ========================"
5351 # bug 2543 - update blocks count on client
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5355 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5356 sync; sync_all_data; sync; sync_all_data
5357 cancel_lru_locks osc
5358 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5359 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5361 run_test 66 "update inode blocks count on client ==============="
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5368 if [ ! -z "$LLOOP" ]; then
5369 if swapon -s | grep -q $LLOOP; then
5370 swapoff $LLOOP || error "swapoff failed"
5373 $LCTL blockdev_detach $LLOOP || error "detach failed"
5377 if [ ! -z "$LLITELOOPLOAD" ]; then
5385 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5389 swapon -s | awk '($1 == "'$1'") { print $4 }'
5392 # test case for lloop driver, basic function
5394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5395 [ "$UID" != 0 ] && skip_env "must run as root" && return
5396 llite_lloop_enabled || \
5397 { skip_env "llite_lloop module disabled" && return; }
5399 trap cleanup_68 EXIT
5401 if ! module_loaded llite_lloop; then
5402 if load_module llite/llite_lloop; then
5405 skip_env "can't find module llite_lloop"
5410 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5411 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5412 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5414 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5415 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5419 run_test 68a "lloop driver - basic test ========================"
5421 # excercise swapping to lustre by adding a high priority swapfile entry
5422 # and then consuming memory until it is used.
5423 test_68b() { # was test_68
5424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5425 [ "$UID" != 0 ] && skip_env "must run as root" && return
5426 lctl get_param -n devices | grep -q obdfilter && \
5427 skip "local OST" && return
5429 grep -q llite_lloop /proc/modules
5430 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5432 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5433 skip "can't reliably test swap with TCP" && return
5435 MEMTOTAL=`meminfo MemTotal`
5436 NR_BLOCKS=$((MEMTOTAL>>8))
5437 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5439 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5440 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5443 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5445 trap cleanup_68 EXIT
5447 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5449 echo "before: `swapon -s | grep $LLOOP`"
5450 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5451 echo "after: `swapon -s | grep $LLOOP`"
5452 SWAPUSED=`swap_used $LLOOP`
5456 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5458 run_test 68b "support swapping to Lustre ========================"
5460 # bug5265, obdfilter oa2dentry return -ENOENT
5461 # #define OBD_FAIL_OST_ENOENT 0x217
5463 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5464 remote_ost_nodsh && skip "remote OST with nodsh" && return
5467 $SETSTRIPE -c 1 -i 0 $f
5469 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5471 do_facet ost1 lctl set_param fail_loc=0x217
5472 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5473 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5475 do_facet ost1 lctl set_param fail_loc=0
5476 $DIRECTIO write $f 0 2 || error "write error"
5478 cancel_lru_locks osc
5479 $DIRECTIO read $f 0 1 || error "read error"
5481 do_facet ost1 lctl set_param fail_loc=0x217
5482 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5484 do_facet ost1 lctl set_param fail_loc=0
5487 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5490 test_mkdir -p $DIR/$tdir
5491 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5493 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5495 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5497 [ "$RUNAS_ID" = "$UID" ] &&
5498 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5500 # Check that testing environment is properly set up. Skip if not
5501 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5502 skip_env "User $RUNAS_ID does not exist - skipping"
5506 chmod 777 $DIR/$tfile
5507 chmod ug+s $DIR/$tfile
5508 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5509 error "$RUNAS dd $DIR/$tfile failed"
5510 # See if we are still setuid/sgid
5511 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5512 error "S/gid is not dropped on write"
5513 # Now test that MDS is updated too
5514 cancel_lru_locks mdc
5515 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5516 error "S/gid is not dropped on MDS"
5519 run_test 72a "Test that remove suid works properly (bug5695) ===="
5521 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5524 [ "$RUNAS_ID" = "$UID" ] && \
5525 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5526 [ "$RUNAS_ID" -eq 0 ] && \
5527 skip_env "RUNAS_ID = 0 -- skipping" && return
5529 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5530 # Check that testing environment is properly set up. Skip if not
5531 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5532 skip_env "User $RUNAS_ID does not exist - skipping"
5535 touch $DIR/${tfile}-f{g,u}
5536 test_mkdir $DIR/${tfile}-dg
5537 test_mkdir $DIR/${tfile}-du
5538 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5539 chmod g+s $DIR/${tfile}-{f,d}g
5540 chmod u+s $DIR/${tfile}-{f,d}u
5541 for perm in 777 2777 4777; do
5542 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5543 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5544 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5545 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5549 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5551 # bug 3462 - multiple simultaneous MDC requests
5553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5554 test_mkdir $DIR/d73-1
5555 test_mkdir $DIR/d73-2
5556 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5559 lctl set_param fail_loc=0x80000129
5560 $MULTIOP $DIR/d73-1/f73-2 Oc &
5562 lctl set_param fail_loc=0
5564 $MULTIOP $DIR/d73-2/f73-3 Oc &
5568 wait $pid1 || return 1
5572 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5573 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5574 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5578 run_test 73 "multiple MDC requests (should not deadlock)"
5580 test_74a() { # bug 6149, 6184
5581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5582 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5584 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5585 # will spin in a tight reconnection loop
5587 $LCTL set_param fail_loc=0x8000030e
5588 # get any lock that won't be difficult - lookup works.
5590 $LCTL set_param fail_loc=0
5594 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5596 test_74b() { # bug 13310
5597 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5598 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5600 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5601 # will spin in a tight reconnection loop
5602 $LCTL set_param fail_loc=0x8000030e
5603 # get a "difficult" lock
5605 $LCTL set_param fail_loc=0
5609 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5613 #define OBD_FAIL_LDLM_NEW_LOCK
5614 $LCTL set_param fail_loc=0x319
5615 touch $DIR/$tfile && error "touch successful"
5616 $LCTL set_param fail_loc=0
5619 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5622 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5625 get_inode_slab_tunables() {
5626 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5629 set_inode_slab_tunables() {
5630 echo "lustre_inode_cache $1" > /proc/slabinfo
5633 test_76() { # Now for bug 20433, added originally in bug 1443
5634 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5635 local SLAB_SETTINGS=`get_inode_slab_tunables`
5636 local CPUS=`getconf _NPROCESSORS_ONLN`
5637 # we cannot set limit below 1 which means 1 inode in each
5638 # per-cpu cache is still allowed
5639 set_inode_slab_tunables "1 1 0"
5640 cancel_lru_locks osc
5641 BEFORE_INODES=$(num_inodes)
5642 echo "before inodes: $BEFORE_INODES"
5644 [ "$SLOW" = "no" ] && COUNT=100
5645 for i in $(seq $COUNT); do
5649 cancel_lru_locks osc
5650 AFTER_INODES=$(num_inodes)
5651 echo "after inodes: $AFTER_INODES"
5653 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5655 AFTER_INODES=$(num_inodes)
5657 echo "wait $wait seconds inodes: $AFTER_INODES"
5658 if [ $wait -gt 30 ]; then
5659 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5662 set_inode_slab_tunables "$SLAB_SETTINGS"
5664 run_test 76 "confirm clients recycle inodes properly ===="
5670 # Note: in sptlrpc modes which enable its own bulk checksum, the
5671 # original crc32_le bulk checksum will be automatically disabled,
5672 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5673 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5674 # In this case set_checksums() will not be no-op, because sptlrpc
5675 # bulk checksum will be enabled all through the test.
5677 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5678 lctl set_param -n osc.*.checksums $1
5682 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5683 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5684 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5685 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5688 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5689 log "set checksum type to $1"
5692 F77_TMP=$TMP/f77-temp
5695 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5696 error "error writing to $F77_TMP"
5699 test_77a() { # bug 10889
5700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5701 $GSS && skip "could not run with gss" && return
5702 [ ! -f $F77_TMP ] && setup_f77
5704 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5708 run_test 77a "normal checksum read/write operation"
5710 test_77b() { # bug 10889
5711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5712 $GSS && skip "could not run with gss" && return
5713 [ ! -f $F77_TMP ] && setup_f77
5714 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5715 $LCTL set_param fail_loc=0x80000409
5718 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5719 error "dd error: $?"
5720 $LCTL set_param fail_loc=0
5722 for algo in $CKSUM_TYPES; do
5723 cancel_lru_locks osc
5724 set_checksum_type $algo
5725 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5726 $LCTL set_param fail_loc=0x80000408
5727 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5728 $LCTL set_param fail_loc=0
5731 set_checksum_type $ORIG_CSUM_TYPE
5734 run_test 77b "checksum error on client write, read"
5736 test_77d() { # bug 10889
5737 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5738 $GSS && skip "could not run with gss" && return
5739 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5740 $LCTL set_param fail_loc=0x80000409
5742 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5743 error "direct write: rc=$?"
5744 $LCTL set_param fail_loc=0
5747 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5748 $LCTL set_param fail_loc=0x80000408
5750 cancel_lru_locks osc
5751 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5752 error "direct read: rc=$?"
5753 $LCTL set_param fail_loc=0
5756 run_test 77d "checksum error on OST direct write, read"
5758 test_77f() { # bug 10889
5759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5760 $GSS && skip "could not run with gss" && return
5762 for algo in $CKSUM_TYPES; do
5763 cancel_lru_locks osc
5764 set_checksum_type $algo
5765 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5766 $LCTL set_param fail_loc=0x409
5767 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5768 error "direct write succeeded"
5769 $LCTL set_param fail_loc=0
5771 set_checksum_type $ORIG_CSUM_TYPE
5774 run_test 77f "repeat checksum error on write (expect error)"
5776 test_77g() { # bug 10889
5777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5778 $GSS && skip "could not run with gss" && return
5779 remote_ost_nodsh && skip "remote OST with nodsh" && return
5781 [ ! -f $F77_TMP ] && setup_f77
5783 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5784 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5785 do_facet ost1 lctl set_param fail_loc=0x8000021a
5787 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5788 error "write error: rc=$?"
5789 do_facet ost1 lctl set_param fail_loc=0
5792 cancel_lru_locks osc
5793 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5794 do_facet ost1 lctl set_param fail_loc=0x8000021b
5796 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5797 do_facet ost1 lctl set_param fail_loc=0
5800 run_test 77g "checksum error on OST write, read"
5802 test_77i() { # bug 13805
5803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5804 $GSS && skip "could not run with gss" && return
5805 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5806 lctl set_param fail_loc=0x40b
5807 remount_client $MOUNT
5808 lctl set_param fail_loc=0
5809 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5810 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5811 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5812 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5814 remount_client $MOUNT
5816 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5818 test_77j() { # bug 13805
5819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5820 $GSS && skip "could not run with gss" && return
5821 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5822 lctl set_param fail_loc=0x40c
5823 remount_client $MOUNT
5824 lctl set_param fail_loc=0
5825 sleep 2 # wait async osc connect to finish
5826 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5827 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5828 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5829 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5831 remount_client $MOUNT
5833 run_test 77j "client only supporting ADLER32"
5835 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5839 test_78() { # bug 10901
5840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5841 remote_ost || { skip_env "local OST" && return; }
5844 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5845 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5846 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5847 echo "MemTotal: $MEMTOTAL"
5849 # reserve 256MB of memory for the kernel and other running processes,
5850 # and then take 1/2 of the remaining memory for the read/write buffers.
5851 if [ $MEMTOTAL -gt 512 ] ;then
5852 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5854 # for those poor memory-starved high-end clusters...
5855 MEMTOTAL=$((MEMTOTAL / 2))
5857 echo "Mem to use for directio: $MEMTOTAL"
5859 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5860 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5861 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5862 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5864 echo "Smallest OST: $SMALLESTOST"
5865 [[ $SMALLESTOST -lt 10240 ]] &&
5866 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5868 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5869 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5871 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5872 echo "File size: $F78SIZE"
5873 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5874 for i in $(seq 1 $NSEQ); do
5875 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5876 echo directIO rdwr round $i of $NSEQ
5877 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5882 run_test 78 "handle large O_DIRECT writes correctly ============"
5884 test_79() { # bug 12743
5885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5886 wait_delete_completed
5888 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5889 BKFREE=$(calc_osc_kbytes kbytesfree)
5890 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5892 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5893 DFTOTAL=`echo $STRING | cut -d, -f1`
5894 DFUSED=`echo $STRING | cut -d, -f2`
5895 DFAVAIL=`echo $STRING | cut -d, -f3`
5896 DFFREE=$(($DFTOTAL - $DFUSED))
5898 ALLOWANCE=$((64 * $OSTCOUNT))
5900 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5901 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5902 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5904 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5905 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5906 error "df free($DFFREE) mismatch OST free($BKFREE)"
5908 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5909 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5910 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5913 run_test 79 "df report consistency check ======================="
5915 test_80() { # bug 10718
5916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5917 # relax strong synchronous semantics for slow backends like ZFS
5918 local soc="obdfilter.*.sync_on_lock_cancel"
5919 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5921 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5922 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5923 facet_active_host $host; done | sort -u)
5924 do_nodes $hosts lctl set_param $soc=never
5927 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5929 local BEFORE=`date +%s`
5930 cancel_lru_locks osc
5931 local AFTER=`date +%s`
5932 local DIFF=$((AFTER-BEFORE))
5933 if [ $DIFF -gt 1 ] ; then
5934 error "elapsed for 1M@1T = $DIFF"
5937 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5941 run_test 80 "Page eviction is equally fast at high offsets too ===="
5943 test_81a() { # LU-456
5944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5945 remote_ost_nodsh && skip "remote OST with nodsh" && return
5946 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5947 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5948 do_facet ost1 lctl set_param fail_loc=0x80000228
5950 # write should trigger a retry and success
5951 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5952 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5954 if [ $RC -ne 0 ] ; then
5955 error "write should success, but failed for $RC"
5958 run_test 81a "OST should retry write when get -ENOSPC ==============="
5960 test_81b() { # LU-456
5961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5962 remote_ost_nodsh && skip "remote OST with nodsh" && return
5963 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5964 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5965 do_facet ost1 lctl set_param fail_loc=0x228
5967 # write should retry several times and return -ENOSPC finally
5968 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5969 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5972 if [ $RC -ne $ENOSPC ] ; then
5973 error "dd should fail for -ENOSPC, but succeed."
5976 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5978 test_82() { # LU-1031
5979 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5983 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5985 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5987 kill -USR1 $MULTIPID2
5989 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5990 error "First grouplock does not block second one"
5992 echo "Second grouplock blocks first one"
5994 kill -USR1 $MULTIPID1
5998 run_test 82 "Basic grouplock test ==============================="
6001 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6003 test_mkdir -p $DIR/d99cvsroot
6004 chown $RUNAS_ID $DIR/d99cvsroot
6005 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6008 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6011 run_test 99a "cvs init ========================================="
6014 [ -z "$(which cvs 2>/dev/null)" ] &&
6015 skip_env "could not find cvs" && return
6016 [ ! -d $DIR/d99cvsroot ] && test_99a
6018 # some versions of cvs import exit(1) when asked to import links or
6019 # files they can't read. ignore those files.
6020 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6021 ! -perm +4 -printf '-I %f\n')
6022 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6023 d99reposname vtag rtag
6025 run_test 99b "cvs import ======================================="
6028 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6029 [ ! -d $DIR/d99cvsroot ] && test_99b
6031 test_mkdir -p $DIR/d99reposname
6032 chown $RUNAS_ID $DIR/d99reposname
6033 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6035 run_test 99c "cvs checkout ====================================="
6038 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6039 [ ! -d $DIR/d99cvsroot ] && test_99c
6040 cd $DIR/d99reposname
6042 $RUNAS cvs add -m 'addmsg' foo99
6044 run_test 99d "cvs add =========================================="
6047 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6048 [ ! -d $DIR/d99cvsroot ] && test_99c
6049 cd $DIR/d99reposname
6052 run_test 99e "cvs update ======================================="
6055 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6056 [ ! -d $DIR/d99cvsroot ] && test_99d
6057 cd $DIR/d99reposname
6058 $RUNAS cvs commit -m 'nomsg' foo99
6059 rm -fr $DIR/d99cvsroot
6061 run_test 99f "cvs commit ======================================="
6064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6065 [ "$NETTYPE" = tcp ] || \
6066 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6069 remote_ost_nodsh && skip "remote OST with nodsh" && return
6070 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6072 { skip "useless for local single node setup" && return; }
6074 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6075 [ "$PROT" != "tcp" ] && continue
6076 RPORT=$(echo $REMOTE | cut -d: -f2)
6077 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6080 LPORT=`echo $LOCAL | cut -d: -f2`
6081 if [ $LPORT -ge 1024 ]; then
6082 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6084 error_exit "local: $LPORT > 1024, remote: $RPORT"
6087 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6089 run_test 100 "check local port using privileged port ==========="
6091 function get_named_value()
6100 echo $line | sed "s/^$tag[ ]*//"
6107 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6108 awk '/^max_cached_mb/ { print $2 }')
6111 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6116 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6117 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6121 local cache_limit=32
6123 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6124 trap cleanup_101a EXIT
6125 $LCTL set_param -n llite.*.read_ahead_stats 0
6126 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6129 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6131 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6132 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6135 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6136 get_named_value 'read but discarded' | cut -d" " -f1); do
6137 discard=$(($discard + $s))
6141 if [[ $(($discard * 10)) -gt $nreads ]]; then
6142 $LCTL get_param osc.*-osc*.rpc_stats
6143 $LCTL get_param llite.*.read_ahead_stats
6144 error "too many ($discard) discarded pages"
6146 rm -f $DIR/$tfile || true
6148 run_test 101a "check read-ahead for random reads ================"
6151 test_mkdir -p $DIR/$tdir
6152 local STRIPE_SIZE=$1
6153 local FILE_LENGTH=$2
6156 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6158 local list=$(comma_list $(osts_nodes))
6159 set_osd_param $list '' read_cache_enable 0
6160 set_osd_param $list '' writethrough_cache_enable 0
6162 trap cleanup_test101bc EXIT
6163 # prepare the read-ahead file
6164 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6166 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6167 count=$FILE_SIZE_MB 2> /dev/null
6171 cleanup_test101bc() {
6176 local list=$(comma_list $(osts_nodes))
6177 set_osd_param $list '' read_cache_enable 1
6178 set_osd_param $list '' writethrough_cache_enable 1
6182 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6187 local STRIPE_SIZE=$2
6188 local FILE_LENGTH=$3
6189 local RA_INC=1048576
6190 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6191 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6192 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6193 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6194 get_named_value 'read but discarded' |
6195 cut -d" " -f1 | calc_total)
6196 if [[ $DISCARD -gt $discard_limit ]]; then
6197 $LCTL get_param llite.*.read_ahead_stats
6198 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6200 echo "Read-ahead success for size ${READ_SIZE}"
6205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6206 [[ $OSTCOUNT -lt 2 ]] &&
6207 skip_env "skipping stride IO stride-ahead test" && return
6208 local STRIPE_SIZE=1048576
6209 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6210 if [ $SLOW == "yes" ]; then
6211 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6213 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6216 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6218 # prepare the read-ahead file
6219 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6220 cancel_lru_locks osc
6221 for BIDX in 2 4 8 16 32 64 128 256
6223 local BSIZE=$((BIDX*4096))
6224 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6225 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6226 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6227 $LCTL set_param -n llite.*.read_ahead_stats 0
6228 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6229 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6230 cancel_lru_locks osc
6231 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6236 run_test 101b "check stride-io mode read-ahead ================="
6239 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6240 local STRIPE_SIZE=1048576
6241 local FILE_LENGTH=$((STRIPE_SIZE*100))
6245 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6247 cancel_lru_locks osc
6248 $LCTL set_param osc.*.rpc_stats 0
6249 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6250 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6251 local stats=$($LCTL get_param -n $osc_rpc_stats)
6252 local lines=$(echo "$stats" | awk 'END {print NR;}')
6255 if [ $lines -le 20 ]; then
6258 for size in 1 2 4 8; do
6259 local rpc=$(echo "$stats" |
6260 awk '($1 == "'$size':") {print $2; exit; }')
6262 error "Small $((size*4))k read IO $rpc !"
6264 echo "$osc_rpc_stats check passed!"
6269 run_test 101c "check stripe_size aligned read-ahead ================="
6272 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6273 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6278 local file=$DIR/$tfile
6279 local sz_MB=${FILESIZE_101d:-500}
6280 local ra_MB=${READAHEAD_MB:-40}
6282 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6283 [ $free_MB -lt $sz_MB ] &&
6284 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6286 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6287 $SETSTRIPE -c -1 $file || error "setstripe failed"
6289 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6290 echo Cancel LRU locks on lustre client to flush the client cache
6291 cancel_lru_locks osc
6293 echo Disable read-ahead
6294 local old_READAHEAD=$(set_read_ahead 0)
6296 echo Reading the test file $file with read-ahead disabled
6297 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6299 echo Cancel LRU locks on lustre client to flush the client cache
6300 cancel_lru_locks osc
6301 echo Enable read-ahead with ${ra_MB}MB
6302 set_read_ahead $ra_MB
6304 echo Reading the test file $file with read-ahead enabled
6305 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6307 echo "read-ahead disabled time read $raOFF"
6308 echo "read-ahead enabled time read $raON"
6310 set_read_ahead $old_READAHEAD
6312 wait_delete_completed
6314 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6315 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6317 run_test 101d "file read with and without read-ahead enabled"
6320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6321 local file=$DIR/$tfile
6322 local size_KB=500 #KB
6326 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6327 local need_KB=$((count * size_KB))
6328 [[ $free_KB -le $need_KB ]] &&
6329 skip_env "Need free space $need_KB, have $free_KB" && return
6331 echo "Creating $count ${size_KB}K test files"
6332 for ((i = 0; i < $count; i++)); do
6333 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6336 echo "Cancel LRU locks on lustre client to flush the client cache"
6337 cancel_lru_locks osc
6339 echo "Reset readahead stats"
6340 $LCTL set_param -n llite.*.read_ahead_stats 0
6342 for ((i = 0; i < $count; i++)); do
6343 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6346 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6347 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6349 for ((i = 0; i < $count; i++)); do
6350 rm -rf $file.$i 2>/dev/null
6353 #10000 means 20% reads are missing in readahead
6354 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6356 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6358 cleanup_test101f() {
6360 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6361 rm -rf $DIR/$tfile 2>/dev/null
6365 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6366 local file=$DIR/$tfile
6369 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6370 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6371 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6372 trap cleanup_test101f EXIT
6374 echo Cancel LRU locks on lustre client to flush the client cache
6375 cancel_lru_locks osc
6377 echo Reset readahead stats
6378 $LCTL set_param -n llite.*.read_ahead_stats 0
6379 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6380 # readahead should read in 2M file on second read, so only miss
6382 echo Random 4K reads on 2M file for 1000 times
6383 $READS -f $file -s 2097152 -b 4096 -n $nreads
6385 echo checking missing pages
6386 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6387 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6389 [ $miss -lt 3 ] || error "misses too much pages!"
6392 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6395 test_mkdir -p $DIR/$tdir
6396 chown $RUNAS_ID $DIR/$tdir
6399 STRIPE_COUNT=$OSTCOUNT
6400 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6402 trap cleanup_test102 EXIT
6404 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6406 for num in 1 2 3 4; do
6407 for count in $(seq 1 $STRIPE_COUNT); do
6408 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6409 local size=`expr $STRIPE_SIZE \* $num`
6410 local file=file"$num-$idx-$count"
6411 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6417 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6423 rm -rf $DIR/d0.sanity/d102
6427 local testfile=$DIR/$tfile
6431 [ "$UID" != 0 ] && skip_env "must run as root" && return
6432 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6433 skip_env "must have user_xattr" && return
6435 [ -z "$(which setfattr 2>/dev/null)" ] &&
6436 skip_env "could not find setfattr" && return
6438 echo "set/get xattr..."
6439 setfattr -n trusted.name1 -v value1 $testfile ||
6440 error "setfattr -n trusted.name1=value1 $testfile failed"
6441 getfattr -n trusted.name1 $testfile 2> /dev/null |
6442 grep "trusted.name1=.value1" ||
6443 error "$testfile missing trusted.name1=value1"
6445 setfattr -n user.author1 -v author1 $testfile ||
6446 error "setfattr -n user.author1=author1 $testfile failed"
6447 getfattr -n user.author1 $testfile 2> /dev/null |
6448 grep "user.author1=.author1" ||
6449 error "$testfile missing trusted.author1=author1"
6452 setfattr -n trusted.name2 -v value2 $testfile ||
6453 error "$testfile unable to set trusted.name2"
6454 setfattr -n trusted.name3 -v value3 $testfile ||
6455 error "$testfile unable to set trusted.name3"
6456 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6457 grep "trusted.name" | wc -l) -eq 3 ] ||
6458 error "$testfile missing 3 trusted.name xattrs"
6460 setfattr -n user.author2 -v author2 $testfile ||
6461 error "$testfile unable to set user.author2"
6462 setfattr -n user.author3 -v author3 $testfile ||
6463 error "$testfile unable to set user.author3"
6464 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6465 grep "user.author" | wc -l) -eq 3 ] ||
6466 error "$testfile missing 3 user.author xattrs"
6468 echo "remove xattr..."
6469 setfattr -x trusted.name1 $testfile ||
6470 error "$testfile error deleting trusted.name1"
6471 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6472 error "$testfile did not delete trusted.name1 xattr"
6474 setfattr -x user.author1 $testfile ||
6475 error "$testfile error deleting user.author1"
6476 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6477 error "$testfile did not delete trusted.name1 xattr"
6479 # b10667: setting lustre special xattr be silently discarded
6480 echo "set lustre special xattr ..."
6481 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6482 error "$testfile allowed setting trusted.lov"
6484 run_test 102a "user xattr test =================================="
6487 [ -z "$(which setfattr 2>/dev/null)" ] &&
6488 skip_env "could not find setfattr" && return
6490 # b10930: get/set/list trusted.lov xattr
6491 echo "get/set/list trusted.lov xattr ..."
6492 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6493 local testfile=$DIR/$tfile
6494 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6495 error "setstripe failed"
6496 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6497 error "getstripe failed"
6498 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6499 error "can't get trusted.lov from $testfile"
6501 local testfile2=${testfile}2
6502 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6503 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6506 setfattr -n trusted.lov -v $value $testfile2
6507 local stripe_size=$($GETSTRIPE -S $testfile2)
6508 local stripe_count=$($GETSTRIPE -c $testfile2)
6509 [[ $stripe_size -eq 65536 ]] ||
6510 error "stripe size $stripe_size != 65536"
6511 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6512 error "stripe count $stripe_count != $STRIPECOUNT"
6515 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6518 [ -z "$(which setfattr 2>/dev/null)" ] &&
6519 skip_env "could not find setfattr" && return
6521 # b10930: get/set/list lustre.lov xattr
6522 echo "get/set/list lustre.lov xattr ..."
6523 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6524 test_mkdir -p $DIR/$tdir
6525 chown $RUNAS_ID $DIR/$tdir
6526 local testfile=$DIR/$tdir/$tfile
6527 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6528 error "setstripe failed"
6529 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6530 error "getstripe failed"
6531 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6532 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6534 local testfile2=${testfile}2
6535 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6536 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6538 $RUNAS $MCREATE $testfile2
6539 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6540 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6541 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6542 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6543 [ $stripe_count -eq $STRIPECOUNT ] ||
6544 error "stripe count $stripe_count != $STRIPECOUNT"
6546 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6548 compare_stripe_info1() {
6549 local stripe_index_all_zero=true
6551 for num in 1 2 3 4; do
6552 for count in $(seq 1 $STRIPE_COUNT); do
6553 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6554 local size=$((STRIPE_SIZE * num))
6555 local file=file"$num-$offset-$count"
6556 stripe_size=$(lfs getstripe -S $PWD/$file)
6557 [[ $stripe_size -ne $size ]] &&
6558 error "$file: size $stripe_size != $size"
6559 stripe_count=$(lfs getstripe -c $PWD/$file)
6560 # allow fewer stripes to be created, ORI-601
6561 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6562 error "$file: count $stripe_count != $count"
6563 stripe_index=$(lfs getstripe -i $PWD/$file)
6564 [[ $stripe_index -ne 0 ]] &&
6565 stripe_index_all_zero=false
6569 $stripe_index_all_zero &&
6570 error "all files are being extracted starting from OST index 0"
6575 [ -n "$(which tar 2>/dev/null)" ] &&
6576 strings $(which tar) | grep -q "lustre" && echo tar
6580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6581 # b10930: tar test for trusted.lov xattr
6582 TAR=$(find_lustre_tar)
6583 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6584 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6586 test_mkdir -p $DIR/d102d
6587 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6589 compare_stripe_info1
6591 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6594 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6595 # b10930: tar test for trusted.lov xattr
6596 TAR=$(find_lustre_tar)
6597 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6598 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6600 test_mkdir -p $DIR/d102f
6602 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6604 compare_stripe_info1
6606 run_test 102f "tar copy files, not keep osts ==========="
6609 local xsize=${1:-1024} # in bytes
6610 local file=$DIR/$tfile
6612 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6613 skip "must have user_xattr" && return 0
6614 [ -z "$(which setfattr 2>/dev/null)" ] &&
6615 skip_env "could not find setfattr" && return 0
6616 [ -z "$(which getfattr 2>/dev/null)" ] &&
6617 skip_env "could not find getfattr" && return 0
6621 local value="$(generate_string $xsize)"
6623 local xbig=trusted.big
6624 log "save $xbig on $file"
6625 setfattr -n $xbig -v $value $file ||
6626 error "saving $xbig on $file failed"
6628 local orig=$(get_xattr_value $xbig $file)
6629 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6631 local xsml=trusted.sml
6632 log "save $xsml on $file"
6633 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6635 local new=$(get_xattr_value $xbig $file)
6636 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6638 log "grow $xsml on $file"
6639 setfattr -n $xsml -v "$value" $file ||
6640 error "growing $xsml on $file failed"
6642 new=$(get_xattr_value $xbig $file)
6643 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6644 log "$xbig still valid after growing $xsml"
6649 test_102h() { # bug 15777
6652 run_test 102h "grow xattr from inside inode to external block"
6655 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6656 grow_xattr $(max_xattr_size)
6658 run_test 102ha "grow xattr from inside inode to external inode"
6660 test_102i() { # bug 17038
6661 [ -z "$(which getfattr 2>/dev/null)" ] &&
6662 skip "could not find getfattr" && return
6664 ln -s $DIR/$tfile $DIR/${tfile}link
6665 getfattr -n trusted.lov $DIR/$tfile ||
6666 error "lgetxattr on $DIR/$tfile failed"
6667 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6668 grep -i "no such attr" ||
6669 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6670 rm -f $DIR/$tfile $DIR/${tfile}link
6672 run_test 102i "lgetxattr test on symbolic link ============"
6675 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6676 TAR=$(find_lustre_tar)
6677 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6678 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6679 setup_test102 "$RUNAS"
6680 test_mkdir -p $DIR/d102j
6681 chown $RUNAS_ID $DIR/d102j
6682 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6684 compare_stripe_info1 "$RUNAS"
6686 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6689 [ -z "$(which setfattr 2>/dev/null)" ] &&
6690 skip "could not find setfattr" && return
6692 # b22187 just check that does not crash for regular file.
6693 setfattr -n trusted.lov $DIR/$tfile
6694 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6695 local test_kdir=$DIR/d102k
6696 test_mkdir $test_kdir
6697 local default_size=`$GETSTRIPE -S $test_kdir`
6698 local default_count=`$GETSTRIPE -c $test_kdir`
6699 local default_offset=`$GETSTRIPE -i $test_kdir`
6700 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6701 error 'dir setstripe failed'
6702 setfattr -n trusted.lov $test_kdir
6703 local stripe_size=`$GETSTRIPE -S $test_kdir`
6704 local stripe_count=`$GETSTRIPE -c $test_kdir`
6705 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6706 [ $stripe_size -eq $default_size ] ||
6707 error "stripe size $stripe_size != $default_size"
6708 [ $stripe_count -eq $default_count ] ||
6709 error "stripe count $stripe_count != $default_count"
6710 [ $stripe_offset -eq $default_offset ] ||
6711 error "stripe offset $stripe_offset != $default_offset"
6712 rm -rf $DIR/$tfile $test_kdir
6714 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6717 [ -z "$(which getfattr 2>/dev/null)" ] &&
6718 skip "could not find getfattr" && return
6720 # LU-532 trusted. xattr is invisible to non-root
6721 local testfile=$DIR/$tfile
6725 echo "listxattr as user..."
6726 chown $RUNAS_ID $testfile
6727 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6728 grep -q "trusted" &&
6729 error "$testfile trusted xattrs are user visible"
6733 run_test 102l "listxattr size test =================================="
6735 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6736 local path=$DIR/$tfile
6739 listxattr_size_check $path || error "listattr_size_check $path failed"
6741 run_test 102m "Ensure listxattr fails on small bufffer ========"
6745 getxattr() { # getxattr path name
6746 # Return the base64 encoding of the value of xattr name on path.
6750 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6752 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6754 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6756 getfattr --absolute-names --encoding=base64 --name=$name $path |
6757 awk -F= -v name=$name '$1 == name {
6758 print substr($0, index($0, "=") + 1);
6762 test_102n() { # LU-4101 mdt: protect internal xattrs
6763 local file0=$DIR/$tfile.0
6764 local file1=$DIR/$tfile.1
6765 local xattr0=$TMP/$tfile.0
6766 local xattr1=$TMP/$tfile.1
6770 [ -z "$(which setfattr 2>/dev/null)" ] &&
6771 skip "could not find setfattr" && return
6773 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6775 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6779 rm -rf $file0 $file1 $xattr0 $xattr1
6782 # Get 'before' xattrs of $file1.
6783 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6785 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6786 # Try to copy xattr from $file0 to $file1.
6787 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6789 setfattr --name=trusted.$name --value="$value" $file1 ||
6790 error "setxattr 'trusted.$name' failed"
6792 # Try to set a garbage xattr.
6793 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6795 setfattr --name=trusted.$name --value="$value" $file1 ||
6796 error "setxattr 'trusted.$name' failed"
6798 # Try to remove the xattr from $file1. We don't care if this
6799 # appears to succeed or fail, we just don't want there to be
6800 # any changes or crashes.
6801 setfattr --remove=$trusted.$name $file1 2> /dev/null
6804 # Get 'after' xattrs of file1.
6805 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6807 if ! diff $xattr0 $xattr1; then
6808 error "before and after xattrs of '$file1' differ"
6811 rm -rf $file0 $file1 $xattr0 $xattr1
6815 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6817 test_102p() { # LU-4703 setxattr did not check ownership
6818 local testfile=$DIR/$tfile
6820 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6821 skip "MDS needs to be at least 2.5.56" && return
6825 echo "setfacl as user..."
6826 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6827 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6829 echo "setfattr as user..."
6830 setfacl -m "u:$RUNAS_ID:---" $testfile
6831 $RUNAS setfattr -x system.posix_acl_access $testfile
6832 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6834 run_test 102p "check setxattr(2) correctly fails without permission"
6838 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6843 [ "$UID" != 0 ] && skip_env "must run as root" && return
6844 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6845 skip "must have acl enabled" && return
6846 [ -z "$(which setfacl 2>/dev/null)" ] &&
6847 skip_env "could not find setfacl" && return
6848 $GSS && skip "could not run under gss" && return
6850 declare -a identity_old
6852 for num in $(seq $MDSCOUNT); do
6853 switch_identity $num true || identity_old[$num]=$?
6860 echo "performing cp ..."
6861 run_acl_subtest cp || error "run_acl_subtest cp failed"
6862 echo "performing getfacl-noacl..."
6863 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6864 echo "performing misc..."
6865 run_acl_subtest misc || error "misc test failed"
6866 echo "performing permissions..."
6867 run_acl_subtest permissions || error "permissions failed"
6868 echo "performing setfacl..."
6869 run_acl_subtest setfacl || error "setfacl test failed"
6871 # inheritance test got from HP
6872 echo "performing inheritance..."
6873 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6874 chmod +x make-tree || error "chmod +x failed"
6875 run_acl_subtest inheritance || error "inheritance test failed"
6878 echo "LU-974 ignore umask when acl is enabled..."
6879 run_acl_subtest 974 || error "LU-974 umask test failed"
6880 if [ $MDSCOUNT -ge 2 ]; then
6881 run_acl_subtest 974_remote ||
6882 error "LU-974 umask test failed under remote dir"
6885 echo "LU-2561 newly created file is same size as directory..."
6886 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6887 run_acl_subtest 2561 || error "LU-2561 test failed"
6889 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6892 run_acl_subtest 4924 || error "LU-4924 test failed"
6897 for num in $(seq $MDSCOUNT); do
6898 if [ "${identity_old[$num]}" = 1 ]; then
6899 switch_identity $num false || identity_old[$num]=$?
6903 run_test 103a "acl test ========================================="
6907 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
6908 local mountopts=$MDS_MOUNT_OPTS
6910 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
6914 stop $SINGLEMDS || error "failed to stop MDT."
6916 if [ -z "$MDS_MOUNT_OPTS" ]; then
6917 MDS_MOUNT_OPTS="-o noacl"
6919 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
6921 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6922 error "failed to start MDT."
6923 MDS_MOUNT_OPTS=$mountopts
6927 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
6931 stop $SINGLEMDS || error "failed to stop MDT."
6933 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6934 error "failed to start MDT."
6939 run_test 103b "MDS mount option 'noacl'"
6943 cp -rp $DIR/$tdir $DIR/$tdir.bak
6945 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
6946 error "$DIR/$tdir shouldn't contain default ACL"
6947 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
6948 error "$DIR/$tdir.bak shouldn't contain default ACL"
6951 run_test 103c "'cp -rp' won't set empty acl"
6954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6956 lfs df || error "lfs df failed"
6957 lfs df -ih || error "lfs df -ih failed"
6958 lfs df -h $DIR || error "lfs df -h $DIR failed"
6959 lfs df -i $DIR || error "lfs df -i $DIR failed"
6960 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6961 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6963 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6964 lctl --device %$OSC deactivate
6965 lfs df || error "lfs df with deactivated OSC failed"
6966 lctl --device %$OSC activate
6967 # wait the osc back to normal
6968 wait_osc_import_state client ost FULL
6970 lfs df || error "lfs df with reactivated OSC failed"
6973 run_test 104a "lfs df [-ih] [path] test ========================="
6976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6977 [ $RUNAS_ID -eq $UID ] &&
6978 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6980 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6981 grep "Permission denied" | wc -l)))
6982 if [ $denied_cnt -ne 0 ]; then
6983 error "lfs check servers test failed"
6986 run_test 104b "$RUNAS lfs check servers test ===================="
6989 # doesn't work on 2.4 kernels
6991 if $(flock_is_enabled); then
6992 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6994 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6998 run_test 105a "flock when mounted without -o flock test ========"
7002 if $(flock_is_enabled); then
7003 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7005 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7009 run_test 105b "fcntl when mounted without -o flock test ========"
7013 if $(flock_is_enabled); then
7014 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7016 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7020 run_test 105c "lockf when mounted without -o flock test ========"
7022 test_105d() { # bug 15924
7023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7024 test_mkdir -p $DIR/$tdir
7025 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7026 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7027 $LCTL set_param fail_loc=0x80000315
7028 flocks_test 2 $DIR/$tdir
7030 run_test 105d "flock race (should not freeze) ========"
7032 test_105e() { # bug 22660 && 22040
7033 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7035 flocks_test 3 $DIR/$tfile
7037 run_test 105e "Two conflicting flocks from same process ======="
7039 test_106() { #bug 10921
7040 test_mkdir -p $DIR/$tdir
7041 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7042 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7044 run_test 106 "attempt exec of dir followed by chown of that dir"
7047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7054 local save_pattern=$(sysctl -n kernel.core_pattern)
7055 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7056 sysctl -w kernel.core_pattern=$file
7057 sysctl -w kernel.core_uses_pid=0
7065 kill -s 11 $SLEEPPID
7067 if [ -e $file ]; then
7068 size=`stat -c%s $file`
7069 [ $size -eq 0 ] && error "Fail to create core file $file"
7071 error "Fail to create core file $file"
7074 sysctl -w kernel.core_pattern=$save_pattern
7075 sysctl -w kernel.core_uses_pid=$save_uses_pid
7078 run_test 107 "Coredump on SIG"
7081 test_mkdir -p $DIR/$tdir
7082 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7083 error "mkdir with 255 char failed"
7084 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7085 error "mkdir with 256 char should fail, but did not"
7086 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7087 error "create with 255 char failed"
7088 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7089 error "create with 256 char should fail, but did not"
7094 run_test 110 "filename length checking"
7097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7098 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7099 tail -1 | cut -c11-20)
7100 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7101 echo "Starting with $OSTIO_pre threads"
7104 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7105 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7106 echo "$NUMTEST creates/unlinks"
7107 test_mkdir -p $DIR/$tdir
7108 createmany -o $DIR/$tdir/$tfile $NUMTEST
7109 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7111 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7112 tail -1 | cut -c11-20)
7114 # don't return an error
7115 [ $OSTIO_post == $OSTIO_pre ] && echo \
7116 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7117 echo "This may be fine, depending on what ran before this test" &&
7118 echo "and how fast this system is." && return
7120 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7122 run_test 115 "verify dynamic thread creation===================="
7125 wait_delete_completed
7126 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7127 echo OST kbytes available: ${AVAIL[@]}
7128 MAXI=0; MAXV=${AVAIL[0]}
7129 MINI=0; MINV=${AVAIL[0]}
7130 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7131 #echo OST $i: ${AVAIL[i]}kb
7132 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7133 MAXV=${AVAIL[i]}; MAXI=$i
7135 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7136 MINV=${AVAIL[i]}; MINI=$i
7139 echo Min free space: OST $MINI: $MINV
7140 echo Max free space: OST $MAXI: $MAXV
7143 test_116a() { # was previously test_116()
7144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7145 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7147 echo -n "Free space priority "
7148 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7153 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7154 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7156 trap simple_cleanup_common EXIT
7159 # Check if we need to generate uneven OSTs
7160 test_mkdir -p $DIR/$tdir/OST${MINI}
7161 local FILL=$(($MINV / 4))
7162 local DIFF=$(($MAXV - $MINV))
7163 local DIFF2=$(($DIFF * 100 / $MINV))
7165 local threshold=$(do_facet $SINGLEMDS \
7166 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7167 threshold=${threshold%%%}
7168 echo -n "Check for uneven OSTs: "
7169 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7171 if [[ $DIFF2 -gt $threshold ]]; then
7173 echo "Don't need to fill OST$MINI"
7175 # generate uneven OSTs. Write 2% over the QOS threshold value
7177 DIFF=$(($threshold - $DIFF2 + 2))
7178 DIFF2=$(( ($MINV * $DIFF)/100 ))
7179 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7180 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7181 error "setstripe failed"
7182 DIFF=$(($DIFF2 / 2048))
7184 while [ $i -lt $DIFF ]; do
7186 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7187 bs=2M count=1 2>/dev/null
7196 DIFF=$(($MAXV - $MINV))
7197 DIFF2=$(($DIFF * 100 / $MINV))
7198 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7199 if [[ $DIFF2 -gt $threshold ]]; then
7202 echo "failed - QOS mode won't be used"
7203 skip "QOS imbalance criteria not met"
7204 simple_cleanup_common
7208 MINI1=$MINI; MINV1=$MINV
7209 MAXI1=$MAXI; MAXV1=$MAXV
7211 # now fill using QOS
7212 $SETSTRIPE -c 1 $DIR/$tdir
7213 FILL=$(($FILL / 200))
7214 if [ $FILL -gt 600 ]; then
7217 echo "writing $FILL files to QOS-assigned OSTs"
7219 while [ $i -lt $FILL ]; do
7221 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7225 echo "wrote $i 200k files"
7229 echo "Note: free space may not be updated, so measurements might be off"
7231 DIFF2=$(($MAXV - $MINV))
7232 echo "free space delta: orig $DIFF final $DIFF2"
7233 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7234 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7235 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7236 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7237 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7238 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7240 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7242 # Figure out which files were written where
7243 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7244 awk '/'$MINI1': / {print $2; exit}')
7246 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7247 echo "$MINC files created on smaller OST $MINI1"
7248 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7249 awk '/'$MAXI1': / {print $2; exit}')
7251 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7252 echo "$MAXC files created on larger OST $MAXI1"
7253 FILL=$(($MAXC * 100 / $MINC - 100))
7254 [[ $MINC -gt 0 ]] &&
7255 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7256 [[ $MAXC -gt $MINC ]] ||
7257 error_ignore LU-9 "stripe QOS didn't balance free space"
7258 simple_cleanup_common
7260 run_test 116a "stripe QOS: free space balance ==================="
7262 test_116b() { # LU-2093
7263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7264 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7265 head -1 2>/dev/null)" ] && skip "no QOS" && return
7266 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7268 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7269 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7270 do_facet $SINGLEMDS lctl set_param \
7271 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7273 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7274 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7275 do_facet $SINGLEMDS lctl set_param fail_loc=0
7277 do_facet $SINGLEMDS lctl set_param \
7278 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7280 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7282 test_117() # bug 10891
7284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7285 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7286 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7287 lctl set_param fail_loc=0x21e
7288 > $DIR/$tfile || error "truncate failed"
7289 lctl set_param fail_loc=0
7290 echo "Truncate succeeded."
7293 run_test 117 "verify osd extend =========="
7295 NO_SLOW_RESENDCOUNT=4
7296 export OLD_RESENDCOUNT=""
7297 set_resend_count () {
7298 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7299 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7300 lctl set_param -n $PROC_RESENDCOUNT $1
7301 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7304 # for reduce test_118* time (b=14842)
7305 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7307 # Reset async IO behavior after error case
7309 FILE=$DIR/reset_async
7311 # Ensure all OSCs are cleared
7312 $SETSTRIPE -c -1 $FILE
7313 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7318 test_118a() #bug 11710
7320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7323 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7324 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7325 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7327 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7328 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7333 run_test 118a "verify O_SYNC works =========="
7337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7338 remote_ost_nodsh && skip "remote OST with nodsh" && return
7342 #define OBD_FAIL_OST_ENOENT 0x217
7343 set_nodes_failloc "$(osts_nodes)" 0x217
7344 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7346 set_nodes_failloc "$(osts_nodes)" 0
7347 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7348 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7351 if [[ $RC -eq 0 ]]; then
7352 error "Must return error due to dropped pages, rc=$RC"
7356 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7357 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7361 echo "Dirty pages not leaked on ENOENT"
7363 # Due to the above error the OSC will issue all RPCs syncronously
7364 # until a subsequent RPC completes successfully without error.
7365 $MULTIOP $DIR/$tfile Ow4096yc
7370 run_test 118b "Reclaim dirty pages on fatal error =========="
7374 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7376 # for 118c, restore the original resend count, LU-1940
7377 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7378 set_resend_count $OLD_RESENDCOUNT
7379 remote_ost_nodsh && skip "remote OST with nodsh" && return
7383 #define OBD_FAIL_OST_EROFS 0x216
7384 set_nodes_failloc "$(osts_nodes)" 0x216
7386 # multiop should block due to fsync until pages are written
7387 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7391 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7392 error "Multiop failed to block on fsync, pid=$MULTIPID"
7395 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7397 if [[ $WRITEBACK -eq 0 ]]; then
7398 error "No page in writeback, writeback=$WRITEBACK"
7401 set_nodes_failloc "$(osts_nodes)" 0
7404 if [[ $RC -ne 0 ]]; then
7405 error "Multiop fsync failed, rc=$RC"
7408 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7409 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7411 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7412 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7416 echo "Dirty pages flushed via fsync on EROFS"
7419 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7421 # continue to use small resend count to reduce test_118* time (b=14842)
7422 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7426 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7427 remote_ost_nodsh && skip "remote OST with nodsh" && return
7431 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7432 set_nodes_failloc "$(osts_nodes)" 0x214
7433 # multiop should block due to fsync until pages are written
7434 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7438 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7439 error "Multiop failed to block on fsync, pid=$MULTIPID"
7442 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7444 if [[ $WRITEBACK -eq 0 ]]; then
7445 error "No page in writeback, writeback=$WRITEBACK"
7448 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7449 set_nodes_failloc "$(osts_nodes)" 0
7451 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7452 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7454 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7455 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7459 echo "Dirty pages gaurenteed flushed via fsync"
7462 run_test 118d "Fsync validation inject a delay of the bulk =========="
7465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7468 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7469 lctl set_param fail_loc=0x8000040a
7471 # Should simulate EINVAL error which is fatal
7472 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7474 if [[ $RC -eq 0 ]]; then
7475 error "Must return error due to dropped pages, rc=$RC"
7478 lctl set_param fail_loc=0x0
7480 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7481 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7482 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7484 if [[ $LOCKED -ne 0 ]]; then
7485 error "Locked pages remain in cache, locked=$LOCKED"
7488 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7489 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7493 echo "No pages locked after fsync"
7498 run_test 118f "Simulate unrecoverable OSC side error =========="
7501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7504 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7505 lctl set_param fail_loc=0x406
7507 # simulate local -ENOMEM
7508 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7511 lctl set_param fail_loc=0
7512 if [[ $RC -eq 0 ]]; then
7513 error "Must return error due to dropped pages, rc=$RC"
7516 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7517 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7518 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7520 if [[ $LOCKED -ne 0 ]]; then
7521 error "Locked pages remain in cache, locked=$LOCKED"
7524 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7525 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7529 echo "No pages locked after fsync"
7534 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7538 remote_ost_nodsh && skip "remote OST with nodsh" && return
7542 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7543 set_nodes_failloc "$(osts_nodes)" 0x20e
7544 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7545 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7548 set_nodes_failloc "$(osts_nodes)" 0
7549 if [[ $RC -eq 0 ]]; then
7550 error "Must return error due to dropped pages, rc=$RC"
7553 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7554 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7555 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7557 if [[ $LOCKED -ne 0 ]]; then
7558 error "Locked pages remain in cache, locked=$LOCKED"
7561 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7562 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7566 echo "No pages locked after fsync"
7570 run_test 118h "Verify timeout in handling recoverables errors =========="
7572 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7576 remote_ost_nodsh && skip "remote OST with nodsh" && return
7580 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7581 set_nodes_failloc "$(osts_nodes)" 0x20e
7583 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7584 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7587 set_nodes_failloc "$(osts_nodes)" 0
7591 if [[ $RC -ne 0 ]]; then
7592 error "got error, but should be not, rc=$RC"
7595 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7596 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7597 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7598 if [[ $LOCKED -ne 0 ]]; then
7599 error "Locked pages remain in cache, locked=$LOCKED"
7602 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7603 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7607 echo "No pages locked after fsync"
7611 run_test 118i "Fix error before timeout in recoverable error =========="
7613 [ "$SLOW" = "no" ] && set_resend_count 4
7616 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7617 remote_ost_nodsh && skip "remote OST with nodsh" && return
7621 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7622 set_nodes_failloc "$(osts_nodes)" 0x220
7624 # return -EIO from OST
7625 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7627 set_nodes_failloc "$(osts_nodes)" 0x0
7628 if [[ $RC -eq 0 ]]; then
7629 error "Must return error due to dropped pages, rc=$RC"
7632 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7633 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7634 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7635 if [[ $LOCKED -ne 0 ]]; then
7636 error "Locked pages remain in cache, locked=$LOCKED"
7639 # in recoverable error on OST we want resend and stay until it finished
7640 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7641 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7645 echo "No pages locked after fsync"
7649 run_test 118j "Simulate unrecoverable OST side error =========="
7653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7654 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7656 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7657 set_nodes_failloc "$(osts_nodes)" 0x20e
7658 test_mkdir -p $DIR/$tdir
7660 for ((i=0;i<10;i++)); do
7661 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7662 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7669 set_nodes_failloc "$(osts_nodes)" 0
7672 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7678 test_mkdir -p $DIR/$tdir
7679 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7682 run_test 118l "fsync dir ========="
7684 test_118m() # LU-3066
7686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7687 test_mkdir -p $DIR/$tdir
7688 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7691 run_test 118m "fdatasync dir ========="
7693 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7695 test_119a() # bug 11737
7697 BSIZE=$((512 * 1024))
7698 directio write $DIR/$tfile 0 1 $BSIZE
7699 # We ask to read two blocks, which is more than a file size.
7700 # directio will indicate an error when requested and actual
7701 # sizes aren't equeal (a normal situation in this case) and
7702 # print actual read amount.
7703 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7704 if [ "$NOB" != "$BSIZE" ]; then
7705 error "read $NOB bytes instead of $BSIZE"
7709 run_test 119a "Short directIO read must return actual read amount"
7711 test_119b() # bug 11737
7713 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7715 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7716 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7718 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7719 error "direct read failed"
7722 run_test 119b "Sparse directIO read must return actual read amount"
7724 test_119c() # bug 13099
7727 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7728 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7731 run_test 119c "Testing for direct read hitting hole"
7733 test_119d() # bug 15950
7735 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7736 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7737 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7739 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7740 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7741 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7742 lctl set_param fail_loc=0x40d
7743 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7746 cat $DIR/$tfile > /dev/null &
7747 lctl set_param fail_loc=0
7750 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7752 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7753 error "the read rpcs have not completed in 2s"
7755 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7757 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7761 test_mkdir -p $DIR/$tdir
7762 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7763 skip "no early lock cancel on server" && return 0
7765 lru_resize_disable mdc
7766 lru_resize_disable osc
7767 cancel_lru_locks mdc
7768 # asynchronous object destroy at MDT could cause bl ast to client
7769 cancel_lru_locks osc
7771 stat $DIR/$tdir > /dev/null
7772 can1=$(do_facet $SINGLEMDS \
7773 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7774 awk '/ldlm_cancel/ {print $2}')
7775 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7776 awk '/ldlm_bl_callback/ {print $2}')
7777 test_mkdir -c1 $DIR/$tdir/d1
7778 can2=$(do_facet $SINGLEMDS \
7779 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7780 awk '/ldlm_cancel/ {print $2}')
7781 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7782 awk '/ldlm_bl_callback/ {print $2}')
7783 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7784 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7785 lru_resize_enable mdc
7786 lru_resize_enable osc
7788 run_test 120a "Early Lock Cancel: mkdir test"
7791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7792 test_mkdir $DIR/$tdir
7793 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7794 skip "no early lock cancel on server" && return 0
7795 lru_resize_disable mdc
7796 lru_resize_disable osc
7797 cancel_lru_locks mdc
7798 stat $DIR/$tdir > /dev/null
7799 can1=$(do_facet $SINGLEMDS \
7800 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7801 awk '/ldlm_cancel/ {print $2}')
7802 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7803 awk '/ldlm_bl_callback/ {print $2}')
7805 can2=$(do_facet $SINGLEMDS \
7806 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7807 awk '/ldlm_cancel/ {print $2}')
7808 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7809 awk '/ldlm_bl_callback/ {print $2}')
7810 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7811 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7812 lru_resize_enable mdc
7813 lru_resize_enable osc
7815 run_test 120b "Early Lock Cancel: create test"
7818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7819 test_mkdir -c1 $DIR/$tdir
7820 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7821 skip "no early lock cancel on server" && return 0
7822 lru_resize_disable mdc
7823 lru_resize_disable osc
7824 test_mkdir -p -c1 $DIR/$tdir/d1
7825 test_mkdir -p -c1 $DIR/$tdir/d2
7826 touch $DIR/$tdir/d1/f1
7827 cancel_lru_locks mdc
7828 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7829 can1=$(do_facet $SINGLEMDS \
7830 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7831 awk '/ldlm_cancel/ {print $2}')
7832 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7833 awk '/ldlm_bl_callback/ {print $2}')
7834 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7835 can2=$(do_facet $SINGLEMDS \
7836 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7837 awk '/ldlm_cancel/ {print $2}')
7838 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7839 awk '/ldlm_bl_callback/ {print $2}')
7840 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7841 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7842 lru_resize_enable mdc
7843 lru_resize_enable osc
7845 run_test 120c "Early Lock Cancel: link test"
7848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7849 test_mkdir -p -c1 $DIR/$tdir
7850 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7851 skip "no early lock cancel on server" && return 0
7852 lru_resize_disable mdc
7853 lru_resize_disable osc
7855 cancel_lru_locks mdc
7856 stat $DIR/$tdir > /dev/null
7857 can1=$(do_facet $SINGLEMDS \
7858 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7859 awk '/ldlm_cancel/ {print $2}')
7860 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7861 awk '/ldlm_bl_callback/ {print $2}')
7862 chmod a+x $DIR/$tdir
7863 can2=$(do_facet $SINGLEMDS \
7864 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7865 awk '/ldlm_cancel/ {print $2}')
7866 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7867 awk '/ldlm_bl_callback/ {print $2}')
7868 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7869 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7870 lru_resize_enable mdc
7871 lru_resize_enable osc
7873 run_test 120d "Early Lock Cancel: setattr test"
7876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7877 test_mkdir -p -c1 $DIR/$tdir
7878 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7879 skip "no early lock cancel on server" && return 0
7880 lru_resize_disable mdc
7881 lru_resize_disable osc
7882 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7883 cancel_lru_locks mdc
7884 cancel_lru_locks osc
7885 dd if=$DIR/$tdir/f1 of=/dev/null
7886 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7887 # XXX client can not do early lock cancel of OST lock
7888 # during unlink (LU-4206), so cancel osc lock now.
7889 cancel_lru_locks osc
7890 can1=$(do_facet $SINGLEMDS \
7891 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7892 awk '/ldlm_cancel/ {print $2}')
7893 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7894 awk '/ldlm_bl_callback/ {print $2}')
7895 unlink $DIR/$tdir/f1
7897 can2=$(do_facet $SINGLEMDS \
7898 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7899 awk '/ldlm_cancel/ {print $2}')
7900 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7901 awk '/ldlm_bl_callback/ {print $2}')
7902 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7903 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7904 lru_resize_enable mdc
7905 lru_resize_enable osc
7907 run_test 120e "Early Lock Cancel: unlink test"
7910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7911 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7912 skip "no early lock cancel on server" && return 0
7913 test_mkdir -p -c1 $DIR/$tdir
7914 lru_resize_disable mdc
7915 lru_resize_disable osc
7916 test_mkdir -p -c1 $DIR/$tdir/d1
7917 test_mkdir -p -c1 $DIR/$tdir/d2
7918 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7919 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7920 cancel_lru_locks mdc
7921 cancel_lru_locks osc
7922 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7923 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7924 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7925 # XXX client can not do early lock cancel of OST lock
7926 # during rename (LU-4206), so cancel osc lock now.
7927 cancel_lru_locks osc
7928 can1=$(do_facet $SINGLEMDS \
7929 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7930 awk '/ldlm_cancel/ {print $2}')
7931 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7932 awk '/ldlm_bl_callback/ {print $2}')
7933 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7935 can2=$(do_facet $SINGLEMDS \
7936 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7937 awk '/ldlm_cancel/ {print $2}')
7938 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7939 awk '/ldlm_bl_callback/ {print $2}')
7940 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7941 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7942 lru_resize_enable mdc
7943 lru_resize_enable osc
7945 run_test 120f "Early Lock Cancel: rename test"
7948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7949 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7950 skip "no early lock cancel on server" && return 0
7951 lru_resize_disable mdc
7952 lru_resize_disable osc
7954 echo create $count files
7955 test_mkdir -p $DIR/$tdir
7956 cancel_lru_locks mdc
7957 cancel_lru_locks osc
7960 can0=$(do_facet $SINGLEMDS \
7961 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7962 awk '/ldlm_cancel/ {print $2}')
7963 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7964 awk '/ldlm_bl_callback/ {print $2}')
7965 createmany -o $DIR/$tdir/f $count
7967 can1=$(do_facet $SINGLEMDS \
7968 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7969 awk '/ldlm_cancel/ {print $2}')
7970 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7971 awk '/ldlm_bl_callback/ {print $2}')
7973 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7974 echo rm $count files
7977 can2=$(do_facet $SINGLEMDS \
7978 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7979 awk '/ldlm_cancel/ {print $2}')
7980 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7981 awk '/ldlm_bl_callback/ {print $2}')
7983 echo total: $count removes in $((t2-t1))
7984 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7986 # wait for commitment of removal
7987 lru_resize_enable mdc
7988 lru_resize_enable osc
7990 run_test 120g "Early Lock Cancel: performance test"
7992 test_121() { #bug #10589
7993 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7995 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7996 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7997 lctl set_param fail_loc=0x310
7998 cancel_lru_locks osc > /dev/null
7999 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8000 lctl set_param fail_loc=0
8001 [[ $reads -eq $writes ]] ||
8002 error "read $reads blocks, must be $writes blocks"
8004 run_test 121 "read cancel race ========="
8006 test_123a() { # was test 123, statahead(bug 11401)
8007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8009 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8010 log "testing on UP system. Performance may be not as good as expected."
8015 test_mkdir -p $DIR/$tdir
8016 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8017 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8019 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8020 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8022 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8023 lctl set_param -n llite.*.statahead_max 0
8024 lctl get_param llite.*.statahead_max
8025 cancel_lru_locks mdc
8026 cancel_lru_locks osc
8028 time ls -l $DIR/$tdir | wc -l
8030 delta=$((etime - stime))
8031 log "ls $i files without statahead: $delta sec"
8032 lctl set_param llite.*.statahead_max=$max
8034 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8035 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8036 cancel_lru_locks mdc
8037 cancel_lru_locks osc
8039 time ls -l $DIR/$tdir | wc -l
8041 delta_sa=$((etime - stime))
8042 log "ls $i files with statahead: $delta_sa sec"
8043 lctl get_param -n llite.*.statahead_stats
8044 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8046 [[ $swrong -lt $ewrong ]] &&
8047 log "statahead was stopped, maybe too many locks held!"
8048 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8050 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8051 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8052 lctl set_param -n llite.*.statahead_max 0
8053 lctl get_param llite.*.statahead_max
8054 cancel_lru_locks mdc
8055 cancel_lru_locks osc
8057 time ls -l $DIR/$tdir | wc -l
8059 delta=$((etime - stime))
8060 log "ls $i files again without statahead: $delta sec"
8061 lctl set_param llite.*.statahead_max=$max
8062 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8063 if [ $SLOWOK -eq 0 ]; then
8064 error "ls $i files is slower with statahead!"
8066 log "ls $i files is slower with statahead!"
8072 [ $delta -gt 20 ] && break
8073 [ $delta -gt 8 ] && MULT=$((50 / delta))
8074 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8082 delta=$((etime - stime))
8083 log "rm -r $DIR/$tdir/: $delta seconds"
8085 lctl get_param -n llite.*.statahead_stats
8087 run_test 123a "verify statahead work"
8089 test_123b () { # statahead(bug 15027)
8090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8091 test_mkdir -p $DIR/$tdir
8092 createmany -o $DIR/$tdir/$tfile-%d 1000
8094 cancel_lru_locks mdc
8095 cancel_lru_locks osc
8097 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8098 lctl set_param fail_loc=0x80000803
8099 ls -lR $DIR/$tdir > /dev/null
8101 lctl set_param fail_loc=0x0
8102 lctl get_param -n llite.*.statahead_stats
8107 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8111 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8112 skip "no lru resize on server" && return 0
8114 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8116 log "create $NR files at $DIR/$tdir"
8117 createmany -o $DIR/$tdir/f $NR ||
8118 error "failed to create $NR files in $DIR/$tdir"
8120 cancel_lru_locks mdc
8121 ls -l $DIR/$tdir > /dev/null
8125 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8126 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8127 LRU_SIZE=$($LCTL get_param -n $PARAM)
8128 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8129 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8131 log "NS=$(basename $NSDIR)"
8136 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8137 skip "Not enough cached locks created!"
8144 # We know that lru resize allows one client to hold $LIMIT locks
8145 # for 10h. After that locks begin to be killed by client.
8147 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8150 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8151 # killing locks. Some time was spent for creating locks. This means
8152 # that up to the moment of sleep finish we must have killed some of
8153 # them (10-100 locks). This depends on how fast ther were created.
8154 # Many of them were touched in almost the same moment and thus will
8155 # be killed in groups.
8156 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8158 # Use $LRU_SIZE_B here to take into account real number of locks
8159 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8160 local LRU_SIZE_B=$LRU_SIZE
8162 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8163 log "OLD_LVF=$OLD_LVF"
8164 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8166 # Let's make sure that we really have some margin. Client checks
8167 # cached locks every 10 sec.
8169 log "Sleep ${SLEEP} sec"
8171 while ((SEC<$SLEEP)); do
8175 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8179 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8180 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8182 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8183 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8184 unlinkmany $DIR/$tdir/f $NR
8188 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8189 log "unlink $NR files at $DIR/$tdir"
8190 unlinkmany $DIR/$tdir/f $NR
8192 run_test 124a "lru resize ======================================="
8194 get_max_pool_limit()
8196 local limit=$($LCTL get_param \
8197 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8200 if [[ $l -gt $max ]]; then
8208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8209 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8210 skip "no lru resize on server" && return 0
8212 LIMIT=$(get_max_pool_limit)
8214 NR=$(($(default_lru_size)*20))
8215 if [[ $NR -gt $LIMIT ]]; then
8216 log "Limit lock number by $LIMIT locks"
8219 lru_resize_disable mdc
8220 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8221 error "failed to create $DIR/$tdir/disable_lru_resize"
8223 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8224 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8225 cancel_lru_locks mdc
8228 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8231 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8234 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8238 nolruresize_delta=$((etime-stime))
8239 log "ls -la time: $nolruresize_delta seconds"
8240 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8241 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8243 lru_resize_enable mdc
8244 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8245 error "failed to create $DIR/$tdir/enable_lru_resize"
8247 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8248 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8249 cancel_lru_locks mdc
8252 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8255 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8258 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8262 lruresize_delta=$((etime-stime))
8263 log "ls -la time: $lruresize_delta seconds"
8264 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8266 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8267 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8268 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8269 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8271 log "lru resize performs the same with no lru resize"
8273 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8275 run_test 124b "lru resize (performance test) ======================="
8277 test_125() { # 13358
8278 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8279 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8280 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8281 test_mkdir -p $DIR/d125 || error "mkdir failed"
8282 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8283 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8284 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8286 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8288 test_126() { # bug 12829/13455
8289 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8290 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8291 $GSS && skip "must run as gss disabled" && return
8293 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8294 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8296 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8298 run_test 126 "check that the fsgid provided by the client is taken into account"
8300 test_127a() { # bug 15521
8301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8302 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8303 $LCTL set_param osc.*.stats=0
8304 FSIZE=$((2048 * 1024))
8305 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8306 cancel_lru_locks osc
8307 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8309 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8310 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8311 echo "got $COUNT $NAME"
8312 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8313 eval $NAME=$COUNT || error "Wrong proc format"
8316 read_bytes|write_bytes)
8317 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8318 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8319 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8320 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8321 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8322 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8323 error "sumsquare is too small: $SUMSQ"
8324 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8325 error "sumsquare is too big: $SUMSQ"
8329 done < $DIR/${tfile}.tmp
8331 #check that we actually got some stats
8332 [ "$read_bytes" ] || error "Missing read_bytes stats"
8333 [ "$write_bytes" ] || error "Missing write_bytes stats"
8334 [ "$read_bytes" != 0 ] || error "no read done"
8335 [ "$write_bytes" != 0 ] || error "no write done"
8337 run_test 127a "verify the client stats are sane"
8339 test_127b() { # bug LU-333
8340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8341 $LCTL set_param llite.*.stats=0
8342 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8343 # perform 2 reads and writes so MAX is different from SUM.
8344 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8345 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8346 cancel_lru_locks osc
8347 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8348 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8350 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8351 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8352 echo "got $COUNT $NAME"
8353 eval $NAME=$COUNT || error "Wrong proc format"
8357 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8358 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8359 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8360 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8363 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8364 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8365 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8366 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8370 done < $TMP/${tfile}.tmp
8372 #check that we actually got some stats
8373 [ "$read_bytes" ] || error "Missing read_bytes stats"
8374 [ "$write_bytes" ] || error "Missing write_bytes stats"
8375 [ "$read_bytes" != 0 ] || error "no read done"
8376 [ "$write_bytes" != 0 ] || error "no write done"
8378 run_test 127b "verify the llite client stats are sane"
8380 test_128() { # bug 15212
8382 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8387 result=$(grep error $TMP/$tfile.log)
8389 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8391 run_test 128 "interactive lfs for 2 consecutive find's"
8398 local LDPROC=/proc/fs/ldiskfs
8399 local facets=$(get_facets MDS)
8401 for facet in ${facets//,/ }; do
8402 canondev=$(ldiskfs_canon \
8403 *.$(convert_facet2label $facet).mntdev $facet)
8404 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8405 LDPROC=/sys/fs/ldiskfs
8406 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8412 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8413 skip "Only applicable to ldiskfs-based MDTs"
8416 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8421 test_mkdir -p $DIR/$tdir
8423 # block size of mds1
8424 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8425 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8426 local MAX=$((MDSBLOCKSIZE * 3))
8428 local I=$(stat -c%s "$DIR/$tdir")
8430 local STRIPE_COUNT=1
8431 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8432 MAX=$((MAX*STRIPE_COUNT))
8433 while [[ $I -le $MAX ]]; do
8434 $MULTIOP $DIR/$tdir/$J Oc
8436 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8437 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8438 #and EFBIG for previous versions
8439 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8441 echo "return code $rc received as expected"
8442 multiop $DIR/$tdir/$J Oc ||
8443 error_exit "multiop failed w/o dir size limit"
8445 I=$(stat -c%s "$DIR/$tdir")
8447 if [ $(lustre_version_code $SINGLEMDS) -lt \
8448 $(version_code 2.4.51) ]
8450 [[ $I -eq $MAX ]] && return 0
8452 [[ $I -gt $MAX ]] && return 0
8454 error_exit "current dir size $I, previous limit $MAX"
8455 elif [ $rc -ne 0 ]; then
8457 error_exit "return code $rc received instead of expected " \
8458 "$EFBIG or $ENOSPC, files in dir $I"
8461 I=$(stat -c%s "$DIR/$tdir")
8465 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8467 run_test 129 "test directory size limit ========================"
8476 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8477 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8480 trap cleanup_130 EXIT RETURN
8482 local fm_file=$DIR/$tfile
8483 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8484 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8485 error "dd failed for $fm_file"
8487 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8488 filefrag -ves $fm_file
8490 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8491 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8492 [ $RC != 0 ] && error "filefrag $fm_file failed"
8494 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8495 grep -v "ext:" | grep -v "found")
8496 lun=$($GETSTRIPE -i $fm_file)
8498 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8501 for line in $filefrag_op
8503 frag_lun=`echo $line | cut -d: -f5`
8504 ext_len=`echo $line | cut -d: -f4`
8505 if (( $frag_lun != $lun )); then
8507 error "FIEMAP on 1-stripe file($fm_file) failed"
8510 (( tot_len += ext_len ))
8513 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8515 error "FIEMAP on 1-stripe file($fm_file) failed;"
8521 echo "FIEMAP on single striped file succeeded"
8523 run_test 130a "FIEMAP (1-stripe file)"
8526 [ "$OSTCOUNT" -lt "2" ] &&
8527 skip_env "skipping FIEMAP on 2-stripe file test" && return
8529 [ "$OSTCOUNT" -ge "10" ] &&
8530 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8532 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8533 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8536 trap cleanup_130 EXIT RETURN
8538 local fm_file=$DIR/$tfile
8539 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8540 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8541 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8543 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8544 error "dd failed on $fm_file"
8546 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8547 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8548 grep -v "ext:" | grep -v "found")
8550 last_lun=$(echo $filefrag_op | cut -d: -f5)
8555 for line in $filefrag_op
8557 frag_lun=`echo $line | cut -d: -f5`
8558 ext_len=`echo $line | cut -d: -f4`
8559 if (( $frag_lun != $last_lun )); then
8560 if (( tot_len != 1024 )); then
8562 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8569 (( tot_len += ext_len ))
8572 if (( num_luns != 2 || tot_len != 1024 )); then
8574 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8580 echo "FIEMAP on 2-stripe file succeeded"
8582 run_test 130b "FIEMAP (2-stripe file)"
8585 [ "$OSTCOUNT" -lt "2" ] &&
8586 skip_env "skipping FIEMAP on 2-stripe file" && return
8588 [ "$OSTCOUNT" -ge "10" ] &&
8589 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8591 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8592 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8595 trap cleanup_130 EXIT RETURN
8597 local fm_file=$DIR/$tfile
8598 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8599 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8600 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8602 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8604 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8605 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8607 last_lun=`echo $filefrag_op | cut -d: -f5`
8612 for line in $filefrag_op
8614 frag_lun=`echo $line | cut -d: -f5`
8615 ext_len=`echo $line | cut -d: -f4`
8616 if (( $frag_lun != $last_lun )); then
8617 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8618 if (( logical != 512 )); then
8620 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8623 if (( tot_len != 512 )); then
8625 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8632 (( tot_len += ext_len ))
8635 if (( num_luns != 2 || tot_len != 512 )); then
8637 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8643 echo "FIEMAP on 2-stripe file with hole succeeded"
8645 run_test 130c "FIEMAP (2-stripe file with hole)"
8648 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8650 [ "$OSTCOUNT" -ge "10" ] &&
8651 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8653 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8654 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8656 trap cleanup_130 EXIT RETURN
8658 local fm_file=$DIR/$tfile
8659 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8660 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8661 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8663 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8664 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8665 error "dd failed on $fm_file"
8667 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8668 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8669 grep -v "ext:" | grep -v "found"`
8671 last_lun=`echo $filefrag_op | cut -d: -f5`
8676 for line in $filefrag_op
8678 frag_lun=`echo $line | cut -d: -f5`
8679 ext_len=`echo $line | cut -d: -f4`
8680 if (( $frag_lun != $last_lun )); then
8681 if (( tot_len != 1024 )); then
8683 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8690 (( tot_len += ext_len ))
8693 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8695 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8701 echo "FIEMAP on N-stripe file succeeded"
8703 run_test 130d "FIEMAP (N-stripe file)"
8706 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8708 [ "$OSTCOUNT" -ge "10" ] &&
8709 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8711 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8712 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8714 trap cleanup_130 EXIT RETURN
8716 local fm_file=$DIR/$tfile
8717 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8718 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8719 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8722 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8723 for ((i = 0; i < $NUM_BLKS; i++))
8725 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8728 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8729 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8731 last_lun=`echo $filefrag_op | cut -d: -f5`
8736 for line in $filefrag_op
8738 frag_lun=`echo $line | cut -d: -f5`
8739 ext_len=`echo $line | cut -d: -f4`
8740 if (( $frag_lun != $last_lun )); then
8741 if (( tot_len != $EXPECTED_LEN )); then
8743 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8750 (( tot_len += ext_len ))
8753 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8755 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8761 echo "FIEMAP with continuation calls succeeded"
8763 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8765 # Test for writev/readv
8767 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8768 error "writev test failed"
8769 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8770 error "readv failed"
8773 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8776 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8777 error "append writev test failed"
8778 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8779 error "append writev test failed"
8782 run_test 131b "test append writev"
8785 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8788 run_test 131c "test read/write on file w/o objects"
8791 rwv -f $DIR/$tfile -w -n 1 1572864
8792 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8793 if [ "$NOB" != 1572864 ]; then
8794 error "Short read filed: read $NOB bytes instead of 1572864"
8798 run_test 131d "test short read"
8801 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8802 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8803 error "read hitting hole failed"
8806 run_test 131e "test read hitting hole"
8811 for node in $(osts_nodes); do
8812 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8813 [ x$gl = x"" ] && gl=0
8814 gl_sum=$((gl_sum + gl))
8824 if [ x$som = x"enabled" ]; then
8825 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8826 MOUNT_OPTS=`echo $MOUNT_OPTS |
8827 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8828 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8830 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8831 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8832 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8835 # do remount to make new mount-conf parameters actual
8842 test_132() { #1028, SOM
8843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8844 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8845 local num=$(get_mds_dir $DIR)
8846 local mymds=mds${num}
8847 local MOUNT_OPTS_SAVE=$MOUNT_OPTS
8849 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8850 cancel_lru_locks osc
8852 som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8854 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8855 stat $DIR/$tfile >/dev/null
8856 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8857 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8859 som_mode_switch $som1 $gl1 $gl2
8861 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8862 cancel_lru_locks osc
8864 som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8865 if [ $som1 == $som2 ]; then
8866 error "som is still "$som2
8867 if [ x$som2 = x"enabled" ]; then
8874 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8875 stat $DIR/$tfile >/dev/null
8876 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8877 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8878 som_mode_switch $som2 $gl1 $gl2
8879 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8881 run_test 132 "som avoids glimpse rpc"
8887 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8889 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8891 *) error "Wrong argument $1" ;;
8894 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8895 # if the argument $3 is zero, it means any stat increment is ok.
8896 if [[ $3 -gt 0 ]]; then
8897 count=$(echo $res | awk '{ print $2 }')
8898 [[ $count -ne $3 ]] &&
8899 error "The $2 counter on $1 is wrong - expected $3"
8904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8905 remote_ost_nodsh && skip "remote OST with nodsh" && return
8906 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8908 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8909 { skip "MDS doesn't support rename stats"; return; }
8910 local testdir=$DIR/${tdir}/stats_testdir
8911 mkdir -p $DIR/${tdir}
8914 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8915 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8917 # verify mdt stats first.
8918 mkdir ${testdir} || error "mkdir failed"
8919 check_stats $SINGLEMDS "mkdir" 1
8920 touch ${testdir}/${tfile} || "touch failed"
8921 check_stats $SINGLEMDS "open" 1
8922 check_stats $SINGLEMDS "close" 1
8923 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8924 check_stats $SINGLEMDS "mknod" 1
8925 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8926 check_stats $SINGLEMDS "unlink" 1
8927 rm -f ${testdir}/${tfile} || error "file remove failed"
8928 check_stats $SINGLEMDS "unlink" 2
8930 # remove working dir and check mdt stats again.
8931 rmdir ${testdir} || error "rmdir failed"
8932 check_stats $SINGLEMDS "rmdir" 1
8934 local testdir1=$DIR/${tdir}/stats_testdir1
8936 mkdir -p ${testdir1}
8937 touch ${testdir1}/test1
8938 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8939 check_stats $SINGLEMDS "crossdir_rename" 1
8941 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8942 check_stats $SINGLEMDS "samedir_rename" 1
8946 run_test 133a "Verifying MDT stats ========================================"
8949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8950 remote_ost_nodsh && skip "remote OST with nodsh" && return
8951 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8952 local testdir=$DIR/${tdir}/stats_testdir
8953 mkdir -p ${testdir} || error "mkdir failed"
8954 touch ${testdir}/${tfile} || "touch failed"
8955 cancel_lru_locks mdc
8958 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8959 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8961 # extra mdt stats verification.
8962 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8963 check_stats $SINGLEMDS "setattr" 1
8964 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8965 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8967 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8968 check_stats $SINGLEMDS "getattr" 1
8970 $LFS df || error "lfs failed"
8971 check_stats $SINGLEMDS "statfs" 1
8975 run_test 133b "Verifying extra MDT stats =================================="
8978 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8979 remote_ost_nodsh && skip "remote OST with nodsh" && return
8980 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8981 local testdir=$DIR/${tdir}/stats_testdir
8982 test_mkdir -p ${testdir} || error "mkdir failed"
8984 # verify obdfilter stats.
8985 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8987 cancel_lru_locks osc
8988 wait_delete_completed
8991 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8992 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8994 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8996 cancel_lru_locks osc
8997 check_stats ost "write" 1
8999 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9000 check_stats ost "read" 1
9002 > ${testdir}/${tfile} || error "truncate failed"
9003 check_stats ost "punch" 1
9005 rm -f ${testdir}/${tfile} || error "file remove failed"
9006 wait_delete_completed
9007 check_stats ost "destroy" 1
9011 run_test 133c "Verifying OST stats ========================================"
9018 while [ $value -ge 2 ]; do
9023 if [ $orig -gt $order ]; then
9031 local size=('K' 'M' 'G' 'T');
9033 local size_string=$value
9035 while [ $value -ge 1024 ]; do
9036 if [ $i -gt 3 ]; then
9037 #T is the biggest unit we get here, if that is bigger,
9039 size_string=${value}T
9042 value=$((value >> 10))
9043 if [ $value -lt 1024 ]; then
9044 size_string=${value}${size[$i]}
9055 local context=${2:-.}
9056 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9058 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9064 remote_ost_nodsh && skip "remote OST with nodsh" && return
9065 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9066 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9067 { skip "MDS doesn't support rename stats"; return; }
9069 local testdir1=$DIR/${tdir}/stats_testdir1
9070 local testdir2=$DIR/${tdir}/stats_testdir2
9072 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9074 mkdir -p ${testdir1} || error "mkdir failed"
9075 mkdir -p ${testdir2} || error "mkdir failed"
9077 createmany -o $testdir1/test 512 || error "createmany failed"
9079 # check samedir rename size
9080 mv ${testdir1}/test0 ${testdir1}/test_0
9082 local testdir1_size=$(ls -l $DIR/${tdir} |
9083 awk '/stats_testdir1/ {print $5}')
9084 local testdir2_size=$(ls -l $DIR/${tdir} |
9085 awk '/stats_testdir2/ {print $5}')
9087 testdir1_size=$(order_2 $testdir1_size)
9088 testdir2_size=$(order_2 $testdir2_size)
9090 testdir1_size=$(size_in_KMGT $testdir1_size)
9091 testdir2_size=$(size_in_KMGT $testdir2_size)
9093 echo "source rename dir size: ${testdir1_size}"
9094 echo "target rename dir size: ${testdir2_size}"
9096 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9097 eval $cmd || error "$cmd failed"
9098 local samedir=$($cmd | grep 'same_dir')
9099 local same_sample=$(get_rename_size $testdir1_size)
9100 [ -z "$samedir" ] && error "samedir_rename_size count error"
9101 [[ $same_sample -eq 1 ]] ||
9102 error "samedir_rename_size error $same_sample"
9103 echo "Check same dir rename stats success"
9105 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9107 # check crossdir rename size
9108 mv ${testdir1}/test_0 ${testdir2}/test_0
9110 testdir1_size=$(ls -l $DIR/${tdir} |
9111 awk '/stats_testdir1/ {print $5}')
9112 testdir2_size=$(ls -l $DIR/${tdir} |
9113 awk '/stats_testdir2/ {print $5}')
9115 testdir1_size=$(order_2 $testdir1_size)
9116 testdir2_size=$(order_2 $testdir2_size)
9118 testdir1_size=$(size_in_KMGT $testdir1_size)
9119 testdir2_size=$(size_in_KMGT $testdir2_size)
9121 echo "source rename dir size: ${testdir1_size}"
9122 echo "target rename dir size: ${testdir2_size}"
9124 eval $cmd || error "$cmd failed"
9125 local crossdir=$($cmd | grep 'crossdir')
9126 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9127 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9128 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9129 [[ $src_sample -eq 1 ]] ||
9130 error "crossdir_rename_size error $src_sample"
9131 [[ $tgt_sample -eq 1 ]] ||
9132 error "crossdir_rename_size error $tgt_sample"
9133 echo "Check cross dir rename stats success"
9136 run_test 133d "Verifying rename_stats ========================================"
9139 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9140 local testdir=$DIR/${tdir}/stats_testdir
9141 local ctr f0 f1 bs=32768 count=42 sum
9143 remote_ost_nodsh && skip "remote OST with nodsh" && return
9144 mkdir -p ${testdir} || error "mkdir failed"
9146 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9148 for ctr in {write,read}_bytes; do
9150 cancel_lru_locks osc
9152 do_facet ost1 $LCTL set_param -n \
9153 "obdfilter.*.exports.clear=clear"
9155 if [ $ctr = write_bytes ]; then
9157 f1=${testdir}/${tfile}
9159 f0=${testdir}/${tfile}
9163 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9166 cancel_lru_locks osc
9168 sum=$(do_facet ost1 $LCTL get_param \
9169 "obdfilter.*.exports.*.stats" |
9170 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9171 $1 == ctr { sum += $7 }
9172 END { printf("%0.0f", sum) }')
9174 if ((sum != bs * count)); then
9175 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9181 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9184 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9187 # First without trusting modes.
9188 find $proc_dirs -exec cat '{}' \; &> /dev/null
9190 # Second verifying readability.
9193 -exec cat '{}' \; &> /dev/null ||
9194 error "proc file read failed"
9196 for facet in $SINGLEMDS ost1; do
9197 do_facet $facet find $proc_dirs \
9198 ! -name req_history \
9199 -exec cat '{}' \\\; &> /dev/null
9201 do_facet $facet find $proc_dirs \
9202 ! -name req_history \
9204 -exec cat '{}' \\\; &> /dev/null ||
9205 error "proc file read failed"
9208 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9211 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9214 # Second verifying readability.
9217 -not -name force_lbug \
9218 -not -name changelog_mask \
9219 -exec badarea_io '{}' \; &> /dev/null ||
9220 error "find $proc_dirs failed"
9222 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9223 skip "Too old lustre on MDS"
9225 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9226 skip "Too old lustre on ost1"
9228 for facet in $SINGLEMDS ost1; do
9229 do_facet $facet find $proc_dirs \
9231 -not -name force_lbug \
9232 -not -name changelog_mask \
9233 -exec badarea_io '{}' \\\; &> /dev/null ||
9234 error "$facet find $proc_dirs failed"
9238 # remount the FS in case writes/reads /proc break the FS
9239 cleanup || error "failed to unmount"
9240 setup || error "failed to setup"
9243 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9245 test_140() { #bug-17379
9246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9247 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9248 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9249 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9251 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9252 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9254 while i=`expr $i + 1`; do
9255 test_mkdir -p $i || error "Creating dir $i"
9256 cd $i || error "Changing to $i"
9257 ln -s ../stat stat || error "Creating stat symlink"
9258 # Read the symlink until ELOOP present,
9259 # not LBUGing the system is considered success,
9260 # we didn't overrun the stack.
9261 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9263 if [ $ret -eq 40 ]; then
9266 error "Open stat symlink"
9272 echo "The symlink depth = $i"
9273 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9274 error "Invalid symlink depth"
9276 # Test recursive symlink
9277 ln -s symlink_self symlink_self
9278 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9279 echo "open symlink_self returns $ret"
9280 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9282 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9286 local TF="$TMP/$tfile"
9288 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9290 cancel_lru_locks osc
9291 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9292 remount_client $MOUNT
9294 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9297 $TRUNCATE $DIR/$tfile 6000
9298 cancel_lru_locks osc
9299 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9302 echo "12345" >>$DIR/$tfile
9303 cancel_lru_locks osc
9304 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9307 echo "12345" >>$DIR/$tfile
9308 cancel_lru_locks osc
9309 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9314 run_test 150 "truncate/append tests"
9316 #LU-2902 roc_hit was not able to read all values from lproc
9317 function roc_hit_init() {
9318 local list=$(comma_list $(osts_nodes))
9319 local dir=$DIR/$tdir-check
9320 local file=$dir/file
9326 #use setstripe to do a write to every ost
9327 for i in $(seq 0 $((OSTCOUNT-1))); do
9328 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9329 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9330 idx=$(printf %04x $i)
9331 BEFORE=$(get_osd_param $list *OST*$idx stats |
9332 awk '$1 == "cache_access" {sum += $7}
9333 END { printf("%0.0f", sum) }')
9335 cancel_lru_locks osc
9336 cat $file >/dev/null
9338 AFTER=$(get_osd_param $list *OST*$idx stats |
9339 awk '$1 == "cache_access" {sum += $7}
9340 END { printf("%0.0f", sum) }')
9342 echo BEFORE:$BEFORE AFTER:$AFTER
9343 if ! let "AFTER - BEFORE == 4"; then
9345 error "roc_hit is not safe to use"
9353 function roc_hit() {
9354 local list=$(comma_list $(osts_nodes))
9355 echo $(get_osd_param $list '' stats |
9356 awk '$1 == "cache_hit" {sum += $7}
9357 END { printf("%0.0f", sum) }')
9360 function set_cache() {
9363 if [ "$2" == "off" ]; then
9366 local list=$(comma_list $(osts_nodes))
9367 set_osd_param $list '' $1_cache_enable $on
9369 cancel_lru_locks osc
9373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9374 remote_ost_nodsh && skip "remote OST with nodsh" && return
9377 local list=$(comma_list $(osts_nodes))
9379 # check whether obdfilter is cache capable at all
9380 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9381 echo "not cache-capable obdfilter"
9385 # check cache is enabled on all obdfilters
9386 if get_osd_param $list '' read_cache_enable | grep 0; then
9387 echo "oss cache is disabled"
9391 set_osd_param $list '' writethrough_cache_enable 1
9393 # check write cache is enabled on all obdfilters
9394 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9395 echo "oss write cache is NOT enabled"
9401 #define OBD_FAIL_OBD_NO_LRU 0x609
9402 do_nodes $list $LCTL set_param fail_loc=0x609
9404 # pages should be in the case right after write
9405 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9408 local BEFORE=$(roc_hit)
9409 cancel_lru_locks osc
9410 cat $DIR/$tfile >/dev/null
9411 local AFTER=$(roc_hit)
9413 do_nodes $list $LCTL set_param fail_loc=0
9415 if ! let "AFTER - BEFORE == CPAGES"; then
9416 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9419 # the following read invalidates the cache
9420 cancel_lru_locks osc
9421 set_osd_param $list '' read_cache_enable 0
9422 cat $DIR/$tfile >/dev/null
9424 # now data shouldn't be found in the cache
9426 cancel_lru_locks osc
9427 cat $DIR/$tfile >/dev/null
9429 if let "AFTER - BEFORE != 0"; then
9430 error "IN CACHE: before: $BEFORE, after: $AFTER"
9433 set_osd_param $list '' read_cache_enable 1
9436 run_test 151 "test cache on oss and controls ==============================="
9439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9440 local TF="$TMP/$tfile"
9442 # simulate ENOMEM during write
9443 #define OBD_FAIL_OST_NOMEM 0x226
9444 lctl set_param fail_loc=0x80000226
9445 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9447 sync || error "sync failed"
9448 lctl set_param fail_loc=0
9450 # discard client's cache
9451 cancel_lru_locks osc
9453 # simulate ENOMEM during read
9454 lctl set_param fail_loc=0x80000226
9455 cmp $TF $DIR/$tfile || error "cmp failed"
9456 lctl set_param fail_loc=0
9460 run_test 152 "test read/write with enomem ============================"
9463 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9465 run_test 153 "test if fdatasync does not crash ======================="
9467 dot_lustre_fid_permission_check() {
9469 local ffid=$MOUNT/.lustre/fid/$fid
9472 echo "stat fid $fid"
9473 stat $ffid > /dev/null || error "stat $ffid failed."
9474 echo "touch fid $fid"
9475 touch $ffid || error "touch $ffid failed."
9476 echo "write to fid $fid"
9477 cat /etc/hosts > $ffid || error "write $ffid failed."
9478 echo "read fid $fid"
9479 diff /etc/hosts $ffid || error "read $ffid failed."
9480 echo "append write to fid $fid"
9481 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9482 echo "rename fid $fid"
9483 mv $ffid $test_dir/$tfile.1 &&
9484 error "rename $ffid to $tfile.1 should fail."
9485 touch $test_dir/$tfile.1
9486 mv $test_dir/$tfile.1 $ffid &&
9487 error "rename $tfile.1 to $ffid should fail."
9488 rm -f $test_dir/$tfile.1
9489 echo "truncate fid $fid"
9490 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9491 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9492 echo "link fid $fid"
9493 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9495 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9496 echo "setfacl fid $fid"
9497 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9498 echo "getfacl fid $fid"
9499 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9501 echo "unlink fid $fid"
9502 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9503 echo "mknod fid $fid"
9504 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9506 fid=[0xf00000400:0x1:0x0]
9507 ffid=$MOUNT/.lustre/fid/$fid
9509 echo "stat non-exist fid $fid"
9510 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9511 echo "write to non-exist fid $fid"
9512 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9513 echo "link new fid $fid"
9514 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9516 mkdir -p $test_dir/$tdir
9517 touch $test_dir/$tdir/$tfile
9518 fid=$($LFS path2fid $test_dir/$tdir)
9521 error "error: could not get fid for $test_dir/$dir/$tfile."
9523 ffid=$MOUNT/.lustre/fid/$fid
9526 ls $ffid > /dev/null || error "ls $ffid failed."
9527 echo "touch $fid/$tfile.1"
9528 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9530 echo "touch $MOUNT/.lustre/fid/$tfile"
9531 touch $MOUNT/.lustre/fid/$tfile && \
9532 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9534 echo "setxattr to $MOUNT/.lustre/fid"
9535 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9537 echo "listxattr for $MOUNT/.lustre/fid"
9538 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9540 echo "delxattr from $MOUNT/.lustre/fid"
9541 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9543 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9544 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9545 error "touch invalid fid should fail."
9547 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9548 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9549 error "touch non-normal fid should fail."
9551 echo "rename $tdir to $MOUNT/.lustre/fid"
9552 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9553 error "rename to $MOUNT/.lustre/fid should fail."
9555 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9557 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9558 local new_obf_mode=777
9560 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9561 chmod $new_obf_mode $DIR/.lustre/fid ||
9562 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9564 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9565 [ $obf_mode -eq $new_obf_mode ] ||
9566 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9568 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9569 chmod $old_obf_mode $DIR/.lustre/fid ||
9570 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9573 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9574 fid=$($LFS path2fid $test_dir/$tfile-2)
9576 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9578 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9579 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9580 error "create lov data thru .lustre failed"
9582 echo "cp /etc/passwd $test_dir/$tfile-2"
9583 cp /etc/passwd $test_dir/$tfile-2 ||
9584 error "copy to $test_dir/$tfile-2 failed."
9585 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9586 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9587 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9589 rm -rf $test_dir/tfile.lnk
9590 rm -rf $test_dir/$tfile-2
9594 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9595 skip "Need MDS version at least 2.4.1" && return
9598 local FID=$($LFS path2fid $DIR/$tfile)
9599 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9601 # check that we get the same pathname back
9602 local FOUND=$($LFS fid2path $MOUNT $FID)
9603 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9604 [ "$FOUND" != "$DIR/$tfile" ] &&
9605 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9609 run_test 154A "lfs path2fid and fid2path basic checks"
9612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9613 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9614 { skip "Need MDS version at least 2.2.51"; return 0; }
9615 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9617 cp /etc/hosts $DIR/$tfile
9619 fid=$($LFS path2fid $DIR/$tfile)
9621 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9623 dot_lustre_fid_permission_check "$fid" $DIR ||
9624 error "dot lustre permission check $fid failed"
9626 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9628 touch $MOUNT/.lustre/file &&
9629 error "creation is not allowed under .lustre"
9631 mkdir $MOUNT/.lustre/dir &&
9632 error "mkdir is not allowed under .lustre"
9636 run_test 154a "Open-by-FID"
9639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9640 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9641 { skip "Need MDS version at least 2.2.51"; return 0; }
9643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9645 local remote_dir=$DIR/$tdir/remote_dir
9650 $LFS mkdir -i $MDTIDX $remote_dir ||
9651 error "create remote directory failed"
9653 cp /etc/hosts $remote_dir/$tfile
9655 fid=$($LFS path2fid $remote_dir/$tfile)
9657 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9659 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9660 error "dot lustre permission check $fid failed"
9663 run_test 154b "Open-by-FID for remote directory"
9666 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9667 skip "Need MDS version at least 2.4.1" && return
9669 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9670 local FID1=$($LFS path2fid $DIR/$tfile.1)
9671 local FID2=$($LFS path2fid $DIR/$tfile.2)
9672 local FID3=$($LFS path2fid $DIR/$tfile.3)
9675 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9676 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9677 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9679 [ "$FID" = "${!want}" ] ||
9680 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9684 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9685 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9686 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9690 run_test 154c "lfs path2fid and fid2path multiple arguments"
9693 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9694 skip "Need MDS version at least 2.5.53" && return
9697 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9701 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9708 fid=$($LFS path2fid $DIR/$tfile)
9711 cmd="exec $fd<$DIR/$tfile"
9713 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9714 echo $fid_list | grep $fid
9717 cmd="exec $fd>/dev/null"
9719 if [ $rc -ne 0 ]; then
9720 error "FID $fid not found in open files list $fid_list"
9723 run_test 154d "Verify open file fid"
9727 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9728 skip "Need MDS version at least 2.6.50" && return
9730 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9731 error ".lustre returned by readdir"
9734 run_test 154e ".lustre is not returned by readdir"
9736 test_155_small_load() {
9737 local temp=$TMP/$tfile
9738 local file=$DIR/$tfile
9740 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9741 error "dd of=$temp bs=6096 count=1 failed"
9743 cancel_lru_locks osc
9744 cmp $temp $file || error "$temp $file differ"
9746 $TRUNCATE $temp 6000
9747 $TRUNCATE $file 6000
9748 cmp $temp $file || error "$temp $file differ (truncate1)"
9750 echo "12345" >>$temp
9751 echo "12345" >>$file
9752 cmp $temp $file || error "$temp $file differ (append1)"
9754 echo "12345" >>$temp
9755 echo "12345" >>$file
9756 cmp $temp $file || error "$temp $file differ (append2)"
9762 test_155_big_load() {
9763 remote_ost_nodsh && skip "remote OST with nodsh" && return
9764 local temp=$TMP/$tfile
9765 local file=$DIR/$tfile
9768 local cache_size=$(do_facet ost$((MAXI+1)) \
9769 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9770 local large_file_size=$((cache_size * 2))
9772 echo "OSS cache size: $cache_size KB"
9773 echo "Large file size: $large_file_size KB"
9775 [ $MAXV -le $large_file_size ] && \
9776 skip_env "max available OST size needs > $large_file_size KB" && \
9779 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9781 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9782 error "dd of=$temp bs=$large_file_size count=1k failed"
9785 cancel_lru_locks osc
9786 cmp $temp $file || error "$temp $file differ"
9793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9795 set_cache writethrough on
9798 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9803 set_cache writethrough off
9806 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9811 set_cache writethrough on
9814 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9819 set_cache writethrough off
9822 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9827 set_cache writethrough on
9830 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9835 set_cache writethrough off
9838 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9841 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9843 set_cache writethrough on
9846 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9851 set_cache writethrough off
9854 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9861 local file="$DIR/$tfile"
9863 [ "$(facet_fstype ost1)" = "zfs" ] &&
9864 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9869 log "Turn on read and write cache"
9871 set_cache writethrough on
9873 log "Write data and read it back."
9874 log "Read should be satisfied from the cache."
9875 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9877 cancel_lru_locks osc
9878 cat $file >/dev/null
9880 if ! let "AFTER - BEFORE == CPAGES"; then
9881 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9883 log "cache hits:: before: $BEFORE, after: $AFTER"
9886 log "Read again; it should be satisfied from the cache."
9888 cancel_lru_locks osc
9889 cat $file >/dev/null
9891 if ! let "AFTER - BEFORE == CPAGES"; then
9892 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9894 log "cache hits:: before: $BEFORE, after: $AFTER"
9898 log "Turn off the read cache and turn on the write cache"
9900 set_cache writethrough on
9902 log "Read again; it should be satisfied from the cache."
9904 cancel_lru_locks osc
9905 cat $file >/dev/null
9907 if ! let "AFTER - BEFORE == CPAGES"; then
9908 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9910 log "cache hits:: before: $BEFORE, after: $AFTER"
9913 log "Read again; it should not be satisfied from the cache."
9915 cancel_lru_locks osc
9916 cat $file >/dev/null
9918 if ! let "AFTER - BEFORE == 0"; then
9919 error "IN CACHE: before: $BEFORE, after: $AFTER"
9921 log "cache hits:: before: $BEFORE, after: $AFTER"
9924 log "Write data and read it back."
9925 log "Read should be satisfied from the cache."
9926 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9928 cancel_lru_locks osc
9929 cat $file >/dev/null
9931 if ! let "AFTER - BEFORE == CPAGES"; then
9932 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9934 log "cache hits:: before: $BEFORE, after: $AFTER"
9937 log "Read again; it should not be satisfied from the cache."
9939 cancel_lru_locks osc
9940 cat $file >/dev/null
9942 if ! let "AFTER - BEFORE == 0"; then
9943 error "IN CACHE: before: $BEFORE, after: $AFTER"
9945 log "cache hits:: before: $BEFORE, after: $AFTER"
9949 log "Turn off read and write cache"
9951 set_cache writethrough off
9953 log "Write data and read it back"
9954 log "It should not be satisfied from the cache."
9956 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9957 cancel_lru_locks osc
9959 cat $file >/dev/null
9961 if ! let "AFTER - BEFORE == 0"; then
9962 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9964 log "cache hits:: before: $BEFORE, after: $AFTER"
9967 log "Turn on the read cache and turn off the write cache"
9969 set_cache writethrough off
9971 log "Write data and read it back"
9972 log "It should not be satisfied from the cache."
9974 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9976 cancel_lru_locks osc
9977 cat $file >/dev/null
9979 if ! let "AFTER - BEFORE == 0"; then
9980 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9982 log "cache hits:: before: $BEFORE, after: $AFTER"
9985 log "Read again; it should be satisfied from the cache."
9987 cancel_lru_locks osc
9988 cat $file >/dev/null
9990 if ! let "AFTER - BEFORE == CPAGES"; then
9991 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9993 log "cache hits:: before: $BEFORE, after: $AFTER"
9998 run_test 156 "Verification of tunables ============================"
10002 if [[ $MDSCOUNT -gt 1 ]]; then
10003 error_ignore bz17935 $*
10011 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10013 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10015 if [ $MASK -eq 1 ]; then
10016 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10018 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10022 changelog_extract_field() {
10026 local identifier=$4
10028 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10029 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10035 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10036 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10037 { skip "Need MDS version at least 2.2.0"; return; }
10039 local CL_USERS="mdd.$MDT0.changelog_users"
10040 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10041 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10042 echo "Registered as changelog user $USER"
10043 $GET_CL_USERS | grep -q $USER ||
10044 error "User $USER not found in changelog_users"
10047 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10048 touch $DIR/$tdir/pics/2008/zachy/timestamp
10049 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10050 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10051 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10052 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10053 rm $DIR/$tdir/pics/desktop.jpg
10055 $LFS changelog $MDT0 | tail -5
10057 echo "verifying changelog mask"
10058 changelog_chmask "MKDIR"
10059 changelog_chmask "CLOSE"
10061 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10062 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10064 changelog_chmask "MKDIR"
10065 changelog_chmask "CLOSE"
10067 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10068 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10070 $LFS changelog $MDT0
10071 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10072 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10073 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10074 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10077 echo "verifying target fid"
10078 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10079 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10080 [ "$fidc" == "$fidf" ] ||
10081 err17935 "fid in changelog $fidc != file fid $fidf"
10082 echo "verifying parent fid"
10083 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10084 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10085 [ "$fidc" == "$fidf" ] ||
10086 err17935 "pfid in changelog $fidc != dir fid $fidf"
10088 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10089 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10090 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10091 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10092 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10093 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10095 MIN_REC=$($GET_CL_USERS |
10096 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10097 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10098 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10099 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10100 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10102 # LU-3446 changelog index reset on MDT restart
10103 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10104 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10105 $LFS changelog_clear $MDT0 $USER 0
10106 stop $SINGLEMDS || error "Fail to stop MDT."
10107 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10108 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10109 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10110 [ $CUR_REC1 == $CUR_REC2 ] ||
10111 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10113 echo "verifying user deregister"
10114 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10115 $GET_CL_USERS | grep -q $USER &&
10116 error "User $USER still in changelog_users"
10118 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10119 if [ $USERS -eq 0 ]; then
10120 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10121 touch $DIR/$tdir/chloe
10122 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10123 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10124 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10126 echo "$USERS other changelog users; can't verify off"
10129 run_test 160a "changelog sanity"
10131 test_160b() { # LU-3587
10132 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10133 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10134 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10135 { skip "Need MDS version at least 2.2.0"; return; }
10137 local CL_USERS="mdd.$MDT0.changelog_users"
10138 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10139 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10140 echo "Registered as changelog user $USER"
10141 $GET_CL_USERS | grep -q $USER ||
10142 error "User $USER not found in changelog_users"
10144 local LONGNAME1=$(str_repeat a 255)
10145 local LONGNAME2=$(str_repeat b 255)
10148 echo "creating very long named file"
10149 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10150 echo "moving very long named file"
10151 mv $LONGNAME1 $LONGNAME2
10153 $LFS changelog $MDT0 | grep RENME
10155 echo "deregistering $USER"
10156 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10160 run_test 160b "Verify that very long rename doesn't crash in changelog"
10164 local server_version=$(lustre_version_code $SINGLEMDS)
10166 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10167 [[ $server_version -gt $(version_code 2.5.1) &&
10168 $server_version -lt $(version_code 2.5.50) ]] ||
10169 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10172 # Registration step
10173 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10174 changelog_register -n)
10177 mkdir -p $DIR/$tdir
10178 $MCREATE $DIR/$tdir/foo_160c
10179 changelog_chmask "TRUNC"
10180 $TRUNCATE $DIR/$tdir/foo_160c 200
10181 changelog_chmask "TRUNC"
10182 $TRUNCATE $DIR/$tdir/foo_160c 199
10183 $LFS changelog $MDT0
10184 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10185 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10186 $LFS changelog_clear $MDT0 $USER 0
10188 # Deregistration step
10189 echo "deregistering $USER"
10190 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10192 run_test 160c "verify that changelog log catch the truncate event"
10195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10196 test_mkdir -p -c1 $DIR/$tdir
10197 cp /etc/hosts $DIR/$tdir/$tfile
10198 test_mkdir -c1 $DIR/$tdir/foo1
10199 test_mkdir -c1 $DIR/$tdir/foo2
10200 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10201 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10202 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10203 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10204 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10205 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10206 $LFS fid2path $DIR $FID
10207 err17935 "bad link ea"
10210 rm $DIR/$tdir/foo2/zachary
10212 rm $DIR/$tdir/foo2/thor
10214 rm $DIR/$tdir/$tfile
10216 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10217 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10219 $LFS fid2path $DIR $FID
10220 err17935 "bad link rename"
10222 rm $DIR/$tdir/foo2/maggie
10225 local longname=filename_avg_len_is_thirty_two_
10226 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10227 error "failed to hardlink many files"
10228 links=$($LFS fid2path $DIR $FID | wc -l)
10229 echo -n "${links}/1000 links in link EA"
10230 [[ $links -gt 60 ]] ||
10231 err17935 "expected at least 60 links in link EA"
10232 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10233 error "failed to unlink many hardlinks"
10235 run_test 161a "link ea sanity"
10238 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10239 [ $MDSCOUNT -lt 2 ] &&
10240 skip "skipping remote directory test" && return
10242 local remote_dir=$DIR/$tdir/remote_dir
10244 mkdir -p $DIR/$tdir
10245 $LFS mkdir -i $MDTIDX $remote_dir ||
10246 error "create remote directory failed"
10248 cp /etc/hosts $remote_dir/$tfile
10249 mkdir -p $remote_dir/foo1
10250 mkdir -p $remote_dir/foo2
10251 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10252 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10253 ln $remote_dir/$tfile $remote_dir/foo1/luna
10254 ln $remote_dir/$tfile $remote_dir/foo2/thor
10256 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10258 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10259 $LFS fid2path $DIR $FID
10260 err17935 "bad link ea"
10263 rm $remote_dir/foo2/zachary
10265 rm $remote_dir/foo2/thor
10267 rm $remote_dir/$tfile
10269 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10270 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10271 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10272 $LFS fid2path $DIR $FID
10273 err17935 "bad link rename"
10275 rm $remote_dir/foo2/maggie
10278 local longname=filename_avg_len_is_thirty_two_
10279 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10280 error "failed to hardlink many files"
10281 links=$($LFS fid2path $DIR $FID | wc -l)
10282 echo -n "${links}/1000 links in link EA"
10283 [[ ${links} -gt 60 ]] ||
10284 err17935 "expected at least 60 links in link EA"
10285 unlinkmany $remote_dir/foo2/$longname 1000 ||
10286 error "failed to unlink many hardlinks"
10288 run_test 161b "link ea sanity under remote directory"
10291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10292 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10293 skip "Need MDS version at least 2.1.5" && return
10295 # define CLF_RENAME_LAST 0x0001
10296 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10297 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10298 changelog_register -n)
10300 mkdir -p $DIR/$tdir
10301 touch $DIR/$tdir/foo_161c
10302 touch $DIR/$tdir/bar_161c
10303 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10304 $LFS changelog $MDT0 | grep RENME
10305 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10307 $LFS changelog_clear $MDT0 $USER 0
10308 if [ x$flags != "x0x1" ]; then
10309 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10311 error "flag $flags is not 0x1"
10313 echo "rename overwrite a target having nlink = 1," \
10314 "changelog record has flags of $flags"
10316 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10317 touch $DIR/$tdir/foo_161c
10318 touch $DIR/$tdir/bar_161c
10319 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10320 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10321 $LFS changelog $MDT0 | grep RENME
10322 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10323 $LFS changelog_clear $MDT0 $USER 0
10324 if [ x$flags != "x0x0" ]; then
10325 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10327 error "flag $flags is not 0x0"
10329 echo "rename overwrite a target having nlink > 1," \
10330 "changelog record has flags of $flags"
10332 # rename doesn't overwrite a target (changelog flag 0x0)
10333 touch $DIR/$tdir/foo_161c
10334 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10335 $LFS changelog $MDT0 | grep RENME
10336 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10337 $LFS changelog_clear $MDT0 $USER 0
10338 if [ x$flags != "x0x0" ]; then
10339 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10341 error "flag $flags is not 0x0"
10343 echo "rename doesn't overwrite a target," \
10344 "changelog record has flags of $flags"
10346 # define CLF_UNLINK_LAST 0x0001
10347 # unlink a file having nlink = 1 (changelog flag 0x1)
10348 rm -f $DIR/$tdir/foo2_161c
10349 $LFS changelog $MDT0 | grep UNLNK
10350 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10351 $LFS changelog_clear $MDT0 $USER 0
10352 if [ x$flags != "x0x1" ]; then
10353 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10355 error "flag $flags is not 0x1"
10357 echo "unlink a file having nlink = 1," \
10358 "changelog record has flags of $flags"
10360 # unlink a file having nlink > 1 (changelog flag 0x0)
10361 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10362 rm -f $DIR/$tdir/foobar_161c
10363 $LFS changelog $MDT0 | grep UNLNK
10364 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10365 $LFS changelog_clear $MDT0 $USER 0
10366 if [ x$flags != "x0x0" ]; then
10367 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10369 error "flag $flags is not 0x0"
10371 echo "unlink a file having nlink > 1," \
10372 "changelog record has flags of $flags"
10373 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10375 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10382 local path=$(${LFS} fid2path $*)
10385 if [ $RC -ne 0 ]; then
10386 err17935 "path looked up of $expected failed. Error $RC"
10388 elif [ "${path}" != "${expected}" ]; then
10389 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10392 echo "fid $fid resolves to path $path (expected $expected)"
10396 # Make changes to filesystem
10397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10398 test_mkdir -p -c1 $DIR/$tdir/d2
10399 touch $DIR/$tdir/d2/$tfile
10400 touch $DIR/$tdir/d2/x1
10401 touch $DIR/$tdir/d2/x2
10402 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10403 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10405 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10406 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10407 error "check path $tdir/d2/$tfile failed"
10410 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10411 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10412 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10413 error "check path $tdir/d2/p/q/r/slink failed"
10415 # softlink to wrong file
10416 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10417 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10418 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10419 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10422 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10423 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10424 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10425 # fid2path dir/fsname should both work
10426 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10427 error "check path $tdir/d2/a/b/c/new_file failed"
10428 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10429 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10431 # hardlink count: check that there are 2 links
10432 # Doesnt work with CMD yet: 17935
10433 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10434 err17935 "expected 2 links"
10436 # hardlink indexing: remove the first link
10437 rm $DIR/$tdir/d2/p/q/r/hlink
10438 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10439 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10443 run_test 162 "path lookup sanity"
10446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10447 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10450 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10451 error "create striped dir failed"
10453 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10454 tail -n 1 | awk '{print $2}')
10455 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10457 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10458 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10461 for ((i=0;i<5;i++)); do
10462 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10463 error "get fid for f$i failed"
10464 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10465 error "check path $tdir/striped_dir/f$i failed"
10467 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10468 error "get fid for d$i failed"
10469 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10470 error "check path $tdir/striped_dir/d$i failed"
10475 run_test 162b "striped directory path lookup sanity"
10478 # do directio so as not to populate the page cache
10479 log "creating a 10 Mb file"
10480 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10481 log "starting reads"
10482 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10483 log "truncating the file"
10484 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10486 kill %+ || true # reads might have finished
10487 echo "wait until dd is finished"
10489 log "removing the temporary file"
10490 rm -rf $DIR/$tfile || error "tmp file removal failed"
10492 run_test 169 "parallel read and truncate should not deadlock"
10495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10496 $LCTL clear # bug 18514
10497 $LCTL debug_daemon start $TMP/${tfile}_log_good
10499 $LCTL debug_daemon stop
10500 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10501 error "sed failed to read log_good"
10503 $LCTL debug_daemon start $TMP/${tfile}_log_good
10505 $LCTL debug_daemon stop
10507 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10508 error "lctl df log_bad failed"
10510 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10511 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10513 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10514 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10516 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10517 error "bad_line good_line1 good_line2 are empty"
10519 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10520 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10521 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10523 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10524 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10525 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10527 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10528 error "bad_line_new good_line_new are empty"
10530 local expected_good=$((good_line1 + good_line2*2))
10532 rm -f $TMP/${tfile}*
10533 # LU-231, short malformed line may not be counted into bad lines
10534 if [ $bad_line -ne $bad_line_new ] &&
10535 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10536 error "expected $bad_line bad lines, but got $bad_line_new"
10540 if [ $expected_good -ne $good_line_new ]; then
10541 error "expected $expected_good good lines, but got $good_line_new"
10546 run_test 170 "test lctl df to handle corrupted log ====================="
10548 test_171() { # bug20592
10549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10550 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10551 $LCTL set_param fail_loc=0x50e
10552 $LCTL set_param fail_val=3000
10553 multiop_bg_pause $DIR/$tfile O_s || true
10555 kill -USR1 $MULTIPID
10559 if dmesg | grep "recursive fault"; then
10560 error "caught a recursive fault"
10562 $LCTL set_param fail_loc=0
10565 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10567 # it would be good to share it with obdfilter-survey/iokit-libecho code
10568 setup_obdecho_osc () {
10571 local obdfilter_name=$2
10572 echo "Creating new osc for $obdfilter_name on $ost_nid"
10573 # make sure we can find loopback nid
10574 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10576 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10577 ${obdfilter_name}_osc_UUID || rc=2; }
10578 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10579 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10583 cleanup_obdecho_osc () {
10584 local obdfilter_name=$1
10585 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10586 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10593 local pages=${3:-64}
10598 local obd_size=$(get_obd_size $node $OBD)
10599 local page_size=$(get_page_size $node)
10600 if [[ -n "$obd_size" ]]; then
10601 local new_count=$((obd_size / (pages * page_size / 1024)))
10602 [[ $new_count -ge $count ]] || count=$new_count
10605 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10606 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10608 if [ $rc -eq 0 ]; then
10609 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10610 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10612 echo "New object id is $id"
10613 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10615 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10616 "test_brw $count w v $pages $id" || rc=4; }
10617 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10619 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10620 "cleanup" || rc=5; }
10621 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10622 "detach" || rc=6; }
10623 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10629 remote_ost_nodsh && skip "remote OST with nodsh" && return
10631 local rmmod_local=0
10633 if ! module_loaded obdecho; then
10634 load_module obdecho/obdecho
10638 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10639 local host=$(lctl get_param -n osc.$osc.import |
10640 awk '/current_connection:/ {print $2}' )
10641 local target=$(lctl get_param -n osc.$osc.import |
10642 awk '/target:/ {print $2}' )
10643 target=${target%_UUID}
10645 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10646 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10647 [[ -n $target ]] && cleanup_obdecho_osc $target
10648 [ $rmmod_local -eq 1 ] && rmmod obdecho
10651 run_test 180a "test obdecho on osc"
10654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10655 remote_ost_nodsh && skip "remote OST with nodsh" && return
10657 local rmmod_remote=0
10659 do_facet ost1 "lsmod | grep -q obdecho || " \
10660 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10661 "modprobe obdecho; }" && rmmod_remote=1
10662 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10663 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10664 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10667 run_test 180b "test obdecho directly on obdfilter"
10669 test_180c() { # LU-2598
10670 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10671 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10672 skip "Need MDS version at least 2.4.0" && return
10675 local rmmod_remote=false
10676 local pages=16384 # 64MB bulk I/O RPC size
10679 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10680 rmmod_remote=true || error "failed to load module obdecho"
10682 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10684 if [ -n "$target" ]; then
10685 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10687 echo "there is no obdfilter target on ost1"
10690 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10693 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10695 test_181() { # bug 22177
10696 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10697 # create enough files to index the directory
10698 createmany -o $DIR/$tdir/foobar 4000
10699 # print attributes for debug purpose
10702 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10704 # remove the files & current working dir
10705 unlinkmany $DIR/$tdir/foobar 4000
10707 kill -USR1 $MULTIPID
10709 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10712 run_test 181 "Test open-unlinked dir ========================"
10715 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10716 # disable MDC RPC lock wouldn't crash client
10720 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10721 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10722 $LCTL set_param fail_loc=0x804
10724 for (( i=0; i < $tcount; i++ )) ; do
10725 mkdir $DIR/$tdir/$i
10726 createmany -o $DIR/$tdir/$i/f- $fcount &
10730 for (( i=0; i < $tcount; i++ )) ; do
10731 unlinkmany $DIR/$tdir/$i/f- $fcount &
10737 $LCTL set_param fail_loc=0
10739 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10741 test_183() { # LU-2275
10742 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10743 skip "Need MDS version at least 2.3.56" && return
10745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10746 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10747 echo aaa > $DIR/$tdir/$tfile
10749 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10750 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10752 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10753 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10755 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10757 # Flush negative dentry cache
10758 touch $DIR/$tdir/$tfile
10760 # We are not checking for any leaked references here, they'll
10761 # become evident next time we do cleanup with module unload.
10764 run_test 183 "No crash or request leak in case of strange dispositions ========"
10766 # test suite 184 is for LU-2016, LU-2017
10768 check_swap_layouts_support && return 0
10770 dir0=$DIR/$tdir/$testnum
10771 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10776 $SETSTRIPE -c1 $file1
10778 $SETSTRIPE -c2 $file2
10780 gen1=$($GETSTRIPE -g $file1)
10781 gen2=$($GETSTRIPE -g $file2)
10783 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10784 gen=$($GETSTRIPE -g $file1)
10785 [[ $gen1 != $gen ]] ||
10786 "Layout generation on $file1 does not change"
10787 gen=$($GETSTRIPE -g $file2)
10788 [[ $gen2 != $gen ]] ||
10789 "Layout generation on $file2 does not change"
10791 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10792 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10794 run_test 184a "Basic layout swap"
10797 check_swap_layouts_support && return 0
10799 dir0=$DIR/$tdir/$testnum
10800 mkdir -p $dir0 || error "creating dir $dir0"
10807 $SETSTRIPE -c1 $file1
10808 $SETSTRIPE -c2 $file2
10809 $SETSTRIPE -c1 $file3
10810 chown $RUNAS_ID $file3
10811 gen1=$($GETSTRIPE -g $file1)
10812 gen2=$($GETSTRIPE -g $file2)
10814 $LFS swap_layouts $dir1 $dir2 &&
10815 error "swap of directories layouts should fail"
10816 $LFS swap_layouts $dir1 $file1 &&
10817 error "swap of directory and file layouts should fail"
10818 $RUNAS $LFS swap_layouts $file1 $file2 &&
10819 error "swap of file we cannot write should fail"
10820 $LFS swap_layouts $file1 $file3 &&
10821 error "swap of file with different owner should fail"
10822 /bin/true # to clear error code
10824 run_test 184b "Forbidden layout swap (will generate errors)"
10827 check_swap_layouts_support && return 0
10829 local dir0=$DIR/$tdir/$testnum
10830 mkdir -p $dir0 || error "creating dir $dir0"
10832 local ref1=$dir0/ref1
10833 local ref2=$dir0/ref2
10834 local file1=$dir0/file1
10835 local file2=$dir0/file2
10836 # create a file large enough for the concurent test
10837 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10838 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10839 echo "ref file size: ref1($(stat -c %s $ref1))," \
10840 "ref2($(stat -c %s $ref2))"
10843 dd if=$ref1 of=$file1 bs=16k &
10846 # Make sure dd starts to copy file
10847 while [ ! -f $file1 ]; do sleep 0.1; done
10849 $LFS swap_layouts $file1 $file2
10852 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10853 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10855 # how many bytes copied before swapping layout
10856 local copied=$(stat -c %s $file2)
10857 local remaining=$(stat -c %s $ref1)
10858 remaining=$((remaining - copied))
10859 echo "Copied $copied bytes before swapping layout..."
10861 cmp -n $copied $file1 $ref2 | grep differ &&
10862 error "Content mismatch [0, $copied) of ref2 and file1"
10863 cmp -n $copied $file2 $ref1 ||
10864 error "Content mismatch [0, $copied) of ref1 and file2"
10865 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10866 error "Content mismatch [$copied, EOF) of ref1 and file1"
10869 rm -f $ref1 $ref2 $file1 $file2
10871 run_test 184c "Concurrent write and layout swap"
10874 check_swap_layouts_support && return 0
10875 [ -z "$(which getfattr 2>/dev/null)" ] &&
10876 skip "no getfattr command" && return 0
10878 local file1=$DIR/$tdir/$tfile-1
10879 local file2=$DIR/$tdir/$tfile-2
10880 local file3=$DIR/$tdir/$tfile-3
10884 mkdir -p $DIR/$tdir
10885 touch $file1 || error "create $file1 failed"
10886 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10887 error "create $file2 failed"
10888 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10889 error "create $file3 failed"
10890 lovea1=$($LFS getstripe $file1 | sed 1d)
10892 $LFS swap_layouts $file2 $file3 ||
10893 error "swap $file2 $file3 layouts failed"
10894 $LFS swap_layouts $file1 $file2 ||
10895 error "swap $file1 $file2 layouts failed"
10897 lovea2=$($LFS getstripe $file2 | sed 1d)
10898 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10900 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10901 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10903 run_test 184d "allow stripeless layouts swap"
10906 test_185() { # LU-2441
10907 # LU-3553 - no volatile file support in old servers
10908 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10909 { skip "Need MDS version at least 2.3.60"; return 0; }
10911 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10912 touch $DIR/$tdir/spoo
10913 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10914 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10915 error "cannot create/write a volatile file"
10916 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10917 error "FID is still valid after close"
10919 multiop_bg_pause $DIR/$tdir vVw4096_c
10926 # assume that the next FID for this client is sequential, since stdout
10927 # is unfortunately eaten by multiop_bg_pause
10928 local n=$((${fidv[1]} + 1))
10929 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10930 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10931 error "FID is missing before close"
10932 kill -USR1 $multi_pid
10933 # 1 second delay, so if mtime change we will see it
10935 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10936 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10938 run_test 185 "Volatile file support"
10941 local dir0=$DIR/$tdir/$testnum
10942 mkdir -p $dir0 || error "creating dir $dir0"
10944 local file=$dir0/file1
10945 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10946 local dv1=$($LFS data_version $file)
10947 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10948 local dv2=$($LFS data_version $file)
10949 [[ $dv1 != $dv2 ]] ||
10950 error "data version did not change on write $dv1 == $dv2"
10955 run_test 187a "Test data version change"
10958 local dir0=$DIR/$tdir/$testnum
10959 mkdir -p $dir0 || error "creating dir $dir0"
10961 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10962 [[ ${DV[0]} != ${DV[1]} ]] ||
10963 error "data version did not change on write"\
10964 " ${DV[0]} == ${DV[1]}"
10969 run_test 187b "Test data version change on volatile file"
10972 check_file_in_pool()
10977 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10980 for t in $tlist ; do
10981 [ "$i" -eq "$t" ] && continue 2
10984 echo "pool list: $tlist"
10985 echo "striping: $res"
10986 error_noexit "$file not allocated in $pool"
10993 echo "Creating new pool"
10996 create_pool $FSNAME.$pool ||
10997 { error_noexit "No pool created, result code $?"; return 1; }
10998 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10999 { error_noexit "$pool not in lfs pool_list"; return 2; }
11002 pool_add_targets() {
11003 echo "Adding targets to pool"
11009 local list=$(seq $first $step $last)
11011 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
11012 do_facet mgs $LCTL pool_add \
11013 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
11014 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
11015 | sort -u | tr '\n' ' ' " "$t" || {
11016 error_noexit "Add to pool failed"
11019 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
11020 local addcount=$(((last - first) / step + 1))
11021 [ $lfscount -eq $addcount ] || {
11022 error_noexit "lfs pool_list bad ost count" \
11023 "$lfscount != $addcount"
11031 echo "Setting pool on directory $tdir"
11033 $SETSTRIPE -c 2 -p $pool $tdir && return 0
11035 error_noexit "Cannot set pool $pool to $tdir"
11042 echo "Checking pool on directory $tdir"
11044 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
11045 [ "$res" = "$pool" ] && return 0
11047 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
11051 pool_dir_rel_path() {
11052 echo "Testing relative path works well"
11057 mkdir -p $root/$tdir/$tdir
11059 pool_set_dir $pool $tdir || return 1
11060 pool_set_dir $pool ./$tdir || return 2
11061 pool_set_dir $pool ../$tdir || return 3
11062 pool_set_dir $pool ../$tdir/$tdir || return 4
11063 rm -rf $tdir; cd - > /dev/null
11066 pool_alloc_files() {
11067 echo "Checking files allocation from directory pool"
11074 for i in $(seq -w 1 $count)
11076 local file=$tdir/file-$i
11078 check_file_in_pool $file $pool "$tlist" || \
11079 failed=$((failed + 1))
11081 [ "$failed" = 0 ] && return 0
11083 error_noexit "$failed files not allocated in $pool"
11087 pool_create_files() {
11088 echo "Creating files in pool"
11096 for i in $(seq -w 1 $count)
11098 local file=$tdir/spoo-$i
11099 $SETSTRIPE -p $pool $file
11100 check_file_in_pool $file $pool "$tlist" || \
11101 failed=$((failed + 1))
11103 [ "$failed" = 0 ] && return 0
11105 error_noexit "$failed files not allocated in $pool"
11110 echo "Checking 'lfs df' output"
11113 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
11115 local res=$($LFS df --pool $FSNAME.$pool |
11117 grep "$FSNAME-OST" |
11119 [ "$res" = "$t" ] && return 0
11121 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
11125 pool_file_rel_path() {
11126 echo "Creating files in a pool with relative pathname"
11131 { error_noexit "unable to create $tdir"; return 1 ; }
11132 local file="/..$tdir/$tfile-1"
11133 $SETSTRIPE -p $pool $file ||
11134 { error_noexit "unable to create $file" ; return 2 ; }
11137 $SETSTRIPE -p $pool $tfile-2 || {
11138 error_noexit "unable to create $tfile-2 in $tdir"
11143 pool_remove_first_target() {
11144 echo "Removing first target from a pool"
11147 local pname="lov.$FSNAME-*.pools.$pool"
11148 local t=$($LCTL get_param -n $pname | head -n1)
11149 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11150 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
11151 error_noexit "$t not removed from $FSNAME.$pool"
11156 pool_remove_all_targets() {
11157 echo "Removing all targets from pool"
11160 local pname="lov.$FSNAME-*.pools.$pool"
11161 for t in $($LCTL get_param -n $pname | sort -u)
11163 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11165 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
11166 error_noexit "Pool $FSNAME.$pool cannot be drained"
11169 # striping on an empty/nonexistant pool should fall back
11170 # to "pool of everything"
11172 error_noexit "failed to use fallback striping for empty pool"
11175 # setstripe on an empty pool should fail
11176 $SETSTRIPE -p $pool $file 2>/dev/null && {
11177 error_noexit "expected failure when creating file" \
11185 echo "Destroying pool"
11189 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
11192 # striping on an empty/nonexistant pool should fall back
11193 # to "pool of everything"
11195 error_noexit "failed to use fallback striping for missing pool"
11198 # setstripe on an empty pool should fail
11199 $SETSTRIPE -p $pool $file 2>/dev/null && {
11200 error_noexit "expected failure when creating file" \
11201 "with missing pool"
11205 # get param should return err once pool is gone
11206 if wait_update $HOSTNAME "lctl get_param -n \
11207 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
11209 remove_pool_from_list $FSNAME.$pool
11212 error_noexit "Pool $FSNAME.$pool is not destroyed"
11217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11218 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11220 local POOL=${POOL:-cea1}
11221 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11222 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11225 local last_ost=$(($OSTCOUNT - 1))
11227 local ost_list=$(seq $first_ost $ost_step $last_ost)
11228 local ost_range="$first_ost $last_ost $ost_step"
11229 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11230 local file_dir=$POOL_ROOT/file_tst
11234 # former test_200a test_200b
11235 pool_add $POOL || { rc=$? ; break; }
11236 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11237 # former test_200c test_200d
11238 mkdir -p $test_path
11239 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11240 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11241 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11242 || { rc=$? ; break; }
11243 # former test_200e test_200f
11244 local files=$((OSTCOUNT*3))
11245 pool_alloc_files $POOL $test_path $files "$ost_list" \
11246 || { rc=$? ; break; }
11247 pool_create_files $POOL $file_dir $files "$ost_list" \
11248 || { rc=$? ; break; }
11249 # former test_200g test_200h
11250 pool_lfs_df $POOL || { rc=$? ; break; }
11251 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11253 # former test_201a test_201b test_201c
11254 pool_remove_first_target $POOL || { rc=$? ; break; }
11256 local f=$test_path/$tfile
11257 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11258 pool_remove $POOL $f || { rc=$? ; break; }
11265 run_test 200 "OST pools"
11267 # usage: default_attr <count | size | offset>
11269 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11272 # usage: check_default_stripe_attr
11273 check_default_stripe_attr() {
11274 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11276 --stripe-count|--count)
11277 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11278 --stripe-size|--size)
11279 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11280 --stripe-index|--index)
11283 error "unknown getstripe attr '$1'"
11286 [ $ACTUAL != $EXPECTED ] &&
11287 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11291 test_mkdir -p $DIR/$tdir
11292 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11294 check_default_stripe_attr --stripe-count
11295 check_default_stripe_attr --stripe-size
11296 check_default_stripe_attr --stripe-index
11300 run_test 204a "Print default stripe attributes ================="
11303 test_mkdir -p $DIR/$tdir
11304 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11306 check_default_stripe_attr --stripe-size
11307 check_default_stripe_attr --stripe-index
11311 run_test 204b "Print default stripe size and offset ==========="
11314 test_mkdir -p $DIR/$tdir
11315 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11317 check_default_stripe_attr --stripe-count
11318 check_default_stripe_attr --stripe-index
11322 run_test 204c "Print default stripe count and offset ==========="
11325 test_mkdir -p $DIR/$tdir
11326 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11328 check_default_stripe_attr --stripe-count
11329 check_default_stripe_attr --stripe-size
11333 run_test 204d "Print default stripe count and size ============="
11336 test_mkdir -p $DIR/$tdir
11337 $SETSTRIPE -d $DIR/$tdir
11339 check_default_stripe_attr --stripe-count --raw
11340 check_default_stripe_attr --stripe-size --raw
11341 check_default_stripe_attr --stripe-index --raw
11345 run_test 204e "Print raw stripe attributes ================="
11348 test_mkdir -p $DIR/$tdir
11349 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11351 check_default_stripe_attr --stripe-size --raw
11352 check_default_stripe_attr --stripe-index --raw
11356 run_test 204f "Print raw stripe size and offset ==========="
11359 test_mkdir -p $DIR/$tdir
11360 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11362 check_default_stripe_attr --stripe-count --raw
11363 check_default_stripe_attr --stripe-index --raw
11367 run_test 204g "Print raw stripe count and offset ==========="
11370 test_mkdir -p $DIR/$tdir
11371 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11373 check_default_stripe_attr --stripe-count --raw
11374 check_default_stripe_attr --stripe-size --raw
11378 run_test 204h "Print raw stripe count and size ============="
11380 # Figure out which job scheduler is being used, if any,
11381 # or use a fake one
11382 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11383 JOBENV=SLURM_JOB_ID
11384 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11386 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11388 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11389 JOBENV=LOADL_STEP_ID
11390 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11396 verify_jobstats() {
11400 # clear old jobstats
11401 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11402 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11404 # use a new JobID for this test, or we might see an old one
11405 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11409 log "Using JobID environment variable $JOBENV=$JOBVAL"
11411 if [ $JOBENV = "FAKE_JOBID" ]; then
11412 FAKE_JOBID=$JOBVAL $cmd
11417 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11418 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11419 do_facet $FACET lctl get_param mdt.*.job_stats |
11420 grep $JOBVAL || error "No job stats found on MDT $FACET"
11422 if [ "$target" = "ost" -o "$target" = "both" ]; then
11424 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11425 grep $JOBVAL || error "No job stats found on OST $FACET"
11431 NEW_JOBENV=${1:-$OLD_JOBENV}
11432 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11433 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11436 test_205() { # Job stats
11437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11438 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11439 skip "Server doesn't support jobstats" && return 0
11440 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11443 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11444 if [ $OLD_JOBENV != $JOBENV ]; then
11445 jobstats_set $JOBENV
11446 trap jobstats_set EXIT
11450 cmd="mkdir $DIR/$tfile"
11451 verify_jobstats "$cmd" "mdt"
11453 cmd="rm -fr $DIR/$tfile"
11454 verify_jobstats "$cmd" "mdt"
11456 cmd="mknod $DIR/$tfile c 1 3"
11457 verify_jobstats "$cmd" "mdt"
11459 cmd="rm -f $DIR/$tfile"
11460 verify_jobstats "$cmd" "mdt"
11462 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11463 verify_jobstats "$cmd" "mdt"
11465 cmd="touch $DIR/$tfile"
11466 verify_jobstats "$cmd" "both"
11468 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11469 verify_jobstats "$cmd" "ost"
11471 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11472 verify_jobstats "$cmd" "ost"
11474 cmd="$TRUNCATE $DIR/$tfile 0"
11475 verify_jobstats "$cmd" "both"
11477 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11478 verify_jobstats "$cmd" "mdt"
11481 rm -f $DIR/jobstats_test_rename
11483 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11485 run_test 205 "Verify job stats"
11487 # LU-1480, LU-1773 and LU-1657
11489 mkdir -p $DIR/$tdir
11490 $SETSTRIPE -c -1 $DIR/$tdir
11491 #define OBD_FAIL_LOV_INIT 0x1403
11492 $LCTL set_param fail_loc=0xa0001403
11493 $LCTL set_param fail_val=1
11494 touch $DIR/$tdir/$tfile || true
11496 run_test 206 "fail lov_init_raid0() doesn't lbug"
11499 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11500 local fsz=`stat -c %s $DIR/$tfile`
11501 cancel_lru_locks mdc
11503 # do not return layout in getattr intent
11504 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11505 $LCTL set_param fail_loc=0x170
11506 local sz=`stat -c %s $DIR/$tfile`
11508 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11512 run_test 207a "can refresh layout at glimpse"
11515 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11516 local cksum=`md5sum $DIR/$tfile`
11517 local fsz=`stat -c %s $DIR/$tfile`
11518 cancel_lru_locks mdc
11519 cancel_lru_locks osc
11521 # do not return layout in getattr intent
11522 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11523 $LCTL set_param fail_loc=0x171
11525 # it will refresh layout after the file is opened but before read issues
11526 echo checksum is "$cksum"
11527 echo "$cksum" |md5sum -c --quiet || error "file differs"
11531 run_test 207b "can refresh layout at open"
11534 # FIXME: in this test suite, only RD lease is used. This is okay
11535 # for now as only exclusive open is supported. After generic lease
11536 # is done, this test suite should be revised. - Jinshan
11538 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11539 { skip "Need MDS version at least 2.4.52"; return 0; }
11541 echo "==== test 1: verify get lease work"
11542 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11544 echo "==== test 2: verify lease can be broken by upcoming open"
11545 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11549 $MULTIOP $DIR/$tfile oO_RDONLY:c
11550 kill -USR1 $PID && wait $PID || error "break lease error"
11552 echo "==== test 3: verify lease can't be granted if an open already exists"
11553 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11557 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11558 kill -USR1 $PID && wait $PID || error "open file error"
11560 echo "==== test 4: lease can sustain over recovery"
11561 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11567 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11569 echo "==== test 5: lease broken can't be regained by replay"
11570 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11574 # open file to break lease and then recovery
11575 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11578 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11582 run_test 208 "Exclusive open"
11585 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11586 skip_env "must have disp_stripe" && return
11589 sync; sleep 5; sync;
11591 echo 3 > /proc/sys/vm/drop_caches
11592 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11594 # open/close 500 times
11595 for i in $(seq 500); do
11599 echo 3 > /proc/sys/vm/drop_caches
11600 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11602 echo "before: $req_before, after: $req_after"
11603 [ $((req_after - req_before)) -ge 300 ] &&
11604 error "open/close requests are not freed"
11607 run_test 209 "read-only open/close requests should be freed promptly"
11611 size=$((size % 8192 + 1))
11612 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11613 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11614 rm -f $DIR/f212 $DIR/f212.xyz
11616 run_test 212 "Sendfile test ============================================"
11619 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11620 cancel_lru_locks osc
11621 lctl set_param fail_loc=0x8000040f
11622 # generate a read lock
11623 cat $DIR/$tfile > /dev/null
11624 # write to the file, it will try to cancel the above read lock.
11625 cat /etc/hosts >> $DIR/$tfile
11627 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11629 test_214() { # for bug 20133
11630 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11631 for (( i=0; i < 340; i++ )) ; do
11632 touch $DIR/$tdir/d214c/a$i
11635 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11636 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11637 ls $DIR/d214c || error "ls $DIR/d214c failed"
11638 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11639 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11641 run_test 214 "hash-indexed directory test - bug 20133"
11643 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11644 create_lnet_proc_files() {
11645 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11646 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11648 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11649 rm -f "$TMP/lnet_$1.sys_tmp"
11652 # counterpart of create_lnet_proc_files
11653 remove_lnet_proc_files() {
11654 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11657 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11658 # 3rd arg as regexp for body
11659 check_lnet_proc_stats() {
11660 local l=$(cat "$TMP/lnet_$1" |wc -l)
11661 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11663 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11666 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11667 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11668 # optional and can be regexp for 2nd line (lnet.routes case)
11669 check_lnet_proc_entry() {
11670 local blp=2 # blp stands for 'position of 1st line of body'
11671 [ -z "$5" ] || blp=3 # lnet.routes case
11673 local l=$(cat "$TMP/lnet_$1" |wc -l)
11674 # subtracting one from $blp because the body can be empty
11675 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11677 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11678 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11680 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11681 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11683 # bail out if any unexpected line happened
11684 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11685 [ "$?" != 0 ] || error "$2 misformatted"
11688 test_215() { # for bugs 18102, 21079, 21517
11689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11690 local N='(0|[1-9][0-9]*)' # non-negative numeric
11691 local P='[1-9][0-9]*' # positive numeric
11692 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11693 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11694 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11695 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11697 local L1 # regexp for 1st line
11698 local L2 # regexp for 2nd line (optional)
11699 local BR # regexp for the rest (body)
11701 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11702 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11703 create_lnet_proc_files "stats"
11704 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11705 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11706 remove_lnet_proc_files "stats"
11708 # /proc/sys/lnet/routes should look like this:
11709 # Routing disabled/enabled
11710 # net hops priority state router
11711 # where net is a string like tcp0, hops > 0, priority >= 0,
11712 # state is up/down,
11713 # router is a string like 192.168.1.1@tcp2
11714 L1="^Routing (disabled|enabled)$"
11715 L2="^net +hops +priority +state +router$"
11716 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11717 create_lnet_proc_files "routes"
11718 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11719 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11720 remove_lnet_proc_files "routes"
11722 # /proc/sys/lnet/routers should look like this:
11723 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11724 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11725 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11726 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11727 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11728 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11729 create_lnet_proc_files "routers"
11730 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11731 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11732 remove_lnet_proc_files "routers"
11734 # /proc/sys/lnet/peers should look like this:
11735 # nid refs state last max rtr min tx min queue
11736 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11737 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11738 # numeric (0 or >0 or <0), queue >= 0.
11739 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11740 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11741 create_lnet_proc_files "peers"
11742 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11743 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11744 remove_lnet_proc_files "peers"
11746 # /proc/sys/lnet/buffers should look like this:
11747 # pages count credits min
11748 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11749 L1="^pages +count +credits +min$"
11750 BR="^ +$N +$N +$I +$I$"
11751 create_lnet_proc_files "buffers"
11752 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11753 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11754 remove_lnet_proc_files "buffers"
11756 # /proc/sys/lnet/nis should look like this:
11757 # nid status alive refs peer rtr max tx min
11758 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11759 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11760 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11761 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11762 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11763 create_lnet_proc_files "nis"
11764 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11765 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11766 remove_lnet_proc_files "nis"
11768 # can we successfully write to /proc/sys/lnet/stats?
11769 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11770 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11772 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11774 test_216() { # bug 20317
11775 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11776 remote_ost_nodsh && skip "remote OST with nodsh" && return
11779 local facets=$(get_facets OST)
11780 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11782 save_lustre_params client "osc.*.contention_seconds" > $p
11783 save_lustre_params $facets \
11784 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11785 save_lustre_params $facets \
11786 "ldlm.namespaces.filter-*.contended_locks" >> $p
11787 save_lustre_params $facets \
11788 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11791 # agressive lockless i/o settings
11792 for node in $(osts_nodes); do
11793 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'
11795 lctl set_param -n osc.*.contention_seconds 60
11797 $DIRECTIO write $DIR/$tfile 0 10 4096
11798 $CHECKSTAT -s 40960 $DIR/$tfile
11800 # disable lockless i/o
11801 for node in $(osts_nodes); do
11802 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'
11804 lctl set_param -n osc.*.contention_seconds 0
11807 dd if=/dev/zero of=$DIR/$tfile count=0
11808 $CHECKSTAT -s 0 $DIR/$tfile
11810 restore_lustre_params <$p
11814 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11816 test_217() { # bug 22430
11817 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11821 for node in $(nodes_list); do
11822 nid=$(host_nids_address $node $NETTYPE)
11823 if [[ $nid = *-* ]] ; then
11824 echo "lctl ping $nid@$NETTYPE"
11825 lctl ping $nid@$NETTYPE
11827 echo "skipping $node (no hyphen detected)"
11831 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11834 # do directio so as not to populate the page cache
11835 log "creating a 10 Mb file"
11836 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11837 log "starting reads"
11838 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11839 log "truncating the file"
11840 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11842 kill %+ || true # reads might have finished
11843 echo "wait until dd is finished"
11845 log "removing the temporary file"
11846 rm -rf $DIR/$tfile || error "tmp file removal failed"
11848 run_test 218 "parallel read and truncate should not deadlock ======================="
11851 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11852 # write one partial page
11853 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11854 # set no grant so vvp_io_commit_write will do sync write
11855 $LCTL set_param fail_loc=0x411
11856 # write a full page at the end of file
11857 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11859 $LCTL set_param fail_loc=0
11860 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11861 $LCTL set_param fail_loc=0x411
11862 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11865 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11866 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11868 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11870 test_220() { #LU-325
11871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11872 remote_ost_nodsh && skip "remote OST with nodsh" && return
11875 test_mkdir -p $DIR/$tdir
11876 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11877 awk '{print $2}' | sed -e 's/_UUID$//')
11880 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11881 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11882 osc.$mdtosc_proc1.prealloc_last_id)
11883 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11884 osc.$mdtosc_proc1.prealloc_next_id)
11888 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11889 #define OBD_FAIL_OST_ENOINO 0x229
11890 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11891 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11892 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11894 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11896 MDSOBJS=$((last_id - next_id))
11897 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11899 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11900 echo "OST still has $count kbytes free"
11902 echo "create $MDSOBJS files @next_id..."
11903 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11905 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11906 osc.$mdtosc_proc1.prealloc_last_id)
11907 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11908 osc.$mdtosc_proc1.prealloc_next_id)
11910 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11915 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11916 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11918 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11919 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11920 echo "unlink $MDSOBJS files @$next_id..."
11921 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11923 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11927 dd if=`which date` of=$MOUNT/date oflag=sync
11928 chmod +x $MOUNT/date
11930 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11931 $LCTL set_param fail_loc=0x80001401
11933 $MOUNT/date > /dev/null
11936 run_test 221 "make sure fault and truncate race to not cause OOM"
11939 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11941 test_mkdir -p $DIR/$tdir
11942 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11943 createmany -o $DIR/$tdir/$tfile 10
11944 cancel_lru_locks mdc
11945 cancel_lru_locks osc
11946 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11947 $LCTL set_param fail_loc=0x31a
11948 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11949 $LCTL set_param fail_loc=0
11952 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11957 test_mkdir -p $DIR/$tdir
11958 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11959 createmany -o $DIR/$tdir/$tfile 10
11960 cancel_lru_locks mdc
11961 cancel_lru_locks osc
11962 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11963 $LCTL set_param fail_loc=0x31a
11964 rm -r $DIR/$tdir || "AGL for rmdir failed"
11965 $LCTL set_param fail_loc=0
11967 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11972 test_mkdir -p $DIR/$tdir
11973 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11974 createmany -o $DIR/$tdir/$tfile 10
11975 cancel_lru_locks mdc
11976 cancel_lru_locks osc
11977 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11978 $LCTL set_param fail_loc=0x31b
11979 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11980 $LCTL set_param fail_loc=0
11983 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11985 test_224a() { # LU-1039, MRP-303
11986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11987 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11988 $LCTL set_param fail_loc=0x508
11989 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11990 $LCTL set_param fail_loc=0
11993 run_test 224a "Don't panic on bulk IO failure"
11995 test_224b() { # LU-1039, MRP-303
11996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11997 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11998 cancel_lru_locks osc
11999 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12000 $LCTL set_param fail_loc=0x515
12001 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12002 $LCTL set_param fail_loc=0
12005 run_test 224b "Don't panic on bulk IO failure"
12007 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12010 if [ -z ${MDSSURVEY} ]; then
12011 skip_env "mds-survey not found" && return
12014 [ $MDSCOUNT -ge 2 ] &&
12015 skip "skipping now for more than one MDT" && return
12017 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12018 { skip "Need MDS version at least 2.2.51"; return; }
12020 local mds=$(facet_host $SINGLEMDS)
12021 local target=$(do_nodes $mds 'lctl dl' | \
12022 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12024 local cmd1="file_count=1000 thrhi=4"
12025 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12026 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12027 local cmd="$cmd1 $cmd2 $cmd3"
12029 rm -f ${TMP}/mds_survey*
12031 eval $cmd || error "mds-survey with zero-stripe failed"
12032 cat ${TMP}/mds_survey*
12033 rm -f ${TMP}/mds_survey*
12035 run_test 225a "Metadata survey sanity with zero-stripe"
12038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12040 if [ -z ${MDSSURVEY} ]; then
12041 skip_env "mds-survey not found" && return
12043 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12044 { skip "Need MDS version at least 2.2.51"; return; }
12046 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12047 skip_env "Need to mount OST to test" && return
12050 [ $MDSCOUNT -ge 2 ] &&
12051 skip "skipping now for more than one MDT" && return
12052 local mds=$(facet_host $SINGLEMDS)
12053 local target=$(do_nodes $mds 'lctl dl' | \
12054 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12056 local cmd1="file_count=1000 thrhi=4"
12057 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12058 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12059 local cmd="$cmd1 $cmd2 $cmd3"
12061 rm -f ${TMP}/mds_survey*
12063 eval $cmd || error "mds-survey with stripe_count failed"
12064 cat ${TMP}/mds_survey*
12065 rm -f ${TMP}/mds_survey*
12067 run_test 225b "Metadata survey sanity with stripe_count = 1"
12069 mcreate_path2fid () {
12075 local path=$DIR/$tdir/$name
12080 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12081 error "cannot create $desc"
12083 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12085 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12087 fid_path=$($LFS fid2path $MOUNT $fid)
12089 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12091 [ "$path" == "$fid_path" ] ||
12092 error "fid2path returned $fid_path, expected $path"
12094 echo "pass with $path and $fid"
12099 mkdir -p $DIR/$tdir
12101 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12102 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12103 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12104 mcreate_path2fid 0040666 0 0 dir "directory"
12105 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12106 mcreate_path2fid 0100666 0 0 file "regular file"
12107 mcreate_path2fid 0120666 0 0 link "symbolic link"
12108 mcreate_path2fid 0140666 0 0 sock "socket"
12110 run_test 226a "call path2fid and fid2path on files of all type"
12113 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12117 mkdir -p $DIR/$tdir
12118 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12119 error "create remote directory failed"
12120 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12121 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12122 "character special file (null)"
12123 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12124 "character special file (no device)"
12125 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12126 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12127 "block special file (loop)"
12128 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12129 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12130 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12132 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12134 # LU-1299 Executing or running ldd on a truncated executable does not
12135 # cause an out-of-memory condition.
12137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12138 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12139 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12140 chmod +x $MOUNT/date
12142 $MOUNT/date > /dev/null
12143 ldd $MOUNT/date > /dev/null
12146 run_test 227 "running truncated executable does not cause OOM"
12148 # LU-1512 try to reuse idle OI blocks
12150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12151 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12152 skip "non-ldiskfs backend" && return
12154 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12155 local myDIR=$DIR/$tdir
12158 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12159 $LCTL set_param fail_loc=0x80001002
12160 createmany -o $myDIR/t- 10000
12161 $LCTL set_param fail_loc=0
12162 # The guard is current the largest FID holder
12164 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12166 local IDX=$(($SEQ % 64))
12168 do_facet $SINGLEMDS sync
12169 # Make sure journal flushed.
12171 local blk1=$(do_facet $SINGLEMDS \
12172 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12173 grep Blockcount | awk '{print $4}')
12175 # Remove old files, some OI blocks will become idle.
12176 unlinkmany $myDIR/t- 10000
12177 # Create new files, idle OI blocks should be reused.
12178 createmany -o $myDIR/t- 2000
12179 do_facet $SINGLEMDS sync
12180 # Make sure journal flushed.
12182 local blk2=$(do_facet $SINGLEMDS \
12183 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12184 grep Blockcount | awk '{print $4}')
12186 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12188 run_test 228a "try to reuse idle OI blocks"
12191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12192 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12193 skip "non-ldiskfs backend" && return
12195 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12196 local myDIR=$DIR/$tdir
12199 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12200 $LCTL set_param fail_loc=0x80001002
12201 createmany -o $myDIR/t- 10000
12202 $LCTL set_param fail_loc=0
12203 # The guard is current the largest FID holder
12205 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12207 local IDX=$(($SEQ % 64))
12209 do_facet $SINGLEMDS sync
12210 # Make sure journal flushed.
12212 local blk1=$(do_facet $SINGLEMDS \
12213 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12214 grep Blockcount | awk '{print $4}')
12216 # Remove old files, some OI blocks will become idle.
12217 unlinkmany $myDIR/t- 10000
12220 stop $SINGLEMDS || error "Fail to stop MDT."
12222 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12224 df $MOUNT || error "Fail to df."
12225 # Create new files, idle OI blocks should be reused.
12226 createmany -o $myDIR/t- 2000
12227 do_facet $SINGLEMDS sync
12228 # Make sure journal flushed.
12230 local blk2=$(do_facet $SINGLEMDS \
12231 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12232 grep Blockcount | awk '{print $4}')
12234 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12236 run_test 228b "idle OI blocks can be reused after MDT restart"
12240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12241 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12242 skip "non-ldiskfs backend" && return
12244 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12245 local myDIR=$DIR/$tdir
12248 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12249 $LCTL set_param fail_loc=0x80001002
12250 # 20000 files can guarantee there are index nodes in the OI file
12251 createmany -o $myDIR/t- 20000
12252 $LCTL set_param fail_loc=0
12253 # The guard is current the largest FID holder
12255 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12257 local IDX=$(($SEQ % 64))
12259 do_facet $SINGLEMDS sync
12260 # Make sure journal flushed.
12262 local blk1=$(do_facet $SINGLEMDS \
12263 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12264 grep Blockcount | awk '{print $4}')
12266 # Remove old files, some OI blocks will become idle.
12267 unlinkmany $myDIR/t- 20000
12269 # The OI file should become empty now
12271 # Create new files, idle OI blocks should be reused.
12272 createmany -o $myDIR/t- 2000
12273 do_facet $SINGLEMDS sync
12274 # Make sure journal flushed.
12276 local blk2=$(do_facet $SINGLEMDS \
12277 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12278 grep Blockcount | awk '{print $4}')
12280 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12282 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12284 test_229() { # LU-2482, LU-3448
12285 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12286 skip "No HSM support on MDS of $(get_lustre_version)," \
12287 "need 2.4.53 at least" && return
12288 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12289 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12293 # Create a file with a released layout and stripe count 2.
12294 $MULTIOP $DIR/$tfile H2c ||
12295 error "failed to create file with released layout"
12297 $GETSTRIPE -v $DIR/$tfile
12299 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12300 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12302 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12303 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12304 stat $DIR/$tfile || error "failed to stat released file"
12306 chown $RUNAS_ID $DIR/$tfile ||
12307 error "chown $RUNAS_ID $DIR/$tfile failed"
12309 chgrp $RUNAS_ID $DIR/$tfile ||
12310 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12312 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12313 rm $DIR/$tfile || error "failed to remove released file"
12315 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12319 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12322 mkdir -p $DIR/$tdir/test_230_local
12323 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12324 [ $mdt_idx -ne 0 ] &&
12325 error "create local directory on wrong MDT $mdt_idx"
12327 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12328 error "create remote directory failed"
12329 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12330 [ $mdt_idx -ne $MDTIDX ] &&
12331 error "create remote directory on wrong MDT $mdt_idx"
12333 createmany -o $DIR/$tdir/test_230/t- 10 ||
12334 error "create files on remote directory failed"
12335 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12336 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12337 rm -r $DIR/$tdir || error "unlink remote directory failed"
12339 run_test 230a "Create remote directory and files under the remote directory"
12342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12343 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12350 local migrate_dir=$DIR/$tdir/migrate_dir
12351 local other_dir=$DIR/$tdir/other_dir
12353 mkdir -p $migrate_dir
12354 mkdir -p $other_dir
12355 for ((i=0; i<10; i++)); do
12356 mkdir -p $migrate_dir/dir_${i}
12357 createmany -o $migrate_dir/dir_${i}/f 10 ||
12358 error "create files under remote dir failed $i"
12361 cp /etc/passwd $migrate_dir/$tfile
12362 cp /etc/passwd $other_dir/$tfile
12363 chattr +SAD $migrate_dir
12364 chattr +SAD $migrate_dir/$tfile
12366 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12367 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12368 local old_dir_mode=$(stat -c%f $migrate_dir)
12369 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12371 mkdir -p $migrate_dir/dir_default_stripe2
12372 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12373 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12375 mkdir -p $other_dir
12376 ln $migrate_dir/$tfile $other_dir/luna
12377 ln $migrate_dir/$tfile $migrate_dir/sofia
12378 ln $other_dir/$tfile $migrate_dir/david
12379 ln -s $migrate_dir/$tfile $other_dir/zachary
12380 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12381 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12383 $LFS mv -v -M $MDTIDX $migrate_dir ||
12384 error "migrate remote dir error"
12386 echo "migratate to MDT1, then checking.."
12387 for ((i=0; i<10; i++)); do
12388 for file in $(find $migrate_dir/dir_${i}); do
12389 mdt_index=$($LFS getstripe -M $file)
12390 [ $mdt_index == $MDTIDX ] ||
12391 error "$file is not on MDT${MDTIDX}"
12395 # the multiple link file should still in MDT0
12396 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12397 [ $mdt_index == 0 ] ||
12398 error "$file is not on MDT${MDTIDX}"
12400 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12401 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12402 error " expect $old_dir_flag get $new_dir_flag"
12404 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12405 [ "$old_file_flag" = "$new_file_flag" ] ||
12406 error " expect $old_file_flag get $new_file_flag"
12408 local new_dir_mode=$(stat -c%f $migrate_dir)
12409 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12410 error "expect mode $old_dir_mode get $new_dir_mode"
12412 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12413 [ "$old_file_mode" = "$new_file_mode" ] ||
12414 error "expect mode $old_file_mode get $new_file_mode"
12416 diff /etc/passwd $migrate_dir/$tfile ||
12417 error "$tfile different after migration"
12419 diff /etc/passwd $other_dir/luna ||
12420 error "luna different after migration"
12422 diff /etc/passwd $migrate_dir/sofia ||
12423 error "sofia different after migration"
12425 diff /etc/passwd $migrate_dir/david ||
12426 error "david different after migration"
12428 diff /etc/passwd $other_dir/zachary ||
12429 error "zachary different after migration"
12431 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12432 error "${tfile}_ln different after migration"
12434 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12435 error "${tfile}_ln_other different after migration"
12437 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12438 [ $stripe_count = 2 ] ||
12439 error "dir strpe_count $d != 2 after migration."
12441 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12442 [ $stripe_count = 2 ] ||
12443 error "file strpe_count $d != 2 after migration."
12445 #migrate back to MDT0
12447 $LFS mv -v -M $MDTIDX $migrate_dir ||
12448 error "migrate remote dir error"
12450 echo "migrate back to MDT0, checking.."
12451 for file in $(find $migrate_dir); do
12452 mdt_index=$($LFS getstripe -M $file)
12453 [ $mdt_index == $MDTIDX ] ||
12454 error "$file is not on MDT${MDTIDX}"
12457 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12458 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12459 error " expect $old_dir_flag get $new_dir_flag"
12461 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12462 [ "$old_file_flag" = "$new_file_flag" ] ||
12463 error " expect $old_file_flag get $new_file_flag"
12465 local new_dir_mode=$(stat -c%f $migrate_dir)
12466 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12467 error "expect mode $old_dir_mode get $new_dir_mode"
12469 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12470 [ "$old_file_mode" = "$new_file_mode" ] ||
12471 error "expect mode $old_file_mode get $new_file_mode"
12473 diff /etc/passwd ${migrate_dir}/$tfile ||
12474 error "$tfile different after migration"
12476 diff /etc/passwd ${other_dir}/luna ||
12477 error "luna different after migration"
12479 diff /etc/passwd ${migrate_dir}/sofia ||
12480 error "sofia different after migration"
12482 diff /etc/passwd ${other_dir}/zachary ||
12483 error "zachary different after migration"
12485 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12486 error "${tfile}_ln different after migration"
12488 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12489 error "${tfile}_ln_other different after migration"
12491 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12492 [ $stripe_count = 2 ] ||
12493 error "dir strpe_count $d != 2 after migration."
12495 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12496 [ $stripe_count = 2 ] ||
12497 error "file strpe_count $d != 2 after migration."
12499 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12501 run_test 230b "migrate directory"
12504 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12505 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12510 #If migrating directory fails in the middle, all entries of
12511 #the directory is still accessiable.
12512 mkdir -p $DIR/$tdir
12514 createmany -o $DIR/$tdir/f 10 ||
12515 error "create files under ${tdir} failed"
12517 #failed after migrating 5 entries
12518 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12519 do_facet mds1 lctl set_param fail_loc=0x20001801
12520 do_facet mds1 lctl set_param fail_val=5
12521 local t=`ls $DIR/$tdir | wc -l`
12522 $LFS mv -M $MDTIDX $DIR/$tdir &&
12523 error "migrate should failed after 5 entries"
12524 local u=`ls $DIR/$tdir | wc -l`
12525 [ "$u" == "$t" ] || error "$u != $t during migration"
12527 for file in $(find $DIR/$tdir); do
12528 stat $file || error "stat $file failed"
12531 do_facet mds1 lctl set_param fail_loc=0
12532 do_facet mds1 lctl set_param fail_val=0
12534 $LFS mv -M $MDTIDX $DIR/$tdir ||
12535 error "migrate open files should failed with open files"
12537 echo "Finish migration, then checking.."
12538 for file in $(find $DIR/$tdir); do
12539 mdt_index=$($LFS getstripe -M $file)
12540 [ $mdt_index == $MDTIDX ] ||
12541 error "$file is not on MDT${MDTIDX}"
12544 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12546 run_test 230c "check directory accessiblity if migration is failed"
12549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12550 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12556 mkdir -p $DIR/$tdir
12558 for ((i=0; i<100; i++)); do
12559 mkdir -p $DIR/$tdir/dir_${i}
12560 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12561 error "create files under remote dir failed $i"
12564 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12566 echo "Finish migration, then checking.."
12567 for file in $(find $DIR/$tdir); do
12568 mdt_index=$($LFS getstripe -M $file)
12569 [ $mdt_index == $MDTIDX ] ||
12570 error "$file is not on MDT${MDTIDX}"
12573 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12575 run_test 230d "check migrate big directory"
12579 # For simplicity this test assumes that max_pages_per_rpc
12580 # is the same across all OSCs
12581 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12582 local bulk_size=$((max_pages * 4096))
12584 mkdir -p $DIR/$tdir
12586 # clear the OSC stats
12587 $LCTL set_param osc.*.stats=0 &>/dev/null
12589 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12590 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12591 oflag=direct &>/dev/null || error "dd failed"
12593 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12594 if [ x$nrpcs != "x1" ]; then
12595 error "found $nrpc ost_write RPCs, not 1 as expected"
12598 # Drop the OSC cache, otherwise we will read from it
12599 cancel_lru_locks osc
12601 # clear the OSC stats
12602 $LCTL set_param osc.*.stats=0 &>/dev/null
12604 # Client reads $bulk_size.
12605 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12606 iflag=direct &>/dev/null || error "dd failed"
12608 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12609 if [ x$nrpcs != "x1" ]; then
12610 error "found $nrpc ost_read RPCs, not 1 as expected"
12613 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12616 mkdir -p $DIR/$tdir
12618 for i in {0..1023}; do
12619 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12620 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12621 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12625 run_test 231b "must not assert on fully utilized OST request buffer"
12628 mkdir -p $DIR/$tdir
12629 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12630 $LCTL set_param fail_loc=0x31c
12632 # ignore dd failure
12633 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12635 $LCTL set_param fail_loc=0
12636 umount_client $MOUNT || error "umount failed"
12637 mount_client $MOUNT || error "mount failed"
12639 run_test 232 "failed lock should not block umount"
12642 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12643 { skip "Need MDS version at least 2.3.64"; return; }
12645 local fid=$($LFS path2fid $MOUNT)
12646 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12647 error "cannot access $MOUNT using its FID '$fid'"
12649 run_test 233a "checking that OBF of the FS root succeeds"
12652 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12653 { skip "Need MDS version at least 2.5.90"; return; }
12655 local fid=$($LFS path2fid $MOUNT/.lustre)
12656 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12657 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12659 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12660 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12661 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12663 run_test 233b "checking that OBF of the FS .lustre succeeds"
12666 local p="$TMP/sanityN-$TESTNAME.parameters"
12667 save_lustre_params client "llite.*.xattr_cache" > $p
12668 lctl set_param llite.*.xattr_cache 1 ||
12669 { skip "xattr cache is not supported"; return 0; }
12671 mkdir -p $DIR/$tdir || error "mkdir failed"
12672 touch $DIR/$tdir/$tfile || error "touch failed"
12673 # OBD_FAIL_LLITE_XATTR_ENOMEM
12674 $LCTL set_param fail_loc=0x1405
12675 if [ ! -f /etc/SuSE-release ]; then
12676 # attr pre-2.4.44-7 had a bug with rc
12677 # LU-3703 - SLES clients have older attr
12678 getfattr -n user.attr $DIR/$tdir/$tfile &&
12679 error "getfattr should have failed with ENOMEM"
12681 $LCTL set_param fail_loc=0x0
12684 restore_lustre_params < $p
12687 run_test 234 "xattr cache should not crash on ENOMEM"
12690 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12691 skip "Need MDS version at least 2.4.52" && return
12692 flock_deadlock $DIR/$tfile
12697 124) error "process hangs on a deadlock"
12699 *) error "error executing flock_deadlock $DIR/$tfile"
12703 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12707 check_swap_layouts_support && return 0
12708 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12710 local ref1=/etc/passwd
12711 local ref2=/etc/group
12712 local file1=$DIR/$tdir/f1
12713 local file2=$DIR/$tdir/f2
12715 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12716 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12717 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12718 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12719 local fd=$(free_fd)
12720 local cmd="exec $fd<>$file2"
12723 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12724 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12727 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12732 run_test 236 "Layout swap on open unlinked file"
12734 # test to verify file handle related system calls
12735 # (name_to_handle_at/open_by_handle_at)
12736 # The new system calls are supported in glibc >= 2.14.
12739 echo "Test file_handle syscalls" > $DIR/$tfile ||
12740 error "write failed"
12741 check_fhandle_syscalls $DIR/$tfile ||
12742 error "check_fhandle_syscalls failed"
12744 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12746 # LU-4659 linkea consistency
12748 local server_version=$(lustre_version_code $SINGLEMDS)
12750 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12751 [[ $server_version -gt $(version_code 2.5.1) &&
12752 $server_version -lt $(version_code 2.5.50) ]] ||
12753 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12756 ln $DIR/$tfile $DIR/$tfile.lnk
12757 touch $DIR/$tfile.new
12758 mv $DIR/$tfile.new $DIR/$tfile
12759 local fid1=$(lfs path2fid $DIR/$tfile)
12760 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12761 local path1=$(lfs fid2path $FSNAME $fid1)
12762 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12763 local path2=$(lfs fid2path $FSNAME $fid2)
12764 [ $tfile.lnk == $path2 ] ||
12765 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12768 run_test 238 "Verify linkea consistency"
12771 local list=$(comma_list $(mdts_nodes))
12773 mkdir -p $DIR/$tdir
12774 createmany -o $DIR/$tdir/f- 5000
12775 unlinkmany $DIR/$tdir/f- 5000
12776 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12777 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12778 osc.*MDT*.sync_in_flight" | calc_sum)
12779 [ "$changes" -eq 0 ] || error "$changes not synced"
12781 run_test 239 "osp_sync test"
12784 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12786 mkdir -p $DIR/$tdir
12788 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12789 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12790 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12791 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12793 umount_client $MOUNT || error "umount failed"
12794 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12795 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12796 mount_client $MOUNT || error "failed to mount client"
12798 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12799 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12801 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12803 cleanup_test_300() {
12807 test_striped_dir() {
12812 mkdir -p $DIR/$tdir
12814 SAVE_UMASK=$(umask)
12815 trap cleanup_test_300 RETURN EXIT
12817 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12818 $DIR/$tdir/striped_dir ||
12819 error "set striped dir error"
12821 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12822 [ "$mode" = "755" ] || error "expect 755 got $mode"
12824 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12825 if [ "$stripe_count" != "2" ]; then
12826 error "stripe_count is $stripe_count, expect 2"
12829 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12830 if [ "$stripe_index" != "$mdt_index" ]; then
12831 error "stripe_index is $stripe_index, expect $mdt_index"
12834 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12835 error "nlink error after create striped dir"
12837 mkdir $DIR/$tdir/striped_dir/a
12838 mkdir $DIR/$tdir/striped_dir/b
12840 stat $DIR/$tdir/striped_dir/a ||
12841 error "create dir under striped dir failed"
12842 stat $DIR/$tdir/striped_dir/b ||
12843 error "create dir under striped dir failed"
12845 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12846 error "nlink error after mkdir"
12848 rmdir $DIR/$tdir/striped_dir/a
12849 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12850 error "nlink error after rmdir"
12852 rmdir $DIR/$tdir/striped_dir/b
12853 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12854 error "nlink error after rmdir"
12856 rmdir $DIR/$tdir/striped_dir ||
12857 error "rmdir striped dir error"
12865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12868 test_striped_dir 0 || error "failed on striped dir on MDT0"
12869 test_striped_dir 1 || error "failed on striped dir on MDT0"
12871 run_test 300a "basic striped dir sanity test"
12874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12881 test_mkdir $DIR/$tdir || error "mkdir fail"
12882 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12883 error "set striped dir error"
12884 for ((i=0; i<10; i++)); do
12885 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12887 touch $DIR/$tdir/striped_dir/file_$i ||
12888 error "touch error $i"
12889 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12890 [ $mtime1 -eq $mtime2 ] &&
12891 error "mtime not change after create"
12893 rm -f $DIR/$tdir/striped_dir/file_$i ||
12894 error "unlink error $i"
12895 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12896 [ $mtime2 -eq $mtime3 ] &&
12897 error "mtime did not change after unlink"
12901 run_test 300b "check ctime/mtime for striped dir"
12904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12905 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12908 mkdir -p $DIR/$tdir
12909 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12910 error "set striped dir error"
12912 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12913 error "chown striped dir failed"
12915 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12916 error "create 5k files failed"
12918 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12920 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12924 run_test 300c "chown && check ls under striped directory"
12927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12932 mkdir -p $DIR/$tdir
12933 $SETSTRIPE -c 2 $DIR/$tdir
12935 #local striped directory
12936 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12937 error "set striped dir error"
12938 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12939 error "create 10 files failed"
12941 #remote striped directory
12942 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12943 error "set striped dir error"
12944 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12945 error "create 10 files failed"
12947 for file in $(find $DIR/$tdir); do
12948 stripe_count=$($GETSTRIPE -c $file)
12949 [ $stripe_count -eq 2 ] ||
12950 error "wrong stripe $stripe_count for $file"
12955 run_test 300d "check default stripe under striped directory"
12958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12959 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12963 mkdir -p $DIR/$tdir
12965 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12966 error "set striped dir error"
12968 touch $DIR/$tdir/striped_dir/a
12969 touch $DIR/$tdir/striped_dir/b
12970 touch $DIR/$tdir/striped_dir/c
12972 mkdir $DIR/$tdir/striped_dir/dir_a
12973 mkdir $DIR/$tdir/striped_dir/dir_b
12974 mkdir $DIR/$tdir/striped_dir/dir_c
12976 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12977 error "set striped dir under striped dir error"
12979 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12980 error "set striped dir under striped dir error"
12982 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12983 error "set striped dir under striped dir error"
12985 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12986 error "rename file under striped dir should fail"
12988 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12989 error "rename dir under striped dir should fail"
12991 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12992 error "rename dir under different stripes should fail"
12994 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12995 error "rename file under striped dir should succeed"
12997 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12998 error "rename dir under striped dir should succeed"
13002 run_test 300e "check rename under striped directory"
13005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13006 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13011 mkdir -p $DIR/$tdir
13013 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13014 error "set striped dir error"
13016 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13017 error "set striped dir error"
13019 touch $DIR/$tdir/striped_dir/a
13020 mkdir $DIR/$tdir/striped_dir/dir_a
13021 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13022 error "create striped dir under striped dir fails"
13024 touch $DIR/$tdir/striped_dir1/b
13025 mkdir $DIR/$tdir/striped_dir1/dir_b
13026 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13027 error "create striped dir under striped dir fails"
13029 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
13030 error "rename file under different striped dir should fail"
13032 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
13033 error "rename dir under different striped dir should fail"
13035 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
13036 error "rename striped dir under diff striped dir should fail"
13038 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13039 error "rename file under diff striped dirs fails"
13041 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
13042 error "rename dir under diff striped dirs fails"
13046 run_test 300f "check rename cross striped directory"
13049 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13054 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13055 $DIR/$tdir/striped_dir ||
13056 error "set striped dir error"
13058 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13059 error "set default stripe on striped dir error"
13061 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
13062 [ $stripe_count -eq $MDSCOUNT ] ||
13063 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
13065 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13067 for dir in $(find $DIR/$tdir/striped_dir/*); do
13068 stripe_count=$($LFS getdirstripe -c $dir)
13069 [ $stripe_count -eq $MDSCOUNT ] ||
13070 error "expect $MDSCOUNT get $stripe_count for $dir"
13073 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
13074 #change default stripe count to 2
13075 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
13076 error "set default stripe on striped dir error"
13078 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13080 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
13082 #change default stripe count to 1
13083 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
13084 error "set default stripe on striped dir error"
13086 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13087 for dir in $(find $DIR/$tdir/striped_dir/*); do
13088 stripe_count=$($LFS getdirstripe -c $dir)
13089 [ $stripe_count -eq 1 ] ||
13090 error "expect 1 get $stripe_count for $dir"
13092 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
13094 run_test 300g "check default striped directory for striped directory"
13097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13098 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13104 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13105 error "set striped dir error"
13107 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13108 error "create files under striped dir failed"
13110 # unfortunately, we need to umount to clear dir layout cache for now
13111 # once we fully implement dir layout, we can drop this
13112 umount_client $MOUNT || error "umount failed"
13113 mount_client $MOUNT || error "mount failed"
13115 #set the stripe to be unknown hash type
13116 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13117 $LCTL set_param fail_loc=0x1901
13118 for ((i = 0; i < 10; i++)); do
13119 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13120 error "stat f-$i failed"
13121 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13124 touch $DIR/$tdir/striped_dir/f0 &&
13125 error "create under striped dir with unknown hash should fail"
13127 $LCTL set_param fail_loc=0
13129 umount_client $MOUNT || error "umount failed"
13130 mount_client $MOUNT || error "mount failed"
13134 run_test 300h "client handle unknown hash type striped directory"
13136 test_400a() { # LU-1606, was conf-sanity test_74
13137 local extra_flags=''
13138 local out=$TMP/$tfile
13139 local prefix=/usr/include/lustre
13142 if ! which $CC > /dev/null 2>&1; then
13143 skip_env "$CC is not installed"
13147 if ! [[ -d $prefix ]]; then
13148 # Assume we're running in tree and fixup the include path.
13149 extra_flags+=" -I$LUSTRE/../libcfs/include"
13150 extra_flags+=" -I$LUSTRE/include"
13151 extra_flags+=" -L$LUSTRE/utils"
13154 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13155 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13156 error "client api broken"
13159 run_test 400a "Lustre client api program can compile and link"
13161 test_400b() { # LU-1606, LU-5011
13163 local out=$TMP/$tfile
13164 local prefix=/usr/include/lustre
13166 # We use a hard coded prefix so that this test will not fail
13167 # when run in tree. There are headers in lustre/include/lustre/
13168 # that are not packaged (like lustre_idl.h) and have more
13169 # complicated include dependencies (like config.h and lnet/types.h).
13170 # Since this test about correct packaging we just skip them when
13171 # they don't exist (see below) rather than try to fixup cppflags.
13173 if ! which $CC > /dev/null 2>&1; then
13174 skip_env "$CC is not installed"
13178 for header in $prefix/*.h; do
13179 if ! [[ -f "$header" ]]; then
13183 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13184 continue # liblustreapi.h is deprecated.
13187 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13188 error "cannot compile '$header'"
13191 run_test 400b "packaged headers can be compiled"
13194 # tests that do cleanup/setup should be run at the end
13198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13200 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13201 $LCTL set_param fail_loc=0x903
13202 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
13203 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
13206 FAIL_ON_ERROR=true cleanup
13207 FAIL_ON_ERROR=true setup
13209 run_test 900 "umount should not race with any mgc requeue thread"
13212 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13213 check_and_cleanup_lustre
13214 if [ "$I_MOUNTED" != "yes" ]; then
13215 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true