2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
110 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
200 test_mkdir $DIR/$tdir ||
201 error "Create remote directory failed"
203 touch $DIR/$tdir/$tfile ||
204 error "Create file under remote directory failed"
207 error "Expect error removing in-use dir $DIR/$tdir"
209 test -d $DIR/$tdir || error "Remote directory disappeared"
211 rm -rf $DIR/$tdir || error "remove remote dir error"
213 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
216 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
217 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
218 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
219 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
220 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
222 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
225 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
226 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile does not have perm 0666 or UID $UID"
229 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile should be 0666 and owned by UID $UID"
233 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
238 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
241 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
245 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
250 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by GID $UID"
253 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
257 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
260 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
261 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
262 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
263 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
264 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
265 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
266 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
267 error "$tdir/d/subdir should be GID $RUNAS_GID"
269 run_test 6g "Is new dir in sgid dir inheriting group?"
271 test_6h() { # bug 7331
272 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
273 touch $DIR/$tfile || error "touch failed"
274 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
275 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
276 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
277 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
278 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
280 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
283 test_mkdir $DIR/$tdir
284 $MCREATE $DIR/$tdir/$tfile
285 chmod 0666 $DIR/$tdir/$tfile
286 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
287 error "$tdir/$tfile should be mode 0666"
289 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
292 if [ ! -d $DIR/$tdir ]; then
295 $MCREATE $DIR/$tdir/$tfile
296 echo -n foo > $DIR/$tdir/$tfile
297 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
298 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
300 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
303 test_mkdir $DIR/$tdir
304 touch $DIR/$tdir/$tfile
305 chmod 0666 $DIR/$tdir/$tfile
306 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
307 error "$tfile mode not 0666"
309 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 test_mkdir $DIR/$tdir/d2/d3
315 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
317 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
320 test_mkdir $DIR/$tdir
321 test_mkdir $DIR/$tdir/d2
322 touch $DIR/$tdir/d2/$tfile
323 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
324 error "$tdir/d2/$tfile not a file"
326 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 chmod 0666 $DIR/$tdir/d2
332 chmod 0705 $DIR/$tdir/d2
333 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
334 error "$tdir/d2 mode not 0705"
336 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
341 chmod 0666 $DIR/$tdir/$tfile
342 chmod 0654 $DIR/$tdir/$tfile
343 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
344 error "$tdir/d2 mode not 0654"
346 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
349 test_mkdir $DIR/$tdir
350 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
352 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
353 error "$tdir/$tfile size not 0 after truncate"
355 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
361 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
363 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
366 test_mkdir $DIR/$tdir
367 touch $DIR/$tdir/$tfile
368 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
369 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
370 error "$tdir/${tfile_2} not a file after rename"
372 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
377 rm -rf $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
383 test_mkdir -p $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
387 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not a symlink"
389 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not referencing a file"
391 rm -f $DIR/$tdir/l-exist
392 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
394 run_test 17a "symlinks: create, remove (real) =================="
397 test_mkdir -p $DIR/$tdir
398 ln -s no-such-file $DIR/$tdir/l-dangle
400 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing no-such-file"
402 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing non-existent file"
404 rm -f $DIR/$tdir/l-dangle
405 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
407 run_test 17b "symlinks: create, remove (dangling) =============="
409 test_17c() { # bug 3440 - don't save failed open RPC for replay
410 test_mkdir -p $DIR/$tdir
411 ln -s foo $DIR/$tdir/$tfile
412 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
414 run_test 17c "symlinks: open dangling (should return error) ===="
417 test_mkdir -p $DIR/$tdir
418 ln -s foo $DIR/$tdir/$tfile
419 touch $DIR/$tdir/$tfile || error "creating to new symlink"
421 run_test 17d "symlinks: create dangling ========================"
424 test_mkdir -p $DIR/$tdir
425 local foo=$DIR/$tdir/$tfile
426 ln -s $foo $foo || error "create symlink failed"
427 ls -l $foo || error "ls -l failed"
428 ls $foo && error "ls not failed" || true
430 run_test 17e "symlinks: create recursive symlink (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
442 run_test 17f "symlinks: long and very long symlink name ========================"
444 # str_repeat(S, N) generate a string that is string S repeated N times
449 while [ $((n -= 1)) -ge 0 ]; do
455 # Long symlinks and LU-2241
457 test_mkdir -p $DIR/$tdir
458 local TESTS="59 60 61 4094 4095"
460 # Fix for inode size boundary in 2.1.4
461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
464 # Patch not applied to 2.2 or 2.3 branches
465 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
466 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
469 # skip long symlink name for rhel6.5.
470 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
471 grep -q '6.5' /etc/redhat-release &>/dev/null &&
472 TESTS="59 60 61 4062 4063"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
486 test_mkdir -p $DIR/$tdir
487 if [[ $MDSCOUNT -gt 1 ]]; then
488 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
492 $SETSTRIPE -c -1 $DIR/$tdir
493 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
494 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
495 touch $DIR/$tdir/$tfile || true
497 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
499 test_17i() { #bug 20018
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -c1 $DIR/$tdir
503 local foo=$DIR/$tdir/$tfile
505 if [[ $MDSCOUNT -gt 1 ]]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 ln -s $foo $foo || error "create symlink failed"
511 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
513 ls -l $foo && error "error not detected"
516 run_test 17i "don't panic on short symlink"
518 test_17k() { #bug 22301
519 [[ -z "$(which rsync 2>/dev/null)" ]] &&
520 skip "no rsync command" && return 0
521 rsync --help | grep -q xattr ||
522 skip_env "$(rsync --version | head -n1) does not support xattrs"
523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
524 test_mkdir -p $DIR/$tdir
525 test_mkdir -p $DIR/$tdir.new
526 touch $DIR/$tdir/$tfile
527 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
528 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
529 error "rsync failed with xattrs enabled"
531 run_test 17k "symlinks: rsync with xattrs enabled ========================="
533 test_17l() { # LU-279
534 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
535 skip "no getfattr command" && return 0
537 touch $DIR/$tdir/$tfile
538 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
539 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
540 # -h to not follow symlinks. -m '' to list all the xattrs.
541 # grep to remove first line: '# file: $path'.
542 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
544 lgetxattr_size_check $path $xattr ||
545 error "lgetxattr_size_check $path $xattr failed"
549 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
553 local short_sym="0123456789"
554 local WDIR=$DIR/${tdir}m
561 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
562 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
563 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
565 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
566 skip "only for ldiskfs MDT" && return 0
568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
572 # create a long symlink file
573 for ((i = 0; i < 4; ++i)); do
574 long_sym=${long_sym}${long_sym}
577 echo "create 512 short and long symlink files under $WDIR"
578 for ((i = 0; i < 256; ++i)); do
579 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
580 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
586 wait_delete_completed
588 echo "recreate the 512 symlink files with a shorter string"
589 for ((i = 0; i < 512; ++i)); do
590 # rewrite the symlink file with a shorter string
591 ln -sf ${long_sym} $WDIR/long-$i
592 ln -sf ${short_sym} $WDIR/short-$i
595 mds_index=$($LFS getstripe -M $WDIR)
596 mds_index=$((mds_index+1))
597 devname=$(mdsdevname $mds_index)
598 cmd="$E2FSCK -fnvd $devname"
600 echo "stop and checking mds${mds_index}: $cmd"
601 # e2fsck should not return error
603 do_facet mds${mds_index} $cmd || rc=$?
605 start mds${mds_index} $devname $MDS_MOUNT_OPTS
606 df $MOUNT > /dev/null 2>&1
607 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
608 "short/long symlink MDT: rc=$rc"
611 run_test 17m "run e2fsck against MDT which contains short/long symlink"
613 check_fs_consistency_17n() {
619 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
620 # so it only check MDT1/MDT2 instead of all of MDTs.
621 for mdt_index in $(seq 1 2); do
622 devname=$(mdsdevname $mdt_index)
623 cmd="$E2FSCK -fnvd $devname"
625 echo "stop and checking mds${mdt_index}: $cmd"
626 # e2fsck should not return error
628 do_facet mds${mdt_index} $cmd || rc=$?
630 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
631 df $MOUNT > /dev/null 2>&1
632 [ $rc -ne 0 ] && break
640 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
641 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
642 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
644 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
645 skip "only for ldiskfs MDT" && return 0
647 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
649 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
652 for ((i=0; i<10; i++)); do
653 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
654 error "create remote dir error $i"
655 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
656 error "create files under remote dir failed $i"
659 check_fs_consistency_17n ||
660 error "e2fsck report error after create files under remote dir"
662 for ((i=0;i<10;i++)); do
663 rm -rf $DIR/$tdir/remote_dir_${i} ||
664 error "destroy remote dir error $i"
667 check_fs_consistency_17n ||
668 error "e2fsck report error after unlink files under remote dir"
670 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
671 skip "lustre < 2.4.50 does not support migrate mv " && return
673 for ((i=0; i<10; i++)); do
674 mkdir -p $DIR/$tdir/remote_dir_${i}
675 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
676 error "create files under remote dir failed $i"
677 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
678 error "migrate remote dir error $i"
680 check_fs_consistency_17n || error "e2fsck report error after migration"
682 for ((i=0;i<10;i++)); do
683 rm -rf $DIR/$tdir/remote_dir_${i} ||
684 error "destroy remote dir error $i"
687 check_fs_consistency_17n || error "e2fsck report error after unlink"
689 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
692 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
693 skip "Need MDS version at least 2.3.64" && return
695 local WDIR=$DIR/${tdir}o
701 mdt_index=$($LFS getstripe -M $WDIR)
702 mdt_index=$((mdt_index+1))
703 mdtdevname=$(mdsdevname $mdt_index)
707 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
709 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
710 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
711 ls -l $WDIR/$tfile && rc=1
712 do_facet mds${mdt_index} lctl set_param fail_loc=0
713 [[ $rc -ne 0 ]] && error "stat file should fail"
716 run_test 17o "stat file with incompat LMA feature"
719 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
720 ls $DIR || error "Failed to ls $DIR: $?"
722 run_test 18 "touch .../f ; ls ... =============================="
728 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
730 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
733 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
735 run_test 19b "ls -l .../f19 (should return error) =============="
738 [ $RUNAS_ID -eq $UID ] &&
739 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
740 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
742 run_test 19c "$RUNAS touch .../f19 (should return error) =="
745 cat $DIR/f19 && error || true
747 run_test 19d "cat .../f19 (should return error) =============="
759 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
761 run_test 20 "touch .../f ; ls -l ... ==========================="
764 test_mkdir -p $DIR/$tdir
765 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
766 ln -s dangle $DIR/$tdir/link
767 echo foo >> $DIR/$tdir/link
768 cat $DIR/$tdir/dangle
769 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
770 $CHECKSTAT -f -t file $DIR/$tdir/link ||
771 error "$tdir/link not linked to a file"
773 run_test 21 "write to dangling link ============================"
777 test_mkdir -p $DIR/$tdir
778 chown $RUNAS_ID:$RUNAS_GID $WDIR
779 (cd $WDIR || error "cd $WDIR failed";
780 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
782 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
783 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
784 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
786 run_test 22 "unpack tar archive as non-root user ==============="
790 test_mkdir -p $DIR/$tdir
791 local file=$DIR/$tdir/$tfile
793 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
794 openfile -f O_CREAT:O_EXCL $file &&
795 error "$file recreate succeeded" || true
797 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
799 test_23b() { # bug 18988
800 test_mkdir -p $DIR/$tdir
801 local file=$DIR/$tdir/$tfile
804 echo foo > $file || error "write filed"
805 echo bar >> $file || error "append filed"
806 $CHECKSTAT -s 8 $file || error "wrong size"
809 run_test 23b "O_APPEND check =========================="
813 echo '-- same directory rename'
814 test_mkdir $DIR/$tdir
815 touch $DIR/$tdir/$tfile.1
816 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
817 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
819 run_test 24a "rename file to non-existent target"
822 test_mkdir $DIR/$tdir
823 touch $DIR/$tdir/$tfile.{1,2}
824 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
825 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
826 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
828 run_test 24b "rename file to existing target"
831 test_mkdir $DIR/$tdir
832 test_mkdir $DIR/$tdir/d$testnum.1
833 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
834 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
835 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
837 run_test 24c "rename directory to non-existent target"
840 test_mkdir -c1 $DIR/$tdir
841 test_mkdir -c1 $DIR/$tdir/d$testnum.1
842 test_mkdir -c1 $DIR/$tdir/d$testnum.2
843 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
844 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
845 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
847 run_test 24d "rename directory to existing target"
850 echo '-- cross directory renames --'
854 mv $DIR/R5a/f $DIR/R5b/g
855 $CHECKSTAT -a $DIR/R5a/f || error
856 $CHECKSTAT -t file $DIR/R5b/g || error
858 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
863 touch $DIR/R6a/f $DIR/R6b/g
864 mv $DIR/R6a/f $DIR/R6b/g
865 $CHECKSTAT -a $DIR/R6a/f || error
866 $CHECKSTAT -t file $DIR/R6b/g || error
868 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
873 test_mkdir $DIR/R7a/d
874 mv $DIR/R7a/d $DIR/R7b/e
875 $CHECKSTAT -a $DIR/R7a/d || error
876 $CHECKSTAT -t dir $DIR/R7b/e || error
878 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
881 test_mkdir -c1 $DIR/R8a
882 test_mkdir -c1 $DIR/R8b
883 test_mkdir -c1 $DIR/R8a/d
884 test_mkdir -c1 $DIR/R8b/e
885 mrename $DIR/R8a/d $DIR/R8b/e
886 $CHECKSTAT -a $DIR/R8a/d || error
887 $CHECKSTAT -t dir $DIR/R8b/e || error
889 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
892 echo "-- rename error cases"
896 mrename $DIR/R9/f $DIR/R9/a
897 $CHECKSTAT -t file $DIR/R9/f || error
898 $CHECKSTAT -t dir $DIR/R9/a || error
899 $CHECKSTAT -a $DIR/R9/a/f || error
901 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
905 mrename $DIR/R10/f $DIR/R10/g
906 $CHECKSTAT -t dir $DIR/R10 || error
907 $CHECKSTAT -a $DIR/R10/f || error
908 $CHECKSTAT -a $DIR/R10/g || error
910 run_test 24j "source does not exist ============================"
914 test_mkdir $DIR/R11a/d
916 mv $DIR/R11a/f $DIR/R11a/d
917 $CHECKSTAT -a $DIR/R11a/f || error
918 $CHECKSTAT -t file $DIR/R11a/d/f || error
920 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
922 # bug 2429 - rename foo foo foo creates invalid file
925 $MULTIOP $f OcNs || error
927 run_test 24l "Renaming a file to itself ========================"
931 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
932 # on ext3 this does not remove either the source or target files
933 # though the "expected" operation would be to remove the source
934 $CHECKSTAT -t file ${f} || error "${f} missing"
935 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
937 run_test 24m "Renaming a file to a hard link to itself ========="
941 # this stats the old file after it was renamed, so it should fail
945 $CHECKSTAT ${f}.rename
948 run_test 24n "Statting the old file after renaming (Posix rename 2)"
951 check_kernel_version 37 || return 0
952 test_mkdir -p $DIR/d24o
953 rename_many -s random -v -n 10 $DIR/d24o
955 run_test 24o "rename of files during htree split ==============="
960 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
961 mrename $DIR/R12a $DIR/R12b
962 $CHECKSTAT -a $DIR/R12a || error
963 $CHECKSTAT -t dir $DIR/R12b || error
964 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
965 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
967 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
969 cleanup_multiop_pause() {
975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
978 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
979 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
982 trap cleanup_multiop_pause EXIT
983 mrename $DIR/R13a $DIR/R13b
984 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
985 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
986 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
987 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
988 cleanup_multiop_pause
989 wait $MULTIPID || error "multiop close failed"
991 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
993 test_24r() { #bug 3789
995 test_mkdir $DIR/R14a/b
996 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
997 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
998 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1000 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1003 test_mkdir $DIR/R15a
1004 test_mkdir $DIR/R15a/b
1005 test_mkdir $DIR/R15a/b/c
1006 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1007 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1008 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1010 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1012 test_mkdir $DIR/R16a
1013 test_mkdir $DIR/R16a/b
1014 test_mkdir $DIR/R16a/b/c
1015 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1016 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1017 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1019 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1021 test_24u() { # bug12192
1022 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1023 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1025 run_test 24u "create stripe file"
1031 simple_cleanup_common() {
1034 wait_delete_completed
1037 max_pages_per_rpc() {
1038 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1042 local NRFILES=100000
1043 local FREE_INODES=$(mdt_free_inodes 0)
1044 [[ $FREE_INODES -lt $NRFILES ]] &&
1045 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1048 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1049 trap simple_cleanup_common EXIT
1051 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1052 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1055 createmany -m $DIR/$tdir/$tfile $NRFILES
1057 cancel_lru_locks mdc
1058 lctl set_param mdc.*.stats clear
1060 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1062 # LU-5 large readdir
1063 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1064 # 8 bytes for name(filename is mostly 5 in this test) +
1065 # 8 bytes for luda_type
1066 # take into account of overhead in lu_dirpage header and end mark in
1067 # each page, plus one in RPC_NUM calculation.
1069 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1070 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1071 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1072 awk '/^mds_readpage/ {print $2}')
1073 [[ $mds_readpage -gt $RPC_NUM ]] &&
1074 error "large readdir doesn't take effect"
1076 simple_cleanup_common
1078 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1080 test_24w() { # bug21506
1082 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1083 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1084 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1085 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1086 [[ "$SZ1" -eq "$SZ2" ]] ||
1087 error "Error reading at the end of the file $tfile"
1089 run_test 24w "Reading a file larger than 4Gb"
1092 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1095 local remote_dir=$DIR/$tdir/remote_dir
1098 $LFS mkdir -i $MDTIDX $remote_dir ||
1099 error "create remote directory failed"
1101 mkdir -p $DIR/$tdir/src_dir
1102 touch $DIR/$tdir/src_file
1103 mkdir -p $remote_dir/tgt_dir
1104 touch $remote_dir/tgt_file
1106 mrename $remote_dir $DIR/ &&
1107 error "rename dir cross MDT works!"
1109 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1110 error "rename dir cross MDT works!"
1112 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1113 error "rename file cross MDT works!"
1115 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1116 error "ln file cross MDT should not work!"
1118 rm -rf $DIR/$tdir || error "Can not delete directories"
1120 run_test 24x "cross rename/link should be failed"
1123 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1124 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1126 local remote_dir=$DIR/$tdir/remote_dir
1129 $LFS mkdir -i $MDTIDX $remote_dir ||
1130 error "create remote directory failed"
1132 mkdir -p $remote_dir/src_dir
1133 touch $remote_dir/src_file
1134 mkdir -p $remote_dir/tgt_dir
1135 touch $remote_dir/tgt_file
1137 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1138 error "rename subdir in the same remote dir failed!"
1140 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1141 error "rename files in the same remote dir failed!"
1143 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1144 error "link files in the same remote dir failed!"
1146 rm -rf $DIR/$tdir || error "Can not delete directories"
1148 run_test 24y "rename/link on the same dir should succeed"
1151 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1154 local remote_src=$DIR/$tdir/remote_dir
1155 local remote_tgt=$DIR/$tdir/remote_tgt
1158 $LFS mkdir -i $MDTIDX $remote_src ||
1159 error "create remote directory failed"
1161 $LFS mkdir -i $MDTIDX $remote_tgt ||
1162 error "create remote directory failed"
1164 mrename $remote_src $remote_tgt &&
1165 error "rename remote dirs should not work!"
1167 # If target dir does not exists, it should succeed
1169 mrename $remote_src $remote_tgt ||
1170 error "rename remote dirs(tgt dir does not exists) failed!"
1172 rm -rf $DIR/$tdir || error "Can not delete directories"
1174 run_test 24z "rename one remote dir to another remote dir should fail"
1176 test_24A() { # LU-3182
1181 createmany -m $DIR/$tdir/$tfile $NFILES
1182 local t=$(ls $DIR/$tdir | wc -l)
1183 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1184 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1185 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1186 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1189 rm -rf $DIR/$tdir || error "Can not delete directories"
1191 run_test 24A "readdir() returns correct number of entries."
1193 test_24B() { # LU-4805
1194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1198 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1199 error "create striped dir failed"
1201 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1202 [ $count -eq 2 ] || error "Expected 2, got $count"
1204 touch $DIR/$tdir/striped_dir/a
1206 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1207 [ $count -eq 3 ] || error "Expected 3, got $count"
1209 touch $DIR/$tdir/striped_dir/.f
1211 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1212 [ $count -eq 4 ] || error "Expected 4, got $count"
1214 rm -rf $DIR/$tdir || error "Can not delete directories"
1216 run_test 24B "readdir for striped dir return correct number of entries"
1219 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1225 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1226 error "create striped dir failed"
1228 cd $DIR/$tdir/d0/striped_dir
1230 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1231 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1232 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1234 [ "$d0_ino" = "$parent_ino" ] ||
1235 error ".. wrong, expect $d0_ino, get $parent_ino"
1237 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1238 error "mv striped dir failed"
1240 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1242 [ "$d1_ino" = "$parent_ino" ] ||
1243 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1245 run_test 24C "check .. in striped dir"
1248 echo '== symlink sanity ============================================='
1252 touch $DIR/s25/foo || error
1254 run_test 25a "create file in symlinked directory ==============="
1257 [ ! -d $DIR/d25 ] && test_25a
1258 $CHECKSTAT -t file $DIR/s25/foo || error
1260 run_test 25b "lookup file in symlinked directory ==============="
1264 test_mkdir $DIR/d26/d26-2
1265 ln -s d26/d26-2 $DIR/s26
1266 touch $DIR/s26/foo || error
1268 run_test 26a "multiple component symlink ======================="
1271 test_mkdir -p $DIR/d26b/d26-2
1272 ln -s d26b/d26-2/foo $DIR/s26-2
1273 touch $DIR/s26-2 || error
1275 run_test 26b "multiple component symlink at end of lookup ======"
1278 test_mkdir $DIR/d26.2
1279 touch $DIR/d26.2/foo
1280 ln -s d26.2 $DIR/s26.2-1
1281 ln -s s26.2-1 $DIR/s26.2-2
1282 ln -s s26.2-2 $DIR/s26.2-3
1283 chmod 0666 $DIR/s26.2-3/foo
1285 run_test 26c "chain of symlinks ================================"
1287 # recursive symlinks (bug 439)
1289 ln -s d26-3/foo $DIR/d26-3
1291 run_test 26d "create multiple component recursive symlink ======"
1294 [ ! -h $DIR/d26-3 ] && test_26d
1297 run_test 26e "unlink multiple component recursive symlink ======"
1299 # recursive symlinks (bug 7022)
1301 test_mkdir -p $DIR/$tdir
1302 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1303 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1304 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1305 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1306 cd $tfile || error "cd $tfile failed"
1307 ln -s .. dotdot || error "ln dotdot failed"
1308 ln -s dotdot/lndir lndir || error "ln lndir failed"
1309 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1310 output=`ls $tfile/$tfile/lndir/bar1`
1311 [ "$output" = bar1 ] && error "unexpected output"
1312 rm -r $tfile || error "rm $tfile failed"
1313 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1315 run_test 26f "rm -r of a directory which has recursive symlink ="
1318 echo '== stripe sanity =============================================='
1319 test_mkdir -p $DIR/d27 || error "mkdir failed"
1321 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1322 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1323 log "== test_27a: write to one stripe file ========================="
1324 cp /etc/hosts $DIR/d27/f0 || error
1326 run_test 27a "one stripe file =================================="
1329 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1330 test_mkdir -p $DIR/d27
1331 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1332 $GETSTRIPE -c $DIR/d27/f01
1333 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1334 error "two-stripe file doesn't have two stripes"
1336 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1338 run_test 27b "create and write to two stripe file"
1341 test_mkdir -p $DIR/d27
1342 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1343 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1344 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1346 run_test 27d "create file with default settings ================"
1349 test_mkdir -p $DIR/d27
1350 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1351 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1352 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1354 run_test 27e "setstripe existing file (should return error) ======"
1357 test_mkdir -p $DIR/d27
1358 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1359 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1360 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1362 run_test 27f "setstripe with bad stripe size (should return error)"
1365 test_mkdir -p $DIR/d27
1366 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1367 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1368 error "$DIR/d27/fnone has object"
1370 run_test 27g "$GETSTRIPE with no objects"
1373 touch $DIR/d27/fsome || error "touch failed"
1374 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1376 run_test 27i "$GETSTRIPE with some objects"
1379 test_mkdir -p $DIR/d27
1380 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1382 run_test 27j "setstripe with bad stripe offset (should return error)"
1384 test_27k() { # bug 2844
1385 test_mkdir -p $DIR/d27
1387 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1388 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1389 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1390 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1391 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1392 dd if=/dev/zero of=$FILE bs=4k count=1
1393 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1394 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1396 run_test 27k "limit i_blksize for broken user apps ============="
1399 test_mkdir -p $DIR/d27
1400 mcreate $DIR/f27l || error "creating file"
1401 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1402 error "setstripe should have failed" || true
1404 run_test 27l "check setstripe permissions (should return error)"
1407 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1409 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1410 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1413 trap simple_cleanup_common EXIT
1414 test_mkdir -p $DIR/$tdir
1415 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1416 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1417 error "dd should fill OST0"
1419 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1421 [ $i -gt 256 ] && break
1424 touch $DIR/$tdir/f27m_$i
1425 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1426 error "OST0 was full but new created file still use it"
1428 touch $DIR/$tdir/f27m_$i
1429 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1430 error "OST0 was full but new created file still use it"
1431 simple_cleanup_common
1433 run_test 27m "create file while OST0 was full =================="
1436 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1440 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1441 # if the OST isn't full anymore.
1443 local OSTIDX=${1:-""}
1445 local list=$(comma_list $(osts_nodes))
1446 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1448 do_nodes $list lctl set_param fail_loc=0
1449 sync # initiate all OST_DESTROYs from MDS to OST
1453 exhaust_precreations() {
1456 local FAILIDX=${3:-$OSTIDX}
1458 test_mkdir -p $DIR/$tdir
1459 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1460 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1462 local OST=$(ostname_from_index $OSTIDX)
1463 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1464 sed -e 's/_UUID$//;s/^.*-//')
1467 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1468 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1469 osc.$mdtosc_proc1.prealloc_last_id)
1470 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1471 osc.$mdtosc_proc1.prealloc_next_id)
1473 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1474 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1476 test_mkdir -p $DIR/$tdir/${OST}
1477 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1478 #define OBD_FAIL_OST_ENOSPC 0x215
1479 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1480 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1481 echo "Creating to objid $last_id on ost $OST..."
1482 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1483 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1484 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1488 exhaust_all_precreations() {
1490 for (( i=0; i < OSTCOUNT; i++ )) ; do
1491 exhaust_precreations $i $1 -1
1496 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1498 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1499 remote_ost_nodsh && skip "remote OST with nodsh" && return
1502 rm -f $DIR/$tdir/$tfile
1503 exhaust_precreations 0 0x80000215
1504 $SETSTRIPE -c -1 $DIR/$tdir
1505 touch $DIR/$tdir/$tfile || error
1506 $GETSTRIPE $DIR/$tdir/$tfile
1509 run_test 27n "create file with some full OSTs =================="
1512 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1514 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1515 remote_ost_nodsh && skip "remote OST with nodsh" && return
1518 rm -f $DIR/$tdir/$tfile
1519 exhaust_all_precreations 0x215
1521 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1526 run_test 27o "create file with all full OSTs (should error) ===="
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 test_mkdir -p $DIR/$tdir
1538 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1539 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1540 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1542 exhaust_precreations 0 0x80000215
1543 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1544 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1545 $GETSTRIPE $DIR/$tdir/$tfile
1549 run_test 27p "append to a truncated file with some full OSTs ==="
1552 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1553 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1554 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1555 remote_ost_nodsh && skip "remote OST with nodsh" && return
1558 rm -f $DIR/$tdir/$tfile
1560 test_mkdir -p $DIR/$tdir
1561 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1562 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1563 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1565 exhaust_all_precreations 0x215
1567 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1568 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1572 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1575 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1577 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1578 remote_ost_nodsh && skip "remote OST with nodsh" && return
1581 rm -f $DIR/$tdir/$tfile
1582 exhaust_precreations 0 0x80000215
1584 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1588 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1590 test_27s() { # bug 10725
1591 test_mkdir -p $DIR/$tdir
1592 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1593 local stripe_count=0
1594 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1595 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1596 error "stripe width >= 2^32 succeeded" || true
1599 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1601 test_27t() { # bug 10864
1606 $WLFS getstripe $tfile
1609 run_test 27t "check that utils parse path correctly"
1611 test_27u() { # bug 4900
1612 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1613 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1615 local list=$(comma_list $(mdts_nodes))
1617 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1618 do_nodes $list $LCTL set_param fail_loc=0x139
1619 test_mkdir -p $DIR/$tdir
1621 createmany -o $DIR/$tdir/t- 1000
1622 do_nodes $list $LCTL set_param fail_loc=0
1624 TLOG=$DIR/$tfile.getstripe
1625 $GETSTRIPE $DIR/$tdir > $TLOG
1626 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1627 unlinkmany $DIR/$tdir/t- 1000
1628 [[ $OBJS -gt 0 ]] &&
1629 error "$OBJS objects created on OST-0. See $TLOG" || pass
1631 run_test 27u "skip object creation on OSC w/o objects =========="
1633 test_27v() { # bug 4900
1634 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1635 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1636 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1637 remote_ost_nodsh && skip "remote OST with nodsh" && return
1639 exhaust_all_precreations 0x215
1642 test_mkdir -p $DIR/$tdir
1643 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1645 touch $DIR/$tdir/$tfile
1646 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1648 for (( i=1; i < OSTCOUNT; i++ )); do
1649 do_facet ost$i lctl set_param fail_loc=0x705
1651 local START=`date +%s`
1652 createmany -o $DIR/$tdir/$tfile 32
1654 local FINISH=`date +%s`
1655 local TIMEOUT=`lctl get_param -n timeout`
1656 local PROCESS=$((FINISH - START))
1657 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1658 error "$FINISH - $START >= $TIMEOUT / 2"
1659 sleep $((TIMEOUT / 2 - PROCESS))
1662 run_test 27v "skip object creation on slow OST ================="
1664 test_27w() { # bug 10997
1665 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1666 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1667 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1668 error "stripe size $size != 65536" || true
1669 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1670 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1672 run_test 27w "check $SETSTRIPE -S option"
1675 [[ $OSTCOUNT -lt 2 ]] &&
1676 skip_env "skipping multiple stripe count/offset test" && return
1678 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1679 for i in $(seq 1 $OSTCOUNT); do
1681 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1682 error "setstripe -c $i -i $offset failed"
1683 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1684 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1685 [ $count -ne $i ] && error "stripe count $count != $i" || true
1686 [ $index -ne $offset ] &&
1687 error "stripe offset $index != $offset" || true
1690 run_test 27wa "check $SETSTRIPE -c -i options"
1693 remote_ost_nodsh && skip "remote OST with nodsh" && return
1694 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1695 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1696 OFFSET=$(($OSTCOUNT - 1))
1698 local OST=$(ostname_from_index $OSTIDX)
1700 test_mkdir -p $DIR/$tdir
1701 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1702 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1704 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1705 for i in `seq 0 $OFFSET`; do
1706 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1707 error "OST0 was degraded but new created file still use it"
1709 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1711 run_test 27x "create files while OST0 is degraded"
1714 [[ $OSTCOUNT -lt 2 ]] &&
1715 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1716 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1717 remote_ost_nodsh && skip "remote OST with nodsh" && return
1718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1720 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1721 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1722 osc.$mdtosc.prealloc_last_id)
1723 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1724 osc.$mdtosc.prealloc_next_id)
1725 local fcount=$((last_id - next_id))
1726 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1727 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1729 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1730 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1731 local OST_DEACTIVE_IDX=-1
1736 for OSC in $MDS_OSCS; do
1737 OST=$(osc_to_ost $OSC)
1738 OSTIDX=$(index_from_ostuuid $OST)
1739 if [ $OST_DEACTIVE_IDX == -1 ]; then
1740 OST_DEACTIVE_IDX=$OSTIDX
1742 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1743 echo $OSC "is Deactivated:"
1744 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1748 OSTIDX=$(index_from_ostuuid $OST)
1750 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1752 for OSC in $MDS_OSCS; do
1753 OST=$(osc_to_ost $OSC)
1754 OSTIDX=$(index_from_ostuuid $OST)
1755 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1756 echo $OST "is degraded:"
1757 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1758 obdfilter.$OST.degraded=1
1763 createmany -o $DIR/$tdir/$tfile $fcount
1765 for OSC in $MDS_OSCS; do
1766 OST=$(osc_to_ost $OSC)
1767 OSTIDX=$(index_from_ostuuid $OST)
1768 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1769 echo $OST "is recovered from degraded:"
1770 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1771 obdfilter.$OST.degraded=0
1773 do_facet $SINGLEMDS lctl --device %$OSC activate
1777 # all osp devices get activated, hence -1 stripe count restored
1780 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1781 # devices get activated.
1783 $SETSTRIPE -c -1 $DIR/$tfile
1784 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1786 [ $stripecnt -ne $OSTCOUNT ] &&
1787 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1790 run_test 27y "create files while OST0 is degraded and the rest inactive"
1796 lmm_count=$($GETSTRIPE -c $1)
1797 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1798 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1800 local old_ifs="$IFS"
1802 fid=($($LFS path2fid $1))
1805 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1806 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1808 # compare lmm_seq and lu_fid->f_seq
1809 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1810 # compare lmm_object_id and lu_fid->oid
1811 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1813 # check the trusted.fid attribute of the OST objects of the file
1814 local have_obdidx=false
1816 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1817 # skip lines up to and including "obdidx"
1818 [ -z "$obdidx" ] && break
1819 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1820 $have_obdidx || continue
1822 local ost=$((obdidx + 1))
1823 local dev=$(ostdevname $ost)
1826 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1828 seq=$(echo $seq | sed -e "s/^0x//g")
1829 if [ $seq == 0 ]; then
1830 oid_hex=$(echo $oid)
1832 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1834 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1838 # Don't unmount/remount the OSTs if we don't need to do that.
1839 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1840 # update too, until that use mount/ll_decode_filter_fid/mount.
1841 # Re-enable when debugfs will understand new filter_fid.
1843 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1844 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1845 $dev 2>/dev/null" | grep "parent=")
1848 mount_fstype ost$ost
1849 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1850 $(facet_mntpt ost$ost)/$obj_file)
1851 unmount_fstype ost$ost
1852 start ost$ost $dev $OST_MOUNT_OPTS
1855 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1857 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1859 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1860 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1861 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1862 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1863 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1865 if echo $ff_parent | grep -q 'stripe='; then
1866 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1869 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1870 # into f_ver in this case. See the comment on
1873 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1877 # compare lmm_seq and filter_fid->ff_parent.f_seq
1878 [ $ff_pseq = $lmm_seq ] ||
1879 error "FF parent SEQ $ff_pseq != $lmm_seq"
1880 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1881 [ $ff_poid = $lmm_oid ] ||
1882 error "FF parent OID $ff_poid != $lmm_oid"
1883 (($ff_pstripe == $stripe_nr)) ||
1884 error "FF stripe $ff_pstripe != $stripe_nr"
1886 stripe_nr=$((stripe_nr + 1))
1891 remote_ost_nodsh && skip "remote OST with nodsh" && return
1892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1893 test_mkdir -p $DIR/$tdir
1895 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1896 { error "setstripe -c -1 failed"; return 1; }
1897 # We need to send a write to every object to get parent FID info set.
1898 # This _should_ also work for setattr, but does not currently.
1899 # touch $DIR/$tdir/$tfile-1 ||
1900 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1901 { error "dd $tfile-1 failed"; return 2; }
1902 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1903 { error "setstripe -c -1 failed"; return 3; }
1904 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1905 { error "dd $tfile-2 failed"; return 4; }
1907 # make sure write RPCs have been sent to OSTs
1910 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1911 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1913 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1915 test_27A() { # b=19102
1916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1917 local restore_size=$($GETSTRIPE -S $MOUNT)
1918 local restore_count=$($GETSTRIPE -c $MOUNT)
1919 local restore_offset=$($GETSTRIPE -i $MOUNT)
1920 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1921 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1922 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1923 local default_size=$($GETSTRIPE -S $MOUNT)
1924 local default_offset=$($GETSTRIPE -i $MOUNT)
1925 local dsize=$((1024 * 1024))
1926 [ $default_size -eq $dsize ] ||
1927 error "stripe size $default_size != $dsize"
1928 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1929 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1931 run_test 27A "check filesystem-wide default LOV EA values"
1933 test_27B() { # LU-2523
1934 test_mkdir -p $DIR/$tdir
1935 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1937 # open f1 with O_LOV_DELAY_CREATE
1939 # call setstripe ioctl on open file descriptor for f1
1941 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1945 # open f1 with O_LOV_DELAY_CREATE
1947 # call setstripe ioctl on open file descriptor for f1
1949 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1951 # Allow multiop to fail in imitation of NFS's busted semantics.
1954 run_test 27B "call setstripe on open unlinked file/rename victim"
1956 test_27C() { #LU-2871
1957 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1965 test_mkdir -p $DIR/$tdir
1967 for i in $(seq 0 $((OSTCOUNT - 1))); do
1968 # set stripe across all OSTs starting from OST$i
1969 $SETSTRIPE -i $i -c -1 $tfile$i
1970 # get striping information
1971 ost_idx=($($GETSTRIPE $tfile$i |
1972 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1976 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1977 error "${#ost_idx[@]} != $OSTCOUNT"
1979 for index in $(seq 0 $((OSTCOUNT - 1))); do
1981 for j in $(echo ${ost_idx[@]}); do
1982 if [ $index -eq $j ]; then
1988 error "Can not find $index in ${ost_idx[@]}"
1992 run_test 27C "check full striping across all OSTs"
1994 # createtest also checks that device nodes are created and
1995 # then visible correctly (#2091)
1996 test_28() { # bug 2091
1998 $CREATETEST $DIR/d28/ct || error
2000 run_test 28 "create/mknod/mkdir with bad file types ============"
2003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2004 cancel_lru_locks mdc
2010 declare -i LOCKCOUNTORIG=0
2011 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2012 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2014 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2016 declare -i LOCKUNUSEDCOUNTORIG=0
2017 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2018 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2025 declare -i LOCKCOUNTCURRENT=0
2026 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2027 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2030 declare -i LOCKUNUSEDCOUNTCURRENT=0
2031 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2032 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2035 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2036 $LCTL set_param -n ldlm.dump_namespaces ""
2037 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2038 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2039 log "dumped log to $TMP/test_29.dk (bug 5793)"
2042 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2043 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2044 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2045 log "dumped log to $TMP/test_29.dk (bug 5793)"
2049 run_test 29 "IT_GETATTR regression ============================"
2051 test_30a() { # was test_30
2052 cp $(which ls) $DIR || cp /bin/ls $DIR
2056 run_test 30a "execute binary from Lustre (execve) =============="
2059 cp `which ls` $DIR || cp /bin/ls $DIR
2061 $RUNAS $DIR/ls / || error
2064 run_test 30b "execute binary from Lustre as non-root ==========="
2066 test_30c() { # b=22376
2067 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2068 cp `which ls` $DIR || cp /bin/ls $DIR
2070 cancel_lru_locks mdc
2071 cancel_lru_locks osc
2072 $RUNAS $DIR/ls / || error
2075 run_test 30c "execute binary from Lustre without read perms ===="
2078 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2079 $CHECKSTAT -a $DIR/f31 || error
2081 run_test 31a "open-unlink file =================================="
2084 touch $DIR/f31 || error
2085 ln $DIR/f31 $DIR/f31b || error
2086 $MULTIOP $DIR/f31b Ouc || error
2087 $CHECKSTAT -t file $DIR/f31 || error
2089 run_test 31b "unlink file with multiple links while open ======="
2092 touch $DIR/f31 || error
2093 ln $DIR/f31 $DIR/f31c || error
2094 multiop_bg_pause $DIR/f31 O_uc || return 1
2096 $MULTIOP $DIR/f31c Ouc
2097 kill -USR1 $MULTIPID
2100 run_test 31c "open-unlink file with multiple links ============="
2103 opendirunlink $DIR/d31d $DIR/d31d || error
2104 $CHECKSTAT -a $DIR/d31d || error
2106 run_test 31d "remove of open directory ========================="
2108 test_31e() { # bug 2904
2109 check_kernel_version 34 || return 0
2110 openfilleddirunlink $DIR/d31e || error
2112 run_test 31e "remove of open non-empty directory ==============="
2114 test_31f() { # bug 4554
2115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2117 test_mkdir $DIR/d31f
2118 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2119 cp /etc/hosts $DIR/d31f
2121 $GETSTRIPE $DIR/d31f/hosts
2122 multiop_bg_pause $DIR/d31f D_c || return 1
2125 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2126 test_mkdir $DIR/d31f
2127 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2128 cp /etc/hosts $DIR/d31f
2130 $GETSTRIPE $DIR/d31f/hosts
2131 multiop_bg_pause $DIR/d31f D_c || return 1
2134 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2135 wait $MULTIPID || error "first opendir $MULTIPID failed"
2139 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2140 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2143 run_test 31f "remove of open directory with open-unlink file ==="
2146 echo "-- cross directory link --"
2147 test_mkdir -c1 $DIR/${tdir}ga
2148 test_mkdir -c1 $DIR/${tdir}gb
2149 touch $DIR/${tdir}ga/f
2150 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2151 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2152 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2153 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2154 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2156 run_test 31g "cross directory link==============="
2159 echo "-- cross directory link --"
2160 test_mkdir -c1 $DIR/${tdir}
2161 test_mkdir -c1 $DIR/${tdir}/dir
2162 touch $DIR/${tdir}/f
2163 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2164 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2165 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2166 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2167 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2169 run_test 31h "cross directory link under child==============="
2172 echo "-- cross directory link --"
2173 test_mkdir -c1 $DIR/$tdir
2174 test_mkdir -c1 $DIR/$tdir/dir
2175 touch $DIR/$tdir/dir/f
2176 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2177 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2178 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2179 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2180 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2182 run_test 31i "cross directory link under parent==============="
2185 test_mkdir -c1 -p $DIR/$tdir
2186 test_mkdir -c1 -p $DIR/$tdir/dir1
2187 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2188 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2189 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2190 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2193 run_test 31j "link for directory==============="
2196 test_mkdir -c1 -p $DIR/$tdir
2198 touch $DIR/$tdir/exist
2199 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2200 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2201 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2202 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2203 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2204 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2205 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2208 run_test 31k "link to file: the same, non-existing, dir==============="
2214 touch $DIR/d31m2/exist
2215 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2216 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2217 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2218 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2219 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2220 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2223 run_test 31m "link to file: the same, non-existing, dir==============="
2226 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2227 nlink=$(stat --format=%h $DIR/$tfile)
2228 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2230 local cmd="exec $fd<$DIR/$tfile"
2233 trap "eval $cmd" EXIT
2234 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2235 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2236 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2237 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2238 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2241 run_test 31n "check link count of unlinked file"
2244 local TEMPNAME=$(mktemp $1_XXXXXX)
2245 mlink $TEMPNAME $1 2> /dev/null &&
2246 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2250 test_31o() { # LU-2901
2252 for LOOP in $(seq 100); do
2253 rm -f $DIR/$tdir/$tfile*
2254 for THREAD in $(seq 8); do
2255 link_one $DIR/$tdir/$tfile.$LOOP &
2258 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2259 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2260 error "$LINKS duplicate links to $tfile.$LOOP" &&
2264 run_test 31o "duplicate hard links with same filename"
2267 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2270 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2271 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2273 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2274 error "open unlink test1 failed"
2275 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2276 error "open unlink test2 failed"
2278 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2279 error "test1 still exists"
2280 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2281 error "test2 still exists"
2283 run_test 31p "remove of open striped directory"
2285 cleanup_test32_mount() {
2287 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2292 echo "== more mountpoints and symlinks ================="
2293 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2294 trap cleanup_test32_mount EXIT
2295 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2296 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2297 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2298 cleanup_test32_mount
2300 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2304 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2305 trap cleanup_test32_mount EXIT
2306 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2307 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2308 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2309 cleanup_test32_mount
2311 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2315 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2316 trap cleanup_test32_mount EXIT
2317 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2318 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2319 test_mkdir -p $DIR/$tdir/d2/test_dir
2320 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2321 cleanup_test32_mount
2323 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2327 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2328 trap cleanup_test32_mount EXIT
2329 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2330 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2331 test_mkdir -p $DIR/$tdir/d2/test_dir
2332 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2333 cleanup_test32_mount
2335 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2338 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2339 test_mkdir -p $DIR/d32e/tmp
2340 TMP_DIR=$DIR/d32e/tmp
2341 ln -s $DIR/d32e $TMP_DIR/symlink11
2342 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2343 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2344 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2346 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2349 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2350 test_mkdir -p $DIR/d32f/tmp
2351 TMP_DIR=$DIR/d32f/tmp
2352 ln -s $DIR/d32f $TMP_DIR/symlink11
2353 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2354 ls $DIR/d32f/tmp/symlink11 || error
2355 ls $DIR/d32f/symlink01 || error
2357 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2360 TMP_DIR=$DIR/$tdir/tmp
2361 test_mkdir -p $DIR/$tdir/tmp
2362 test_mkdir $DIR/${tdir}2
2363 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2364 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2365 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2366 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2367 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2368 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2370 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2373 rm -fr $DIR/$tdir $DIR/${tdir}2
2374 TMP_DIR=$DIR/$tdir/tmp
2375 test_mkdir -p $DIR/$tdir/tmp
2376 test_mkdir $DIR/${tdir}2
2377 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2378 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2379 ls $TMP_DIR/symlink12 || error
2380 ls $DIR/$tdir/symlink02 || error
2382 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2385 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2386 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2387 trap cleanup_test32_mount EXIT
2388 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2389 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2390 touch $DIR/$tdir/test_file
2391 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2392 cleanup_test32_mount
2394 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2398 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2399 trap cleanup_test32_mount EXIT
2400 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2401 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2402 touch $DIR/$tdir/test_file
2403 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2404 cleanup_test32_mount
2406 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2411 trap cleanup_test32_mount EXIT
2412 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2413 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2414 test_mkdir -p $DIR/$tdir/d2
2415 touch $DIR/$tdir/d2/test_file || error
2416 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2417 cleanup_test32_mount
2419 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2424 trap cleanup_test32_mount EXIT
2425 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2426 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2427 test_mkdir -p $DIR/$tdir/d2
2428 touch $DIR/$tdir/d2/test_file
2429 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2430 cleanup_test32_mount
2432 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2436 test_mkdir -p $DIR/d32m/tmp
2437 TMP_DIR=$DIR/d32m/tmp
2438 ln -s $DIR $TMP_DIR/symlink11
2439 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2440 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2441 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2443 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2447 test_mkdir -p $DIR/d32n/tmp
2448 TMP_DIR=$DIR/d32n/tmp
2449 ln -s $DIR $TMP_DIR/symlink11
2450 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2451 ls -l $DIR/d32n/tmp/symlink11 || error
2452 ls -l $DIR/d32n/symlink01 || error
2454 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2458 test_mkdir -p $DIR/d32o/tmp
2459 TMP_DIR=$DIR/d32o/tmp
2460 ln -s $DIR/$tfile $TMP_DIR/symlink12
2461 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2462 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2463 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2464 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2465 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2467 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2477 test_mkdir -p $DIR/d32p/tmp
2479 TMP_DIR=$DIR/d32p/tmp
2481 ln -s $DIR/$tfile $TMP_DIR/symlink12
2483 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2485 cat $DIR/d32p/tmp/symlink12 || error
2487 cat $DIR/d32p/symlink02 || error
2490 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2492 cleanup_testdir_mount() {
2494 $UMOUNT -d $DIR/$tdir
2498 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2499 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2500 trap cleanup_testdir_mount EXIT
2501 test_mkdir -p $DIR/$tdir
2502 touch $DIR/$tdir/under_the_mount
2503 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2504 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2505 cleanup_testdir_mount
2507 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2511 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2512 trap cleanup_testdir_mount EXIT
2513 test_mkdir -p $DIR/$tdir
2514 touch $DIR/$tdir/under_the_mount
2515 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2516 ls $DIR/$tdir | grep -q under_the_mount && error || true
2517 cleanup_testdir_mount
2519 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2524 chmod 444 $DIR/$tfile
2525 chown $RUNAS_ID $DIR/$tfile
2527 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2530 run_test 33aa "write file with mode 444 (should return error) ===="
2534 test_mkdir -p $DIR/d33
2535 chown $RUNAS_ID $DIR/d33
2536 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2537 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2538 error "open RDWR" || true
2540 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2544 test_mkdir -p $DIR/d33
2545 chown $RUNAS_ID $DIR/d33
2546 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2548 run_test 33b "test open file with malformed flags (No panic)"
2551 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2557 remote_ost_nodsh && skip "remote OST with nodsh" && return
2560 test_mkdir -p $DIR/d33
2561 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2564 for ostnum in $(seq $OSTCOUNT); do
2565 # test-framework's OST numbering is one-based, while Lustre's
2567 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2568 # Parsing llobdstat's output sucks; we could grep the /proc
2569 # path, but that's likely to not be as portable as using the
2570 # llobdstat utility. So we parse lctl output instead.
2571 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2572 obdfilter/$ostname/stats |
2573 awk '/^write_bytes/ {print $7}' )
2574 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2575 if (( ${write_bytes:-0} > 0 ))
2582 $all_zeros || return 0
2585 echo foo > $DIR/d33/bar
2589 # Total up write_bytes after writing. We'd better find non-zeros.
2590 for ostnum in $(seq $OSTCOUNT); do
2591 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2592 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2593 obdfilter/$ostname/stats |
2594 awk '/^write_bytes/ {print $7}' )
2595 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2596 if (( ${write_bytes:-0} > 0 ))
2605 for ostnum in $(seq $OSTCOUNT); do
2606 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2607 echo "Check that write_bytes is present in obdfilter/*/stats:"
2608 do_facet ost$ostnum lctl get_param -n \
2609 obdfilter/$ostname/stats
2611 error "OST not keeping write_bytes stats (b22312)"
2614 run_test 33c "test llobdstat and write_bytes"
2617 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2620 local remote_dir=$DIR/$tdir/remote_dir
2623 $LFS mkdir -i $MDTIDX $remote_dir ||
2624 error "create remote directory failed"
2626 touch $remote_dir/$tfile
2627 chmod 444 $remote_dir/$tfile
2628 chown $RUNAS_ID $remote_dir/$tfile
2630 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2632 chown $RUNAS_ID $remote_dir
2633 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2634 error "create" || true
2635 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2636 error "open RDWR" || true
2637 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2638 error "create" || true
2640 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2643 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2647 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2648 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2649 mkdir $DIR/$tdir/local_dir
2651 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2652 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2653 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2655 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2656 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2658 rmdir $DIR/$tdir/* || error "rmdir failed"
2661 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2662 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2663 mkdir $DIR/$tdir/local_dir
2665 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2666 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2667 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2669 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2670 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2672 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2675 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2676 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2677 mkdir $DIR/$tdir/local_dir
2679 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2680 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2681 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2683 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2684 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2686 run_test 33e "mkdir and striped directory should have same mode"
2688 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2691 $MCREATE $DIR/f34 || error
2692 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2693 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2694 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2695 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2697 run_test 34a "truncate file that has not been opened ==========="
2700 [ ! -f $DIR/f34 ] && test_34a
2701 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2702 $OPENFILE -f O_RDONLY $DIR/f34
2703 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2704 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2706 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2709 [ ! -f $DIR/f34 ] && test_34a
2710 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2711 $OPENFILE -f O_RDWR $DIR/f34
2712 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2713 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2715 run_test 34c "O_RDWR opening file-with-size works =============="
2718 [ ! -f $DIR/f34 ] && test_34a
2719 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2720 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2723 run_test 34d "write to sparse file ============================="
2727 $MCREATE $DIR/f34e || error
2728 $TRUNCATE $DIR/f34e 1000 || error
2729 $CHECKSTAT -s 1000 $DIR/f34e || error
2730 $OPENFILE -f O_RDWR $DIR/f34e
2731 $CHECKSTAT -s 1000 $DIR/f34e || error
2733 run_test 34e "create objects, some with size and some without =="
2735 test_34f() { # bug 6242, 6243
2736 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2739 $MCREATE $DIR/f34f || error
2740 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2741 dd if=$DIR/f34f of=$TMP/f34f
2742 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2743 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2744 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2745 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2746 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2748 run_test 34f "read from a file with no objects until EOF ======="
2751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2752 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2753 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2754 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2755 cancel_lru_locks osc
2756 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2757 error "wrong size after lock cancel"
2759 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2760 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2761 error "expanding truncate failed"
2762 cancel_lru_locks osc
2763 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2764 error "wrong expanded size after lock cancel"
2766 run_test 34g "truncate long file ==============================="
2769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2773 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2774 sync # Flush the cache so that multiop below does not block on cache
2775 # flush when getting the group lock
2776 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2779 # Since just timed wait is not good enough, let's do a sync write
2780 # that way we are sure enough time for a roundtrip + processing
2781 # passed + 2 seconds of extra margin.
2782 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2786 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2787 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2791 local nsz=`stat -c %s $DIR/$tfile`
2792 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2794 run_test 34h "ftruncate file under grouplock should not block"
2797 cp /bin/sh $DIR/f35a
2799 chown $RUNAS_ID $DIR/f35a
2800 $RUNAS $DIR/f35a && error || true
2803 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2807 utime $DIR/f36 || error
2809 run_test 36a "MDS utime check (mknod, utime) ==================="
2813 utime $DIR/f36 || error
2815 run_test 36b "OST utime check (open, utime) ===================="
2820 chown $RUNAS_ID $DIR/d36
2821 $RUNAS utime $DIR/d36/f36 || error
2823 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2826 [ ! -d $DIR/d36 ] && test_36c
2827 echo "" > $DIR/d36/f36
2828 $RUNAS utime $DIR/d36/f36 || error
2830 run_test 36d "non-root OST utime check (open, utime) ==========="
2833 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2834 test_mkdir -p $DIR/$tdir
2835 touch $DIR/$tdir/$tfile
2836 $RUNAS utime $DIR/$tdir/$tfile && \
2837 error "utime worked, expected failure" || true
2839 run_test 36e "utime on non-owned file (should return error) ===="
2843 local LANG_SAVE=$LANG
2844 local LC_LANG_SAVE=$LC_LANG
2845 export LANG=C LC_LANG=C # for date language
2847 DATESTR="Dec 20 2000"
2848 test_mkdir -p $DIR/$tdir
2849 lctl set_param fail_loc=$fl
2851 cp /etc/hosts $DIR/$tdir/$tfile
2852 sync & # write RPC generated with "current" inode timestamp, but delayed
2854 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2855 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2856 cancel_lru_locks osc
2857 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2859 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2860 echo "BEFORE: $LS_BEFORE" && \
2861 echo "AFTER : $LS_AFTER" && \
2862 echo "WANT : $DATESTR" && \
2863 error "$DIR/$tdir/$tfile timestamps changed" || true
2865 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2869 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2870 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2871 subr_36fh "0x80000214"
2873 run_test 36f "utime on file racing with OST BRW write =========="
2876 remote_ost_nodsh && skip "remote OST with nodsh" && return
2877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2882 test_mkdir -p $DIR/$tdir
2883 fmd_max_age=$(do_facet ost1 \
2884 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2887 fmd_before=$(do_facet ost1 \
2888 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2889 touch $DIR/$tdir/$tfile
2890 sleep $((fmd_max_age + 12))
2891 fmd_after=$(do_facet ost1 \
2892 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2894 echo "fmd_before: $fmd_before"
2895 echo "fmd_after: $fmd_after"
2896 [[ $fmd_after -gt $fmd_before ]] &&
2897 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2898 error "fmd didn't expire after ping" || true
2900 run_test 36g "filter mod data cache expiry ====================="
2903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2904 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2905 subr_36fh "0x80000227"
2907 run_test 36h "utime on file racing with OST BRW write =========="
2910 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2913 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2915 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2916 local new_mtime=$((mtime + 200))
2918 #change Modify time of striped dir
2919 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2920 error "change mtime failed"
2922 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2924 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2926 run_test 36i "change mtime on striped directory"
2928 # test_37 - duplicate with tests 32q 32r
2931 local file=$DIR/$tfile
2933 openfile -f O_DIRECTORY $file
2936 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2937 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2939 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2943 touch $DIR/${tfile}2
2944 # ls -l $DIR/$tfile $DIR/${tfile}2
2945 # ls -lu $DIR/$tfile $DIR/${tfile}2
2946 # ls -lc $DIR/$tfile $DIR/${tfile}2
2948 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2949 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2951 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2953 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2955 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2956 error "O_TRUNC didn't change timestamps"
2959 run_test 39 "mtime changed on create ==========================="
2962 test_mkdir -p -c1 $DIR/$tdir
2963 cp -p /etc/passwd $DIR/$tdir/fopen
2964 cp -p /etc/passwd $DIR/$tdir/flink
2965 cp -p /etc/passwd $DIR/$tdir/funlink
2966 cp -p /etc/passwd $DIR/$tdir/frename
2967 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2970 echo "aaaaaa" >> $DIR/$tdir/fopen
2971 echo "aaaaaa" >> $DIR/$tdir/flink
2972 echo "aaaaaa" >> $DIR/$tdir/funlink
2973 echo "aaaaaa" >> $DIR/$tdir/frename
2975 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2976 local link_new=`stat -c %Y $DIR/$tdir/flink`
2977 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2978 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2980 cat $DIR/$tdir/fopen > /dev/null
2981 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2982 rm -f $DIR/$tdir/funlink2
2983 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2985 for (( i=0; i < 2; i++ )) ; do
2986 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2987 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2988 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2989 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2991 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2992 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2993 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2994 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2996 cancel_lru_locks osc
2997 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3000 run_test 39b "mtime change on open, link, unlink, rename ======"
3002 # this should be set to past
3003 TEST_39_MTIME=`date -d "1 year ago" +%s`
3009 local mtime0=`stat -c %Y $DIR1/$tfile`
3011 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3012 local mtime1=`stat -c %Y $DIR1/$tfile`
3013 [ "$mtime1" = $TEST_39_MTIME ] || \
3014 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3017 echo hello >> $DIR1/$tfile
3019 local mtime2=`stat -c %Y $DIR1/$tfile`
3020 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3021 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3023 mv $DIR1/$tfile $DIR1/$tfile-1
3025 for (( i=0; i < 2; i++ )) ; do
3026 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3027 [ "$mtime2" = "$mtime3" ] || \
3028 error "mtime ($mtime2) changed (to $mtime3) on rename"
3030 cancel_lru_locks osc
3031 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3034 run_test 39c "mtime change on rename ==========================="
3038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3041 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3043 for (( i=0; i < 2; i++ )) ; do
3044 local mtime=`stat -c %Y $DIR1/$tfile`
3045 [ $mtime = $TEST_39_MTIME ] || \
3046 error "mtime($mtime) is not set to $TEST_39_MTIME"
3048 cancel_lru_locks osc
3049 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3052 run_test 39d "create, utime, stat =============================="
3056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3058 local mtime1=`stat -c %Y $DIR1/$tfile`
3060 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3062 for (( i=0; i < 2; i++ )) ; do
3063 local mtime2=`stat -c %Y $DIR1/$tfile`
3064 [ $mtime2 = $TEST_39_MTIME ] || \
3065 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3067 cancel_lru_locks osc
3068 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3071 run_test 39e "create, stat, utime, stat ========================"
3075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3077 mtime1=`stat -c %Y $DIR1/$tfile`
3080 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3082 for (( i=0; i < 2; i++ )) ; do
3083 local mtime2=`stat -c %Y $DIR1/$tfile`
3084 [ $mtime2 = $TEST_39_MTIME ] || \
3085 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3087 cancel_lru_locks osc
3088 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3091 run_test 39f "create, stat, sleep, utime, stat ================="
3095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3096 echo hello >> $DIR1/$tfile
3097 local mtime1=`stat -c %Y $DIR1/$tfile`
3100 chmod o+r $DIR1/$tfile
3102 for (( i=0; i < 2; i++ )) ; do
3103 local mtime2=`stat -c %Y $DIR1/$tfile`
3104 [ "$mtime1" = "$mtime2" ] || \
3105 error "lost mtime: $mtime2, should be $mtime1"
3107 cancel_lru_locks osc
3108 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3111 run_test 39g "write, chmod, stat ==============================="
3115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3120 echo hello >> $DIR1/$tfile
3121 local mtime1=`stat -c %Y $DIR1/$tfile`
3123 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3125 if [ "$d1" != "$d2" ]; then
3126 echo "write and touch not within one second"
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3130 [ "$mtime2" = $TEST_39_MTIME ] || \
3131 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39h "write, utime within one second, stat ============="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3145 echo hello >> $DIR1/$tfile
3146 local mtime1=`stat -c %Y $DIR1/$tfile`
3148 mv $DIR1/$tfile $DIR1/$tfile-1
3150 for (( i=0; i < 2; i++ )) ; do
3151 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3153 [ "$mtime1" = "$mtime2" ] || \
3154 error "lost mtime: $mtime2, should be $mtime1"
3156 cancel_lru_locks osc
3157 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3160 run_test 39i "write, rename, stat =============================="
3163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3164 start_full_debug_logging
3168 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3169 lctl set_param fail_loc=0x80000412
3170 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3171 error "multiop failed"
3173 local mtime1=`stat -c %Y $DIR1/$tfile`
3175 mv $DIR1/$tfile $DIR1/$tfile-1
3177 kill -USR1 $multipid
3178 wait $multipid || error "multiop close failed"
3180 for (( i=0; i < 2; i++ )) ; do
3181 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3182 [ "$mtime1" = "$mtime2" ] ||
3183 error "mtime is lost on close: $mtime2, " \
3186 cancel_lru_locks osc
3187 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3189 lctl set_param fail_loc=0
3190 stop_full_debug_logging
3192 run_test 39j "write, rename, close, stat ======================="
3195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3199 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3201 local mtime1=`stat -c %Y $DIR1/$tfile`
3203 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3205 kill -USR1 $multipid
3206 wait $multipid || error "multiop close failed"
3208 for (( i=0; i < 2; i++ )) ; do
3209 local mtime2=`stat -c %Y $DIR1/$tfile`
3211 [ "$mtime2" = $TEST_39_MTIME ] || \
3212 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3214 cancel_lru_locks osc
3215 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3218 run_test 39k "write, utime, close, stat ========================"
3220 # this should be set to future
3221 TEST_39_ATIME=`date -d "1 year" +%s`
3224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3225 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3226 local atime_diff=$(do_facet $SINGLEMDS \
3227 lctl get_param -n mdd.*MDT0000*.atime_diff)
3231 # test setting directory atime to future
3232 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3233 local atime=$(stat -c %X $DIR/$tdir)
3234 [ "$atime" = $TEST_39_ATIME ] || \
3235 error "atime is not set to future: $atime, $TEST_39_ATIME"
3237 # test setting directory atime from future to now
3238 local d1=$(date +%s)
3240 local d2=$(date +%s)
3242 cancel_lru_locks mdc
3243 atime=$(stat -c %X $DIR/$tdir)
3244 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3245 error "atime is not updated from future: $atime, $d1<atime<$d2"
3247 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3250 # test setting directory atime when now > dir atime + atime_diff
3254 cancel_lru_locks mdc
3255 atime=$(stat -c %X $DIR/$tdir)
3256 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3257 error "atime is not updated : $atime, should be $d2"
3259 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3262 # test not setting directory atime when now < dir atime + atime_diff
3264 cancel_lru_locks mdc
3265 atime=$(stat -c %X $DIR/$tdir)
3266 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3267 error "atime is updated to $atime, should remain $d1<atime<$d2"
3269 do_facet $SINGLEMDS \
3270 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3272 run_test 39l "directory atime update ==========================="
3275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3278 local far_past_mtime=$(date -d "May 29 1953" +%s)
3279 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3281 touch -m -d @$far_past_mtime $DIR1/$tfile
3282 touch -a -d @$far_past_atime $DIR1/$tfile
3284 for (( i=0; i < 2; i++ )) ; do
3285 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3286 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3287 error "atime or mtime set incorrectly"
3289 cancel_lru_locks osc
3290 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3293 run_test 39m "test atime and mtime before 1970"
3295 test_39n() { # LU-3832
3296 local atime_diff=$(do_facet $SINGLEMDS \
3297 lctl get_param -n mdd.*MDT0000*.atime_diff)
3302 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3305 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3306 atime0=$(stat -c %X $DIR/$tfile)
3309 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3310 atime1=$(stat -c %X $DIR/$tfile)
3313 cancel_lru_locks mdc
3314 cancel_lru_locks osc
3315 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3316 atime2=$(stat -c %X $DIR/$tfile)
3318 do_facet $SINGLEMDS \
3319 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3321 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3322 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3324 run_test 39n "check that O_NOATIME is honored"
3327 TESTDIR=$DIR/$tdir/$tfile
3328 [ -e $TESTDIR ] && rm -rf $TESTDIR
3329 test_mkdir -p $TESTDIR
3335 links2=$(stat -c %h .)
3336 [ $(($links1 + 2)) != $links2 ] &&
3337 error "wrong links count $(($links1 + 2)) != $links2"
3339 links3=$(stat -c %h .)
3340 [ $(($links1 + 1)) != $links3 ] &&
3341 error "wrong links count $links1 != $links3"
3344 run_test 39o "directory cached attributes updated after create ========"
3347 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3349 TESTDIR=$DIR/$tdir/$tfile
3350 [ -e $TESTDIR ] && rm -rf $TESTDIR
3355 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3356 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3358 links2=$(stat -c %h .)
3359 [ $(($links1 + 2)) != $links2 ] &&
3360 error "wrong links count $(($links1 + 2)) != $links2"
3362 links3=$(stat -c %h .)
3363 [ $(($links1 + 1)) != $links3 ] &&
3364 error "wrong links count $links1 != $links3"
3367 run_test 39p "remote directory cached attributes updated after create ========"
3371 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3372 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3373 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3374 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3375 error "$tfile is not 4096 bytes in size"
3377 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3381 small_write $DIR/f41 18
3383 run_test 41 "test small file write + fstat ====================="
3385 count_ost_writes() {
3386 lctl get_param -n osc.*.stats |
3387 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3388 END { printf("%0.0f", writes) }'
3395 BG_DIRTY_RATIO_SAVE=10
3396 MAX_BG_DIRTY_RATIO=25
3400 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3401 # dirty_ratio, dirty_background_ratio
3402 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3403 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3404 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3405 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3407 # if file not here, we are a 2.4 kernel
3408 kill -CONT `pidof kupdated`
3413 # setup the trap first, so someone cannot exit the test at the
3414 # exact wrong time and mess up a machine
3415 trap start_writeback EXIT
3416 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3417 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3418 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3419 sysctl -w vm.dirty_writeback_centisecs=0
3420 sysctl -w vm.dirty_writeback_centisecs=0
3421 # save and increase /proc/sys/vm/dirty_ratio
3422 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3423 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3424 # save and increase /proc/sys/vm/dirty_background_ratio
3425 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3426 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3428 # if file not here, we are a 2.4 kernel
3429 kill -STOP `pidof kupdated`
3433 # ensure that all stripes have some grant before we test client-side cache
3435 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3436 dd if=/dev/zero of=$i bs=4k count=1
3441 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3442 # file truncation, and file removal.
3444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3446 cancel_lru_locks osc
3448 sync; sleep 1; sync # just to be safe
3449 BEFOREWRITES=`count_ost_writes`
3450 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3451 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3452 AFTERWRITES=`count_ost_writes`
3453 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3454 error "$BEFOREWRITES < $AFTERWRITES"
3457 run_test 42a "ensure that we don't flush on close =============="
3460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3462 cancel_lru_locks osc
3465 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3466 BEFOREWRITES=$(count_ost_writes)
3467 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3468 AFTERWRITES=$(count_ost_writes)
3469 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3470 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3472 BEFOREWRITES=$(count_ost_writes)
3473 sync || error "sync: $?"
3474 AFTERWRITES=$(count_ost_writes)
3475 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3476 error "$BEFOREWRITES < $AFTERWRITES on sync"
3478 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3482 run_test 42b "test destroy of file with cached dirty data ======"
3484 # if these tests just want to test the effect of truncation,
3485 # they have to be very careful. consider:
3486 # - the first open gets a {0,EOF}PR lock
3487 # - the first write conflicts and gets a {0, count-1}PW
3488 # - the rest of the writes are under {count,EOF}PW
3489 # - the open for truncate tries to match a {0,EOF}PR
3490 # for the filesize and cancels the PWs.
3491 # any number of fixes (don't get {0,EOF} on open, match
3492 # composite locks, do smarter file size management) fix
3493 # this, but for now we want these tests to verify that
3494 # the cancellation with truncate intent works, so we
3495 # start the file with a full-file pw lock to match against
3496 # until the truncate.
3501 cancel_lru_locks osc
3503 # prime the file with 0,EOF PW to match
3507 # now the real test..
3508 dd if=/dev/zero of=$file bs=1024 count=100
3509 BEFOREWRITES=`count_ost_writes`
3510 $TRUNCATE $file $offset
3511 cancel_lru_locks osc
3512 AFTERWRITES=`count_ost_writes`
3517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3519 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3520 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3523 run_test 42c "test partial truncate of file with cached dirty data"
3526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3528 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3529 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3532 run_test 42d "test complete truncate of file with cached dirty data"
3534 test_42e() { # bug22074
3535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3536 local TDIR=$DIR/${tdir}e
3537 local pagesz=$(page_size)
3538 local pages=16 # hardcoded 16 pages, don't change it.
3539 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3540 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3544 test_mkdir -p $DIR/${tdir}e
3545 $SETSTRIPE -c 1 $TDIR
3546 createmany -o $TDIR/f $files
3548 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3550 # we assume that with $OSTCOUNT files, at least one of them will
3551 # be allocated on OST0.
3552 warmup_files=$((OSTCOUNT * max_dirty_mb))
3553 createmany -o $TDIR/w $warmup_files
3555 # write a large amount of data into one file and sync, to get good
3556 # avail_grant number from OST.
3557 for ((i=0; i<$warmup_files; i++)); do
3558 idx=$($GETSTRIPE -i $TDIR/w$i)
3559 [ $idx -ne 0 ] && continue
3560 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3563 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3565 $LCTL get_param $proc_osc0/cur_dirty_bytes
3566 $LCTL get_param $proc_osc0/cur_grant_bytes
3568 # create as much dirty pages as we can while not to trigger the actual
3569 # RPCs directly. but depends on the env, VFS may trigger flush during this
3570 # period, hopefully we are good.
3571 for ((i=0; i<$warmup_files; i++)); do
3572 idx=$($GETSTRIPE -i $TDIR/w$i)
3573 [ $idx -ne 0 ] && continue
3574 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3576 $LCTL get_param $proc_osc0/cur_dirty_bytes
3577 $LCTL get_param $proc_osc0/cur_grant_bytes
3579 # perform the real test
3580 $LCTL set_param $proc_osc0/rpc_stats 0
3581 for ((;i<$files; i++)); do
3582 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3583 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3586 $LCTL get_param $proc_osc0/rpc_stats
3589 local have_ppr=false
3590 $LCTL get_param $proc_osc0/rpc_stats |
3591 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3592 # skip lines until we are at the RPC histogram data
3593 [ "$PPR" == "pages" ] && have_ppr=true && continue
3594 $have_ppr || continue
3596 # we only want the percent stat for < 16 pages
3597 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3599 percent=$((percent + WPCT))
3600 if [[ $percent -gt 15 ]]; then
3601 error "less than 16-pages write RPCs" \
3608 run_test 42e "verify sub-RPC writes are not done synchronously"
3611 test_mkdir -p $DIR/$tdir
3612 cp -p /bin/ls $DIR/$tdir/$tfile
3613 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3615 # give multiop a chance to open
3618 $DIR/$tdir/$tfile && error || true
3621 run_test 43 "execution of file opened for write should return -ETXTBSY"
3624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3625 test_mkdir -p $DIR/$tdir
3626 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3627 cp -p multiop $DIR/$tdir/multiop
3628 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3631 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3632 kill -USR1 $MULTIOP_PID || return 2
3633 wait $MULTIOP_PID || return 3
3634 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3636 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3640 test_mkdir -p $DIR/$tdir
3641 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3642 cp -p multiop $DIR/$tdir/multiop
3643 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3646 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3647 kill -USR1 $MULTIOP_PID || return 2
3648 wait $MULTIOP_PID || return 3
3649 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3651 run_test 43b "truncate of file being executed should return -ETXTBSY"
3654 local testdir="$DIR/$tdir"
3655 test_mkdir -p $DIR/$tdir
3657 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3658 ( cd $testdir && md5sum -c)
3660 run_test 43c "md5sum of copy into lustre========================"
3663 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3664 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3665 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3667 run_test 44 "zero length read from a sparse stripe ============="
3670 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3672 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3673 [[ $nstripe -gt $OSTCOUNT ]] &&
3674 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3676 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3678 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3679 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3683 OFFSETS="0 $((stride/2)) $((stride-1))"
3684 for offset in $OFFSETS; do
3685 for i in $(seq 0 $((nstripe-1))); do
3686 local GLOBALOFFSETS=""
3688 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3689 local myfn=$DIR/d44a-$size
3690 echo "--------writing $myfn at $size"
3691 ll_sparseness_write $myfn $size ||
3692 error "ll_sparseness_write"
3693 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3694 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3695 error "ll_sparseness_verify $GLOBALOFFSETS"
3697 for j in $(seq 0 $((nstripe-1))); do
3699 size=$((((j + $nstripe )*$stride + $offset)))
3700 ll_sparseness_write $myfn $size ||
3701 error "ll_sparseness_write"
3702 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3704 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3705 error "ll_sparseness_verify $GLOBALOFFSETS"
3710 run_test 44a "test sparse pwrite ==============================="
3714 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3720 before=`dirty_osc_total`
3721 echo executing "\"$*\""
3723 after=`dirty_osc_total`
3724 echo before $before, after $after
3727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3729 # Obtain grants from OST if it supports it
3730 echo blah > ${f}_grant
3733 do_dirty_record "echo blah > $f"
3734 [[ $before -eq $after ]] && error "write wasn't cached"
3735 do_dirty_record "> $f"
3736 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3737 do_dirty_record "echo blah > $f"
3738 [[ $before -eq $after ]] && error "write wasn't cached"
3739 do_dirty_record "sync"
3740 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3741 do_dirty_record "echo blah > $f"
3742 [[ $before -eq $after ]] && error "write wasn't cached"
3743 do_dirty_record "cancel_lru_locks osc"
3744 [[ $before -gt $after ]] ||
3745 error "lock cancellation didn't lower dirty count"
3748 run_test 45 "osc io page accounting ============================"
3750 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3751 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3752 # objects offset and an assert hit when an rpc was built with 1023's mapped
3753 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3759 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3761 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3762 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3766 run_test 46 "dirtying a previously written page ================"
3768 # test_47 is removed "Device nodes check" is moved to test_28
3770 test_48a() { # bug 2399
3771 check_kernel_version 34 || return 0
3772 test_mkdir -p $DIR/$tdir
3774 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3775 test_mkdir $DIR/$tdir || error "recreate directory failed"
3776 touch foo || error "'touch foo' failed after recreating cwd"
3777 test_mkdir $DIR/$tdir/bar ||
3778 error "'mkdir foo' failed after recreating cwd"
3779 if check_kernel_version 44; then
3780 touch .foo || error "'touch .foo' failed after recreating cwd"
3781 test_mkdir $DIR/$tdir/.bar ||
3782 error "'mkdir .foo' failed after recreating cwd"
3784 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3785 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3786 cd . || error "'cd .' failed after recreating cwd"
3787 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3788 rmdir . && error "'rmdir .' worked after recreating cwd"
3789 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3790 cd .. || error "'cd ..' failed after recreating cwd"
3792 run_test 48a "Access renamed working dir (should return errors)="
3794 test_48b() { # bug 2399
3795 check_kernel_version 34 || return 0
3797 test_mkdir -p $DIR/$tdir
3799 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3800 touch foo && error "'touch foo' worked after removing cwd"
3801 test_mkdir $DIR/$tdir/foo &&
3802 error "'mkdir foo' worked after removing cwd"
3803 if check_kernel_version 44; then
3804 touch .foo && error "'touch .foo' worked after removing cwd"
3805 test_mkdir $DIR/$tdir/.foo &&
3806 error "'mkdir .foo' worked after removing cwd"
3808 ls . > /dev/null && error "'ls .' worked after removing cwd"
3809 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3810 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3811 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3812 rmdir . && error "'rmdir .' worked after removing cwd"
3813 ln -s . foo && error "'ln -s .' worked after removing cwd"
3814 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3816 run_test 48b "Access removed working dir (should return errors)="
3818 test_48c() { # bug 2350
3819 check_kernel_version 36 || return 0
3820 #lctl set_param debug=-1
3823 test_mkdir -p $DIR/$tdir/dir
3825 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3826 $TRACE touch foo && error "touch foo worked after removing cwd"
3827 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3828 if check_kernel_version 44; then
3829 touch .foo && error "touch .foo worked after removing cwd"
3830 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3832 $TRACE ls . && error "'ls .' worked after removing cwd"
3833 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3834 is_patchless || ( $TRACE cd . &&
3835 error "'cd .' worked after removing cwd" )
3836 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3837 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3838 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3839 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3841 run_test 48c "Access removed working subdir (should return errors)"
3843 test_48d() { # bug 2350
3844 check_kernel_version 36 || return 0
3845 #lctl set_param debug=-1
3848 test_mkdir -p $DIR/$tdir/dir
3850 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3851 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3852 $TRACE touch foo && error "'touch foo' worked after removing parent"
3853 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3854 if check_kernel_version 44; then
3855 touch .foo && error "'touch .foo' worked after removing parent"
3857 error "mkdir .foo worked after removing parent"
3859 $TRACE ls . && error "'ls .' worked after removing parent"
3860 $TRACE ls .. && error "'ls ..' worked after removing parent"
3861 is_patchless || ( $TRACE cd . &&
3862 error "'cd .' worked after recreate parent" )
3863 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3864 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3865 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3866 is_patchless || ( $TRACE cd .. &&
3867 error "'cd ..' worked after removing parent" || true )
3869 run_test 48d "Access removed parent subdir (should return errors)"
3871 test_48e() { # bug 4134
3872 check_kernel_version 41 || return 0
3873 #lctl set_param debug=-1
3876 test_mkdir -p $DIR/$tdir/dir
3878 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3879 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3880 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3881 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3882 # On a buggy kernel addition of "touch foo" after cd .. will
3883 # produce kernel oops in lookup_hash_it
3884 touch ../foo && error "'cd ..' worked after recreate parent"
3886 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3888 run_test 48e "Access to recreated parent subdir (should return errors)"
3890 test_49() { # LU-1030
3891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3892 # get ost1 size - lustre-OST0000
3893 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3895 # write 800M at maximum
3896 [[ $ost1_size -lt 2 ]] && ost1_size=2
3897 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3899 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3900 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3903 # change max_pages_per_rpc while writing the file
3904 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3905 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3906 # loop until dd process exits
3907 while ps ax -opid | grep -wq $dd_pid; do
3908 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3909 sleep $((RANDOM % 5 + 1))
3911 # restore original max_pages_per_rpc
3912 $LCTL set_param $osc1_mppc=$orig_mppc
3913 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3915 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3919 test_mkdir $DIR/$tdir
3921 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3923 run_test 50 "special situations: /proc symlinks ==============="
3925 test_51a() { # was test_51
3926 # bug 1516 - create an empty entry right after ".." then split dir
3927 test_mkdir -c1 $DIR/$tdir
3928 touch $DIR/$tdir/foo
3929 $MCREATE $DIR/$tdir/bar
3931 createmany -m $DIR/$tdir/longfile 201
3933 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3934 $MCREATE $DIR/$tdir/longfile$FNUM
3939 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3941 run_test 51a "special situations: split htree with empty entry =="
3943 export NUMTEST=70000
3945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3946 local BASE=$DIR/d${base}.${TESTSUITE}
3948 # cleanup the directory
3951 test_mkdir -p -c1 $BASE
3953 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3954 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3955 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3958 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3959 echo "reduced count to $NUMTEST due to inodes"
3961 # need to check free space for the directories as well
3962 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3963 numfree=$((blkfree / 4))
3964 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3965 echo "reduced count to $NUMTEST due to blocks"
3967 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3968 echo "failed" > $BASE/fnum
3970 run_test 51b "exceed 64k subdirectory nlink limit"
3972 test_51ba() { # LU-993
3973 local BASE=$DIR/d${base}.${TESTSUITE}
3974 # unlink all but 100 subdirectories, then check it still works
3976 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3978 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3979 local DELETE=$((NUMTEST - LEFT))
3981 # continue on to run this test even if 51b didn't finish,
3982 # just to delete the many subdirectories created.
3983 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3985 # for ldiskfs the nlink count should be 1, but this is OSD specific
3986 # and so this is listed for informational purposes only
3987 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3988 unlinkmany -d $BASE/d $DELETE
3991 if [ $RC -ne 0 ]; then
3992 if [ "$NUMPREV" == "failed" ]; then
3993 skip "previous setup failed"
3996 error "unlink of first $DELETE subdirs failed"
4001 echo "nlink between: $(stat -c %h $BASE)"
4002 # trim the first line of ls output
4003 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4004 [ $FOUND -ne $LEFT ] &&
4005 error "can't find subdirs: found only $FOUND/$LEFT"
4007 unlinkmany -d $BASE/d $DELETE $LEFT ||
4008 error "unlink of second $LEFT subdirs failed"
4009 # regardless of whether the backing filesystem tracks nlink accurately
4010 # or not, the nlink count shouldn't be more than "." and ".." here
4011 local AFTER=$(stat -c %h $BASE)
4012 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4013 echo "nlink after: $AFTER"
4015 run_test 51ba "verify nlink for many subdirectory cleanup"
4018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4019 [[ $OSTCOUNT -lt 3 ]] &&
4020 skip_env "skipping test with few OSTs" && return
4021 test_mkdir -p $DIR/$tdir
4022 createmany -o $DIR/$tdir/t- 1000
4023 $GETSTRIPE $DIR/$tdir > $TMP/files
4024 for N in $(seq 0 $((OSTCOUNT - 1))); do
4025 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4026 END { printf("%0.0f", objs) }' $TMP/files)
4027 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4028 '($1 == '$N') { objs += 1 } \
4029 END { printf("%0.0f", objs) }')
4030 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4032 unlinkmany $DIR/$tdir/t- 1000
4035 for N in $(seq 1 $((OSTCOUNT - 1))); do
4036 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4037 error "OST $N has less objects vs OST $NLAST" \
4038 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4039 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4040 error "OST $N has less objects vs OST $NLAST" \
4041 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4043 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4044 error "OST $N has less #0 objects vs OST $NLAST" \
4045 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4046 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4047 error "OST $N has less #0 objects vs OST $NLAST" \
4048 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4052 run_test 51d "check object distribution ===================="
4055 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4056 skip "Only applicable to ldiskfs-based MDTs"
4060 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4061 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4063 touch $DIR/$tdir/d0/foo
4064 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4065 error "file exceed 65000 nlink limit!"
4066 unlinkmany $DIR/$tdir/d0/f- 65001
4069 run_test 51e "check file nlink limit"
4072 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4073 test_mkdir -p $DIR/$tdir
4074 touch $DIR/$tdir/foo
4075 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4076 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4077 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4078 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4079 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4081 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4082 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4083 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4085 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4086 cp -r $DIR/$tdir /tmp/
4087 rm -fr $DIR/$tdir || error "cleanup rm failed"
4089 run_test 52a "append-only flag test (should return errors) ====="
4092 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4093 test_mkdir -p $DIR/$tdir
4094 touch $DIR/$tdir/foo
4095 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4096 cat test > $DIR/$tdir/foo && error "cat test worked"
4097 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4098 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4099 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4101 echo foo >> $DIR/$tdir/foo && error "echo worked"
4102 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4103 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4104 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4105 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4107 chattr -i $DIR/$tdir/foo || error "chattr failed"
4109 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4111 run_test 52b "immutable flag test (should return errors) ======="
4114 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4115 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4116 remote_ost_nodsh && skip "remote OST with nodsh" && return
4129 local support_last_seq=true
4131 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4132 support_last_seq=false
4135 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4137 for value in $(do_facet $SINGLEMDS \
4138 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4139 param=$(echo ${value[0]} | cut -d "=" -f1)
4140 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4142 if $support_last_seq; then
4143 param_seq=$(echo $param |
4144 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4145 mds_last_seq=$(do_facet $SINGLEMDS \
4146 $LCTL get_param -n $param_seq)
4148 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4150 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4151 node=$(facet_active_host ost$((ostnum+1)))
4152 param="obdfilter.$ostname.last_id"
4153 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4154 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4155 ost_last_id=$ost_last
4157 if $support_last_seq; then
4158 ost_last_id=$(echo $ost_last |
4159 awk -F':' '{print $2}' |
4161 ost_last_seq=$(echo $ost_last |
4162 awk -F':' '{print $1}')
4163 [[ $ost_last_seq = $mds_last_seq ]] || continue
4166 if [[ $ost_last_id != $mds_last ]]; then
4167 error "$ost_last_id != $mds_last"
4174 $found || error "can not match last_seq/last_id for $mdtosc"
4177 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4180 $SOCKETSERVER $DIR/socket ||
4181 error "$SOCKETSERVER $DIR/socket failed: $?"
4182 $SOCKETCLIENT $DIR/socket ||
4183 error "$SOCKETCLIENT $DIR/socket failed: $?"
4184 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4186 run_test 54a "unix domain socket test =========================="
4192 dd if=/dev/zero of=$f bs=$(page_size) count=1
4194 run_test 54b "char device works in lustre ======================"
4197 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4198 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4199 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4201 for i in $(seq 3 7); do
4202 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4210 loopdev="$DIR/loop54c"
4213 $UMOUNT -d $DIR/$tdir || rc=$?
4214 losetup -d $loopdev || true
4215 losetup -d $LOOPDEV || true
4216 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4222 loopdev="$DIR/loop54c"
4225 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4226 trap cleanup_54c EXIT
4227 mknod $loopdev b 7 $LOOPNUM
4228 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4229 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4230 losetup $loopdev $DIR/$tfile ||
4231 error "can't set up $loopdev for $DIR/$tfile"
4232 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4233 test_mkdir -p $DIR/$tdir
4234 mount -t ext2 $loopdev $DIR/$tdir ||
4235 error "error mounting $loopdev on $DIR/$tdir"
4236 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4239 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4243 run_test 54c "block device works in lustre ====================="
4249 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4251 run_test 54d "fifo device works in lustre ======================"
4254 check_kernel_version 46 || return 0
4257 cp -aL /dev/console $f
4258 echo $string > $f || error "echo $string to $f failed"
4260 run_test 54e "console/tty device works in lustre ======================"
4262 #The test_55 used to be iopen test and it was removed by bz#24037.
4263 #run_test 55 "check iopen_connect_dentry() ======================"
4265 test_56a() { # was test_56
4268 test_mkdir -p $DIR/$tdir/dir
4270 NUMFILESx2=$(($NUMFILES * 2))
4271 for i in $(seq 1 $NUMFILES); do
4272 touch $DIR/$tdir/file$i
4273 touch $DIR/$tdir/dir/file$i
4276 # test lfs getstripe with --recursive
4277 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4278 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4279 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4280 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4281 [[ $FILENUM -eq $NUMFILES ]] ||
4282 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4283 echo "$GETSTRIPE --recursive passed."
4285 # test lfs getstripe with file instead of dir
4286 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4287 [[ $FILENUM -eq 1 ]] ||
4288 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4289 echo "$GETSTRIPE file1 passed."
4291 #test lfs getstripe with --verbose
4292 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4293 grep -c lmm_magic) -eq $NUMFILES ]] ||
4294 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4295 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4296 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4297 echo "$GETSTRIPE --verbose passed."
4299 #test lfs getstripe with --obd
4300 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4301 grep -q "unknown obduuid" ||
4302 error "$GETSTRIPE --obd wrong_uuid should return error message"
4304 [[ $OSTCOUNT -lt 2 ]] &&
4305 skip_env "skipping other $GETSTRIPE --obd test" && return
4308 OBDUUID=$(ostuuid_from_index $OSTIDX)
4309 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4310 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4311 [[ $FOUND -eq $FILENUM ]] ||
4312 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4313 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4314 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4315 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4316 error "$GETSTRIPE --obd: should not show file on other obd"
4317 echo "$GETSTRIPE --obd passed"
4319 run_test 56a "check $GETSTRIPE"
4324 local LOCAL_NUMFILES="$1"
4325 local LOCAL_NUMDIRS="$2"
4326 local MKDIR_PARAMS="$3"
4327 local DIR_STRIPE_PARAMS="$4"
4329 if [ ! -d "$TDIR" ] ; then
4330 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4331 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4332 for i in `seq 1 $LOCAL_NUMFILES` ; do
4335 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4336 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4337 for j in `seq 1 $LOCAL_NUMFILES` ; do
4338 touch $TDIR/dir$i/file$j
4344 setup_56_special() {
4348 if [ ! -e "$TDIR/loop1b" ] ; then
4349 for i in `seq 1 $LOCAL_NUMFILES` ; do
4350 mknod $TDIR/loop${i}b b 7 $i
4351 mknod $TDIR/null${i}c c 1 3
4352 ln -s $TDIR/file1 $TDIR/link${i}l
4354 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4355 mknod $TDIR/dir$i/loop${i}b b 7 $i
4356 mknod $TDIR/dir$i/null${i}c c 1 3
4357 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4366 setup_56 $NUMFILES $NUMDIRS
4368 EXPECTED=$(($NUMDIRS + 2))
4369 # test lfs find with -name
4370 for i in $(seq 1 $NUMFILES) ; do
4371 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4372 [ $NUMS -eq $EXPECTED ] ||
4373 error "lfs find -name \"*$i\" $TDIR wrong: "\
4374 "found $NUMS, expected $EXPECTED"
4377 run_test 56g "check lfs find -name ============================="
4383 setup_56 $NUMFILES $NUMDIRS
4385 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
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 56h "check lfs find ! -name ============================="
4398 test_mkdir -p $DIR/$tdir
4399 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4400 CMD="$LFIND -ost $UUID $DIR/$tdir"
4402 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4404 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4408 setup_56_special $NUMFILES $NUMDIRS
4410 EXPECTED=$((NUMDIRS + 1))
4411 CMD="$LFIND -type d $TDIR"
4412 NUMS=$($CMD | wc -l)
4413 [ $NUMS -eq $EXPECTED ] ||
4414 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4416 run_test 56j "check lfs find -type d ============================="
4420 setup_56_special $NUMFILES $NUMDIRS
4422 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4423 CMD="$LFIND -type f $TDIR"
4424 NUMS=$($CMD | wc -l)
4425 [ $NUMS -eq $EXPECTED ] ||
4426 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4428 run_test 56k "check lfs find -type f ============================="
4432 setup_56_special $NUMFILES $NUMDIRS
4434 EXPECTED=$((NUMDIRS + NUMFILES))
4435 CMD="$LFIND -type b $TDIR"
4436 NUMS=$($CMD | wc -l)
4437 [ $NUMS -eq $EXPECTED ] ||
4438 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4440 run_test 56l "check lfs find -type b ============================="
4444 setup_56_special $NUMFILES $NUMDIRS
4446 EXPECTED=$((NUMDIRS + NUMFILES))
4447 CMD="$LFIND -type c $TDIR"
4448 NUMS=$($CMD | wc -l)
4449 [ $NUMS -eq $EXPECTED ] ||
4450 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4452 run_test 56m "check lfs find -type c ============================="
4456 setup_56_special $NUMFILES $NUMDIRS
4458 EXPECTED=$((NUMDIRS + NUMFILES))
4459 CMD="$LFIND -type l $TDIR"
4460 NUMS=$($CMD | wc -l)
4461 [ $NUMS -eq $EXPECTED ] ||
4462 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4464 run_test 56n "check lfs find -type l ============================="
4468 setup_56 $NUMFILES $NUMDIRS
4469 utime $TDIR/file1 > /dev/null || error "utime (1)"
4470 utime $TDIR/file2 > /dev/null || error "utime (2)"
4471 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4472 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4473 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4474 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4477 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4478 [ $NUMS -eq $EXPECTED ] || \
4479 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4482 CMD="$LFIND -mtime 0 $TDIR"
4483 NUMS=$($CMD | wc -l)
4484 [ $NUMS -eq $EXPECTED ] ||
4485 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4487 run_test 56o "check lfs find -mtime for old files =========================="
4490 [ $RUNAS_ID -eq $UID ] &&
4491 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4494 setup_56 $NUMFILES $NUMDIRS
4496 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4498 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4499 NUMS=$($CMD | wc -l)
4500 [ $NUMS -eq $EXPECTED ] || \
4501 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4503 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4504 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4505 NUMS=$($CMD | wc -l)
4506 [ $NUMS -eq $EXPECTED ] || \
4507 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4509 run_test 56p "check lfs find -uid and ! -uid ==============================="
4512 [ $RUNAS_ID -eq $UID ] &&
4513 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4516 setup_56 $NUMFILES $NUMDIRS
4518 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4521 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4522 NUMS=$($CMD | wc -l)
4523 [ $NUMS -eq $EXPECTED ] ||
4524 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4526 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4527 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4528 NUMS=$($CMD | wc -l)
4529 [ $NUMS -eq $EXPECTED ] ||
4530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4532 run_test 56q "check lfs find -gid and ! -gid ==============================="
4536 setup_56 $NUMFILES $NUMDIRS
4539 CMD="$LFIND -size 0 -type f $TDIR"
4540 NUMS=$($CMD | wc -l)
4541 [ $NUMS -eq $EXPECTED ] ||
4542 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4544 CMD="$LFIND ! -size 0 -type f $TDIR"
4545 NUMS=$($CMD | wc -l)
4546 [ $NUMS -eq $EXPECTED ] ||
4547 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4548 echo "test" > $TDIR/$tfile
4549 echo "test2" > $TDIR/$tfile.2 && sync
4551 CMD="$LFIND -size 5 -type f $TDIR"
4552 NUMS=$($CMD | wc -l)
4553 [ $NUMS -eq $EXPECTED ] ||
4554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4556 CMD="$LFIND -size +5 -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"
4566 CMD="$LFIND ! -size -5 -type f $TDIR"
4567 NUMS=$($CMD | wc -l)
4568 [ $NUMS -eq $EXPECTED ] ||
4569 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4571 CMD="$LFIND -size -5 -type f $TDIR"
4572 NUMS=$($CMD | wc -l)
4573 [ $NUMS -eq $EXPECTED ] ||
4574 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4576 run_test 56r "check lfs find -size works =========================="
4578 test_56s() { # LU-611
4580 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4582 if [[ $OSTCOUNT -gt 1 ]]; then
4583 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4587 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4591 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4592 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4593 NUMS=$($CMD | wc -l)
4594 [ $NUMS -eq $EXPECTED ] || {
4596 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4599 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4600 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4601 NUMS=$($CMD | wc -l)
4602 [ $NUMS -eq $EXPECTED ] || {
4604 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4608 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4609 NUMS=$($CMD | wc -l)
4610 [ $NUMS -eq $EXPECTED ] || {
4612 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4615 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4616 NUMS=$($CMD | wc -l)
4617 [ $NUMS -eq $EXPECTED ] || {
4619 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4623 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4624 NUMS=$($CMD | wc -l)
4625 [ $NUMS -eq $EXPECTED ] || {
4627 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4630 run_test 56s "check lfs find -stripe-count works"
4632 test_56t() { # LU-611
4634 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4636 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4638 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4639 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4640 NUMS=$($CMD | wc -l)
4641 [ $NUMS -eq $EXPECTED ] ||
4642 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4644 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4645 NUMS=$($CMD | wc -l)
4646 [ $NUMS -eq $EXPECTED ] ||
4647 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4649 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4650 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4651 NUMS=$($CMD | wc -l)
4652 [ $NUMS -eq $EXPECTED ] ||
4653 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4655 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4656 NUMS=$($CMD | wc -l)
4657 [ $NUMS -eq $EXPECTED ] ||
4658 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4661 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4662 NUMS=$($CMD | wc -l)
4663 [ $NUMS -eq $EXPECTED ] ||
4664 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4666 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4667 NUMS=$($CMD | wc -l)
4668 [ $NUMS -eq $EXPECTED ] ||
4669 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4672 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4673 NUMS=$($CMD | wc -l)
4674 [ $NUMS -eq $EXPECTED ] ||
4675 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4677 run_test 56t "check lfs find -stripe-size works"
4679 test_56u() { # LU-611
4681 setup_56 $NUMFILES $NUMDIRS "-i 0"
4683 if [[ $OSTCOUNT -gt 1 ]]; then
4684 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4690 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4691 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4692 NUMS=$($CMD | wc -l)
4693 [ $NUMS -eq $EXPECTED ] ||
4694 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4697 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4698 NUMS=$($CMD | wc -l)
4699 [ $NUMS -eq $EXPECTED ] ||
4700 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4702 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4703 NUMS=$($CMD | wc -l)
4704 [ $NUMS -eq $EXPECTED ] ||
4705 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4708 # This should produce an error and not return any files
4709 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4710 NUMS=$($CMD 2>/dev/null | wc -l)
4711 [ $NUMS -eq $EXPECTED ] ||
4712 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4714 if [[ $OSTCOUNT -gt 1 ]]; then
4715 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4716 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4717 NUMS=$($CMD | wc -l)
4718 [ $NUMS -eq $EXPECTED ] ||
4719 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4722 run_test 56u "check lfs find -stripe-index works"
4729 setup_56 $NUMFILES $NUMDIRS
4731 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4732 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4734 for file in $($LFIND -mdt $UUID $TDIR); do
4735 file_mdt_idx=$($GETSTRIPE -M $file)
4736 [ $file_mdt_idx -eq $MDT_IDX ] ||
4737 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4740 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4742 # Get and check the actual stripe count of one file.
4743 # Usage: check_stripe_count <file> <expected_stripe_count>
4744 check_stripe_count() {
4749 [[ -z "$file" || -z "$expected" ]] &&
4750 error "check_stripe_count: invalid argument!"
4752 local cmd="$GETSTRIPE -c $file"
4753 actual=$($cmd) || error "$cmd failed"
4754 actual=${actual%% *}
4756 if [[ $actual -ne $expected ]]; then
4757 [[ $expected -eq -1 ]] ||
4758 error "$cmd wrong: found $actual, expected $expected"
4759 [[ $actual -eq $OSTCOUNT ]] ||
4760 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4768 rm -rf $TDIR || error "remove $TDIR failed"
4769 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4772 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4773 error "$GETSTRIPE -S -d $TDIR failed"
4774 stripe_size=${stripe_size%% *}
4776 local file_size=$((stripe_size * OSTCOUNT))
4777 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4778 local required_space=$((file_num * file_size))
4779 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4780 [[ $free_space -le $((required_space / 1024)) ]] &&
4781 skip_env "need at least $required_space bytes free space," \
4782 "have $free_space kbytes" && return
4785 local dd_count=$((file_size / dd_bs))
4787 # write data into the files
4791 for i in $(seq 1 $NUMFILES); do
4793 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4794 error "write data into $file failed"
4796 for i in $(seq 1 $NUMDIRS); do
4797 for j in $(seq 1 $NUMFILES); do
4798 file=$TDIR/dir$i/file$j
4799 yes | dd bs=$dd_bs count=$dd_count of=$file \
4801 error "write data into $file failed"
4806 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4809 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4811 eval $cmd || error "$cmd failed"
4813 check_stripe_count $TDIR/file1 $expected
4816 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4818 eval $cmd || error "$cmd failed"
4820 for j in $(seq 1 $NUMFILES); do
4821 check_stripe_count $TDIR/dir1/file$j $expected
4824 # lfs_migrate works with lfs find
4825 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4826 $LFS_MIGRATE -y -c $expected"
4828 eval $cmd || error "$cmd failed"
4830 for i in $(seq 2 $NUMFILES); do
4831 check_stripe_count $TDIR/file$i $expected
4833 for i in $(seq 2 $NUMDIRS); do
4834 for j in $(seq 1 $NUMFILES); do
4835 check_stripe_count $TDIR/dir$i/file$j $expected
4839 run_test 56w "check lfs_migrate -c stripe_count works"
4842 check_swap_layouts_support && return 0
4843 [[ $OSTCOUNT -lt 2 ]] &&
4844 skip_env "need 2 OST, skipping test" && return
4846 local dir0=$DIR/$tdir/$testnum
4847 mkdir -p $dir0 || error "creating dir $dir0"
4849 local ref1=/etc/passwd
4850 local file1=$dir0/file1
4852 $SETSTRIPE -c 2 $file1
4854 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4855 stripe=$($GETSTRIPE -c $file1)
4856 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4857 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4862 run_test 56x "lfs migration support"
4865 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4866 skip "No HSM support on MDS of $(get_lustre_version)," \
4867 "need 2.4.53 at least" && return
4870 local dir0=$DIR/$tdir/$testnum
4871 mkdir -p $dir0 || error "creating dir $dir0"
4872 local f1=$dir0/file1
4873 local f2=$dir0/file2
4875 touch $f1 || error "creating std file $f1"
4876 $MULTIOP $f2 H2c || error "creating released file $f2"
4878 # a directory can be raid0, so ask only for files
4879 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4880 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4882 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4883 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4885 # only files can be released, so no need to force file search
4886 res=$($LFIND $dir0 -L released)
4887 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4889 res=$($LFIND $dir0 \! -L released)
4890 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4893 run_test 56y "lfs find -L raid0|released"
4895 test_56z() { # LU-4824
4896 # This checks to make sure 'lfs find' continues after errors
4897 # There are two classes of errors that should be caught:
4898 # - If multiple paths are provided, all should be searched even if one
4900 # - If errors are encountered during the search, it should not terminate
4903 test_mkdir $DIR/$tdir
4904 for i in d{0..9}; do
4905 test_mkdir $DIR/$tdir/$i
4907 touch $DIR/$tdir/d{0..9}/$tfile
4908 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4909 error "$LFS find did not return an error"
4910 # Make a directory unsearchable. This should NOT be the last entry in
4911 # directory order. Arbitrarily pick the 6th entry
4912 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
4913 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4914 # The user should be able to see 10 directories and 9 files
4915 [ $count == 19 ] || error "$LFS find did not continue after error"
4917 run_test 56z "lfs find should continue after an error"
4920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4921 # note test will not do anything if MDS is not local
4922 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4923 skip "Only applicable to ldiskfs-based MDTs"
4927 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4928 local MNTDEV="osd*.*MDT*.mntdev"
4929 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4930 [ -z "$DEV" ] && error "can't access $MNTDEV"
4931 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4932 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4933 error "can't access $DEV"
4934 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4935 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4939 run_test 57a "verify MDS filesystem created with large inodes =="
4942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4943 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4944 skip "Only applicable to ldiskfs-based MDTs"
4948 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4953 local FILEN=$dir/f$FILECOUNT
4955 rm -rf $dir || error "removing $dir"
4956 test_mkdir -p $dir || error "creating $dir"
4957 local num=$(get_mds_dir $dir)
4960 echo "mcreating $FILECOUNT files"
4961 createmany -m $dir/f 1 $FILECOUNT || \
4962 error "creating files in $dir"
4964 # verify that files do not have EAs yet
4965 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4966 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4970 df $dir #make sure we get new statfs data
4971 local MDSFREE=$(do_facet $mymds \
4972 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4973 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4974 echo "opening files to create objects/EAs"
4976 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4977 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4980 # verify that files have EAs now
4981 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4982 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4984 sleep 1 #make sure we get new statfs data
4986 local MDSFREE2=$(do_facet $mymds \
4987 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4988 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4989 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
4990 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4991 error "MDC before $MDCFREE != after $MDCFREE2"
4993 echo "MDC before $MDCFREE != after $MDCFREE2"
4994 echo "unable to confirm if MDS has large inodes"
4999 run_test 57b "default LOV EAs are stored inside large inodes ==="
5002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5003 [ -z "$(which wiretest 2>/dev/null)" ] &&
5004 skip_env "could not find wiretest" && return
5007 run_test 58 "verify cross-platform wire constants =============="
5010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5011 echo "touch 130 files"
5012 createmany -o $DIR/f59- 130
5014 unlinkmany $DIR/f59- 130
5016 # wait for commitment of removal
5017 wait_delete_completed
5019 run_test 59 "verify cancellation of llog records async ========="
5021 TEST60_HEAD="test_60 run $RANDOM"
5023 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5024 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5025 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5026 skip_env "missing subtest run-llog.sh" && return
5027 log "$TEST60_HEAD - from kernel mode"
5028 do_facet mgs sh run-llog.sh
5030 run_test 60a "llog sanity tests run from kernel module =========="
5032 test_60b() { # bug 6411
5033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5035 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5047 [[ $LLOG_COUNT -gt 50 ]] &&
5048 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5050 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5054 echo "create 5000 files"
5055 createmany -o $DIR/f60c- 5000
5056 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5057 lctl set_param fail_loc=0x80000137
5058 unlinkmany $DIR/f60c- 5000
5059 lctl set_param fail_loc=0
5061 run_test 60c "unlink file when mds full"
5064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5065 SAVEPRINTK=$(lctl get_param -n printk)
5067 # verify "lctl mark" is even working"
5068 MESSAGE="test message ID $RANDOM $$"
5069 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5070 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5072 lctl set_param printk=0 || error "set lnet.printk failed"
5073 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5074 MESSAGE="new test message ID $RANDOM $$"
5075 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5076 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5077 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5079 lctl set_param -n printk="$SAVEPRINTK"
5081 run_test 60d "test printk console message masking"
5084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5086 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5087 cancel_lru_locks osc
5088 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5091 run_test 61 "mmap() writes don't make sync hang ================"
5093 # bug 2330 - insufficient obd_match error checking causes LBUG
5095 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5098 cancel_lru_locks osc
5099 lctl set_param fail_loc=0x405
5100 cat $f && error "cat succeeded, expect -EIO"
5101 lctl set_param fail_loc=0
5103 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5104 # match every page all of the time.
5105 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5107 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5108 # Though this test is irrelevant anymore, it helped to reveal some
5109 # other grant bugs (LU-4482), let's keep it.
5110 test_63a() { # was test_63
5111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5112 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5113 for i in `seq 10` ; do
5114 dd if=/dev/zero of=$DIR/f63 bs=8k &
5120 rm -f $DIR/f63 || true
5122 run_test 63a "Verify oig_wait interruption does not crash ======="
5124 # bug 2248 - async write errors didn't return to application on sync
5125 # bug 3677 - async write errors left page locked
5127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5129 lctl set_param debug=-1
5131 # ensure we have a grant to do async writes
5132 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5135 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5136 lctl set_param fail_loc=0x80000406
5137 $MULTIOP $DIR/$tfile Owy && \
5138 error "sync didn't return ENOMEM"
5139 sync; sleep 2; sync # do a real sync this time to flush page
5140 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5141 error "locked page left in cache after async error" || true
5144 run_test 63b "async write errors should be returned to fsync ==="
5147 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5149 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5151 run_test 64a "verify filter grant calculations (in kernel) ====="
5154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5155 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5157 run_test 64b "check out-of-space detection on client ==========="
5160 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5162 run_test 64c "verify grant shrink ========================------"
5164 # bug 1414 - set/get directories' stripe info
5166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5167 test_mkdir -p $DIR/$tdir
5169 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5171 run_test 65a "directory with no stripe info ===================="
5174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5175 test_mkdir -p $DIR/$tdir
5176 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5179 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5181 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5185 if [[ $OSTCOUNT -gt 1 ]]; then
5186 test_mkdir -p $DIR/$tdir
5187 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5188 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5190 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5193 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5197 test_mkdir -p $DIR/$tdir
5198 if [[ $STRIPECOUNT -le 0 ]]; then
5200 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5201 #LOV_MAX_STRIPE_COUNT is 2000
5202 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5204 sc=$(($STRIPECOUNT - 1))
5206 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5207 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5208 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5209 error "lverify failed"
5211 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5215 test_mkdir -p $DIR/$tdir
5217 $SETSTRIPE $DIR/$tdir || error "setstripe"
5218 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5219 error "no stripe info failed"
5221 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5223 run_test 65e "directory setstripe defaults ======================="
5226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5227 test_mkdir -p $DIR/${tdir}f
5228 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5230 run_test 65f "dir setstripe permission (should return error) ==="
5233 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5234 test_mkdir -p $DIR/$tdir
5235 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5237 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5238 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5239 error "delete default stripe failed"
5241 run_test 65g "directory setstripe -d ==========================="
5244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5245 test_mkdir -p $DIR/$tdir
5246 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5248 test_mkdir -p $DIR/$tdir/dd1
5249 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5250 error "stripe info inherit failed"
5252 run_test 65h "directory stripe info inherit ===================="
5254 test_65i() { # bug6367
5255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5256 $SETSTRIPE -S 65536 -c -1 $MOUNT
5258 run_test 65i "set non-default striping on root directory (bug 6367)="
5260 test_65ia() { # bug12836
5261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5262 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5264 run_test 65ia "getstripe on -1 default directory striping"
5266 test_65ib() { # bug12836
5267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5268 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5270 run_test 65ib "getstripe -v on -1 default directory striping"
5272 test_65ic() { # bug12836
5273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5274 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5276 run_test 65ic "new find on -1 default directory striping"
5278 test_65j() { # bug6367
5279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5281 # if we aren't already remounting for each test, do so for this test
5282 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5283 cleanup || error "failed to unmount"
5286 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5288 run_test 65j "set default striping on root directory (bug 6367)="
5290 test_65k() { # bug11679
5291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5292 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5293 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5295 echo "Check OST status: "
5296 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5297 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5299 for OSC in $MDS_OSCS; do
5300 echo $OSC "is activate"
5301 do_facet $SINGLEMDS lctl --device %$OSC activate
5305 for INACTIVE_OSC in $MDS_OSCS; do
5306 echo "Deactivate: " $INACTIVE_OSC
5307 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5308 for STRIPE_OSC in $MDS_OSCS; do
5309 OST=`osc_to_ost $STRIPE_OSC`
5310 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5311 awk -F: /$OST/'{ print $1 }' | head -n 1`
5313 [ -f $DIR/$tdir/$IDX ] && continue
5314 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5315 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5317 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5320 echo $INACTIVE_OSC "is Activate."
5321 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5324 run_test 65k "validate manual striping works properly with deactivated OSCs"
5326 test_65l() { # bug 12836
5327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5328 test_mkdir -p $DIR/$tdir/test_dir
5329 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5330 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5332 run_test 65l "lfs find on -1 stripe dir ========================"
5334 # bug 2543 - update blocks count on client
5336 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5338 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5339 sync; sync_all_data; sync; sync_all_data
5340 cancel_lru_locks osc
5341 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5342 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5344 run_test 66 "update inode blocks count on client ==============="
5349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5351 if [ ! -z "$LLOOP" ]; then
5352 if swapon -s | grep -q $LLOOP; then
5353 swapoff $LLOOP || error "swapoff failed"
5356 $LCTL blockdev_detach $LLOOP || error "detach failed"
5360 if [ ! -z "$LLITELOOPLOAD" ]; then
5368 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5372 swapon -s | awk '($1 == "'$1'") { print $4 }'
5375 # test case for lloop driver, basic function
5377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5378 [ "$UID" != 0 ] && skip_env "must run as root" && return
5379 llite_lloop_enabled || \
5380 { skip_env "llite_lloop module disabled" && return; }
5382 trap cleanup_68 EXIT
5384 if ! module_loaded llite_lloop; then
5385 if load_module llite/llite_lloop; then
5388 skip_env "can't find module llite_lloop"
5393 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5394 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5395 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5397 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5398 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5402 run_test 68a "lloop driver - basic test ========================"
5404 # excercise swapping to lustre by adding a high priority swapfile entry
5405 # and then consuming memory until it is used.
5406 test_68b() { # was test_68
5407 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5408 [ "$UID" != 0 ] && skip_env "must run as root" && return
5409 lctl get_param -n devices | grep -q obdfilter && \
5410 skip "local OST" && return
5412 grep -q llite_lloop /proc/modules
5413 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5415 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5416 skip "can't reliably test swap with TCP" && return
5418 MEMTOTAL=`meminfo MemTotal`
5419 NR_BLOCKS=$((MEMTOTAL>>8))
5420 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5422 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5423 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5426 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5428 trap cleanup_68 EXIT
5430 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5432 echo "before: `swapon -s | grep $LLOOP`"
5433 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5434 echo "after: `swapon -s | grep $LLOOP`"
5435 SWAPUSED=`swap_used $LLOOP`
5439 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5441 run_test 68b "support swapping to Lustre ========================"
5443 # bug5265, obdfilter oa2dentry return -ENOENT
5444 # #define OBD_FAIL_OST_ENOENT 0x217
5446 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5447 remote_ost_nodsh && skip "remote OST with nodsh" && return
5450 $SETSTRIPE -c 1 -i 0 $f
5452 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5454 do_facet ost1 lctl set_param fail_loc=0x217
5455 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5456 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5458 do_facet ost1 lctl set_param fail_loc=0
5459 $DIRECTIO write $f 0 2 || error "write error"
5461 cancel_lru_locks osc
5462 $DIRECTIO read $f 0 1 || error "read error"
5464 do_facet ost1 lctl set_param fail_loc=0x217
5465 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5467 do_facet ost1 lctl set_param fail_loc=0
5470 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5473 test_mkdir -p $DIR/$tdir
5474 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5476 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5478 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5479 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5480 [ "$RUNAS_ID" = "$UID" ] &&
5481 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5483 # Check that testing environment is properly set up. Skip if not
5484 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5485 skip_env "User $RUNAS_ID does not exist - skipping"
5489 chmod 777 $DIR/$tfile
5490 chmod ug+s $DIR/$tfile
5491 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5492 error "$RUNAS dd $DIR/$tfile failed"
5493 # See if we are still setuid/sgid
5494 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5495 error "S/gid is not dropped on write"
5496 # Now test that MDS is updated too
5497 cancel_lru_locks mdc
5498 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5499 error "S/gid is not dropped on MDS"
5502 run_test 72a "Test that remove suid works properly (bug5695) ===="
5504 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5507 [ "$RUNAS_ID" = "$UID" ] && \
5508 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5509 [ "$RUNAS_ID" -eq 0 ] && \
5510 skip_env "RUNAS_ID = 0 -- skipping" && return
5512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5513 # Check that testing environment is properly set up. Skip if not
5514 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5515 skip_env "User $RUNAS_ID does not exist - skipping"
5518 touch $DIR/${tfile}-f{g,u}
5519 test_mkdir $DIR/${tfile}-dg
5520 test_mkdir $DIR/${tfile}-du
5521 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5522 chmod g+s $DIR/${tfile}-{f,d}g
5523 chmod u+s $DIR/${tfile}-{f,d}u
5524 for perm in 777 2777 4777; do
5525 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5526 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5527 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5528 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5532 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5534 # bug 3462 - multiple simultaneous MDC requests
5536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5537 test_mkdir $DIR/d73-1
5538 test_mkdir $DIR/d73-2
5539 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5542 lctl set_param fail_loc=0x80000129
5543 $MULTIOP $DIR/d73-1/f73-2 Oc &
5545 lctl set_param fail_loc=0
5547 $MULTIOP $DIR/d73-2/f73-3 Oc &
5551 wait $pid1 || return 1
5555 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5556 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5557 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5561 run_test 73 "multiple MDC requests (should not deadlock)"
5563 test_74a() { # bug 6149, 6184
5564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5565 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5567 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5568 # will spin in a tight reconnection loop
5570 $LCTL set_param fail_loc=0x8000030e
5571 # get any lock that won't be difficult - lookup works.
5573 $LCTL set_param fail_loc=0
5577 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5579 test_74b() { # bug 13310
5580 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5581 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5583 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5584 # will spin in a tight reconnection loop
5585 $LCTL set_param fail_loc=0x8000030e
5586 # get a "difficult" lock
5588 $LCTL set_param fail_loc=0
5592 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5596 #define OBD_FAIL_LDLM_NEW_LOCK
5597 $LCTL set_param fail_loc=0x319
5598 touch $DIR/$tfile && error "touch successful"
5599 $LCTL set_param fail_loc=0
5602 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5605 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5608 get_inode_slab_tunables() {
5609 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5612 set_inode_slab_tunables() {
5613 echo "lustre_inode_cache $1" > /proc/slabinfo
5616 test_76() { # Now for bug 20433, added originally in bug 1443
5617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5618 local SLAB_SETTINGS=`get_inode_slab_tunables`
5619 local CPUS=`getconf _NPROCESSORS_ONLN`
5620 # we cannot set limit below 1 which means 1 inode in each
5621 # per-cpu cache is still allowed
5622 set_inode_slab_tunables "1 1 0"
5623 cancel_lru_locks osc
5624 BEFORE_INODES=$(num_inodes)
5625 echo "before inodes: $BEFORE_INODES"
5627 [ "$SLOW" = "no" ] && COUNT=100
5628 for i in $(seq $COUNT); do
5632 cancel_lru_locks osc
5633 AFTER_INODES=$(num_inodes)
5634 echo "after inodes: $AFTER_INODES"
5636 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5638 AFTER_INODES=$(num_inodes)
5640 echo "wait $wait seconds inodes: $AFTER_INODES"
5641 if [ $wait -gt 30 ]; then
5642 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5645 set_inode_slab_tunables "$SLAB_SETTINGS"
5647 run_test 76 "confirm clients recycle inodes properly ===="
5653 # Note: in sptlrpc modes which enable its own bulk checksum, the
5654 # original crc32_le bulk checksum will be automatically disabled,
5655 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5656 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5657 # In this case set_checksums() will not be no-op, because sptlrpc
5658 # bulk checksum will be enabled all through the test.
5660 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5661 lctl set_param -n osc.*.checksums $1
5665 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5666 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5667 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5668 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5671 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5672 log "set checksum type to $1"
5675 F77_TMP=$TMP/f77-temp
5678 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5679 error "error writing to $F77_TMP"
5682 test_77a() { # bug 10889
5683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5684 $GSS && skip "could not run with gss" && return
5685 [ ! -f $F77_TMP ] && setup_f77
5687 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5691 run_test 77a "normal checksum read/write operation"
5693 test_77b() { # bug 10889
5694 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5695 $GSS && skip "could not run with gss" && return
5696 [ ! -f $F77_TMP ] && setup_f77
5697 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5698 $LCTL set_param fail_loc=0x80000409
5701 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5702 error "dd error: $?"
5703 $LCTL set_param fail_loc=0
5705 for algo in $CKSUM_TYPES; do
5706 cancel_lru_locks osc
5707 set_checksum_type $algo
5708 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5709 $LCTL set_param fail_loc=0x80000408
5710 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5711 $LCTL set_param fail_loc=0
5714 set_checksum_type $ORIG_CSUM_TYPE
5717 run_test 77b "checksum error on client write, read"
5719 test_77d() { # bug 10889
5720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 $GSS && skip "could not run with gss" && return
5722 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5723 $LCTL set_param fail_loc=0x80000409
5725 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5726 error "direct write: rc=$?"
5727 $LCTL set_param fail_loc=0
5730 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5731 $LCTL set_param fail_loc=0x80000408
5733 cancel_lru_locks osc
5734 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5735 error "direct read: rc=$?"
5736 $LCTL set_param fail_loc=0
5739 run_test 77d "checksum error on OST direct write, read"
5741 test_77f() { # bug 10889
5742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5743 $GSS && skip "could not run with gss" && return
5745 for algo in $CKSUM_TYPES; do
5746 cancel_lru_locks osc
5747 set_checksum_type $algo
5748 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5749 $LCTL set_param fail_loc=0x409
5750 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5751 error "direct write succeeded"
5752 $LCTL set_param fail_loc=0
5754 set_checksum_type $ORIG_CSUM_TYPE
5757 run_test 77f "repeat checksum error on write (expect error)"
5759 test_77g() { # bug 10889
5760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5761 $GSS && skip "could not run with gss" && return
5762 remote_ost_nodsh && skip "remote OST with nodsh" && return
5764 [ ! -f $F77_TMP ] && setup_f77
5766 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5767 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5768 do_facet ost1 lctl set_param fail_loc=0x8000021a
5770 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5771 error "write error: rc=$?"
5772 do_facet ost1 lctl set_param fail_loc=0
5775 cancel_lru_locks osc
5776 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5777 do_facet ost1 lctl set_param fail_loc=0x8000021b
5779 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5780 do_facet ost1 lctl set_param fail_loc=0
5783 run_test 77g "checksum error on OST write, read"
5785 test_77i() { # bug 13805
5786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5787 $GSS && skip "could not run with gss" && return
5788 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5789 lctl set_param fail_loc=0x40b
5790 remount_client $MOUNT
5791 lctl set_param fail_loc=0
5792 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5793 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5794 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5795 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5797 remount_client $MOUNT
5799 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5801 test_77j() { # bug 13805
5802 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5803 $GSS && skip "could not run with gss" && return
5804 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5805 lctl set_param fail_loc=0x40c
5806 remount_client $MOUNT
5807 lctl set_param fail_loc=0
5808 sleep 2 # wait async osc connect to finish
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 77j "client only supporting ADLER32"
5818 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5822 test_78() { # bug 10901
5823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5824 remote_ost || { skip_env "local OST" && return; }
5827 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5828 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5829 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5830 echo "MemTotal: $MEMTOTAL"
5832 # reserve 256MB of memory for the kernel and other running processes,
5833 # and then take 1/2 of the remaining memory for the read/write buffers.
5834 if [ $MEMTOTAL -gt 512 ] ;then
5835 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5837 # for those poor memory-starved high-end clusters...
5838 MEMTOTAL=$((MEMTOTAL / 2))
5840 echo "Mem to use for directio: $MEMTOTAL"
5842 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5843 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5844 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5845 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5847 echo "Smallest OST: $SMALLESTOST"
5848 [[ $SMALLESTOST -lt 10240 ]] &&
5849 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5851 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5852 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5854 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5855 echo "File size: $F78SIZE"
5856 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5857 for i in $(seq 1 $NSEQ); do
5858 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5859 echo directIO rdwr round $i of $NSEQ
5860 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5865 run_test 78 "handle large O_DIRECT writes correctly ============"
5867 test_79() { # bug 12743
5868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5869 wait_delete_completed
5871 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5872 BKFREE=$(calc_osc_kbytes kbytesfree)
5873 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5875 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5876 DFTOTAL=`echo $STRING | cut -d, -f1`
5877 DFUSED=`echo $STRING | cut -d, -f2`
5878 DFAVAIL=`echo $STRING | cut -d, -f3`
5879 DFFREE=$(($DFTOTAL - $DFUSED))
5881 ALLOWANCE=$((64 * $OSTCOUNT))
5883 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5884 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5885 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5887 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5888 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5889 error "df free($DFFREE) mismatch OST free($BKFREE)"
5891 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5892 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5893 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5896 run_test 79 "df report consistency check ======================="
5898 test_80() { # bug 10718
5899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5900 # relax strong synchronous semantics for slow backends like ZFS
5901 local soc="obdfilter.*.sync_on_lock_cancel"
5902 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5904 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5905 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5906 facet_active_host $host; done | sort -u)
5907 do_nodes $hosts lctl set_param $soc=never
5910 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5912 local BEFORE=`date +%s`
5913 cancel_lru_locks osc
5914 local AFTER=`date +%s`
5915 local DIFF=$((AFTER-BEFORE))
5916 if [ $DIFF -gt 1 ] ; then
5917 error "elapsed for 1M@1T = $DIFF"
5920 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5924 run_test 80 "Page eviction is equally fast at high offsets too ===="
5926 test_81a() { # LU-456
5927 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5928 remote_ost_nodsh && skip "remote OST with nodsh" && return
5929 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5930 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5931 do_facet ost1 lctl set_param fail_loc=0x80000228
5933 # write should trigger a retry and success
5934 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5935 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5937 if [ $RC -ne 0 ] ; then
5938 error "write should success, but failed for $RC"
5941 run_test 81a "OST should retry write when get -ENOSPC ==============="
5943 test_81b() { # 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 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5948 do_facet ost1 lctl set_param fail_loc=0x228
5950 # write should retry several times and return -ENOSPC finally
5951 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5952 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5955 if [ $RC -ne $ENOSPC ] ; then
5956 error "dd should fail for -ENOSPC, but succeed."
5959 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5961 test_82() { # LU-1031
5962 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5966 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5968 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5970 kill -USR1 $MULTIPID2
5972 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5973 error "First grouplock does not block second one"
5975 echo "Second grouplock blocks first one"
5977 kill -USR1 $MULTIPID1
5981 run_test 82 "Basic grouplock test ==============================="
5984 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5986 test_mkdir -p $DIR/d99cvsroot
5987 chown $RUNAS_ID $DIR/d99cvsroot
5988 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5991 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5994 run_test 99a "cvs init ========================================="
5997 [ -z "$(which cvs 2>/dev/null)" ] &&
5998 skip_env "could not find cvs" && return
5999 [ ! -d $DIR/d99cvsroot ] && test_99a
6001 # some versions of cvs import exit(1) when asked to import links or
6002 # files they can't read. ignore those files.
6003 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6004 ! -perm +4 -printf '-I %f\n')
6005 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6006 d99reposname vtag rtag
6008 run_test 99b "cvs import ======================================="
6011 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6012 [ ! -d $DIR/d99cvsroot ] && test_99b
6014 test_mkdir -p $DIR/d99reposname
6015 chown $RUNAS_ID $DIR/d99reposname
6016 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6018 run_test 99c "cvs checkout ====================================="
6021 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6022 [ ! -d $DIR/d99cvsroot ] && test_99c
6023 cd $DIR/d99reposname
6025 $RUNAS cvs add -m 'addmsg' foo99
6027 run_test 99d "cvs add =========================================="
6030 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6031 [ ! -d $DIR/d99cvsroot ] && test_99c
6032 cd $DIR/d99reposname
6035 run_test 99e "cvs update ======================================="
6038 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6039 [ ! -d $DIR/d99cvsroot ] && test_99d
6040 cd $DIR/d99reposname
6041 $RUNAS cvs commit -m 'nomsg' foo99
6042 rm -fr $DIR/d99cvsroot
6044 run_test 99f "cvs commit ======================================="
6047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6048 [ "$NETTYPE" = tcp ] || \
6049 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6052 remote_ost_nodsh && skip "remote OST with nodsh" && return
6053 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6055 { skip "useless for local single node setup" && return; }
6057 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6058 [ "$PROT" != "tcp" ] && continue
6059 RPORT=$(echo $REMOTE | cut -d: -f2)
6060 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6063 LPORT=`echo $LOCAL | cut -d: -f2`
6064 if [ $LPORT -ge 1024 ]; then
6065 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6067 error_exit "local: $LPORT > 1024, remote: $RPORT"
6070 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6072 run_test 100 "check local port using privileged port ==========="
6074 function get_named_value()
6083 echo $line | sed "s/^$tag[ ]*//"
6090 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6091 awk '/^max_cached_mb/ { print $2 }')
6094 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6100 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6104 local cache_limit=32
6106 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6107 trap cleanup_101a EXIT
6108 $LCTL set_param -n llite.*.read_ahead_stats 0
6109 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6112 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6114 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6115 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6118 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6119 get_named_value 'read but discarded' | cut -d" " -f1); do
6120 discard=$(($discard + $s))
6124 if [[ $(($discard * 10)) -gt $nreads ]]; then
6125 $LCTL get_param osc.*-osc*.rpc_stats
6126 $LCTL get_param llite.*.read_ahead_stats
6127 error "too many ($discard) discarded pages"
6129 rm -f $DIR/$tfile || true
6131 run_test 101a "check read-ahead for random reads ================"
6134 test_mkdir -p $DIR/$tdir
6135 local STRIPE_SIZE=$1
6136 local FILE_LENGTH=$2
6139 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6141 local list=$(comma_list $(osts_nodes))
6142 set_osd_param $list '' read_cache_enable 0
6143 set_osd_param $list '' writethrough_cache_enable 0
6145 trap cleanup_test101bc EXIT
6146 # prepare the read-ahead file
6147 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6149 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6150 count=$FILE_SIZE_MB 2> /dev/null
6154 cleanup_test101bc() {
6159 local list=$(comma_list $(osts_nodes))
6160 set_osd_param $list '' read_cache_enable 1
6161 set_osd_param $list '' writethrough_cache_enable 1
6165 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6170 local STRIPE_SIZE=$2
6171 local FILE_LENGTH=$3
6172 local RA_INC=1048576
6173 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6174 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6175 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6176 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6177 get_named_value 'read but discarded' |
6178 cut -d" " -f1 | calc_total)
6179 if [[ $DISCARD -gt $discard_limit ]]; then
6180 $LCTL get_param llite.*.read_ahead_stats
6181 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6183 echo "Read-ahead success for size ${READ_SIZE}"
6188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6189 [[ $OSTCOUNT -lt 2 ]] &&
6190 skip_env "skipping stride IO stride-ahead test" && return
6191 local STRIPE_SIZE=1048576
6192 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6193 if [ $SLOW == "yes" ]; then
6194 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6196 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6199 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6201 # prepare the read-ahead file
6202 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6203 cancel_lru_locks osc
6204 for BIDX in 2 4 8 16 32 64 128 256
6206 local BSIZE=$((BIDX*4096))
6207 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6208 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6209 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6210 $LCTL set_param -n llite.*.read_ahead_stats 0
6211 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6212 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6213 cancel_lru_locks osc
6214 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6219 run_test 101b "check stride-io mode read-ahead ================="
6222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6223 local STRIPE_SIZE=1048576
6224 local FILE_LENGTH=$((STRIPE_SIZE*100))
6228 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6230 cancel_lru_locks osc
6231 $LCTL set_param osc.*.rpc_stats 0
6232 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6233 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6234 local stats=$($LCTL get_param -n $osc_rpc_stats)
6235 local lines=$(echo "$stats" | awk 'END {print NR;}')
6238 if [ $lines -le 20 ]; then
6241 for size in 1 2 4 8; do
6242 local rpc=$(echo "$stats" |
6243 awk '($1 == "'$size':") {print $2; exit; }')
6245 error "Small $((size*4))k read IO $rpc !"
6247 echo "$osc_rpc_stats check passed!"
6252 run_test 101c "check stripe_size aligned read-ahead ================="
6255 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6256 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6261 local file=$DIR/$tfile
6262 local sz_MB=${FILESIZE_101d:-500}
6263 local ra_MB=${READAHEAD_MB:-40}
6265 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6266 [ $free_MB -lt $sz_MB ] &&
6267 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6269 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6270 $SETSTRIPE -c -1 $file || error "setstripe failed"
6272 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6273 echo Cancel LRU locks on lustre client to flush the client cache
6274 cancel_lru_locks osc
6276 echo Disable read-ahead
6277 local old_READAHEAD=$(set_read_ahead 0)
6279 echo Reading the test file $file with read-ahead disabled
6280 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6282 echo Cancel LRU locks on lustre client to flush the client cache
6283 cancel_lru_locks osc
6284 echo Enable read-ahead with ${ra_MB}MB
6285 set_read_ahead $ra_MB
6287 echo Reading the test file $file with read-ahead enabled
6288 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6290 echo "read-ahead disabled time read $raOFF"
6291 echo "read-ahead enabled time read $raON"
6293 set_read_ahead $old_READAHEAD
6295 wait_delete_completed
6297 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6298 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6300 run_test 101d "file read with and without read-ahead enabled"
6303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6304 local file=$DIR/$tfile
6305 local size_KB=500 #KB
6309 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6310 local need_KB=$((count * size_KB))
6311 [[ $free_KB -le $need_KB ]] &&
6312 skip_env "Need free space $need_KB, have $free_KB" && return
6314 echo "Creating $count ${size_KB}K test files"
6315 for ((i = 0; i < $count; i++)); do
6316 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6319 echo "Cancel LRU locks on lustre client to flush the client cache"
6320 cancel_lru_locks osc
6322 echo "Reset readahead stats"
6323 $LCTL set_param -n llite.*.read_ahead_stats 0
6325 for ((i = 0; i < $count; i++)); do
6326 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6329 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6330 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6332 for ((i = 0; i < $count; i++)); do
6333 rm -rf $file.$i 2>/dev/null
6336 #10000 means 20% reads are missing in readahead
6337 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6339 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6341 cleanup_test101f() {
6343 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6344 rm -rf $DIR/$tfile 2>/dev/null
6348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6349 local file=$DIR/$tfile
6352 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6353 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6354 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6355 trap cleanup_test101f EXIT
6357 echo Cancel LRU locks on lustre client to flush the client cache
6358 cancel_lru_locks osc
6360 echo Reset readahead stats
6361 $LCTL set_param -n llite.*.read_ahead_stats 0
6362 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6363 # readahead should read in 2M file on second read, so only miss
6365 echo Random 4K reads on 2M file for 1000 times
6366 $READS -f $file -s 2097152 -b 4096 -n $nreads
6368 echo checking missing pages
6369 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6370 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6372 [ $miss -lt 3 ] || error "misses too much pages!"
6375 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6378 test_mkdir -p $DIR/$tdir
6379 chown $RUNAS_ID $DIR/$tdir
6382 STRIPE_COUNT=$OSTCOUNT
6383 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6385 trap cleanup_test102 EXIT
6387 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6389 for num in 1 2 3 4; do
6390 for count in $(seq 1 $STRIPE_COUNT); do
6391 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6392 local size=`expr $STRIPE_SIZE \* $num`
6393 local file=file"$num-$idx-$count"
6394 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6400 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6406 rm -rf $DIR/d0.sanity/d102
6410 local testfile=$DIR/$tfile
6414 [ "$UID" != 0 ] && skip_env "must run as root" && return
6415 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6416 skip_env "must have user_xattr" && return
6418 [ -z "$(which setfattr 2>/dev/null)" ] &&
6419 skip_env "could not find setfattr" && return
6421 echo "set/get xattr..."
6422 setfattr -n trusted.name1 -v value1 $testfile ||
6423 error "setfattr -n trusted.name1=value1 $testfile failed"
6424 getfattr -n trusted.name1 $testfile 2> /dev/null |
6425 grep "trusted.name1=.value1" ||
6426 error "$testfile missing trusted.name1=value1"
6428 setfattr -n user.author1 -v author1 $testfile ||
6429 error "setfattr -n user.author1=author1 $testfile failed"
6430 getfattr -n user.author1 $testfile 2> /dev/null |
6431 grep "user.author1=.author1" ||
6432 error "$testfile missing trusted.author1=author1"
6435 setfattr -n trusted.name2 -v value2 $testfile ||
6436 error "$testfile unable to set trusted.name2"
6437 setfattr -n trusted.name3 -v value3 $testfile ||
6438 error "$testfile unable to set trusted.name3"
6439 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6440 grep "trusted.name" | wc -l) -eq 3 ] ||
6441 error "$testfile missing 3 trusted.name xattrs"
6443 setfattr -n user.author2 -v author2 $testfile ||
6444 error "$testfile unable to set user.author2"
6445 setfattr -n user.author3 -v author3 $testfile ||
6446 error "$testfile unable to set user.author3"
6447 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6448 grep "user.author" | wc -l) -eq 3 ] ||
6449 error "$testfile missing 3 user.author xattrs"
6451 echo "remove xattr..."
6452 setfattr -x trusted.name1 $testfile ||
6453 error "$testfile error deleting trusted.name1"
6454 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6455 error "$testfile did not delete trusted.name1 xattr"
6457 setfattr -x user.author1 $testfile ||
6458 error "$testfile error deleting user.author1"
6459 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6460 error "$testfile did not delete trusted.name1 xattr"
6462 # b10667: setting lustre special xattr be silently discarded
6463 echo "set lustre special xattr ..."
6464 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6465 error "$testfile allowed setting trusted.lov"
6467 run_test 102a "user xattr test =================================="
6470 [ -z "$(which setfattr 2>/dev/null)" ] &&
6471 skip_env "could not find setfattr" && return
6473 # b10930: get/set/list trusted.lov xattr
6474 echo "get/set/list trusted.lov xattr ..."
6475 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6476 local testfile=$DIR/$tfile
6477 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6478 error "setstripe failed"
6479 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6480 error "getstripe failed"
6481 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6482 error "can't get trusted.lov from $testfile"
6484 local testfile2=${testfile}2
6485 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6486 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6489 setfattr -n trusted.lov -v $value $testfile2
6490 local stripe_size=$($GETSTRIPE -S $testfile2)
6491 local stripe_count=$($GETSTRIPE -c $testfile2)
6492 [[ $stripe_size -eq 65536 ]] ||
6493 error "stripe size $stripe_size != 65536"
6494 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6495 error "stripe count $stripe_count != $STRIPECOUNT"
6498 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6501 [ -z "$(which setfattr 2>/dev/null)" ] &&
6502 skip_env "could not find setfattr" && return
6504 # b10930: get/set/list lustre.lov xattr
6505 echo "get/set/list lustre.lov xattr ..."
6506 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6507 test_mkdir -p $DIR/$tdir
6508 chown $RUNAS_ID $DIR/$tdir
6509 local testfile=$DIR/$tdir/$tfile
6510 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6511 error "setstripe failed"
6512 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6513 error "getstripe failed"
6514 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6515 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6517 local testfile2=${testfile}2
6518 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6519 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6521 $RUNAS $MCREATE $testfile2
6522 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6523 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6524 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6525 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6526 [ $stripe_count -eq $STRIPECOUNT ] ||
6527 error "stripe count $stripe_count != $STRIPECOUNT"
6529 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6531 compare_stripe_info1() {
6532 local stripe_index_all_zero=true
6534 for num in 1 2 3 4; do
6535 for count in $(seq 1 $STRIPE_COUNT); do
6536 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6537 local size=$((STRIPE_SIZE * num))
6538 local file=file"$num-$offset-$count"
6539 stripe_size=$(lfs getstripe -S $PWD/$file)
6540 [[ $stripe_size -ne $size ]] &&
6541 error "$file: size $stripe_size != $size"
6542 stripe_count=$(lfs getstripe -c $PWD/$file)
6543 # allow fewer stripes to be created, ORI-601
6544 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6545 error "$file: count $stripe_count != $count"
6546 stripe_index=$(lfs getstripe -i $PWD/$file)
6547 [[ $stripe_index -ne 0 ]] &&
6548 stripe_index_all_zero=false
6552 $stripe_index_all_zero &&
6553 error "all files are being extracted starting from OST index 0"
6558 [ -n "$(which tar 2>/dev/null)" ] &&
6559 strings $(which tar) | grep -q "lustre" && echo tar
6563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6564 # b10930: tar test for trusted.lov xattr
6565 TAR=$(find_lustre_tar)
6566 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6567 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6569 test_mkdir -p $DIR/d102d
6570 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6572 compare_stripe_info1
6574 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6578 # b10930: tar test for trusted.lov xattr
6579 TAR=$(find_lustre_tar)
6580 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6581 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6583 test_mkdir -p $DIR/d102f
6585 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6587 compare_stripe_info1
6589 run_test 102f "tar copy files, not keep osts ==========="
6592 local xsize=${1:-1024} # in bytes
6593 local file=$DIR/$tfile
6595 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6596 skip "must have user_xattr" && return 0
6597 [ -z "$(which setfattr 2>/dev/null)" ] &&
6598 skip_env "could not find setfattr" && return 0
6599 [ -z "$(which getfattr 2>/dev/null)" ] &&
6600 skip_env "could not find getfattr" && return 0
6604 local value="$(generate_string $xsize)"
6606 local xbig=trusted.big
6607 log "save $xbig on $file"
6608 setfattr -n $xbig -v $value $file ||
6609 error "saving $xbig on $file failed"
6611 local orig=$(get_xattr_value $xbig $file)
6612 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6614 local xsml=trusted.sml
6615 log "save $xsml on $file"
6616 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6618 local new=$(get_xattr_value $xbig $file)
6619 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6621 log "grow $xsml on $file"
6622 setfattr -n $xsml -v "$value" $file ||
6623 error "growing $xsml on $file failed"
6625 new=$(get_xattr_value $xbig $file)
6626 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6627 log "$xbig still valid after growing $xsml"
6632 test_102h() { # bug 15777
6635 run_test 102h "grow xattr from inside inode to external block"
6638 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6639 grow_xattr $(max_xattr_size)
6641 run_test 102ha "grow xattr from inside inode to external inode"
6643 test_102i() { # bug 17038
6644 [ -z "$(which getfattr 2>/dev/null)" ] &&
6645 skip "could not find getfattr" && return
6647 ln -s $DIR/$tfile $DIR/${tfile}link
6648 getfattr -n trusted.lov $DIR/$tfile ||
6649 error "lgetxattr on $DIR/$tfile failed"
6650 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6651 grep -i "no such attr" ||
6652 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6653 rm -f $DIR/$tfile $DIR/${tfile}link
6655 run_test 102i "lgetxattr test on symbolic link ============"
6658 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6659 TAR=$(find_lustre_tar)
6660 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6661 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6662 setup_test102 "$RUNAS"
6663 test_mkdir -p $DIR/d102j
6664 chown $RUNAS_ID $DIR/d102j
6665 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6667 compare_stripe_info1 "$RUNAS"
6669 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6672 [ -z "$(which setfattr 2>/dev/null)" ] &&
6673 skip "could not find setfattr" && return
6675 # b22187 just check that does not crash for regular file.
6676 setfattr -n trusted.lov $DIR/$tfile
6677 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6678 local test_kdir=$DIR/d102k
6679 test_mkdir $test_kdir
6680 local default_size=`$GETSTRIPE -S $test_kdir`
6681 local default_count=`$GETSTRIPE -c $test_kdir`
6682 local default_offset=`$GETSTRIPE -i $test_kdir`
6683 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6684 error 'dir setstripe failed'
6685 setfattr -n trusted.lov $test_kdir
6686 local stripe_size=`$GETSTRIPE -S $test_kdir`
6687 local stripe_count=`$GETSTRIPE -c $test_kdir`
6688 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6689 [ $stripe_size -eq $default_size ] ||
6690 error "stripe size $stripe_size != $default_size"
6691 [ $stripe_count -eq $default_count ] ||
6692 error "stripe count $stripe_count != $default_count"
6693 [ $stripe_offset -eq $default_offset ] ||
6694 error "stripe offset $stripe_offset != $default_offset"
6695 rm -rf $DIR/$tfile $test_kdir
6697 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6700 [ -z "$(which getfattr 2>/dev/null)" ] &&
6701 skip "could not find getfattr" && return
6703 # LU-532 trusted. xattr is invisible to non-root
6704 local testfile=$DIR/$tfile
6708 echo "listxattr as user..."
6709 chown $RUNAS_ID $testfile
6710 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6711 grep -q "trusted" &&
6712 error "$testfile trusted xattrs are user visible"
6716 run_test 102l "listxattr size test =================================="
6718 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6719 local path=$DIR/$tfile
6722 listxattr_size_check $path || error "listattr_size_check $path failed"
6724 run_test 102m "Ensure listxattr fails on small bufffer ========"
6728 getxattr() { # getxattr path name
6729 # Return the base64 encoding of the value of xattr name on path.
6733 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6735 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6737 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6739 getfattr --absolute-names --encoding=base64 --name=$name $path |
6740 awk -F= -v name=$name '$1 == name {
6741 print substr($0, index($0, "=") + 1);
6745 test_102n() { # LU-4101 mdt: protect internal xattrs
6746 local file0=$DIR/$tfile.0
6747 local file1=$DIR/$tfile.1
6748 local xattr0=$TMP/$tfile.0
6749 local xattr1=$TMP/$tfile.1
6753 [ -z "$(which setfattr 2>/dev/null)" ] &&
6754 skip "could not find setfattr" && return
6756 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6758 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6762 rm -rf $file0 $file1 $xattr0 $xattr1
6765 # Get 'before' xattrs of $file1.
6766 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6768 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6769 # Try to copy xattr from $file0 to $file1.
6770 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6772 setfattr --name=trusted.$name --value="$value" $file1 ||
6773 error "setxattr 'trusted.$name' failed"
6775 # Try to set a garbage xattr.
6776 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6778 setfattr --name=trusted.$name --value="$value" $file1 ||
6779 error "setxattr 'trusted.$name' failed"
6781 # Try to remove the xattr from $file1. We don't care if this
6782 # appears to succeed or fail, we just don't want there to be
6783 # any changes or crashes.
6784 setfattr --remove=$trusted.$name $file1 2> /dev/null
6787 # Get 'after' xattrs of file1.
6788 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6790 if ! diff $xattr0 $xattr1; then
6791 error "before and after xattrs of '$file1' differ"
6794 rm -rf $file0 $file1 $xattr0 $xattr1
6798 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6800 test_102p() { # LU-4703 setxattr did not check ownership
6801 local testfile=$DIR/$tfile
6803 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6804 skip "MDS needs to be at least 2.5.56" && return
6808 echo "setfacl as user..."
6809 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6810 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6812 echo "setfattr as user..."
6813 setfacl -m "u:$RUNAS_ID:---" $testfile
6814 $RUNAS setfattr -x system.posix_acl_access $testfile
6815 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6817 run_test 102p "check setxattr(2) correctly fails without permission"
6821 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6826 [ "$UID" != 0 ] && skip_env "must run as root" && return
6827 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6828 skip "must have acl enabled" && return
6829 [ -z "$(which setfacl 2>/dev/null)" ] &&
6830 skip_env "could not find setfacl" && return
6831 $GSS && skip "could not run under gss" && return
6833 declare -a identity_old
6835 for num in $(seq $MDSCOUNT); do
6836 switch_identity $num true || identity_old[$num]=$?
6843 echo "performing cp ..."
6844 run_acl_subtest cp || error "run_acl_subtest cp failed"
6845 echo "performing getfacl-noacl..."
6846 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6847 echo "performing misc..."
6848 run_acl_subtest misc || error "misc test failed"
6849 echo "performing permissions..."
6850 run_acl_subtest permissions || error "permissions failed"
6851 echo "performing setfacl..."
6852 run_acl_subtest setfacl || error "setfacl test failed"
6854 # inheritance test got from HP
6855 echo "performing inheritance..."
6856 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6857 chmod +x make-tree || error "chmod +x failed"
6858 run_acl_subtest inheritance || error "inheritance test failed"
6861 echo "LU-974 ignore umask when acl is enabled..."
6862 run_acl_subtest 974 || error "LU-974 umask test failed"
6863 if [ $MDSCOUNT -ge 2 ]; then
6864 run_acl_subtest 974_remote ||
6865 error "LU-974 umask test failed under remote dir"
6868 echo "LU-2561 newly created file is same size as directory..."
6869 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6870 run_acl_subtest 2561 || error "LU-2561 test failed"
6872 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6875 run_acl_subtest 4924 || error "LU-4924 test failed"
6880 for num in $(seq $MDSCOUNT); do
6881 if [ "${identity_old[$num]}" = 1 ]; then
6882 switch_identity $num false || identity_old[$num]=$?
6886 run_test 103a "acl test ========================================="
6890 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
6891 local mountopts=$MDS_MOUNT_OPTS
6893 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
6897 stop $SINGLEMDS || error "failed to stop MDT."
6899 if [ -z "$MDS_MOUNT_OPTS" ]; then
6900 MDS_MOUNT_OPTS="-o noacl"
6902 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
6904 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6905 error "failed to start MDT."
6906 MDS_MOUNT_OPTS=$mountopts
6910 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
6914 stop $SINGLEMDS || error "failed to stop MDT."
6916 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6917 error "failed to start MDT."
6922 run_test 103b "MDS mount option 'noacl'"
6926 cp -rp $DIR/$tdir $DIR/$tdir.bak
6928 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
6929 error "$DIR/$tdir shouldn't contain default ACL"
6930 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
6931 error "$DIR/$tdir.bak shouldn't contain default ACL"
6934 run_test 103c "'cp -rp' won't set empty acl"
6937 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6939 lfs df || error "lfs df failed"
6940 lfs df -ih || error "lfs df -ih failed"
6941 lfs df -h $DIR || error "lfs df -h $DIR failed"
6942 lfs df -i $DIR || error "lfs df -i $DIR failed"
6943 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6944 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6946 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6947 lctl --device %$OSC deactivate
6948 lfs df || error "lfs df with deactivated OSC failed"
6949 lctl --device %$OSC activate
6950 # wait the osc back to normal
6951 wait_osc_import_state client ost FULL
6953 lfs df || error "lfs df with reactivated OSC failed"
6956 run_test 104a "lfs df [-ih] [path] test ========================="
6959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6960 [ $RUNAS_ID -eq $UID ] &&
6961 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6963 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6964 grep "Permission denied" | wc -l)))
6965 if [ $denied_cnt -ne 0 ]; then
6966 error "lfs check servers test failed"
6969 run_test 104b "$RUNAS lfs check servers test ===================="
6972 # doesn't work on 2.4 kernels
6974 if $(flock_is_enabled); then
6975 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6977 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6981 run_test 105a "flock when mounted without -o flock test ========"
6985 if $(flock_is_enabled); then
6986 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6988 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6992 run_test 105b "fcntl when mounted without -o flock test ========"
6996 if $(flock_is_enabled); then
6997 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6999 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7003 run_test 105c "lockf when mounted without -o flock test ========"
7005 test_105d() { # bug 15924
7006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7007 test_mkdir -p $DIR/$tdir
7008 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7009 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7010 $LCTL set_param fail_loc=0x80000315
7011 flocks_test 2 $DIR/$tdir
7013 run_test 105d "flock race (should not freeze) ========"
7015 test_105e() { # bug 22660 && 22040
7016 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7018 flocks_test 3 $DIR/$tfile
7020 run_test 105e "Two conflicting flocks from same process ======="
7022 test_106() { #bug 10921
7023 test_mkdir -p $DIR/$tdir
7024 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7025 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7027 run_test 106 "attempt exec of dir followed by chown of that dir"
7030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7037 local save_pattern=$(sysctl -n kernel.core_pattern)
7038 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7039 sysctl -w kernel.core_pattern=$file
7040 sysctl -w kernel.core_uses_pid=0
7048 kill -s 11 $SLEEPPID
7050 if [ -e $file ]; then
7051 size=`stat -c%s $file`
7052 [ $size -eq 0 ] && error "Fail to create core file $file"
7054 error "Fail to create core file $file"
7057 sysctl -w kernel.core_pattern=$save_pattern
7058 sysctl -w kernel.core_uses_pid=$save_uses_pid
7061 run_test 107 "Coredump on SIG"
7064 test_mkdir -p $DIR/$tdir
7065 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7066 error "mkdir with 255 char failed"
7067 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7068 error "mkdir with 256 char should fail, but did not"
7069 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7070 error "create with 255 char failed"
7071 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7072 error "create with 256 char should fail, but did not"
7077 run_test 110 "filename length checking"
7080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7081 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7082 tail -1 | cut -c11-20)
7083 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7084 echo "Starting with $OSTIO_pre threads"
7087 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7088 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7089 echo "$NUMTEST creates/unlinks"
7090 test_mkdir -p $DIR/$tdir
7091 createmany -o $DIR/$tdir/$tfile $NUMTEST
7092 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7094 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7095 tail -1 | cut -c11-20)
7097 # don't return an error
7098 [ $OSTIO_post == $OSTIO_pre ] && echo \
7099 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7100 echo "This may be fine, depending on what ran before this test" &&
7101 echo "and how fast this system is." && return
7103 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7105 run_test 115 "verify dynamic thread creation===================="
7108 wait_delete_completed
7109 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7110 echo OST kbytes available: ${AVAIL[@]}
7111 MAXI=0; MAXV=${AVAIL[0]}
7112 MINI=0; MINV=${AVAIL[0]}
7113 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7114 #echo OST $i: ${AVAIL[i]}kb
7115 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7116 MAXV=${AVAIL[i]}; MAXI=$i
7118 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7119 MINV=${AVAIL[i]}; MINI=$i
7122 echo Min free space: OST $MINI: $MINV
7123 echo Max free space: OST $MAXI: $MAXV
7126 test_116a() { # was previously test_116()
7127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7128 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7130 echo -n "Free space priority "
7131 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7136 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7137 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7139 trap simple_cleanup_common EXIT
7142 # Check if we need to generate uneven OSTs
7143 test_mkdir -p $DIR/$tdir/OST${MINI}
7144 local FILL=$(($MINV / 4))
7145 local DIFF=$(($MAXV - $MINV))
7146 local DIFF2=$(($DIFF * 100 / $MINV))
7148 local threshold=$(do_facet $SINGLEMDS \
7149 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7150 threshold=${threshold%%%}
7151 echo -n "Check for uneven OSTs: "
7152 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7154 if [[ $DIFF2 -gt $threshold ]]; then
7156 echo "Don't need to fill OST$MINI"
7158 # generate uneven OSTs. Write 2% over the QOS threshold value
7160 DIFF=$(($threshold - $DIFF2 + 2))
7161 DIFF2=$(( ($MINV * $DIFF)/100 ))
7162 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7163 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7164 error "setstripe failed"
7165 DIFF=$(($DIFF2 / 2048))
7167 while [ $i -lt $DIFF ]; do
7169 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7170 bs=2M count=1 2>/dev/null
7179 DIFF=$(($MAXV - $MINV))
7180 DIFF2=$(($DIFF * 100 / $MINV))
7181 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7182 if [[ $DIFF2 -gt $threshold ]]; then
7185 echo "failed - QOS mode won't be used"
7186 skip "QOS imbalance criteria not met"
7187 simple_cleanup_common
7191 MINI1=$MINI; MINV1=$MINV
7192 MAXI1=$MAXI; MAXV1=$MAXV
7194 # now fill using QOS
7195 $SETSTRIPE -c 1 $DIR/$tdir
7196 FILL=$(($FILL / 200))
7197 if [ $FILL -gt 600 ]; then
7200 echo "writing $FILL files to QOS-assigned OSTs"
7202 while [ $i -lt $FILL ]; do
7204 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7208 echo "wrote $i 200k files"
7212 echo "Note: free space may not be updated, so measurements might be off"
7214 DIFF2=$(($MAXV - $MINV))
7215 echo "free space delta: orig $DIFF final $DIFF2"
7216 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7217 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7218 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7219 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7220 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7221 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7223 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7225 # Figure out which files were written where
7226 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7227 awk '/'$MINI1': / {print $2; exit}')
7229 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7230 echo "$MINC files created on smaller OST $MINI1"
7231 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7232 awk '/'$MAXI1': / {print $2; exit}')
7234 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7235 echo "$MAXC files created on larger OST $MAXI1"
7236 FILL=$(($MAXC * 100 / $MINC - 100))
7237 [[ $MINC -gt 0 ]] &&
7238 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7239 [[ $MAXC -gt $MINC ]] ||
7240 error_ignore LU-9 "stripe QOS didn't balance free space"
7241 simple_cleanup_common
7243 run_test 116a "stripe QOS: free space balance ==================="
7245 test_116b() { # LU-2093
7246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7247 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7248 head -1 2>/dev/null)" ] && skip "no QOS" && return
7249 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7251 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7252 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7253 do_facet $SINGLEMDS lctl set_param \
7254 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7256 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7257 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7258 do_facet $SINGLEMDS lctl set_param fail_loc=0
7260 do_facet $SINGLEMDS lctl set_param \
7261 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7263 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7265 test_117() # bug 10891
7267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7268 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7269 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7270 lctl set_param fail_loc=0x21e
7271 > $DIR/$tfile || error "truncate failed"
7272 lctl set_param fail_loc=0
7273 echo "Truncate succeeded."
7276 run_test 117 "verify osd extend =========="
7278 NO_SLOW_RESENDCOUNT=4
7279 export OLD_RESENDCOUNT=""
7280 set_resend_count () {
7281 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7282 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7283 lctl set_param -n $PROC_RESENDCOUNT $1
7284 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7287 # for reduce test_118* time (b=14842)
7288 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7290 # Reset async IO behavior after error case
7292 FILE=$DIR/reset_async
7294 # Ensure all OSCs are cleared
7295 $SETSTRIPE -c -1 $FILE
7296 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7301 test_118a() #bug 11710
7303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7306 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7307 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7308 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7310 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7311 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7316 run_test 118a "verify O_SYNC works =========="
7320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7321 remote_ost_nodsh && skip "remote OST with nodsh" && return
7325 #define OBD_FAIL_OST_ENOENT 0x217
7326 set_nodes_failloc "$(osts_nodes)" 0x217
7327 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7329 set_nodes_failloc "$(osts_nodes)" 0
7330 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7331 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7334 if [[ $RC -eq 0 ]]; then
7335 error "Must return error due to dropped pages, rc=$RC"
7339 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7340 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7344 echo "Dirty pages not leaked on ENOENT"
7346 # Due to the above error the OSC will issue all RPCs syncronously
7347 # until a subsequent RPC completes successfully without error.
7348 $MULTIOP $DIR/$tfile Ow4096yc
7353 run_test 118b "Reclaim dirty pages on fatal error =========="
7357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7359 # for 118c, restore the original resend count, LU-1940
7360 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7361 set_resend_count $OLD_RESENDCOUNT
7362 remote_ost_nodsh && skip "remote OST with nodsh" && return
7366 #define OBD_FAIL_OST_EROFS 0x216
7367 set_nodes_failloc "$(osts_nodes)" 0x216
7369 # multiop should block due to fsync until pages are written
7370 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7374 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7375 error "Multiop failed to block on fsync, pid=$MULTIPID"
7378 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7380 if [[ $WRITEBACK -eq 0 ]]; then
7381 error "No page in writeback, writeback=$WRITEBACK"
7384 set_nodes_failloc "$(osts_nodes)" 0
7387 if [[ $RC -ne 0 ]]; then
7388 error "Multiop fsync failed, rc=$RC"
7391 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7392 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7394 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7395 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7399 echo "Dirty pages flushed via fsync on EROFS"
7402 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7404 # continue to use small resend count to reduce test_118* time (b=14842)
7405 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7410 remote_ost_nodsh && skip "remote OST with nodsh" && return
7414 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7415 set_nodes_failloc "$(osts_nodes)" 0x214
7416 # multiop should block due to fsync until pages are written
7417 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7421 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7422 error "Multiop failed to block on fsync, pid=$MULTIPID"
7425 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7427 if [[ $WRITEBACK -eq 0 ]]; then
7428 error "No page in writeback, writeback=$WRITEBACK"
7431 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7432 set_nodes_failloc "$(osts_nodes)" 0
7434 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7435 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7437 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7438 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7442 echo "Dirty pages gaurenteed flushed via fsync"
7445 run_test 118d "Fsync validation inject a delay of the bulk =========="
7448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7451 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7452 lctl set_param fail_loc=0x8000040a
7454 # Should simulate EINVAL error which is fatal
7455 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7457 if [[ $RC -eq 0 ]]; then
7458 error "Must return error due to dropped pages, rc=$RC"
7461 lctl set_param fail_loc=0x0
7463 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7464 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7465 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7467 if [[ $LOCKED -ne 0 ]]; then
7468 error "Locked pages remain in cache, locked=$LOCKED"
7471 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7472 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7476 echo "No pages locked after fsync"
7481 run_test 118f "Simulate unrecoverable OSC side error =========="
7484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7487 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7488 lctl set_param fail_loc=0x406
7490 # simulate local -ENOMEM
7491 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7494 lctl set_param fail_loc=0
7495 if [[ $RC -eq 0 ]]; then
7496 error "Must return error due to dropped pages, rc=$RC"
7499 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7500 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7501 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7503 if [[ $LOCKED -ne 0 ]]; then
7504 error "Locked pages remain in cache, locked=$LOCKED"
7507 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7508 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7512 echo "No pages locked after fsync"
7517 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7521 remote_ost_nodsh && skip "remote OST with nodsh" && return
7525 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7526 set_nodes_failloc "$(osts_nodes)" 0x20e
7527 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7528 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7531 set_nodes_failloc "$(osts_nodes)" 0
7532 if [[ $RC -eq 0 ]]; then
7533 error "Must return error due to dropped pages, rc=$RC"
7536 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7537 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7538 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7540 if [[ $LOCKED -ne 0 ]]; then
7541 error "Locked pages remain in cache, locked=$LOCKED"
7544 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7545 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7549 echo "No pages locked after fsync"
7553 run_test 118h "Verify timeout in handling recoverables errors =========="
7555 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7559 remote_ost_nodsh && skip "remote OST with nodsh" && return
7563 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7564 set_nodes_failloc "$(osts_nodes)" 0x20e
7566 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7567 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7570 set_nodes_failloc "$(osts_nodes)" 0
7574 if [[ $RC -ne 0 ]]; then
7575 error "got error, but should be not, rc=$RC"
7578 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7579 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7580 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7581 if [[ $LOCKED -ne 0 ]]; then
7582 error "Locked pages remain in cache, locked=$LOCKED"
7585 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7586 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7590 echo "No pages locked after fsync"
7594 run_test 118i "Fix error before timeout in recoverable error =========="
7596 [ "$SLOW" = "no" ] && set_resend_count 4
7599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7600 remote_ost_nodsh && skip "remote OST with nodsh" && return
7604 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7605 set_nodes_failloc "$(osts_nodes)" 0x220
7607 # return -EIO from OST
7608 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7610 set_nodes_failloc "$(osts_nodes)" 0x0
7611 if [[ $RC -eq 0 ]]; then
7612 error "Must return error due to dropped pages, rc=$RC"
7615 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7616 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7617 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7618 if [[ $LOCKED -ne 0 ]]; then
7619 error "Locked pages remain in cache, locked=$LOCKED"
7622 # in recoverable error on OST we want resend and stay until it finished
7623 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7624 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7628 echo "No pages locked after fsync"
7632 run_test 118j "Simulate unrecoverable OST side error =========="
7636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7637 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7639 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7640 set_nodes_failloc "$(osts_nodes)" 0x20e
7641 test_mkdir -p $DIR/$tdir
7643 for ((i=0;i<10;i++)); do
7644 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7645 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7652 set_nodes_failloc "$(osts_nodes)" 0
7655 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7661 test_mkdir -p $DIR/$tdir
7662 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7665 run_test 118l "fsync dir ========="
7667 test_118m() # LU-3066
7669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7670 test_mkdir -p $DIR/$tdir
7671 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7674 run_test 118m "fdatasync dir ========="
7676 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7678 test_119a() # bug 11737
7680 BSIZE=$((512 * 1024))
7681 directio write $DIR/$tfile 0 1 $BSIZE
7682 # We ask to read two blocks, which is more than a file size.
7683 # directio will indicate an error when requested and actual
7684 # sizes aren't equeal (a normal situation in this case) and
7685 # print actual read amount.
7686 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7687 if [ "$NOB" != "$BSIZE" ]; then
7688 error "read $NOB bytes instead of $BSIZE"
7692 run_test 119a "Short directIO read must return actual read amount"
7694 test_119b() # bug 11737
7696 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7698 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7699 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7701 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7702 error "direct read failed"
7705 run_test 119b "Sparse directIO read must return actual read amount"
7707 test_119c() # bug 13099
7710 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7711 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7714 run_test 119c "Testing for direct read hitting hole"
7716 test_119d() # bug 15950
7718 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7719 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7720 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7722 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7723 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7724 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7725 lctl set_param fail_loc=0x40d
7726 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7729 cat $DIR/$tfile > /dev/null &
7730 lctl set_param fail_loc=0
7733 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7735 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7736 error "the read rpcs have not completed in 2s"
7738 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7740 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7744 test_mkdir -p $DIR/$tdir
7745 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7746 skip "no early lock cancel on server" && return 0
7748 lru_resize_disable mdc
7749 lru_resize_disable osc
7750 cancel_lru_locks mdc
7751 # asynchronous object destroy at MDT could cause bl ast to client
7752 cancel_lru_locks osc
7754 stat $DIR/$tdir > /dev/null
7755 can1=$(do_facet $SINGLEMDS \
7756 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7757 awk '/ldlm_cancel/ {print $2}')
7758 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7759 awk '/ldlm_bl_callback/ {print $2}')
7760 test_mkdir -c1 $DIR/$tdir/d1
7761 can2=$(do_facet $SINGLEMDS \
7762 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7763 awk '/ldlm_cancel/ {print $2}')
7764 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7765 awk '/ldlm_bl_callback/ {print $2}')
7766 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7767 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7768 lru_resize_enable mdc
7769 lru_resize_enable osc
7771 run_test 120a "Early Lock Cancel: mkdir test"
7774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7775 test_mkdir $DIR/$tdir
7776 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7777 skip "no early lock cancel on server" && return 0
7778 lru_resize_disable mdc
7779 lru_resize_disable osc
7780 cancel_lru_locks mdc
7781 stat $DIR/$tdir > /dev/null
7782 can1=$(do_facet $SINGLEMDS \
7783 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7784 awk '/ldlm_cancel/ {print $2}')
7785 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7786 awk '/ldlm_bl_callback/ {print $2}')
7788 can2=$(do_facet $SINGLEMDS \
7789 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7790 awk '/ldlm_cancel/ {print $2}')
7791 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7792 awk '/ldlm_bl_callback/ {print $2}')
7793 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7794 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7795 lru_resize_enable mdc
7796 lru_resize_enable osc
7798 run_test 120b "Early Lock Cancel: create test"
7801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7802 test_mkdir -c1 $DIR/$tdir
7803 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7804 skip "no early lock cancel on server" && return 0
7805 lru_resize_disable mdc
7806 lru_resize_disable osc
7807 test_mkdir -p -c1 $DIR/$tdir/d1
7808 test_mkdir -p -c1 $DIR/$tdir/d2
7809 touch $DIR/$tdir/d1/f1
7810 cancel_lru_locks mdc
7811 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7812 can1=$(do_facet $SINGLEMDS \
7813 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7814 awk '/ldlm_cancel/ {print $2}')
7815 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7816 awk '/ldlm_bl_callback/ {print $2}')
7817 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7818 can2=$(do_facet $SINGLEMDS \
7819 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7820 awk '/ldlm_cancel/ {print $2}')
7821 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7822 awk '/ldlm_bl_callback/ {print $2}')
7823 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7824 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7825 lru_resize_enable mdc
7826 lru_resize_enable osc
7828 run_test 120c "Early Lock Cancel: link test"
7831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7832 test_mkdir -p -c1 $DIR/$tdir
7833 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7834 skip "no early lock cancel on server" && return 0
7835 lru_resize_disable mdc
7836 lru_resize_disable osc
7838 cancel_lru_locks mdc
7839 stat $DIR/$tdir > /dev/null
7840 can1=$(do_facet $SINGLEMDS \
7841 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7842 awk '/ldlm_cancel/ {print $2}')
7843 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7844 awk '/ldlm_bl_callback/ {print $2}')
7845 chmod a+x $DIR/$tdir
7846 can2=$(do_facet $SINGLEMDS \
7847 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7848 awk '/ldlm_cancel/ {print $2}')
7849 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7850 awk '/ldlm_bl_callback/ {print $2}')
7851 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7852 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7853 lru_resize_enable mdc
7854 lru_resize_enable osc
7856 run_test 120d "Early Lock Cancel: setattr test"
7859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7860 test_mkdir -p -c1 $DIR/$tdir
7861 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7862 skip "no early lock cancel on server" && return 0
7863 lru_resize_disable mdc
7864 lru_resize_disable osc
7865 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7866 cancel_lru_locks mdc
7867 cancel_lru_locks osc
7868 dd if=$DIR/$tdir/f1 of=/dev/null
7869 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7870 # XXX client can not do early lock cancel of OST lock
7871 # during unlink (LU-4206), so cancel osc lock now.
7872 cancel_lru_locks osc
7873 can1=$(do_facet $SINGLEMDS \
7874 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7875 awk '/ldlm_cancel/ {print $2}')
7876 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7877 awk '/ldlm_bl_callback/ {print $2}')
7878 unlink $DIR/$tdir/f1
7880 can2=$(do_facet $SINGLEMDS \
7881 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7882 awk '/ldlm_cancel/ {print $2}')
7883 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7884 awk '/ldlm_bl_callback/ {print $2}')
7885 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7886 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7887 lru_resize_enable mdc
7888 lru_resize_enable osc
7890 run_test 120e "Early Lock Cancel: unlink test"
7893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7894 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7895 skip "no early lock cancel on server" && return 0
7896 test_mkdir -p -c1 $DIR/$tdir
7897 lru_resize_disable mdc
7898 lru_resize_disable osc
7899 test_mkdir -p -c1 $DIR/$tdir/d1
7900 test_mkdir -p -c1 $DIR/$tdir/d2
7901 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7902 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7903 cancel_lru_locks mdc
7904 cancel_lru_locks osc
7905 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7906 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7907 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7908 # XXX client can not do early lock cancel of OST lock
7909 # during rename (LU-4206), so cancel osc lock now.
7910 cancel_lru_locks osc
7911 can1=$(do_facet $SINGLEMDS \
7912 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7913 awk '/ldlm_cancel/ {print $2}')
7914 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7915 awk '/ldlm_bl_callback/ {print $2}')
7916 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7918 can2=$(do_facet $SINGLEMDS \
7919 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7920 awk '/ldlm_cancel/ {print $2}')
7921 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7922 awk '/ldlm_bl_callback/ {print $2}')
7923 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7924 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7925 lru_resize_enable mdc
7926 lru_resize_enable osc
7928 run_test 120f "Early Lock Cancel: rename test"
7931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7932 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7933 skip "no early lock cancel on server" && return 0
7934 lru_resize_disable mdc
7935 lru_resize_disable osc
7937 echo create $count files
7938 test_mkdir -p $DIR/$tdir
7939 cancel_lru_locks mdc
7940 cancel_lru_locks osc
7943 can0=$(do_facet $SINGLEMDS \
7944 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7945 awk '/ldlm_cancel/ {print $2}')
7946 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7947 awk '/ldlm_bl_callback/ {print $2}')
7948 createmany -o $DIR/$tdir/f $count
7950 can1=$(do_facet $SINGLEMDS \
7951 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7952 awk '/ldlm_cancel/ {print $2}')
7953 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7954 awk '/ldlm_bl_callback/ {print $2}')
7956 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7957 echo rm $count files
7960 can2=$(do_facet $SINGLEMDS \
7961 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7962 awk '/ldlm_cancel/ {print $2}')
7963 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7964 awk '/ldlm_bl_callback/ {print $2}')
7966 echo total: $count removes in $((t2-t1))
7967 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7969 # wait for commitment of removal
7970 lru_resize_enable mdc
7971 lru_resize_enable osc
7973 run_test 120g "Early Lock Cancel: performance test"
7975 test_121() { #bug #10589
7976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7978 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7979 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7980 lctl set_param fail_loc=0x310
7981 cancel_lru_locks osc > /dev/null
7982 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7983 lctl set_param fail_loc=0
7984 [[ $reads -eq $writes ]] ||
7985 error "read $reads blocks, must be $writes blocks"
7987 run_test 121 "read cancel race ========="
7989 test_123a() { # was test 123, statahead(bug 11401)
7990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7992 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7993 log "testing on UP system. Performance may be not as good as expected."
7998 test_mkdir -p $DIR/$tdir
7999 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8000 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8002 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8003 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8005 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8006 lctl set_param -n llite.*.statahead_max 0
8007 lctl get_param llite.*.statahead_max
8008 cancel_lru_locks mdc
8009 cancel_lru_locks osc
8011 time ls -l $DIR/$tdir | wc -l
8013 delta=$((etime - stime))
8014 log "ls $i files without statahead: $delta sec"
8015 lctl set_param llite.*.statahead_max=$max
8017 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8018 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8019 cancel_lru_locks mdc
8020 cancel_lru_locks osc
8022 time ls -l $DIR/$tdir | wc -l
8024 delta_sa=$((etime - stime))
8025 log "ls $i files with statahead: $delta_sa sec"
8026 lctl get_param -n llite.*.statahead_stats
8027 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8029 [[ $swrong -lt $ewrong ]] &&
8030 log "statahead was stopped, maybe too many locks held!"
8031 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8033 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8034 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8035 lctl set_param -n llite.*.statahead_max 0
8036 lctl get_param llite.*.statahead_max
8037 cancel_lru_locks mdc
8038 cancel_lru_locks osc
8040 time ls -l $DIR/$tdir | wc -l
8042 delta=$((etime - stime))
8043 log "ls $i files again without statahead: $delta sec"
8044 lctl set_param llite.*.statahead_max=$max
8045 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8046 if [ $SLOWOK -eq 0 ]; then
8047 error "ls $i files is slower with statahead!"
8049 log "ls $i files is slower with statahead!"
8055 [ $delta -gt 20 ] && break
8056 [ $delta -gt 8 ] && MULT=$((50 / delta))
8057 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8065 delta=$((etime - stime))
8066 log "rm -r $DIR/$tdir/: $delta seconds"
8068 lctl get_param -n llite.*.statahead_stats
8070 run_test 123a "verify statahead work"
8072 test_123b () { # statahead(bug 15027)
8073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8074 test_mkdir -p $DIR/$tdir
8075 createmany -o $DIR/$tdir/$tfile-%d 1000
8077 cancel_lru_locks mdc
8078 cancel_lru_locks osc
8080 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8081 lctl set_param fail_loc=0x80000803
8082 ls -lR $DIR/$tdir > /dev/null
8084 lctl set_param fail_loc=0x0
8085 lctl get_param -n llite.*.statahead_stats
8090 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8094 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8095 skip "no lru resize on server" && return 0
8097 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8099 log "create $NR files at $DIR/$tdir"
8100 createmany -o $DIR/$tdir/f $NR ||
8101 error "failed to create $NR files in $DIR/$tdir"
8103 cancel_lru_locks mdc
8104 ls -l $DIR/$tdir > /dev/null
8108 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8109 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8110 LRU_SIZE=$($LCTL get_param -n $PARAM)
8111 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8112 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8114 log "NS=$(basename $NSDIR)"
8119 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8120 skip "Not enough cached locks created!"
8127 # We know that lru resize allows one client to hold $LIMIT locks
8128 # for 10h. After that locks begin to be killed by client.
8130 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8133 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8134 # killing locks. Some time was spent for creating locks. This means
8135 # that up to the moment of sleep finish we must have killed some of
8136 # them (10-100 locks). This depends on how fast ther were created.
8137 # Many of them were touched in almost the same moment and thus will
8138 # be killed in groups.
8139 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8141 # Use $LRU_SIZE_B here to take into account real number of locks
8142 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8143 local LRU_SIZE_B=$LRU_SIZE
8145 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8146 log "OLD_LVF=$OLD_LVF"
8147 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8149 # Let's make sure that we really have some margin. Client checks
8150 # cached locks every 10 sec.
8152 log "Sleep ${SLEEP} sec"
8154 while ((SEC<$SLEEP)); do
8158 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8162 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8163 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8165 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8166 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8167 unlinkmany $DIR/$tdir/f $NR
8171 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8172 log "unlink $NR files at $DIR/$tdir"
8173 unlinkmany $DIR/$tdir/f $NR
8175 run_test 124a "lru resize ======================================="
8177 get_max_pool_limit()
8179 local limit=$($LCTL get_param \
8180 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8183 if [[ $l -gt $max ]]; then
8191 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8192 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8193 skip "no lru resize on server" && return 0
8195 LIMIT=$(get_max_pool_limit)
8197 NR=$(($(default_lru_size)*20))
8198 if [[ $NR -gt $LIMIT ]]; then
8199 log "Limit lock number by $LIMIT locks"
8202 lru_resize_disable mdc
8203 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8204 error "failed to create $DIR/$tdir/disable_lru_resize"
8206 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8207 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8208 cancel_lru_locks mdc
8211 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8214 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8217 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8221 nolruresize_delta=$((etime-stime))
8222 log "ls -la time: $nolruresize_delta seconds"
8223 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8224 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8226 lru_resize_enable mdc
8227 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8228 error "failed to create $DIR/$tdir/enable_lru_resize"
8230 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8231 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8232 cancel_lru_locks mdc
8235 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8238 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8241 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8245 lruresize_delta=$((etime-stime))
8246 log "ls -la time: $lruresize_delta seconds"
8247 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8249 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8250 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8251 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8252 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8254 log "lru resize performs the same with no lru resize"
8256 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8258 run_test 124b "lru resize (performance test) ======================="
8260 test_125() { # 13358
8261 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8262 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8263 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8264 test_mkdir -p $DIR/d125 || error "mkdir failed"
8265 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8266 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8267 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8269 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8271 test_126() { # bug 12829/13455
8272 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8273 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8274 $GSS && skip "must run as gss disabled" && return
8276 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8277 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8279 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8281 run_test 126 "check that the fsgid provided by the client is taken into account"
8283 test_127a() { # bug 15521
8284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8285 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8286 $LCTL set_param osc.*.stats=0
8287 FSIZE=$((2048 * 1024))
8288 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8289 cancel_lru_locks osc
8290 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8292 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8293 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8294 echo "got $COUNT $NAME"
8295 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8296 eval $NAME=$COUNT || error "Wrong proc format"
8299 read_bytes|write_bytes)
8300 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8301 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8302 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8303 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8304 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8305 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8306 error "sumsquare is too small: $SUMSQ"
8307 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8308 error "sumsquare is too big: $SUMSQ"
8312 done < $DIR/${tfile}.tmp
8314 #check that we actually got some stats
8315 [ "$read_bytes" ] || error "Missing read_bytes stats"
8316 [ "$write_bytes" ] || error "Missing write_bytes stats"
8317 [ "$read_bytes" != 0 ] || error "no read done"
8318 [ "$write_bytes" != 0 ] || error "no write done"
8320 run_test 127a "verify the client stats are sane"
8322 test_127b() { # bug LU-333
8323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8324 $LCTL set_param llite.*.stats=0
8325 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8326 # perform 2 reads and writes so MAX is different from SUM.
8327 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8328 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8329 cancel_lru_locks osc
8330 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8331 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8333 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8334 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8335 echo "got $COUNT $NAME"
8336 eval $NAME=$COUNT || error "Wrong proc format"
8340 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8341 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8342 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8343 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8346 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8347 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8348 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8349 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8353 done < $TMP/${tfile}.tmp
8355 #check that we actually got some stats
8356 [ "$read_bytes" ] || error "Missing read_bytes stats"
8357 [ "$write_bytes" ] || error "Missing write_bytes stats"
8358 [ "$read_bytes" != 0 ] || error "no read done"
8359 [ "$write_bytes" != 0 ] || error "no write done"
8361 run_test 127b "verify the llite client stats are sane"
8363 test_128() { # bug 15212
8365 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8370 result=$(grep error $TMP/$tfile.log)
8372 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8374 run_test 128 "interactive lfs for 2 consecutive find's"
8381 local LDPROC=/proc/fs/ldiskfs
8382 local facets=$(get_facets MDS)
8384 for facet in ${facets//,/ }; do
8385 canondev=$(ldiskfs_canon \
8386 *.$(convert_facet2label $facet).mntdev $facet)
8387 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8388 LDPROC=/sys/fs/ldiskfs
8389 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8395 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8396 skip "Only applicable to ldiskfs-based MDTs"
8399 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8404 test_mkdir -p $DIR/$tdir
8406 # block size of mds1
8407 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8408 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8409 local MAX=$((MDSBLOCKSIZE * 3))
8411 local I=$(stat -c%s "$DIR/$tdir")
8413 local STRIPE_COUNT=1
8414 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8415 MAX=$((MAX*STRIPE_COUNT))
8416 while [[ $I -le $MAX ]]; do
8417 $MULTIOP $DIR/$tdir/$J Oc
8419 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8420 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8421 #and EFBIG for previous versions
8422 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8424 echo "return code $rc received as expected"
8425 multiop $DIR/$tdir/$J Oc ||
8426 error_exit "multiop failed w/o dir size limit"
8428 I=$(stat -c%s "$DIR/$tdir")
8430 if [ $(lustre_version_code $SINGLEMDS) -lt \
8431 $(version_code 2.4.51) ]
8433 [[ $I -eq $MAX ]] && return 0
8435 [[ $I -gt $MAX ]] && return 0
8437 error_exit "current dir size $I, previous limit $MAX"
8438 elif [ $rc -ne 0 ]; then
8440 error_exit "return code $rc received instead of expected " \
8441 "$EFBIG or $ENOSPC, files in dir $I"
8444 I=$(stat -c%s "$DIR/$tdir")
8448 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8450 run_test 129 "test directory size limit ========================"
8459 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8460 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8463 trap cleanup_130 EXIT RETURN
8465 local fm_file=$DIR/$tfile
8466 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8467 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8468 error "dd failed for $fm_file"
8470 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8471 filefrag -ves $fm_file
8473 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8474 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8475 [ $RC != 0 ] && error "filefrag $fm_file failed"
8477 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8478 grep -v "ext:" | grep -v "found")
8479 lun=$($GETSTRIPE -i $fm_file)
8481 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8484 for line in $filefrag_op
8486 frag_lun=`echo $line | cut -d: -f5`
8487 ext_len=`echo $line | cut -d: -f4`
8488 if (( $frag_lun != $lun )); then
8490 error "FIEMAP on 1-stripe file($fm_file) failed"
8493 (( tot_len += ext_len ))
8496 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8498 error "FIEMAP on 1-stripe file($fm_file) failed;"
8504 echo "FIEMAP on single striped file succeeded"
8506 run_test 130a "FIEMAP (1-stripe file)"
8509 [ "$OSTCOUNT" -lt "2" ] &&
8510 skip_env "skipping FIEMAP on 2-stripe file test" && return
8512 [ "$OSTCOUNT" -ge "10" ] &&
8513 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8515 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8516 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8519 trap cleanup_130 EXIT RETURN
8521 local fm_file=$DIR/$tfile
8522 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8523 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8524 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8526 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8527 error "dd failed on $fm_file"
8529 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8530 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8531 grep -v "ext:" | grep -v "found")
8533 last_lun=$(echo $filefrag_op | cut -d: -f5)
8538 for line in $filefrag_op
8540 frag_lun=`echo $line | cut -d: -f5`
8541 ext_len=`echo $line | cut -d: -f4`
8542 if (( $frag_lun != $last_lun )); then
8543 if (( tot_len != 1024 )); then
8545 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8552 (( tot_len += ext_len ))
8555 if (( num_luns != 2 || tot_len != 1024 )); then
8557 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8563 echo "FIEMAP on 2-stripe file succeeded"
8565 run_test 130b "FIEMAP (2-stripe file)"
8568 [ "$OSTCOUNT" -lt "2" ] &&
8569 skip_env "skipping FIEMAP on 2-stripe file" && return
8571 [ "$OSTCOUNT" -ge "10" ] &&
8572 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8574 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8575 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8578 trap cleanup_130 EXIT RETURN
8580 local fm_file=$DIR/$tfile
8581 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8582 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8583 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8585 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8587 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8588 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8590 last_lun=`echo $filefrag_op | cut -d: -f5`
8595 for line in $filefrag_op
8597 frag_lun=`echo $line | cut -d: -f5`
8598 ext_len=`echo $line | cut -d: -f4`
8599 if (( $frag_lun != $last_lun )); then
8600 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8601 if (( logical != 512 )); then
8603 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8606 if (( tot_len != 512 )); then
8608 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8615 (( tot_len += ext_len ))
8618 if (( num_luns != 2 || tot_len != 512 )); then
8620 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8626 echo "FIEMAP on 2-stripe file with hole succeeded"
8628 run_test 130c "FIEMAP (2-stripe file with hole)"
8631 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8633 [ "$OSTCOUNT" -ge "10" ] &&
8634 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8636 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8637 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8639 trap cleanup_130 EXIT RETURN
8641 local fm_file=$DIR/$tfile
8642 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8643 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8644 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8646 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8647 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8648 error "dd failed on $fm_file"
8650 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8651 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8652 grep -v "ext:" | grep -v "found"`
8654 last_lun=`echo $filefrag_op | cut -d: -f5`
8659 for line in $filefrag_op
8661 frag_lun=`echo $line | cut -d: -f5`
8662 ext_len=`echo $line | cut -d: -f4`
8663 if (( $frag_lun != $last_lun )); then
8664 if (( tot_len != 1024 )); then
8666 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8673 (( tot_len += ext_len ))
8676 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8678 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8684 echo "FIEMAP on N-stripe file succeeded"
8686 run_test 130d "FIEMAP (N-stripe file)"
8689 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8691 [ "$OSTCOUNT" -ge "10" ] &&
8692 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8694 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8695 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8697 trap cleanup_130 EXIT RETURN
8699 local fm_file=$DIR/$tfile
8700 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8701 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8702 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8705 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8706 for ((i = 0; i < $NUM_BLKS; i++))
8708 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8711 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8712 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8714 last_lun=`echo $filefrag_op | cut -d: -f5`
8719 for line in $filefrag_op
8721 frag_lun=`echo $line | cut -d: -f5`
8722 ext_len=`echo $line | cut -d: -f4`
8723 if (( $frag_lun != $last_lun )); then
8724 if (( tot_len != $EXPECTED_LEN )); then
8726 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8733 (( tot_len += ext_len ))
8736 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8738 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8744 echo "FIEMAP with continuation calls succeeded"
8746 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8748 # Test for writev/readv
8750 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8751 error "writev test failed"
8752 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8753 error "readv failed"
8756 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8759 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8760 error "append writev test failed"
8761 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8762 error "append writev test failed"
8765 run_test 131b "test append writev"
8768 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8771 run_test 131c "test read/write on file w/o objects"
8774 rwv -f $DIR/$tfile -w -n 1 1572864
8775 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8776 if [ "$NOB" != 1572864 ]; then
8777 error "Short read filed: read $NOB bytes instead of 1572864"
8781 run_test 131d "test short read"
8784 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8785 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8786 error "read hitting hole failed"
8789 run_test 131e "test read hitting hole"
8794 for node in $(osts_nodes); do
8795 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8796 [ x$gl = x"" ] && gl=0
8797 gl_sum=$((gl_sum + gl))
8807 if [ x$som = x"enabled" ]; then
8808 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8809 MOUNT_OPTS=`echo $MOUNT_OPTS |
8810 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8811 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8813 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8814 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8815 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8818 # do remount to make new mount-conf parameters actual
8825 test_132() { #1028, SOM
8826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8827 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8828 local num=$(get_mds_dir $DIR)
8829 local mymds=mds${num}
8830 local MOUNT_OPTS_SAVE=$MOUNT_OPTS
8832 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8833 cancel_lru_locks osc
8835 som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8837 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8838 stat $DIR/$tfile >/dev/null
8839 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8840 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8842 som_mode_switch $som1 $gl1 $gl2
8844 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8845 cancel_lru_locks osc
8847 som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8848 if [ $som1 == $som2 ]; then
8849 error "som is still "$som2
8850 if [ x$som2 = x"enabled" ]; then
8857 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8858 stat $DIR/$tfile >/dev/null
8859 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8860 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8861 som_mode_switch $som2 $gl1 $gl2
8862 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8864 run_test 132 "som avoids glimpse rpc"
8870 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8872 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8874 *) error "Wrong argument $1" ;;
8877 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8878 # if the argument $3 is zero, it means any stat increment is ok.
8879 if [[ $3 -gt 0 ]]; then
8880 count=$(echo $res | awk '{ print $2 }')
8881 [[ $count -ne $3 ]] &&
8882 error "The $2 counter on $1 is wrong - expected $3"
8887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8888 remote_ost_nodsh && skip "remote OST with nodsh" && return
8889 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8891 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8892 { skip "MDS doesn't support rename stats"; return; }
8893 local testdir=$DIR/${tdir}/stats_testdir
8894 mkdir -p $DIR/${tdir}
8897 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8898 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8900 # verify mdt stats first.
8901 mkdir ${testdir} || error "mkdir failed"
8902 check_stats $SINGLEMDS "mkdir" 1
8903 touch ${testdir}/${tfile} || "touch failed"
8904 check_stats $SINGLEMDS "open" 1
8905 check_stats $SINGLEMDS "close" 1
8906 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8907 check_stats $SINGLEMDS "mknod" 1
8908 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8909 check_stats $SINGLEMDS "unlink" 1
8910 rm -f ${testdir}/${tfile} || error "file remove failed"
8911 check_stats $SINGLEMDS "unlink" 2
8913 # remove working dir and check mdt stats again.
8914 rmdir ${testdir} || error "rmdir failed"
8915 check_stats $SINGLEMDS "rmdir" 1
8917 local testdir1=$DIR/${tdir}/stats_testdir1
8919 mkdir -p ${testdir1}
8920 touch ${testdir1}/test1
8921 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8922 check_stats $SINGLEMDS "crossdir_rename" 1
8924 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8925 check_stats $SINGLEMDS "samedir_rename" 1
8929 run_test 133a "Verifying MDT stats ========================================"
8932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8933 remote_ost_nodsh && skip "remote OST with nodsh" && return
8934 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8935 local testdir=$DIR/${tdir}/stats_testdir
8936 mkdir -p ${testdir} || error "mkdir failed"
8937 touch ${testdir}/${tfile} || "touch failed"
8938 cancel_lru_locks mdc
8941 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8942 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8944 # extra mdt stats verification.
8945 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8946 check_stats $SINGLEMDS "setattr" 1
8947 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8948 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8950 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8951 check_stats $SINGLEMDS "getattr" 1
8953 $LFS df || error "lfs failed"
8954 check_stats $SINGLEMDS "statfs" 1
8958 run_test 133b "Verifying extra MDT stats =================================="
8961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8962 remote_ost_nodsh && skip "remote OST with nodsh" && return
8963 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8964 local testdir=$DIR/${tdir}/stats_testdir
8965 test_mkdir -p ${testdir} || error "mkdir failed"
8967 # verify obdfilter stats.
8968 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8970 cancel_lru_locks osc
8971 wait_delete_completed
8974 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8975 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8977 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8979 cancel_lru_locks osc
8980 check_stats ost "write" 1
8982 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8983 check_stats ost "read" 1
8985 > ${testdir}/${tfile} || error "truncate failed"
8986 check_stats ost "punch" 1
8988 rm -f ${testdir}/${tfile} || error "file remove failed"
8989 wait_delete_completed
8990 check_stats ost "destroy" 1
8994 run_test 133c "Verifying OST stats ========================================"
9001 while [ $value -ge 2 ]; do
9006 if [ $orig -gt $order ]; then
9014 local size=('K' 'M' 'G' 'T');
9016 local size_string=$value
9018 while [ $value -ge 1024 ]; do
9019 if [ $i -gt 3 ]; then
9020 #T is the biggest unit we get here, if that is bigger,
9022 size_string=${value}T
9025 value=$((value >> 10))
9026 if [ $value -lt 1024 ]; then
9027 size_string=${value}${size[$i]}
9038 local context=${2:-.}
9039 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9041 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9047 remote_ost_nodsh && skip "remote OST with nodsh" && return
9048 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9049 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9050 { skip "MDS doesn't support rename stats"; return; }
9052 local testdir1=$DIR/${tdir}/stats_testdir1
9053 local testdir2=$DIR/${tdir}/stats_testdir2
9055 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9057 mkdir -p ${testdir1} || error "mkdir failed"
9058 mkdir -p ${testdir2} || error "mkdir failed"
9060 createmany -o $testdir1/test 512 || error "createmany failed"
9062 # check samedir rename size
9063 mv ${testdir1}/test0 ${testdir1}/test_0
9065 local testdir1_size=$(ls -l $DIR/${tdir} |
9066 awk '/stats_testdir1/ {print $5}')
9067 local testdir2_size=$(ls -l $DIR/${tdir} |
9068 awk '/stats_testdir2/ {print $5}')
9070 testdir1_size=$(order_2 $testdir1_size)
9071 testdir2_size=$(order_2 $testdir2_size)
9073 testdir1_size=$(size_in_KMGT $testdir1_size)
9074 testdir2_size=$(size_in_KMGT $testdir2_size)
9076 echo "source rename dir size: ${testdir1_size}"
9077 echo "target rename dir size: ${testdir2_size}"
9079 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9080 eval $cmd || error "$cmd failed"
9081 local samedir=$($cmd | grep 'same_dir')
9082 local same_sample=$(get_rename_size $testdir1_size)
9083 [ -z "$samedir" ] && error "samedir_rename_size count error"
9084 [[ $same_sample -eq 1 ]] ||
9085 error "samedir_rename_size error $same_sample"
9086 echo "Check same dir rename stats success"
9088 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9090 # check crossdir rename size
9091 mv ${testdir1}/test_0 ${testdir2}/test_0
9093 testdir1_size=$(ls -l $DIR/${tdir} |
9094 awk '/stats_testdir1/ {print $5}')
9095 testdir2_size=$(ls -l $DIR/${tdir} |
9096 awk '/stats_testdir2/ {print $5}')
9098 testdir1_size=$(order_2 $testdir1_size)
9099 testdir2_size=$(order_2 $testdir2_size)
9101 testdir1_size=$(size_in_KMGT $testdir1_size)
9102 testdir2_size=$(size_in_KMGT $testdir2_size)
9104 echo "source rename dir size: ${testdir1_size}"
9105 echo "target rename dir size: ${testdir2_size}"
9107 eval $cmd || error "$cmd failed"
9108 local crossdir=$($cmd | grep 'crossdir')
9109 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9110 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9111 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9112 [[ $src_sample -eq 1 ]] ||
9113 error "crossdir_rename_size error $src_sample"
9114 [[ $tgt_sample -eq 1 ]] ||
9115 error "crossdir_rename_size error $tgt_sample"
9116 echo "Check cross dir rename stats success"
9119 run_test 133d "Verifying rename_stats ========================================"
9122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9123 local testdir=$DIR/${tdir}/stats_testdir
9124 local ctr f0 f1 bs=32768 count=42 sum
9126 remote_ost_nodsh && skip "remote OST with nodsh" && return
9127 mkdir -p ${testdir} || error "mkdir failed"
9129 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9131 for ctr in {write,read}_bytes; do
9133 cancel_lru_locks osc
9135 do_facet ost1 $LCTL set_param -n \
9136 "obdfilter.*.exports.clear=clear"
9138 if [ $ctr = write_bytes ]; then
9140 f1=${testdir}/${tfile}
9142 f0=${testdir}/${tfile}
9146 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9149 cancel_lru_locks osc
9151 sum=$(do_facet ost1 $LCTL get_param \
9152 "obdfilter.*.exports.*.stats" |
9153 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9154 $1 == ctr { sum += $7 }
9155 END { printf("%0.0f", sum) }')
9157 if ((sum != bs * count)); then
9158 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9164 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9167 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9170 # First without trusting modes.
9171 find $proc_dirs -exec cat '{}' \; &> /dev/null
9173 # Second verifying readability.
9176 -exec cat '{}' \; &> /dev/null ||
9177 error "proc file read failed"
9179 for facet in $SINGLEMDS ost1; do
9180 do_facet $facet find $proc_dirs \
9181 ! -name req_history \
9182 -exec cat '{}' \\\; &> /dev/null
9184 do_facet $facet find $proc_dirs \
9185 ! -name req_history \
9187 -exec cat '{}' \\\; &> /dev/null ||
9188 error "proc file read failed"
9191 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9194 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
9197 # Second verifying readability.
9200 -not -name force_lbug \
9201 -not -name changelog_mask \
9202 -exec badarea_io '{}' \; &> /dev/null ||
9203 error "find $proc_dirs failed"
9205 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9206 skip "Too old lustre on MDS"
9208 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9209 skip "Too old lustre on ost1"
9211 for facet in $SINGLEMDS ost1; do
9212 do_facet $facet find $proc_dirs \
9214 -not -name force_lbug \
9215 -not -name changelog_mask \
9216 -exec badarea_io '{}' \\\; &> /dev/null ||
9217 error "$facet find $proc_dirs failed"
9221 # remount the FS in case writes/reads /proc break the FS
9222 cleanup || error "failed to unmount"
9223 setup || error "failed to setup"
9226 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9228 test_140() { #bug-17379
9229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9230 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9231 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9232 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9234 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9235 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9237 while i=`expr $i + 1`; do
9238 test_mkdir -p $i || error "Creating dir $i"
9239 cd $i || error "Changing to $i"
9240 ln -s ../stat stat || error "Creating stat symlink"
9241 # Read the symlink until ELOOP present,
9242 # not LBUGing the system is considered success,
9243 # we didn't overrun the stack.
9244 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9246 if [ $ret -eq 40 ]; then
9249 error "Open stat symlink"
9255 echo "The symlink depth = $i"
9256 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9257 error "Invalid symlink depth"
9259 # Test recursive symlink
9260 ln -s symlink_self symlink_self
9261 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9262 echo "open symlink_self returns $ret"
9263 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9265 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9269 local TF="$TMP/$tfile"
9271 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9273 cancel_lru_locks osc
9274 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9275 remount_client $MOUNT
9277 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9280 $TRUNCATE $DIR/$tfile 6000
9281 cancel_lru_locks osc
9282 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9285 echo "12345" >>$DIR/$tfile
9286 cancel_lru_locks osc
9287 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9290 echo "12345" >>$DIR/$tfile
9291 cancel_lru_locks osc
9292 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9297 run_test 150 "truncate/append tests"
9299 #LU-2902 roc_hit was not able to read all values from lproc
9300 function roc_hit_init() {
9301 local list=$(comma_list $(osts_nodes))
9302 local dir=$DIR/$tdir-check
9303 local file=$dir/file
9309 #use setstripe to do a write to every ost
9310 for i in $(seq 0 $((OSTCOUNT-1))); do
9311 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9312 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9313 idx=$(printf %04x $i)
9314 BEFORE=$(get_osd_param $list *OST*$idx stats |
9315 awk '$1 == "cache_access" {sum += $7}
9316 END { printf("%0.0f", sum) }')
9318 cancel_lru_locks osc
9319 cat $file >/dev/null
9321 AFTER=$(get_osd_param $list *OST*$idx stats |
9322 awk '$1 == "cache_access" {sum += $7}
9323 END { printf("%0.0f", sum) }')
9325 echo BEFORE:$BEFORE AFTER:$AFTER
9326 if ! let "AFTER - BEFORE == 4"; then
9328 error "roc_hit is not safe to use"
9336 function roc_hit() {
9337 local list=$(comma_list $(osts_nodes))
9338 echo $(get_osd_param $list '' stats |
9339 awk '$1 == "cache_hit" {sum += $7}
9340 END { printf("%0.0f", sum) }')
9343 function set_cache() {
9346 if [ "$2" == "off" ]; then
9349 local list=$(comma_list $(osts_nodes))
9350 set_osd_param $list '' $1_cache_enable $on
9352 cancel_lru_locks osc
9356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9357 remote_ost_nodsh && skip "remote OST with nodsh" && return
9360 local list=$(comma_list $(osts_nodes))
9362 # check whether obdfilter is cache capable at all
9363 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9364 echo "not cache-capable obdfilter"
9368 # check cache is enabled on all obdfilters
9369 if get_osd_param $list '' read_cache_enable | grep 0; then
9370 echo "oss cache is disabled"
9374 set_osd_param $list '' writethrough_cache_enable 1
9376 # check write cache is enabled on all obdfilters
9377 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9378 echo "oss write cache is NOT enabled"
9384 #define OBD_FAIL_OBD_NO_LRU 0x609
9385 do_nodes $list $LCTL set_param fail_loc=0x609
9387 # pages should be in the case right after write
9388 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9391 local BEFORE=$(roc_hit)
9392 cancel_lru_locks osc
9393 cat $DIR/$tfile >/dev/null
9394 local AFTER=$(roc_hit)
9396 do_nodes $list $LCTL set_param fail_loc=0
9398 if ! let "AFTER - BEFORE == CPAGES"; then
9399 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9402 # the following read invalidates the cache
9403 cancel_lru_locks osc
9404 set_osd_param $list '' read_cache_enable 0
9405 cat $DIR/$tfile >/dev/null
9407 # now data shouldn't be found in the cache
9409 cancel_lru_locks osc
9410 cat $DIR/$tfile >/dev/null
9412 if let "AFTER - BEFORE != 0"; then
9413 error "IN CACHE: before: $BEFORE, after: $AFTER"
9416 set_osd_param $list '' read_cache_enable 1
9419 run_test 151 "test cache on oss and controls ==============================="
9422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9423 local TF="$TMP/$tfile"
9425 # simulate ENOMEM during write
9426 #define OBD_FAIL_OST_NOMEM 0x226
9427 lctl set_param fail_loc=0x80000226
9428 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9430 sync || error "sync failed"
9431 lctl set_param fail_loc=0
9433 # discard client's cache
9434 cancel_lru_locks osc
9436 # simulate ENOMEM during read
9437 lctl set_param fail_loc=0x80000226
9438 cmp $TF $DIR/$tfile || error "cmp failed"
9439 lctl set_param fail_loc=0
9443 run_test 152 "test read/write with enomem ============================"
9446 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9448 run_test 153 "test if fdatasync does not crash ======================="
9450 dot_lustre_fid_permission_check() {
9452 local ffid=$MOUNT/.lustre/fid/$fid
9455 echo "stat fid $fid"
9456 stat $ffid > /dev/null || error "stat $ffid failed."
9457 echo "touch fid $fid"
9458 touch $ffid || error "touch $ffid failed."
9459 echo "write to fid $fid"
9460 cat /etc/hosts > $ffid || error "write $ffid failed."
9461 echo "read fid $fid"
9462 diff /etc/hosts $ffid || error "read $ffid failed."
9463 echo "append write to fid $fid"
9464 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9465 echo "rename fid $fid"
9466 mv $ffid $test_dir/$tfile.1 &&
9467 error "rename $ffid to $tfile.1 should fail."
9468 touch $test_dir/$tfile.1
9469 mv $test_dir/$tfile.1 $ffid &&
9470 error "rename $tfile.1 to $ffid should fail."
9471 rm -f $test_dir/$tfile.1
9472 echo "truncate fid $fid"
9473 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9474 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9475 echo "link fid $fid"
9476 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9478 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9479 echo "setfacl fid $fid"
9480 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9481 echo "getfacl fid $fid"
9482 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9484 echo "unlink fid $fid"
9485 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9486 echo "mknod fid $fid"
9487 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9489 fid=[0xf00000400:0x1:0x0]
9490 ffid=$MOUNT/.lustre/fid/$fid
9492 echo "stat non-exist fid $fid"
9493 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9494 echo "write to non-exist fid $fid"
9495 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9496 echo "link new fid $fid"
9497 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9499 mkdir -p $test_dir/$tdir
9500 touch $test_dir/$tdir/$tfile
9501 fid=$($LFS path2fid $test_dir/$tdir)
9504 error "error: could not get fid for $test_dir/$dir/$tfile."
9506 ffid=$MOUNT/.lustre/fid/$fid
9509 ls $ffid > /dev/null || error "ls $ffid failed."
9510 echo "touch $fid/$tfile.1"
9511 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9513 echo "touch $MOUNT/.lustre/fid/$tfile"
9514 touch $MOUNT/.lustre/fid/$tfile && \
9515 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9517 echo "setxattr to $MOUNT/.lustre/fid"
9518 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9520 echo "listxattr for $MOUNT/.lustre/fid"
9521 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9523 echo "delxattr from $MOUNT/.lustre/fid"
9524 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9526 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9527 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9528 error "touch invalid fid should fail."
9530 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9531 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9532 error "touch non-normal fid should fail."
9534 echo "rename $tdir to $MOUNT/.lustre/fid"
9535 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9536 error "rename to $MOUNT/.lustre/fid should fail."
9538 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9540 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9541 local new_obf_mode=777
9543 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9544 chmod $new_obf_mode $DIR/.lustre/fid ||
9545 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9547 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9548 [ $obf_mode -eq $new_obf_mode ] ||
9549 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9551 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9552 chmod $old_obf_mode $DIR/.lustre/fid ||
9553 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9556 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9557 fid=$($LFS path2fid $test_dir/$tfile-2)
9559 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9561 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9562 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9563 error "create lov data thru .lustre failed"
9565 echo "cp /etc/passwd $test_dir/$tfile-2"
9566 cp /etc/passwd $test_dir/$tfile-2 ||
9567 error "copy to $test_dir/$tfile-2 failed."
9568 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9569 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9570 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9572 rm -rf $test_dir/tfile.lnk
9573 rm -rf $test_dir/$tfile-2
9577 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9578 skip "Need MDS version at least 2.4.1" && return
9581 local FID=$($LFS path2fid $DIR/$tfile)
9582 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9584 # check that we get the same pathname back
9585 local FOUND=$($LFS fid2path $MOUNT $FID)
9586 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9587 [ "$FOUND" != "$DIR/$tfile" ] &&
9588 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9592 run_test 154A "lfs path2fid and fid2path basic checks"
9595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9596 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9597 { skip "Need MDS version at least 2.2.51"; return 0; }
9598 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9600 cp /etc/hosts $DIR/$tfile
9602 fid=$($LFS path2fid $DIR/$tfile)
9604 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9606 dot_lustre_fid_permission_check "$fid" $DIR ||
9607 error "dot lustre permission check $fid failed"
9609 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9611 touch $MOUNT/.lustre/file &&
9612 error "creation is not allowed under .lustre"
9614 mkdir $MOUNT/.lustre/dir &&
9615 error "mkdir is not allowed under .lustre"
9619 run_test 154a "Open-by-FID"
9622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9623 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9624 { skip "Need MDS version at least 2.2.51"; return 0; }
9626 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9628 local remote_dir=$DIR/$tdir/remote_dir
9633 $LFS mkdir -i $MDTIDX $remote_dir ||
9634 error "create remote directory failed"
9636 cp /etc/hosts $remote_dir/$tfile
9638 fid=$($LFS path2fid $remote_dir/$tfile)
9640 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9642 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9643 error "dot lustre permission check $fid failed"
9646 run_test 154b "Open-by-FID for remote directory"
9649 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9650 skip "Need MDS version at least 2.4.1" && return
9652 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9653 local FID1=$($LFS path2fid $DIR/$tfile.1)
9654 local FID2=$($LFS path2fid $DIR/$tfile.2)
9655 local FID3=$($LFS path2fid $DIR/$tfile.3)
9658 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9659 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9660 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9662 [ "$FID" = "${!want}" ] ||
9663 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9667 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9668 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9669 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9673 run_test 154c "lfs path2fid and fid2path multiple arguments"
9676 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9677 skip "Need MDS version at least 2.5.53" && return
9680 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9684 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9691 fid=$($LFS path2fid $DIR/$tfile)
9694 cmd="exec $fd<$DIR/$tfile"
9696 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9697 echo $fid_list | grep $fid
9700 cmd="exec $fd>/dev/null"
9702 if [ $rc -ne 0 ]; then
9703 error "FID $fid not found in open files list $fid_list"
9706 run_test 154d "Verify open file fid"
9710 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9711 skip "Need MDS version at least 2.6.50" && return
9713 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9714 error ".lustre returned by readdir"
9717 run_test 154e ".lustre is not returned by readdir"
9719 test_155_small_load() {
9720 local temp=$TMP/$tfile
9721 local file=$DIR/$tfile
9723 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9724 error "dd of=$temp bs=6096 count=1 failed"
9726 cancel_lru_locks osc
9727 cmp $temp $file || error "$temp $file differ"
9729 $TRUNCATE $temp 6000
9730 $TRUNCATE $file 6000
9731 cmp $temp $file || error "$temp $file differ (truncate1)"
9733 echo "12345" >>$temp
9734 echo "12345" >>$file
9735 cmp $temp $file || error "$temp $file differ (append1)"
9737 echo "12345" >>$temp
9738 echo "12345" >>$file
9739 cmp $temp $file || error "$temp $file differ (append2)"
9745 test_155_big_load() {
9746 remote_ost_nodsh && skip "remote OST with nodsh" && return
9747 local temp=$TMP/$tfile
9748 local file=$DIR/$tfile
9751 local cache_size=$(do_facet ost$((MAXI+1)) \
9752 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9753 local large_file_size=$((cache_size * 2))
9755 echo "OSS cache size: $cache_size KB"
9756 echo "Large file size: $large_file_size KB"
9758 [ $MAXV -le $large_file_size ] && \
9759 skip_env "max available OST size needs > $large_file_size KB" && \
9762 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9764 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9765 error "dd of=$temp bs=$large_file_size count=1k failed"
9768 cancel_lru_locks osc
9769 cmp $temp $file || error "$temp $file differ"
9776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9778 set_cache writethrough on
9781 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9786 set_cache writethrough off
9789 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9794 set_cache writethrough on
9797 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9802 set_cache writethrough off
9805 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9808 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9810 set_cache writethrough on
9813 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9818 set_cache writethrough off
9821 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9826 set_cache writethrough on
9829 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9832 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9834 set_cache writethrough off
9837 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9844 local file="$DIR/$tfile"
9846 [ "$(facet_fstype ost1)" = "zfs" ] &&
9847 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9852 log "Turn on read and write cache"
9854 set_cache writethrough on
9856 log "Write data and read it back."
9857 log "Read should be satisfied from the cache."
9858 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9860 cancel_lru_locks osc
9861 cat $file >/dev/null
9863 if ! let "AFTER - BEFORE == CPAGES"; then
9864 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9866 log "cache hits:: before: $BEFORE, after: $AFTER"
9869 log "Read again; it should be satisfied from the cache."
9871 cancel_lru_locks osc
9872 cat $file >/dev/null
9874 if ! let "AFTER - BEFORE == CPAGES"; then
9875 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9877 log "cache hits:: before: $BEFORE, after: $AFTER"
9881 log "Turn off the read cache and turn on the write cache"
9883 set_cache writethrough on
9885 log "Read again; it should be satisfied from the cache."
9887 cancel_lru_locks osc
9888 cat $file >/dev/null
9890 if ! let "AFTER - BEFORE == CPAGES"; then
9891 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9893 log "cache hits:: before: $BEFORE, after: $AFTER"
9896 log "Read again; it should not be satisfied from the cache."
9898 cancel_lru_locks osc
9899 cat $file >/dev/null
9901 if ! let "AFTER - BEFORE == 0"; then
9902 error "IN CACHE: before: $BEFORE, after: $AFTER"
9904 log "cache hits:: before: $BEFORE, after: $AFTER"
9907 log "Write data and read it back."
9908 log "Read should be satisfied from the cache."
9909 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9911 cancel_lru_locks osc
9912 cat $file >/dev/null
9914 if ! let "AFTER - BEFORE == CPAGES"; then
9915 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9917 log "cache hits:: before: $BEFORE, after: $AFTER"
9920 log "Read again; it should not be satisfied from the cache."
9922 cancel_lru_locks osc
9923 cat $file >/dev/null
9925 if ! let "AFTER - BEFORE == 0"; then
9926 error "IN CACHE: before: $BEFORE, after: $AFTER"
9928 log "cache hits:: before: $BEFORE, after: $AFTER"
9932 log "Turn off read and write cache"
9934 set_cache writethrough off
9936 log "Write data and read it back"
9937 log "It should not be satisfied from the cache."
9939 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9940 cancel_lru_locks osc
9942 cat $file >/dev/null
9944 if ! let "AFTER - BEFORE == 0"; then
9945 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9947 log "cache hits:: before: $BEFORE, after: $AFTER"
9950 log "Turn on the read cache and turn off the write cache"
9952 set_cache writethrough off
9954 log "Write data and read it back"
9955 log "It should not be satisfied from the cache."
9957 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9959 cancel_lru_locks osc
9960 cat $file >/dev/null
9962 if ! let "AFTER - BEFORE == 0"; then
9963 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9965 log "cache hits:: before: $BEFORE, after: $AFTER"
9968 log "Read again; it should be satisfied from the cache."
9970 cancel_lru_locks osc
9971 cat $file >/dev/null
9973 if ! let "AFTER - BEFORE == CPAGES"; then
9974 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9976 log "cache hits:: before: $BEFORE, after: $AFTER"
9981 run_test 156 "Verification of tunables ============================"
9985 if [[ $MDSCOUNT -gt 1 ]]; then
9986 error_ignore bz17935 $*
9994 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9996 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9998 if [ $MASK -eq 1 ]; then
9999 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10001 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10005 changelog_extract_field() {
10009 local identifier=$4
10011 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10012 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10018 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10019 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10020 { skip "Need MDS version at least 2.2.0"; return; }
10022 local CL_USERS="mdd.$MDT0.changelog_users"
10023 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10024 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10025 echo "Registered as changelog user $USER"
10026 $GET_CL_USERS | grep -q $USER ||
10027 error "User $USER not found in changelog_users"
10030 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10031 touch $DIR/$tdir/pics/2008/zachy/timestamp
10032 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10033 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10034 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10035 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10036 rm $DIR/$tdir/pics/desktop.jpg
10038 $LFS changelog $MDT0 | tail -5
10040 echo "verifying changelog mask"
10041 changelog_chmask "MKDIR"
10042 changelog_chmask "CLOSE"
10044 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10045 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10047 changelog_chmask "MKDIR"
10048 changelog_chmask "CLOSE"
10050 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10051 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10053 $LFS changelog $MDT0
10054 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10055 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10056 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10057 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10060 echo "verifying target fid"
10061 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10062 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10063 [ "$fidc" == "$fidf" ] ||
10064 err17935 "fid in changelog $fidc != file fid $fidf"
10065 echo "verifying parent fid"
10066 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10067 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10068 [ "$fidc" == "$fidf" ] ||
10069 err17935 "pfid in changelog $fidc != dir fid $fidf"
10071 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10072 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10073 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10074 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10075 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10076 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10078 MIN_REC=$($GET_CL_USERS |
10079 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10080 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10081 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10082 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10083 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10085 # LU-3446 changelog index reset on MDT restart
10086 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10087 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10088 $LFS changelog_clear $MDT0 $USER 0
10089 stop $SINGLEMDS || error "Fail to stop MDT."
10090 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10091 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10092 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10093 [ $CUR_REC1 == $CUR_REC2 ] ||
10094 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10096 echo "verifying user deregister"
10097 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10098 $GET_CL_USERS | grep -q $USER &&
10099 error "User $USER still in changelog_users"
10101 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10102 if [ $USERS -eq 0 ]; then
10103 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10104 touch $DIR/$tdir/chloe
10105 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10106 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10107 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10109 echo "$USERS other changelog users; can't verify off"
10112 run_test 160a "changelog sanity"
10114 test_160b() { # LU-3587
10115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10116 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10117 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10118 { skip "Need MDS version at least 2.2.0"; return; }
10120 local CL_USERS="mdd.$MDT0.changelog_users"
10121 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10122 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10123 echo "Registered as changelog user $USER"
10124 $GET_CL_USERS | grep -q $USER ||
10125 error "User $USER not found in changelog_users"
10127 local LONGNAME1=$(str_repeat a 255)
10128 local LONGNAME2=$(str_repeat b 255)
10131 echo "creating very long named file"
10132 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10133 echo "moving very long named file"
10134 mv $LONGNAME1 $LONGNAME2
10136 $LFS changelog $MDT0 | grep RENME
10138 echo "deregistering $USER"
10139 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10143 run_test 160b "Verify that very long rename doesn't crash in changelog"
10147 local server_version=$(lustre_version_code $SINGLEMDS)
10149 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10150 [[ $server_version -gt $(version_code 2.5.1) &&
10151 $server_version -lt $(version_code 2.5.50) ]] ||
10152 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10155 # Registration step
10156 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10157 changelog_register -n)
10160 mkdir -p $DIR/$tdir
10161 $MCREATE $DIR/$tdir/foo_160c
10162 changelog_chmask "TRUNC"
10163 $TRUNCATE $DIR/$tdir/foo_160c 200
10164 changelog_chmask "TRUNC"
10165 $TRUNCATE $DIR/$tdir/foo_160c 199
10166 $LFS changelog $MDT0
10167 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10168 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10169 $LFS changelog_clear $MDT0 $USER 0
10171 # Deregistration step
10172 echo "deregistering $USER"
10173 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10175 run_test 160c "verify that changelog log catch the truncate event"
10178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10179 test_mkdir -p -c1 $DIR/$tdir
10180 cp /etc/hosts $DIR/$tdir/$tfile
10181 test_mkdir -c1 $DIR/$tdir/foo1
10182 test_mkdir -c1 $DIR/$tdir/foo2
10183 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10184 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10185 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10186 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10187 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10188 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10189 $LFS fid2path $DIR $FID
10190 err17935 "bad link ea"
10193 rm $DIR/$tdir/foo2/zachary
10195 rm $DIR/$tdir/foo2/thor
10197 rm $DIR/$tdir/$tfile
10199 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10200 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10202 $LFS fid2path $DIR $FID
10203 err17935 "bad link rename"
10205 rm $DIR/$tdir/foo2/maggie
10208 local longname=filename_avg_len_is_thirty_two_
10209 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10210 error "failed to hardlink many files"
10211 links=$($LFS fid2path $DIR $FID | wc -l)
10212 echo -n "${links}/1000 links in link EA"
10213 [[ $links -gt 60 ]] ||
10214 err17935 "expected at least 60 links in link EA"
10215 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10216 error "failed to unlink many hardlinks"
10218 run_test 161a "link ea sanity"
10221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10222 [ $MDSCOUNT -lt 2 ] &&
10223 skip "skipping remote directory test" && return
10225 local remote_dir=$DIR/$tdir/remote_dir
10227 mkdir -p $DIR/$tdir
10228 $LFS mkdir -i $MDTIDX $remote_dir ||
10229 error "create remote directory failed"
10231 cp /etc/hosts $remote_dir/$tfile
10232 mkdir -p $remote_dir/foo1
10233 mkdir -p $remote_dir/foo2
10234 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10235 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10236 ln $remote_dir/$tfile $remote_dir/foo1/luna
10237 ln $remote_dir/$tfile $remote_dir/foo2/thor
10239 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10241 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10242 $LFS fid2path $DIR $FID
10243 err17935 "bad link ea"
10246 rm $remote_dir/foo2/zachary
10248 rm $remote_dir/foo2/thor
10250 rm $remote_dir/$tfile
10252 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10253 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10254 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10255 $LFS fid2path $DIR $FID
10256 err17935 "bad link rename"
10258 rm $remote_dir/foo2/maggie
10261 local longname=filename_avg_len_is_thirty_two_
10262 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10263 error "failed to hardlink many files"
10264 links=$($LFS fid2path $DIR $FID | wc -l)
10265 echo -n "${links}/1000 links in link EA"
10266 [[ ${links} -gt 60 ]] ||
10267 err17935 "expected at least 60 links in link EA"
10268 unlinkmany $remote_dir/foo2/$longname 1000 ||
10269 error "failed to unlink many hardlinks"
10271 run_test 161b "link ea sanity under remote directory"
10274 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10275 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10276 skip "Need MDS version at least 2.1.5" && return
10278 # define CLF_RENAME_LAST 0x0001
10279 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10280 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10281 changelog_register -n)
10283 mkdir -p $DIR/$tdir
10284 touch $DIR/$tdir/foo_161c
10285 touch $DIR/$tdir/bar_161c
10286 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10287 $LFS changelog $MDT0 | grep RENME
10288 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10290 $LFS changelog_clear $MDT0 $USER 0
10291 if [ x$flags != "x0x1" ]; then
10292 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10294 error "flag $flags is not 0x1"
10296 echo "rename overwrite a target having nlink = 1," \
10297 "changelog record has flags of $flags"
10299 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10300 touch $DIR/$tdir/foo_161c
10301 touch $DIR/$tdir/bar_161c
10302 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10303 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10304 $LFS changelog $MDT0 | grep RENME
10305 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10306 $LFS changelog_clear $MDT0 $USER 0
10307 if [ x$flags != "x0x0" ]; then
10308 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10310 error "flag $flags is not 0x0"
10312 echo "rename overwrite a target having nlink > 1," \
10313 "changelog record has flags of $flags"
10315 # rename doesn't overwrite a target (changelog flag 0x0)
10316 touch $DIR/$tdir/foo_161c
10317 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10318 $LFS changelog $MDT0 | grep RENME
10319 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10320 $LFS changelog_clear $MDT0 $USER 0
10321 if [ x$flags != "x0x0" ]; then
10322 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10324 error "flag $flags is not 0x0"
10326 echo "rename doesn't overwrite a target," \
10327 "changelog record has flags of $flags"
10329 # define CLF_UNLINK_LAST 0x0001
10330 # unlink a file having nlink = 1 (changelog flag 0x1)
10331 rm -f $DIR/$tdir/foo2_161c
10332 $LFS changelog $MDT0 | grep UNLNK
10333 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10334 $LFS changelog_clear $MDT0 $USER 0
10335 if [ x$flags != "x0x1" ]; then
10336 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10338 error "flag $flags is not 0x1"
10340 echo "unlink a file having nlink = 1," \
10341 "changelog record has flags of $flags"
10343 # unlink a file having nlink > 1 (changelog flag 0x0)
10344 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10345 rm -f $DIR/$tdir/foobar_161c
10346 $LFS changelog $MDT0 | grep UNLNK
10347 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10348 $LFS changelog_clear $MDT0 $USER 0
10349 if [ x$flags != "x0x0" ]; then
10350 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10352 error "flag $flags is not 0x0"
10354 echo "unlink a file having nlink > 1," \
10355 "changelog record has flags of $flags"
10356 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10358 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10365 local path=$(${LFS} fid2path $*)
10368 if [ $RC -ne 0 ]; then
10369 err17935 "path looked up of $expected failed. Error $RC"
10371 elif [ "${path}" != "${expected}" ]; then
10372 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10375 echo "fid $fid resolves to path $path (expected $expected)"
10379 # Make changes to filesystem
10380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10381 test_mkdir -p -c1 $DIR/$tdir/d2
10382 touch $DIR/$tdir/d2/$tfile
10383 touch $DIR/$tdir/d2/x1
10384 touch $DIR/$tdir/d2/x2
10385 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10386 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10388 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10389 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10390 error "check path $tdir/d2/$tfile failed"
10393 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10394 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10395 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10396 error "check path $tdir/d2/p/q/r/slink failed"
10398 # softlink to wrong file
10399 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10400 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10401 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10402 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10405 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10406 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10407 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10408 # fid2path dir/fsname should both work
10409 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10410 error "check path $tdir/d2/a/b/c/new_file failed"
10411 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10412 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10414 # hardlink count: check that there are 2 links
10415 # Doesnt work with CMD yet: 17935
10416 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10417 err17935 "expected 2 links"
10419 # hardlink indexing: remove the first link
10420 rm $DIR/$tdir/d2/p/q/r/hlink
10421 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10422 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10426 run_test 162 "path lookup sanity"
10429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10430 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10433 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10434 error "create striped dir failed"
10436 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10437 tail -n 1 | awk '{print $2}')
10438 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10440 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10441 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10444 for ((i=0;i<5;i++)); do
10445 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10446 error "get fid for f$i failed"
10447 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10448 error "check path $tdir/striped_dir/f$i failed"
10450 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10451 error "get fid for d$i failed"
10452 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10453 error "check path $tdir/striped_dir/d$i failed"
10458 run_test 162b "striped directory path lookup sanity"
10461 # do directio so as not to populate the page cache
10462 log "creating a 10 Mb file"
10463 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10464 log "starting reads"
10465 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10466 log "truncating the file"
10467 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10469 kill %+ || true # reads might have finished
10470 echo "wait until dd is finished"
10472 log "removing the temporary file"
10473 rm -rf $DIR/$tfile || error "tmp file removal failed"
10475 run_test 169 "parallel read and truncate should not deadlock"
10478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10479 $LCTL clear # bug 18514
10480 $LCTL debug_daemon start $TMP/${tfile}_log_good
10482 $LCTL debug_daemon stop
10483 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10484 error "sed failed to read log_good"
10486 $LCTL debug_daemon start $TMP/${tfile}_log_good
10488 $LCTL debug_daemon stop
10490 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10491 error "lctl df log_bad failed"
10493 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10494 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10496 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10497 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10499 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10500 error "bad_line good_line1 good_line2 are empty"
10502 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10503 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10504 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10506 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10507 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10508 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10510 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10511 error "bad_line_new good_line_new are empty"
10513 local expected_good=$((good_line1 + good_line2*2))
10515 rm -f $TMP/${tfile}*
10516 # LU-231, short malformed line may not be counted into bad lines
10517 if [ $bad_line -ne $bad_line_new ] &&
10518 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10519 error "expected $bad_line bad lines, but got $bad_line_new"
10523 if [ $expected_good -ne $good_line_new ]; then
10524 error "expected $expected_good good lines, but got $good_line_new"
10529 run_test 170 "test lctl df to handle corrupted log ====================="
10531 test_171() { # bug20592
10532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10533 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10534 $LCTL set_param fail_loc=0x50e
10535 $LCTL set_param fail_val=3000
10536 multiop_bg_pause $DIR/$tfile O_s || true
10538 kill -USR1 $MULTIPID
10542 if dmesg | grep "recursive fault"; then
10543 error "caught a recursive fault"
10545 $LCTL set_param fail_loc=0
10548 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10550 # it would be good to share it with obdfilter-survey/iokit-libecho code
10551 setup_obdecho_osc () {
10554 local obdfilter_name=$2
10555 echo "Creating new osc for $obdfilter_name on $ost_nid"
10556 # make sure we can find loopback nid
10557 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10559 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10560 ${obdfilter_name}_osc_UUID || rc=2; }
10561 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10562 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10566 cleanup_obdecho_osc () {
10567 local obdfilter_name=$1
10568 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10569 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10576 local pages=${3:-64}
10581 local obd_size=$(get_obd_size $node $OBD)
10582 local page_size=$(get_page_size $node)
10583 if [[ -n "$obd_size" ]]; then
10584 local new_count=$((obd_size / (pages * page_size / 1024)))
10585 [[ $new_count -ge $count ]] || count=$new_count
10588 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10589 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10591 if [ $rc -eq 0 ]; then
10592 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10593 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10595 echo "New object id is $id"
10596 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10598 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10599 "test_brw $count w v $pages $id" || rc=4; }
10600 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10602 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10603 "cleanup" || rc=5; }
10604 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10605 "detach" || rc=6; }
10606 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10611 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10612 remote_ost_nodsh && skip "remote OST with nodsh" && return
10614 local rmmod_local=0
10616 if ! module_loaded obdecho; then
10617 load_module obdecho/obdecho
10621 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10622 local host=$(lctl get_param -n osc.$osc.import |
10623 awk '/current_connection:/ {print $2}' )
10624 local target=$(lctl get_param -n osc.$osc.import |
10625 awk '/target:/ {print $2}' )
10626 target=${target%_UUID}
10628 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10629 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10630 [[ -n $target ]] && cleanup_obdecho_osc $target
10631 [ $rmmod_local -eq 1 ] && rmmod obdecho
10634 run_test 180a "test obdecho on osc"
10637 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10638 remote_ost_nodsh && skip "remote OST with nodsh" && return
10640 local rmmod_remote=0
10642 do_facet ost1 "lsmod | grep -q obdecho || " \
10643 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10644 "modprobe obdecho; }" && rmmod_remote=1
10645 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10646 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10647 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10650 run_test 180b "test obdecho directly on obdfilter"
10652 test_180c() { # LU-2598
10653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10654 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10655 skip "Need MDS version at least 2.4.0" && return
10658 local rmmod_remote=false
10659 local pages=16384 # 64MB bulk I/O RPC size
10662 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10663 rmmod_remote=true || error "failed to load module obdecho"
10665 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10667 if [ -n "$target" ]; then
10668 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10670 echo "there is no obdfilter target on ost1"
10673 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10676 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10678 test_181() { # bug 22177
10679 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10680 # create enough files to index the directory
10681 createmany -o $DIR/$tdir/foobar 4000
10682 # print attributes for debug purpose
10685 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10687 # remove the files & current working dir
10688 unlinkmany $DIR/$tdir/foobar 4000
10690 kill -USR1 $MULTIPID
10692 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10695 run_test 181 "Test open-unlinked dir ========================"
10698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10699 # disable MDC RPC lock wouldn't crash client
10703 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10704 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10705 $LCTL set_param fail_loc=0x804
10707 for (( i=0; i < $tcount; i++ )) ; do
10708 mkdir $DIR/$tdir/$i
10709 createmany -o $DIR/$tdir/$i/f- $fcount &
10713 for (( i=0; i < $tcount; i++ )) ; do
10714 unlinkmany $DIR/$tdir/$i/f- $fcount &
10720 $LCTL set_param fail_loc=0
10722 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10724 test_183() { # LU-2275
10725 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10726 skip "Need MDS version at least 2.3.56" && return
10728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10729 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10730 echo aaa > $DIR/$tdir/$tfile
10732 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10733 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10735 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10736 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10738 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10740 # Flush negative dentry cache
10741 touch $DIR/$tdir/$tfile
10743 # We are not checking for any leaked references here, they'll
10744 # become evident next time we do cleanup with module unload.
10747 run_test 183 "No crash or request leak in case of strange dispositions ========"
10749 # test suite 184 is for LU-2016, LU-2017
10751 check_swap_layouts_support && return 0
10753 dir0=$DIR/$tdir/$testnum
10754 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10759 $SETSTRIPE -c1 $file1
10761 $SETSTRIPE -c2 $file2
10763 gen1=$($GETSTRIPE -g $file1)
10764 gen2=$($GETSTRIPE -g $file2)
10766 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10767 gen=$($GETSTRIPE -g $file1)
10768 [[ $gen1 != $gen ]] ||
10769 "Layout generation on $file1 does not change"
10770 gen=$($GETSTRIPE -g $file2)
10771 [[ $gen2 != $gen ]] ||
10772 "Layout generation on $file2 does not change"
10774 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10775 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10777 run_test 184a "Basic layout swap"
10780 check_swap_layouts_support && return 0
10782 dir0=$DIR/$tdir/$testnum
10783 mkdir -p $dir0 || error "creating dir $dir0"
10790 $SETSTRIPE -c1 $file1
10791 $SETSTRIPE -c2 $file2
10792 $SETSTRIPE -c1 $file3
10793 chown $RUNAS_ID $file3
10794 gen1=$($GETSTRIPE -g $file1)
10795 gen2=$($GETSTRIPE -g $file2)
10797 $LFS swap_layouts $dir1 $dir2 &&
10798 error "swap of directories layouts should fail"
10799 $LFS swap_layouts $dir1 $file1 &&
10800 error "swap of directory and file layouts should fail"
10801 $RUNAS $LFS swap_layouts $file1 $file2 &&
10802 error "swap of file we cannot write should fail"
10803 $LFS swap_layouts $file1 $file3 &&
10804 error "swap of file with different owner should fail"
10805 /bin/true # to clear error code
10807 run_test 184b "Forbidden layout swap (will generate errors)"
10810 check_swap_layouts_support && return 0
10812 local dir0=$DIR/$tdir/$testnum
10813 mkdir -p $dir0 || error "creating dir $dir0"
10815 local ref1=$dir0/ref1
10816 local ref2=$dir0/ref2
10817 local file1=$dir0/file1
10818 local file2=$dir0/file2
10819 # create a file large enough for the concurent test
10820 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10821 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10822 echo "ref file size: ref1($(stat -c %s $ref1))," \
10823 "ref2($(stat -c %s $ref2))"
10826 dd if=$ref1 of=$file1 bs=16k &
10829 # Make sure dd starts to copy file
10830 while [ ! -f $file1 ]; do sleep 0.1; done
10832 $LFS swap_layouts $file1 $file2
10835 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10836 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10838 # how many bytes copied before swapping layout
10839 local copied=$(stat -c %s $file2)
10840 local remaining=$(stat -c %s $ref1)
10841 remaining=$((remaining - copied))
10842 echo "Copied $copied bytes before swapping layout..."
10844 cmp -n $copied $file1 $ref2 | grep differ &&
10845 error "Content mismatch [0, $copied) of ref2 and file1"
10846 cmp -n $copied $file2 $ref1 ||
10847 error "Content mismatch [0, $copied) of ref1 and file2"
10848 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10849 error "Content mismatch [$copied, EOF) of ref1 and file1"
10852 rm -f $ref1 $ref2 $file1 $file2
10854 run_test 184c "Concurrent write and layout swap"
10857 check_swap_layouts_support && return 0
10858 [ -z "$(which getfattr 2>/dev/null)" ] &&
10859 skip "no getfattr command" && return 0
10861 local file1=$DIR/$tdir/$tfile-1
10862 local file2=$DIR/$tdir/$tfile-2
10863 local file3=$DIR/$tdir/$tfile-3
10867 mkdir -p $DIR/$tdir
10868 touch $file1 || error "create $file1 failed"
10869 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10870 error "create $file2 failed"
10871 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10872 error "create $file3 failed"
10873 lovea1=$($LFS getstripe $file1 | sed 1d)
10875 $LFS swap_layouts $file2 $file3 ||
10876 error "swap $file2 $file3 layouts failed"
10877 $LFS swap_layouts $file1 $file2 ||
10878 error "swap $file1 $file2 layouts failed"
10880 lovea2=$($LFS getstripe $file2 | sed 1d)
10881 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10883 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10884 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10886 run_test 184d "allow stripeless layouts swap"
10889 test_185() { # LU-2441
10890 # LU-3553 - no volatile file support in old servers
10891 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10892 { skip "Need MDS version at least 2.3.60"; return 0; }
10894 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10895 touch $DIR/$tdir/spoo
10896 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10897 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10898 error "cannot create/write a volatile file"
10899 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10900 error "FID is still valid after close"
10902 multiop_bg_pause $DIR/$tdir vVw4096_c
10909 # assume that the next FID for this client is sequential, since stdout
10910 # is unfortunately eaten by multiop_bg_pause
10911 local n=$((${fidv[1]} + 1))
10912 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10913 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10914 error "FID is missing before close"
10915 kill -USR1 $multi_pid
10916 # 1 second delay, so if mtime change we will see it
10918 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10919 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10921 run_test 185 "Volatile file support"
10924 local dir0=$DIR/$tdir/$testnum
10925 mkdir -p $dir0 || error "creating dir $dir0"
10927 local file=$dir0/file1
10928 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10929 local dv1=$($LFS data_version $file)
10930 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10931 local dv2=$($LFS data_version $file)
10932 [[ $dv1 != $dv2 ]] ||
10933 error "data version did not change on write $dv1 == $dv2"
10938 run_test 187a "Test data version change"
10941 local dir0=$DIR/$tdir/$testnum
10942 mkdir -p $dir0 || error "creating dir $dir0"
10944 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10945 [[ ${DV[0]} != ${DV[1]} ]] ||
10946 error "data version did not change on write"\
10947 " ${DV[0]} == ${DV[1]}"
10952 run_test 187b "Test data version change on volatile file"
10955 check_file_in_pool()
10960 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10963 for t in $tlist ; do
10964 [ "$i" -eq "$t" ] && continue 2
10967 echo "pool list: $tlist"
10968 echo "striping: $res"
10969 error_noexit "$file not allocated in $pool"
10976 echo "Creating new pool"
10979 create_pool $FSNAME.$pool ||
10980 { error_noexit "No pool created, result code $?"; return 1; }
10981 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10982 { error_noexit "$pool not in lfs pool_list"; return 2; }
10985 pool_add_targets() {
10986 echo "Adding targets to pool"
10992 local list=$(seq $first $step $last)
10994 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10995 do_facet mgs $LCTL pool_add \
10996 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10997 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10998 | sort -u | tr '\n' ' ' " "$t" || {
10999 error_noexit "Add to pool failed"
11002 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
11003 local addcount=$(((last - first) / step + 1))
11004 [ $lfscount -eq $addcount ] || {
11005 error_noexit "lfs pool_list bad ost count" \
11006 "$lfscount != $addcount"
11014 echo "Setting pool on directory $tdir"
11016 $SETSTRIPE -c 2 -p $pool $tdir && return 0
11018 error_noexit "Cannot set pool $pool to $tdir"
11025 echo "Checking pool on directory $tdir"
11027 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
11028 [ "$res" = "$pool" ] && return 0
11030 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
11034 pool_dir_rel_path() {
11035 echo "Testing relative path works well"
11040 mkdir -p $root/$tdir/$tdir
11042 pool_set_dir $pool $tdir || return 1
11043 pool_set_dir $pool ./$tdir || return 2
11044 pool_set_dir $pool ../$tdir || return 3
11045 pool_set_dir $pool ../$tdir/$tdir || return 4
11046 rm -rf $tdir; cd - > /dev/null
11049 pool_alloc_files() {
11050 echo "Checking files allocation from directory pool"
11057 for i in $(seq -w 1 $count)
11059 local file=$tdir/file-$i
11061 check_file_in_pool $file $pool "$tlist" || \
11062 failed=$((failed + 1))
11064 [ "$failed" = 0 ] && return 0
11066 error_noexit "$failed files not allocated in $pool"
11070 pool_create_files() {
11071 echo "Creating files in pool"
11079 for i in $(seq -w 1 $count)
11081 local file=$tdir/spoo-$i
11082 $SETSTRIPE -p $pool $file
11083 check_file_in_pool $file $pool "$tlist" || \
11084 failed=$((failed + 1))
11086 [ "$failed" = 0 ] && return 0
11088 error_noexit "$failed files not allocated in $pool"
11093 echo "Checking 'lfs df' output"
11096 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
11098 local res=$($LFS df --pool $FSNAME.$pool |
11100 grep "$FSNAME-OST" |
11102 [ "$res" = "$t" ] && return 0
11104 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
11108 pool_file_rel_path() {
11109 echo "Creating files in a pool with relative pathname"
11114 { error_noexit "unable to create $tdir"; return 1 ; }
11115 local file="/..$tdir/$tfile-1"
11116 $SETSTRIPE -p $pool $file ||
11117 { error_noexit "unable to create $file" ; return 2 ; }
11120 $SETSTRIPE -p $pool $tfile-2 || {
11121 error_noexit "unable to create $tfile-2 in $tdir"
11126 pool_remove_first_target() {
11127 echo "Removing first target from a pool"
11130 local pname="lov.$FSNAME-*.pools.$pool"
11131 local t=$($LCTL get_param -n $pname | head -n1)
11132 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11133 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
11134 error_noexit "$t not removed from $FSNAME.$pool"
11139 pool_remove_all_targets() {
11140 echo "Removing all targets from pool"
11143 local pname="lov.$FSNAME-*.pools.$pool"
11144 for t in $($LCTL get_param -n $pname | sort -u)
11146 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
11148 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
11149 error_noexit "Pool $FSNAME.$pool cannot be drained"
11152 # striping on an empty/nonexistant pool should fall back
11153 # to "pool of everything"
11155 error_noexit "failed to use fallback striping for empty pool"
11158 # setstripe on an empty pool should fail
11159 $SETSTRIPE -p $pool $file 2>/dev/null && {
11160 error_noexit "expected failure when creating file" \
11168 echo "Destroying pool"
11172 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
11175 # striping on an empty/nonexistant pool should fall back
11176 # to "pool of everything"
11178 error_noexit "failed to use fallback striping for missing pool"
11181 # setstripe on an empty pool should fail
11182 $SETSTRIPE -p $pool $file 2>/dev/null && {
11183 error_noexit "expected failure when creating file" \
11184 "with missing pool"
11188 # get param should return err once pool is gone
11189 if wait_update $HOSTNAME "lctl get_param -n \
11190 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
11192 remove_pool_from_list $FSNAME.$pool
11195 error_noexit "Pool $FSNAME.$pool is not destroyed"
11200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11201 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11203 local POOL=${POOL:-cea1}
11204 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11205 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11208 local last_ost=$(($OSTCOUNT - 1))
11210 local ost_list=$(seq $first_ost $ost_step $last_ost)
11211 local ost_range="$first_ost $last_ost $ost_step"
11212 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11213 local file_dir=$POOL_ROOT/file_tst
11217 # former test_200a test_200b
11218 pool_add $POOL || { rc=$? ; break; }
11219 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11220 # former test_200c test_200d
11221 mkdir -p $test_path
11222 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11223 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11224 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11225 || { rc=$? ; break; }
11226 # former test_200e test_200f
11227 local files=$((OSTCOUNT*3))
11228 pool_alloc_files $POOL $test_path $files "$ost_list" \
11229 || { rc=$? ; break; }
11230 pool_create_files $POOL $file_dir $files "$ost_list" \
11231 || { rc=$? ; break; }
11232 # former test_200g test_200h
11233 pool_lfs_df $POOL || { rc=$? ; break; }
11234 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11236 # former test_201a test_201b test_201c
11237 pool_remove_first_target $POOL || { rc=$? ; break; }
11239 local f=$test_path/$tfile
11240 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11241 pool_remove $POOL $f || { rc=$? ; break; }
11248 run_test 200 "OST pools"
11250 # usage: default_attr <count | size | offset>
11252 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11255 # usage: check_default_stripe_attr
11256 check_default_stripe_attr() {
11257 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11259 --stripe-count|--count)
11260 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11261 --stripe-size|--size)
11262 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11263 --stripe-index|--index)
11266 error "unknown getstripe attr '$1'"
11269 [ $ACTUAL != $EXPECTED ] &&
11270 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11274 test_mkdir -p $DIR/$tdir
11275 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11277 check_default_stripe_attr --stripe-count
11278 check_default_stripe_attr --stripe-size
11279 check_default_stripe_attr --stripe-index
11283 run_test 204a "Print default stripe attributes ================="
11286 test_mkdir -p $DIR/$tdir
11287 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11289 check_default_stripe_attr --stripe-size
11290 check_default_stripe_attr --stripe-index
11294 run_test 204b "Print default stripe size and offset ==========="
11297 test_mkdir -p $DIR/$tdir
11298 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11300 check_default_stripe_attr --stripe-count
11301 check_default_stripe_attr --stripe-index
11305 run_test 204c "Print default stripe count and offset ==========="
11308 test_mkdir -p $DIR/$tdir
11309 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11311 check_default_stripe_attr --stripe-count
11312 check_default_stripe_attr --stripe-size
11316 run_test 204d "Print default stripe count and size ============="
11319 test_mkdir -p $DIR/$tdir
11320 $SETSTRIPE -d $DIR/$tdir
11322 check_default_stripe_attr --stripe-count --raw
11323 check_default_stripe_attr --stripe-size --raw
11324 check_default_stripe_attr --stripe-index --raw
11328 run_test 204e "Print raw stripe attributes ================="
11331 test_mkdir -p $DIR/$tdir
11332 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11334 check_default_stripe_attr --stripe-size --raw
11335 check_default_stripe_attr --stripe-index --raw
11339 run_test 204f "Print raw stripe size and offset ==========="
11342 test_mkdir -p $DIR/$tdir
11343 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11345 check_default_stripe_attr --stripe-count --raw
11346 check_default_stripe_attr --stripe-index --raw
11350 run_test 204g "Print raw stripe count and offset ==========="
11353 test_mkdir -p $DIR/$tdir
11354 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11356 check_default_stripe_attr --stripe-count --raw
11357 check_default_stripe_attr --stripe-size --raw
11361 run_test 204h "Print raw stripe count and size ============="
11363 # Figure out which job scheduler is being used, if any,
11364 # or use a fake one
11365 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11366 JOBENV=SLURM_JOB_ID
11367 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11369 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11371 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11372 JOBENV=LOADL_STEP_ID
11373 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11379 verify_jobstats() {
11383 # clear old jobstats
11384 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11385 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11387 # use a new JobID for this test, or we might see an old one
11388 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11392 log "Using JobID environment variable $JOBENV=$JOBVAL"
11394 if [ $JOBENV = "FAKE_JOBID" ]; then
11395 FAKE_JOBID=$JOBVAL $cmd
11400 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11401 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11402 do_facet $FACET lctl get_param mdt.*.job_stats |
11403 grep $JOBVAL || error "No job stats found on MDT $FACET"
11405 if [ "$target" = "ost" -o "$target" = "both" ]; then
11407 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11408 grep $JOBVAL || error "No job stats found on OST $FACET"
11414 NEW_JOBENV=${1:-$OLD_JOBENV}
11415 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11416 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11419 test_205() { # Job stats
11420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11421 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11422 skip "Server doesn't support jobstats" && return 0
11423 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11426 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11427 if [ $OLD_JOBENV != $JOBENV ]; then
11428 jobstats_set $JOBENV
11429 trap jobstats_set EXIT
11433 cmd="mkdir $DIR/$tfile"
11434 verify_jobstats "$cmd" "mdt"
11436 cmd="rm -fr $DIR/$tfile"
11437 verify_jobstats "$cmd" "mdt"
11439 cmd="mknod $DIR/$tfile c 1 3"
11440 verify_jobstats "$cmd" "mdt"
11442 cmd="rm -f $DIR/$tfile"
11443 verify_jobstats "$cmd" "mdt"
11445 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11446 verify_jobstats "$cmd" "mdt"
11448 cmd="touch $DIR/$tfile"
11449 verify_jobstats "$cmd" "both"
11451 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11452 verify_jobstats "$cmd" "ost"
11454 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11455 verify_jobstats "$cmd" "ost"
11457 cmd="$TRUNCATE $DIR/$tfile 0"
11458 verify_jobstats "$cmd" "both"
11460 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11461 verify_jobstats "$cmd" "mdt"
11464 rm -f $DIR/jobstats_test_rename
11466 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11468 run_test 205 "Verify job stats"
11470 # LU-1480, LU-1773 and LU-1657
11472 mkdir -p $DIR/$tdir
11473 $SETSTRIPE -c -1 $DIR/$tdir
11474 #define OBD_FAIL_LOV_INIT 0x1403
11475 $LCTL set_param fail_loc=0xa0001403
11476 $LCTL set_param fail_val=1
11477 touch $DIR/$tdir/$tfile || true
11479 run_test 206 "fail lov_init_raid0() doesn't lbug"
11482 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11483 local fsz=`stat -c %s $DIR/$tfile`
11484 cancel_lru_locks mdc
11486 # do not return layout in getattr intent
11487 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11488 $LCTL set_param fail_loc=0x170
11489 local sz=`stat -c %s $DIR/$tfile`
11491 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11495 run_test 207a "can refresh layout at glimpse"
11498 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11499 local cksum=`md5sum $DIR/$tfile`
11500 local fsz=`stat -c %s $DIR/$tfile`
11501 cancel_lru_locks mdc
11502 cancel_lru_locks osc
11504 # do not return layout in getattr intent
11505 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11506 $LCTL set_param fail_loc=0x171
11508 # it will refresh layout after the file is opened but before read issues
11509 echo checksum is "$cksum"
11510 echo "$cksum" |md5sum -c --quiet || error "file differs"
11514 run_test 207b "can refresh layout at open"
11517 # FIXME: in this test suite, only RD lease is used. This is okay
11518 # for now as only exclusive open is supported. After generic lease
11519 # is done, this test suite should be revised. - Jinshan
11521 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11522 { skip "Need MDS version at least 2.4.52"; return 0; }
11524 echo "==== test 1: verify get lease work"
11525 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11527 echo "==== test 2: verify lease can be broken by upcoming open"
11528 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11532 $MULTIOP $DIR/$tfile oO_RDONLY:c
11533 kill -USR1 $PID && wait $PID || error "break lease error"
11535 echo "==== test 3: verify lease can't be granted if an open already exists"
11536 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11540 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11541 kill -USR1 $PID && wait $PID || error "open file error"
11543 echo "==== test 4: lease can sustain over recovery"
11544 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11550 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11552 echo "==== test 5: lease broken can't be regained by replay"
11553 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11557 # open file to break lease and then recovery
11558 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11561 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11565 run_test 208 "Exclusive open"
11568 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11569 skip_env "must have disp_stripe" && return
11572 sync; sleep 5; sync;
11574 echo 3 > /proc/sys/vm/drop_caches
11575 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11577 # open/close 500 times
11578 for i in $(seq 500); do
11582 echo 3 > /proc/sys/vm/drop_caches
11583 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11585 echo "before: $req_before, after: $req_after"
11586 [ $((req_after - req_before)) -ge 300 ] &&
11587 error "open/close requests are not freed"
11590 run_test 209 "read-only open/close requests should be freed promptly"
11594 size=$((size % 8192 + 1))
11595 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11596 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11597 rm -f $DIR/f212 $DIR/f212.xyz
11599 run_test 212 "Sendfile test ============================================"
11602 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11603 cancel_lru_locks osc
11604 lctl set_param fail_loc=0x8000040f
11605 # generate a read lock
11606 cat $DIR/$tfile > /dev/null
11607 # write to the file, it will try to cancel the above read lock.
11608 cat /etc/hosts >> $DIR/$tfile
11610 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11612 test_214() { # for bug 20133
11613 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11614 for (( i=0; i < 340; i++ )) ; do
11615 touch $DIR/$tdir/d214c/a$i
11618 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11619 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11620 ls $DIR/d214c || error "ls $DIR/d214c failed"
11621 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11622 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11624 run_test 214 "hash-indexed directory test - bug 20133"
11626 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11627 create_lnet_proc_files() {
11628 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11629 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11631 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11632 rm -f "$TMP/lnet_$1.sys_tmp"
11635 # counterpart of create_lnet_proc_files
11636 remove_lnet_proc_files() {
11637 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11640 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11641 # 3rd arg as regexp for body
11642 check_lnet_proc_stats() {
11643 local l=$(cat "$TMP/lnet_$1" |wc -l)
11644 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11646 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11649 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11650 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11651 # optional and can be regexp for 2nd line (lnet.routes case)
11652 check_lnet_proc_entry() {
11653 local blp=2 # blp stands for 'position of 1st line of body'
11654 [ -z "$5" ] || blp=3 # lnet.routes case
11656 local l=$(cat "$TMP/lnet_$1" |wc -l)
11657 # subtracting one from $blp because the body can be empty
11658 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11660 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11661 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11663 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11664 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11666 # bail out if any unexpected line happened
11667 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11668 [ "$?" != 0 ] || error "$2 misformatted"
11671 test_215() { # for bugs 18102, 21079, 21517
11672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11673 local N='(0|[1-9][0-9]*)' # non-negative numeric
11674 local P='[1-9][0-9]*' # positive numeric
11675 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11676 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11677 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11678 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11680 local L1 # regexp for 1st line
11681 local L2 # regexp for 2nd line (optional)
11682 local BR # regexp for the rest (body)
11684 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11685 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11686 create_lnet_proc_files "stats"
11687 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11688 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11689 remove_lnet_proc_files "stats"
11691 # /proc/sys/lnet/routes should look like this:
11692 # Routing disabled/enabled
11693 # net hops priority state router
11694 # where net is a string like tcp0, hops > 0, priority >= 0,
11695 # state is up/down,
11696 # router is a string like 192.168.1.1@tcp2
11697 L1="^Routing (disabled|enabled)$"
11698 L2="^net +hops +priority +state +router$"
11699 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11700 create_lnet_proc_files "routes"
11701 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11702 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11703 remove_lnet_proc_files "routes"
11705 # /proc/sys/lnet/routers should look like this:
11706 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11707 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11708 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11709 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11710 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11711 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11712 create_lnet_proc_files "routers"
11713 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11714 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11715 remove_lnet_proc_files "routers"
11717 # /proc/sys/lnet/peers should look like this:
11718 # nid refs state last max rtr min tx min queue
11719 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11720 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11721 # numeric (0 or >0 or <0), queue >= 0.
11722 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11723 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11724 create_lnet_proc_files "peers"
11725 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11726 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11727 remove_lnet_proc_files "peers"
11729 # /proc/sys/lnet/buffers should look like this:
11730 # pages count credits min
11731 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11732 L1="^pages +count +credits +min$"
11733 BR="^ +$N +$N +$I +$I$"
11734 create_lnet_proc_files "buffers"
11735 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11736 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11737 remove_lnet_proc_files "buffers"
11739 # /proc/sys/lnet/nis should look like this:
11740 # nid status alive refs peer rtr max tx min
11741 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11742 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11743 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11744 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11745 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11746 create_lnet_proc_files "nis"
11747 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11748 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11749 remove_lnet_proc_files "nis"
11751 # can we successfully write to /proc/sys/lnet/stats?
11752 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11753 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11755 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11757 test_216() { # bug 20317
11758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11759 remote_ost_nodsh && skip "remote OST with nodsh" && return
11762 local facets=$(get_facets OST)
11763 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11765 save_lustre_params client "osc.*.contention_seconds" > $p
11766 save_lustre_params $facets \
11767 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11768 save_lustre_params $facets \
11769 "ldlm.namespaces.filter-*.contended_locks" >> $p
11770 save_lustre_params $facets \
11771 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11774 # agressive lockless i/o settings
11775 for node in $(osts_nodes); do
11776 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'
11778 lctl set_param -n osc.*.contention_seconds 60
11780 $DIRECTIO write $DIR/$tfile 0 10 4096
11781 $CHECKSTAT -s 40960 $DIR/$tfile
11783 # disable lockless i/o
11784 for node in $(osts_nodes); do
11785 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'
11787 lctl set_param -n osc.*.contention_seconds 0
11790 dd if=/dev/zero of=$DIR/$tfile count=0
11791 $CHECKSTAT -s 0 $DIR/$tfile
11793 restore_lustre_params <$p
11797 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11799 test_217() { # bug 22430
11800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11804 for node in $(nodes_list); do
11805 nid=$(host_nids_address $node $NETTYPE)
11806 if [[ $nid = *-* ]] ; then
11807 echo "lctl ping $nid@$NETTYPE"
11808 lctl ping $nid@$NETTYPE
11810 echo "skipping $node (no hyphen detected)"
11814 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11817 # do directio so as not to populate the page cache
11818 log "creating a 10 Mb file"
11819 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11820 log "starting reads"
11821 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11822 log "truncating the file"
11823 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11825 kill %+ || true # reads might have finished
11826 echo "wait until dd is finished"
11828 log "removing the temporary file"
11829 rm -rf $DIR/$tfile || error "tmp file removal failed"
11831 run_test 218 "parallel read and truncate should not deadlock ======================="
11834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11835 # write one partial page
11836 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11837 # set no grant so vvp_io_commit_write will do sync write
11838 $LCTL set_param fail_loc=0x411
11839 # write a full page at the end of file
11840 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11842 $LCTL set_param fail_loc=0
11843 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11844 $LCTL set_param fail_loc=0x411
11845 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11848 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11849 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11851 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11853 test_220() { #LU-325
11854 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11855 remote_ost_nodsh && skip "remote OST with nodsh" && return
11858 test_mkdir -p $DIR/$tdir
11859 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11860 awk '{print $2}' | sed -e 's/_UUID$//')
11863 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11864 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11865 osc.$mdtosc_proc1.prealloc_last_id)
11866 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11867 osc.$mdtosc_proc1.prealloc_next_id)
11871 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11872 #define OBD_FAIL_OST_ENOINO 0x229
11873 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11874 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11875 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11877 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11879 MDSOBJS=$((last_id - next_id))
11880 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11882 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11883 echo "OST still has $count kbytes free"
11885 echo "create $MDSOBJS files @next_id..."
11886 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11888 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11889 osc.$mdtosc_proc1.prealloc_last_id)
11890 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11891 osc.$mdtosc_proc1.prealloc_next_id)
11893 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11898 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11899 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11901 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11902 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11903 echo "unlink $MDSOBJS files @$next_id..."
11904 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11906 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11910 dd if=`which date` of=$MOUNT/date oflag=sync
11911 chmod +x $MOUNT/date
11913 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11914 $LCTL set_param fail_loc=0x80001401
11916 $MOUNT/date > /dev/null
11919 run_test 221 "make sure fault and truncate race to not cause OOM"
11922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11924 test_mkdir -p $DIR/$tdir
11925 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11926 createmany -o $DIR/$tdir/$tfile 10
11927 cancel_lru_locks mdc
11928 cancel_lru_locks osc
11929 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11930 $LCTL set_param fail_loc=0x31a
11931 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11932 $LCTL set_param fail_loc=0
11935 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11940 test_mkdir -p $DIR/$tdir
11941 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11942 createmany -o $DIR/$tdir/$tfile 10
11943 cancel_lru_locks mdc
11944 cancel_lru_locks osc
11945 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11946 $LCTL set_param fail_loc=0x31a
11947 rm -r $DIR/$tdir || "AGL for rmdir failed"
11948 $LCTL set_param fail_loc=0
11950 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11953 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11955 test_mkdir -p $DIR/$tdir
11956 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11957 createmany -o $DIR/$tdir/$tfile 10
11958 cancel_lru_locks mdc
11959 cancel_lru_locks osc
11960 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11961 $LCTL set_param fail_loc=0x31b
11962 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11963 $LCTL set_param fail_loc=0
11966 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11968 test_224a() { # LU-1039, MRP-303
11969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11970 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11971 $LCTL set_param fail_loc=0x508
11972 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11973 $LCTL set_param fail_loc=0
11976 run_test 224a "Don't panic on bulk IO failure"
11978 test_224b() { # LU-1039, MRP-303
11979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11980 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11981 cancel_lru_locks osc
11982 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11983 $LCTL set_param fail_loc=0x515
11984 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11985 $LCTL set_param fail_loc=0
11988 run_test 224b "Don't panic on bulk IO failure"
11990 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11993 if [ -z ${MDSSURVEY} ]; then
11994 skip_env "mds-survey not found" && return
11997 [ $MDSCOUNT -ge 2 ] &&
11998 skip "skipping now for more than one MDT" && return
12000 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12001 { skip "Need MDS version at least 2.2.51"; return; }
12003 local mds=$(facet_host $SINGLEMDS)
12004 local target=$(do_nodes $mds 'lctl dl' | \
12005 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12007 local cmd1="file_count=1000 thrhi=4"
12008 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12009 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12010 local cmd="$cmd1 $cmd2 $cmd3"
12012 rm -f ${TMP}/mds_survey*
12014 eval $cmd || error "mds-survey with zero-stripe failed"
12015 cat ${TMP}/mds_survey*
12016 rm -f ${TMP}/mds_survey*
12018 run_test 225a "Metadata survey sanity with zero-stripe"
12021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12023 if [ -z ${MDSSURVEY} ]; then
12024 skip_env "mds-survey not found" && return
12026 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12027 { skip "Need MDS version at least 2.2.51"; return; }
12029 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12030 skip_env "Need to mount OST to test" && return
12033 [ $MDSCOUNT -ge 2 ] &&
12034 skip "skipping now for more than one MDT" && return
12035 local mds=$(facet_host $SINGLEMDS)
12036 local target=$(do_nodes $mds 'lctl dl' | \
12037 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12039 local cmd1="file_count=1000 thrhi=4"
12040 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12041 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12042 local cmd="$cmd1 $cmd2 $cmd3"
12044 rm -f ${TMP}/mds_survey*
12046 eval $cmd || error "mds-survey with stripe_count failed"
12047 cat ${TMP}/mds_survey*
12048 rm -f ${TMP}/mds_survey*
12050 run_test 225b "Metadata survey sanity with stripe_count = 1"
12052 mcreate_path2fid () {
12058 local path=$DIR/$tdir/$name
12063 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12064 error "cannot create $desc"
12066 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12068 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12070 fid_path=$($LFS fid2path $MOUNT $fid)
12072 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12074 [ "$path" == "$fid_path" ] ||
12075 error "fid2path returned $fid_path, expected $path"
12077 echo "pass with $path and $fid"
12082 mkdir -p $DIR/$tdir
12084 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12085 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12086 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12087 mcreate_path2fid 0040666 0 0 dir "directory"
12088 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12089 mcreate_path2fid 0100666 0 0 file "regular file"
12090 mcreate_path2fid 0120666 0 0 link "symbolic link"
12091 mcreate_path2fid 0140666 0 0 sock "socket"
12093 run_test 226a "call path2fid and fid2path on files of all type"
12096 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12100 mkdir -p $DIR/$tdir
12101 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12102 error "create remote directory failed"
12103 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12104 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12105 "character special file (null)"
12106 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12107 "character special file (no device)"
12108 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12109 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12110 "block special file (loop)"
12111 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12112 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12113 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12115 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12117 # LU-1299 Executing or running ldd on a truncated executable does not
12118 # cause an out-of-memory condition.
12120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12121 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12122 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12123 chmod +x $MOUNT/date
12125 $MOUNT/date > /dev/null
12126 ldd $MOUNT/date > /dev/null
12129 run_test 227 "running truncated executable does not cause OOM"
12131 # LU-1512 try to reuse idle OI blocks
12133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12134 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12135 skip "non-ldiskfs backend" && return
12137 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12138 local myDIR=$DIR/$tdir
12141 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12142 $LCTL set_param fail_loc=0x80001002
12143 createmany -o $myDIR/t- 10000
12144 $LCTL set_param fail_loc=0
12145 # The guard is current the largest FID holder
12147 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12149 local IDX=$(($SEQ % 64))
12151 do_facet $SINGLEMDS sync
12152 # Make sure journal flushed.
12154 local blk1=$(do_facet $SINGLEMDS \
12155 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12156 grep Blockcount | awk '{print $4}')
12158 # Remove old files, some OI blocks will become idle.
12159 unlinkmany $myDIR/t- 10000
12160 # Create new files, idle OI blocks should be reused.
12161 createmany -o $myDIR/t- 2000
12162 do_facet $SINGLEMDS sync
12163 # Make sure journal flushed.
12165 local blk2=$(do_facet $SINGLEMDS \
12166 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12167 grep Blockcount | awk '{print $4}')
12169 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12171 run_test 228a "try to reuse idle OI blocks"
12174 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12175 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12176 skip "non-ldiskfs backend" && return
12178 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12179 local myDIR=$DIR/$tdir
12182 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12183 $LCTL set_param fail_loc=0x80001002
12184 createmany -o $myDIR/t- 10000
12185 $LCTL set_param fail_loc=0
12186 # The guard is current the largest FID holder
12188 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12190 local IDX=$(($SEQ % 64))
12192 do_facet $SINGLEMDS sync
12193 # Make sure journal flushed.
12195 local blk1=$(do_facet $SINGLEMDS \
12196 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12197 grep Blockcount | awk '{print $4}')
12199 # Remove old files, some OI blocks will become idle.
12200 unlinkmany $myDIR/t- 10000
12203 stop $SINGLEMDS || error "Fail to stop MDT."
12205 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12207 df $MOUNT || error "Fail to df."
12208 # Create new files, idle OI blocks should be reused.
12209 createmany -o $myDIR/t- 2000
12210 do_facet $SINGLEMDS sync
12211 # Make sure journal flushed.
12213 local blk2=$(do_facet $SINGLEMDS \
12214 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12215 grep Blockcount | awk '{print $4}')
12217 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12219 run_test 228b "idle OI blocks can be reused after MDT restart"
12223 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12224 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12225 skip "non-ldiskfs backend" && return
12227 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12228 local myDIR=$DIR/$tdir
12231 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12232 $LCTL set_param fail_loc=0x80001002
12233 # 20000 files can guarantee there are index nodes in the OI file
12234 createmany -o $myDIR/t- 20000
12235 $LCTL set_param fail_loc=0
12236 # The guard is current the largest FID holder
12238 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12240 local IDX=$(($SEQ % 64))
12242 do_facet $SINGLEMDS sync
12243 # Make sure journal flushed.
12245 local blk1=$(do_facet $SINGLEMDS \
12246 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12247 grep Blockcount | awk '{print $4}')
12249 # Remove old files, some OI blocks will become idle.
12250 unlinkmany $myDIR/t- 20000
12252 # The OI file should become empty now
12254 # Create new files, idle OI blocks should be reused.
12255 createmany -o $myDIR/t- 2000
12256 do_facet $SINGLEMDS sync
12257 # Make sure journal flushed.
12259 local blk2=$(do_facet $SINGLEMDS \
12260 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12261 grep Blockcount | awk '{print $4}')
12263 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12265 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12267 test_229() { # LU-2482, LU-3448
12268 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12269 skip "No HSM support on MDS of $(get_lustre_version)," \
12270 "need 2.4.53 at least" && return
12271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12272 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12276 # Create a file with a released layout and stripe count 2.
12277 $MULTIOP $DIR/$tfile H2c ||
12278 error "failed to create file with released layout"
12280 $GETSTRIPE -v $DIR/$tfile
12282 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12283 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12285 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12286 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12287 stat $DIR/$tfile || error "failed to stat released file"
12289 chown $RUNAS_ID $DIR/$tfile ||
12290 error "chown $RUNAS_ID $DIR/$tfile failed"
12292 chgrp $RUNAS_ID $DIR/$tfile ||
12293 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12295 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12296 rm $DIR/$tfile || error "failed to remove released file"
12298 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12302 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12305 mkdir -p $DIR/$tdir/test_230_local
12306 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12307 [ $mdt_idx -ne 0 ] &&
12308 error "create local directory on wrong MDT $mdt_idx"
12310 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12311 error "create remote directory failed"
12312 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12313 [ $mdt_idx -ne $MDTIDX ] &&
12314 error "create remote directory on wrong MDT $mdt_idx"
12316 createmany -o $DIR/$tdir/test_230/t- 10 ||
12317 error "create files on remote directory failed"
12318 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12319 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12320 rm -r $DIR/$tdir || error "unlink remote directory failed"
12322 run_test 230a "Create remote directory and files under the remote directory"
12325 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12326 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12333 local migrate_dir=$DIR/$tdir/migrate_dir
12334 local other_dir=$DIR/$tdir/other_dir
12336 mkdir -p $migrate_dir
12337 mkdir -p $other_dir
12338 for ((i=0; i<10; i++)); do
12339 mkdir -p $migrate_dir/dir_${i}
12340 createmany -o $migrate_dir/dir_${i}/f 10 ||
12341 error "create files under remote dir failed $i"
12344 cp /etc/passwd $migrate_dir/$tfile
12345 cp /etc/passwd $other_dir/$tfile
12346 chattr +SAD $migrate_dir
12347 chattr +SAD $migrate_dir/$tfile
12349 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12350 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12351 local old_dir_mode=$(stat -c%f $migrate_dir)
12352 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12354 mkdir -p $migrate_dir/dir_default_stripe2
12355 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12356 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12358 mkdir -p $other_dir
12359 ln $migrate_dir/$tfile $other_dir/luna
12360 ln $migrate_dir/$tfile $migrate_dir/sofia
12361 ln $other_dir/$tfile $migrate_dir/david
12362 ln -s $migrate_dir/$tfile $other_dir/zachary
12363 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12364 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12366 $LFS mv -v -M $MDTIDX $migrate_dir ||
12367 error "migrate remote dir error"
12369 echo "migratate to MDT1, then checking.."
12370 for ((i=0; i<10; i++)); do
12371 for file in $(find $migrate_dir/dir_${i}); do
12372 mdt_index=$($LFS getstripe -M $file)
12373 [ $mdt_index == $MDTIDX ] ||
12374 error "$file is not on MDT${MDTIDX}"
12378 # the multiple link file should still in MDT0
12379 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12380 [ $mdt_index == 0 ] ||
12381 error "$file is not on MDT${MDTIDX}"
12383 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12384 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12385 error " expect $old_dir_flag get $new_dir_flag"
12387 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12388 [ "$old_file_flag" = "$new_file_flag" ] ||
12389 error " expect $old_file_flag get $new_file_flag"
12391 local new_dir_mode=$(stat -c%f $migrate_dir)
12392 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12393 error "expect mode $old_dir_mode get $new_dir_mode"
12395 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12396 [ "$old_file_mode" = "$new_file_mode" ] ||
12397 error "expect mode $old_file_mode get $new_file_mode"
12399 diff /etc/passwd $migrate_dir/$tfile ||
12400 error "$tfile different after migration"
12402 diff /etc/passwd $other_dir/luna ||
12403 error "luna different after migration"
12405 diff /etc/passwd $migrate_dir/sofia ||
12406 error "sofia different after migration"
12408 diff /etc/passwd $migrate_dir/david ||
12409 error "david different after migration"
12411 diff /etc/passwd $other_dir/zachary ||
12412 error "zachary different after migration"
12414 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12415 error "${tfile}_ln different after migration"
12417 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12418 error "${tfile}_ln_other different after migration"
12420 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12421 [ $stripe_count = 2 ] ||
12422 error "dir strpe_count $d != 2 after migration."
12424 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12425 [ $stripe_count = 2 ] ||
12426 error "file strpe_count $d != 2 after migration."
12428 #migrate back to MDT0
12430 $LFS mv -v -M $MDTIDX $migrate_dir ||
12431 error "migrate remote dir error"
12433 echo "migrate back to MDT0, checking.."
12434 for file in $(find $migrate_dir); do
12435 mdt_index=$($LFS getstripe -M $file)
12436 [ $mdt_index == $MDTIDX ] ||
12437 error "$file is not on MDT${MDTIDX}"
12440 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12441 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12442 error " expect $old_dir_flag get $new_dir_flag"
12444 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12445 [ "$old_file_flag" = "$new_file_flag" ] ||
12446 error " expect $old_file_flag get $new_file_flag"
12448 local new_dir_mode=$(stat -c%f $migrate_dir)
12449 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12450 error "expect mode $old_dir_mode get $new_dir_mode"
12452 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12453 [ "$old_file_mode" = "$new_file_mode" ] ||
12454 error "expect mode $old_file_mode get $new_file_mode"
12456 diff /etc/passwd ${migrate_dir}/$tfile ||
12457 error "$tfile different after migration"
12459 diff /etc/passwd ${other_dir}/luna ||
12460 error "luna different after migration"
12462 diff /etc/passwd ${migrate_dir}/sofia ||
12463 error "sofia different after migration"
12465 diff /etc/passwd ${other_dir}/zachary ||
12466 error "zachary different after migration"
12468 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12469 error "${tfile}_ln different after migration"
12471 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12472 error "${tfile}_ln_other different after migration"
12474 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12475 [ $stripe_count = 2 ] ||
12476 error "dir strpe_count $d != 2 after migration."
12478 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12479 [ $stripe_count = 2 ] ||
12480 error "file strpe_count $d != 2 after migration."
12482 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12484 run_test 230b "migrate directory"
12487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12488 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12493 #If migrating directory fails in the middle, all entries of
12494 #the directory is still accessiable.
12495 mkdir -p $DIR/$tdir
12497 createmany -o $DIR/$tdir/f 10 ||
12498 error "create files under ${tdir} failed"
12500 #failed after migrating 5 entries
12501 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12502 do_facet mds1 lctl set_param fail_loc=0x20001801
12503 do_facet mds1 lctl set_param fail_val=5
12504 local t=`ls $DIR/$tdir | wc -l`
12505 $LFS mv -M $MDTIDX $DIR/$tdir &&
12506 error "migrate should failed after 5 entries"
12507 local u=`ls $DIR/$tdir | wc -l`
12508 [ "$u" == "$t" ] || error "$u != $t during migration"
12510 for file in $(find $DIR/$tdir); do
12511 stat $file || error "stat $file failed"
12514 do_facet mds1 lctl set_param fail_loc=0
12515 do_facet mds1 lctl set_param fail_val=0
12517 $LFS mv -M $MDTIDX $DIR/$tdir ||
12518 error "migrate open files should failed with open files"
12520 echo "Finish migration, then checking.."
12521 for file in $(find $DIR/$tdir); do
12522 mdt_index=$($LFS getstripe -M $file)
12523 [ $mdt_index == $MDTIDX ] ||
12524 error "$file is not on MDT${MDTIDX}"
12527 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12529 run_test 230c "check directory accessiblity if migration is failed"
12532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12533 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12539 mkdir -p $DIR/$tdir
12541 for ((i=0; i<100; i++)); do
12542 mkdir -p $DIR/$tdir/dir_${i}
12543 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12544 error "create files under remote dir failed $i"
12547 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12549 echo "Finish migration, then checking.."
12550 for file in $(find $DIR/$tdir); do
12551 mdt_index=$($LFS getstripe -M $file)
12552 [ $mdt_index == $MDTIDX ] ||
12553 error "$file is not on MDT${MDTIDX}"
12556 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12558 run_test 230d "check migrate big directory"
12562 # For simplicity this test assumes that max_pages_per_rpc
12563 # is the same across all OSCs
12564 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12565 local bulk_size=$((max_pages * 4096))
12567 mkdir -p $DIR/$tdir
12569 # clear the OSC stats
12570 $LCTL set_param osc.*.stats=0 &>/dev/null
12572 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12573 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12574 oflag=direct &>/dev/null || error "dd failed"
12576 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12577 if [ x$nrpcs != "x1" ]; then
12578 error "found $nrpc ost_write RPCs, not 1 as expected"
12581 # Drop the OSC cache, otherwise we will read from it
12582 cancel_lru_locks osc
12584 # clear the OSC stats
12585 $LCTL set_param osc.*.stats=0 &>/dev/null
12587 # Client reads $bulk_size.
12588 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12589 iflag=direct &>/dev/null || error "dd failed"
12591 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12592 if [ x$nrpcs != "x1" ]; then
12593 error "found $nrpc ost_read RPCs, not 1 as expected"
12596 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12599 mkdir -p $DIR/$tdir
12601 for i in {0..1023}; do
12602 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12603 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12604 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12608 run_test 231b "must not assert on fully utilized OST request buffer"
12611 mkdir -p $DIR/$tdir
12612 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12613 $LCTL set_param fail_loc=0x31c
12615 # ignore dd failure
12616 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12618 $LCTL set_param fail_loc=0
12619 umount_client $MOUNT || error "umount failed"
12620 mount_client $MOUNT || error "mount failed"
12622 run_test 232 "failed lock should not block umount"
12625 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12626 { skip "Need MDS version at least 2.3.64"; return; }
12628 local fid=$($LFS path2fid $MOUNT)
12629 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12630 error "cannot access $MOUNT using its FID '$fid'"
12632 run_test 233a "checking that OBF of the FS root succeeds"
12635 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12636 { skip "Need MDS version at least 2.5.90"; return; }
12638 local fid=$($LFS path2fid $MOUNT/.lustre)
12639 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12640 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12642 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12643 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12644 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12646 run_test 233b "checking that OBF of the FS .lustre succeeds"
12649 local p="$TMP/sanityN-$TESTNAME.parameters"
12650 save_lustre_params client "llite.*.xattr_cache" > $p
12651 lctl set_param llite.*.xattr_cache 1 ||
12652 { skip "xattr cache is not supported"; return 0; }
12654 mkdir -p $DIR/$tdir || error "mkdir failed"
12655 touch $DIR/$tdir/$tfile || error "touch failed"
12656 # OBD_FAIL_LLITE_XATTR_ENOMEM
12657 $LCTL set_param fail_loc=0x1405
12658 if [ ! -f /etc/SuSE-release ]; then
12659 # attr pre-2.4.44-7 had a bug with rc
12660 # LU-3703 - SLES clients have older attr
12661 getfattr -n user.attr $DIR/$tdir/$tfile &&
12662 error "getfattr should have failed with ENOMEM"
12664 $LCTL set_param fail_loc=0x0
12667 restore_lustre_params < $p
12670 run_test 234 "xattr cache should not crash on ENOMEM"
12673 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12674 skip "Need MDS version at least 2.4.52" && return
12675 flock_deadlock $DIR/$tfile
12680 124) error "process hangs on a deadlock"
12682 *) error "error executing flock_deadlock $DIR/$tfile"
12686 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12690 check_swap_layouts_support && return 0
12691 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12693 local ref1=/etc/passwd
12694 local ref2=/etc/group
12695 local file1=$DIR/$tdir/f1
12696 local file2=$DIR/$tdir/f2
12698 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12699 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12700 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12701 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12702 local fd=$(free_fd)
12703 local cmd="exec $fd<>$file2"
12706 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12707 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12710 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12715 run_test 236 "Layout swap on open unlinked file"
12717 # test to verify file handle related system calls
12718 # (name_to_handle_at/open_by_handle_at)
12719 # The new system calls are supported in glibc >= 2.14.
12722 echo "Test file_handle syscalls" > $DIR/$tfile ||
12723 error "write failed"
12724 check_fhandle_syscalls $DIR/$tfile ||
12725 error "check_fhandle_syscalls failed"
12727 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12729 # LU-4659 linkea consistency
12731 local server_version=$(lustre_version_code $SINGLEMDS)
12733 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12734 [[ $server_version -gt $(version_code 2.5.1) &&
12735 $server_version -lt $(version_code 2.5.50) ]] ||
12736 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12739 ln $DIR/$tfile $DIR/$tfile.lnk
12740 touch $DIR/$tfile.new
12741 mv $DIR/$tfile.new $DIR/$tfile
12742 local fid1=$(lfs path2fid $DIR/$tfile)
12743 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12744 local path1=$(lfs fid2path $FSNAME $fid1)
12745 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12746 local path2=$(lfs fid2path $FSNAME $fid2)
12747 [ $tfile.lnk == $path2 ] ||
12748 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12751 run_test 238 "Verify linkea consistency"
12754 local list=$(comma_list $(mdts_nodes))
12756 mkdir -p $DIR/$tdir
12757 createmany -o $DIR/$tdir/f- 5000
12758 unlinkmany $DIR/$tdir/f- 5000
12759 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12760 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12761 osc.*MDT*.sync_in_flight" | calc_sum)
12762 [ "$changes" -eq 0 ] || error "$changes not synced"
12764 run_test 239 "osp_sync test"
12767 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12769 mkdir -p $DIR/$tdir
12771 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12772 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12773 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12774 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12776 umount_client $MOUNT || error "umount failed"
12777 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12778 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12779 mount_client $MOUNT || error "failed to mount client"
12781 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12782 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12784 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12786 cleanup_test_300() {
12790 test_striped_dir() {
12795 mkdir -p $DIR/$tdir
12797 SAVE_UMASK=$(umask)
12798 trap cleanup_test_300 RETURN EXIT
12800 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12801 $DIR/$tdir/striped_dir ||
12802 error "set striped dir error"
12804 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12805 [ "$mode" = "755" ] || error "expect 755 got $mode"
12807 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12808 if [ "$stripe_count" != "2" ]; then
12809 error "stripe_count is $stripe_count, expect 2"
12812 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12813 if [ "$stripe_index" != "$mdt_index" ]; then
12814 error "stripe_index is $stripe_index, expect $mdt_index"
12817 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12818 error "nlink error after create striped dir"
12820 mkdir $DIR/$tdir/striped_dir/a
12821 mkdir $DIR/$tdir/striped_dir/b
12823 stat $DIR/$tdir/striped_dir/a ||
12824 error "create dir under striped dir failed"
12825 stat $DIR/$tdir/striped_dir/b ||
12826 error "create dir under striped dir failed"
12828 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12829 error "nlink error after mkdir"
12831 rmdir $DIR/$tdir/striped_dir/a
12832 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12833 error "nlink error after rmdir"
12835 rmdir $DIR/$tdir/striped_dir/b
12836 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12837 error "nlink error after rmdir"
12839 rmdir $DIR/$tdir/striped_dir ||
12840 error "rmdir striped dir error"
12848 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12849 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12851 test_striped_dir 0 || error "failed on striped dir on MDT0"
12852 test_striped_dir 1 || error "failed on striped dir on MDT0"
12854 run_test 300a "basic striped dir sanity test"
12857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12858 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12864 test_mkdir $DIR/$tdir || error "mkdir fail"
12865 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12866 error "set striped dir error"
12867 for ((i=0; i<10; i++)); do
12868 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12870 touch $DIR/$tdir/striped_dir/file_$i ||
12871 error "touch error $i"
12872 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12873 [ $mtime1 -eq $mtime2 ] &&
12874 error "mtime not change after create"
12876 rm -f $DIR/$tdir/striped_dir/file_$i ||
12877 error "unlink error $i"
12878 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12879 [ $mtime2 -eq $mtime3 ] &&
12880 error "mtime did not change after unlink"
12884 run_test 300b "check ctime/mtime for striped dir"
12887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12888 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12891 mkdir -p $DIR/$tdir
12892 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12893 error "set striped dir error"
12895 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12896 error "chown striped dir failed"
12898 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12899 error "create 5k files failed"
12901 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12903 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12907 run_test 300c "chown && check ls under striped directory"
12910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12915 mkdir -p $DIR/$tdir
12916 $SETSTRIPE -c 2 $DIR/$tdir
12918 #local striped directory
12919 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12920 error "set striped dir error"
12921 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12922 error "create 10 files failed"
12924 #remote striped directory
12925 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12926 error "set striped dir error"
12927 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12928 error "create 10 files failed"
12930 for file in $(find $DIR/$tdir); do
12931 stripe_count=$($GETSTRIPE -c $file)
12932 [ $stripe_count -eq 2 ] ||
12933 error "wrong stripe $stripe_count for $file"
12938 run_test 300d "check default stripe under striped directory"
12941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12942 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12946 mkdir -p $DIR/$tdir
12948 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12949 error "set striped dir error"
12951 touch $DIR/$tdir/striped_dir/a
12952 touch $DIR/$tdir/striped_dir/b
12953 touch $DIR/$tdir/striped_dir/c
12955 mkdir $DIR/$tdir/striped_dir/dir_a
12956 mkdir $DIR/$tdir/striped_dir/dir_b
12957 mkdir $DIR/$tdir/striped_dir/dir_c
12959 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12960 error "set striped dir under striped dir error"
12962 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12963 error "set striped dir under striped dir error"
12965 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12966 error "set striped dir under striped dir error"
12968 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12969 error "rename file under striped dir should fail"
12971 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12972 error "rename dir under striped dir should fail"
12974 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12975 error "rename dir under different stripes should fail"
12977 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12978 error "rename file under striped dir should succeed"
12980 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12981 error "rename dir under striped dir should succeed"
12985 run_test 300e "check rename under striped directory"
12988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12994 mkdir -p $DIR/$tdir
12996 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12997 error "set striped dir error"
12999 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13000 error "set striped dir error"
13002 touch $DIR/$tdir/striped_dir/a
13003 mkdir $DIR/$tdir/striped_dir/dir_a
13004 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13005 error "create striped dir under striped dir fails"
13007 touch $DIR/$tdir/striped_dir1/b
13008 mkdir $DIR/$tdir/striped_dir1/dir_b
13009 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13010 error "create striped dir under striped dir fails"
13012 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
13013 error "rename file under different striped dir should fail"
13015 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
13016 error "rename dir under different striped dir should fail"
13018 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
13019 error "rename striped dir under diff striped dir should fail"
13021 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13022 error "rename file under diff striped dirs fails"
13024 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
13025 error "rename dir under diff striped dirs fails"
13029 run_test 300f "check rename cross striped directory"
13032 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13037 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13038 $DIR/$tdir/striped_dir ||
13039 error "set striped dir error"
13041 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13042 error "set default stripe on striped dir error"
13044 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
13045 [ $stripe_count -eq $MDSCOUNT ] ||
13046 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
13048 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13050 for dir in $(find $DIR/$tdir/striped_dir/*); do
13051 stripe_count=$($LFS getdirstripe -c $dir)
13052 [ $stripe_count -eq $MDSCOUNT ] ||
13053 error "expect $MDSCOUNT get $stripe_count for $dir"
13056 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
13057 #change default stripe count to 2
13058 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
13059 error "set default stripe on striped dir error"
13061 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13063 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
13065 #change default stripe count to 1
13066 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
13067 error "set default stripe on striped dir error"
13069 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13070 for dir in $(find $DIR/$tdir/striped_dir/*); do
13071 stripe_count=$($LFS getdirstripe -c $dir)
13072 [ $stripe_count -eq 1 ] ||
13073 error "expect 1 get $stripe_count for $dir"
13075 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
13077 run_test 300g "check default striped directory for striped directory"
13080 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13081 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13087 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13088 error "set striped dir error"
13090 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13091 error "create files under striped dir failed"
13093 # unfortunately, we need to umount to clear dir layout cache for now
13094 # once we fully implement dir layout, we can drop this
13095 umount_client $MOUNT || error "umount failed"
13096 mount_client $MOUNT || error "mount failed"
13098 #set the stripe to be unknown hash type
13099 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13100 $LCTL set_param fail_loc=0x1901
13101 for ((i = 0; i < 10; i++)); do
13102 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13103 error "stat f-$i failed"
13104 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13107 touch $DIR/$tdir/striped_dir/f0 &&
13108 error "create under striped dir with unknown hash should fail"
13110 $LCTL set_param fail_loc=0
13112 umount_client $MOUNT || error "umount failed"
13113 mount_client $MOUNT || error "mount failed"
13117 run_test 300h "client handle unknown hash type striped directory"
13119 test_400a() { # LU-1606, was conf-sanity test_74
13120 local extra_flags=''
13121 local out=$TMP/$tfile
13122 local prefix=/usr/include/lustre
13125 if ! which $CC > /dev/null 2>&1; then
13126 skip_env "$CC is not installed"
13130 if ! [[ -d $prefix ]]; then
13131 # Assume we're running in tree and fixup the include path.
13132 extra_flags+=" -I$LUSTRE/../libcfs/include"
13133 extra_flags+=" -I$LUSTRE/include"
13134 extra_flags+=" -L$LUSTRE/utils"
13137 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13138 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13139 error "client api broken"
13142 run_test 400a "Lustre client api program can compile and link"
13144 test_400b() { # LU-1606, LU-5011
13146 local out=$TMP/$tfile
13147 local prefix=/usr/include/lustre
13149 # We use a hard coded prefix so that this test will not fail
13150 # when run in tree. There are headers in lustre/include/lustre/
13151 # that are not packaged (like lustre_idl.h) and have more
13152 # complicated include dependencies (like config.h and lnet/types.h).
13153 # Since this test about correct packaging we just skip them when
13154 # they don't exist (see below) rather than try to fixup cppflags.
13156 if ! which $CC > /dev/null 2>&1; then
13157 skip_env "$CC is not installed"
13161 for header in $prefix/*.h; do
13162 if ! [[ -f "$header" ]]; then
13166 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13167 continue # liblustreapi.h is deprecated.
13170 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13171 error "cannot compile '$header'"
13174 run_test 400b "packaged headers can be compiled"
13177 # tests that do cleanup/setup should be run at the end
13181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13183 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13184 $LCTL set_param fail_loc=0x903
13185 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
13186 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
13189 FAIL_ON_ERROR=true cleanup
13190 FAIL_ON_ERROR=true setup
13192 run_test 900 "umount should not race with any mgc requeue thread"
13195 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13196 check_and_cleanup_lustre
13197 if [ "$I_MOUNTED" != "yes" ]; then
13198 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true