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-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 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 remote_mds_nodsh && skip "remote MDS with nodsh" && return
562 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
563 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
564 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
566 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
567 skip "only for ldiskfs MDT" && return 0
569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
573 # create a long symlink file
574 for ((i = 0; i < 4; ++i)); do
575 long_sym=${long_sym}${long_sym}
578 echo "create 512 short and long symlink files under $WDIR"
579 for ((i = 0; i < 256; ++i)); do
580 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
581 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
587 wait_delete_completed
589 echo "recreate the 512 symlink files with a shorter string"
590 for ((i = 0; i < 512; ++i)); do
591 # rewrite the symlink file with a shorter string
592 ln -sf ${long_sym} $WDIR/long-$i
593 ln -sf ${short_sym} $WDIR/short-$i
596 mds_index=$($LFS getstripe -M $WDIR)
597 mds_index=$((mds_index+1))
598 devname=$(mdsdevname $mds_index)
599 cmd="$E2FSCK -fnvd $devname"
601 echo "stop and checking mds${mds_index}: $cmd"
602 # e2fsck should not return error
604 do_facet mds${mds_index} $cmd || rc=$?
606 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
607 df $MOUNT > /dev/null 2>&1
608 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
609 "short/long symlink MDT: rc=$rc"
612 run_test 17m "run e2fsck against MDT which contains short/long symlink"
614 check_fs_consistency_17n() {
620 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
621 # so it only check MDT1/MDT2 instead of all of MDTs.
622 for mdt_index in $(seq 1 2); do
623 devname=$(mdsdevname $mdt_index)
624 cmd="$E2FSCK -fnvd $devname"
626 echo "stop and checking mds${mdt_index}: $cmd"
627 # e2fsck should not return error
629 do_facet mds${mdt_index} $cmd || rc=$?
631 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
632 error "mount mds${mdt_index} failed"
633 df $MOUNT > /dev/null 2>&1
634 [ $rc -ne 0 ] && break
642 remote_mds_nodsh && skip "remote MDS with nodsh" && return
643 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
644 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
645 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
647 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
648 skip "only for ldiskfs MDT" && return 0
650 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
652 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
655 for ((i=0; i<10; i++)); do
656 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
657 error "create remote dir error $i"
658 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
659 error "create files under remote dir failed $i"
662 check_fs_consistency_17n ||
663 error "e2fsck report error after create files under remote dir"
665 for ((i=0;i<10;i++)); do
666 rm -rf $DIR/$tdir/remote_dir_${i} ||
667 error "destroy remote dir error $i"
670 check_fs_consistency_17n ||
671 error "e2fsck report error after unlink files under remote dir"
673 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
674 skip "lustre < 2.4.50 does not support migrate mv " && return
676 for ((i=0; i<10; i++)); do
677 mkdir -p $DIR/$tdir/remote_dir_${i}
678 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
679 error "create files under remote dir failed $i"
680 $LFS mv -M 1 $DIR/$tdir/remote_dir_${i} ||
681 error "migrate remote dir error $i"
683 check_fs_consistency_17n || error "e2fsck report error after migration"
685 for ((i=0;i<10;i++)); do
686 rm -rf $DIR/$tdir/remote_dir_${i} ||
687 error "destroy remote dir error $i"
690 check_fs_consistency_17n || error "e2fsck report error after unlink"
692 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
695 remote_mds_nodsh && skip "remote MDS with nodsh" && return
696 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
697 skip "Need MDS version at least 2.3.64" && return
699 local WDIR=$DIR/${tdir}o
705 mdt_index=$($LFS getstripe -M $WDIR)
706 mdt_index=$((mdt_index+1))
707 mdtdevname=$(mdsdevname $mdt_index)
711 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
712 error "mount mds${mdt_index} failed"
714 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
715 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
716 ls -l $WDIR/$tfile && rc=1
717 do_facet mds${mdt_index} lctl set_param fail_loc=0
718 [[ $rc -ne 0 ]] && error "stat file should fail"
721 run_test 17o "stat file with incompat LMA feature"
724 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
725 ls $DIR || error "Failed to ls $DIR: $?"
727 run_test 18 "touch .../f ; ls ... =============================="
733 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
735 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
738 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
740 run_test 19b "ls -l .../f19 (should return error) =============="
743 [ $RUNAS_ID -eq $UID ] &&
744 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
745 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
747 run_test 19c "$RUNAS touch .../f19 (should return error) =="
750 cat $DIR/f19 && error || true
752 run_test 19d "cat .../f19 (should return error) =============="
764 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
766 run_test 20 "touch .../f ; ls -l ... ==========================="
769 test_mkdir -p $DIR/$tdir
770 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
771 ln -s dangle $DIR/$tdir/link
772 echo foo >> $DIR/$tdir/link
773 cat $DIR/$tdir/dangle
774 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
775 $CHECKSTAT -f -t file $DIR/$tdir/link ||
776 error "$tdir/link not linked to a file"
778 run_test 21 "write to dangling link ============================"
782 test_mkdir -p $DIR/$tdir
783 chown $RUNAS_ID:$RUNAS_GID $WDIR
784 (cd $WDIR || error "cd $WDIR failed";
785 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
787 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
788 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
789 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
791 run_test 22 "unpack tar archive as non-root user ==============="
795 test_mkdir -p $DIR/$tdir
796 local file=$DIR/$tdir/$tfile
798 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
799 openfile -f O_CREAT:O_EXCL $file &&
800 error "$file recreate succeeded" || true
802 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
804 test_23b() { # bug 18988
805 test_mkdir -p $DIR/$tdir
806 local file=$DIR/$tdir/$tfile
809 echo foo > $file || error "write filed"
810 echo bar >> $file || error "append filed"
811 $CHECKSTAT -s 8 $file || error "wrong size"
814 run_test 23b "O_APPEND check =========================="
818 echo '-- same directory rename'
819 test_mkdir $DIR/$tdir
820 touch $DIR/$tdir/$tfile.1
821 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
822 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
824 run_test 24a "rename file to non-existent target"
827 test_mkdir $DIR/$tdir
828 touch $DIR/$tdir/$tfile.{1,2}
829 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
830 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
831 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
833 run_test 24b "rename file to existing target"
836 test_mkdir $DIR/$tdir
837 test_mkdir $DIR/$tdir/d$testnum.1
838 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
839 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
840 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
842 run_test 24c "rename directory to non-existent target"
845 test_mkdir -c1 $DIR/$tdir
846 test_mkdir -c1 $DIR/$tdir/d$testnum.1
847 test_mkdir -c1 $DIR/$tdir/d$testnum.2
848 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
849 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
850 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
852 run_test 24d "rename directory to existing target"
855 echo '-- cross directory renames --'
859 mv $DIR/R5a/f $DIR/R5b/g
860 $CHECKSTAT -a $DIR/R5a/f || error
861 $CHECKSTAT -t file $DIR/R5b/g || error
863 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
868 touch $DIR/R6a/f $DIR/R6b/g
869 mv $DIR/R6a/f $DIR/R6b/g
870 $CHECKSTAT -a $DIR/R6a/f || error
871 $CHECKSTAT -t file $DIR/R6b/g || error
873 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
878 test_mkdir $DIR/R7a/d
879 mv $DIR/R7a/d $DIR/R7b/e
880 $CHECKSTAT -a $DIR/R7a/d || error
881 $CHECKSTAT -t dir $DIR/R7b/e || error
883 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
886 test_mkdir -c1 $DIR/R8a
887 test_mkdir -c1 $DIR/R8b
888 test_mkdir -c1 $DIR/R8a/d
889 test_mkdir -c1 $DIR/R8b/e
890 mrename $DIR/R8a/d $DIR/R8b/e
891 $CHECKSTAT -a $DIR/R8a/d || error
892 $CHECKSTAT -t dir $DIR/R8b/e || error
894 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
897 echo "-- rename error cases"
901 mrename $DIR/R9/f $DIR/R9/a
902 $CHECKSTAT -t file $DIR/R9/f || error
903 $CHECKSTAT -t dir $DIR/R9/a || error
904 $CHECKSTAT -a $DIR/R9/a/f || error
906 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
910 mrename $DIR/R10/f $DIR/R10/g
911 $CHECKSTAT -t dir $DIR/R10 || error
912 $CHECKSTAT -a $DIR/R10/f || error
913 $CHECKSTAT -a $DIR/R10/g || error
915 run_test 24j "source does not exist ============================"
919 test_mkdir $DIR/R11a/d
921 mv $DIR/R11a/f $DIR/R11a/d
922 $CHECKSTAT -a $DIR/R11a/f || error
923 $CHECKSTAT -t file $DIR/R11a/d/f || error
925 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
927 # bug 2429 - rename foo foo foo creates invalid file
930 $MULTIOP $f OcNs || error
932 run_test 24l "Renaming a file to itself ========================"
936 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
937 # on ext3 this does not remove either the source or target files
938 # though the "expected" operation would be to remove the source
939 $CHECKSTAT -t file ${f} || error "${f} missing"
940 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
942 run_test 24m "Renaming a file to a hard link to itself ========="
946 # this stats the old file after it was renamed, so it should fail
950 $CHECKSTAT ${f}.rename
953 run_test 24n "Statting the old file after renaming (Posix rename 2)"
956 check_kernel_version 37 || return 0
957 test_mkdir -p $DIR/d24o
958 rename_many -s random -v -n 10 $DIR/d24o
960 run_test 24o "rename of files during htree split ==============="
965 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
966 mrename $DIR/R12a $DIR/R12b
967 $CHECKSTAT -a $DIR/R12a || error
968 $CHECKSTAT -t dir $DIR/R12b || error
969 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
970 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
972 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
974 cleanup_multiop_pause() {
980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
983 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
984 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
987 trap cleanup_multiop_pause EXIT
988 mrename $DIR/R13a $DIR/R13b
989 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
990 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
991 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
992 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
993 cleanup_multiop_pause
994 wait $MULTIPID || error "multiop close failed"
996 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
998 test_24r() { #bug 3789
1000 test_mkdir $DIR/R14a/b
1001 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1002 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1003 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1005 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1008 test_mkdir $DIR/R15a
1009 test_mkdir $DIR/R15a/b
1010 test_mkdir $DIR/R15a/b/c
1011 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1012 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1013 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1015 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1017 test_mkdir $DIR/R16a
1018 test_mkdir $DIR/R16a/b
1019 test_mkdir $DIR/R16a/b/c
1020 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1021 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1022 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1024 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1026 test_24u() { # bug12192
1027 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1028 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1030 run_test 24u "create stripe file"
1036 simple_cleanup_common() {
1039 wait_delete_completed
1042 max_pages_per_rpc() {
1043 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1047 local NRFILES=100000
1048 local FREE_INODES=$(mdt_free_inodes 0)
1049 [[ $FREE_INODES -lt $NRFILES ]] &&
1050 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1054 trap simple_cleanup_common EXIT
1056 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1057 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1060 createmany -m $DIR/$tdir/$tfile $NRFILES
1062 cancel_lru_locks mdc
1063 lctl set_param mdc.*.stats clear
1065 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1067 # LU-5 large readdir
1068 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1069 # 8 bytes for name(filename is mostly 5 in this test) +
1070 # 8 bytes for luda_type
1071 # take into account of overhead in lu_dirpage header and end mark in
1072 # each page, plus one in RPC_NUM calculation.
1074 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1075 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1076 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1077 awk '/^mds_readpage/ {print $2}')
1078 [[ $mds_readpage -gt $RPC_NUM ]] &&
1079 error "large readdir doesn't take effect"
1081 simple_cleanup_common
1083 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1085 test_24w() { # bug21506
1087 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1088 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1089 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1090 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1091 [[ "$SZ1" -eq "$SZ2" ]] ||
1092 error "Error reading at the end of the file $tfile"
1094 run_test 24w "Reading a file larger than 4Gb"
1097 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1100 local remote_dir=$DIR/$tdir/remote_dir
1103 $LFS mkdir -i $MDTIDX $remote_dir ||
1104 error "create remote directory failed"
1106 mkdir -p $DIR/$tdir/src_dir
1107 touch $DIR/$tdir/src_file
1108 mkdir -p $remote_dir/tgt_dir
1109 touch $remote_dir/tgt_file
1111 mrename $remote_dir $DIR/ &&
1112 error "rename dir cross MDT works!"
1114 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1115 error "rename dir cross MDT works!"
1117 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1118 error "rename file cross MDT works!"
1120 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1121 error "ln file cross MDT should not work!"
1123 rm -rf $DIR/$tdir || error "Can not delete directories"
1125 run_test 24x "cross rename/link should be failed"
1128 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1131 local remote_dir=$DIR/$tdir/remote_dir
1134 $LFS mkdir -i $MDTIDX $remote_dir ||
1135 error "create remote directory failed"
1137 mkdir -p $remote_dir/src_dir
1138 touch $remote_dir/src_file
1139 mkdir -p $remote_dir/tgt_dir
1140 touch $remote_dir/tgt_file
1142 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1143 error "rename subdir in the same remote dir failed!"
1145 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1146 error "rename files in the same remote dir failed!"
1148 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1149 error "link files in the same remote dir failed!"
1151 rm -rf $DIR/$tdir || error "Can not delete directories"
1153 run_test 24y "rename/link on the same dir should succeed"
1156 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1159 local remote_src=$DIR/$tdir/remote_dir
1160 local remote_tgt=$DIR/$tdir/remote_tgt
1163 $LFS mkdir -i $MDTIDX $remote_src ||
1164 error "create remote directory failed"
1166 $LFS mkdir -i $MDTIDX $remote_tgt ||
1167 error "create remote directory failed"
1169 mrename $remote_src $remote_tgt &&
1170 error "rename remote dirs should not work!"
1172 # If target dir does not exists, it should succeed
1174 mrename $remote_src $remote_tgt ||
1175 error "rename remote dirs(tgt dir does not exists) failed!"
1177 rm -rf $DIR/$tdir || error "Can not delete directories"
1179 run_test 24z "rename one remote dir to another remote dir should fail"
1181 test_24A() { # LU-3182
1186 createmany -m $DIR/$tdir/$tfile $NFILES
1187 local t=$(ls $DIR/$tdir | wc -l)
1188 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1189 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1190 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1191 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1194 rm -rf $DIR/$tdir || error "Can not delete directories"
1196 run_test 24A "readdir() returns correct number of entries."
1198 test_24B() { # LU-4805
1199 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1203 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1204 error "create striped dir failed"
1206 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1207 [ $count -eq 2 ] || error "Expected 2, got $count"
1209 touch $DIR/$tdir/striped_dir/a
1211 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1212 [ $count -eq 3 ] || error "Expected 3, got $count"
1214 touch $DIR/$tdir/striped_dir/.f
1216 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1217 [ $count -eq 4 ] || error "Expected 4, got $count"
1219 rm -rf $DIR/$tdir || error "Can not delete directories"
1221 run_test 24B "readdir for striped dir return correct number of entries"
1224 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1230 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1231 error "create striped dir failed"
1233 cd $DIR/$tdir/d0/striped_dir
1235 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1236 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1237 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1239 [ "$d0_ino" = "$parent_ino" ] ||
1240 error ".. wrong, expect $d0_ino, get $parent_ino"
1242 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1243 error "mv striped dir failed"
1245 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1247 [ "$d1_ino" = "$parent_ino" ] ||
1248 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1250 run_test 24C "check .. in striped dir"
1253 echo '== symlink sanity ============================================='
1257 touch $DIR/s25/foo || error
1259 run_test 25a "create file in symlinked directory ==============="
1262 [ ! -d $DIR/d25 ] && test_25a
1263 $CHECKSTAT -t file $DIR/s25/foo || error
1265 run_test 25b "lookup file in symlinked directory ==============="
1269 test_mkdir $DIR/d26/d26-2
1270 ln -s d26/d26-2 $DIR/s26
1271 touch $DIR/s26/foo || error
1273 run_test 26a "multiple component symlink ======================="
1276 test_mkdir -p $DIR/d26b/d26-2
1277 ln -s d26b/d26-2/foo $DIR/s26-2
1278 touch $DIR/s26-2 || error
1280 run_test 26b "multiple component symlink at end of lookup ======"
1283 test_mkdir $DIR/d26.2
1284 touch $DIR/d26.2/foo
1285 ln -s d26.2 $DIR/s26.2-1
1286 ln -s s26.2-1 $DIR/s26.2-2
1287 ln -s s26.2-2 $DIR/s26.2-3
1288 chmod 0666 $DIR/s26.2-3/foo
1290 run_test 26c "chain of symlinks ================================"
1292 # recursive symlinks (bug 439)
1294 ln -s d26-3/foo $DIR/d26-3
1296 run_test 26d "create multiple component recursive symlink ======"
1299 [ ! -h $DIR/d26-3 ] && test_26d
1302 run_test 26e "unlink multiple component recursive symlink ======"
1304 # recursive symlinks (bug 7022)
1306 test_mkdir -p $DIR/$tdir
1307 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1308 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1309 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1310 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1311 cd $tfile || error "cd $tfile failed"
1312 ln -s .. dotdot || error "ln dotdot failed"
1313 ln -s dotdot/lndir lndir || error "ln lndir failed"
1314 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1315 output=`ls $tfile/$tfile/lndir/bar1`
1316 [ "$output" = bar1 ] && error "unexpected output"
1317 rm -r $tfile || error "rm $tfile failed"
1318 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1320 run_test 26f "rm -r of a directory which has recursive symlink ="
1323 echo '== stripe sanity =============================================='
1324 test_mkdir -p $DIR/d27 || error "mkdir failed"
1326 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1327 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1328 log "== test_27a: write to one stripe file ========================="
1329 cp /etc/hosts $DIR/d27/f0 || error
1331 run_test 27a "one stripe file =================================="
1334 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1335 test_mkdir -p $DIR/d27
1336 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1337 $GETSTRIPE -c $DIR/d27/f01
1338 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1339 error "two-stripe file doesn't have two stripes"
1341 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1343 run_test 27b "create and write to two stripe file"
1346 test_mkdir -p $DIR/d27
1347 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1348 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1349 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1351 run_test 27d "create file with default settings ================"
1354 test_mkdir -p $DIR/d27
1355 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1356 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1357 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1359 run_test 27e "setstripe existing file (should return error) ======"
1362 test_mkdir $DIR/$tdir
1363 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1364 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1365 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1366 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1367 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1368 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1370 run_test 27f "setstripe with bad stripe size (should return error)"
1373 test_mkdir -p $DIR/d27
1374 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1375 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1376 error "$DIR/d27/fnone has object"
1378 run_test 27g "$GETSTRIPE with no objects"
1381 touch $DIR/d27/fsome || error "touch failed"
1382 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1384 run_test 27i "$GETSTRIPE with some objects"
1387 test_mkdir -p $DIR/d27
1388 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1390 run_test 27j "setstripe with bad stripe offset (should return error)"
1392 test_27k() { # bug 2844
1393 test_mkdir -p $DIR/d27
1395 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1396 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1397 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1398 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1399 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1400 dd if=/dev/zero of=$FILE bs=4k count=1
1401 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1402 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1404 run_test 27k "limit i_blksize for broken user apps ============="
1407 test_mkdir -p $DIR/d27
1408 mcreate $DIR/f27l || error "creating file"
1409 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1410 error "setstripe should have failed" || true
1412 run_test 27l "check setstripe permissions (should return error)"
1415 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1417 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1418 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1421 trap simple_cleanup_common EXIT
1422 test_mkdir -p $DIR/$tdir
1423 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1424 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1425 error "dd should fill OST0"
1427 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1429 [ $i -gt 256 ] && break
1432 touch $DIR/$tdir/f27m_$i
1433 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1434 error "OST0 was full but new created file still use it"
1436 touch $DIR/$tdir/f27m_$i
1437 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1438 error "OST0 was full but new created file still use it"
1439 simple_cleanup_common
1441 run_test 27m "create file while OST0 was full =================="
1444 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1448 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1449 # if the OST isn't full anymore.
1451 local OSTIDX=${1:-""}
1453 local list=$(comma_list $(osts_nodes))
1454 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1456 do_nodes $list lctl set_param fail_loc=0
1457 sync # initiate all OST_DESTROYs from MDS to OST
1461 exhaust_precreations() {
1464 local FAILIDX=${3:-$OSTIDX}
1466 test_mkdir -p $DIR/$tdir
1467 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1468 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1470 local OST=$(ostname_from_index $OSTIDX)
1471 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1472 sed -e 's/_UUID$//;s/^.*-//')
1475 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1476 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1477 osc.$mdtosc_proc1.prealloc_last_id)
1478 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1479 osc.$mdtosc_proc1.prealloc_next_id)
1481 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1482 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1484 test_mkdir -p $DIR/$tdir/${OST}
1485 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1486 #define OBD_FAIL_OST_ENOSPC 0x215
1487 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1488 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1489 echo "Creating to objid $last_id on ost $OST..."
1490 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1491 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1492 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1496 exhaust_all_precreations() {
1498 for (( i=0; i < OSTCOUNT; i++ )) ; do
1499 exhaust_precreations $i $1 -1
1504 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1506 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1507 remote_ost_nodsh && skip "remote OST with nodsh" && return
1510 rm -f $DIR/$tdir/$tfile
1511 exhaust_precreations 0 0x80000215
1512 $SETSTRIPE -c -1 $DIR/$tdir
1513 touch $DIR/$tdir/$tfile || error
1514 $GETSTRIPE $DIR/$tdir/$tfile
1517 run_test 27n "create file with some full OSTs =================="
1520 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1522 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1523 remote_ost_nodsh && skip "remote OST with nodsh" && return
1526 rm -f $DIR/$tdir/$tfile
1527 exhaust_all_precreations 0x215
1529 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1534 run_test 27o "create file with all full OSTs (should error) ===="
1537 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1539 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1540 remote_ost_nodsh && skip "remote OST with nodsh" && return
1543 rm -f $DIR/$tdir/$tfile
1544 test_mkdir -p $DIR/$tdir
1546 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1547 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1548 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1550 exhaust_precreations 0 0x80000215
1551 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1552 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1553 $GETSTRIPE $DIR/$tdir/$tfile
1557 run_test 27p "append to a truncated file with some full OSTs ==="
1560 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1562 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1563 remote_ost_nodsh && skip "remote OST with nodsh" && return
1566 rm -f $DIR/$tdir/$tfile
1568 test_mkdir -p $DIR/$tdir
1569 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1570 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1571 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1573 exhaust_all_precreations 0x215
1575 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1576 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1580 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1583 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1585 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1586 remote_ost_nodsh && skip "remote OST with nodsh" && return
1589 rm -f $DIR/$tdir/$tfile
1590 exhaust_precreations 0 0x80000215
1592 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1596 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1598 test_27s() { # bug 10725
1599 test_mkdir -p $DIR/$tdir
1600 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1601 local stripe_count=0
1602 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1603 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1604 error "stripe width >= 2^32 succeeded" || true
1607 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1609 test_27t() { # bug 10864
1614 $WLFS getstripe $tfile
1617 run_test 27t "check that utils parse path correctly"
1619 test_27u() { # bug 4900
1620 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1621 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1623 local list=$(comma_list $(mdts_nodes))
1625 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1626 do_nodes $list $LCTL set_param fail_loc=0x139
1627 test_mkdir -p $DIR/$tdir
1629 createmany -o $DIR/$tdir/t- 1000
1630 do_nodes $list $LCTL set_param fail_loc=0
1632 TLOG=$DIR/$tfile.getstripe
1633 $GETSTRIPE $DIR/$tdir > $TLOG
1634 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1635 unlinkmany $DIR/$tdir/t- 1000
1636 [[ $OBJS -gt 0 ]] &&
1637 error "$OBJS objects created on OST-0. See $TLOG" || pass
1639 run_test 27u "skip object creation on OSC w/o objects =========="
1641 test_27v() { # bug 4900
1642 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1645 remote_ost_nodsh && skip "remote OST with nodsh" && return
1647 exhaust_all_precreations 0x215
1650 test_mkdir -p $DIR/$tdir
1651 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1653 touch $DIR/$tdir/$tfile
1654 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1656 for (( i=1; i < OSTCOUNT; i++ )); do
1657 do_facet ost$i lctl set_param fail_loc=0x705
1659 local START=`date +%s`
1660 createmany -o $DIR/$tdir/$tfile 32
1662 local FINISH=`date +%s`
1663 local TIMEOUT=`lctl get_param -n timeout`
1664 local PROCESS=$((FINISH - START))
1665 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1666 error "$FINISH - $START >= $TIMEOUT / 2"
1667 sleep $((TIMEOUT / 2 - PROCESS))
1670 run_test 27v "skip object creation on slow OST ================="
1672 test_27w() { # bug 10997
1673 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1674 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1675 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1676 error "stripe size $size != 65536" || true
1677 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1678 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1680 run_test 27w "check $SETSTRIPE -S option"
1683 [[ $OSTCOUNT -lt 2 ]] &&
1684 skip_env "skipping multiple stripe count/offset test" && return
1686 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1687 for i in $(seq 1 $OSTCOUNT); do
1689 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1690 error "setstripe -c $i -i $offset failed"
1691 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1692 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1693 [ $count -ne $i ] && error "stripe count $count != $i" || true
1694 [ $index -ne $offset ] &&
1695 error "stripe offset $index != $offset" || true
1698 run_test 27wa "check $SETSTRIPE -c -i options"
1701 remote_ost_nodsh && skip "remote OST with nodsh" && return
1702 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1703 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1704 OFFSET=$(($OSTCOUNT - 1))
1706 local OST=$(ostname_from_index $OSTIDX)
1708 test_mkdir -p $DIR/$tdir
1709 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1710 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1712 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1713 for i in `seq 0 $OFFSET`; do
1714 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1715 error "OST0 was degraded but new created file still use it"
1717 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1719 run_test 27x "create files while OST0 is degraded"
1722 [[ $OSTCOUNT -lt 2 ]] &&
1723 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1724 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1725 remote_ost_nodsh && skip "remote OST with nodsh" && return
1726 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1728 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1729 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1730 osc.$mdtosc.prealloc_last_id)
1731 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1732 osc.$mdtosc.prealloc_next_id)
1733 local fcount=$((last_id - next_id))
1734 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1735 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1737 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1738 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1739 local OST_DEACTIVE_IDX=-1
1744 for OSC in $MDS_OSCS; do
1745 OST=$(osc_to_ost $OSC)
1746 OSTIDX=$(index_from_ostuuid $OST)
1747 if [ $OST_DEACTIVE_IDX == -1 ]; then
1748 OST_DEACTIVE_IDX=$OSTIDX
1750 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1751 echo $OSC "is Deactivated:"
1752 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1756 OSTIDX=$(index_from_ostuuid $OST)
1758 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1760 for OSC in $MDS_OSCS; do
1761 OST=$(osc_to_ost $OSC)
1762 OSTIDX=$(index_from_ostuuid $OST)
1763 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1764 echo $OST "is degraded:"
1765 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1766 obdfilter.$OST.degraded=1
1771 createmany -o $DIR/$tdir/$tfile $fcount
1773 for OSC in $MDS_OSCS; do
1774 OST=$(osc_to_ost $OSC)
1775 OSTIDX=$(index_from_ostuuid $OST)
1776 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1777 echo $OST "is recovered from degraded:"
1778 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1779 obdfilter.$OST.degraded=0
1781 do_facet $SINGLEMDS lctl --device %$OSC activate
1785 # all osp devices get activated, hence -1 stripe count restored
1788 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1789 # devices get activated.
1791 $SETSTRIPE -c -1 $DIR/$tfile
1792 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1794 [ $stripecnt -ne $OSTCOUNT ] &&
1795 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1798 run_test 27y "create files while OST0 is degraded and the rest inactive"
1804 lmm_count=$($GETSTRIPE -c $1)
1805 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1806 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1808 local old_ifs="$IFS"
1810 fid=($($LFS path2fid $1))
1813 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1814 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1816 # compare lmm_seq and lu_fid->f_seq
1817 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1818 # compare lmm_object_id and lu_fid->oid
1819 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1821 # check the trusted.fid attribute of the OST objects of the file
1822 local have_obdidx=false
1824 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1825 # skip lines up to and including "obdidx"
1826 [ -z "$obdidx" ] && break
1827 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1828 $have_obdidx || continue
1830 local ost=$((obdidx + 1))
1831 local dev=$(ostdevname $ost)
1834 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1836 seq=$(echo $seq | sed -e "s/^0x//g")
1837 if [ $seq == 0 ]; then
1838 oid_hex=$(echo $oid)
1840 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1842 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1846 # Don't unmount/remount the OSTs if we don't need to do that.
1847 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1848 # update too, until that use mount/ll_decode_filter_fid/mount.
1849 # Re-enable when debugfs will understand new filter_fid.
1851 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1852 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1853 $dev 2>/dev/null" | grep "parent=")
1856 mount_fstype ost$ost
1857 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1858 $(facet_mntpt ost$ost)/$obj_file)
1859 unmount_fstype ost$ost
1860 start ost$ost $dev $OST_MOUNT_OPTS
1863 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1865 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1867 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1868 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1869 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1870 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1871 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1873 if echo $ff_parent | grep -q 'stripe='; then
1874 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1877 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1878 # into f_ver in this case. See the comment on
1881 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1885 # compare lmm_seq and filter_fid->ff_parent.f_seq
1886 [ $ff_pseq = $lmm_seq ] ||
1887 error "FF parent SEQ $ff_pseq != $lmm_seq"
1888 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1889 [ $ff_poid = $lmm_oid ] ||
1890 error "FF parent OID $ff_poid != $lmm_oid"
1891 (($ff_pstripe == $stripe_nr)) ||
1892 error "FF stripe $ff_pstripe != $stripe_nr"
1894 stripe_nr=$((stripe_nr + 1))
1899 remote_ost_nodsh && skip "remote OST with nodsh" && return
1900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1901 test_mkdir -p $DIR/$tdir
1903 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1904 { error "setstripe -c -1 failed"; return 1; }
1905 # We need to send a write to every object to get parent FID info set.
1906 # This _should_ also work for setattr, but does not currently.
1907 # touch $DIR/$tdir/$tfile-1 ||
1908 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1909 { error "dd $tfile-1 failed"; return 2; }
1910 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1911 { error "setstripe -c -1 failed"; return 3; }
1912 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1913 { error "dd $tfile-2 failed"; return 4; }
1915 # make sure write RPCs have been sent to OSTs
1918 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1919 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1921 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1923 test_27A() { # b=19102
1924 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1925 local restore_size=$($GETSTRIPE -S $MOUNT)
1926 local restore_count=$($GETSTRIPE -c $MOUNT)
1927 local restore_offset=$($GETSTRIPE -i $MOUNT)
1928 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1929 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1930 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1931 local default_size=$($GETSTRIPE -S $MOUNT)
1932 local default_offset=$($GETSTRIPE -i $MOUNT)
1933 local dsize=$((1024 * 1024))
1934 [ $default_size -eq $dsize ] ||
1935 error "stripe size $default_size != $dsize"
1936 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1937 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1939 run_test 27A "check filesystem-wide default LOV EA values"
1941 test_27B() { # LU-2523
1942 test_mkdir -p $DIR/$tdir
1943 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
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:nB1c \
1953 # open f1 with O_LOV_DELAY_CREATE
1955 # call setstripe ioctl on open file descriptor for f1
1957 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1959 # Allow multiop to fail in imitation of NFS's busted semantics.
1962 run_test 27B "call setstripe on open unlinked file/rename victim"
1964 test_27C() { #LU-2871
1965 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1973 test_mkdir -p $DIR/$tdir
1975 for i in $(seq 0 $((OSTCOUNT - 1))); do
1976 # set stripe across all OSTs starting from OST$i
1977 $SETSTRIPE -i $i -c -1 $tfile$i
1978 # get striping information
1979 ost_idx=($($GETSTRIPE $tfile$i |
1980 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1984 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1985 error "${#ost_idx[@]} != $OSTCOUNT"
1987 for index in $(seq 0 $((OSTCOUNT - 1))); do
1989 for j in $(echo ${ost_idx[@]}); do
1990 if [ $index -eq $j ]; then
1996 error "Can not find $index in ${ost_idx[@]}"
2000 run_test 27C "check full striping across all OSTs"
2003 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2004 local POOL=${POOL:-testpool}
2006 local last_ost=$(($OSTCOUNT - 1))
2008 local ost_list=$(seq $first_ost $ost_step $last_ost)
2009 local ost_range="$first_ost $last_ost $ost_step"
2012 pool_add $POOL || error "pool_add failed"
2013 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2014 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2015 error "llapi_layout_test failed"
2016 cleanup_pools || error "cleanup_pools failed"
2018 run_test 27D "validate llapi_layout API"
2020 # createtest also checks that device nodes are created and
2021 # then visible correctly (#2091)
2022 test_28() { # bug 2091
2024 $CREATETEST $DIR/d28/ct || error
2026 run_test 28 "create/mknod/mkdir with bad file types ============"
2029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2030 cancel_lru_locks mdc
2036 declare -i LOCKCOUNTORIG=0
2037 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2038 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2040 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2042 declare -i LOCKUNUSEDCOUNTORIG=0
2043 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2044 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2051 declare -i LOCKCOUNTCURRENT=0
2052 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2053 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2056 declare -i LOCKUNUSEDCOUNTCURRENT=0
2057 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2058 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2061 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2062 $LCTL set_param -n ldlm.dump_namespaces ""
2063 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2064 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2065 log "dumped log to $TMP/test_29.dk (bug 5793)"
2068 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2069 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2070 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2071 log "dumped log to $TMP/test_29.dk (bug 5793)"
2075 run_test 29 "IT_GETATTR regression ============================"
2077 test_30a() { # was test_30
2078 cp $(which ls) $DIR || cp /bin/ls $DIR
2082 run_test 30a "execute binary from Lustre (execve) =============="
2085 cp `which ls` $DIR || cp /bin/ls $DIR
2087 $RUNAS $DIR/ls / || error
2090 run_test 30b "execute binary from Lustre as non-root ==========="
2092 test_30c() { # b=22376
2093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2094 cp `which ls` $DIR || cp /bin/ls $DIR
2096 cancel_lru_locks mdc
2097 cancel_lru_locks osc
2098 $RUNAS $DIR/ls / || error
2101 run_test 30c "execute binary from Lustre without read perms ===="
2104 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2105 $CHECKSTAT -a $DIR/f31 || error
2107 run_test 31a "open-unlink file =================================="
2110 touch $DIR/f31 || error
2111 ln $DIR/f31 $DIR/f31b || error
2112 $MULTIOP $DIR/f31b Ouc || error
2113 $CHECKSTAT -t file $DIR/f31 || error
2115 run_test 31b "unlink file with multiple links while open ======="
2118 touch $DIR/f31 || error
2119 ln $DIR/f31 $DIR/f31c || error
2120 multiop_bg_pause $DIR/f31 O_uc || return 1
2122 $MULTIOP $DIR/f31c Ouc
2123 kill -USR1 $MULTIPID
2126 run_test 31c "open-unlink file with multiple links ============="
2129 opendirunlink $DIR/d31d $DIR/d31d || error
2130 $CHECKSTAT -a $DIR/d31d || error
2132 run_test 31d "remove of open directory ========================="
2134 test_31e() { # bug 2904
2135 check_kernel_version 34 || return 0
2136 openfilleddirunlink $DIR/d31e || error
2138 run_test 31e "remove of open non-empty directory ==============="
2140 test_31f() { # bug 4554
2141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2143 test_mkdir $DIR/d31f
2144 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2145 cp /etc/hosts $DIR/d31f
2147 $GETSTRIPE $DIR/d31f/hosts
2148 multiop_bg_pause $DIR/d31f D_c || return 1
2151 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2152 test_mkdir $DIR/d31f
2153 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2154 cp /etc/hosts $DIR/d31f
2156 $GETSTRIPE $DIR/d31f/hosts
2157 multiop_bg_pause $DIR/d31f D_c || return 1
2160 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2161 wait $MULTIPID || error "first opendir $MULTIPID failed"
2165 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2166 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2169 run_test 31f "remove of open directory with open-unlink file ==="
2172 echo "-- cross directory link --"
2173 test_mkdir -c1 $DIR/${tdir}ga
2174 test_mkdir -c1 $DIR/${tdir}gb
2175 touch $DIR/${tdir}ga/f
2176 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2177 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2178 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2179 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2180 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2182 run_test 31g "cross directory link==============="
2185 echo "-- cross directory link --"
2186 test_mkdir -c1 $DIR/${tdir}
2187 test_mkdir -c1 $DIR/${tdir}/dir
2188 touch $DIR/${tdir}/f
2189 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2190 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2191 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2192 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2193 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2195 run_test 31h "cross directory link under child==============="
2198 echo "-- cross directory link --"
2199 test_mkdir -c1 $DIR/$tdir
2200 test_mkdir -c1 $DIR/$tdir/dir
2201 touch $DIR/$tdir/dir/f
2202 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2203 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2204 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2205 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2206 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2208 run_test 31i "cross directory link under parent==============="
2211 test_mkdir -c1 -p $DIR/$tdir
2212 test_mkdir -c1 -p $DIR/$tdir/dir1
2213 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2214 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2215 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2216 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2219 run_test 31j "link for directory==============="
2222 test_mkdir -c1 -p $DIR/$tdir
2224 touch $DIR/$tdir/exist
2225 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2226 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2227 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2228 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2229 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2230 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2231 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2234 run_test 31k "link to file: the same, non-existing, dir==============="
2240 touch $DIR/d31m2/exist
2241 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2242 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2243 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2244 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2245 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2246 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2249 run_test 31m "link to file: the same, non-existing, dir==============="
2252 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2253 nlink=$(stat --format=%h $DIR/$tfile)
2254 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2256 local cmd="exec $fd<$DIR/$tfile"
2259 trap "eval $cmd" EXIT
2260 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2261 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2262 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2263 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2264 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2267 run_test 31n "check link count of unlinked file"
2270 local TEMPNAME=$(mktemp $1_XXXXXX)
2271 mlink $TEMPNAME $1 2> /dev/null &&
2272 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2276 test_31o() { # LU-2901
2278 for LOOP in $(seq 100); do
2279 rm -f $DIR/$tdir/$tfile*
2280 for THREAD in $(seq 8); do
2281 link_one $DIR/$tdir/$tfile.$LOOP &
2284 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2285 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2286 error "$LINKS duplicate links to $tfile.$LOOP" &&
2290 run_test 31o "duplicate hard links with same filename"
2293 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2296 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2297 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2299 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2300 error "open unlink test1 failed"
2301 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2302 error "open unlink test2 failed"
2304 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2305 error "test1 still exists"
2306 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2307 error "test2 still exists"
2309 run_test 31p "remove of open striped directory"
2311 cleanup_test32_mount() {
2313 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2318 echo "== more mountpoints and symlinks ================="
2319 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2320 trap cleanup_test32_mount EXIT
2321 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2322 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2323 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2324 cleanup_test32_mount
2326 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2330 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2331 trap cleanup_test32_mount EXIT
2332 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2333 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2334 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2335 cleanup_test32_mount
2337 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2341 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2342 trap cleanup_test32_mount EXIT
2343 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2344 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2345 test_mkdir -p $DIR/$tdir/d2/test_dir
2346 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2347 cleanup_test32_mount
2349 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2353 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2354 trap cleanup_test32_mount EXIT
2355 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2356 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2357 test_mkdir -p $DIR/$tdir/d2/test_dir
2358 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2359 cleanup_test32_mount
2361 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2364 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2365 test_mkdir -p $DIR/d32e/tmp
2366 TMP_DIR=$DIR/d32e/tmp
2367 ln -s $DIR/d32e $TMP_DIR/symlink11
2368 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2369 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2370 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2372 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2375 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2376 test_mkdir -p $DIR/d32f/tmp
2377 TMP_DIR=$DIR/d32f/tmp
2378 ln -s $DIR/d32f $TMP_DIR/symlink11
2379 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2380 ls $DIR/d32f/tmp/symlink11 || error
2381 ls $DIR/d32f/symlink01 || error
2383 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2386 TMP_DIR=$DIR/$tdir/tmp
2387 test_mkdir -p $DIR/$tdir/tmp
2388 test_mkdir $DIR/${tdir}2
2389 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2390 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2391 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2392 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2393 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2394 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2396 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2399 rm -fr $DIR/$tdir $DIR/${tdir}2
2400 TMP_DIR=$DIR/$tdir/tmp
2401 test_mkdir -p $DIR/$tdir/tmp
2402 test_mkdir $DIR/${tdir}2
2403 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2404 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2405 ls $TMP_DIR/symlink12 || error
2406 ls $DIR/$tdir/symlink02 || error
2408 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2412 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2413 trap cleanup_test32_mount EXIT
2414 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2415 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2416 touch $DIR/$tdir/test_file
2417 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2418 cleanup_test32_mount
2420 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2424 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2425 trap cleanup_test32_mount EXIT
2426 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2427 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2428 touch $DIR/$tdir/test_file
2429 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2430 cleanup_test32_mount
2432 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2435 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2437 trap cleanup_test32_mount EXIT
2438 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2439 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2440 test_mkdir -p $DIR/$tdir/d2
2441 touch $DIR/$tdir/d2/test_file || error
2442 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2443 cleanup_test32_mount
2445 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2448 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2450 trap cleanup_test32_mount EXIT
2451 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2452 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2453 test_mkdir -p $DIR/$tdir/d2
2454 touch $DIR/$tdir/d2/test_file
2455 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2456 cleanup_test32_mount
2458 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2462 test_mkdir -p $DIR/d32m/tmp
2463 TMP_DIR=$DIR/d32m/tmp
2464 ln -s $DIR $TMP_DIR/symlink11
2465 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2466 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2467 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2469 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2473 test_mkdir -p $DIR/d32n/tmp
2474 TMP_DIR=$DIR/d32n/tmp
2475 ln -s $DIR $TMP_DIR/symlink11
2476 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2477 ls -l $DIR/d32n/tmp/symlink11 || error
2478 ls -l $DIR/d32n/symlink01 || error
2480 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2484 test_mkdir -p $DIR/d32o/tmp
2485 TMP_DIR=$DIR/d32o/tmp
2486 ln -s $DIR/$tfile $TMP_DIR/symlink12
2487 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2488 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2489 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2490 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2491 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2493 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2503 test_mkdir -p $DIR/d32p/tmp
2505 TMP_DIR=$DIR/d32p/tmp
2507 ln -s $DIR/$tfile $TMP_DIR/symlink12
2509 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2511 cat $DIR/d32p/tmp/symlink12 || error
2513 cat $DIR/d32p/symlink02 || error
2516 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2518 cleanup_testdir_mount() {
2520 $UMOUNT -d $DIR/$tdir
2524 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2525 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2526 trap cleanup_testdir_mount EXIT
2527 test_mkdir -p $DIR/$tdir
2528 touch $DIR/$tdir/under_the_mount
2529 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2530 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2531 cleanup_testdir_mount
2533 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2536 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2537 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2538 trap cleanup_testdir_mount EXIT
2539 test_mkdir -p $DIR/$tdir
2540 touch $DIR/$tdir/under_the_mount
2541 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2542 ls $DIR/$tdir | grep -q under_the_mount && error || true
2543 cleanup_testdir_mount
2545 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2550 chmod 444 $DIR/$tfile
2551 chown $RUNAS_ID $DIR/$tfile
2553 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2556 run_test 33aa "write file with mode 444 (should return error) ===="
2560 test_mkdir -p $DIR/d33
2561 chown $RUNAS_ID $DIR/d33
2562 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2563 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2564 error "open RDWR" || true
2566 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2570 test_mkdir -p $DIR/d33
2571 chown $RUNAS_ID $DIR/d33
2572 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2574 run_test 33b "test open file with malformed flags (No panic)"
2577 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2583 remote_ost_nodsh && skip "remote OST with nodsh" && return
2586 test_mkdir -p $DIR/d33
2587 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2590 for ostnum in $(seq $OSTCOUNT); do
2591 # test-framework's OST numbering is one-based, while Lustre's
2593 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2594 # Parsing llobdstat's output sucks; we could grep the /proc
2595 # path, but that's likely to not be as portable as using the
2596 # llobdstat utility. So we parse lctl output instead.
2597 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2598 obdfilter/$ostname/stats |
2599 awk '/^write_bytes/ {print $7}' )
2600 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2601 if (( ${write_bytes:-0} > 0 ))
2608 $all_zeros || return 0
2611 echo foo > $DIR/d33/bar
2615 # Total up write_bytes after writing. We'd better find non-zeros.
2616 for ostnum in $(seq $OSTCOUNT); do
2617 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2618 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2619 obdfilter/$ostname/stats |
2620 awk '/^write_bytes/ {print $7}' )
2621 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2622 if (( ${write_bytes:-0} > 0 ))
2631 for ostnum in $(seq $OSTCOUNT); do
2632 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2633 echo "Check that write_bytes is present in obdfilter/*/stats:"
2634 do_facet ost$ostnum lctl get_param -n \
2635 obdfilter/$ostname/stats
2637 error "OST not keeping write_bytes stats (b22312)"
2640 run_test 33c "test llobdstat and write_bytes"
2643 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2644 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2646 local remote_dir=$DIR/$tdir/remote_dir
2649 $LFS mkdir -i $MDTIDX $remote_dir ||
2650 error "create remote directory failed"
2652 touch $remote_dir/$tfile
2653 chmod 444 $remote_dir/$tfile
2654 chown $RUNAS_ID $remote_dir/$tfile
2656 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2658 chown $RUNAS_ID $remote_dir
2659 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2660 error "create" || true
2661 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2662 error "open RDWR" || true
2663 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2664 error "create" || true
2666 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2669 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2673 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2674 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2675 mkdir $DIR/$tdir/local_dir
2677 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2678 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2679 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2681 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2682 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2684 rmdir $DIR/$tdir/* || error "rmdir failed"
2687 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2688 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2689 mkdir $DIR/$tdir/local_dir
2691 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2692 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2693 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2695 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2696 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2698 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2701 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2702 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2703 mkdir $DIR/$tdir/local_dir
2705 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2706 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2707 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2709 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2710 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2712 run_test 33e "mkdir and striped directory should have same mode"
2714 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2717 $MCREATE $DIR/f34 || error
2718 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2719 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2720 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2721 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2723 run_test 34a "truncate file that has not been opened ==========="
2726 [ ! -f $DIR/f34 ] && test_34a
2727 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2728 $OPENFILE -f O_RDONLY $DIR/f34
2729 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2730 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2732 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2735 [ ! -f $DIR/f34 ] && test_34a
2736 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2737 $OPENFILE -f O_RDWR $DIR/f34
2738 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2739 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2741 run_test 34c "O_RDWR opening file-with-size works =============="
2744 [ ! -f $DIR/f34 ] && test_34a
2745 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2746 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2749 run_test 34d "write to sparse file ============================="
2753 $MCREATE $DIR/f34e || error
2754 $TRUNCATE $DIR/f34e 1000 || error
2755 $CHECKSTAT -s 1000 $DIR/f34e || error
2756 $OPENFILE -f O_RDWR $DIR/f34e
2757 $CHECKSTAT -s 1000 $DIR/f34e || error
2759 run_test 34e "create objects, some with size and some without =="
2761 test_34f() { # bug 6242, 6243
2762 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2765 $MCREATE $DIR/f34f || error
2766 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2767 dd if=$DIR/f34f of=$TMP/f34f
2768 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2769 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2770 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2771 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2772 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2774 run_test 34f "read from a file with no objects until EOF ======="
2777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2778 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2779 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2780 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2781 cancel_lru_locks osc
2782 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2783 error "wrong size after lock cancel"
2785 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2786 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2787 error "expanding truncate failed"
2788 cancel_lru_locks osc
2789 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2790 error "wrong expanded size after lock cancel"
2792 run_test 34g "truncate long file ==============================="
2795 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2799 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2800 sync # Flush the cache so that multiop below does not block on cache
2801 # flush when getting the group lock
2802 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2805 # Since just timed wait is not good enough, let's do a sync write
2806 # that way we are sure enough time for a roundtrip + processing
2807 # passed + 2 seconds of extra margin.
2808 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2812 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2813 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2817 local nsz=`stat -c %s $DIR/$tfile`
2818 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2820 run_test 34h "ftruncate file under grouplock should not block"
2823 cp /bin/sh $DIR/f35a
2825 chown $RUNAS_ID $DIR/f35a
2826 $RUNAS $DIR/f35a && error || true
2829 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2833 utime $DIR/f36 || error
2835 run_test 36a "MDS utime check (mknod, utime) ==================="
2839 utime $DIR/f36 || error
2841 run_test 36b "OST utime check (open, utime) ===================="
2846 chown $RUNAS_ID $DIR/d36
2847 $RUNAS utime $DIR/d36/f36 || error
2849 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2852 [ ! -d $DIR/d36 ] && test_36c
2853 echo "" > $DIR/d36/f36
2854 $RUNAS utime $DIR/d36/f36 || error
2856 run_test 36d "non-root OST utime check (open, utime) ==========="
2859 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2860 test_mkdir -p $DIR/$tdir
2861 touch $DIR/$tdir/$tfile
2862 $RUNAS utime $DIR/$tdir/$tfile && \
2863 error "utime worked, expected failure" || true
2865 run_test 36e "utime on non-owned file (should return error) ===="
2869 local LANG_SAVE=$LANG
2870 local LC_LANG_SAVE=$LC_LANG
2871 export LANG=C LC_LANG=C # for date language
2873 DATESTR="Dec 20 2000"
2874 test_mkdir -p $DIR/$tdir
2875 lctl set_param fail_loc=$fl
2877 cp /etc/hosts $DIR/$tdir/$tfile
2878 sync & # write RPC generated with "current" inode timestamp, but delayed
2880 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2881 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2882 cancel_lru_locks osc
2883 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2885 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2886 echo "BEFORE: $LS_BEFORE" && \
2887 echo "AFTER : $LS_AFTER" && \
2888 echo "WANT : $DATESTR" && \
2889 error "$DIR/$tdir/$tfile timestamps changed" || true
2891 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2896 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2897 subr_36fh "0x80000214"
2899 run_test 36f "utime on file racing with OST BRW write =========="
2902 remote_ost_nodsh && skip "remote OST with nodsh" && return
2903 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2908 test_mkdir -p $DIR/$tdir
2909 fmd_max_age=$(do_facet ost1 \
2910 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2913 fmd_before=$(do_facet ost1 \
2914 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2915 touch $DIR/$tdir/$tfile
2916 sleep $((fmd_max_age + 12))
2917 fmd_after=$(do_facet ost1 \
2918 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2920 echo "fmd_before: $fmd_before"
2921 echo "fmd_after: $fmd_after"
2922 [[ $fmd_after -gt $fmd_before ]] &&
2923 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2924 error "fmd didn't expire after ping" || true
2926 run_test 36g "filter mod data cache expiry ====================="
2929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2930 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2931 subr_36fh "0x80000227"
2933 run_test 36h "utime on file racing with OST BRW write =========="
2936 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2939 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2941 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2942 local new_mtime=$((mtime + 200))
2944 #change Modify time of striped dir
2945 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2946 error "change mtime failed"
2948 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2950 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2952 run_test 36i "change mtime on striped directory"
2954 # test_37 - duplicate with tests 32q 32r
2957 local file=$DIR/$tfile
2959 openfile -f O_DIRECTORY $file
2962 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2963 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2965 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2969 touch $DIR/${tfile}2
2970 # ls -l $DIR/$tfile $DIR/${tfile}2
2971 # ls -lu $DIR/$tfile $DIR/${tfile}2
2972 # ls -lc $DIR/$tfile $DIR/${tfile}2
2974 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2975 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2977 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2979 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2981 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2982 error "O_TRUNC didn't change timestamps"
2985 run_test 39 "mtime changed on create ==========================="
2988 test_mkdir -p -c1 $DIR/$tdir
2989 cp -p /etc/passwd $DIR/$tdir/fopen
2990 cp -p /etc/passwd $DIR/$tdir/flink
2991 cp -p /etc/passwd $DIR/$tdir/funlink
2992 cp -p /etc/passwd $DIR/$tdir/frename
2993 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2996 echo "aaaaaa" >> $DIR/$tdir/fopen
2997 echo "aaaaaa" >> $DIR/$tdir/flink
2998 echo "aaaaaa" >> $DIR/$tdir/funlink
2999 echo "aaaaaa" >> $DIR/$tdir/frename
3001 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3002 local link_new=`stat -c %Y $DIR/$tdir/flink`
3003 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3004 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3006 cat $DIR/$tdir/fopen > /dev/null
3007 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3008 rm -f $DIR/$tdir/funlink2
3009 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3011 for (( i=0; i < 2; i++ )) ; do
3012 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3013 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3014 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3015 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3017 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3018 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3019 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3020 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3022 cancel_lru_locks osc
3023 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3026 run_test 39b "mtime change on open, link, unlink, rename ======"
3028 # this should be set to past
3029 TEST_39_MTIME=`date -d "1 year ago" +%s`
3035 local mtime0=`stat -c %Y $DIR1/$tfile`
3037 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3038 local mtime1=`stat -c %Y $DIR1/$tfile`
3039 [ "$mtime1" = $TEST_39_MTIME ] || \
3040 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3043 echo hello >> $DIR1/$tfile
3045 local mtime2=`stat -c %Y $DIR1/$tfile`
3046 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3047 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3049 mv $DIR1/$tfile $DIR1/$tfile-1
3051 for (( i=0; i < 2; i++ )) ; do
3052 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3053 [ "$mtime2" = "$mtime3" ] || \
3054 error "mtime ($mtime2) changed (to $mtime3) on rename"
3056 cancel_lru_locks osc
3057 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3060 run_test 39c "mtime change on rename ==========================="
3064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3067 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3069 for (( i=0; i < 2; i++ )) ; do
3070 local mtime=`stat -c %Y $DIR1/$tfile`
3071 [ $mtime = $TEST_39_MTIME ] || \
3072 error "mtime($mtime) is not set to $TEST_39_MTIME"
3074 cancel_lru_locks osc
3075 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3078 run_test 39d "create, utime, stat =============================="
3082 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3084 local mtime1=`stat -c %Y $DIR1/$tfile`
3086 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3088 for (( i=0; i < 2; i++ )) ; do
3089 local mtime2=`stat -c %Y $DIR1/$tfile`
3090 [ $mtime2 = $TEST_39_MTIME ] || \
3091 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3093 cancel_lru_locks osc
3094 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3097 run_test 39e "create, stat, utime, stat ========================"
3101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3103 mtime1=`stat -c %Y $DIR1/$tfile`
3106 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3108 for (( i=0; i < 2; i++ )) ; do
3109 local mtime2=`stat -c %Y $DIR1/$tfile`
3110 [ $mtime2 = $TEST_39_MTIME ] || \
3111 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3113 cancel_lru_locks osc
3114 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3117 run_test 39f "create, stat, sleep, utime, stat ================="
3121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3122 echo hello >> $DIR1/$tfile
3123 local mtime1=`stat -c %Y $DIR1/$tfile`
3126 chmod o+r $DIR1/$tfile
3128 for (( i=0; i < 2; i++ )) ; do
3129 local mtime2=`stat -c %Y $DIR1/$tfile`
3130 [ "$mtime1" = "$mtime2" ] || \
3131 error "lost mtime: $mtime2, should be $mtime1"
3133 cancel_lru_locks osc
3134 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3137 run_test 39g "write, chmod, stat ==============================="
3141 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3146 echo hello >> $DIR1/$tfile
3147 local mtime1=`stat -c %Y $DIR1/$tfile`
3149 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3151 if [ "$d1" != "$d2" ]; then
3152 echo "write and touch not within one second"
3154 for (( i=0; i < 2; i++ )) ; do
3155 local mtime2=`stat -c %Y $DIR1/$tfile`
3156 [ "$mtime2" = $TEST_39_MTIME ] || \
3157 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3159 cancel_lru_locks osc
3160 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3164 run_test 39h "write, utime within one second, stat ============="
3167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3171 echo hello >> $DIR1/$tfile
3172 local mtime1=`stat -c %Y $DIR1/$tfile`
3174 mv $DIR1/$tfile $DIR1/$tfile-1
3176 for (( i=0; i < 2; i++ )) ; do
3177 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3179 [ "$mtime1" = "$mtime2" ] || \
3180 error "lost mtime: $mtime2, should be $mtime1"
3182 cancel_lru_locks osc
3183 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3186 run_test 39i "write, rename, stat =============================="
3189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3190 start_full_debug_logging
3194 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3195 lctl set_param fail_loc=0x80000412
3196 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3197 error "multiop failed"
3199 local mtime1=`stat -c %Y $DIR1/$tfile`
3201 mv $DIR1/$tfile $DIR1/$tfile-1
3203 kill -USR1 $multipid
3204 wait $multipid || error "multiop close failed"
3206 for (( i=0; i < 2; i++ )) ; do
3207 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3208 [ "$mtime1" = "$mtime2" ] ||
3209 error "mtime is lost on close: $mtime2, " \
3212 cancel_lru_locks osc
3213 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3215 lctl set_param fail_loc=0
3216 stop_full_debug_logging
3218 run_test 39j "write, rename, close, stat ======================="
3221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3225 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3227 local mtime1=`stat -c %Y $DIR1/$tfile`
3229 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3231 kill -USR1 $multipid
3232 wait $multipid || error "multiop close failed"
3234 for (( i=0; i < 2; i++ )) ; do
3235 local mtime2=`stat -c %Y $DIR1/$tfile`
3237 [ "$mtime2" = $TEST_39_MTIME ] || \
3238 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3240 cancel_lru_locks osc
3241 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3244 run_test 39k "write, utime, close, stat ========================"
3246 # this should be set to future
3247 TEST_39_ATIME=`date -d "1 year" +%s`
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3251 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3252 local atime_diff=$(do_facet $SINGLEMDS \
3253 lctl get_param -n mdd.*MDT0000*.atime_diff)
3257 # test setting directory atime to future
3258 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3259 local atime=$(stat -c %X $DIR/$tdir)
3260 [ "$atime" = $TEST_39_ATIME ] || \
3261 error "atime is not set to future: $atime, $TEST_39_ATIME"
3263 # test setting directory atime from future to now
3264 local d1=$(date +%s)
3266 local d2=$(date +%s)
3268 cancel_lru_locks mdc
3269 atime=$(stat -c %X $DIR/$tdir)
3270 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3271 error "atime is not updated from future: $atime, $d1<atime<$d2"
3273 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3276 # test setting directory atime when now > dir atime + atime_diff
3280 cancel_lru_locks mdc
3281 atime=$(stat -c %X $DIR/$tdir)
3282 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3283 error "atime is not updated : $atime, should be $d2"
3285 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3288 # test not setting directory atime when now < dir atime + atime_diff
3290 cancel_lru_locks mdc
3291 atime=$(stat -c %X $DIR/$tdir)
3292 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3293 error "atime is updated to $atime, should remain $d1<atime<$d2"
3295 do_facet $SINGLEMDS \
3296 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3298 run_test 39l "directory atime update ==========================="
3301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3304 local far_past_mtime=$(date -d "May 29 1953" +%s)
3305 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3307 touch -m -d @$far_past_mtime $DIR1/$tfile
3308 touch -a -d @$far_past_atime $DIR1/$tfile
3310 for (( i=0; i < 2; i++ )) ; do
3311 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3312 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3313 error "atime or mtime set incorrectly"
3315 cancel_lru_locks osc
3316 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3319 run_test 39m "test atime and mtime before 1970"
3321 test_39n() { # LU-3832
3322 local atime_diff=$(do_facet $SINGLEMDS \
3323 lctl get_param -n mdd.*MDT0000*.atime_diff)
3328 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3331 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3332 atime0=$(stat -c %X $DIR/$tfile)
3335 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3336 atime1=$(stat -c %X $DIR/$tfile)
3339 cancel_lru_locks mdc
3340 cancel_lru_locks osc
3341 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3342 atime2=$(stat -c %X $DIR/$tfile)
3344 do_facet $SINGLEMDS \
3345 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3347 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3348 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3350 run_test 39n "check that O_NOATIME is honored"
3353 TESTDIR=$DIR/$tdir/$tfile
3354 [ -e $TESTDIR ] && rm -rf $TESTDIR
3355 test_mkdir -p $TESTDIR
3361 links2=$(stat -c %h .)
3362 [ $(($links1 + 2)) != $links2 ] &&
3363 error "wrong links count $(($links1 + 2)) != $links2"
3365 links3=$(stat -c %h .)
3366 [ $(($links1 + 1)) != $links3 ] &&
3367 error "wrong links count $links1 != $links3"
3370 run_test 39o "directory cached attributes updated after create ========"
3373 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3375 TESTDIR=$DIR/$tdir/$tfile
3376 [ -e $TESTDIR ] && rm -rf $TESTDIR
3381 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3382 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3384 links2=$(stat -c %h .)
3385 [ $(($links1 + 2)) != $links2 ] &&
3386 error "wrong links count $(($links1 + 2)) != $links2"
3388 links3=$(stat -c %h .)
3389 [ $(($links1 + 1)) != $links3 ] &&
3390 error "wrong links count $links1 != $links3"
3393 run_test 39p "remote directory cached attributes updated after create ========"
3397 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3398 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3399 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3400 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3401 error "$tfile is not 4096 bytes in size"
3403 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3407 small_write $DIR/f41 18
3409 run_test 41 "test small file write + fstat ====================="
3411 count_ost_writes() {
3412 lctl get_param -n osc.*.stats |
3413 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3414 END { printf("%0.0f", writes) }'
3421 BG_DIRTY_RATIO_SAVE=10
3422 MAX_BG_DIRTY_RATIO=25
3426 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3427 # dirty_ratio, dirty_background_ratio
3428 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3429 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3430 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3431 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3433 # if file not here, we are a 2.4 kernel
3434 kill -CONT `pidof kupdated`
3439 # setup the trap first, so someone cannot exit the test at the
3440 # exact wrong time and mess up a machine
3441 trap start_writeback EXIT
3442 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3443 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3444 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3445 sysctl -w vm.dirty_writeback_centisecs=0
3446 sysctl -w vm.dirty_writeback_centisecs=0
3447 # save and increase /proc/sys/vm/dirty_ratio
3448 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3449 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3450 # save and increase /proc/sys/vm/dirty_background_ratio
3451 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3452 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3454 # if file not here, we are a 2.4 kernel
3455 kill -STOP `pidof kupdated`
3459 # ensure that all stripes have some grant before we test client-side cache
3461 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3462 dd if=/dev/zero of=$i bs=4k count=1
3467 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3468 # file truncation, and file removal.
3470 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3472 cancel_lru_locks osc
3474 sync; sleep 1; sync # just to be safe
3475 BEFOREWRITES=`count_ost_writes`
3476 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3477 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3478 AFTERWRITES=`count_ost_writes`
3479 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3480 error "$BEFOREWRITES < $AFTERWRITES"
3483 run_test 42a "ensure that we don't flush on close =============="
3486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3488 cancel_lru_locks osc
3491 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3492 BEFOREWRITES=$(count_ost_writes)
3493 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3494 AFTERWRITES=$(count_ost_writes)
3495 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3496 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3498 BEFOREWRITES=$(count_ost_writes)
3499 sync || error "sync: $?"
3500 AFTERWRITES=$(count_ost_writes)
3501 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3502 error "$BEFOREWRITES < $AFTERWRITES on sync"
3504 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3508 run_test 42b "test destroy of file with cached dirty data ======"
3510 # if these tests just want to test the effect of truncation,
3511 # they have to be very careful. consider:
3512 # - the first open gets a {0,EOF}PR lock
3513 # - the first write conflicts and gets a {0, count-1}PW
3514 # - the rest of the writes are under {count,EOF}PW
3515 # - the open for truncate tries to match a {0,EOF}PR
3516 # for the filesize and cancels the PWs.
3517 # any number of fixes (don't get {0,EOF} on open, match
3518 # composite locks, do smarter file size management) fix
3519 # this, but for now we want these tests to verify that
3520 # the cancellation with truncate intent works, so we
3521 # start the file with a full-file pw lock to match against
3522 # until the truncate.
3527 cancel_lru_locks osc
3529 # prime the file with 0,EOF PW to match
3533 # now the real test..
3534 dd if=/dev/zero of=$file bs=1024 count=100
3535 BEFOREWRITES=`count_ost_writes`
3536 $TRUNCATE $file $offset
3537 cancel_lru_locks osc
3538 AFTERWRITES=`count_ost_writes`
3543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3545 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3546 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3549 run_test 42c "test partial truncate of file with cached dirty data"
3552 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3554 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3555 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3558 run_test 42d "test complete truncate of file with cached dirty data"
3560 test_42e() { # bug22074
3561 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3562 local TDIR=$DIR/${tdir}e
3563 local pagesz=$(page_size)
3564 local pages=16 # hardcoded 16 pages, don't change it.
3565 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3566 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3570 test_mkdir -p $DIR/${tdir}e
3571 $SETSTRIPE -c 1 $TDIR
3572 createmany -o $TDIR/f $files
3574 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3576 # we assume that with $OSTCOUNT files, at least one of them will
3577 # be allocated on OST0.
3578 warmup_files=$((OSTCOUNT * max_dirty_mb))
3579 createmany -o $TDIR/w $warmup_files
3581 # write a large amount of data into one file and sync, to get good
3582 # avail_grant number from OST.
3583 for ((i=0; i<$warmup_files; i++)); do
3584 idx=$($GETSTRIPE -i $TDIR/w$i)
3585 [ $idx -ne 0 ] && continue
3586 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3589 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3591 $LCTL get_param $proc_osc0/cur_dirty_bytes
3592 $LCTL get_param $proc_osc0/cur_grant_bytes
3594 # create as much dirty pages as we can while not to trigger the actual
3595 # RPCs directly. but depends on the env, VFS may trigger flush during this
3596 # period, hopefully we are good.
3597 for ((i=0; i<$warmup_files; i++)); do
3598 idx=$($GETSTRIPE -i $TDIR/w$i)
3599 [ $idx -ne 0 ] && continue
3600 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3602 $LCTL get_param $proc_osc0/cur_dirty_bytes
3603 $LCTL get_param $proc_osc0/cur_grant_bytes
3605 # perform the real test
3606 $LCTL set_param $proc_osc0/rpc_stats 0
3607 for ((;i<$files; i++)); do
3608 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3609 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3612 $LCTL get_param $proc_osc0/rpc_stats
3615 local have_ppr=false
3616 $LCTL get_param $proc_osc0/rpc_stats |
3617 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3618 # skip lines until we are at the RPC histogram data
3619 [ "$PPR" == "pages" ] && have_ppr=true && continue
3620 $have_ppr || continue
3622 # we only want the percent stat for < 16 pages
3623 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3625 percent=$((percent + WPCT))
3626 if [[ $percent -gt 15 ]]; then
3627 error "less than 16-pages write RPCs" \
3634 run_test 42e "verify sub-RPC writes are not done synchronously"
3637 test_mkdir -p $DIR/$tdir
3638 cp -p /bin/ls $DIR/$tdir/$tfile
3639 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3641 # give multiop a chance to open
3644 $DIR/$tdir/$tfile && error || true
3647 run_test 43 "execution of file opened for write should return -ETXTBSY"
3650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3651 test_mkdir -p $DIR/$tdir
3652 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3653 cp -p multiop $DIR/$tdir/multiop
3654 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3657 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3658 kill -USR1 $MULTIOP_PID || return 2
3659 wait $MULTIOP_PID || return 3
3660 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3662 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3666 test_mkdir -p $DIR/$tdir
3667 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3668 cp -p multiop $DIR/$tdir/multiop
3669 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3672 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3673 kill -USR1 $MULTIOP_PID || return 2
3674 wait $MULTIOP_PID || return 3
3675 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3677 run_test 43b "truncate of file being executed should return -ETXTBSY"
3680 local testdir="$DIR/$tdir"
3681 test_mkdir -p $DIR/$tdir
3683 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3684 ( cd $testdir && md5sum -c)
3686 run_test 43c "md5sum of copy into lustre========================"
3689 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3690 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3691 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3693 run_test 44 "zero length read from a sparse stripe ============="
3696 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3698 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3699 [[ $nstripe -gt $OSTCOUNT ]] &&
3700 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3702 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3704 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3705 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3709 OFFSETS="0 $((stride/2)) $((stride-1))"
3710 for offset in $OFFSETS; do
3711 for i in $(seq 0 $((nstripe-1))); do
3712 local GLOBALOFFSETS=""
3714 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3715 local myfn=$DIR/d44a-$size
3716 echo "--------writing $myfn at $size"
3717 ll_sparseness_write $myfn $size ||
3718 error "ll_sparseness_write"
3719 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3720 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3721 error "ll_sparseness_verify $GLOBALOFFSETS"
3723 for j in $(seq 0 $((nstripe-1))); do
3725 size=$((((j + $nstripe )*$stride + $offset)))
3726 ll_sparseness_write $myfn $size ||
3727 error "ll_sparseness_write"
3728 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3730 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3731 error "ll_sparseness_verify $GLOBALOFFSETS"
3736 run_test 44a "test sparse pwrite ==============================="
3740 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3746 before=`dirty_osc_total`
3747 echo executing "\"$*\""
3749 after=`dirty_osc_total`
3750 echo before $before, after $after
3753 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3755 # Obtain grants from OST if it supports it
3756 echo blah > ${f}_grant
3759 do_dirty_record "echo blah > $f"
3760 [[ $before -eq $after ]] && error "write wasn't cached"
3761 do_dirty_record "> $f"
3762 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3763 do_dirty_record "echo blah > $f"
3764 [[ $before -eq $after ]] && error "write wasn't cached"
3765 do_dirty_record "sync"
3766 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3767 do_dirty_record "echo blah > $f"
3768 [[ $before -eq $after ]] && error "write wasn't cached"
3769 do_dirty_record "cancel_lru_locks osc"
3770 [[ $before -gt $after ]] ||
3771 error "lock cancellation didn't lower dirty count"
3774 run_test 45 "osc io page accounting ============================"
3776 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3777 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3778 # objects offset and an assert hit when an rpc was built with 1023's mapped
3779 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3785 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3787 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3788 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3792 run_test 46 "dirtying a previously written page ================"
3794 # test_47 is removed "Device nodes check" is moved to test_28
3796 test_48a() { # bug 2399
3797 check_kernel_version 34 || return 0
3798 test_mkdir -p $DIR/$tdir
3800 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3801 test_mkdir $DIR/$tdir || error "recreate directory failed"
3802 touch foo || error "'touch foo' failed after recreating cwd"
3803 test_mkdir $DIR/$tdir/bar ||
3804 error "'mkdir foo' failed after recreating cwd"
3805 if check_kernel_version 44; then
3806 touch .foo || error "'touch .foo' failed after recreating cwd"
3807 test_mkdir $DIR/$tdir/.bar ||
3808 error "'mkdir .foo' failed after recreating cwd"
3810 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3811 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3812 cd . || error "'cd .' failed after recreating cwd"
3813 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3814 rmdir . && error "'rmdir .' worked after recreating cwd"
3815 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3816 cd .. || error "'cd ..' failed after recreating cwd"
3818 run_test 48a "Access renamed working dir (should return errors)="
3820 test_48b() { # bug 2399
3821 check_kernel_version 34 || return 0
3823 test_mkdir -p $DIR/$tdir
3825 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3826 touch foo && error "'touch foo' worked after removing cwd"
3827 test_mkdir $DIR/$tdir/foo &&
3828 error "'mkdir foo' worked after removing cwd"
3829 if check_kernel_version 44; then
3830 touch .foo && error "'touch .foo' worked after removing cwd"
3831 test_mkdir $DIR/$tdir/.foo &&
3832 error "'mkdir .foo' worked after removing cwd"
3834 ls . > /dev/null && error "'ls .' worked after removing cwd"
3835 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3836 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3837 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3838 rmdir . && error "'rmdir .' worked after removing cwd"
3839 ln -s . foo && error "'ln -s .' worked after removing cwd"
3840 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3842 run_test 48b "Access removed working dir (should return errors)="
3844 test_48c() { # bug 2350
3845 check_kernel_version 36 || return 0
3846 #lctl set_param debug=-1
3849 test_mkdir -p $DIR/$tdir/dir
3851 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3852 $TRACE touch foo && error "touch foo worked after removing cwd"
3853 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3854 if check_kernel_version 44; then
3855 touch .foo && error "touch .foo worked after removing cwd"
3856 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3858 $TRACE ls . && error "'ls .' worked after removing cwd"
3859 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3860 is_patchless || ( $TRACE cd . &&
3861 error "'cd .' worked after removing cwd" )
3862 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3863 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3864 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3865 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3867 run_test 48c "Access removed working subdir (should return errors)"
3869 test_48d() { # bug 2350
3870 check_kernel_version 36 || return 0
3871 #lctl set_param debug=-1
3874 test_mkdir -p $DIR/$tdir/dir
3876 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3877 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3878 $TRACE touch foo && error "'touch foo' worked after removing parent"
3879 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3880 if check_kernel_version 44; then
3881 touch .foo && error "'touch .foo' worked after removing parent"
3883 error "mkdir .foo worked after removing parent"
3885 $TRACE ls . && error "'ls .' worked after removing parent"
3886 $TRACE ls .. && error "'ls ..' worked after removing parent"
3887 is_patchless || ( $TRACE cd . &&
3888 error "'cd .' worked after recreate parent" )
3889 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3890 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3891 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3892 is_patchless || ( $TRACE cd .. &&
3893 error "'cd ..' worked after removing parent" || true )
3895 run_test 48d "Access removed parent subdir (should return errors)"
3897 test_48e() { # bug 4134
3898 check_kernel_version 41 || return 0
3899 #lctl set_param debug=-1
3902 test_mkdir -p $DIR/$tdir/dir
3904 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3905 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3906 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3907 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3908 # On a buggy kernel addition of "touch foo" after cd .. will
3909 # produce kernel oops in lookup_hash_it
3910 touch ../foo && error "'cd ..' worked after recreate parent"
3912 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3914 run_test 48e "Access to recreated parent subdir (should return errors)"
3916 test_49() { # LU-1030
3917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3918 # get ost1 size - lustre-OST0000
3919 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3921 # write 800M at maximum
3922 [[ $ost1_size -lt 2 ]] && ost1_size=2
3923 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3925 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3926 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3929 # change max_pages_per_rpc while writing the file
3930 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3931 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3932 # loop until dd process exits
3933 while ps ax -opid | grep -wq $dd_pid; do
3934 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3935 sleep $((RANDOM % 5 + 1))
3937 # restore original max_pages_per_rpc
3938 $LCTL set_param $osc1_mppc=$orig_mppc
3939 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3941 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3945 test_mkdir $DIR/$tdir
3947 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3949 run_test 50 "special situations: /proc symlinks ==============="
3951 test_51a() { # was test_51
3952 # bug 1516 - create an empty entry right after ".." then split dir
3953 test_mkdir -c1 $DIR/$tdir
3954 touch $DIR/$tdir/foo
3955 $MCREATE $DIR/$tdir/bar
3957 createmany -m $DIR/$tdir/longfile 201
3959 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3960 $MCREATE $DIR/$tdir/longfile$FNUM
3965 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3967 run_test 51a "special situations: split htree with empty entry =="
3969 export NUMTEST=70000
3971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3972 local BASE=$DIR/d${base}.${TESTSUITE}
3974 # cleanup the directory
3977 test_mkdir -p -c1 $BASE
3979 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3980 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3981 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3984 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3985 echo "reduced count to $NUMTEST due to inodes"
3987 # need to check free space for the directories as well
3988 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3989 numfree=$((blkfree / 4))
3990 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3991 echo "reduced count to $NUMTEST due to blocks"
3993 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3994 echo "failed" > $BASE/fnum
3996 run_test 51b "exceed 64k subdirectory nlink limit"
3998 test_51ba() { # LU-993
3999 local BASE=$DIR/d${base}.${TESTSUITE}
4000 # unlink all but 100 subdirectories, then check it still works
4002 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4004 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4005 local DELETE=$((NUMTEST - LEFT))
4007 # continue on to run this test even if 51b didn't finish,
4008 # just to delete the many subdirectories created.
4009 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4011 # for ldiskfs the nlink count should be 1, but this is OSD specific
4012 # and so this is listed for informational purposes only
4013 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4014 unlinkmany -d $BASE/d $DELETE
4017 if [ $RC -ne 0 ]; then
4018 if [ "$NUMPREV" == "failed" ]; then
4019 skip "previous setup failed"
4022 error "unlink of first $DELETE subdirs failed"
4027 echo "nlink between: $(stat -c %h $BASE)"
4028 # trim the first line of ls output
4029 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4030 [ $FOUND -ne $LEFT ] &&
4031 error "can't find subdirs: found only $FOUND/$LEFT"
4033 unlinkmany -d $BASE/d $DELETE $LEFT ||
4034 error "unlink of second $LEFT subdirs failed"
4035 # regardless of whether the backing filesystem tracks nlink accurately
4036 # or not, the nlink count shouldn't be more than "." and ".." here
4037 local AFTER=$(stat -c %h $BASE)
4038 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4039 echo "nlink after: $AFTER"
4041 run_test 51ba "verify nlink for many subdirectory cleanup"
4044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4045 [[ $OSTCOUNT -lt 3 ]] &&
4046 skip_env "skipping test with few OSTs" && return
4047 test_mkdir -p $DIR/$tdir
4048 createmany -o $DIR/$tdir/t- 1000
4049 $GETSTRIPE $DIR/$tdir > $TMP/files
4050 for N in $(seq 0 $((OSTCOUNT - 1))); do
4051 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4052 END { printf("%0.0f", objs) }' $TMP/files)
4053 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4054 '($1 == '$N') { objs += 1 } \
4055 END { printf("%0.0f", objs) }')
4056 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4058 unlinkmany $DIR/$tdir/t- 1000
4061 for N in $(seq 1 $((OSTCOUNT - 1))); do
4062 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4063 error "OST $N has less objects vs OST $NLAST" \
4064 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4065 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4066 error "OST $N has less objects vs OST $NLAST" \
4067 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4069 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4070 error "OST $N has less #0 objects vs OST $NLAST" \
4071 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4072 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4073 error "OST $N has less #0 objects vs OST $NLAST" \
4074 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4078 run_test 51d "check object distribution ===================="
4081 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4082 skip "Only applicable to ldiskfs-based MDTs"
4086 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4087 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4089 touch $DIR/$tdir/d0/foo
4090 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4091 error "file exceed 65000 nlink limit!"
4092 unlinkmany $DIR/$tdir/d0/f- 65001
4095 run_test 51e "check file nlink limit"
4098 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4099 test_mkdir -p $DIR/$tdir
4100 touch $DIR/$tdir/foo
4101 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4102 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4103 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4104 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4105 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4107 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4108 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4109 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4111 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4112 cp -r $DIR/$tdir /tmp/
4113 rm -fr $DIR/$tdir || error "cleanup rm failed"
4115 run_test 52a "append-only flag test (should return errors) ====="
4118 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4119 test_mkdir -p $DIR/$tdir
4120 touch $DIR/$tdir/foo
4121 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4122 cat test > $DIR/$tdir/foo && error "cat test worked"
4123 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4124 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4125 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4127 echo foo >> $DIR/$tdir/foo && error "echo worked"
4128 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4129 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4130 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4131 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4133 chattr -i $DIR/$tdir/foo || error "chattr failed"
4135 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4137 run_test 52b "immutable flag test (should return errors) ======="
4140 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4141 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4142 remote_ost_nodsh && skip "remote OST with nodsh" && return
4155 local support_last_seq=true
4157 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4158 support_last_seq=false
4161 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4163 for value in $(do_facet $SINGLEMDS \
4164 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4165 param=$(echo ${value[0]} | cut -d "=" -f1)
4166 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4168 if $support_last_seq; then
4169 param_seq=$(echo $param |
4170 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4171 mds_last_seq=$(do_facet $SINGLEMDS \
4172 $LCTL get_param -n $param_seq)
4174 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4176 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4177 node=$(facet_active_host ost$((ostnum+1)))
4178 param="obdfilter.$ostname.last_id"
4179 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4180 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4181 ost_last_id=$ost_last
4183 if $support_last_seq; then
4184 ost_last_id=$(echo $ost_last |
4185 awk -F':' '{print $2}' |
4187 ost_last_seq=$(echo $ost_last |
4188 awk -F':' '{print $1}')
4189 [[ $ost_last_seq = $mds_last_seq ]] || continue
4192 if [[ $ost_last_id != $mds_last ]]; then
4193 error "$ost_last_id != $mds_last"
4200 $found || error "can not match last_seq/last_id for $mdtosc"
4203 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4206 $SOCKETSERVER $DIR/socket ||
4207 error "$SOCKETSERVER $DIR/socket failed: $?"
4208 $SOCKETCLIENT $DIR/socket ||
4209 error "$SOCKETCLIENT $DIR/socket failed: $?"
4210 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4212 run_test 54a "unix domain socket test =========================="
4218 dd if=/dev/zero of=$f bs=$(page_size) count=1
4220 run_test 54b "char device works in lustre ======================"
4223 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4224 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4225 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4227 for i in $(seq 3 7); do
4228 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4236 loopdev="$DIR/loop54c"
4239 $UMOUNT -d $DIR/$tdir || rc=$?
4240 losetup -d $loopdev || true
4241 losetup -d $LOOPDEV || true
4242 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4248 loopdev="$DIR/loop54c"
4251 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4252 trap cleanup_54c EXIT
4253 mknod $loopdev b 7 $LOOPNUM
4254 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4255 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4256 losetup $loopdev $DIR/$tfile ||
4257 error "can't set up $loopdev for $DIR/$tfile"
4258 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4259 test_mkdir -p $DIR/$tdir
4260 mount -t ext2 $loopdev $DIR/$tdir ||
4261 error "error mounting $loopdev on $DIR/$tdir"
4262 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4265 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4269 run_test 54c "block device works in lustre ====================="
4275 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4277 run_test 54d "fifo device works in lustre ======================"
4280 check_kernel_version 46 || return 0
4283 cp -aL /dev/console $f
4284 echo $string > $f || error "echo $string to $f failed"
4286 run_test 54e "console/tty device works in lustre ======================"
4288 #The test_55 used to be iopen test and it was removed by bz#24037.
4289 #run_test 55 "check iopen_connect_dentry() ======================"
4291 test_56a() { # was test_56
4294 test_mkdir -p $DIR/$tdir/dir
4296 NUMFILESx2=$(($NUMFILES * 2))
4297 for i in $(seq 1 $NUMFILES); do
4298 touch $DIR/$tdir/file$i
4299 touch $DIR/$tdir/dir/file$i
4302 # test lfs getstripe with --recursive
4303 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4304 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4305 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4306 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4307 [[ $FILENUM -eq $NUMFILES ]] ||
4308 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4309 echo "$GETSTRIPE --recursive passed."
4311 # test lfs getstripe with file instead of dir
4312 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4313 [[ $FILENUM -eq 1 ]] ||
4314 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4315 echo "$GETSTRIPE file1 passed."
4317 #test lfs getstripe with --verbose
4318 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4319 grep -c lmm_magic) -eq $NUMFILES ]] ||
4320 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4321 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4322 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4323 echo "$GETSTRIPE --verbose passed."
4325 #test lfs getstripe with --obd
4326 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4327 grep -q "unknown obduuid" ||
4328 error "$GETSTRIPE --obd wrong_uuid should return error message"
4330 [[ $OSTCOUNT -lt 2 ]] &&
4331 skip_env "skipping other $GETSTRIPE --obd test" && return
4334 OBDUUID=$(ostuuid_from_index $OSTIDX)
4335 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4336 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4337 [[ $FOUND -eq $FILENUM ]] ||
4338 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4339 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4340 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4341 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4342 error "$GETSTRIPE --obd: should not show file on other obd"
4343 echo "$GETSTRIPE --obd passed"
4345 run_test 56a "check $GETSTRIPE"
4350 local LOCAL_NUMFILES="$1"
4351 local LOCAL_NUMDIRS="$2"
4352 local MKDIR_PARAMS="$3"
4353 local DIR_STRIPE_PARAMS="$4"
4355 if [ ! -d "$TDIR" ] ; then
4356 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4357 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4358 for i in `seq 1 $LOCAL_NUMFILES` ; do
4361 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4362 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4363 for j in `seq 1 $LOCAL_NUMFILES` ; do
4364 touch $TDIR/dir$i/file$j
4370 setup_56_special() {
4374 if [ ! -e "$TDIR/loop1b" ] ; then
4375 for i in `seq 1 $LOCAL_NUMFILES` ; do
4376 mknod $TDIR/loop${i}b b 7 $i
4377 mknod $TDIR/null${i}c c 1 3
4378 ln -s $TDIR/file1 $TDIR/link${i}l
4380 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4381 mknod $TDIR/dir$i/loop${i}b b 7 $i
4382 mknod $TDIR/dir$i/null${i}c c 1 3
4383 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4392 setup_56 $NUMFILES $NUMDIRS
4394 EXPECTED=$(($NUMDIRS + 2))
4395 # test lfs find with -name
4396 for i in $(seq 1 $NUMFILES) ; do
4397 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4398 [ $NUMS -eq $EXPECTED ] ||
4399 error "lfs find -name \"*$i\" $TDIR wrong: "\
4400 "found $NUMS, expected $EXPECTED"
4403 run_test 56g "check lfs find -name ============================="
4409 setup_56 $NUMFILES $NUMDIRS
4411 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4412 # test lfs find with ! -name
4413 for i in $(seq 1 $NUMFILES) ; do
4414 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4415 [ $NUMS -eq $EXPECTED ] ||
4416 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4417 "found $NUMS, expected $EXPECTED"
4420 run_test 56h "check lfs find ! -name ============================="
4424 test_mkdir -p $DIR/$tdir
4425 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4426 CMD="$LFIND -ost $UUID $DIR/$tdir"
4428 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4430 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4434 setup_56_special $NUMFILES $NUMDIRS
4436 EXPECTED=$((NUMDIRS + 1))
4437 CMD="$LFIND -type d $TDIR"
4438 NUMS=$($CMD | wc -l)
4439 [ $NUMS -eq $EXPECTED ] ||
4440 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4442 run_test 56j "check lfs find -type d ============================="
4446 setup_56_special $NUMFILES $NUMDIRS
4448 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4449 CMD="$LFIND -type f $TDIR"
4450 NUMS=$($CMD | wc -l)
4451 [ $NUMS -eq $EXPECTED ] ||
4452 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4454 run_test 56k "check lfs find -type f ============================="
4458 setup_56_special $NUMFILES $NUMDIRS
4460 EXPECTED=$((NUMDIRS + NUMFILES))
4461 CMD="$LFIND -type b $TDIR"
4462 NUMS=$($CMD | wc -l)
4463 [ $NUMS -eq $EXPECTED ] ||
4464 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4466 run_test 56l "check lfs find -type b ============================="
4470 setup_56_special $NUMFILES $NUMDIRS
4472 EXPECTED=$((NUMDIRS + NUMFILES))
4473 CMD="$LFIND -type c $TDIR"
4474 NUMS=$($CMD | wc -l)
4475 [ $NUMS -eq $EXPECTED ] ||
4476 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4478 run_test 56m "check lfs find -type c ============================="
4482 setup_56_special $NUMFILES $NUMDIRS
4484 EXPECTED=$((NUMDIRS + NUMFILES))
4485 CMD="$LFIND -type l $TDIR"
4486 NUMS=$($CMD | wc -l)
4487 [ $NUMS -eq $EXPECTED ] ||
4488 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4490 run_test 56n "check lfs find -type l ============================="
4494 setup_56 $NUMFILES $NUMDIRS
4495 utime $TDIR/file1 > /dev/null || error "utime (1)"
4496 utime $TDIR/file2 > /dev/null || error "utime (2)"
4497 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4498 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4499 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4500 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4503 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4504 [ $NUMS -eq $EXPECTED ] || \
4505 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4508 CMD="$LFIND -mtime 0 $TDIR"
4509 NUMS=$($CMD | wc -l)
4510 [ $NUMS -eq $EXPECTED ] ||
4511 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4513 run_test 56o "check lfs find -mtime for old files =========================="
4516 [ $RUNAS_ID -eq $UID ] &&
4517 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4520 setup_56 $NUMFILES $NUMDIRS
4522 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4524 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4525 NUMS=$($CMD | wc -l)
4526 [ $NUMS -eq $EXPECTED ] || \
4527 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4529 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4530 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4531 NUMS=$($CMD | wc -l)
4532 [ $NUMS -eq $EXPECTED ] || \
4533 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4535 run_test 56p "check lfs find -uid and ! -uid ==============================="
4538 [ $RUNAS_ID -eq $UID ] &&
4539 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4542 setup_56 $NUMFILES $NUMDIRS
4544 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4547 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4548 NUMS=$($CMD | wc -l)
4549 [ $NUMS -eq $EXPECTED ] ||
4550 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4552 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4553 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4554 NUMS=$($CMD | wc -l)
4555 [ $NUMS -eq $EXPECTED ] ||
4556 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4558 run_test 56q "check lfs find -gid and ! -gid ==============================="
4562 setup_56 $NUMFILES $NUMDIRS
4565 CMD="$LFIND -size 0 -type f $TDIR"
4566 NUMS=$($CMD | wc -l)
4567 [ $NUMS -eq $EXPECTED ] ||
4568 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4570 CMD="$LFIND ! -size 0 -type f $TDIR"
4571 NUMS=$($CMD | wc -l)
4572 [ $NUMS -eq $EXPECTED ] ||
4573 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4574 echo "test" > $TDIR/$tfile
4575 echo "test2" > $TDIR/$tfile.2 && sync
4577 CMD="$LFIND -size 5 -type f $TDIR"
4578 NUMS=$($CMD | wc -l)
4579 [ $NUMS -eq $EXPECTED ] ||
4580 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4582 CMD="$LFIND -size +5 -type f $TDIR"
4583 NUMS=$($CMD | wc -l)
4584 [ $NUMS -eq $EXPECTED ] ||
4585 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4587 CMD="$LFIND -size +0 -type f $TDIR"
4588 NUMS=$($CMD | wc -l)
4589 [ $NUMS -eq $EXPECTED ] ||
4590 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4592 CMD="$LFIND ! -size -5 -type f $TDIR"
4593 NUMS=$($CMD | wc -l)
4594 [ $NUMS -eq $EXPECTED ] ||
4595 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4597 CMD="$LFIND -size -5 -type f $TDIR"
4598 NUMS=$($CMD | wc -l)
4599 [ $NUMS -eq $EXPECTED ] ||
4600 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4602 run_test 56r "check lfs find -size works =========================="
4604 test_56s() { # LU-611
4606 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4608 if [[ $OSTCOUNT -gt 1 ]]; then
4609 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4613 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4617 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4618 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4619 NUMS=$($CMD | wc -l)
4620 [ $NUMS -eq $EXPECTED ] || {
4622 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4625 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4626 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4627 NUMS=$($CMD | wc -l)
4628 [ $NUMS -eq $EXPECTED ] || {
4630 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4634 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4635 NUMS=$($CMD | wc -l)
4636 [ $NUMS -eq $EXPECTED ] || {
4638 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4641 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4642 NUMS=$($CMD | wc -l)
4643 [ $NUMS -eq $EXPECTED ] || {
4645 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4649 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4650 NUMS=$($CMD | wc -l)
4651 [ $NUMS -eq $EXPECTED ] || {
4653 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4656 run_test 56s "check lfs find -stripe-count works"
4658 test_56t() { # LU-611
4660 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4662 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4664 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4665 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4666 NUMS=$($CMD | wc -l)
4667 [ $NUMS -eq $EXPECTED ] ||
4668 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4670 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4671 NUMS=$($CMD | wc -l)
4672 [ $NUMS -eq $EXPECTED ] ||
4673 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4675 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4676 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4677 NUMS=$($CMD | wc -l)
4678 [ $NUMS -eq $EXPECTED ] ||
4679 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4681 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4682 NUMS=$($CMD | wc -l)
4683 [ $NUMS -eq $EXPECTED ] ||
4684 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4687 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4688 NUMS=$($CMD | wc -l)
4689 [ $NUMS -eq $EXPECTED ] ||
4690 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4692 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4693 NUMS=$($CMD | wc -l)
4694 [ $NUMS -eq $EXPECTED ] ||
4695 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4698 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4699 NUMS=$($CMD | wc -l)
4700 [ $NUMS -eq $EXPECTED ] ||
4701 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4703 run_test 56t "check lfs find -stripe-size works"
4705 test_56u() { # LU-611
4707 setup_56 $NUMFILES $NUMDIRS "-i 0"
4709 if [[ $OSTCOUNT -gt 1 ]]; then
4710 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4716 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4717 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4718 NUMS=$($CMD | wc -l)
4719 [ $NUMS -eq $EXPECTED ] ||
4720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4723 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4724 NUMS=$($CMD | wc -l)
4725 [ $NUMS -eq $EXPECTED ] ||
4726 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4728 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4729 NUMS=$($CMD | wc -l)
4730 [ $NUMS -eq $EXPECTED ] ||
4731 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 # This should produce an error and not return any files
4735 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4736 NUMS=$($CMD 2>/dev/null | wc -l)
4737 [ $NUMS -eq $EXPECTED ] ||
4738 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4740 if [[ $OSTCOUNT -gt 1 ]]; then
4741 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4742 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4743 NUMS=$($CMD | wc -l)
4744 [ $NUMS -eq $EXPECTED ] ||
4745 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4748 run_test 56u "check lfs find -stripe-index works"
4755 setup_56 $NUMFILES $NUMDIRS
4757 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4758 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4760 for file in $($LFIND -mdt $UUID $TDIR); do
4761 file_mdt_idx=$($GETSTRIPE -M $file)
4762 [ $file_mdt_idx -eq $MDT_IDX ] ||
4763 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4766 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4768 # Get and check the actual stripe count of one file.
4769 # Usage: check_stripe_count <file> <expected_stripe_count>
4770 check_stripe_count() {
4775 [[ -z "$file" || -z "$expected" ]] &&
4776 error "check_stripe_count: invalid argument!"
4778 local cmd="$GETSTRIPE -c $file"
4779 actual=$($cmd) || error "$cmd failed"
4780 actual=${actual%% *}
4782 if [[ $actual -ne $expected ]]; then
4783 [[ $expected -eq -1 ]] ||
4784 error "$cmd wrong: found $actual, expected $expected"
4785 [[ $actual -eq $OSTCOUNT ]] ||
4786 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4794 rm -rf $TDIR || error "remove $TDIR failed"
4795 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4798 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4799 error "$GETSTRIPE -S -d $TDIR failed"
4800 stripe_size=${stripe_size%% *}
4802 local file_size=$((stripe_size * OSTCOUNT))
4803 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4804 local required_space=$((file_num * file_size))
4805 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4806 [[ $free_space -le $((required_space / 1024)) ]] &&
4807 skip_env "need at least $required_space bytes free space," \
4808 "have $free_space kbytes" && return
4811 local dd_count=$((file_size / dd_bs))
4813 # write data into the files
4817 for i in $(seq 1 $NUMFILES); do
4819 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4820 error "write data into $file failed"
4822 for i in $(seq 1 $NUMDIRS); do
4823 for j in $(seq 1 $NUMFILES); do
4824 file=$TDIR/dir$i/file$j
4825 yes | dd bs=$dd_bs count=$dd_count of=$file \
4827 error "write data into $file failed"
4832 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4835 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4837 eval $cmd || error "$cmd failed"
4839 check_stripe_count $TDIR/file1 $expected
4842 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4844 eval $cmd || error "$cmd failed"
4846 for j in $(seq 1 $NUMFILES); do
4847 check_stripe_count $TDIR/dir1/file$j $expected
4850 # lfs_migrate works with lfs find
4851 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4852 $LFS_MIGRATE -y -c $expected"
4854 eval $cmd || error "$cmd failed"
4856 for i in $(seq 2 $NUMFILES); do
4857 check_stripe_count $TDIR/file$i $expected
4859 for i in $(seq 2 $NUMDIRS); do
4860 for j in $(seq 1 $NUMFILES); do
4861 check_stripe_count $TDIR/dir$i/file$j $expected
4865 run_test 56w "check lfs_migrate -c stripe_count works"
4868 check_swap_layouts_support && return 0
4869 [[ $OSTCOUNT -lt 2 ]] &&
4870 skip_env "need 2 OST, skipping test" && return
4872 local dir0=$DIR/$tdir/$testnum
4873 mkdir -p $dir0 || error "creating dir $dir0"
4875 local ref1=/etc/passwd
4876 local file1=$dir0/file1
4878 $SETSTRIPE -c 2 $file1
4880 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4881 stripe=$($GETSTRIPE -c $file1)
4882 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4883 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4888 run_test 56x "lfs migration support"
4891 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4892 skip "No HSM support on MDS of $(get_lustre_version)," \
4893 "need 2.4.53 at least" && return
4896 local dir0=$DIR/$tdir/$testnum
4897 mkdir -p $dir0 || error "creating dir $dir0"
4898 local f1=$dir0/file1
4899 local f2=$dir0/file2
4901 touch $f1 || error "creating std file $f1"
4902 $MULTIOP $f2 H2c || error "creating released file $f2"
4904 # a directory can be raid0, so ask only for files
4905 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4906 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4908 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4909 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4911 # only files can be released, so no need to force file search
4912 res=$($LFIND $dir0 -L released)
4913 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4915 res=$($LFIND $dir0 \! -L released)
4916 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4919 run_test 56y "lfs find -L raid0|released"
4921 test_56z() { # LU-4824
4922 # This checks to make sure 'lfs find' continues after errors
4923 # There are two classes of errors that should be caught:
4924 # - If multiple paths are provided, all should be searched even if one
4926 # - If errors are encountered during the search, it should not terminate
4929 test_mkdir $DIR/$tdir
4930 for i in d{0..9}; do
4931 test_mkdir $DIR/$tdir/$i
4933 touch $DIR/$tdir/d{0..9}/$tfile
4934 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4935 error "$LFS find did not return an error"
4936 # Make a directory unsearchable. This should NOT be the last entry in
4937 # directory order. Arbitrarily pick the 6th entry
4938 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
4939 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4940 # The user should be able to see 10 directories and 9 files
4941 [ $count == 19 ] || error "$LFS find did not continue after error"
4943 run_test 56z "lfs find should continue after an error"
4946 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4947 # note test will not do anything if MDS is not local
4948 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4949 skip "Only applicable to ldiskfs-based MDTs"
4953 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4954 local MNTDEV="osd*.*MDT*.mntdev"
4955 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4956 [ -z "$DEV" ] && error "can't access $MNTDEV"
4957 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4958 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4959 error "can't access $DEV"
4960 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4961 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4965 run_test 57a "verify MDS filesystem created with large inodes =="
4968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4969 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4970 skip "Only applicable to ldiskfs-based MDTs"
4974 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4979 local FILEN=$dir/f$FILECOUNT
4981 rm -rf $dir || error "removing $dir"
4982 test_mkdir -p $dir || error "creating $dir"
4983 local num=$(get_mds_dir $dir)
4986 echo "mcreating $FILECOUNT files"
4987 createmany -m $dir/f 1 $FILECOUNT || \
4988 error "creating files in $dir"
4990 # verify that files do not have EAs yet
4991 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4992 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4996 df $dir #make sure we get new statfs data
4997 local MDSFREE=$(do_facet $mymds \
4998 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4999 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5000 echo "opening files to create objects/EAs"
5002 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5003 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5006 # verify that files have EAs now
5007 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5008 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5010 sleep 1 #make sure we get new statfs data
5012 local MDSFREE2=$(do_facet $mymds \
5013 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
5014 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5015 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5016 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5017 error "MDC before $MDCFREE != after $MDCFREE2"
5019 echo "MDC before $MDCFREE != after $MDCFREE2"
5020 echo "unable to confirm if MDS has large inodes"
5025 run_test 57b "default LOV EAs are stored inside large inodes ==="
5028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5029 [ -z "$(which wiretest 2>/dev/null)" ] &&
5030 skip_env "could not find wiretest" && return
5033 run_test 58 "verify cross-platform wire constants =============="
5036 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5037 echo "touch 130 files"
5038 createmany -o $DIR/f59- 130
5040 unlinkmany $DIR/f59- 130
5042 # wait for commitment of removal
5043 wait_delete_completed
5045 run_test 59 "verify cancellation of llog records async ========="
5047 TEST60_HEAD="test_60 run $RANDOM"
5049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5050 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5051 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5052 skip_env "missing subtest run-llog.sh" && return
5053 log "$TEST60_HEAD - from kernel mode"
5054 do_facet mgs sh run-llog.sh
5056 run_test 60a "llog sanity tests run from kernel module =========="
5058 test_60b() { # bug 6411
5059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5061 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5073 [[ $LLOG_COUNT -gt 50 ]] &&
5074 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5076 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5080 echo "create 5000 files"
5081 createmany -o $DIR/f60c- 5000
5082 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5083 lctl set_param fail_loc=0x80000137
5084 unlinkmany $DIR/f60c- 5000
5085 lctl set_param fail_loc=0
5087 run_test 60c "unlink file when mds full"
5090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5091 SAVEPRINTK=$(lctl get_param -n printk)
5093 # verify "lctl mark" is even working"
5094 MESSAGE="test message ID $RANDOM $$"
5095 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5096 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5098 lctl set_param printk=0 || error "set lnet.printk failed"
5099 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5100 MESSAGE="new test message ID $RANDOM $$"
5101 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5102 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5103 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5105 lctl set_param -n printk="$SAVEPRINTK"
5107 run_test 60d "test printk console message masking"
5110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5112 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5113 cancel_lru_locks osc
5114 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5117 run_test 61 "mmap() writes don't make sync hang ================"
5119 # bug 2330 - insufficient obd_match error checking causes LBUG
5121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5124 cancel_lru_locks osc
5125 lctl set_param fail_loc=0x405
5126 cat $f && error "cat succeeded, expect -EIO"
5127 lctl set_param fail_loc=0
5129 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5130 # match every page all of the time.
5131 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5133 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5134 # Though this test is irrelevant anymore, it helped to reveal some
5135 # other grant bugs (LU-4482), let's keep it.
5136 test_63a() { # was test_63
5137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5138 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5139 for i in `seq 10` ; do
5140 dd if=/dev/zero of=$DIR/f63 bs=8k &
5146 rm -f $DIR/f63 || true
5148 run_test 63a "Verify oig_wait interruption does not crash ======="
5150 # bug 2248 - async write errors didn't return to application on sync
5151 # bug 3677 - async write errors left page locked
5153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5155 lctl set_param debug=-1
5157 # ensure we have a grant to do async writes
5158 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5161 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5162 lctl set_param fail_loc=0x80000406
5163 $MULTIOP $DIR/$tfile Owy && \
5164 error "sync didn't return ENOMEM"
5165 sync; sleep 2; sync # do a real sync this time to flush page
5166 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5167 error "locked page left in cache after async error" || true
5170 run_test 63b "async write errors should be returned to fsync ==="
5173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5175 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5177 run_test 64a "verify filter grant calculations (in kernel) ====="
5180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5181 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5183 run_test 64b "check out-of-space detection on client ==========="
5186 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5188 run_test 64c "verify grant shrink ========================------"
5190 # bug 1414 - set/get directories' stripe info
5192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5193 test_mkdir -p $DIR/$tdir
5195 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5197 run_test 65a "directory with no stripe info ===================="
5200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5201 test_mkdir -p $DIR/$tdir
5202 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5205 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5207 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5210 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5211 if [[ $OSTCOUNT -gt 1 ]]; then
5212 test_mkdir -p $DIR/$tdir
5213 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5214 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5216 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5219 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5223 test_mkdir -p $DIR/$tdir
5224 if [[ $STRIPECOUNT -le 0 ]]; then
5226 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5227 #LOV_MAX_STRIPE_COUNT is 2000
5228 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5230 sc=$(($STRIPECOUNT - 1))
5232 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5233 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5234 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5235 error "lverify failed"
5237 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5240 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5241 test_mkdir -p $DIR/$tdir
5243 $SETSTRIPE $DIR/$tdir || error "setstripe"
5244 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5245 error "no stripe info failed"
5247 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5249 run_test 65e "directory setstripe defaults ======================="
5252 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5253 test_mkdir -p $DIR/${tdir}f
5254 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5256 run_test 65f "dir setstripe permission (should return error) ==="
5259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5260 test_mkdir -p $DIR/$tdir
5261 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5263 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5264 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5265 error "delete default stripe failed"
5267 run_test 65g "directory setstripe -d ==========================="
5270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5271 test_mkdir -p $DIR/$tdir
5272 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5274 test_mkdir -p $DIR/$tdir/dd1
5275 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5276 error "stripe info inherit failed"
5278 run_test 65h "directory stripe info inherit ===================="
5280 test_65i() { # bug6367
5281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5282 $SETSTRIPE -S 65536 -c -1 $MOUNT
5284 run_test 65i "set non-default striping on root directory (bug 6367)="
5286 test_65ia() { # bug12836
5287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5288 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5290 run_test 65ia "getstripe on -1 default directory striping"
5292 test_65ib() { # bug12836
5293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5294 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5296 run_test 65ib "getstripe -v on -1 default directory striping"
5298 test_65ic() { # bug12836
5299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5300 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5302 run_test 65ic "new find on -1 default directory striping"
5304 test_65j() { # bug6367
5305 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5307 # if we aren't already remounting for each test, do so for this test
5308 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5309 cleanup || error "failed to unmount"
5312 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5314 run_test 65j "set default striping on root directory (bug 6367)="
5316 test_65k() { # bug11679
5317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5318 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5319 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5321 echo "Check OST status: "
5322 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5323 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5325 for OSC in $MDS_OSCS; do
5326 echo $OSC "is activate"
5327 do_facet $SINGLEMDS lctl --device %$OSC activate
5331 for INACTIVE_OSC in $MDS_OSCS; do
5332 echo "Deactivate: " $INACTIVE_OSC
5333 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5334 for STRIPE_OSC in $MDS_OSCS; do
5335 OST=`osc_to_ost $STRIPE_OSC`
5336 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5337 awk -F: /$OST/'{ print $1 }' | head -n 1`
5339 [ -f $DIR/$tdir/$IDX ] && continue
5340 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5341 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5343 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5346 echo $INACTIVE_OSC "is Activate."
5347 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5350 run_test 65k "validate manual striping works properly with deactivated OSCs"
5352 test_65l() { # bug 12836
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5354 test_mkdir -p $DIR/$tdir/test_dir
5355 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5356 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5358 run_test 65l "lfs find on -1 stripe dir ========================"
5360 # bug 2543 - update blocks count on client
5362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5364 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5365 sync; sync_all_data; sync; sync_all_data
5366 cancel_lru_locks osc
5367 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5368 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5370 run_test 66 "update inode blocks count on client ==============="
5375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5377 if [ ! -z "$LLOOP" ]; then
5378 if swapon -s | grep -q $LLOOP; then
5379 swapoff $LLOOP || error "swapoff failed"
5382 $LCTL blockdev_detach $LLOOP || error "detach failed"
5386 if [ ! -z "$LLITELOOPLOAD" ]; then
5394 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5398 swapon -s | awk '($1 == "'$1'") { print $4 }'
5401 # test case for lloop driver, basic function
5403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5404 [ "$UID" != 0 ] && skip_env "must run as root" && return
5405 llite_lloop_enabled || \
5406 { skip_env "llite_lloop module disabled" && return; }
5408 trap cleanup_68 EXIT
5410 if ! module_loaded llite_lloop; then
5411 if load_module llite/llite_lloop; then
5414 skip_env "can't find module llite_lloop"
5419 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5420 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5421 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5423 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5424 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5428 run_test 68a "lloop driver - basic test ========================"
5430 # excercise swapping to lustre by adding a high priority swapfile entry
5431 # and then consuming memory until it is used.
5432 test_68b() { # was test_68
5433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5434 [ "$UID" != 0 ] && skip_env "must run as root" && return
5435 lctl get_param -n devices | grep -q obdfilter && \
5436 skip "local OST" && return
5438 grep -q llite_lloop /proc/modules
5439 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5441 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5442 skip "can't reliably test swap with TCP" && return
5444 MEMTOTAL=`meminfo MemTotal`
5445 NR_BLOCKS=$((MEMTOTAL>>8))
5446 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5448 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5449 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5452 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5454 trap cleanup_68 EXIT
5456 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5458 echo "before: `swapon -s | grep $LLOOP`"
5459 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5460 echo "after: `swapon -s | grep $LLOOP`"
5461 SWAPUSED=`swap_used $LLOOP`
5465 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5467 run_test 68b "support swapping to Lustre ========================"
5469 # bug5265, obdfilter oa2dentry return -ENOENT
5470 # #define OBD_FAIL_OST_ENOENT 0x217
5472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5473 remote_ost_nodsh && skip "remote OST with nodsh" && return
5476 $SETSTRIPE -c 1 -i 0 $f
5478 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5480 do_facet ost1 lctl set_param fail_loc=0x217
5481 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5482 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5484 do_facet ost1 lctl set_param fail_loc=0
5485 $DIRECTIO write $f 0 2 || error "write error"
5487 cancel_lru_locks osc
5488 $DIRECTIO read $f 0 1 || error "read error"
5490 do_facet ost1 lctl set_param fail_loc=0x217
5491 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5493 do_facet ost1 lctl set_param fail_loc=0
5496 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5499 test_mkdir -p $DIR/$tdir
5500 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5502 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5504 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5505 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5506 [ "$RUNAS_ID" = "$UID" ] &&
5507 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5509 # Check that testing environment is properly set up. Skip if not
5510 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5511 skip_env "User $RUNAS_ID does not exist - skipping"
5515 chmod 777 $DIR/$tfile
5516 chmod ug+s $DIR/$tfile
5517 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5518 error "$RUNAS dd $DIR/$tfile failed"
5519 # See if we are still setuid/sgid
5520 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5521 error "S/gid is not dropped on write"
5522 # Now test that MDS is updated too
5523 cancel_lru_locks mdc
5524 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5525 error "S/gid is not dropped on MDS"
5528 run_test 72a "Test that remove suid works properly (bug5695) ===="
5530 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5533 [ "$RUNAS_ID" = "$UID" ] && \
5534 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5535 [ "$RUNAS_ID" -eq 0 ] && \
5536 skip_env "RUNAS_ID = 0 -- skipping" && return
5538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5539 # Check that testing environment is properly set up. Skip if not
5540 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5541 skip_env "User $RUNAS_ID does not exist - skipping"
5544 touch $DIR/${tfile}-f{g,u}
5545 test_mkdir $DIR/${tfile}-dg
5546 test_mkdir $DIR/${tfile}-du
5547 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5548 chmod g+s $DIR/${tfile}-{f,d}g
5549 chmod u+s $DIR/${tfile}-{f,d}u
5550 for perm in 777 2777 4777; do
5551 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5552 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5553 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5554 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5558 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5560 # bug 3462 - multiple simultaneous MDC requests
5562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5563 test_mkdir $DIR/d73-1
5564 test_mkdir $DIR/d73-2
5565 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5568 lctl set_param fail_loc=0x80000129
5569 $MULTIOP $DIR/d73-1/f73-2 Oc &
5571 lctl set_param fail_loc=0
5573 $MULTIOP $DIR/d73-2/f73-3 Oc &
5577 wait $pid1 || return 1
5581 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5582 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5583 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5587 run_test 73 "multiple MDC requests (should not deadlock)"
5589 test_74a() { # bug 6149, 6184
5590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5591 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5593 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5594 # will spin in a tight reconnection loop
5596 $LCTL set_param fail_loc=0x8000030e
5597 # get any lock that won't be difficult - lookup works.
5599 $LCTL set_param fail_loc=0
5603 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5605 test_74b() { # bug 13310
5606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5607 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5609 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5610 # will spin in a tight reconnection loop
5611 $LCTL set_param fail_loc=0x8000030e
5612 # get a "difficult" lock
5614 $LCTL set_param fail_loc=0
5618 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5622 #define OBD_FAIL_LDLM_NEW_LOCK
5623 $LCTL set_param fail_loc=0x319
5624 touch $DIR/$tfile && error "touch successful"
5625 $LCTL set_param fail_loc=0
5628 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5631 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5634 get_inode_slab_tunables() {
5635 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5638 set_inode_slab_tunables() {
5639 echo "lustre_inode_cache $1" > /proc/slabinfo
5642 test_76() { # Now for bug 20433, added originally in bug 1443
5643 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5644 local SLAB_SETTINGS=`get_inode_slab_tunables`
5645 local CPUS=`getconf _NPROCESSORS_ONLN`
5646 # we cannot set limit below 1 which means 1 inode in each
5647 # per-cpu cache is still allowed
5648 set_inode_slab_tunables "1 1 0"
5649 cancel_lru_locks osc
5650 BEFORE_INODES=$(num_inodes)
5651 echo "before inodes: $BEFORE_INODES"
5653 [ "$SLOW" = "no" ] && COUNT=100
5654 for i in $(seq $COUNT); do
5658 cancel_lru_locks osc
5659 AFTER_INODES=$(num_inodes)
5660 echo "after inodes: $AFTER_INODES"
5662 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5664 AFTER_INODES=$(num_inodes)
5666 echo "wait $wait seconds inodes: $AFTER_INODES"
5667 if [ $wait -gt 30 ]; then
5668 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5671 set_inode_slab_tunables "$SLAB_SETTINGS"
5673 run_test 76 "confirm clients recycle inodes properly ===="
5679 # Note: in sptlrpc modes which enable its own bulk checksum, the
5680 # original crc32_le bulk checksum will be automatically disabled,
5681 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5682 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5683 # In this case set_checksums() will not be no-op, because sptlrpc
5684 # bulk checksum will be enabled all through the test.
5686 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5687 lctl set_param -n osc.*.checksums $1
5691 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5692 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5693 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5694 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5697 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5698 log "set checksum type to $1"
5701 F77_TMP=$TMP/f77-temp
5704 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5705 error "error writing to $F77_TMP"
5708 test_77a() { # bug 10889
5709 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5710 $GSS && skip "could not run with gss" && return
5711 [ ! -f $F77_TMP ] && setup_f77
5713 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5717 run_test 77a "normal checksum read/write operation"
5719 test_77b() { # bug 10889
5720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 $GSS && skip "could not run with gss" && return
5722 [ ! -f $F77_TMP ] && setup_f77
5723 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5724 $LCTL set_param fail_loc=0x80000409
5727 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5728 error "dd error: $?"
5729 $LCTL set_param fail_loc=0
5731 for algo in $CKSUM_TYPES; do
5732 cancel_lru_locks osc
5733 set_checksum_type $algo
5734 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5735 $LCTL set_param fail_loc=0x80000408
5736 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5737 $LCTL set_param fail_loc=0
5740 set_checksum_type $ORIG_CSUM_TYPE
5743 run_test 77b "checksum error on client write, read"
5745 test_77d() { # bug 10889
5746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5747 $GSS && skip "could not run with gss" && return
5748 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5749 $LCTL set_param fail_loc=0x80000409
5751 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5752 error "direct write: rc=$?"
5753 $LCTL set_param fail_loc=0
5756 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5757 $LCTL set_param fail_loc=0x80000408
5759 cancel_lru_locks osc
5760 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5761 error "direct read: rc=$?"
5762 $LCTL set_param fail_loc=0
5765 run_test 77d "checksum error on OST direct write, read"
5767 test_77f() { # bug 10889
5768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5769 $GSS && skip "could not run with gss" && return
5771 for algo in $CKSUM_TYPES; do
5772 cancel_lru_locks osc
5773 set_checksum_type $algo
5774 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5775 $LCTL set_param fail_loc=0x409
5776 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5777 error "direct write succeeded"
5778 $LCTL set_param fail_loc=0
5780 set_checksum_type $ORIG_CSUM_TYPE
5783 run_test 77f "repeat checksum error on write (expect error)"
5785 test_77g() { # bug 10889
5786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5787 $GSS && skip "could not run with gss" && return
5788 remote_ost_nodsh && skip "remote OST with nodsh" && return
5790 [ ! -f $F77_TMP ] && setup_f77
5792 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5793 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5794 do_facet ost1 lctl set_param fail_loc=0x8000021a
5796 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5797 error "write error: rc=$?"
5798 do_facet ost1 lctl set_param fail_loc=0
5801 cancel_lru_locks osc
5802 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5803 do_facet ost1 lctl set_param fail_loc=0x8000021b
5805 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5806 do_facet ost1 lctl set_param fail_loc=0
5809 run_test 77g "checksum error on OST write, read"
5811 test_77i() { # bug 13805
5812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5813 $GSS && skip "could not run with gss" && return
5814 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5815 lctl set_param fail_loc=0x40b
5816 remount_client $MOUNT
5817 lctl set_param fail_loc=0
5818 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5819 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5820 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5821 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5823 remount_client $MOUNT
5825 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5827 test_77j() { # bug 13805
5828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5829 $GSS && skip "could not run with gss" && return
5830 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5831 lctl set_param fail_loc=0x40c
5832 remount_client $MOUNT
5833 lctl set_param fail_loc=0
5834 sleep 2 # wait async osc connect to finish
5835 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5836 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5837 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5838 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5840 remount_client $MOUNT
5842 run_test 77j "client only supporting ADLER32"
5844 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5848 test_78() { # bug 10901
5849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5850 remote_ost || { skip_env "local OST" && return; }
5853 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5854 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5855 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5856 echo "MemTotal: $MEMTOTAL"
5858 # reserve 256MB of memory for the kernel and other running processes,
5859 # and then take 1/2 of the remaining memory for the read/write buffers.
5860 if [ $MEMTOTAL -gt 512 ] ;then
5861 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5863 # for those poor memory-starved high-end clusters...
5864 MEMTOTAL=$((MEMTOTAL / 2))
5866 echo "Mem to use for directio: $MEMTOTAL"
5868 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5869 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5870 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5871 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5873 echo "Smallest OST: $SMALLESTOST"
5874 [[ $SMALLESTOST -lt 10240 ]] &&
5875 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5877 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5878 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5880 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5881 echo "File size: $F78SIZE"
5882 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5883 for i in $(seq 1 $NSEQ); do
5884 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5885 echo directIO rdwr round $i of $NSEQ
5886 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5891 run_test 78 "handle large O_DIRECT writes correctly ============"
5893 test_79() { # bug 12743
5894 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5895 wait_delete_completed
5897 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5898 BKFREE=$(calc_osc_kbytes kbytesfree)
5899 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5901 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5902 DFTOTAL=`echo $STRING | cut -d, -f1`
5903 DFUSED=`echo $STRING | cut -d, -f2`
5904 DFAVAIL=`echo $STRING | cut -d, -f3`
5905 DFFREE=$(($DFTOTAL - $DFUSED))
5907 ALLOWANCE=$((64 * $OSTCOUNT))
5909 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5910 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5911 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5913 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5914 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5915 error "df free($DFFREE) mismatch OST free($BKFREE)"
5917 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5918 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5919 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5922 run_test 79 "df report consistency check ======================="
5924 test_80() { # bug 10718
5925 remote_ost_nodsh && skip "remote OST with nodsh" && return
5926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5927 # relax strong synchronous semantics for slow backends like ZFS
5928 local soc="obdfilter.*.sync_on_lock_cancel"
5929 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5931 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5932 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5933 facet_active_host $host; done | sort -u)
5934 do_nodes $hosts lctl set_param $soc=never
5937 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5939 local BEFORE=`date +%s`
5940 cancel_lru_locks osc
5941 local AFTER=`date +%s`
5942 local DIFF=$((AFTER-BEFORE))
5943 if [ $DIFF -gt 1 ] ; then
5944 error "elapsed for 1M@1T = $DIFF"
5947 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5951 run_test 80 "Page eviction is equally fast at high offsets too ===="
5953 test_81a() { # LU-456
5954 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5955 remote_ost_nodsh && skip "remote OST with nodsh" && return
5956 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5957 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5958 do_facet ost1 lctl set_param fail_loc=0x80000228
5960 # write should trigger a retry and success
5961 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5962 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5964 if [ $RC -ne 0 ] ; then
5965 error "write should success, but failed for $RC"
5968 run_test 81a "OST should retry write when get -ENOSPC ==============="
5970 test_81b() { # LU-456
5971 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5972 remote_ost_nodsh && skip "remote OST with nodsh" && return
5973 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5974 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5975 do_facet ost1 lctl set_param fail_loc=0x228
5977 # write should retry several times and return -ENOSPC finally
5978 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5979 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5982 if [ $RC -ne $ENOSPC ] ; then
5983 error "dd should fail for -ENOSPC, but succeed."
5986 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5988 test_82() { # LU-1031
5989 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5993 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5995 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5997 kill -USR1 $MULTIPID2
5999 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6000 error "First grouplock does not block second one"
6002 echo "Second grouplock blocks first one"
6004 kill -USR1 $MULTIPID1
6008 run_test 82 "Basic grouplock test ==============================="
6011 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6013 test_mkdir -p $DIR/d99cvsroot
6014 chown $RUNAS_ID $DIR/d99cvsroot
6015 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6018 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6021 run_test 99a "cvs init ========================================="
6024 [ -z "$(which cvs 2>/dev/null)" ] &&
6025 skip_env "could not find cvs" && return
6026 [ ! -d $DIR/d99cvsroot ] && test_99a
6028 # some versions of cvs import exit(1) when asked to import links or
6029 # files they can't read. ignore those files.
6030 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6031 ! -perm +4 -printf '-I %f\n')
6032 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6033 d99reposname vtag rtag
6035 run_test 99b "cvs import ======================================="
6038 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6039 [ ! -d $DIR/d99cvsroot ] && test_99b
6041 test_mkdir -p $DIR/d99reposname
6042 chown $RUNAS_ID $DIR/d99reposname
6043 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6045 run_test 99c "cvs checkout ====================================="
6048 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6049 [ ! -d $DIR/d99cvsroot ] && test_99c
6050 cd $DIR/d99reposname
6052 $RUNAS cvs add -m 'addmsg' foo99
6054 run_test 99d "cvs add =========================================="
6057 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6058 [ ! -d $DIR/d99cvsroot ] && test_99c
6059 cd $DIR/d99reposname
6062 run_test 99e "cvs update ======================================="
6065 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6066 [ ! -d $DIR/d99cvsroot ] && test_99d
6067 cd $DIR/d99reposname
6068 $RUNAS cvs commit -m 'nomsg' foo99
6069 rm -fr $DIR/d99cvsroot
6071 run_test 99f "cvs commit ======================================="
6074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6075 [ "$NETTYPE" = tcp ] || \
6076 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6079 remote_ost_nodsh && skip "remote OST with nodsh" && return
6080 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6082 { skip "useless for local single node setup" && return; }
6084 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6085 [ "$PROT" != "tcp" ] && continue
6086 RPORT=$(echo $REMOTE | cut -d: -f2)
6087 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6090 LPORT=`echo $LOCAL | cut -d: -f2`
6091 if [ $LPORT -ge 1024 ]; then
6092 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6094 error_exit "local: $LPORT > 1024, remote: $RPORT"
6097 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6099 run_test 100 "check local port using privileged port ==========="
6101 function get_named_value()
6110 echo $line | sed "s/^$tag[ ]*//"
6117 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6118 awk '/^max_cached_mb/ { print $2 }')
6121 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6127 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6131 local cache_limit=32
6133 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6134 trap cleanup_101a EXIT
6135 $LCTL set_param -n llite.*.read_ahead_stats 0
6136 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6139 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6141 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6142 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6145 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6146 get_named_value 'read but discarded' | cut -d" " -f1); do
6147 discard=$(($discard + $s))
6151 if [[ $(($discard * 10)) -gt $nreads ]]; then
6152 $LCTL get_param osc.*-osc*.rpc_stats
6153 $LCTL get_param llite.*.read_ahead_stats
6154 error "too many ($discard) discarded pages"
6156 rm -f $DIR/$tfile || true
6158 run_test 101a "check read-ahead for random reads ================"
6161 test_mkdir -p $DIR/$tdir
6162 local STRIPE_SIZE=$1
6163 local FILE_LENGTH=$2
6166 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6168 local list=$(comma_list $(osts_nodes))
6169 set_osd_param $list '' read_cache_enable 0
6170 set_osd_param $list '' writethrough_cache_enable 0
6172 trap cleanup_test101bc EXIT
6173 # prepare the read-ahead file
6174 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6176 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6177 count=$FILE_SIZE_MB 2> /dev/null
6181 cleanup_test101bc() {
6186 local list=$(comma_list $(osts_nodes))
6187 set_osd_param $list '' read_cache_enable 1
6188 set_osd_param $list '' writethrough_cache_enable 1
6192 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6197 local STRIPE_SIZE=$2
6198 local FILE_LENGTH=$3
6199 local RA_INC=1048576
6200 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6201 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6202 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6203 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6204 get_named_value 'read but discarded' |
6205 cut -d" " -f1 | calc_total)
6206 if [[ $DISCARD -gt $discard_limit ]]; then
6207 $LCTL get_param llite.*.read_ahead_stats
6208 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6210 echo "Read-ahead success for size ${READ_SIZE}"
6215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6216 [[ $OSTCOUNT -lt 2 ]] &&
6217 skip_env "skipping stride IO stride-ahead test" && return
6218 local STRIPE_SIZE=1048576
6219 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6220 if [ $SLOW == "yes" ]; then
6221 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6223 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6226 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6228 # prepare the read-ahead file
6229 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6230 cancel_lru_locks osc
6231 for BIDX in 2 4 8 16 32 64 128 256
6233 local BSIZE=$((BIDX*4096))
6234 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6235 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6236 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6237 $LCTL set_param -n llite.*.read_ahead_stats 0
6238 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6239 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6240 cancel_lru_locks osc
6241 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6246 run_test 101b "check stride-io mode read-ahead ================="
6249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6250 local STRIPE_SIZE=1048576
6251 local FILE_LENGTH=$((STRIPE_SIZE*100))
6255 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6257 cancel_lru_locks osc
6258 $LCTL set_param osc.*.rpc_stats 0
6259 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6260 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6261 local stats=$($LCTL get_param -n $osc_rpc_stats)
6262 local lines=$(echo "$stats" | awk 'END {print NR;}')
6265 if [ $lines -le 20 ]; then
6268 for size in 1 2 4 8; do
6269 local rpc=$(echo "$stats" |
6270 awk '($1 == "'$size':") {print $2; exit; }')
6272 error "Small $((size*4))k read IO $rpc !"
6274 echo "$osc_rpc_stats check passed!"
6279 run_test 101c "check stripe_size aligned read-ahead ================="
6282 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6283 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6288 local file=$DIR/$tfile
6289 local sz_MB=${FILESIZE_101d:-500}
6290 local ra_MB=${READAHEAD_MB:-40}
6292 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6293 [ $free_MB -lt $sz_MB ] &&
6294 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6296 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6297 $SETSTRIPE -c -1 $file || error "setstripe failed"
6299 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6300 echo Cancel LRU locks on lustre client to flush the client cache
6301 cancel_lru_locks osc
6303 echo Disable read-ahead
6304 local old_READAHEAD=$(set_read_ahead 0)
6306 echo Reading the test file $file with read-ahead disabled
6307 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6309 echo Cancel LRU locks on lustre client to flush the client cache
6310 cancel_lru_locks osc
6311 echo Enable read-ahead with ${ra_MB}MB
6312 set_read_ahead $ra_MB
6314 echo Reading the test file $file with read-ahead enabled
6315 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6317 echo "read-ahead disabled time read $raOFF"
6318 echo "read-ahead enabled time read $raON"
6320 set_read_ahead $old_READAHEAD
6322 wait_delete_completed
6324 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6325 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6327 run_test 101d "file read with and without read-ahead enabled"
6330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6331 local file=$DIR/$tfile
6332 local size_KB=500 #KB
6336 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6337 local need_KB=$((count * size_KB))
6338 [[ $free_KB -le $need_KB ]] &&
6339 skip_env "Need free space $need_KB, have $free_KB" && return
6341 echo "Creating $count ${size_KB}K test files"
6342 for ((i = 0; i < $count; i++)); do
6343 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6346 echo "Cancel LRU locks on lustre client to flush the client cache"
6347 cancel_lru_locks osc
6349 echo "Reset readahead stats"
6350 $LCTL set_param -n llite.*.read_ahead_stats 0
6352 for ((i = 0; i < $count; i++)); do
6353 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6356 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6357 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6359 for ((i = 0; i < $count; i++)); do
6360 rm -rf $file.$i 2>/dev/null
6363 #10000 means 20% reads are missing in readahead
6364 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6366 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6368 cleanup_test101f() {
6370 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6371 rm -rf $DIR/$tfile 2>/dev/null
6375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6376 local file=$DIR/$tfile
6379 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6380 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6381 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6382 trap cleanup_test101f EXIT
6384 echo Cancel LRU locks on lustre client to flush the client cache
6385 cancel_lru_locks osc
6387 echo Reset readahead stats
6388 $LCTL set_param -n llite.*.read_ahead_stats 0
6389 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6390 # readahead should read in 2M file on second read, so only miss
6392 echo Random 4K reads on 2M file for 1000 times
6393 $READS -f $file -s 2097152 -b 4096 -n $nreads
6395 echo checking missing pages
6396 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6397 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6399 [ $miss -lt 3 ] || error "misses too much pages!"
6402 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6405 test_mkdir -p $DIR/$tdir
6406 chown $RUNAS_ID $DIR/$tdir
6409 STRIPE_COUNT=$OSTCOUNT
6410 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6412 trap cleanup_test102 EXIT
6414 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6416 for num in 1 2 3 4; do
6417 for count in $(seq 1 $STRIPE_COUNT); do
6418 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6419 local size=`expr $STRIPE_SIZE \* $num`
6420 local file=file"$num-$idx-$count"
6421 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6427 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6433 rm -rf $DIR/d0.sanity/d102
6437 local testfile=$DIR/$tfile
6441 [ "$UID" != 0 ] && skip_env "must run as root" && return
6442 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6443 skip_env "must have user_xattr" && return
6445 [ -z "$(which setfattr 2>/dev/null)" ] &&
6446 skip_env "could not find setfattr" && return
6448 echo "set/get xattr..."
6449 setfattr -n trusted.name1 -v value1 $testfile ||
6450 error "setfattr -n trusted.name1=value1 $testfile failed"
6451 getfattr -n trusted.name1 $testfile 2> /dev/null |
6452 grep "trusted.name1=.value1" ||
6453 error "$testfile missing trusted.name1=value1"
6455 setfattr -n user.author1 -v author1 $testfile ||
6456 error "setfattr -n user.author1=author1 $testfile failed"
6457 getfattr -n user.author1 $testfile 2> /dev/null |
6458 grep "user.author1=.author1" ||
6459 error "$testfile missing trusted.author1=author1"
6462 setfattr -n trusted.name2 -v value2 $testfile ||
6463 error "$testfile unable to set trusted.name2"
6464 setfattr -n trusted.name3 -v value3 $testfile ||
6465 error "$testfile unable to set trusted.name3"
6466 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6467 grep "trusted.name" | wc -l) -eq 3 ] ||
6468 error "$testfile missing 3 trusted.name xattrs"
6470 setfattr -n user.author2 -v author2 $testfile ||
6471 error "$testfile unable to set user.author2"
6472 setfattr -n user.author3 -v author3 $testfile ||
6473 error "$testfile unable to set user.author3"
6474 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6475 grep "user.author" | wc -l) -eq 3 ] ||
6476 error "$testfile missing 3 user.author xattrs"
6478 echo "remove xattr..."
6479 setfattr -x trusted.name1 $testfile ||
6480 error "$testfile error deleting trusted.name1"
6481 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6482 error "$testfile did not delete trusted.name1 xattr"
6484 setfattr -x user.author1 $testfile ||
6485 error "$testfile error deleting user.author1"
6486 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6487 error "$testfile did not delete trusted.name1 xattr"
6489 # b10667: setting lustre special xattr be silently discarded
6490 echo "set lustre special xattr ..."
6491 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6492 error "$testfile allowed setting trusted.lov"
6494 run_test 102a "user xattr test =================================="
6497 [ -z "$(which setfattr 2>/dev/null)" ] &&
6498 skip_env "could not find setfattr" && return
6500 # b10930: get/set/list trusted.lov xattr
6501 echo "get/set/list trusted.lov xattr ..."
6502 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6503 local testfile=$DIR/$tfile
6504 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6505 error "setstripe failed"
6506 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6507 error "getstripe failed"
6508 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6509 error "can't get trusted.lov from $testfile"
6511 local testfile2=${testfile}2
6512 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6513 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6516 setfattr -n trusted.lov -v $value $testfile2
6517 local stripe_size=$($GETSTRIPE -S $testfile2)
6518 local stripe_count=$($GETSTRIPE -c $testfile2)
6519 [[ $stripe_size -eq 65536 ]] ||
6520 error "stripe size $stripe_size != 65536"
6521 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6522 error "stripe count $stripe_count != $STRIPECOUNT"
6525 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6528 [ -z "$(which setfattr 2>/dev/null)" ] &&
6529 skip_env "could not find setfattr" && return
6531 # b10930: get/set/list lustre.lov xattr
6532 echo "get/set/list lustre.lov xattr ..."
6533 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6534 test_mkdir -p $DIR/$tdir
6535 chown $RUNAS_ID $DIR/$tdir
6536 local testfile=$DIR/$tdir/$tfile
6537 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6538 error "setstripe failed"
6539 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6540 error "getstripe failed"
6541 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6542 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6544 local testfile2=${testfile}2
6545 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6546 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6548 $RUNAS $MCREATE $testfile2
6549 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6550 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6551 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6552 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6553 [ $stripe_count -eq $STRIPECOUNT ] ||
6554 error "stripe count $stripe_count != $STRIPECOUNT"
6556 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6558 compare_stripe_info1() {
6559 local stripe_index_all_zero=true
6561 for num in 1 2 3 4; do
6562 for count in $(seq 1 $STRIPE_COUNT); do
6563 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6564 local size=$((STRIPE_SIZE * num))
6565 local file=file"$num-$offset-$count"
6566 stripe_size=$(lfs getstripe -S $PWD/$file)
6567 [[ $stripe_size -ne $size ]] &&
6568 error "$file: size $stripe_size != $size"
6569 stripe_count=$(lfs getstripe -c $PWD/$file)
6570 # allow fewer stripes to be created, ORI-601
6571 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6572 error "$file: count $stripe_count != $count"
6573 stripe_index=$(lfs getstripe -i $PWD/$file)
6574 [[ $stripe_index -ne 0 ]] &&
6575 stripe_index_all_zero=false
6579 $stripe_index_all_zero &&
6580 error "all files are being extracted starting from OST index 0"
6585 [ -n "$(which tar 2>/dev/null)" ] &&
6586 strings $(which tar) | grep -q "lustre" && echo tar
6590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6591 # b10930: tar test for trusted.lov xattr
6592 TAR=$(find_lustre_tar)
6593 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6594 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6596 test_mkdir -p $DIR/d102d
6597 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6599 compare_stripe_info1
6601 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6605 # b10930: tar test for trusted.lov xattr
6606 TAR=$(find_lustre_tar)
6607 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6608 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6610 test_mkdir -p $DIR/d102f
6612 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6614 compare_stripe_info1
6616 run_test 102f "tar copy files, not keep osts ==========="
6619 local xsize=${1:-1024} # in bytes
6620 local file=$DIR/$tfile
6622 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6623 skip "must have user_xattr" && return 0
6624 [ -z "$(which setfattr 2>/dev/null)" ] &&
6625 skip_env "could not find setfattr" && return 0
6626 [ -z "$(which getfattr 2>/dev/null)" ] &&
6627 skip_env "could not find getfattr" && return 0
6631 local value="$(generate_string $xsize)"
6633 local xbig=trusted.big
6634 log "save $xbig on $file"
6635 setfattr -n $xbig -v $value $file ||
6636 error "saving $xbig on $file failed"
6638 local orig=$(get_xattr_value $xbig $file)
6639 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6641 local xsml=trusted.sml
6642 log "save $xsml on $file"
6643 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6645 local new=$(get_xattr_value $xbig $file)
6646 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6648 log "grow $xsml on $file"
6649 setfattr -n $xsml -v "$value" $file ||
6650 error "growing $xsml on $file failed"
6652 new=$(get_xattr_value $xbig $file)
6653 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6654 log "$xbig still valid after growing $xsml"
6659 test_102h() { # bug 15777
6662 run_test 102h "grow xattr from inside inode to external block"
6665 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6666 grow_xattr $(max_xattr_size)
6668 run_test 102ha "grow xattr from inside inode to external inode"
6670 test_102i() { # bug 17038
6671 [ -z "$(which getfattr 2>/dev/null)" ] &&
6672 skip "could not find getfattr" && return
6674 ln -s $DIR/$tfile $DIR/${tfile}link
6675 getfattr -n trusted.lov $DIR/$tfile ||
6676 error "lgetxattr on $DIR/$tfile failed"
6677 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6678 grep -i "no such attr" ||
6679 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6680 rm -f $DIR/$tfile $DIR/${tfile}link
6682 run_test 102i "lgetxattr test on symbolic link ============"
6685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6686 TAR=$(find_lustre_tar)
6687 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6688 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6689 setup_test102 "$RUNAS"
6690 test_mkdir -p $DIR/d102j
6691 chown $RUNAS_ID $DIR/d102j
6692 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6694 compare_stripe_info1 "$RUNAS"
6696 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6699 [ -z "$(which setfattr 2>/dev/null)" ] &&
6700 skip "could not find setfattr" && return
6702 # b22187 just check that does not crash for regular file.
6703 setfattr -n trusted.lov $DIR/$tfile
6704 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6705 local test_kdir=$DIR/d102k
6706 test_mkdir $test_kdir
6707 local default_size=`$GETSTRIPE -S $test_kdir`
6708 local default_count=`$GETSTRIPE -c $test_kdir`
6709 local default_offset=`$GETSTRIPE -i $test_kdir`
6710 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6711 error 'dir setstripe failed'
6712 setfattr -n trusted.lov $test_kdir
6713 local stripe_size=`$GETSTRIPE -S $test_kdir`
6714 local stripe_count=`$GETSTRIPE -c $test_kdir`
6715 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6716 [ $stripe_size -eq $default_size ] ||
6717 error "stripe size $stripe_size != $default_size"
6718 [ $stripe_count -eq $default_count ] ||
6719 error "stripe count $stripe_count != $default_count"
6720 [ $stripe_offset -eq $default_offset ] ||
6721 error "stripe offset $stripe_offset != $default_offset"
6722 rm -rf $DIR/$tfile $test_kdir
6724 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6727 [ -z "$(which getfattr 2>/dev/null)" ] &&
6728 skip "could not find getfattr" && return
6730 # LU-532 trusted. xattr is invisible to non-root
6731 local testfile=$DIR/$tfile
6735 echo "listxattr as user..."
6736 chown $RUNAS_ID $testfile
6737 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6738 grep -q "trusted" &&
6739 error "$testfile trusted xattrs are user visible"
6743 run_test 102l "listxattr size test =================================="
6745 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6746 local path=$DIR/$tfile
6749 listxattr_size_check $path || error "listattr_size_check $path failed"
6751 run_test 102m "Ensure listxattr fails on small bufffer ========"
6755 getxattr() { # getxattr path name
6756 # Return the base64 encoding of the value of xattr name on path.
6760 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6762 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6764 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6766 getfattr --absolute-names --encoding=base64 --name=$name $path |
6767 awk -F= -v name=$name '$1 == name {
6768 print substr($0, index($0, "=") + 1);
6772 test_102n() { # LU-4101 mdt: protect internal xattrs
6773 local file0=$DIR/$tfile.0
6774 local file1=$DIR/$tfile.1
6775 local xattr0=$TMP/$tfile.0
6776 local xattr1=$TMP/$tfile.1
6780 [ -z "$(which setfattr 2>/dev/null)" ] &&
6781 skip "could not find setfattr" && return
6783 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6785 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6789 rm -rf $file0 $file1 $xattr0 $xattr1
6792 # Get 'before' xattrs of $file1.
6793 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6795 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6796 # Try to copy xattr from $file0 to $file1.
6797 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6799 setfattr --name=trusted.$name --value="$value" $file1 ||
6800 error "setxattr 'trusted.$name' failed"
6802 # Try to set a garbage xattr.
6803 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6805 setfattr --name=trusted.$name --value="$value" $file1 ||
6806 error "setxattr 'trusted.$name' failed"
6808 # Try to remove the xattr from $file1. We don't care if this
6809 # appears to succeed or fail, we just don't want there to be
6810 # any changes or crashes.
6811 setfattr --remove=$trusted.$name $file1 2> /dev/null
6814 # Get 'after' xattrs of file1.
6815 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6817 if ! diff $xattr0 $xattr1; then
6818 error "before and after xattrs of '$file1' differ"
6821 rm -rf $file0 $file1 $xattr0 $xattr1
6825 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6827 test_102p() { # LU-4703 setxattr did not check ownership
6828 local testfile=$DIR/$tfile
6830 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6831 skip "MDS needs to be at least 2.5.56" && return
6835 echo "setfacl as user..."
6836 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6837 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6839 echo "setfattr as user..."
6840 setfacl -m "u:$RUNAS_ID:---" $testfile
6841 $RUNAS setfattr -x system.posix_acl_access $testfile
6842 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6844 run_test 102p "check setxattr(2) correctly fails without permission"
6848 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6853 [ "$UID" != 0 ] && skip_env "must run as root" && return
6854 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6855 skip "must have acl enabled" && return
6856 [ -z "$(which setfacl 2>/dev/null)" ] &&
6857 skip_env "could not find setfacl" && return
6858 $GSS && skip "could not run under gss" && return
6860 gpasswd -a daemon bin # LU-5641
6862 declare -a identity_old
6864 for num in $(seq $MDSCOUNT); do
6865 switch_identity $num true || identity_old[$num]=$?
6872 echo "performing cp ..."
6873 run_acl_subtest cp || error "run_acl_subtest cp failed"
6874 echo "performing getfacl-noacl..."
6875 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6876 echo "performing misc..."
6877 run_acl_subtest misc || error "misc test failed"
6878 echo "performing permissions..."
6879 run_acl_subtest permissions || error "permissions failed"
6880 echo "performing setfacl..."
6881 run_acl_subtest setfacl || error "setfacl test failed"
6883 # inheritance test got from HP
6884 echo "performing inheritance..."
6885 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6886 chmod +x make-tree || error "chmod +x failed"
6887 run_acl_subtest inheritance || error "inheritance test failed"
6890 echo "LU-974 ignore umask when acl is enabled..."
6891 run_acl_subtest 974 || error "LU-974 umask test failed"
6892 if [ $MDSCOUNT -ge 2 ]; then
6893 run_acl_subtest 974_remote ||
6894 error "LU-974 umask test failed under remote dir"
6897 echo "LU-2561 newly created file is same size as directory..."
6898 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6899 run_acl_subtest 2561 || error "LU-2561 test failed"
6901 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6904 run_acl_subtest 4924 || error "LU-4924 test failed"
6909 for num in $(seq $MDSCOUNT); do
6910 if [ "${identity_old[$num]}" = 1 ]; then
6911 switch_identity $num false || identity_old[$num]=$?
6915 run_test 103a "acl test ========================================="
6919 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
6920 local mountopts=$MDS_MOUNT_OPTS
6922 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
6926 stop $SINGLEMDS || error "failed to stop MDT."
6928 if [ -z "$MDS_MOUNT_OPTS" ]; then
6929 MDS_MOUNT_OPTS="-o noacl"
6931 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
6933 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6934 error "failed to start MDT."
6935 MDS_MOUNT_OPTS=$mountopts
6939 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
6943 stop $SINGLEMDS || error "failed to stop MDT."
6945 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6946 error "failed to start MDT."
6951 run_test 103b "MDS mount option 'noacl'"
6955 cp -rp $DIR/$tdir $DIR/$tdir.bak
6957 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
6958 error "$DIR/$tdir shouldn't contain default ACL"
6959 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
6960 error "$DIR/$tdir.bak shouldn't contain default ACL"
6963 run_test 103c "'cp -rp' won't set empty acl"
6966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6968 lfs df || error "lfs df failed"
6969 lfs df -ih || error "lfs df -ih failed"
6970 lfs df -h $DIR || error "lfs df -h $DIR failed"
6971 lfs df -i $DIR || error "lfs df -i $DIR failed"
6972 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6973 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6975 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6976 lctl --device %$OSC deactivate
6977 lfs df || error "lfs df with deactivated OSC failed"
6978 lctl --device %$OSC activate
6979 # wait the osc back to normal
6980 wait_osc_import_state client ost FULL
6982 lfs df || error "lfs df with reactivated OSC failed"
6985 run_test 104a "lfs df [-ih] [path] test ========================="
6988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6989 [ $RUNAS_ID -eq $UID ] &&
6990 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6992 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6993 grep "Permission denied" | wc -l)))
6994 if [ $denied_cnt -ne 0 ]; then
6995 error "lfs check servers test failed"
6998 run_test 104b "$RUNAS lfs check servers test ===================="
7001 # doesn't work on 2.4 kernels
7003 if $(flock_is_enabled); then
7004 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7006 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7010 run_test 105a "flock when mounted without -o flock test ========"
7014 if $(flock_is_enabled); then
7015 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7017 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7021 run_test 105b "fcntl when mounted without -o flock test ========"
7025 if $(flock_is_enabled); then
7026 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7028 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7032 run_test 105c "lockf when mounted without -o flock test ========"
7034 test_105d() { # bug 15924
7035 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7036 test_mkdir -p $DIR/$tdir
7037 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7038 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7039 $LCTL set_param fail_loc=0x80000315
7040 flocks_test 2 $DIR/$tdir
7042 run_test 105d "flock race (should not freeze) ========"
7044 test_105e() { # bug 22660 && 22040
7045 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7047 flocks_test 3 $DIR/$tfile
7049 run_test 105e "Two conflicting flocks from same process ======="
7051 test_106() { #bug 10921
7052 test_mkdir -p $DIR/$tdir
7053 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7054 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7056 run_test 106 "attempt exec of dir followed by chown of that dir"
7059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7066 local save_pattern=$(sysctl -n kernel.core_pattern)
7067 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7068 sysctl -w kernel.core_pattern=$file
7069 sysctl -w kernel.core_uses_pid=0
7077 kill -s 11 $SLEEPPID
7079 if [ -e $file ]; then
7080 size=`stat -c%s $file`
7081 [ $size -eq 0 ] && error "Fail to create core file $file"
7083 error "Fail to create core file $file"
7086 sysctl -w kernel.core_pattern=$save_pattern
7087 sysctl -w kernel.core_uses_pid=$save_uses_pid
7090 run_test 107 "Coredump on SIG"
7093 test_mkdir -p $DIR/$tdir
7094 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7095 error "mkdir with 255 char failed"
7096 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7097 error "mkdir with 256 char should fail, but did not"
7098 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7099 error "create with 255 char failed"
7100 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7101 error "create with 256 char should fail, but did not"
7106 run_test 110 "filename length checking"
7109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7110 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7111 tail -1 | cut -c11-20)
7112 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7113 echo "Starting with $OSTIO_pre threads"
7116 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7117 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7118 echo "$NUMTEST creates/unlinks"
7119 test_mkdir -p $DIR/$tdir
7120 createmany -o $DIR/$tdir/$tfile $NUMTEST
7121 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7123 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7124 tail -1 | cut -c11-20)
7126 # don't return an error
7127 [ $OSTIO_post == $OSTIO_pre ] && echo \
7128 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7129 echo "This may be fine, depending on what ran before this test" &&
7130 echo "and how fast this system is." && return
7132 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7134 run_test 115 "verify dynamic thread creation===================="
7137 wait_delete_completed
7138 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7139 echo OST kbytes available: ${AVAIL[@]}
7140 MAXI=0; MAXV=${AVAIL[0]}
7141 MINI=0; MINV=${AVAIL[0]}
7142 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7143 #echo OST $i: ${AVAIL[i]}kb
7144 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7145 MAXV=${AVAIL[i]}; MAXI=$i
7147 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7148 MINV=${AVAIL[i]}; MINI=$i
7151 echo Min free space: OST $MINI: $MINV
7152 echo Max free space: OST $MAXI: $MAXV
7155 test_116a() { # was previously test_116()
7156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7157 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7159 echo -n "Free space priority "
7160 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7165 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7166 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7168 trap simple_cleanup_common EXIT
7171 # Check if we need to generate uneven OSTs
7172 test_mkdir -p $DIR/$tdir/OST${MINI}
7173 local FILL=$(($MINV / 4))
7174 local DIFF=$(($MAXV - $MINV))
7175 local DIFF2=$(($DIFF * 100 / $MINV))
7177 local threshold=$(do_facet $SINGLEMDS \
7178 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7179 threshold=${threshold%%%}
7180 echo -n "Check for uneven OSTs: "
7181 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7183 if [[ $DIFF2 -gt $threshold ]]; then
7185 echo "Don't need to fill OST$MINI"
7187 # generate uneven OSTs. Write 2% over the QOS threshold value
7189 DIFF=$(($threshold - $DIFF2 + 2))
7190 DIFF2=$(( ($MINV * $DIFF)/100 ))
7191 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7192 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7193 error "setstripe failed"
7194 DIFF=$(($DIFF2 / 2048))
7196 while [ $i -lt $DIFF ]; do
7198 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7199 bs=2M count=1 2>/dev/null
7208 DIFF=$(($MAXV - $MINV))
7209 DIFF2=$(($DIFF * 100 / $MINV))
7210 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7211 if [[ $DIFF2 -gt $threshold ]]; then
7214 echo "failed - QOS mode won't be used"
7215 skip "QOS imbalance criteria not met"
7216 simple_cleanup_common
7220 MINI1=$MINI; MINV1=$MINV
7221 MAXI1=$MAXI; MAXV1=$MAXV
7223 # now fill using QOS
7224 $SETSTRIPE -c 1 $DIR/$tdir
7225 FILL=$(($FILL / 200))
7226 if [ $FILL -gt 600 ]; then
7229 echo "writing $FILL files to QOS-assigned OSTs"
7231 while [ $i -lt $FILL ]; do
7233 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7237 echo "wrote $i 200k files"
7241 echo "Note: free space may not be updated, so measurements might be off"
7243 DIFF2=$(($MAXV - $MINV))
7244 echo "free space delta: orig $DIFF final $DIFF2"
7245 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7246 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7247 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7248 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7249 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7250 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7252 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7254 # Figure out which files were written where
7255 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7256 awk '/'$MINI1': / {print $2; exit}')
7258 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7259 echo "$MINC files created on smaller OST $MINI1"
7260 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7261 awk '/'$MAXI1': / {print $2; exit}')
7263 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7264 echo "$MAXC files created on larger OST $MAXI1"
7265 FILL=$(($MAXC * 100 / $MINC - 100))
7266 [[ $MINC -gt 0 ]] &&
7267 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7268 [[ $MAXC -gt $MINC ]] ||
7269 error_ignore LU-9 "stripe QOS didn't balance free space"
7270 simple_cleanup_common
7272 run_test 116a "stripe QOS: free space balance ==================="
7274 test_116b() { # LU-2093
7275 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7276 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7277 head -1 2>/dev/null)" ] && skip "no QOS" && return
7278 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7280 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7281 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7282 do_facet $SINGLEMDS lctl set_param \
7283 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7285 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7286 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7287 do_facet $SINGLEMDS lctl set_param fail_loc=0
7289 do_facet $SINGLEMDS lctl set_param \
7290 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7292 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7294 test_117() # bug 10891
7296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7297 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7298 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7299 lctl set_param fail_loc=0x21e
7300 > $DIR/$tfile || error "truncate failed"
7301 lctl set_param fail_loc=0
7302 echo "Truncate succeeded."
7305 run_test 117 "verify osd extend =========="
7307 NO_SLOW_RESENDCOUNT=4
7308 export OLD_RESENDCOUNT=""
7309 set_resend_count () {
7310 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7311 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7312 lctl set_param -n $PROC_RESENDCOUNT $1
7313 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7316 # for reduce test_118* time (b=14842)
7317 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7319 # Reset async IO behavior after error case
7321 FILE=$DIR/reset_async
7323 # Ensure all OSCs are cleared
7324 $SETSTRIPE -c -1 $FILE
7325 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7330 test_118a() #bug 11710
7332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7335 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7336 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7337 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7339 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7340 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7345 run_test 118a "verify O_SYNC works =========="
7349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7350 remote_ost_nodsh && skip "remote OST with nodsh" && return
7354 #define OBD_FAIL_OST_ENOENT 0x217
7355 set_nodes_failloc "$(osts_nodes)" 0x217
7356 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7358 set_nodes_failloc "$(osts_nodes)" 0
7359 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7360 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7363 if [[ $RC -eq 0 ]]; then
7364 error "Must return error due to dropped pages, rc=$RC"
7368 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7369 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7373 echo "Dirty pages not leaked on ENOENT"
7375 # Due to the above error the OSC will issue all RPCs syncronously
7376 # until a subsequent RPC completes successfully without error.
7377 $MULTIOP $DIR/$tfile Ow4096yc
7382 run_test 118b "Reclaim dirty pages on fatal error =========="
7386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7388 # for 118c, restore the original resend count, LU-1940
7389 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7390 set_resend_count $OLD_RESENDCOUNT
7391 remote_ost_nodsh && skip "remote OST with nodsh" && return
7395 #define OBD_FAIL_OST_EROFS 0x216
7396 set_nodes_failloc "$(osts_nodes)" 0x216
7398 # multiop should block due to fsync until pages are written
7399 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7403 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7404 error "Multiop failed to block on fsync, pid=$MULTIPID"
7407 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7409 if [[ $WRITEBACK -eq 0 ]]; then
7410 error "No page in writeback, writeback=$WRITEBACK"
7413 set_nodes_failloc "$(osts_nodes)" 0
7416 if [[ $RC -ne 0 ]]; then
7417 error "Multiop fsync failed, rc=$RC"
7420 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7421 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7423 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7424 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7428 echo "Dirty pages flushed via fsync on EROFS"
7431 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7433 # continue to use small resend count to reduce test_118* time (b=14842)
7434 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7439 remote_ost_nodsh && skip "remote OST with nodsh" && return
7443 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7444 set_nodes_failloc "$(osts_nodes)" 0x214
7445 # multiop should block due to fsync until pages are written
7446 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7450 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7451 error "Multiop failed to block on fsync, pid=$MULTIPID"
7454 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7456 if [[ $WRITEBACK -eq 0 ]]; then
7457 error "No page in writeback, writeback=$WRITEBACK"
7460 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7461 set_nodes_failloc "$(osts_nodes)" 0
7463 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7464 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7466 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7467 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7471 echo "Dirty pages gaurenteed flushed via fsync"
7474 run_test 118d "Fsync validation inject a delay of the bulk =========="
7477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7480 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7481 lctl set_param fail_loc=0x8000040a
7483 # Should simulate EINVAL error which is fatal
7484 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7486 if [[ $RC -eq 0 ]]; then
7487 error "Must return error due to dropped pages, rc=$RC"
7490 lctl set_param fail_loc=0x0
7492 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7493 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7494 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7496 if [[ $LOCKED -ne 0 ]]; then
7497 error "Locked pages remain in cache, locked=$LOCKED"
7500 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7501 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7505 echo "No pages locked after fsync"
7510 run_test 118f "Simulate unrecoverable OSC side error =========="
7513 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7516 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7517 lctl set_param fail_loc=0x406
7519 # simulate local -ENOMEM
7520 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7523 lctl set_param fail_loc=0
7524 if [[ $RC -eq 0 ]]; then
7525 error "Must return error due to dropped pages, rc=$RC"
7528 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7529 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7530 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7532 if [[ $LOCKED -ne 0 ]]; then
7533 error "Locked pages remain in cache, locked=$LOCKED"
7536 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7537 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7541 echo "No pages locked after fsync"
7546 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7550 remote_ost_nodsh && skip "remote OST with nodsh" && return
7554 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7555 set_nodes_failloc "$(osts_nodes)" 0x20e
7556 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7557 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7560 set_nodes_failloc "$(osts_nodes)" 0
7561 if [[ $RC -eq 0 ]]; then
7562 error "Must return error due to dropped pages, rc=$RC"
7565 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7566 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7567 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7569 if [[ $LOCKED -ne 0 ]]; then
7570 error "Locked pages remain in cache, locked=$LOCKED"
7573 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7574 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7578 echo "No pages locked after fsync"
7582 run_test 118h "Verify timeout in handling recoverables errors =========="
7584 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7588 remote_ost_nodsh && skip "remote OST with nodsh" && return
7592 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7593 set_nodes_failloc "$(osts_nodes)" 0x20e
7595 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7596 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7599 set_nodes_failloc "$(osts_nodes)" 0
7603 if [[ $RC -ne 0 ]]; then
7604 error "got error, but should be not, rc=$RC"
7607 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7608 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7609 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7610 if [[ $LOCKED -ne 0 ]]; then
7611 error "Locked pages remain in cache, locked=$LOCKED"
7614 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7615 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7619 echo "No pages locked after fsync"
7623 run_test 118i "Fix error before timeout in recoverable error =========="
7625 [ "$SLOW" = "no" ] && set_resend_count 4
7628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7629 remote_ost_nodsh && skip "remote OST with nodsh" && return
7633 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7634 set_nodes_failloc "$(osts_nodes)" 0x220
7636 # return -EIO from OST
7637 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7639 set_nodes_failloc "$(osts_nodes)" 0x0
7640 if [[ $RC -eq 0 ]]; then
7641 error "Must return error due to dropped pages, rc=$RC"
7644 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7645 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7646 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7647 if [[ $LOCKED -ne 0 ]]; then
7648 error "Locked pages remain in cache, locked=$LOCKED"
7651 # in recoverable error on OST we want resend and stay until it finished
7652 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7653 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7657 echo "No pages locked after fsync"
7661 run_test 118j "Simulate unrecoverable OST side error =========="
7665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7666 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7668 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7669 set_nodes_failloc "$(osts_nodes)" 0x20e
7670 test_mkdir -p $DIR/$tdir
7672 for ((i=0;i<10;i++)); do
7673 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7674 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7681 set_nodes_failloc "$(osts_nodes)" 0
7684 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7690 test_mkdir -p $DIR/$tdir
7691 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7694 run_test 118l "fsync dir ========="
7696 test_118m() # LU-3066
7698 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7699 test_mkdir -p $DIR/$tdir
7700 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7703 run_test 118m "fdatasync dir ========="
7705 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7707 test_119a() # bug 11737
7709 BSIZE=$((512 * 1024))
7710 directio write $DIR/$tfile 0 1 $BSIZE
7711 # We ask to read two blocks, which is more than a file size.
7712 # directio will indicate an error when requested and actual
7713 # sizes aren't equeal (a normal situation in this case) and
7714 # print actual read amount.
7715 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7716 if [ "$NOB" != "$BSIZE" ]; then
7717 error "read $NOB bytes instead of $BSIZE"
7721 run_test 119a "Short directIO read must return actual read amount"
7723 test_119b() # bug 11737
7725 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7727 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7728 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7730 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7731 error "direct read failed"
7734 run_test 119b "Sparse directIO read must return actual read amount"
7736 test_119c() # bug 13099
7739 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7740 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7743 run_test 119c "Testing for direct read hitting hole"
7745 test_119d() # bug 15950
7747 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7748 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7749 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7751 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7752 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7753 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7754 lctl set_param fail_loc=0x40d
7755 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7758 cat $DIR/$tfile > /dev/null &
7759 lctl set_param fail_loc=0
7762 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7764 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7765 error "the read rpcs have not completed in 2s"
7767 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7769 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7773 test_mkdir -p $DIR/$tdir
7774 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7775 skip "no early lock cancel on server" && return 0
7777 lru_resize_disable mdc
7778 lru_resize_disable osc
7779 cancel_lru_locks mdc
7780 # asynchronous object destroy at MDT could cause bl ast to client
7781 cancel_lru_locks osc
7783 stat $DIR/$tdir > /dev/null
7784 can1=$(do_facet $SINGLEMDS \
7785 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7786 awk '/ldlm_cancel/ {print $2}')
7787 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7788 awk '/ldlm_bl_callback/ {print $2}')
7789 test_mkdir -c1 $DIR/$tdir/d1
7790 can2=$(do_facet $SINGLEMDS \
7791 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7792 awk '/ldlm_cancel/ {print $2}')
7793 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7794 awk '/ldlm_bl_callback/ {print $2}')
7795 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7796 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7797 lru_resize_enable mdc
7798 lru_resize_enable osc
7800 run_test 120a "Early Lock Cancel: mkdir test"
7803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7804 test_mkdir $DIR/$tdir
7805 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7806 skip "no early lock cancel on server" && return 0
7807 lru_resize_disable mdc
7808 lru_resize_disable osc
7809 cancel_lru_locks mdc
7810 stat $DIR/$tdir > /dev/null
7811 can1=$(do_facet $SINGLEMDS \
7812 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7813 awk '/ldlm_cancel/ {print $2}')
7814 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7815 awk '/ldlm_bl_callback/ {print $2}')
7817 can2=$(do_facet $SINGLEMDS \
7818 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7819 awk '/ldlm_cancel/ {print $2}')
7820 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7821 awk '/ldlm_bl_callback/ {print $2}')
7822 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7823 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7824 lru_resize_enable mdc
7825 lru_resize_enable osc
7827 run_test 120b "Early Lock Cancel: create test"
7830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7831 test_mkdir -c1 $DIR/$tdir
7832 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7833 skip "no early lock cancel on server" && return 0
7834 lru_resize_disable mdc
7835 lru_resize_disable osc
7836 test_mkdir -p -c1 $DIR/$tdir/d1
7837 test_mkdir -p -c1 $DIR/$tdir/d2
7838 touch $DIR/$tdir/d1/f1
7839 cancel_lru_locks mdc
7840 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7841 can1=$(do_facet $SINGLEMDS \
7842 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7843 awk '/ldlm_cancel/ {print $2}')
7844 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7845 awk '/ldlm_bl_callback/ {print $2}')
7846 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7847 can2=$(do_facet $SINGLEMDS \
7848 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7849 awk '/ldlm_cancel/ {print $2}')
7850 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7851 awk '/ldlm_bl_callback/ {print $2}')
7852 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7853 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7854 lru_resize_enable mdc
7855 lru_resize_enable osc
7857 run_test 120c "Early Lock Cancel: link test"
7860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7861 test_mkdir -p -c1 $DIR/$tdir
7862 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7863 skip "no early lock cancel on server" && return 0
7864 lru_resize_disable mdc
7865 lru_resize_disable osc
7867 cancel_lru_locks mdc
7868 stat $DIR/$tdir > /dev/null
7869 can1=$(do_facet $SINGLEMDS \
7870 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7871 awk '/ldlm_cancel/ {print $2}')
7872 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7873 awk '/ldlm_bl_callback/ {print $2}')
7874 chmod a+x $DIR/$tdir
7875 can2=$(do_facet $SINGLEMDS \
7876 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7877 awk '/ldlm_cancel/ {print $2}')
7878 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7879 awk '/ldlm_bl_callback/ {print $2}')
7880 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7881 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7882 lru_resize_enable mdc
7883 lru_resize_enable osc
7885 run_test 120d "Early Lock Cancel: setattr test"
7888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7889 test_mkdir -p -c1 $DIR/$tdir
7890 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7891 skip "no early lock cancel on server" && return 0
7892 lru_resize_disable mdc
7893 lru_resize_disable osc
7894 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7895 cancel_lru_locks mdc
7896 cancel_lru_locks osc
7897 dd if=$DIR/$tdir/f1 of=/dev/null
7898 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7899 # XXX client can not do early lock cancel of OST lock
7900 # during unlink (LU-4206), so cancel osc lock now.
7901 cancel_lru_locks osc
7902 can1=$(do_facet $SINGLEMDS \
7903 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7904 awk '/ldlm_cancel/ {print $2}')
7905 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7906 awk '/ldlm_bl_callback/ {print $2}')
7907 unlink $DIR/$tdir/f1
7909 can2=$(do_facet $SINGLEMDS \
7910 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7911 awk '/ldlm_cancel/ {print $2}')
7912 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7913 awk '/ldlm_bl_callback/ {print $2}')
7914 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7915 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7916 lru_resize_enable mdc
7917 lru_resize_enable osc
7919 run_test 120e "Early Lock Cancel: unlink test"
7922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7923 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7924 skip "no early lock cancel on server" && return 0
7925 test_mkdir -p -c1 $DIR/$tdir
7926 lru_resize_disable mdc
7927 lru_resize_disable osc
7928 test_mkdir -p -c1 $DIR/$tdir/d1
7929 test_mkdir -p -c1 $DIR/$tdir/d2
7930 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7931 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7932 cancel_lru_locks mdc
7933 cancel_lru_locks osc
7934 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7935 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7936 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7937 # XXX client can not do early lock cancel of OST lock
7938 # during rename (LU-4206), so cancel osc lock now.
7939 cancel_lru_locks osc
7940 can1=$(do_facet $SINGLEMDS \
7941 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7942 awk '/ldlm_cancel/ {print $2}')
7943 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7944 awk '/ldlm_bl_callback/ {print $2}')
7945 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7947 can2=$(do_facet $SINGLEMDS \
7948 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7949 awk '/ldlm_cancel/ {print $2}')
7950 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7951 awk '/ldlm_bl_callback/ {print $2}')
7952 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7953 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7954 lru_resize_enable mdc
7955 lru_resize_enable osc
7957 run_test 120f "Early Lock Cancel: rename test"
7960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7961 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7962 skip "no early lock cancel on server" && return 0
7963 lru_resize_disable mdc
7964 lru_resize_disable osc
7966 echo create $count files
7967 test_mkdir -p $DIR/$tdir
7968 cancel_lru_locks mdc
7969 cancel_lru_locks osc
7972 can0=$(do_facet $SINGLEMDS \
7973 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7974 awk '/ldlm_cancel/ {print $2}')
7975 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7976 awk '/ldlm_bl_callback/ {print $2}')
7977 createmany -o $DIR/$tdir/f $count
7979 can1=$(do_facet $SINGLEMDS \
7980 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7981 awk '/ldlm_cancel/ {print $2}')
7982 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7983 awk '/ldlm_bl_callback/ {print $2}')
7985 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7986 echo rm $count files
7989 can2=$(do_facet $SINGLEMDS \
7990 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7991 awk '/ldlm_cancel/ {print $2}')
7992 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7993 awk '/ldlm_bl_callback/ {print $2}')
7995 echo total: $count removes in $((t2-t1))
7996 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7998 # wait for commitment of removal
7999 lru_resize_enable mdc
8000 lru_resize_enable osc
8002 run_test 120g "Early Lock Cancel: performance test"
8004 test_121() { #bug #10589
8005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8007 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8008 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8009 lctl set_param fail_loc=0x310
8010 cancel_lru_locks osc > /dev/null
8011 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8012 lctl set_param fail_loc=0
8013 [[ $reads -eq $writes ]] ||
8014 error "read $reads blocks, must be $writes blocks"
8016 run_test 121 "read cancel race ========="
8018 test_123a() { # was test 123, statahead(bug 11401)
8019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8021 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8022 log "testing on UP system. Performance may be not as good as expected."
8027 test_mkdir -p $DIR/$tdir
8028 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8029 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8031 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8032 createmany -o $DIR/$tdir/$tfile $j $((i - j))
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 without statahead: $delta sec"
8044 lctl set_param llite.*.statahead_max=$max
8046 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8047 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8048 cancel_lru_locks mdc
8049 cancel_lru_locks osc
8051 time ls -l $DIR/$tdir | wc -l
8053 delta_sa=$((etime - stime))
8054 log "ls $i files with statahead: $delta_sa sec"
8055 lctl get_param -n llite.*.statahead_stats
8056 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8058 [[ $swrong -lt $ewrong ]] &&
8059 log "statahead was stopped, maybe too many locks held!"
8060 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8062 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8063 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8064 lctl set_param -n llite.*.statahead_max 0
8065 lctl get_param llite.*.statahead_max
8066 cancel_lru_locks mdc
8067 cancel_lru_locks osc
8069 time ls -l $DIR/$tdir | wc -l
8071 delta=$((etime - stime))
8072 log "ls $i files again without statahead: $delta sec"
8073 lctl set_param llite.*.statahead_max=$max
8074 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8075 if [ $SLOWOK -eq 0 ]; then
8076 error "ls $i files is slower with statahead!"
8078 log "ls $i files is slower with statahead!"
8084 [ $delta -gt 20 ] && break
8085 [ $delta -gt 8 ] && MULT=$((50 / delta))
8086 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8094 delta=$((etime - stime))
8095 log "rm -r $DIR/$tdir/: $delta seconds"
8097 lctl get_param -n llite.*.statahead_stats
8099 run_test 123a "verify statahead work"
8101 test_123b () { # statahead(bug 15027)
8102 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8103 test_mkdir -p $DIR/$tdir
8104 createmany -o $DIR/$tdir/$tfile-%d 1000
8106 cancel_lru_locks mdc
8107 cancel_lru_locks osc
8109 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8110 lctl set_param fail_loc=0x80000803
8111 ls -lR $DIR/$tdir > /dev/null
8113 lctl set_param fail_loc=0x0
8114 lctl get_param -n llite.*.statahead_stats
8119 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8123 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8124 skip "no lru resize on server" && return 0
8126 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8128 log "create $NR files at $DIR/$tdir"
8129 createmany -o $DIR/$tdir/f $NR ||
8130 error "failed to create $NR files in $DIR/$tdir"
8132 cancel_lru_locks mdc
8133 ls -l $DIR/$tdir > /dev/null
8137 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8138 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8139 LRU_SIZE=$($LCTL get_param -n $PARAM)
8140 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8141 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8143 log "NS=$(basename $NSDIR)"
8148 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8149 skip "Not enough cached locks created!"
8156 # We know that lru resize allows one client to hold $LIMIT locks
8157 # for 10h. After that locks begin to be killed by client.
8159 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8162 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8163 # killing locks. Some time was spent for creating locks. This means
8164 # that up to the moment of sleep finish we must have killed some of
8165 # them (10-100 locks). This depends on how fast ther were created.
8166 # Many of them were touched in almost the same moment and thus will
8167 # be killed in groups.
8168 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8170 # Use $LRU_SIZE_B here to take into account real number of locks
8171 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8172 local LRU_SIZE_B=$LRU_SIZE
8174 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8175 log "OLD_LVF=$OLD_LVF"
8176 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8178 # Let's make sure that we really have some margin. Client checks
8179 # cached locks every 10 sec.
8181 log "Sleep ${SLEEP} sec"
8183 while ((SEC<$SLEEP)); do
8187 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8191 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8192 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8194 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8195 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8196 unlinkmany $DIR/$tdir/f $NR
8200 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8201 log "unlink $NR files at $DIR/$tdir"
8202 unlinkmany $DIR/$tdir/f $NR
8204 run_test 124a "lru resize ======================================="
8206 get_max_pool_limit()
8208 local limit=$($LCTL get_param \
8209 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8212 if [[ $l -gt $max ]]; then
8220 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8221 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8222 skip "no lru resize on server" && return 0
8224 LIMIT=$(get_max_pool_limit)
8226 NR=$(($(default_lru_size)*20))
8227 if [[ $NR -gt $LIMIT ]]; then
8228 log "Limit lock number by $LIMIT locks"
8231 lru_resize_disable mdc
8232 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8233 error "failed to create $DIR/$tdir/disable_lru_resize"
8235 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8236 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8237 cancel_lru_locks mdc
8240 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8243 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8246 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8250 nolruresize_delta=$((etime-stime))
8251 log "ls -la time: $nolruresize_delta seconds"
8252 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8253 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8255 lru_resize_enable mdc
8256 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8257 error "failed to create $DIR/$tdir/enable_lru_resize"
8259 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8260 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8261 cancel_lru_locks mdc
8264 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8267 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8270 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8274 lruresize_delta=$((etime-stime))
8275 log "ls -la time: $lruresize_delta seconds"
8276 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8278 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8279 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8280 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8281 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8283 log "lru resize performs the same with no lru resize"
8285 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8287 run_test 124b "lru resize (performance test) ======================="
8289 test_125() { # 13358
8290 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8291 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8292 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8293 test_mkdir -p $DIR/d125 || error "mkdir failed"
8294 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8295 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8296 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8298 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8300 test_126() { # bug 12829/13455
8301 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8302 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8303 $GSS && skip "must run as gss disabled" && return
8305 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8306 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8308 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8310 run_test 126 "check that the fsgid provided by the client is taken into account"
8312 test_127a() { # bug 15521
8313 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8314 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8315 $LCTL set_param osc.*.stats=0
8316 FSIZE=$((2048 * 1024))
8317 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8318 cancel_lru_locks osc
8319 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8321 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8322 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8323 echo "got $COUNT $NAME"
8324 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8325 eval $NAME=$COUNT || error "Wrong proc format"
8328 read_bytes|write_bytes)
8329 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8330 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8331 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8332 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8333 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8334 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8335 error "sumsquare is too small: $SUMSQ"
8336 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8337 error "sumsquare is too big: $SUMSQ"
8341 done < $DIR/${tfile}.tmp
8343 #check that we actually got some stats
8344 [ "$read_bytes" ] || error "Missing read_bytes stats"
8345 [ "$write_bytes" ] || error "Missing write_bytes stats"
8346 [ "$read_bytes" != 0 ] || error "no read done"
8347 [ "$write_bytes" != 0 ] || error "no write done"
8349 run_test 127a "verify the client stats are sane"
8351 test_127b() { # bug LU-333
8352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8353 $LCTL set_param llite.*.stats=0
8354 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8355 # perform 2 reads and writes so MAX is different from SUM.
8356 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8357 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8358 cancel_lru_locks osc
8359 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8360 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8362 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8363 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8364 echo "got $COUNT $NAME"
8365 eval $NAME=$COUNT || error "Wrong proc format"
8369 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8370 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8371 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8372 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8375 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8376 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8377 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8378 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8382 done < $TMP/${tfile}.tmp
8384 #check that we actually got some stats
8385 [ "$read_bytes" ] || error "Missing read_bytes stats"
8386 [ "$write_bytes" ] || error "Missing write_bytes stats"
8387 [ "$read_bytes" != 0 ] || error "no read done"
8388 [ "$write_bytes" != 0 ] || error "no write done"
8390 run_test 127b "verify the llite client stats are sane"
8392 test_128() { # bug 15212
8394 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8399 result=$(grep error $TMP/$tfile.log)
8401 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8403 run_test 128 "interactive lfs for 2 consecutive find's"
8410 local LDPROC=/proc/fs/ldiskfs
8411 local facets=$(get_facets MDS)
8413 for facet in ${facets//,/ }; do
8414 canondev=$(ldiskfs_canon \
8415 *.$(convert_facet2label $facet).mntdev $facet)
8416 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8417 LDPROC=/sys/fs/ldiskfs
8418 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8424 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8425 skip "Only applicable to ldiskfs-based MDTs"
8428 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8433 test_mkdir -p $DIR/$tdir
8435 # block size of mds1
8436 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8437 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8438 local MAX=$((MDSBLOCKSIZE * 3))
8440 local I=$(stat -c%s "$DIR/$tdir")
8442 local STRIPE_COUNT=1
8443 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8444 MAX=$((MAX*STRIPE_COUNT))
8445 while [[ $I -le $MAX ]]; do
8446 $MULTIOP $DIR/$tdir/$J Oc
8448 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8449 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8450 #and EFBIG for previous versions
8451 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8453 echo "return code $rc received as expected"
8454 multiop $DIR/$tdir/$J Oc ||
8455 error_exit "multiop failed w/o dir size limit"
8457 I=$(stat -c%s "$DIR/$tdir")
8459 if [ $(lustre_version_code $SINGLEMDS) -lt \
8460 $(version_code 2.4.51) ]
8462 [[ $I -eq $MAX ]] && return 0
8464 [[ $I -gt $MAX ]] && return 0
8466 error_exit "current dir size $I, previous limit $MAX"
8467 elif [ $rc -ne 0 ]; then
8469 error_exit "return code $rc received instead of expected " \
8470 "$EFBIG or $ENOSPC, files in dir $I"
8473 I=$(stat -c%s "$DIR/$tdir")
8477 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8479 run_test 129 "test directory size limit ========================"
8488 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8489 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8492 trap cleanup_130 EXIT RETURN
8494 local fm_file=$DIR/$tfile
8495 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8496 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8497 error "dd failed for $fm_file"
8499 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8500 filefrag -ves $fm_file
8502 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8503 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8504 [ $RC != 0 ] && error "filefrag $fm_file failed"
8506 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8507 grep -v "ext:" | grep -v "found")
8508 lun=$($GETSTRIPE -i $fm_file)
8510 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8513 for line in $filefrag_op
8515 frag_lun=`echo $line | cut -d: -f5`
8516 ext_len=`echo $line | cut -d: -f4`
8517 if (( $frag_lun != $lun )); then
8519 error "FIEMAP on 1-stripe file($fm_file) failed"
8522 (( tot_len += ext_len ))
8525 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8527 error "FIEMAP on 1-stripe file($fm_file) failed;"
8533 echo "FIEMAP on single striped file succeeded"
8535 run_test 130a "FIEMAP (1-stripe file)"
8538 [ "$OSTCOUNT" -lt "2" ] &&
8539 skip_env "skipping FIEMAP on 2-stripe file test" && return
8541 [ "$OSTCOUNT" -ge "10" ] &&
8542 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8544 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8545 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8548 trap cleanup_130 EXIT RETURN
8550 local fm_file=$DIR/$tfile
8551 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8552 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8553 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8555 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8556 error "dd failed on $fm_file"
8558 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8559 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8560 grep -v "ext:" | grep -v "found")
8562 last_lun=$(echo $filefrag_op | cut -d: -f5)
8567 for line in $filefrag_op
8569 frag_lun=`echo $line | cut -d: -f5`
8570 ext_len=`echo $line | cut -d: -f4`
8571 if (( $frag_lun != $last_lun )); then
8572 if (( tot_len != 1024 )); then
8574 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8581 (( tot_len += ext_len ))
8584 if (( num_luns != 2 || tot_len != 1024 )); then
8586 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8592 echo "FIEMAP on 2-stripe file succeeded"
8594 run_test 130b "FIEMAP (2-stripe file)"
8597 [ "$OSTCOUNT" -lt "2" ] &&
8598 skip_env "skipping FIEMAP on 2-stripe file" && return
8600 [ "$OSTCOUNT" -ge "10" ] &&
8601 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8603 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8604 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8607 trap cleanup_130 EXIT RETURN
8609 local fm_file=$DIR/$tfile
8610 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8611 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8612 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8614 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8616 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8617 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8619 last_lun=`echo $filefrag_op | cut -d: -f5`
8624 for line in $filefrag_op
8626 frag_lun=`echo $line | cut -d: -f5`
8627 ext_len=`echo $line | cut -d: -f4`
8628 if (( $frag_lun != $last_lun )); then
8629 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8630 if (( logical != 512 )); then
8632 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8635 if (( tot_len != 512 )); then
8637 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8644 (( tot_len += ext_len ))
8647 if (( num_luns != 2 || tot_len != 512 )); then
8649 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8655 echo "FIEMAP on 2-stripe file with hole succeeded"
8657 run_test 130c "FIEMAP (2-stripe file with hole)"
8660 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8662 [ "$OSTCOUNT" -ge "10" ] &&
8663 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8665 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8666 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8668 trap cleanup_130 EXIT RETURN
8670 local fm_file=$DIR/$tfile
8671 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8672 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8673 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8675 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8676 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8677 error "dd failed on $fm_file"
8679 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8680 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8681 grep -v "ext:" | grep -v "found"`
8683 last_lun=`echo $filefrag_op | cut -d: -f5`
8688 for line in $filefrag_op
8690 frag_lun=`echo $line | cut -d: -f5`
8691 ext_len=`echo $line | cut -d: -f4`
8692 if (( $frag_lun != $last_lun )); then
8693 if (( tot_len != 1024 )); then
8695 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8702 (( tot_len += ext_len ))
8705 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8707 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8713 echo "FIEMAP on N-stripe file succeeded"
8715 run_test 130d "FIEMAP (N-stripe file)"
8718 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8720 [ "$OSTCOUNT" -ge "10" ] &&
8721 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8723 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8724 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8726 trap cleanup_130 EXIT RETURN
8728 local fm_file=$DIR/$tfile
8729 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8730 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8731 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8734 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8735 for ((i = 0; i < $NUM_BLKS; i++))
8737 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8740 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8741 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8743 last_lun=`echo $filefrag_op | cut -d: -f5`
8748 for line in $filefrag_op
8750 frag_lun=`echo $line | cut -d: -f5`
8751 ext_len=`echo $line | cut -d: -f4`
8752 if (( $frag_lun != $last_lun )); then
8753 if (( tot_len != $EXPECTED_LEN )); then
8755 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8762 (( tot_len += ext_len ))
8765 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8767 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8773 echo "FIEMAP with continuation calls succeeded"
8775 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8777 # Test for writev/readv
8779 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8780 error "writev test failed"
8781 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8782 error "readv failed"
8785 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8788 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8789 error "append writev test failed"
8790 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8791 error "append writev test failed"
8794 run_test 131b "test append writev"
8797 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8800 run_test 131c "test read/write on file w/o objects"
8803 rwv -f $DIR/$tfile -w -n 1 1572864
8804 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8805 if [ "$NOB" != 1572864 ]; then
8806 error "Short read filed: read $NOB bytes instead of 1572864"
8810 run_test 131d "test short read"
8813 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8814 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8815 error "read hitting hole failed"
8818 run_test 131e "test read hitting hole"
8823 for node in $(osts_nodes); do
8824 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8825 [ x$gl = x"" ] && gl=0
8826 gl_sum=$((gl_sum + gl))
8836 if [ x$som = x"enabled" ]; then
8837 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8838 MOUNT_OPTS=`echo $MOUNT_OPTS |
8839 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8840 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8842 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8843 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8844 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8847 # do remount to make new mount-conf parameters actual
8854 test_132() { #1028, SOM
8855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8856 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8857 local num=$(get_mds_dir $DIR)
8858 local mymds=mds${num}
8859 local MOUNT_OPTS_SAVE=$MOUNT_OPTS
8861 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8862 cancel_lru_locks osc
8864 som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8866 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8867 stat $DIR/$tfile >/dev/null
8868 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8869 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8871 som_mode_switch $som1 $gl1 $gl2
8873 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8874 cancel_lru_locks osc
8876 som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8877 if [ $som1 == $som2 ]; then
8878 error "som is still "$som2
8879 if [ x$som2 = x"enabled" ]; then
8886 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8887 stat $DIR/$tfile >/dev/null
8888 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8889 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8890 som_mode_switch $som2 $gl1 $gl2
8891 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8893 run_test 132 "som avoids glimpse rpc"
8899 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8901 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8903 *) error "Wrong argument $1" ;;
8906 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8907 # if the argument $3 is zero, it means any stat increment is ok.
8908 if [[ $3 -gt 0 ]]; then
8909 count=$(echo $res | awk '{ print $2 }')
8910 [[ $count -ne $3 ]] &&
8911 error "The $2 counter on $1 is wrong - expected $3"
8916 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8917 remote_ost_nodsh && skip "remote OST with nodsh" && return
8918 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8920 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8921 { skip "MDS doesn't support rename stats"; return; }
8922 local testdir=$DIR/${tdir}/stats_testdir
8923 mkdir -p $DIR/${tdir}
8926 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8927 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8929 # verify mdt stats first.
8930 mkdir ${testdir} || error "mkdir failed"
8931 check_stats $SINGLEMDS "mkdir" 1
8932 touch ${testdir}/${tfile} || "touch failed"
8933 check_stats $SINGLEMDS "open" 1
8934 check_stats $SINGLEMDS "close" 1
8935 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8936 check_stats $SINGLEMDS "mknod" 1
8937 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8938 check_stats $SINGLEMDS "unlink" 1
8939 rm -f ${testdir}/${tfile} || error "file remove failed"
8940 check_stats $SINGLEMDS "unlink" 2
8942 # remove working dir and check mdt stats again.
8943 rmdir ${testdir} || error "rmdir failed"
8944 check_stats $SINGLEMDS "rmdir" 1
8946 local testdir1=$DIR/${tdir}/stats_testdir1
8948 mkdir -p ${testdir1}
8949 touch ${testdir1}/test1
8950 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8951 check_stats $SINGLEMDS "crossdir_rename" 1
8953 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8954 check_stats $SINGLEMDS "samedir_rename" 1
8958 run_test 133a "Verifying 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 mkdir -p ${testdir} || error "mkdir failed"
8966 touch ${testdir}/${tfile} || "touch failed"
8967 cancel_lru_locks mdc
8970 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8971 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8973 # extra mdt stats verification.
8974 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8975 check_stats $SINGLEMDS "setattr" 1
8976 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8977 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8979 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8980 check_stats $SINGLEMDS "getattr" 1
8982 $LFS df || error "lfs failed"
8983 check_stats $SINGLEMDS "statfs" 1
8987 run_test 133b "Verifying extra MDT stats =================================="
8990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8991 remote_ost_nodsh && skip "remote OST with nodsh" && return
8992 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8993 local testdir=$DIR/${tdir}/stats_testdir
8994 test_mkdir -p ${testdir} || error "mkdir failed"
8996 # verify obdfilter stats.
8997 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8999 cancel_lru_locks osc
9000 wait_delete_completed
9003 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9004 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9006 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9008 cancel_lru_locks osc
9009 check_stats ost "write" 1
9011 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9012 check_stats ost "read" 1
9014 > ${testdir}/${tfile} || error "truncate failed"
9015 check_stats ost "punch" 1
9017 rm -f ${testdir}/${tfile} || error "file remove failed"
9018 wait_delete_completed
9019 check_stats ost "destroy" 1
9023 run_test 133c "Verifying OST stats ========================================"
9030 while [ $value -ge 2 ]; do
9035 if [ $orig -gt $order ]; then
9043 local size=('K' 'M' 'G' 'T');
9045 local size_string=$value
9047 while [ $value -ge 1024 ]; do
9048 if [ $i -gt 3 ]; then
9049 #T is the biggest unit we get here, if that is bigger,
9051 size_string=${value}T
9054 value=$((value >> 10))
9055 if [ $value -lt 1024 ]; then
9056 size_string=${value}${size[$i]}
9067 local context=${2:-.}
9068 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9070 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9076 remote_ost_nodsh && skip "remote OST with nodsh" && return
9077 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9078 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9079 { skip "MDS doesn't support rename stats"; return; }
9081 local testdir1=$DIR/${tdir}/stats_testdir1
9082 local testdir2=$DIR/${tdir}/stats_testdir2
9084 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9086 mkdir -p ${testdir1} || error "mkdir failed"
9087 mkdir -p ${testdir2} || error "mkdir failed"
9089 createmany -o $testdir1/test 512 || error "createmany failed"
9091 # check samedir rename size
9092 mv ${testdir1}/test0 ${testdir1}/test_0
9094 local testdir1_size=$(ls -l $DIR/${tdir} |
9095 awk '/stats_testdir1/ {print $5}')
9096 local testdir2_size=$(ls -l $DIR/${tdir} |
9097 awk '/stats_testdir2/ {print $5}')
9099 testdir1_size=$(order_2 $testdir1_size)
9100 testdir2_size=$(order_2 $testdir2_size)
9102 testdir1_size=$(size_in_KMGT $testdir1_size)
9103 testdir2_size=$(size_in_KMGT $testdir2_size)
9105 echo "source rename dir size: ${testdir1_size}"
9106 echo "target rename dir size: ${testdir2_size}"
9108 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9109 eval $cmd || error "$cmd failed"
9110 local samedir=$($cmd | grep 'same_dir')
9111 local same_sample=$(get_rename_size $testdir1_size)
9112 [ -z "$samedir" ] && error "samedir_rename_size count error"
9113 [[ $same_sample -eq 1 ]] ||
9114 error "samedir_rename_size error $same_sample"
9115 echo "Check same dir rename stats success"
9117 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9119 # check crossdir rename size
9120 mv ${testdir1}/test_0 ${testdir2}/test_0
9122 testdir1_size=$(ls -l $DIR/${tdir} |
9123 awk '/stats_testdir1/ {print $5}')
9124 testdir2_size=$(ls -l $DIR/${tdir} |
9125 awk '/stats_testdir2/ {print $5}')
9127 testdir1_size=$(order_2 $testdir1_size)
9128 testdir2_size=$(order_2 $testdir2_size)
9130 testdir1_size=$(size_in_KMGT $testdir1_size)
9131 testdir2_size=$(size_in_KMGT $testdir2_size)
9133 echo "source rename dir size: ${testdir1_size}"
9134 echo "target rename dir size: ${testdir2_size}"
9136 eval $cmd || error "$cmd failed"
9137 local crossdir=$($cmd | grep 'crossdir')
9138 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9139 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9140 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9141 [[ $src_sample -eq 1 ]] ||
9142 error "crossdir_rename_size error $src_sample"
9143 [[ $tgt_sample -eq 1 ]] ||
9144 error "crossdir_rename_size error $tgt_sample"
9145 echo "Check cross dir rename stats success"
9148 run_test 133d "Verifying rename_stats ========================================"
9151 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9152 remote_ost_nodsh && skip "remote OST with nodsh" && return
9153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9154 local testdir=$DIR/${tdir}/stats_testdir
9155 local ctr f0 f1 bs=32768 count=42 sum
9157 mkdir -p ${testdir} || error "mkdir failed"
9159 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9161 for ctr in {write,read}_bytes; do
9163 cancel_lru_locks osc
9165 do_facet ost1 $LCTL set_param -n \
9166 "obdfilter.*.exports.clear=clear"
9168 if [ $ctr = write_bytes ]; then
9170 f1=${testdir}/${tfile}
9172 f0=${testdir}/${tfile}
9176 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9179 cancel_lru_locks osc
9181 sum=$(do_facet ost1 $LCTL get_param \
9182 "obdfilter.*.exports.*.stats" |
9183 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9184 $1 == ctr { sum += $7 }
9185 END { printf("%0.0f", sum) }')
9187 if ((sum != bs * count)); then
9188 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9194 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9199 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9200 /sys/fs/lustre/ /sys/fs/lnet/"
9202 for dir in $dirs; do
9203 if [ -d $dir ]; then
9204 proc_dirs="$proc_dirs $dir"
9210 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9211 remote_ost_nodsh && skip "remote OST with nodsh" && return
9212 # First without trusting modes.
9213 find $proc_dirs -exec cat '{}' \; &> /dev/null
9215 # Second verifying readability.
9218 -exec cat '{}' \; &> /dev/null ||
9219 error "proc file read failed"
9221 for facet in $SINGLEMDS ost1; do
9222 do_facet $facet find $proc_dirs \
9223 ! -name req_history \
9224 -exec cat '{}' \\\; &> /dev/null
9226 do_facet $facet find $proc_dirs \
9227 ! -name req_history \
9229 -exec cat '{}' \\\; &> /dev/null ||
9230 error "proc file read failed"
9233 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9238 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9239 /sys/fs/lustre/ /sys/fs/lnet/"
9241 for dir in $dirs; do
9242 if [ -d $dir ]; then
9243 proc_dirs="$proc_dirs $dir"
9249 # Second verifying readability.
9252 -not -name force_lbug \
9253 -not -name changelog_mask \
9254 -exec badarea_io '{}' \; &> /dev/null ||
9255 error "find $proc_dirs failed"
9257 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9258 skip "Too old lustre on MDS"
9260 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9261 skip "Too old lustre on ost1"
9263 for facet in $SINGLEMDS ost1; do
9264 do_facet $facet find $proc_dirs \
9266 -not -name force_lbug \
9267 -not -name changelog_mask \
9268 -exec badarea_io '{}' \\\; &> /dev/null ||
9269 error "$facet find $proc_dirs failed"
9273 # remount the FS in case writes/reads /proc break the FS
9274 cleanup || error "failed to unmount"
9275 setup || error "failed to setup"
9278 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9280 test_140() { #bug-17379
9281 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9282 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9283 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9284 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9286 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9287 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9289 while i=`expr $i + 1`; do
9290 test_mkdir -p $i || error "Creating dir $i"
9291 cd $i || error "Changing to $i"
9292 ln -s ../stat stat || error "Creating stat symlink"
9293 # Read the symlink until ELOOP present,
9294 # not LBUGing the system is considered success,
9295 # we didn't overrun the stack.
9296 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9298 if [ $ret -eq 40 ]; then
9301 error "Open stat symlink"
9307 echo "The symlink depth = $i"
9308 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9309 error "Invalid symlink depth"
9311 # Test recursive symlink
9312 ln -s symlink_self symlink_self
9313 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9314 echo "open symlink_self returns $ret"
9315 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9317 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9321 local TF="$TMP/$tfile"
9323 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9325 cancel_lru_locks osc
9326 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9327 remount_client $MOUNT
9329 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9332 $TRUNCATE $DIR/$tfile 6000
9333 cancel_lru_locks osc
9334 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9337 echo "12345" >>$DIR/$tfile
9338 cancel_lru_locks osc
9339 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9342 echo "12345" >>$DIR/$tfile
9343 cancel_lru_locks osc
9344 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9349 run_test 150 "truncate/append tests"
9351 #LU-2902 roc_hit was not able to read all values from lproc
9352 function roc_hit_init() {
9353 local list=$(comma_list $(osts_nodes))
9354 local dir=$DIR/$tdir-check
9355 local file=$dir/file
9361 #use setstripe to do a write to every ost
9362 for i in $(seq 0 $((OSTCOUNT-1))); do
9363 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9364 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9365 idx=$(printf %04x $i)
9366 BEFORE=$(get_osd_param $list *OST*$idx stats |
9367 awk '$1 == "cache_access" {sum += $7}
9368 END { printf("%0.0f", sum) }')
9370 cancel_lru_locks osc
9371 cat $file >/dev/null
9373 AFTER=$(get_osd_param $list *OST*$idx stats |
9374 awk '$1 == "cache_access" {sum += $7}
9375 END { printf("%0.0f", sum) }')
9377 echo BEFORE:$BEFORE AFTER:$AFTER
9378 if ! let "AFTER - BEFORE == 4"; then
9380 error "roc_hit is not safe to use"
9388 function roc_hit() {
9389 local list=$(comma_list $(osts_nodes))
9390 echo $(get_osd_param $list '' stats |
9391 awk '$1 == "cache_hit" {sum += $7}
9392 END { printf("%0.0f", sum) }')
9395 function set_cache() {
9398 if [ "$2" == "off" ]; then
9401 local list=$(comma_list $(osts_nodes))
9402 set_osd_param $list '' $1_cache_enable $on
9404 cancel_lru_locks osc
9408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9409 remote_ost_nodsh && skip "remote OST with nodsh" && return
9412 local list=$(comma_list $(osts_nodes))
9414 # check whether obdfilter is cache capable at all
9415 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9416 echo "not cache-capable obdfilter"
9420 # check cache is enabled on all obdfilters
9421 if get_osd_param $list '' read_cache_enable | grep 0; then
9422 echo "oss cache is disabled"
9426 set_osd_param $list '' writethrough_cache_enable 1
9428 # check write cache is enabled on all obdfilters
9429 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9430 echo "oss write cache is NOT enabled"
9436 #define OBD_FAIL_OBD_NO_LRU 0x609
9437 do_nodes $list $LCTL set_param fail_loc=0x609
9439 # pages should be in the case right after write
9440 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9443 local BEFORE=$(roc_hit)
9444 cancel_lru_locks osc
9445 cat $DIR/$tfile >/dev/null
9446 local AFTER=$(roc_hit)
9448 do_nodes $list $LCTL set_param fail_loc=0
9450 if ! let "AFTER - BEFORE == CPAGES"; then
9451 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9454 # the following read invalidates the cache
9455 cancel_lru_locks osc
9456 set_osd_param $list '' read_cache_enable 0
9457 cat $DIR/$tfile >/dev/null
9459 # now data shouldn't be found in the cache
9461 cancel_lru_locks osc
9462 cat $DIR/$tfile >/dev/null
9464 if let "AFTER - BEFORE != 0"; then
9465 error "IN CACHE: before: $BEFORE, after: $AFTER"
9468 set_osd_param $list '' read_cache_enable 1
9471 run_test 151 "test cache on oss and controls ==============================="
9474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9475 local TF="$TMP/$tfile"
9477 # simulate ENOMEM during write
9478 #define OBD_FAIL_OST_NOMEM 0x226
9479 lctl set_param fail_loc=0x80000226
9480 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9482 sync || error "sync failed"
9483 lctl set_param fail_loc=0
9485 # discard client's cache
9486 cancel_lru_locks osc
9488 # simulate ENOMEM during read
9489 lctl set_param fail_loc=0x80000226
9490 cmp $TF $DIR/$tfile || error "cmp failed"
9491 lctl set_param fail_loc=0
9495 run_test 152 "test read/write with enomem ============================"
9498 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9500 run_test 153 "test if fdatasync does not crash ======================="
9502 dot_lustre_fid_permission_check() {
9504 local ffid=$MOUNT/.lustre/fid/$fid
9507 echo "stat fid $fid"
9508 stat $ffid > /dev/null || error "stat $ffid failed."
9509 echo "touch fid $fid"
9510 touch $ffid || error "touch $ffid failed."
9511 echo "write to fid $fid"
9512 cat /etc/hosts > $ffid || error "write $ffid failed."
9513 echo "read fid $fid"
9514 diff /etc/hosts $ffid || error "read $ffid failed."
9515 echo "append write to fid $fid"
9516 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9517 echo "rename fid $fid"
9518 mv $ffid $test_dir/$tfile.1 &&
9519 error "rename $ffid to $tfile.1 should fail."
9520 touch $test_dir/$tfile.1
9521 mv $test_dir/$tfile.1 $ffid &&
9522 error "rename $tfile.1 to $ffid should fail."
9523 rm -f $test_dir/$tfile.1
9524 echo "truncate fid $fid"
9525 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9526 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9527 echo "link fid $fid"
9528 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9530 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9531 echo "setfacl fid $fid"
9532 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9533 echo "getfacl fid $fid"
9534 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9536 echo "unlink fid $fid"
9537 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9538 echo "mknod fid $fid"
9539 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9541 fid=[0xf00000400:0x1:0x0]
9542 ffid=$MOUNT/.lustre/fid/$fid
9544 echo "stat non-exist fid $fid"
9545 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9546 echo "write to non-exist fid $fid"
9547 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9548 echo "link new fid $fid"
9549 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9551 mkdir -p $test_dir/$tdir
9552 touch $test_dir/$tdir/$tfile
9553 fid=$($LFS path2fid $test_dir/$tdir)
9556 error "error: could not get fid for $test_dir/$dir/$tfile."
9558 ffid=$MOUNT/.lustre/fid/$fid
9561 ls $ffid > /dev/null || error "ls $ffid failed."
9562 echo "touch $fid/$tfile.1"
9563 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9565 echo "touch $MOUNT/.lustre/fid/$tfile"
9566 touch $MOUNT/.lustre/fid/$tfile && \
9567 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9569 echo "setxattr to $MOUNT/.lustre/fid"
9570 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9572 echo "listxattr for $MOUNT/.lustre/fid"
9573 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9575 echo "delxattr from $MOUNT/.lustre/fid"
9576 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9578 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9579 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9580 error "touch invalid fid should fail."
9582 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9583 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9584 error "touch non-normal fid should fail."
9586 echo "rename $tdir to $MOUNT/.lustre/fid"
9587 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9588 error "rename to $MOUNT/.lustre/fid should fail."
9590 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9592 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9593 local new_obf_mode=777
9595 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9596 chmod $new_obf_mode $DIR/.lustre/fid ||
9597 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9599 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9600 [ $obf_mode -eq $new_obf_mode ] ||
9601 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9603 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9604 chmod $old_obf_mode $DIR/.lustre/fid ||
9605 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9608 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9609 fid=$($LFS path2fid $test_dir/$tfile-2)
9611 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9613 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9614 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9615 error "create lov data thru .lustre failed"
9617 echo "cp /etc/passwd $test_dir/$tfile-2"
9618 cp /etc/passwd $test_dir/$tfile-2 ||
9619 error "copy to $test_dir/$tfile-2 failed."
9620 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9621 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9622 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9624 rm -rf $test_dir/tfile.lnk
9625 rm -rf $test_dir/$tfile-2
9629 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9630 skip "Need MDS version at least 2.4.1" && return
9633 local FID=$($LFS path2fid $DIR/$tfile)
9634 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9636 # check that we get the same pathname back
9637 local FOUND=$($LFS fid2path $MOUNT $FID)
9638 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9639 [ "$FOUND" != "$DIR/$tfile" ] &&
9640 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9644 run_test 154A "lfs path2fid and fid2path basic checks"
9647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9648 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9649 { skip "Need MDS version at least 2.2.51"; return 0; }
9650 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9652 cp /etc/hosts $DIR/$tfile
9654 fid=$($LFS path2fid $DIR/$tfile)
9656 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9658 dot_lustre_fid_permission_check "$fid" $DIR ||
9659 error "dot lustre permission check $fid failed"
9661 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9663 touch $MOUNT/.lustre/file &&
9664 error "creation is not allowed under .lustre"
9666 mkdir $MOUNT/.lustre/dir &&
9667 error "mkdir is not allowed under .lustre"
9671 run_test 154a "Open-by-FID"
9674 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9675 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9676 { skip "Need MDS version at least 2.2.51"; return 0; }
9678 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9680 local remote_dir=$DIR/$tdir/remote_dir
9685 $LFS mkdir -i $MDTIDX $remote_dir ||
9686 error "create remote directory failed"
9688 cp /etc/hosts $remote_dir/$tfile
9690 fid=$($LFS path2fid $remote_dir/$tfile)
9692 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9694 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9695 error "dot lustre permission check $fid failed"
9698 run_test 154b "Open-by-FID for remote directory"
9701 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9702 skip "Need MDS version at least 2.4.1" && return
9704 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9705 local FID1=$($LFS path2fid $DIR/$tfile.1)
9706 local FID2=$($LFS path2fid $DIR/$tfile.2)
9707 local FID3=$($LFS path2fid $DIR/$tfile.3)
9710 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9711 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9712 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9714 [ "$FID" = "${!want}" ] ||
9715 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9719 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9720 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9721 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9725 run_test 154c "lfs path2fid and fid2path multiple arguments"
9728 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9729 skip "Need MDS version at least 2.5.53" && return
9732 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9736 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9743 fid=$($LFS path2fid $DIR/$tfile)
9746 cmd="exec $fd<$DIR/$tfile"
9748 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9749 echo $fid_list | grep $fid
9752 cmd="exec $fd>/dev/null"
9754 if [ $rc -ne 0 ]; then
9755 error "FID $fid not found in open files list $fid_list"
9758 run_test 154d "Verify open file fid"
9762 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9763 skip "Need MDS version at least 2.6.50" && return
9765 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9766 error ".lustre returned by readdir"
9769 run_test 154e ".lustre is not returned by readdir"
9772 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9773 test_mkdir -p -c1 $DIR/$tdir/d
9774 # test dirs inherit from its stripe
9775 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9776 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9777 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9778 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9781 # get fid of parents
9782 local FID0=$($LFS path2fid $DIR/$tdir/d)
9783 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9784 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9785 local FID3=$($LFS path2fid $DIR)
9787 # check that path2fid --parents returns expected <parent_fid>/name
9788 # 1) test for a directory (single parent)
9789 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9790 [ "$parent" == "$FID0/foo1" ] ||
9791 error "expected parent: $FID0/foo1, got: $parent"
9793 # 2) test for a file with nlink > 1 (multiple parents)
9794 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9795 echo "$parent" | grep -F "$FID1/$tfile" ||
9796 error "$FID1/$tfile not returned in parent list"
9797 echo "$parent" | grep -F "$FID2/link" ||
9798 error "$FID2/link not returned in parent list"
9800 # 3) get parent by fid
9801 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9802 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9803 echo "$parent" | grep -F "$FID1/$tfile" ||
9804 error "$FID1/$tfile not returned in parent list (by fid)"
9805 echo "$parent" | grep -F "$FID2/link" ||
9806 error "$FID2/link not returned in parent list (by fid)"
9808 # 4) test for entry in root directory
9809 parent=$($LFS path2fid --parents $DIR/f)
9810 echo "$parent" | grep -F "$FID3/f" ||
9811 error "$FID3/f not returned in parent list"
9813 # 5) test it on root directory
9814 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9815 error "$MOUNT should not have parents"
9817 # enable xattr caching and check that linkea is correctly updated
9818 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9819 save_lustre_params client "llite.*.xattr_cache" > $save
9820 lctl set_param llite.*.xattr_cache 1
9822 # 6.1) linkea update on rename
9823 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
9825 # get parents by fid
9826 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9827 # foo1 should no longer be returned in parent list
9828 echo "$parent" | grep -F "$FID1" &&
9829 error "$FID1 should no longer be in parent list"
9830 # the new path should appear
9831 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
9832 error "$FID2/$tfile.moved is not in parent list"
9834 # 6.2) linkea update on unlink
9835 rm -f $DIR/$tdir/d/foo2/link
9836 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9837 # foo2/link should no longer be returned in parent list
9838 echo "$parent" | grep -F "$FID2/link" &&
9839 error "$FID2/link should no longer be in parent list"
9843 restore_lustre_params < $save
9845 run_test 154f "get parent fids by reading link ea"
9847 test_155_small_load() {
9848 local temp=$TMP/$tfile
9849 local file=$DIR/$tfile
9851 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9852 error "dd of=$temp bs=6096 count=1 failed"
9854 cancel_lru_locks osc
9855 cmp $temp $file || error "$temp $file differ"
9857 $TRUNCATE $temp 6000
9858 $TRUNCATE $file 6000
9859 cmp $temp $file || error "$temp $file differ (truncate1)"
9861 echo "12345" >>$temp
9862 echo "12345" >>$file
9863 cmp $temp $file || error "$temp $file differ (append1)"
9865 echo "12345" >>$temp
9866 echo "12345" >>$file
9867 cmp $temp $file || error "$temp $file differ (append2)"
9873 test_155_big_load() {
9874 remote_ost_nodsh && skip "remote OST with nodsh" && return
9875 local temp=$TMP/$tfile
9876 local file=$DIR/$tfile
9879 local cache_size=$(do_facet ost$((MAXI+1)) \
9880 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9881 local large_file_size=$((cache_size * 2))
9883 echo "OSS cache size: $cache_size KB"
9884 echo "Large file size: $large_file_size KB"
9886 [ $MAXV -le $large_file_size ] && \
9887 skip_env "max available OST size needs > $large_file_size KB" && \
9890 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9892 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9893 error "dd of=$temp bs=$large_file_size count=1k failed"
9896 cancel_lru_locks osc
9897 cmp $temp $file || error "$temp $file differ"
9904 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9906 set_cache writethrough on
9909 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9914 set_cache writethrough off
9917 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9922 set_cache writethrough on
9925 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9930 set_cache writethrough off
9933 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9936 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9938 set_cache writethrough on
9941 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9946 set_cache writethrough off
9949 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9952 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9954 set_cache writethrough on
9957 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9962 set_cache writethrough off
9965 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9968 remote_ost_nodsh && skip "remote OST with nodsh" && return
9969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9973 local file="$DIR/$tfile"
9975 [ "$(facet_fstype ost1)" = "zfs" ] &&
9976 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9981 log "Turn on read and write cache"
9983 set_cache writethrough on
9985 log "Write data and read it back."
9986 log "Read should be satisfied from the cache."
9987 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9989 cancel_lru_locks osc
9990 cat $file >/dev/null
9992 if ! let "AFTER - BEFORE == CPAGES"; then
9993 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9995 log "cache hits:: before: $BEFORE, after: $AFTER"
9998 log "Read again; it should be satisfied from the cache."
10000 cancel_lru_locks osc
10001 cat $file >/dev/null
10003 if ! let "AFTER - BEFORE == CPAGES"; then
10004 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10006 log "cache hits:: before: $BEFORE, after: $AFTER"
10010 log "Turn off the read cache and turn on the write cache"
10012 set_cache writethrough on
10014 log "Read again; it should be satisfied from the cache."
10016 cancel_lru_locks osc
10017 cat $file >/dev/null
10019 if ! let "AFTER - BEFORE == CPAGES"; then
10020 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10022 log "cache hits:: before: $BEFORE, after: $AFTER"
10025 log "Read again; it should not be satisfied from the cache."
10027 cancel_lru_locks osc
10028 cat $file >/dev/null
10030 if ! let "AFTER - BEFORE == 0"; then
10031 error "IN CACHE: before: $BEFORE, after: $AFTER"
10033 log "cache hits:: before: $BEFORE, after: $AFTER"
10036 log "Write data and read it back."
10037 log "Read should be satisfied from the cache."
10038 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10040 cancel_lru_locks osc
10041 cat $file >/dev/null
10043 if ! let "AFTER - BEFORE == CPAGES"; then
10044 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10046 log "cache hits:: before: $BEFORE, after: $AFTER"
10049 log "Read again; it should not be satisfied from the cache."
10051 cancel_lru_locks osc
10052 cat $file >/dev/null
10054 if ! let "AFTER - BEFORE == 0"; then
10055 error "IN CACHE: before: $BEFORE, after: $AFTER"
10057 log "cache hits:: before: $BEFORE, after: $AFTER"
10061 log "Turn off read and write cache"
10063 set_cache writethrough off
10065 log "Write data and read it back"
10066 log "It should not be satisfied from the cache."
10068 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10069 cancel_lru_locks osc
10071 cat $file >/dev/null
10073 if ! let "AFTER - BEFORE == 0"; then
10074 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10076 log "cache hits:: before: $BEFORE, after: $AFTER"
10079 log "Turn on the read cache and turn off the write cache"
10081 set_cache writethrough off
10083 log "Write data and read it back"
10084 log "It should not be satisfied from the cache."
10086 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10088 cancel_lru_locks osc
10089 cat $file >/dev/null
10091 if ! let "AFTER - BEFORE == 0"; then
10092 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10094 log "cache hits:: before: $BEFORE, after: $AFTER"
10097 log "Read again; it should be satisfied from the cache."
10099 cancel_lru_locks osc
10100 cat $file >/dev/null
10102 if ! let "AFTER - BEFORE == CPAGES"; then
10103 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10105 log "cache hits:: before: $BEFORE, after: $AFTER"
10110 run_test 156 "Verification of tunables ============================"
10114 if [[ $MDSCOUNT -gt 1 ]]; then
10115 error_ignore bz17935 $*
10123 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10125 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10127 if [ $MASK -eq 1 ]; then
10128 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10130 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10134 changelog_extract_field() {
10138 local identifier=$4
10140 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10141 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10146 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10147 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10148 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10149 { skip "Need MDS version at least 2.2.0"; return; }
10151 local CL_USERS="mdd.$MDT0.changelog_users"
10152 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10153 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10154 echo "Registered as changelog user $USER"
10155 $GET_CL_USERS | grep -q $USER ||
10156 error "User $USER not found in changelog_users"
10159 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10160 touch $DIR/$tdir/pics/2008/zachy/timestamp
10161 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10162 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10163 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10164 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10165 rm $DIR/$tdir/pics/desktop.jpg
10167 $LFS changelog $MDT0 | tail -5
10169 echo "verifying changelog mask"
10170 changelog_chmask "MKDIR"
10171 changelog_chmask "CLOSE"
10173 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10174 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10176 changelog_chmask "MKDIR"
10177 changelog_chmask "CLOSE"
10179 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10180 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10182 $LFS changelog $MDT0
10183 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10184 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10185 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10186 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10189 echo "verifying target fid"
10190 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10191 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10192 [ "$fidc" == "$fidf" ] ||
10193 err17935 "fid in changelog $fidc != file fid $fidf"
10194 echo "verifying parent fid"
10195 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10196 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10197 [ "$fidc" == "$fidf" ] ||
10198 err17935 "pfid in changelog $fidc != dir fid $fidf"
10200 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10201 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10202 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10203 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10204 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10205 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10207 MIN_REC=$($GET_CL_USERS |
10208 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10209 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10210 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10211 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10212 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10214 # LU-3446 changelog index reset on MDT restart
10215 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10216 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10217 $LFS changelog_clear $MDT0 $USER 0
10218 stop $SINGLEMDS || error "Fail to stop MDT."
10219 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10220 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10221 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10222 [ $CUR_REC1 == $CUR_REC2 ] ||
10223 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10225 echo "verifying user deregister"
10226 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10227 $GET_CL_USERS | grep -q $USER &&
10228 error "User $USER still in changelog_users"
10230 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10231 if [ $USERS -eq 0 ]; then
10232 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10233 touch $DIR/$tdir/chloe
10234 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10235 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10236 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10238 echo "$USERS other changelog users; can't verify off"
10241 run_test 160a "changelog sanity"
10243 test_160b() { # LU-3587
10244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10245 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10246 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10247 { skip "Need MDS version at least 2.2.0"; return; }
10249 local CL_USERS="mdd.$MDT0.changelog_users"
10250 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10251 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10252 echo "Registered as changelog user $USER"
10253 $GET_CL_USERS | grep -q $USER ||
10254 error "User $USER not found in changelog_users"
10256 local LONGNAME1=$(str_repeat a 255)
10257 local LONGNAME2=$(str_repeat b 255)
10260 echo "creating very long named file"
10261 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10262 echo "moving very long named file"
10263 mv $LONGNAME1 $LONGNAME2
10265 $LFS changelog $MDT0 | grep RENME
10267 echo "deregistering $USER"
10268 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10272 run_test 160b "Verify that very long rename doesn't crash in changelog"
10276 local server_version=$(lustre_version_code $SINGLEMDS)
10278 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10279 [[ $server_version -gt $(version_code 2.5.1) &&
10280 $server_version -lt $(version_code 2.5.50) ]] ||
10281 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10284 # Registration step
10285 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10286 changelog_register -n)
10289 mkdir -p $DIR/$tdir
10290 $MCREATE $DIR/$tdir/foo_160c
10291 changelog_chmask "TRUNC"
10292 $TRUNCATE $DIR/$tdir/foo_160c 200
10293 changelog_chmask "TRUNC"
10294 $TRUNCATE $DIR/$tdir/foo_160c 199
10295 $LFS changelog $MDT0
10296 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10297 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10298 $LFS changelog_clear $MDT0 $USER 0
10300 # Deregistration step
10301 echo "deregistering $USER"
10302 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10304 run_test 160c "verify that changelog log catch the truncate event"
10307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10308 test_mkdir -p -c1 $DIR/$tdir
10309 cp /etc/hosts $DIR/$tdir/$tfile
10310 test_mkdir -c1 $DIR/$tdir/foo1
10311 test_mkdir -c1 $DIR/$tdir/foo2
10312 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10313 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10314 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10315 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10316 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10317 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10318 $LFS fid2path $DIR $FID
10319 err17935 "bad link ea"
10322 rm $DIR/$tdir/foo2/zachary
10324 rm $DIR/$tdir/foo2/thor
10326 rm $DIR/$tdir/$tfile
10328 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10329 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10331 $LFS fid2path $DIR $FID
10332 err17935 "bad link rename"
10334 rm $DIR/$tdir/foo2/maggie
10337 local longname=filename_avg_len_is_thirty_two_
10338 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10339 error "failed to hardlink many files"
10340 links=$($LFS fid2path $DIR $FID | wc -l)
10341 echo -n "${links}/1000 links in link EA"
10342 [[ $links -gt 60 ]] ||
10343 err17935 "expected at least 60 links in link EA"
10344 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10345 error "failed to unlink many hardlinks"
10347 run_test 161a "link ea sanity"
10350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10351 [ $MDSCOUNT -lt 2 ] &&
10352 skip "skipping remote directory test" && return
10354 local remote_dir=$DIR/$tdir/remote_dir
10356 mkdir -p $DIR/$tdir
10357 $LFS mkdir -i $MDTIDX $remote_dir ||
10358 error "create remote directory failed"
10360 cp /etc/hosts $remote_dir/$tfile
10361 mkdir -p $remote_dir/foo1
10362 mkdir -p $remote_dir/foo2
10363 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10364 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10365 ln $remote_dir/$tfile $remote_dir/foo1/luna
10366 ln $remote_dir/$tfile $remote_dir/foo2/thor
10368 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10370 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10371 $LFS fid2path $DIR $FID
10372 err17935 "bad link ea"
10375 rm $remote_dir/foo2/zachary
10377 rm $remote_dir/foo2/thor
10379 rm $remote_dir/$tfile
10381 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10382 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10383 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10384 $LFS fid2path $DIR $FID
10385 err17935 "bad link rename"
10387 rm $remote_dir/foo2/maggie
10390 local longname=filename_avg_len_is_thirty_two_
10391 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10392 error "failed to hardlink many files"
10393 links=$($LFS fid2path $DIR $FID | wc -l)
10394 echo -n "${links}/1000 links in link EA"
10395 [[ ${links} -gt 60 ]] ||
10396 err17935 "expected at least 60 links in link EA"
10397 unlinkmany $remote_dir/foo2/$longname 1000 ||
10398 error "failed to unlink many hardlinks"
10400 run_test 161b "link ea sanity under remote directory"
10403 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10404 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10405 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10406 skip "Need MDS version at least 2.1.5" && return
10408 # define CLF_RENAME_LAST 0x0001
10409 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10410 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10411 changelog_register -n)
10413 mkdir -p $DIR/$tdir
10414 touch $DIR/$tdir/foo_161c
10415 touch $DIR/$tdir/bar_161c
10416 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10417 $LFS changelog $MDT0 | grep RENME
10418 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10420 $LFS changelog_clear $MDT0 $USER 0
10421 if [ x$flags != "x0x1" ]; then
10422 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10424 error "flag $flags is not 0x1"
10426 echo "rename overwrite a target having nlink = 1," \
10427 "changelog record has flags of $flags"
10429 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10430 touch $DIR/$tdir/foo_161c
10431 touch $DIR/$tdir/bar_161c
10432 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10433 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10434 $LFS changelog $MDT0 | grep RENME
10435 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10436 $LFS changelog_clear $MDT0 $USER 0
10437 if [ x$flags != "x0x0" ]; then
10438 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10440 error "flag $flags is not 0x0"
10442 echo "rename overwrite a target having nlink > 1," \
10443 "changelog record has flags of $flags"
10445 # rename doesn't overwrite a target (changelog flag 0x0)
10446 touch $DIR/$tdir/foo_161c
10447 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10448 $LFS changelog $MDT0 | grep RENME
10449 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10450 $LFS changelog_clear $MDT0 $USER 0
10451 if [ x$flags != "x0x0" ]; then
10452 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10454 error "flag $flags is not 0x0"
10456 echo "rename doesn't overwrite a target," \
10457 "changelog record has flags of $flags"
10459 # define CLF_UNLINK_LAST 0x0001
10460 # unlink a file having nlink = 1 (changelog flag 0x1)
10461 rm -f $DIR/$tdir/foo2_161c
10462 $LFS changelog $MDT0 | grep UNLNK
10463 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10464 $LFS changelog_clear $MDT0 $USER 0
10465 if [ x$flags != "x0x1" ]; then
10466 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10468 error "flag $flags is not 0x1"
10470 echo "unlink a file having nlink = 1," \
10471 "changelog record has flags of $flags"
10473 # unlink a file having nlink > 1 (changelog flag 0x0)
10474 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10475 rm -f $DIR/$tdir/foobar_161c
10476 $LFS changelog $MDT0 | grep UNLNK
10477 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10478 $LFS changelog_clear $MDT0 $USER 0
10479 if [ x$flags != "x0x0" ]; then
10480 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10482 error "flag $flags is not 0x0"
10484 echo "unlink a file having nlink > 1," \
10485 "changelog record has flags of $flags"
10486 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10488 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10495 local path=$(${LFS} fid2path $*)
10498 if [ $RC -ne 0 ]; then
10499 err17935 "path looked up of $expected failed. Error $RC"
10501 elif [ "${path}" != "${expected}" ]; then
10502 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10505 echo "fid $fid resolves to path $path (expected $expected)"
10509 # Make changes to filesystem
10510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10511 test_mkdir -p -c1 $DIR/$tdir/d2
10512 touch $DIR/$tdir/d2/$tfile
10513 touch $DIR/$tdir/d2/x1
10514 touch $DIR/$tdir/d2/x2
10515 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10516 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10518 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10519 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10520 error "check path $tdir/d2/$tfile failed"
10523 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10524 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10525 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10526 error "check path $tdir/d2/p/q/r/slink failed"
10528 # softlink to wrong file
10529 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10530 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10531 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10532 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10535 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10536 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10537 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10538 # fid2path dir/fsname should both work
10539 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10540 error "check path $tdir/d2/a/b/c/new_file failed"
10541 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10542 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10544 # hardlink count: check that there are 2 links
10545 # Doesnt work with CMD yet: 17935
10546 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10547 err17935 "expected 2 links"
10549 # hardlink indexing: remove the first link
10550 rm $DIR/$tdir/d2/p/q/r/hlink
10551 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10552 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10556 run_test 162 "path lookup sanity"
10559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10560 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10563 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10564 error "create striped dir failed"
10566 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10567 tail -n 1 | awk '{print $2}')
10568 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10570 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10571 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10574 for ((i=0;i<5;i++)); do
10575 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10576 error "get fid for f$i failed"
10577 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10578 error "check path $tdir/striped_dir/f$i failed"
10580 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10581 error "get fid for d$i failed"
10582 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10583 error "check path $tdir/striped_dir/d$i failed"
10588 run_test 162b "striped directory path lookup sanity"
10591 # do directio so as not to populate the page cache
10592 log "creating a 10 Mb file"
10593 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10594 log "starting reads"
10595 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10596 log "truncating the file"
10597 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10599 kill %+ || true # reads might have finished
10600 echo "wait until dd is finished"
10602 log "removing the temporary file"
10603 rm -rf $DIR/$tfile || error "tmp file removal failed"
10605 run_test 169 "parallel read and truncate should not deadlock"
10608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10609 $LCTL clear # bug 18514
10610 $LCTL debug_daemon start $TMP/${tfile}_log_good
10612 $LCTL debug_daemon stop
10613 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10614 error "sed failed to read log_good"
10616 $LCTL debug_daemon start $TMP/${tfile}_log_good
10618 $LCTL debug_daemon stop
10620 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10621 error "lctl df log_bad failed"
10623 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10624 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10626 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10627 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10629 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10630 error "bad_line good_line1 good_line2 are empty"
10632 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10633 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10634 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10636 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10637 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10638 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10640 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10641 error "bad_line_new good_line_new are empty"
10643 local expected_good=$((good_line1 + good_line2*2))
10645 rm -f $TMP/${tfile}*
10646 # LU-231, short malformed line may not be counted into bad lines
10647 if [ $bad_line -ne $bad_line_new ] &&
10648 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10649 error "expected $bad_line bad lines, but got $bad_line_new"
10653 if [ $expected_good -ne $good_line_new ]; then
10654 error "expected $expected_good good lines, but got $good_line_new"
10659 run_test 170 "test lctl df to handle corrupted log ====================="
10661 test_171() { # bug20592
10662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10663 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10664 $LCTL set_param fail_loc=0x50e
10665 $LCTL set_param fail_val=3000
10666 multiop_bg_pause $DIR/$tfile O_s || true
10668 kill -USR1 $MULTIPID
10672 if dmesg | grep "recursive fault"; then
10673 error "caught a recursive fault"
10675 $LCTL set_param fail_loc=0
10678 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10680 # it would be good to share it with obdfilter-survey/iokit-libecho code
10681 setup_obdecho_osc () {
10684 local obdfilter_name=$2
10685 echo "Creating new osc for $obdfilter_name on $ost_nid"
10686 # make sure we can find loopback nid
10687 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10689 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10690 ${obdfilter_name}_osc_UUID || rc=2; }
10691 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10692 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10696 cleanup_obdecho_osc () {
10697 local obdfilter_name=$1
10698 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10699 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10706 local pages=${3:-64}
10711 local obd_size=$(get_obd_size $node $OBD)
10712 local page_size=$(get_page_size $node)
10713 if [[ -n "$obd_size" ]]; then
10714 local new_count=$((obd_size / (pages * page_size / 1024)))
10715 [[ $new_count -ge $count ]] || count=$new_count
10718 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10719 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10721 if [ $rc -eq 0 ]; then
10722 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10723 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10725 echo "New object id is $id"
10726 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10728 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10729 "test_brw $count w v $pages $id" || rc=4; }
10730 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10732 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10733 "cleanup" || rc=5; }
10734 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10735 "detach" || rc=6; }
10736 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10741 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10742 remote_ost_nodsh && skip "remote OST with nodsh" && return
10744 local rmmod_local=0
10746 if ! module_loaded obdecho; then
10747 load_module obdecho/obdecho
10751 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10752 local host=$(lctl get_param -n osc.$osc.import |
10753 awk '/current_connection:/ {print $2}' )
10754 local target=$(lctl get_param -n osc.$osc.import |
10755 awk '/target:/ {print $2}' )
10756 target=${target%_UUID}
10758 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10759 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10760 [[ -n $target ]] && cleanup_obdecho_osc $target
10761 [ $rmmod_local -eq 1 ] && rmmod obdecho
10764 run_test 180a "test obdecho on osc"
10767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10768 remote_ost_nodsh && skip "remote OST with nodsh" && return
10770 local rmmod_remote=0
10772 do_facet ost1 "lsmod | grep -q obdecho || " \
10773 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10774 "modprobe obdecho; }" && rmmod_remote=1
10775 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10776 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10777 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10780 run_test 180b "test obdecho directly on obdfilter"
10782 test_180c() { # LU-2598
10783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10784 remote_ost_nodsh && skip "remote OST with nodsh" && return
10785 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10786 skip "Need MDS version at least 2.4.0" && return
10789 local rmmod_remote=false
10790 local pages=16384 # 64MB bulk I/O RPC size
10793 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10794 rmmod_remote=true || error "failed to load module obdecho"
10796 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10798 if [ -n "$target" ]; then
10799 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10801 echo "there is no obdfilter target on ost1"
10804 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10807 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10809 test_181() { # bug 22177
10810 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10811 # create enough files to index the directory
10812 createmany -o $DIR/$tdir/foobar 4000
10813 # print attributes for debug purpose
10816 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10818 # remove the files & current working dir
10819 unlinkmany $DIR/$tdir/foobar 4000
10821 kill -USR1 $MULTIPID
10823 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10826 run_test 181 "Test open-unlinked dir ========================"
10829 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10830 # disable MDC RPC lock wouldn't crash client
10834 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10835 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10836 $LCTL set_param fail_loc=0x804
10838 for (( i=0; i < $tcount; i++ )) ; do
10839 mkdir $DIR/$tdir/$i
10840 createmany -o $DIR/$tdir/$i/f- $fcount &
10844 for (( i=0; i < $tcount; i++ )) ; do
10845 unlinkmany $DIR/$tdir/$i/f- $fcount &
10851 $LCTL set_param fail_loc=0
10853 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10855 test_183() { # LU-2275
10856 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10857 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10858 skip "Need MDS version at least 2.3.56" && return
10860 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10861 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10862 echo aaa > $DIR/$tdir/$tfile
10864 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10865 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10867 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10868 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10870 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10872 # Flush negative dentry cache
10873 touch $DIR/$tdir/$tfile
10875 # We are not checking for any leaked references here, they'll
10876 # become evident next time we do cleanup with module unload.
10879 run_test 183 "No crash or request leak in case of strange dispositions ========"
10881 # test suite 184 is for LU-2016, LU-2017
10883 check_swap_layouts_support && return 0
10885 dir0=$DIR/$tdir/$testnum
10886 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10891 $SETSTRIPE -c1 $file1
10893 $SETSTRIPE -c2 $file2
10895 gen1=$($GETSTRIPE -g $file1)
10896 gen2=$($GETSTRIPE -g $file2)
10898 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10899 gen=$($GETSTRIPE -g $file1)
10900 [[ $gen1 != $gen ]] ||
10901 "Layout generation on $file1 does not change"
10902 gen=$($GETSTRIPE -g $file2)
10903 [[ $gen2 != $gen ]] ||
10904 "Layout generation on $file2 does not change"
10906 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10907 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10909 run_test 184a "Basic layout swap"
10912 check_swap_layouts_support && return 0
10914 dir0=$DIR/$tdir/$testnum
10915 mkdir -p $dir0 || error "creating dir $dir0"
10922 $SETSTRIPE -c1 $file1
10923 $SETSTRIPE -c2 $file2
10924 $SETSTRIPE -c1 $file3
10925 chown $RUNAS_ID $file3
10926 gen1=$($GETSTRIPE -g $file1)
10927 gen2=$($GETSTRIPE -g $file2)
10929 $LFS swap_layouts $dir1 $dir2 &&
10930 error "swap of directories layouts should fail"
10931 $LFS swap_layouts $dir1 $file1 &&
10932 error "swap of directory and file layouts should fail"
10933 $RUNAS $LFS swap_layouts $file1 $file2 &&
10934 error "swap of file we cannot write should fail"
10935 $LFS swap_layouts $file1 $file3 &&
10936 error "swap of file with different owner should fail"
10937 /bin/true # to clear error code
10939 run_test 184b "Forbidden layout swap (will generate errors)"
10942 check_swap_layouts_support && return 0
10944 local dir0=$DIR/$tdir/$testnum
10945 mkdir -p $dir0 || error "creating dir $dir0"
10947 local ref1=$dir0/ref1
10948 local ref2=$dir0/ref2
10949 local file1=$dir0/file1
10950 local file2=$dir0/file2
10951 # create a file large enough for the concurent test
10952 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10953 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10954 echo "ref file size: ref1($(stat -c %s $ref1))," \
10955 "ref2($(stat -c %s $ref2))"
10958 dd if=$ref1 of=$file1 bs=16k &
10961 # Make sure dd starts to copy file
10962 while [ ! -f $file1 ]; do sleep 0.1; done
10964 $LFS swap_layouts $file1 $file2
10967 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10968 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10970 # how many bytes copied before swapping layout
10971 local copied=$(stat -c %s $file2)
10972 local remaining=$(stat -c %s $ref1)
10973 remaining=$((remaining - copied))
10974 echo "Copied $copied bytes before swapping layout..."
10976 cmp -n $copied $file1 $ref2 | grep differ &&
10977 error "Content mismatch [0, $copied) of ref2 and file1"
10978 cmp -n $copied $file2 $ref1 ||
10979 error "Content mismatch [0, $copied) of ref1 and file2"
10980 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10981 error "Content mismatch [$copied, EOF) of ref1 and file1"
10984 rm -f $ref1 $ref2 $file1 $file2
10986 run_test 184c "Concurrent write and layout swap"
10989 check_swap_layouts_support && return 0
10990 [ -z "$(which getfattr 2>/dev/null)" ] &&
10991 skip "no getfattr command" && return 0
10993 local file1=$DIR/$tdir/$tfile-1
10994 local file2=$DIR/$tdir/$tfile-2
10995 local file3=$DIR/$tdir/$tfile-3
10999 mkdir -p $DIR/$tdir
11000 touch $file1 || error "create $file1 failed"
11001 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11002 error "create $file2 failed"
11003 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11004 error "create $file3 failed"
11005 lovea1=$($LFS getstripe $file1 | sed 1d)
11007 $LFS swap_layouts $file2 $file3 ||
11008 error "swap $file2 $file3 layouts failed"
11009 $LFS swap_layouts $file1 $file2 ||
11010 error "swap $file1 $file2 layouts failed"
11012 lovea2=$($LFS getstripe $file2 | sed 1d)
11013 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11015 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11016 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11018 run_test 184d "allow stripeless layouts swap"
11021 test_185() { # LU-2441
11022 # LU-3553 - no volatile file support in old servers
11023 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11024 { skip "Need MDS version at least 2.3.60"; return 0; }
11026 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11027 touch $DIR/$tdir/spoo
11028 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11029 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11030 error "cannot create/write a volatile file"
11031 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11032 error "FID is still valid after close"
11034 multiop_bg_pause $DIR/$tdir vVw4096_c
11041 # assume that the next FID for this client is sequential, since stdout
11042 # is unfortunately eaten by multiop_bg_pause
11043 local n=$((${fidv[1]} + 1))
11044 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11045 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11046 error "FID is missing before close"
11047 kill -USR1 $multi_pid
11048 # 1 second delay, so if mtime change we will see it
11050 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11051 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11053 run_test 185 "Volatile file support"
11056 local dir0=$DIR/$tdir/$testnum
11057 mkdir -p $dir0 || error "creating dir $dir0"
11059 local file=$dir0/file1
11060 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11061 local dv1=$($LFS data_version $file)
11062 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11063 local dv2=$($LFS data_version $file)
11064 [[ $dv1 != $dv2 ]] ||
11065 error "data version did not change on write $dv1 == $dv2"
11070 run_test 187a "Test data version change"
11073 local dir0=$DIR/$tdir/$testnum
11074 mkdir -p $dir0 || error "creating dir $dir0"
11076 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11077 [[ ${DV[0]} != ${DV[1]} ]] ||
11078 error "data version did not change on write"\
11079 " ${DV[0]} == ${DV[1]}"
11084 run_test 187b "Test data version change on volatile file"
11087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11088 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11090 local POOL=${POOL:-cea1}
11091 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11092 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11095 local last_ost=$(($OSTCOUNT - 1))
11097 local ost_list=$(seq $first_ost $ost_step $last_ost)
11098 local ost_range="$first_ost $last_ost $ost_step"
11099 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11100 local file_dir=$POOL_ROOT/file_tst
11104 # former test_200a test_200b
11105 pool_add $POOL || { rc=$? ; break; }
11106 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11107 # former test_200c test_200d
11108 mkdir -p $test_path
11109 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11110 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11111 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11112 || { rc=$? ; break; }
11113 # former test_200e test_200f
11114 local files=$((OSTCOUNT*3))
11115 pool_alloc_files $POOL $test_path $files "$ost_list" \
11116 || { rc=$? ; break; }
11117 pool_create_files $POOL $file_dir $files "$ost_list" \
11118 || { rc=$? ; break; }
11119 # former test_200g test_200h
11120 pool_lfs_df $POOL || { rc=$? ; break; }
11121 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11123 # former test_201a test_201b test_201c
11124 pool_remove_first_target $POOL || { rc=$? ; break; }
11126 local f=$test_path/$tfile
11127 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11128 pool_remove $POOL $f || { rc=$? ; break; }
11135 run_test 200 "OST pools"
11137 # usage: default_attr <count | size | offset>
11139 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11142 # usage: check_default_stripe_attr
11143 check_default_stripe_attr() {
11144 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11146 --stripe-count|--count)
11147 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11148 --stripe-size|--size)
11149 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11150 --stripe-index|--index)
11153 error "unknown getstripe attr '$1'"
11156 [ $ACTUAL != $EXPECTED ] &&
11157 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11161 test_mkdir -p $DIR/$tdir
11162 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11164 check_default_stripe_attr --stripe-count
11165 check_default_stripe_attr --stripe-size
11166 check_default_stripe_attr --stripe-index
11170 run_test 204a "Print default stripe attributes ================="
11173 test_mkdir -p $DIR/$tdir
11174 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11176 check_default_stripe_attr --stripe-size
11177 check_default_stripe_attr --stripe-index
11181 run_test 204b "Print default stripe size and offset ==========="
11184 test_mkdir -p $DIR/$tdir
11185 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11187 check_default_stripe_attr --stripe-count
11188 check_default_stripe_attr --stripe-index
11192 run_test 204c "Print default stripe count and offset ==========="
11195 test_mkdir -p $DIR/$tdir
11196 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11198 check_default_stripe_attr --stripe-count
11199 check_default_stripe_attr --stripe-size
11203 run_test 204d "Print default stripe count and size ============="
11206 test_mkdir -p $DIR/$tdir
11207 $SETSTRIPE -d $DIR/$tdir
11209 check_default_stripe_attr --stripe-count --raw
11210 check_default_stripe_attr --stripe-size --raw
11211 check_default_stripe_attr --stripe-index --raw
11215 run_test 204e "Print raw stripe attributes ================="
11218 test_mkdir -p $DIR/$tdir
11219 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11221 check_default_stripe_attr --stripe-size --raw
11222 check_default_stripe_attr --stripe-index --raw
11226 run_test 204f "Print raw stripe size and offset ==========="
11229 test_mkdir -p $DIR/$tdir
11230 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11232 check_default_stripe_attr --stripe-count --raw
11233 check_default_stripe_attr --stripe-index --raw
11237 run_test 204g "Print raw stripe count and offset ==========="
11240 test_mkdir -p $DIR/$tdir
11241 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11243 check_default_stripe_attr --stripe-count --raw
11244 check_default_stripe_attr --stripe-size --raw
11248 run_test 204h "Print raw stripe count and size ============="
11250 # Figure out which job scheduler is being used, if any,
11251 # or use a fake one
11252 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11253 JOBENV=SLURM_JOB_ID
11254 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11256 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11258 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11259 JOBENV=LOADL_STEP_ID
11260 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11266 verify_jobstats() {
11270 # clear old jobstats
11271 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11272 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11274 # use a new JobID for this test, or we might see an old one
11275 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11279 log "Using JobID environment variable $JOBENV=$JOBVAL"
11281 if [ $JOBENV = "FAKE_JOBID" ]; then
11282 FAKE_JOBID=$JOBVAL $cmd
11287 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11288 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11289 do_facet $FACET lctl get_param mdt.*.job_stats |
11290 grep $JOBVAL || error "No job stats found on MDT $FACET"
11292 if [ "$target" = "ost" -o "$target" = "both" ]; then
11294 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11295 grep $JOBVAL || error "No job stats found on OST $FACET"
11301 NEW_JOBENV=${1:-$OLD_JOBENV}
11302 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11303 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11306 test_205() { # Job stats
11307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11308 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11309 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11310 skip "Server doesn't support jobstats" && return 0
11311 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11314 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11315 if [ $OLD_JOBENV != $JOBENV ]; then
11316 jobstats_set $JOBENV
11317 trap jobstats_set EXIT
11320 local user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11321 changelog_register -n)
11322 echo "Registered as changelog user $user"
11325 cmd="mkdir $DIR/$tfile"
11326 verify_jobstats "$cmd" "mdt"
11328 cmd="rm -fr $DIR/$tfile"
11329 verify_jobstats "$cmd" "mdt"
11331 cmd="mknod $DIR/$tfile c 1 3"
11332 verify_jobstats "$cmd" "mdt"
11334 cmd="rm -f $DIR/$tfile"
11335 verify_jobstats "$cmd" "mdt"
11337 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11338 verify_jobstats "$cmd" "mdt"
11340 cmd="touch $DIR/$tfile"
11341 verify_jobstats "$cmd" "both"
11343 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11344 verify_jobstats "$cmd" "ost"
11346 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11347 verify_jobstats "$cmd" "ost"
11349 cmd="$TRUNCATE $DIR/$tfile 0"
11350 verify_jobstats "$cmd" "both"
11352 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11353 verify_jobstats "$cmd" "mdt"
11355 # Ensure that jobid are present in changelog (if supported by MDS)
11356 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11358 $LFS changelog $MDT0 | tail -9
11359 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11360 [ $jobids -eq 9 ] ||
11361 error "Wrong changelog jobid count $jobids != 9"
11365 rm -f $DIR/jobstats_test_rename
11367 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11369 run_test 205 "Verify job stats"
11371 # LU-1480, LU-1773 and LU-1657
11373 mkdir -p $DIR/$tdir
11374 $SETSTRIPE -c -1 $DIR/$tdir
11375 #define OBD_FAIL_LOV_INIT 0x1403
11376 $LCTL set_param fail_loc=0xa0001403
11377 $LCTL set_param fail_val=1
11378 touch $DIR/$tdir/$tfile || true
11380 run_test 206 "fail lov_init_raid0() doesn't lbug"
11383 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11384 local fsz=`stat -c %s $DIR/$tfile`
11385 cancel_lru_locks mdc
11387 # do not return layout in getattr intent
11388 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11389 $LCTL set_param fail_loc=0x170
11390 local sz=`stat -c %s $DIR/$tfile`
11392 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11396 run_test 207a "can refresh layout at glimpse"
11399 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11400 local cksum=`md5sum $DIR/$tfile`
11401 local fsz=`stat -c %s $DIR/$tfile`
11402 cancel_lru_locks mdc
11403 cancel_lru_locks osc
11405 # do not return layout in getattr intent
11406 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11407 $LCTL set_param fail_loc=0x171
11409 # it will refresh layout after the file is opened but before read issues
11410 echo checksum is "$cksum"
11411 echo "$cksum" |md5sum -c --quiet || error "file differs"
11415 run_test 207b "can refresh layout at open"
11418 # FIXME: in this test suite, only RD lease is used. This is okay
11419 # for now as only exclusive open is supported. After generic lease
11420 # is done, this test suite should be revised. - Jinshan
11422 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11423 { skip "Need MDS version at least 2.4.52"; return 0; }
11424 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11426 echo "==== test 1: verify get lease work"
11427 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11429 echo "==== test 2: verify lease can be broken by upcoming open"
11430 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11434 $MULTIOP $DIR/$tfile oO_RDONLY:c
11435 kill -USR1 $PID && wait $PID || error "break lease error"
11437 echo "==== test 3: verify lease can't be granted if an open already exists"
11438 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11442 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11443 kill -USR1 $PID && wait $PID || error "open file error"
11445 echo "==== test 4: lease can sustain over recovery"
11446 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11452 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11454 echo "==== test 5: lease broken can't be regained by replay"
11455 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11459 # open file to break lease and then recovery
11460 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11463 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11467 run_test 208 "Exclusive open"
11470 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11471 skip_env "must have disp_stripe" && return
11474 sync; sleep 5; sync;
11476 echo 3 > /proc/sys/vm/drop_caches
11477 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11479 # open/close 500 times
11480 for i in $(seq 500); do
11484 echo 3 > /proc/sys/vm/drop_caches
11485 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11487 echo "before: $req_before, after: $req_after"
11488 [ $((req_after - req_before)) -ge 300 ] &&
11489 error "open/close requests are not freed"
11492 run_test 209 "read-only open/close requests should be freed promptly"
11496 size=$((size % 8192 + 1))
11497 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11498 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11499 rm -f $DIR/f212 $DIR/f212.xyz
11501 run_test 212 "Sendfile test ============================================"
11504 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11505 cancel_lru_locks osc
11506 lctl set_param fail_loc=0x8000040f
11507 # generate a read lock
11508 cat $DIR/$tfile > /dev/null
11509 # write to the file, it will try to cancel the above read lock.
11510 cat /etc/hosts >> $DIR/$tfile
11512 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11514 test_214() { # for bug 20133
11515 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11516 for (( i=0; i < 340; i++ )) ; do
11517 touch $DIR/$tdir/d214c/a$i
11520 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11521 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11522 ls $DIR/d214c || error "ls $DIR/d214c failed"
11523 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11524 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11526 run_test 214 "hash-indexed directory test - bug 20133"
11528 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11529 create_lnet_proc_files() {
11530 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11531 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11533 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11534 rm -f "$TMP/lnet_$1.sys_tmp"
11537 # counterpart of create_lnet_proc_files
11538 remove_lnet_proc_files() {
11539 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11542 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11543 # 3rd arg as regexp for body
11544 check_lnet_proc_stats() {
11545 local l=$(cat "$TMP/lnet_$1" |wc -l)
11546 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11548 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11551 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11552 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11553 # optional and can be regexp for 2nd line (lnet.routes case)
11554 check_lnet_proc_entry() {
11555 local blp=2 # blp stands for 'position of 1st line of body'
11556 [ -z "$5" ] || blp=3 # lnet.routes case
11558 local l=$(cat "$TMP/lnet_$1" |wc -l)
11559 # subtracting one from $blp because the body can be empty
11560 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11562 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11563 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11565 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11566 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11568 # bail out if any unexpected line happened
11569 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11570 [ "$?" != 0 ] || error "$2 misformatted"
11573 test_215() { # for bugs 18102, 21079, 21517
11574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11575 local N='(0|[1-9][0-9]*)' # non-negative numeric
11576 local P='[1-9][0-9]*' # positive numeric
11577 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11578 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11579 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11580 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11582 local L1 # regexp for 1st line
11583 local L2 # regexp for 2nd line (optional)
11584 local BR # regexp for the rest (body)
11586 # lnet.stats should look as 11 space-separated non-negative numerics
11587 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11588 create_lnet_proc_files "stats"
11589 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11590 remove_lnet_proc_files "stats"
11592 # lnet.routes should look like this:
11593 # Routing disabled/enabled
11594 # net hops priority state router
11595 # where net is a string like tcp0, hops > 0, priority >= 0,
11596 # state is up/down,
11597 # router is a string like 192.168.1.1@tcp2
11598 L1="^Routing (disabled|enabled)$"
11599 L2="^net +hops +priority +state +router$"
11600 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11601 create_lnet_proc_files "routes"
11602 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11603 remove_lnet_proc_files "routes"
11605 # lnet.routers should look like this:
11606 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11607 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11608 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11609 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11610 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11611 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11612 create_lnet_proc_files "routers"
11613 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11614 remove_lnet_proc_files "routers"
11616 # lnet.peers should look like this:
11617 # nid refs state last max rtr min tx min queue
11618 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11619 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11620 # numeric (0 or >0 or <0), queue >= 0.
11621 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11622 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11623 create_lnet_proc_files "peers"
11624 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11625 remove_lnet_proc_files "peers"
11627 # lnet.buffers should look like this:
11628 # pages count credits min
11629 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11630 L1="^pages +count +credits +min$"
11631 BR="^ +$N +$N +$I +$I$"
11632 create_lnet_proc_files "buffers"
11633 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11634 remove_lnet_proc_files "buffers"
11636 # lnet.nis should look like this:
11637 # nid status alive refs peer rtr max tx min
11638 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11639 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11640 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11641 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11642 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11643 create_lnet_proc_files "nis"
11644 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11645 remove_lnet_proc_files "nis"
11647 # can we successfully write to lnet.stats?
11648 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11649 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11651 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11653 test_216() { # bug 20317
11654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11655 remote_ost_nodsh && skip "remote OST with nodsh" && return
11658 local facets=$(get_facets OST)
11659 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11661 save_lustre_params client "osc.*.contention_seconds" > $p
11662 save_lustre_params $facets \
11663 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11664 save_lustre_params $facets \
11665 "ldlm.namespaces.filter-*.contended_locks" >> $p
11666 save_lustre_params $facets \
11667 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11670 # agressive lockless i/o settings
11671 for node in $(osts_nodes); do
11672 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'
11674 lctl set_param -n osc.*.contention_seconds 60
11676 $DIRECTIO write $DIR/$tfile 0 10 4096
11677 $CHECKSTAT -s 40960 $DIR/$tfile
11679 # disable lockless i/o
11680 for node in $(osts_nodes); do
11681 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'
11683 lctl set_param -n osc.*.contention_seconds 0
11686 dd if=/dev/zero of=$DIR/$tfile count=0
11687 $CHECKSTAT -s 0 $DIR/$tfile
11689 restore_lustre_params <$p
11693 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11695 test_217() { # bug 22430
11696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11700 for node in $(nodes_list); do
11701 nid=$(host_nids_address $node $NETTYPE)
11702 if [[ $nid = *-* ]] ; then
11703 echo "lctl ping $nid@$NETTYPE"
11704 lctl ping $nid@$NETTYPE
11706 echo "skipping $node (no hyphen detected)"
11710 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11713 # do directio so as not to populate the page cache
11714 log "creating a 10 Mb file"
11715 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11716 log "starting reads"
11717 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11718 log "truncating the file"
11719 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11721 kill %+ || true # reads might have finished
11722 echo "wait until dd is finished"
11724 log "removing the temporary file"
11725 rm -rf $DIR/$tfile || error "tmp file removal failed"
11727 run_test 218 "parallel read and truncate should not deadlock ======================="
11730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11731 # write one partial page
11732 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11733 # set no grant so vvp_io_commit_write will do sync write
11734 $LCTL set_param fail_loc=0x411
11735 # write a full page at the end of file
11736 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11738 $LCTL set_param fail_loc=0
11739 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11740 $LCTL set_param fail_loc=0x411
11741 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11744 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11745 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11747 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11749 test_220() { #LU-325
11750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11751 remote_ost_nodsh && skip "remote OST with nodsh" && return
11754 test_mkdir -p $DIR/$tdir
11755 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11756 awk '{print $2}' | sed -e 's/_UUID$//')
11759 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11760 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11761 osc.$mdtosc_proc1.prealloc_last_id)
11762 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11763 osc.$mdtosc_proc1.prealloc_next_id)
11767 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11768 #define OBD_FAIL_OST_ENOINO 0x229
11769 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11770 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11771 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11773 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11775 MDSOBJS=$((last_id - next_id))
11776 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11778 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11779 echo "OST still has $count kbytes free"
11781 echo "create $MDSOBJS files @next_id..."
11782 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11784 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11785 osc.$mdtosc_proc1.prealloc_last_id)
11786 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11787 osc.$mdtosc_proc1.prealloc_next_id)
11789 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11794 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11795 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11797 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11798 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11799 echo "unlink $MDSOBJS files @$next_id..."
11800 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11802 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11806 dd if=`which date` of=$MOUNT/date oflag=sync
11807 chmod +x $MOUNT/date
11809 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11810 $LCTL set_param fail_loc=0x80001401
11812 $MOUNT/date > /dev/null
11815 run_test 221 "make sure fault and truncate race to not cause OOM"
11818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11820 test_mkdir -p $DIR/$tdir
11821 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11822 createmany -o $DIR/$tdir/$tfile 10
11823 cancel_lru_locks mdc
11824 cancel_lru_locks osc
11825 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11826 $LCTL set_param fail_loc=0x31a
11827 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11828 $LCTL set_param fail_loc=0
11831 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11836 test_mkdir -p $DIR/$tdir
11837 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11838 createmany -o $DIR/$tdir/$tfile 10
11839 cancel_lru_locks mdc
11840 cancel_lru_locks osc
11841 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11842 $LCTL set_param fail_loc=0x31a
11843 rm -r $DIR/$tdir || "AGL for rmdir failed"
11844 $LCTL set_param fail_loc=0
11846 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11851 test_mkdir -p $DIR/$tdir
11852 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11853 createmany -o $DIR/$tdir/$tfile 10
11854 cancel_lru_locks mdc
11855 cancel_lru_locks osc
11856 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11857 $LCTL set_param fail_loc=0x31b
11858 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11859 $LCTL set_param fail_loc=0
11862 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11864 test_224a() { # LU-1039, MRP-303
11865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11866 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11867 $LCTL set_param fail_loc=0x508
11868 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11869 $LCTL set_param fail_loc=0
11872 run_test 224a "Don't panic on bulk IO failure"
11874 test_224b() { # LU-1039, MRP-303
11875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11876 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11877 cancel_lru_locks osc
11878 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11879 $LCTL set_param fail_loc=0x515
11880 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11881 $LCTL set_param fail_loc=0
11884 run_test 224b "Don't panic on bulk IO failure"
11886 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11889 if [ -z ${MDSSURVEY} ]; then
11890 skip_env "mds-survey not found" && return
11893 [ $MDSCOUNT -ge 2 ] &&
11894 skip "skipping now for more than one MDT" && return
11896 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11897 { skip "Need MDS version at least 2.2.51"; return; }
11899 local mds=$(facet_host $SINGLEMDS)
11900 local target=$(do_nodes $mds 'lctl dl' | \
11901 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11903 local cmd1="file_count=1000 thrhi=4"
11904 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11905 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11906 local cmd="$cmd1 $cmd2 $cmd3"
11908 rm -f ${TMP}/mds_survey*
11910 eval $cmd || error "mds-survey with zero-stripe failed"
11911 cat ${TMP}/mds_survey*
11912 rm -f ${TMP}/mds_survey*
11914 run_test 225a "Metadata survey sanity with zero-stripe"
11917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11919 if [ -z ${MDSSURVEY} ]; then
11920 skip_env "mds-survey not found" && return
11922 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11923 { skip "Need MDS version at least 2.2.51"; return; }
11925 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11926 skip_env "Need to mount OST to test" && return
11929 [ $MDSCOUNT -ge 2 ] &&
11930 skip "skipping now for more than one MDT" && return
11931 local mds=$(facet_host $SINGLEMDS)
11932 local target=$(do_nodes $mds 'lctl dl' | \
11933 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11935 local cmd1="file_count=1000 thrhi=4"
11936 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11937 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11938 local cmd="$cmd1 $cmd2 $cmd3"
11940 rm -f ${TMP}/mds_survey*
11942 eval $cmd || error "mds-survey with stripe_count failed"
11943 cat ${TMP}/mds_survey*
11944 rm -f ${TMP}/mds_survey*
11946 run_test 225b "Metadata survey sanity with stripe_count = 1"
11948 mcreate_path2fid () {
11954 local path=$DIR/$tdir/$name
11959 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11960 error "cannot create $desc"
11962 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11964 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11966 fid_path=$($LFS fid2path $MOUNT $fid)
11968 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11970 [ "$path" == "$fid_path" ] ||
11971 error "fid2path returned $fid_path, expected $path"
11973 echo "pass with $path and $fid"
11978 mkdir -p $DIR/$tdir
11980 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11981 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11982 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11983 mcreate_path2fid 0040666 0 0 dir "directory"
11984 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11985 mcreate_path2fid 0100666 0 0 file "regular file"
11986 mcreate_path2fid 0120666 0 0 link "symbolic link"
11987 mcreate_path2fid 0140666 0 0 sock "socket"
11989 run_test 226a "call path2fid and fid2path on files of all type"
11992 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11996 mkdir -p $DIR/$tdir
11997 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11998 error "create remote directory failed"
11999 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12000 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12001 "character special file (null)"
12002 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12003 "character special file (no device)"
12004 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12005 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12006 "block special file (loop)"
12007 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12008 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12009 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12011 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12013 # LU-1299 Executing or running ldd on a truncated executable does not
12014 # cause an out-of-memory condition.
12016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12017 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12018 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12019 chmod +x $MOUNT/date
12021 $MOUNT/date > /dev/null
12022 ldd $MOUNT/date > /dev/null
12025 run_test 227 "running truncated executable does not cause OOM"
12027 # LU-1512 try to reuse idle OI blocks
12029 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12030 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12031 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12032 skip "non-ldiskfs backend" && return
12034 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12035 local myDIR=$DIR/$tdir
12038 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12039 $LCTL set_param fail_loc=0x80001002
12040 createmany -o $myDIR/t- 10000
12041 $LCTL set_param fail_loc=0
12042 # The guard is current the largest FID holder
12044 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12046 local IDX=$(($SEQ % 64))
12048 do_facet $SINGLEMDS sync
12049 # Make sure journal flushed.
12051 local blk1=$(do_facet $SINGLEMDS \
12052 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12053 grep Blockcount | awk '{print $4}')
12055 # Remove old files, some OI blocks will become idle.
12056 unlinkmany $myDIR/t- 10000
12057 # Create new files, idle OI blocks should be reused.
12058 createmany -o $myDIR/t- 2000
12059 do_facet $SINGLEMDS sync
12060 # Make sure journal flushed.
12062 local blk2=$(do_facet $SINGLEMDS \
12063 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12064 grep Blockcount | awk '{print $4}')
12066 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12068 run_test 228a "try to reuse idle OI blocks"
12071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12072 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12073 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12074 skip "non-ldiskfs backend" && return
12076 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12077 local myDIR=$DIR/$tdir
12080 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12081 $LCTL set_param fail_loc=0x80001002
12082 createmany -o $myDIR/t- 10000
12083 $LCTL set_param fail_loc=0
12084 # The guard is current the largest FID holder
12086 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12088 local IDX=$(($SEQ % 64))
12090 do_facet $SINGLEMDS sync
12091 # Make sure journal flushed.
12093 local blk1=$(do_facet $SINGLEMDS \
12094 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12095 grep Blockcount | awk '{print $4}')
12097 # Remove old files, some OI blocks will become idle.
12098 unlinkmany $myDIR/t- 10000
12101 stop $SINGLEMDS || error "Fail to stop MDT."
12103 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12105 df $MOUNT || error "Fail to df."
12106 # Create new files, idle OI blocks should be reused.
12107 createmany -o $myDIR/t- 2000
12108 do_facet $SINGLEMDS sync
12109 # Make sure journal flushed.
12111 local blk2=$(do_facet $SINGLEMDS \
12112 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12113 grep Blockcount | awk '{print $4}')
12115 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12117 run_test 228b "idle OI blocks can be reused after MDT restart"
12121 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12122 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12123 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12124 skip "non-ldiskfs backend" && return
12126 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12127 local myDIR=$DIR/$tdir
12130 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12131 $LCTL set_param fail_loc=0x80001002
12132 # 20000 files can guarantee there are index nodes in the OI file
12133 createmany -o $myDIR/t- 20000
12134 $LCTL set_param fail_loc=0
12135 # The guard is current the largest FID holder
12137 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12139 local IDX=$(($SEQ % 64))
12141 do_facet $SINGLEMDS sync
12142 # Make sure journal flushed.
12144 local blk1=$(do_facet $SINGLEMDS \
12145 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12146 grep Blockcount | awk '{print $4}')
12148 # Remove old files, some OI blocks will become idle.
12149 unlinkmany $myDIR/t- 20000
12151 # The OI file should become empty now
12153 # Create new files, idle OI blocks should be reused.
12154 createmany -o $myDIR/t- 2000
12155 do_facet $SINGLEMDS sync
12156 # Make sure journal flushed.
12158 local blk2=$(do_facet $SINGLEMDS \
12159 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12160 grep Blockcount | awk '{print $4}')
12162 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12164 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12166 test_229() { # LU-2482, LU-3448
12167 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12168 skip "No HSM support on MDS of $(get_lustre_version)," \
12169 "need 2.4.53 at least" && return
12170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12171 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12175 # Create a file with a released layout and stripe count 2.
12176 $MULTIOP $DIR/$tfile H2c ||
12177 error "failed to create file with released layout"
12179 $GETSTRIPE -v $DIR/$tfile
12181 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12182 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12184 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12185 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12186 stat $DIR/$tfile || error "failed to stat released file"
12188 chown $RUNAS_ID $DIR/$tfile ||
12189 error "chown $RUNAS_ID $DIR/$tfile failed"
12191 chgrp $RUNAS_ID $DIR/$tfile ||
12192 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12194 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12195 rm $DIR/$tfile || error "failed to remove released file"
12197 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12204 mkdir -p $DIR/$tdir/test_230_local
12205 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12206 [ $mdt_idx -ne 0 ] &&
12207 error "create local directory on wrong MDT $mdt_idx"
12209 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12210 error "create remote directory failed"
12211 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12212 [ $mdt_idx -ne $MDTIDX ] &&
12213 error "create remote directory on wrong MDT $mdt_idx"
12215 createmany -o $DIR/$tdir/test_230/t- 10 ||
12216 error "create files on remote directory failed"
12217 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12218 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12219 rm -r $DIR/$tdir || error "unlink remote directory failed"
12221 run_test 230a "Create remote directory and files under the remote directory"
12224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12225 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12232 local migrate_dir=$DIR/$tdir/migrate_dir
12233 local other_dir=$DIR/$tdir/other_dir
12235 mkdir -p $migrate_dir
12236 mkdir -p $other_dir
12237 for ((i=0; i<10; i++)); do
12238 mkdir -p $migrate_dir/dir_${i}
12239 createmany -o $migrate_dir/dir_${i}/f 10 ||
12240 error "create files under remote dir failed $i"
12243 cp /etc/passwd $migrate_dir/$tfile
12244 cp /etc/passwd $other_dir/$tfile
12245 chattr +SAD $migrate_dir
12246 chattr +SAD $migrate_dir/$tfile
12248 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12249 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12250 local old_dir_mode=$(stat -c%f $migrate_dir)
12251 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12253 mkdir -p $migrate_dir/dir_default_stripe2
12254 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12255 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12257 mkdir -p $other_dir
12258 ln $migrate_dir/$tfile $other_dir/luna
12259 ln $migrate_dir/$tfile $migrate_dir/sofia
12260 ln $other_dir/$tfile $migrate_dir/david
12261 ln -s $migrate_dir/$tfile $other_dir/zachary
12262 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12263 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12265 $LFS mv -v -M $MDTIDX $migrate_dir ||
12266 error "migrate remote dir error"
12268 echo "migratate to MDT1, then checking.."
12269 for ((i=0; i<10; i++)); do
12270 for file in $(find $migrate_dir/dir_${i}); do
12271 mdt_index=$($LFS getstripe -M $file)
12272 [ $mdt_index == $MDTIDX ] ||
12273 error "$file is not on MDT${MDTIDX}"
12277 # the multiple link file should still in MDT0
12278 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12279 [ $mdt_index == 0 ] ||
12280 error "$file is not on MDT${MDTIDX}"
12282 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12283 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12284 error " expect $old_dir_flag get $new_dir_flag"
12286 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12287 [ "$old_file_flag" = "$new_file_flag" ] ||
12288 error " expect $old_file_flag get $new_file_flag"
12290 local new_dir_mode=$(stat -c%f $migrate_dir)
12291 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12292 error "expect mode $old_dir_mode get $new_dir_mode"
12294 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12295 [ "$old_file_mode" = "$new_file_mode" ] ||
12296 error "expect mode $old_file_mode get $new_file_mode"
12298 diff /etc/passwd $migrate_dir/$tfile ||
12299 error "$tfile different after migration"
12301 diff /etc/passwd $other_dir/luna ||
12302 error "luna different after migration"
12304 diff /etc/passwd $migrate_dir/sofia ||
12305 error "sofia different after migration"
12307 diff /etc/passwd $migrate_dir/david ||
12308 error "david different after migration"
12310 diff /etc/passwd $other_dir/zachary ||
12311 error "zachary different after migration"
12313 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12314 error "${tfile}_ln different after migration"
12316 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12317 error "${tfile}_ln_other different after migration"
12319 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12320 [ $stripe_count = 2 ] ||
12321 error "dir strpe_count $d != 2 after migration."
12323 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12324 [ $stripe_count = 2 ] ||
12325 error "file strpe_count $d != 2 after migration."
12327 #migrate back to MDT0
12329 $LFS mv -v -M $MDTIDX $migrate_dir ||
12330 error "migrate remote dir error"
12332 echo "migrate back to MDT0, checking.."
12333 for file in $(find $migrate_dir); do
12334 mdt_index=$($LFS getstripe -M $file)
12335 [ $mdt_index == $MDTIDX ] ||
12336 error "$file is not on MDT${MDTIDX}"
12339 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12340 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12341 error " expect $old_dir_flag get $new_dir_flag"
12343 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12344 [ "$old_file_flag" = "$new_file_flag" ] ||
12345 error " expect $old_file_flag get $new_file_flag"
12347 local new_dir_mode=$(stat -c%f $migrate_dir)
12348 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12349 error "expect mode $old_dir_mode get $new_dir_mode"
12351 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12352 [ "$old_file_mode" = "$new_file_mode" ] ||
12353 error "expect mode $old_file_mode get $new_file_mode"
12355 diff /etc/passwd ${migrate_dir}/$tfile ||
12356 error "$tfile different after migration"
12358 diff /etc/passwd ${other_dir}/luna ||
12359 error "luna different after migration"
12361 diff /etc/passwd ${migrate_dir}/sofia ||
12362 error "sofia different after migration"
12364 diff /etc/passwd ${other_dir}/zachary ||
12365 error "zachary different after migration"
12367 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12368 error "${tfile}_ln different after migration"
12370 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12371 error "${tfile}_ln_other different after migration"
12373 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12374 [ $stripe_count = 2 ] ||
12375 error "dir strpe_count $d != 2 after migration."
12377 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12378 [ $stripe_count = 2 ] ||
12379 error "file strpe_count $d != 2 after migration."
12381 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12383 run_test 230b "migrate directory"
12386 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12387 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12392 #If migrating directory fails in the middle, all entries of
12393 #the directory is still accessiable.
12394 mkdir -p $DIR/$tdir
12396 createmany -o $DIR/$tdir/f 10 ||
12397 error "create files under ${tdir} failed"
12399 #failed after migrating 5 entries
12400 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12401 do_facet mds1 lctl set_param fail_loc=0x20001801
12402 do_facet mds1 lctl set_param fail_val=5
12403 local t=`ls $DIR/$tdir | wc -l`
12404 $LFS mv -M $MDTIDX $DIR/$tdir &&
12405 error "migrate should failed after 5 entries"
12406 local u=`ls $DIR/$tdir | wc -l`
12407 [ "$u" == "$t" ] || error "$u != $t during migration"
12409 for file in $(find $DIR/$tdir); do
12410 stat $file || error "stat $file failed"
12413 do_facet mds1 lctl set_param fail_loc=0
12414 do_facet mds1 lctl set_param fail_val=0
12416 $LFS mv -M $MDTIDX $DIR/$tdir ||
12417 error "migrate open files should failed with open files"
12419 echo "Finish migration, then checking.."
12420 for file in $(find $DIR/$tdir); do
12421 mdt_index=$($LFS getstripe -M $file)
12422 [ $mdt_index == $MDTIDX ] ||
12423 error "$file is not on MDT${MDTIDX}"
12426 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12428 run_test 230c "check directory accessiblity if migration is failed"
12431 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12432 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12438 mkdir -p $DIR/$tdir
12440 for ((i=0; i<100; i++)); do
12441 mkdir -p $DIR/$tdir/dir_${i}
12442 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12443 error "create files under remote dir failed $i"
12446 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12448 echo "Finish migration, then checking.."
12449 for file in $(find $DIR/$tdir); do
12450 mdt_index=$($LFS getstripe -M $file)
12451 [ $mdt_index == $MDTIDX ] ||
12452 error "$file is not on MDT${MDTIDX}"
12455 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12457 run_test 230d "check migrate big directory"
12461 # For simplicity this test assumes that max_pages_per_rpc
12462 # is the same across all OSCs
12463 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12464 local bulk_size=$((max_pages * 4096))
12466 mkdir -p $DIR/$tdir
12468 # clear the OSC stats
12469 $LCTL set_param osc.*.stats=0 &>/dev/null
12471 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12472 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12473 oflag=direct &>/dev/null || error "dd failed"
12475 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12476 if [ x$nrpcs != "x1" ]; then
12477 error "found $nrpc ost_write RPCs, not 1 as expected"
12480 # Drop the OSC cache, otherwise we will read from it
12481 cancel_lru_locks osc
12483 # clear the OSC stats
12484 $LCTL set_param osc.*.stats=0 &>/dev/null
12486 # Client reads $bulk_size.
12487 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12488 iflag=direct &>/dev/null || error "dd failed"
12490 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12491 if [ x$nrpcs != "x1" ]; then
12492 error "found $nrpc ost_read RPCs, not 1 as expected"
12495 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12498 mkdir -p $DIR/$tdir
12500 for i in {0..1023}; do
12501 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12502 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12503 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12507 run_test 231b "must not assert on fully utilized OST request buffer"
12510 mkdir -p $DIR/$tdir
12511 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12512 $LCTL set_param fail_loc=0x31c
12514 # ignore dd failure
12515 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12517 $LCTL set_param fail_loc=0
12518 umount_client $MOUNT || error "umount failed"
12519 mount_client $MOUNT || error "mount failed"
12521 run_test 232 "failed lock should not block umount"
12524 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12525 { skip "Need MDS version at least 2.3.64"; return; }
12527 local fid=$($LFS path2fid $MOUNT)
12528 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12529 error "cannot access $MOUNT using its FID '$fid'"
12531 run_test 233a "checking that OBF of the FS root succeeds"
12534 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12535 { skip "Need MDS version at least 2.5.90"; return; }
12537 local fid=$($LFS path2fid $MOUNT/.lustre)
12538 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12539 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12541 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12542 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12543 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12545 run_test 233b "checking that OBF of the FS .lustre succeeds"
12548 local p="$TMP/sanityN-$TESTNAME.parameters"
12549 save_lustre_params client "llite.*.xattr_cache" > $p
12550 lctl set_param llite.*.xattr_cache 1 ||
12551 { skip "xattr cache is not supported"; return 0; }
12553 mkdir -p $DIR/$tdir || error "mkdir failed"
12554 touch $DIR/$tdir/$tfile || error "touch failed"
12555 # OBD_FAIL_LLITE_XATTR_ENOMEM
12556 $LCTL set_param fail_loc=0x1405
12557 # output of the form: attr 2 4 44 3 fc13 x86_64
12558 V=($(IFS=".-" rpm -q attr))
12559 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12560 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12561 # attr pre-2.4.44-7 had a bug with rc
12562 # LU-3703 - SLES 11 and FC13 clients have older attr
12563 getfattr -n user.attr $DIR/$tdir/$tfile &&
12564 error "getfattr should have failed with ENOMEM"
12566 skip "LU-3703: attr version $(getfattr --version) too old"
12568 $LCTL set_param fail_loc=0x0
12571 restore_lustre_params < $p
12574 run_test 234 "xattr cache should not crash on ENOMEM"
12577 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12578 skip "Need MDS version at least 2.4.52" && return
12579 flock_deadlock $DIR/$tfile
12584 124) error "process hangs on a deadlock"
12586 *) error "error executing flock_deadlock $DIR/$tfile"
12590 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12594 check_swap_layouts_support && return 0
12595 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12597 local ref1=/etc/passwd
12598 local ref2=/etc/group
12599 local file1=$DIR/$tdir/f1
12600 local file2=$DIR/$tdir/f2
12602 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12603 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12604 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12605 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12606 local fd=$(free_fd)
12607 local cmd="exec $fd<>$file2"
12610 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12611 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12614 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12619 run_test 236 "Layout swap on open unlinked file"
12621 # test to verify file handle related system calls
12622 # (name_to_handle_at/open_by_handle_at)
12623 # The new system calls are supported in glibc >= 2.14.
12626 echo "Test file_handle syscalls" > $DIR/$tfile ||
12627 error "write failed"
12628 check_fhandle_syscalls $DIR/$tfile ||
12629 error "check_fhandle_syscalls failed"
12631 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12633 # LU-4659 linkea consistency
12635 local server_version=$(lustre_version_code $SINGLEMDS)
12637 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12638 [[ $server_version -gt $(version_code 2.5.1) &&
12639 $server_version -lt $(version_code 2.5.50) ]] ||
12640 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12643 ln $DIR/$tfile $DIR/$tfile.lnk
12644 touch $DIR/$tfile.new
12645 mv $DIR/$tfile.new $DIR/$tfile
12646 local fid1=$(lfs path2fid $DIR/$tfile)
12647 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12648 local path1=$(lfs fid2path $FSNAME $fid1)
12649 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12650 local path2=$(lfs fid2path $FSNAME $fid2)
12651 [ $tfile.lnk == $path2 ] ||
12652 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12655 run_test 238 "Verify linkea consistency"
12658 local list=$(comma_list $(mdts_nodes))
12660 mkdir -p $DIR/$tdir
12661 createmany -o $DIR/$tdir/f- 5000
12662 unlinkmany $DIR/$tdir/f- 5000
12663 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12664 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12665 osc.*MDT*.sync_in_flight" | calc_sum)
12666 [ "$changes" -eq 0 ] || error "$changes not synced"
12668 run_test 239 "osp_sync test"
12671 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12673 mkdir -p $DIR/$tdir
12675 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12676 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12677 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12678 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12680 umount_client $MOUNT || error "umount failed"
12681 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12682 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12683 mount_client $MOUNT || error "failed to mount client"
12685 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12686 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12688 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12691 for LOOP in $(seq $1); do
12692 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12693 cancel_lru_locks osc
12698 for LOOP in $(seq $1); do
12699 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12700 iflag=direct 2>/dev/null
12705 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12707 cancel_lru_locks osc
12708 test_241_bio 1000 &
12713 run_test 241 "bio vs dio"
12715 cleanup_test_300() {
12719 test_striped_dir() {
12724 mkdir -p $DIR/$tdir
12726 SAVE_UMASK=$(umask)
12727 trap cleanup_test_300 RETURN EXIT
12729 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12730 $DIR/$tdir/striped_dir ||
12731 error "set striped dir error"
12733 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12734 [ "$mode" = "755" ] || error "expect 755 got $mode"
12736 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12737 if [ "$stripe_count" != "2" ]; then
12738 error "stripe_count is $stripe_count, expect 2"
12741 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12742 if [ "$stripe_index" != "$mdt_index" ]; then
12743 error "stripe_index is $stripe_index, expect $mdt_index"
12746 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12747 error "nlink error after create striped dir"
12749 mkdir $DIR/$tdir/striped_dir/a
12750 mkdir $DIR/$tdir/striped_dir/b
12752 stat $DIR/$tdir/striped_dir/a ||
12753 error "create dir under striped dir failed"
12754 stat $DIR/$tdir/striped_dir/b ||
12755 error "create dir under striped dir failed"
12757 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12758 error "nlink error after mkdir"
12760 rmdir $DIR/$tdir/striped_dir/a
12761 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12762 error "nlink error after rmdir"
12764 rmdir $DIR/$tdir/striped_dir/b
12765 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12766 error "nlink error after rmdir"
12768 rmdir $DIR/$tdir/striped_dir ||
12769 error "rmdir striped dir error"
12777 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12778 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12780 test_striped_dir 0 || error "failed on striped dir on MDT0"
12781 test_striped_dir 1 || error "failed on striped dir on MDT0"
12783 run_test 300a "basic striped dir sanity test"
12786 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12787 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12793 test_mkdir $DIR/$tdir || error "mkdir fail"
12794 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12795 error "set striped dir error"
12796 for ((i=0; i<10; i++)); do
12797 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12799 touch $DIR/$tdir/striped_dir/file_$i ||
12800 error "touch error $i"
12801 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12802 [ $mtime1 -eq $mtime2 ] &&
12803 error "mtime not change after create"
12805 rm -f $DIR/$tdir/striped_dir/file_$i ||
12806 error "unlink error $i"
12807 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12808 [ $mtime2 -eq $mtime3 ] &&
12809 error "mtime did not change after unlink"
12813 run_test 300b "check ctime/mtime for striped dir"
12816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12817 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12820 mkdir -p $DIR/$tdir
12821 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12822 error "set striped dir error"
12824 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12825 error "chown striped dir failed"
12827 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12828 error "create 5k files failed"
12830 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12832 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12836 run_test 300c "chown && check ls under striped directory"
12839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12840 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12844 mkdir -p $DIR/$tdir
12845 $SETSTRIPE -c 2 $DIR/$tdir
12847 #local striped directory
12848 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12849 error "set striped dir error"
12850 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12851 error "create 10 files failed"
12853 #remote striped directory
12854 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12855 error "set striped dir error"
12856 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12857 error "create 10 files failed"
12859 for file in $(find $DIR/$tdir); do
12860 stripe_count=$($GETSTRIPE -c $file)
12861 [ $stripe_count -eq 2 ] ||
12862 error "wrong stripe $stripe_count for $file"
12867 run_test 300d "check default stripe under striped directory"
12870 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12871 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12875 mkdir -p $DIR/$tdir
12877 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12878 error "set striped dir error"
12880 touch $DIR/$tdir/striped_dir/a
12881 touch $DIR/$tdir/striped_dir/b
12882 touch $DIR/$tdir/striped_dir/c
12884 mkdir $DIR/$tdir/striped_dir/dir_a
12885 mkdir $DIR/$tdir/striped_dir/dir_b
12886 mkdir $DIR/$tdir/striped_dir/dir_c
12888 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12889 error "set striped dir under striped dir error"
12891 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12892 error "set striped dir under striped dir error"
12894 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12895 error "set striped dir under striped dir error"
12897 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12898 error "rename file under striped dir should fail"
12900 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12901 error "rename dir under striped dir should fail"
12903 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12904 error "rename dir under different stripes should fail"
12906 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12907 error "rename file under striped dir should succeed"
12909 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12910 error "rename dir under striped dir should succeed"
12914 run_test 300e "check rename under striped directory"
12917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12918 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12923 mkdir -p $DIR/$tdir
12925 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12926 error "set striped dir error"
12928 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12929 error "set striped dir error"
12931 touch $DIR/$tdir/striped_dir/a
12932 mkdir $DIR/$tdir/striped_dir/dir_a
12933 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12934 error "create striped dir under striped dir fails"
12936 touch $DIR/$tdir/striped_dir1/b
12937 mkdir $DIR/$tdir/striped_dir1/dir_b
12938 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12939 error "create striped dir under striped dir fails"
12941 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12942 error "rename file under different striped dir should fail"
12944 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12945 error "rename dir under different striped dir should fail"
12947 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12948 error "rename striped dir under diff striped dir should fail"
12950 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12951 error "rename file under diff striped dirs fails"
12953 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12954 error "rename dir under diff striped dirs fails"
12958 run_test 300f "check rename cross striped directory"
12961 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12966 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12967 $DIR/$tdir/striped_dir ||
12968 error "set striped dir error"
12970 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12971 error "set default stripe on striped dir error"
12973 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
12974 [ $stripe_count -eq $MDSCOUNT ] ||
12975 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
12977 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12979 for dir in $(find $DIR/$tdir/striped_dir/*); do
12980 stripe_count=$($LFS getdirstripe -c $dir)
12981 [ $stripe_count -eq $MDSCOUNT ] ||
12982 error "expect $MDSCOUNT get $stripe_count for $dir"
12985 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12986 #change default stripe count to 2
12987 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12988 error "set default stripe on striped dir error"
12990 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12992 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12994 #change default stripe count to 1
12995 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12996 error "set default stripe on striped dir error"
12998 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12999 for dir in $(find $DIR/$tdir/striped_dir/*); do
13000 stripe_count=$($LFS getdirstripe -c $dir)
13001 [ $stripe_count -eq 1 ] ||
13002 error "expect 1 get $stripe_count for $dir"
13004 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
13006 run_test 300g "check default striped directory for striped directory"
13009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13010 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13016 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13017 error "set striped dir error"
13019 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13020 error "create files under striped dir failed"
13022 # unfortunately, we need to umount to clear dir layout cache for now
13023 # once we fully implement dir layout, we can drop this
13024 umount_client $MOUNT || error "umount failed"
13025 mount_client $MOUNT || error "mount failed"
13027 #set the stripe to be unknown hash type
13028 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13029 $LCTL set_param fail_loc=0x1901
13030 for ((i = 0; i < 10; i++)); do
13031 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13032 error "stat f-$i failed"
13033 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13036 touch $DIR/$tdir/striped_dir/f0 &&
13037 error "create under striped dir with unknown hash should fail"
13039 $LCTL set_param fail_loc=0
13041 umount_client $MOUNT || error "umount failed"
13042 mount_client $MOUNT || error "mount failed"
13046 run_test 300h "client handle unknown hash type striped directory"
13048 test_400a() { # LU-1606, was conf-sanity test_74
13049 local extra_flags=''
13050 local out=$TMP/$tfile
13051 local prefix=/usr/include/lustre
13054 if ! which $CC > /dev/null 2>&1; then
13055 skip_env "$CC is not installed"
13059 if ! [[ -d $prefix ]]; then
13060 # Assume we're running in tree and fixup the include path.
13061 extra_flags+=" -I$LUSTRE/../libcfs/include"
13062 extra_flags+=" -I$LUSTRE/include"
13063 extra_flags+=" -L$LUSTRE/utils"
13066 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13067 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13068 error "client api broken"
13071 run_test 400a "Lustre client api program can compile and link"
13073 test_400b() { # LU-1606, LU-5011
13075 local out=$TMP/$tfile
13076 local prefix=/usr/include/lustre
13078 # We use a hard coded prefix so that this test will not fail
13079 # when run in tree. There are headers in lustre/include/lustre/
13080 # that are not packaged (like lustre_idl.h) and have more
13081 # complicated include dependencies (like config.h and lnet/types.h).
13082 # Since this test about correct packaging we just skip them when
13083 # they don't exist (see below) rather than try to fixup cppflags.
13085 if ! which $CC > /dev/null 2>&1; then
13086 skip_env "$CC is not installed"
13090 for header in $prefix/*.h; do
13091 if ! [[ -f "$header" ]]; then
13095 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13096 continue # liblustreapi.h is deprecated.
13099 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13100 error "cannot compile '$header'"
13103 run_test 400b "packaged headers can be compiled"
13106 # tests that do cleanup/setup should be run at the end
13110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13112 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13113 $LCTL set_param fail_loc=0x903
13115 cancel_lru_locks MGC
13117 FAIL_ON_ERROR=true cleanup
13118 FAIL_ON_ERROR=true setup
13120 run_test 900 "umount should not race with any mgc requeue thread"
13123 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13124 check_and_cleanup_lustre
13125 if [ "$I_MOUNTED" != "yes" ]; then
13126 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true