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 declare -a identity_old
6862 for num in $(seq $MDSCOUNT); do
6863 switch_identity $num true || identity_old[$num]=$?
6870 echo "performing cp ..."
6871 run_acl_subtest cp || error "run_acl_subtest cp failed"
6872 echo "performing getfacl-noacl..."
6873 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6874 echo "performing misc..."
6875 run_acl_subtest misc || error "misc test failed"
6876 echo "performing permissions..."
6877 run_acl_subtest permissions || error "permissions failed"
6878 echo "performing setfacl..."
6879 run_acl_subtest setfacl || error "setfacl test failed"
6881 # inheritance test got from HP
6882 echo "performing inheritance..."
6883 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6884 chmod +x make-tree || error "chmod +x failed"
6885 run_acl_subtest inheritance || error "inheritance test failed"
6888 echo "LU-974 ignore umask when acl is enabled..."
6889 run_acl_subtest 974 || error "LU-974 umask test failed"
6890 if [ $MDSCOUNT -ge 2 ]; then
6891 run_acl_subtest 974_remote ||
6892 error "LU-974 umask test failed under remote dir"
6895 echo "LU-2561 newly created file is same size as directory..."
6896 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6897 run_acl_subtest 2561 || error "LU-2561 test failed"
6899 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6902 run_acl_subtest 4924 || error "LU-4924 test failed"
6907 for num in $(seq $MDSCOUNT); do
6908 if [ "${identity_old[$num]}" = 1 ]; then
6909 switch_identity $num false || identity_old[$num]=$?
6913 run_test 103a "acl test ========================================="
6917 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
6918 local mountopts=$MDS_MOUNT_OPTS
6920 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
6924 stop $SINGLEMDS || error "failed to stop MDT."
6926 if [ -z "$MDS_MOUNT_OPTS" ]; then
6927 MDS_MOUNT_OPTS="-o noacl"
6929 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
6931 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6932 error "failed to start MDT."
6933 MDS_MOUNT_OPTS=$mountopts
6937 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
6941 stop $SINGLEMDS || error "failed to stop MDT."
6943 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6944 error "failed to start MDT."
6949 run_test 103b "MDS mount option 'noacl'"
6953 cp -rp $DIR/$tdir $DIR/$tdir.bak
6955 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
6956 error "$DIR/$tdir shouldn't contain default ACL"
6957 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
6958 error "$DIR/$tdir.bak shouldn't contain default ACL"
6961 run_test 103c "'cp -rp' won't set empty acl"
6964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6966 lfs df || error "lfs df failed"
6967 lfs df -ih || error "lfs df -ih failed"
6968 lfs df -h $DIR || error "lfs df -h $DIR failed"
6969 lfs df -i $DIR || error "lfs df -i $DIR failed"
6970 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6971 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6973 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6974 lctl --device %$OSC deactivate
6975 lfs df || error "lfs df with deactivated OSC failed"
6976 lctl --device %$OSC activate
6977 # wait the osc back to normal
6978 wait_osc_import_state client ost FULL
6980 lfs df || error "lfs df with reactivated OSC failed"
6983 run_test 104a "lfs df [-ih] [path] test ========================="
6986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6987 [ $RUNAS_ID -eq $UID ] &&
6988 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6990 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6991 grep "Permission denied" | wc -l)))
6992 if [ $denied_cnt -ne 0 ]; then
6993 error "lfs check servers test failed"
6996 run_test 104b "$RUNAS lfs check servers test ===================="
6999 # doesn't work on 2.4 kernels
7001 if $(flock_is_enabled); then
7002 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7004 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7008 run_test 105a "flock when mounted without -o flock test ========"
7012 if $(flock_is_enabled); then
7013 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7015 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7019 run_test 105b "fcntl when mounted without -o flock test ========"
7023 if $(flock_is_enabled); then
7024 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7026 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7030 run_test 105c "lockf when mounted without -o flock test ========"
7032 test_105d() { # bug 15924
7033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7034 test_mkdir -p $DIR/$tdir
7035 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7036 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7037 $LCTL set_param fail_loc=0x80000315
7038 flocks_test 2 $DIR/$tdir
7040 run_test 105d "flock race (should not freeze) ========"
7042 test_105e() { # bug 22660 && 22040
7043 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7045 flocks_test 3 $DIR/$tfile
7047 run_test 105e "Two conflicting flocks from same process ======="
7049 test_106() { #bug 10921
7050 test_mkdir -p $DIR/$tdir
7051 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7052 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7054 run_test 106 "attempt exec of dir followed by chown of that dir"
7057 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7064 local save_pattern=$(sysctl -n kernel.core_pattern)
7065 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7066 sysctl -w kernel.core_pattern=$file
7067 sysctl -w kernel.core_uses_pid=0
7075 kill -s 11 $SLEEPPID
7077 if [ -e $file ]; then
7078 size=`stat -c%s $file`
7079 [ $size -eq 0 ] && error "Fail to create core file $file"
7081 error "Fail to create core file $file"
7084 sysctl -w kernel.core_pattern=$save_pattern
7085 sysctl -w kernel.core_uses_pid=$save_uses_pid
7088 run_test 107 "Coredump on SIG"
7091 test_mkdir -p $DIR/$tdir
7092 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7093 error "mkdir with 255 char failed"
7094 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7095 error "mkdir with 256 char should fail, but did not"
7096 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7097 error "create with 255 char failed"
7098 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7099 error "create with 256 char should fail, but did not"
7104 run_test 110 "filename length checking"
7107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7108 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7109 tail -1 | cut -c11-20)
7110 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7111 echo "Starting with $OSTIO_pre threads"
7114 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7115 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7116 echo "$NUMTEST creates/unlinks"
7117 test_mkdir -p $DIR/$tdir
7118 createmany -o $DIR/$tdir/$tfile $NUMTEST
7119 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7121 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7122 tail -1 | cut -c11-20)
7124 # don't return an error
7125 [ $OSTIO_post == $OSTIO_pre ] && echo \
7126 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7127 echo "This may be fine, depending on what ran before this test" &&
7128 echo "and how fast this system is." && return
7130 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7132 run_test 115 "verify dynamic thread creation===================="
7135 wait_delete_completed
7136 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7137 echo OST kbytes available: ${AVAIL[@]}
7138 MAXI=0; MAXV=${AVAIL[0]}
7139 MINI=0; MINV=${AVAIL[0]}
7140 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7141 #echo OST $i: ${AVAIL[i]}kb
7142 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7143 MAXV=${AVAIL[i]}; MAXI=$i
7145 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7146 MINV=${AVAIL[i]}; MINI=$i
7149 echo Min free space: OST $MINI: $MINV
7150 echo Max free space: OST $MAXI: $MAXV
7153 test_116a() { # was previously test_116()
7154 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7155 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7157 echo -n "Free space priority "
7158 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7163 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7164 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7166 trap simple_cleanup_common EXIT
7169 # Check if we need to generate uneven OSTs
7170 test_mkdir -p $DIR/$tdir/OST${MINI}
7171 local FILL=$(($MINV / 4))
7172 local DIFF=$(($MAXV - $MINV))
7173 local DIFF2=$(($DIFF * 100 / $MINV))
7175 local threshold=$(do_facet $SINGLEMDS \
7176 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7177 threshold=${threshold%%%}
7178 echo -n "Check for uneven OSTs: "
7179 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7181 if [[ $DIFF2 -gt $threshold ]]; then
7183 echo "Don't need to fill OST$MINI"
7185 # generate uneven OSTs. Write 2% over the QOS threshold value
7187 DIFF=$(($threshold - $DIFF2 + 2))
7188 DIFF2=$(( ($MINV * $DIFF)/100 ))
7189 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7190 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7191 error "setstripe failed"
7192 DIFF=$(($DIFF2 / 2048))
7194 while [ $i -lt $DIFF ]; do
7196 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7197 bs=2M count=1 2>/dev/null
7206 DIFF=$(($MAXV - $MINV))
7207 DIFF2=$(($DIFF * 100 / $MINV))
7208 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7209 if [[ $DIFF2 -gt $threshold ]]; then
7212 echo "failed - QOS mode won't be used"
7213 skip "QOS imbalance criteria not met"
7214 simple_cleanup_common
7218 MINI1=$MINI; MINV1=$MINV
7219 MAXI1=$MAXI; MAXV1=$MAXV
7221 # now fill using QOS
7222 $SETSTRIPE -c 1 $DIR/$tdir
7223 FILL=$(($FILL / 200))
7224 if [ $FILL -gt 600 ]; then
7227 echo "writing $FILL files to QOS-assigned OSTs"
7229 while [ $i -lt $FILL ]; do
7231 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7235 echo "wrote $i 200k files"
7239 echo "Note: free space may not be updated, so measurements might be off"
7241 DIFF2=$(($MAXV - $MINV))
7242 echo "free space delta: orig $DIFF final $DIFF2"
7243 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7244 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7245 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7246 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7247 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7248 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7250 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7252 # Figure out which files were written where
7253 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7254 awk '/'$MINI1': / {print $2; exit}')
7256 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7257 echo "$MINC files created on smaller OST $MINI1"
7258 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7259 awk '/'$MAXI1': / {print $2; exit}')
7261 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7262 echo "$MAXC files created on larger OST $MAXI1"
7263 FILL=$(($MAXC * 100 / $MINC - 100))
7264 [[ $MINC -gt 0 ]] &&
7265 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7266 [[ $MAXC -gt $MINC ]] ||
7267 error_ignore LU-9 "stripe QOS didn't balance free space"
7268 simple_cleanup_common
7270 run_test 116a "stripe QOS: free space balance ==================="
7272 test_116b() { # LU-2093
7273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7274 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7275 head -1 2>/dev/null)" ] && skip "no QOS" && return
7276 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7278 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7279 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7280 do_facet $SINGLEMDS lctl set_param \
7281 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7283 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7284 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7285 do_facet $SINGLEMDS lctl set_param fail_loc=0
7287 do_facet $SINGLEMDS lctl set_param \
7288 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7290 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7292 test_117() # bug 10891
7294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7295 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7296 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7297 lctl set_param fail_loc=0x21e
7298 > $DIR/$tfile || error "truncate failed"
7299 lctl set_param fail_loc=0
7300 echo "Truncate succeeded."
7303 run_test 117 "verify osd extend =========="
7305 NO_SLOW_RESENDCOUNT=4
7306 export OLD_RESENDCOUNT=""
7307 set_resend_count () {
7308 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7309 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7310 lctl set_param -n $PROC_RESENDCOUNT $1
7311 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7314 # for reduce test_118* time (b=14842)
7315 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7317 # Reset async IO behavior after error case
7319 FILE=$DIR/reset_async
7321 # Ensure all OSCs are cleared
7322 $SETSTRIPE -c -1 $FILE
7323 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7328 test_118a() #bug 11710
7330 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7333 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7334 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7335 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7337 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7338 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7343 run_test 118a "verify O_SYNC works =========="
7347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7348 remote_ost_nodsh && skip "remote OST with nodsh" && return
7352 #define OBD_FAIL_OST_ENOENT 0x217
7353 set_nodes_failloc "$(osts_nodes)" 0x217
7354 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7356 set_nodes_failloc "$(osts_nodes)" 0
7357 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7358 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7361 if [[ $RC -eq 0 ]]; then
7362 error "Must return error due to dropped pages, rc=$RC"
7366 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7367 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7371 echo "Dirty pages not leaked on ENOENT"
7373 # Due to the above error the OSC will issue all RPCs syncronously
7374 # until a subsequent RPC completes successfully without error.
7375 $MULTIOP $DIR/$tfile Ow4096yc
7380 run_test 118b "Reclaim dirty pages on fatal error =========="
7384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7386 # for 118c, restore the original resend count, LU-1940
7387 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7388 set_resend_count $OLD_RESENDCOUNT
7389 remote_ost_nodsh && skip "remote OST with nodsh" && return
7393 #define OBD_FAIL_OST_EROFS 0x216
7394 set_nodes_failloc "$(osts_nodes)" 0x216
7396 # multiop should block due to fsync until pages are written
7397 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7401 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7402 error "Multiop failed to block on fsync, pid=$MULTIPID"
7405 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7407 if [[ $WRITEBACK -eq 0 ]]; then
7408 error "No page in writeback, writeback=$WRITEBACK"
7411 set_nodes_failloc "$(osts_nodes)" 0
7414 if [[ $RC -ne 0 ]]; then
7415 error "Multiop fsync failed, rc=$RC"
7418 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7419 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7421 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7422 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7426 echo "Dirty pages flushed via fsync on EROFS"
7429 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7431 # continue to use small resend count to reduce test_118* time (b=14842)
7432 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7437 remote_ost_nodsh && skip "remote OST with nodsh" && return
7441 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7442 set_nodes_failloc "$(osts_nodes)" 0x214
7443 # multiop should block due to fsync until pages are written
7444 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7448 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7449 error "Multiop failed to block on fsync, pid=$MULTIPID"
7452 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7454 if [[ $WRITEBACK -eq 0 ]]; then
7455 error "No page in writeback, writeback=$WRITEBACK"
7458 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7459 set_nodes_failloc "$(osts_nodes)" 0
7461 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7462 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7464 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7465 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7469 echo "Dirty pages gaurenteed flushed via fsync"
7472 run_test 118d "Fsync validation inject a delay of the bulk =========="
7475 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7478 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7479 lctl set_param fail_loc=0x8000040a
7481 # Should simulate EINVAL error which is fatal
7482 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7484 if [[ $RC -eq 0 ]]; then
7485 error "Must return error due to dropped pages, rc=$RC"
7488 lctl set_param fail_loc=0x0
7490 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7491 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7492 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7494 if [[ $LOCKED -ne 0 ]]; then
7495 error "Locked pages remain in cache, locked=$LOCKED"
7498 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7499 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7503 echo "No pages locked after fsync"
7508 run_test 118f "Simulate unrecoverable OSC side error =========="
7511 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7514 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7515 lctl set_param fail_loc=0x406
7517 # simulate local -ENOMEM
7518 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7521 lctl set_param fail_loc=0
7522 if [[ $RC -eq 0 ]]; then
7523 error "Must return error due to dropped pages, rc=$RC"
7526 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7527 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7528 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7530 if [[ $LOCKED -ne 0 ]]; then
7531 error "Locked pages remain in cache, locked=$LOCKED"
7534 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7535 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7539 echo "No pages locked after fsync"
7544 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7547 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7548 remote_ost_nodsh && skip "remote OST with nodsh" && return
7552 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7553 set_nodes_failloc "$(osts_nodes)" 0x20e
7554 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7555 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7558 set_nodes_failloc "$(osts_nodes)" 0
7559 if [[ $RC -eq 0 ]]; then
7560 error "Must return error due to dropped pages, rc=$RC"
7563 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7564 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7565 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7567 if [[ $LOCKED -ne 0 ]]; then
7568 error "Locked pages remain in cache, locked=$LOCKED"
7571 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7572 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7576 echo "No pages locked after fsync"
7580 run_test 118h "Verify timeout in handling recoverables errors =========="
7582 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7586 remote_ost_nodsh && skip "remote OST with nodsh" && return
7590 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7591 set_nodes_failloc "$(osts_nodes)" 0x20e
7593 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7594 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7597 set_nodes_failloc "$(osts_nodes)" 0
7601 if [[ $RC -ne 0 ]]; then
7602 error "got error, but should be not, rc=$RC"
7605 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7606 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7607 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7608 if [[ $LOCKED -ne 0 ]]; then
7609 error "Locked pages remain in cache, locked=$LOCKED"
7612 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7613 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7617 echo "No pages locked after fsync"
7621 run_test 118i "Fix error before timeout in recoverable error =========="
7623 [ "$SLOW" = "no" ] && set_resend_count 4
7626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7627 remote_ost_nodsh && skip "remote OST with nodsh" && return
7631 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7632 set_nodes_failloc "$(osts_nodes)" 0x220
7634 # return -EIO from OST
7635 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7637 set_nodes_failloc "$(osts_nodes)" 0x0
7638 if [[ $RC -eq 0 ]]; then
7639 error "Must return error due to dropped pages, rc=$RC"
7642 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7643 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7644 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7645 if [[ $LOCKED -ne 0 ]]; then
7646 error "Locked pages remain in cache, locked=$LOCKED"
7649 # in recoverable error on OST we want resend and stay until it finished
7650 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7651 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7655 echo "No pages locked after fsync"
7659 run_test 118j "Simulate unrecoverable OST side error =========="
7663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7664 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7666 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7667 set_nodes_failloc "$(osts_nodes)" 0x20e
7668 test_mkdir -p $DIR/$tdir
7670 for ((i=0;i<10;i++)); do
7671 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7672 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7679 set_nodes_failloc "$(osts_nodes)" 0
7682 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7688 test_mkdir -p $DIR/$tdir
7689 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7692 run_test 118l "fsync dir ========="
7694 test_118m() # LU-3066
7696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7697 test_mkdir -p $DIR/$tdir
7698 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7701 run_test 118m "fdatasync dir ========="
7703 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7705 test_119a() # bug 11737
7707 BSIZE=$((512 * 1024))
7708 directio write $DIR/$tfile 0 1 $BSIZE
7709 # We ask to read two blocks, which is more than a file size.
7710 # directio will indicate an error when requested and actual
7711 # sizes aren't equeal (a normal situation in this case) and
7712 # print actual read amount.
7713 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7714 if [ "$NOB" != "$BSIZE" ]; then
7715 error "read $NOB bytes instead of $BSIZE"
7719 run_test 119a "Short directIO read must return actual read amount"
7721 test_119b() # bug 11737
7723 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7725 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7726 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7728 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7729 error "direct read failed"
7732 run_test 119b "Sparse directIO read must return actual read amount"
7734 test_119c() # bug 13099
7737 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7738 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7741 run_test 119c "Testing for direct read hitting hole"
7743 test_119d() # bug 15950
7745 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7746 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7747 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7749 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7750 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7751 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7752 lctl set_param fail_loc=0x40d
7753 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7756 cat $DIR/$tfile > /dev/null &
7757 lctl set_param fail_loc=0
7760 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7762 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7763 error "the read rpcs have not completed in 2s"
7765 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7767 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7770 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7771 test_mkdir -p $DIR/$tdir
7772 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7773 skip "no early lock cancel on server" && return 0
7775 lru_resize_disable mdc
7776 lru_resize_disable osc
7777 cancel_lru_locks mdc
7778 # asynchronous object destroy at MDT could cause bl ast to client
7779 cancel_lru_locks osc
7781 stat $DIR/$tdir > /dev/null
7782 can1=$(do_facet $SINGLEMDS \
7783 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7784 awk '/ldlm_cancel/ {print $2}')
7785 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7786 awk '/ldlm_bl_callback/ {print $2}')
7787 test_mkdir -c1 $DIR/$tdir/d1
7788 can2=$(do_facet $SINGLEMDS \
7789 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7790 awk '/ldlm_cancel/ {print $2}')
7791 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7792 awk '/ldlm_bl_callback/ {print $2}')
7793 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7794 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7795 lru_resize_enable mdc
7796 lru_resize_enable osc
7798 run_test 120a "Early Lock Cancel: mkdir test"
7801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7802 test_mkdir $DIR/$tdir
7803 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7804 skip "no early lock cancel on server" && return 0
7805 lru_resize_disable mdc
7806 lru_resize_disable osc
7807 cancel_lru_locks mdc
7808 stat $DIR/$tdir > /dev/null
7809 can1=$(do_facet $SINGLEMDS \
7810 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7811 awk '/ldlm_cancel/ {print $2}')
7812 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7813 awk '/ldlm_bl_callback/ {print $2}')
7815 can2=$(do_facet $SINGLEMDS \
7816 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7817 awk '/ldlm_cancel/ {print $2}')
7818 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7819 awk '/ldlm_bl_callback/ {print $2}')
7820 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7821 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7822 lru_resize_enable mdc
7823 lru_resize_enable osc
7825 run_test 120b "Early Lock Cancel: create test"
7828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7829 test_mkdir -c1 $DIR/$tdir
7830 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7831 skip "no early lock cancel on server" && return 0
7832 lru_resize_disable mdc
7833 lru_resize_disable osc
7834 test_mkdir -p -c1 $DIR/$tdir/d1
7835 test_mkdir -p -c1 $DIR/$tdir/d2
7836 touch $DIR/$tdir/d1/f1
7837 cancel_lru_locks mdc
7838 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7839 can1=$(do_facet $SINGLEMDS \
7840 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7841 awk '/ldlm_cancel/ {print $2}')
7842 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7843 awk '/ldlm_bl_callback/ {print $2}')
7844 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7845 can2=$(do_facet $SINGLEMDS \
7846 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7847 awk '/ldlm_cancel/ {print $2}')
7848 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7849 awk '/ldlm_bl_callback/ {print $2}')
7850 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7851 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7852 lru_resize_enable mdc
7853 lru_resize_enable osc
7855 run_test 120c "Early Lock Cancel: link test"
7858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7859 test_mkdir -p -c1 $DIR/$tdir
7860 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7861 skip "no early lock cancel on server" && return 0
7862 lru_resize_disable mdc
7863 lru_resize_disable osc
7865 cancel_lru_locks mdc
7866 stat $DIR/$tdir > /dev/null
7867 can1=$(do_facet $SINGLEMDS \
7868 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7869 awk '/ldlm_cancel/ {print $2}')
7870 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7871 awk '/ldlm_bl_callback/ {print $2}')
7872 chmod a+x $DIR/$tdir
7873 can2=$(do_facet $SINGLEMDS \
7874 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7875 awk '/ldlm_cancel/ {print $2}')
7876 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7877 awk '/ldlm_bl_callback/ {print $2}')
7878 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7879 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7880 lru_resize_enable mdc
7881 lru_resize_enable osc
7883 run_test 120d "Early Lock Cancel: setattr test"
7886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7887 test_mkdir -p -c1 $DIR/$tdir
7888 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7889 skip "no early lock cancel on server" && return 0
7890 lru_resize_disable mdc
7891 lru_resize_disable osc
7892 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7893 cancel_lru_locks mdc
7894 cancel_lru_locks osc
7895 dd if=$DIR/$tdir/f1 of=/dev/null
7896 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7897 # XXX client can not do early lock cancel of OST lock
7898 # during unlink (LU-4206), so cancel osc lock now.
7899 cancel_lru_locks osc
7900 can1=$(do_facet $SINGLEMDS \
7901 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7902 awk '/ldlm_cancel/ {print $2}')
7903 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7904 awk '/ldlm_bl_callback/ {print $2}')
7905 unlink $DIR/$tdir/f1
7907 can2=$(do_facet $SINGLEMDS \
7908 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7909 awk '/ldlm_cancel/ {print $2}')
7910 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7911 awk '/ldlm_bl_callback/ {print $2}')
7912 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7913 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7914 lru_resize_enable mdc
7915 lru_resize_enable osc
7917 run_test 120e "Early Lock Cancel: unlink test"
7920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7921 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7922 skip "no early lock cancel on server" && return 0
7923 test_mkdir -p -c1 $DIR/$tdir
7924 lru_resize_disable mdc
7925 lru_resize_disable osc
7926 test_mkdir -p -c1 $DIR/$tdir/d1
7927 test_mkdir -p -c1 $DIR/$tdir/d2
7928 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7929 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7930 cancel_lru_locks mdc
7931 cancel_lru_locks osc
7932 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7933 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7934 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7935 # XXX client can not do early lock cancel of OST lock
7936 # during rename (LU-4206), so cancel osc lock now.
7937 cancel_lru_locks osc
7938 can1=$(do_facet $SINGLEMDS \
7939 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7940 awk '/ldlm_cancel/ {print $2}')
7941 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7942 awk '/ldlm_bl_callback/ {print $2}')
7943 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7945 can2=$(do_facet $SINGLEMDS \
7946 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7947 awk '/ldlm_cancel/ {print $2}')
7948 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7949 awk '/ldlm_bl_callback/ {print $2}')
7950 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7951 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7952 lru_resize_enable mdc
7953 lru_resize_enable osc
7955 run_test 120f "Early Lock Cancel: rename test"
7958 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7959 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7960 skip "no early lock cancel on server" && return 0
7961 lru_resize_disable mdc
7962 lru_resize_disable osc
7964 echo create $count files
7965 test_mkdir -p $DIR/$tdir
7966 cancel_lru_locks mdc
7967 cancel_lru_locks osc
7970 can0=$(do_facet $SINGLEMDS \
7971 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7972 awk '/ldlm_cancel/ {print $2}')
7973 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7974 awk '/ldlm_bl_callback/ {print $2}')
7975 createmany -o $DIR/$tdir/f $count
7977 can1=$(do_facet $SINGLEMDS \
7978 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7979 awk '/ldlm_cancel/ {print $2}')
7980 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7981 awk '/ldlm_bl_callback/ {print $2}')
7983 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7984 echo rm $count files
7987 can2=$(do_facet $SINGLEMDS \
7988 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7989 awk '/ldlm_cancel/ {print $2}')
7990 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7991 awk '/ldlm_bl_callback/ {print $2}')
7993 echo total: $count removes in $((t2-t1))
7994 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7996 # wait for commitment of removal
7997 lru_resize_enable mdc
7998 lru_resize_enable osc
8000 run_test 120g "Early Lock Cancel: performance test"
8002 test_121() { #bug #10589
8003 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8005 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8006 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8007 lctl set_param fail_loc=0x310
8008 cancel_lru_locks osc > /dev/null
8009 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8010 lctl set_param fail_loc=0
8011 [[ $reads -eq $writes ]] ||
8012 error "read $reads blocks, must be $writes blocks"
8014 run_test 121 "read cancel race ========="
8016 test_123a() { # was test 123, statahead(bug 11401)
8017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8019 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8020 log "testing on UP system. Performance may be not as good as expected."
8025 test_mkdir -p $DIR/$tdir
8026 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8027 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8029 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8030 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8032 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8033 lctl set_param -n llite.*.statahead_max 0
8034 lctl get_param llite.*.statahead_max
8035 cancel_lru_locks mdc
8036 cancel_lru_locks osc
8038 time ls -l $DIR/$tdir | wc -l
8040 delta=$((etime - stime))
8041 log "ls $i files without statahead: $delta sec"
8042 lctl set_param llite.*.statahead_max=$max
8044 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8045 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8046 cancel_lru_locks mdc
8047 cancel_lru_locks osc
8049 time ls -l $DIR/$tdir | wc -l
8051 delta_sa=$((etime - stime))
8052 log "ls $i files with statahead: $delta_sa sec"
8053 lctl get_param -n llite.*.statahead_stats
8054 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8056 [[ $swrong -lt $ewrong ]] &&
8057 log "statahead was stopped, maybe too many locks held!"
8058 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8060 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8061 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8062 lctl set_param -n llite.*.statahead_max 0
8063 lctl get_param llite.*.statahead_max
8064 cancel_lru_locks mdc
8065 cancel_lru_locks osc
8067 time ls -l $DIR/$tdir | wc -l
8069 delta=$((etime - stime))
8070 log "ls $i files again without statahead: $delta sec"
8071 lctl set_param llite.*.statahead_max=$max
8072 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8073 if [ $SLOWOK -eq 0 ]; then
8074 error "ls $i files is slower with statahead!"
8076 log "ls $i files is slower with statahead!"
8082 [ $delta -gt 20 ] && break
8083 [ $delta -gt 8 ] && MULT=$((50 / delta))
8084 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8092 delta=$((etime - stime))
8093 log "rm -r $DIR/$tdir/: $delta seconds"
8095 lctl get_param -n llite.*.statahead_stats
8097 run_test 123a "verify statahead work"
8099 test_123b () { # statahead(bug 15027)
8100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8101 test_mkdir -p $DIR/$tdir
8102 createmany -o $DIR/$tdir/$tfile-%d 1000
8104 cancel_lru_locks mdc
8105 cancel_lru_locks osc
8107 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8108 lctl set_param fail_loc=0x80000803
8109 ls -lR $DIR/$tdir > /dev/null
8111 lctl set_param fail_loc=0x0
8112 lctl get_param -n llite.*.statahead_stats
8117 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8120 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8121 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8122 skip "no lru resize on server" && return 0
8124 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8126 log "create $NR files at $DIR/$tdir"
8127 createmany -o $DIR/$tdir/f $NR ||
8128 error "failed to create $NR files in $DIR/$tdir"
8130 cancel_lru_locks mdc
8131 ls -l $DIR/$tdir > /dev/null
8135 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8136 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8137 LRU_SIZE=$($LCTL get_param -n $PARAM)
8138 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8139 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8141 log "NS=$(basename $NSDIR)"
8146 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8147 skip "Not enough cached locks created!"
8154 # We know that lru resize allows one client to hold $LIMIT locks
8155 # for 10h. After that locks begin to be killed by client.
8157 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8160 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8161 # killing locks. Some time was spent for creating locks. This means
8162 # that up to the moment of sleep finish we must have killed some of
8163 # them (10-100 locks). This depends on how fast ther were created.
8164 # Many of them were touched in almost the same moment and thus will
8165 # be killed in groups.
8166 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8168 # Use $LRU_SIZE_B here to take into account real number of locks
8169 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8170 local LRU_SIZE_B=$LRU_SIZE
8172 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8173 log "OLD_LVF=$OLD_LVF"
8174 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8176 # Let's make sure that we really have some margin. Client checks
8177 # cached locks every 10 sec.
8179 log "Sleep ${SLEEP} sec"
8181 while ((SEC<$SLEEP)); do
8185 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8189 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8190 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8192 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8193 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8194 unlinkmany $DIR/$tdir/f $NR
8198 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8199 log "unlink $NR files at $DIR/$tdir"
8200 unlinkmany $DIR/$tdir/f $NR
8202 run_test 124a "lru resize ======================================="
8204 get_max_pool_limit()
8206 local limit=$($LCTL get_param \
8207 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8210 if [[ $l -gt $max ]]; then
8218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8219 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8220 skip "no lru resize on server" && return 0
8222 LIMIT=$(get_max_pool_limit)
8224 NR=$(($(default_lru_size)*20))
8225 if [[ $NR -gt $LIMIT ]]; then
8226 log "Limit lock number by $LIMIT locks"
8229 lru_resize_disable mdc
8230 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8231 error "failed to create $DIR/$tdir/disable_lru_resize"
8233 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8234 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8235 cancel_lru_locks mdc
8238 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8241 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8244 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8248 nolruresize_delta=$((etime-stime))
8249 log "ls -la time: $nolruresize_delta seconds"
8250 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8251 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8253 lru_resize_enable mdc
8254 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8255 error "failed to create $DIR/$tdir/enable_lru_resize"
8257 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8258 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8259 cancel_lru_locks mdc
8262 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8265 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8268 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8272 lruresize_delta=$((etime-stime))
8273 log "ls -la time: $lruresize_delta seconds"
8274 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8276 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8277 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8278 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8279 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8281 log "lru resize performs the same with no lru resize"
8283 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8285 run_test 124b "lru resize (performance test) ======================="
8287 test_125() { # 13358
8288 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8289 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8290 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8291 test_mkdir -p $DIR/d125 || error "mkdir failed"
8292 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8293 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8294 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8296 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8298 test_126() { # bug 12829/13455
8299 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8300 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8301 $GSS && skip "must run as gss disabled" && return
8303 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8304 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8306 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8308 run_test 126 "check that the fsgid provided by the client is taken into account"
8310 test_127a() { # bug 15521
8311 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8312 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8313 $LCTL set_param osc.*.stats=0
8314 FSIZE=$((2048 * 1024))
8315 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8316 cancel_lru_locks osc
8317 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8319 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8320 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8321 echo "got $COUNT $NAME"
8322 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8323 eval $NAME=$COUNT || error "Wrong proc format"
8326 read_bytes|write_bytes)
8327 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8328 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8329 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8330 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8331 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8332 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8333 error "sumsquare is too small: $SUMSQ"
8334 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8335 error "sumsquare is too big: $SUMSQ"
8339 done < $DIR/${tfile}.tmp
8341 #check that we actually got some stats
8342 [ "$read_bytes" ] || error "Missing read_bytes stats"
8343 [ "$write_bytes" ] || error "Missing write_bytes stats"
8344 [ "$read_bytes" != 0 ] || error "no read done"
8345 [ "$write_bytes" != 0 ] || error "no write done"
8347 run_test 127a "verify the client stats are sane"
8349 test_127b() { # bug LU-333
8350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8351 $LCTL set_param llite.*.stats=0
8352 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8353 # perform 2 reads and writes so MAX is different from SUM.
8354 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8355 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8356 cancel_lru_locks osc
8357 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8358 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8360 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8361 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8362 echo "got $COUNT $NAME"
8363 eval $NAME=$COUNT || error "Wrong proc format"
8367 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8368 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8369 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8370 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8373 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8374 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8375 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8376 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8380 done < $TMP/${tfile}.tmp
8382 #check that we actually got some stats
8383 [ "$read_bytes" ] || error "Missing read_bytes stats"
8384 [ "$write_bytes" ] || error "Missing write_bytes stats"
8385 [ "$read_bytes" != 0 ] || error "no read done"
8386 [ "$write_bytes" != 0 ] || error "no write done"
8388 run_test 127b "verify the llite client stats are sane"
8390 test_128() { # bug 15212
8392 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8397 result=$(grep error $TMP/$tfile.log)
8399 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8401 run_test 128 "interactive lfs for 2 consecutive find's"
8408 local LDPROC=/proc/fs/ldiskfs
8409 local facets=$(get_facets MDS)
8411 for facet in ${facets//,/ }; do
8412 canondev=$(ldiskfs_canon \
8413 *.$(convert_facet2label $facet).mntdev $facet)
8414 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8415 LDPROC=/sys/fs/ldiskfs
8416 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8421 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8422 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8423 skip "Only applicable to ldiskfs-based MDTs"
8426 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8431 test_mkdir -p $DIR/$tdir
8433 # block size of mds1
8434 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8435 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8436 local MAX=$((MDSBLOCKSIZE * 3))
8438 local I=$(stat -c%s "$DIR/$tdir")
8440 local STRIPE_COUNT=1
8441 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8442 MAX=$((MAX*STRIPE_COUNT))
8443 while [[ $I -le $MAX ]]; do
8444 $MULTIOP $DIR/$tdir/$J Oc
8446 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8447 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8448 #and EFBIG for previous versions
8449 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8451 echo "return code $rc received as expected"
8452 multiop $DIR/$tdir/$J Oc ||
8453 error_exit "multiop failed w/o dir size limit"
8455 I=$(stat -c%s "$DIR/$tdir")
8457 if [ $(lustre_version_code $SINGLEMDS) -lt \
8458 $(version_code 2.4.51) ]
8460 [[ $I -eq $MAX ]] && return 0
8462 [[ $I -gt $MAX ]] && return 0
8464 error_exit "current dir size $I, previous limit $MAX"
8465 elif [ $rc -ne 0 ]; then
8467 error_exit "return code $rc received instead of expected " \
8468 "$EFBIG or $ENOSPC, files in dir $I"
8471 I=$(stat -c%s "$DIR/$tdir")
8475 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8477 run_test 129 "test directory size limit ========================"
8486 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8487 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8490 trap cleanup_130 EXIT RETURN
8492 local fm_file=$DIR/$tfile
8493 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8494 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8495 error "dd failed for $fm_file"
8497 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8498 filefrag -ves $fm_file
8500 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8501 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8502 [ $RC != 0 ] && error "filefrag $fm_file failed"
8504 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8505 grep -v "ext:" | grep -v "found")
8506 lun=$($GETSTRIPE -i $fm_file)
8508 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8511 for line in $filefrag_op
8513 frag_lun=`echo $line | cut -d: -f5`
8514 ext_len=`echo $line | cut -d: -f4`
8515 if (( $frag_lun != $lun )); then
8517 error "FIEMAP on 1-stripe file($fm_file) failed"
8520 (( tot_len += ext_len ))
8523 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8525 error "FIEMAP on 1-stripe file($fm_file) failed;"
8531 echo "FIEMAP on single striped file succeeded"
8533 run_test 130a "FIEMAP (1-stripe file)"
8536 [ "$OSTCOUNT" -lt "2" ] &&
8537 skip_env "skipping FIEMAP on 2-stripe file test" && return
8539 [ "$OSTCOUNT" -ge "10" ] &&
8540 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8542 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8543 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8546 trap cleanup_130 EXIT RETURN
8548 local fm_file=$DIR/$tfile
8549 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8550 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8551 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8553 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8554 error "dd failed on $fm_file"
8556 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8557 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8558 grep -v "ext:" | grep -v "found")
8560 last_lun=$(echo $filefrag_op | cut -d: -f5)
8565 for line in $filefrag_op
8567 frag_lun=`echo $line | cut -d: -f5`
8568 ext_len=`echo $line | cut -d: -f4`
8569 if (( $frag_lun != $last_lun )); then
8570 if (( tot_len != 1024 )); then
8572 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8579 (( tot_len += ext_len ))
8582 if (( num_luns != 2 || tot_len != 1024 )); then
8584 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8590 echo "FIEMAP on 2-stripe file succeeded"
8592 run_test 130b "FIEMAP (2-stripe file)"
8595 [ "$OSTCOUNT" -lt "2" ] &&
8596 skip_env "skipping FIEMAP on 2-stripe file" && return
8598 [ "$OSTCOUNT" -ge "10" ] &&
8599 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8601 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8602 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8605 trap cleanup_130 EXIT RETURN
8607 local fm_file=$DIR/$tfile
8608 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8609 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8610 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8612 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8614 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8615 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8617 last_lun=`echo $filefrag_op | cut -d: -f5`
8622 for line in $filefrag_op
8624 frag_lun=`echo $line | cut -d: -f5`
8625 ext_len=`echo $line | cut -d: -f4`
8626 if (( $frag_lun != $last_lun )); then
8627 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8628 if (( logical != 512 )); then
8630 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8633 if (( tot_len != 512 )); then
8635 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8642 (( tot_len += ext_len ))
8645 if (( num_luns != 2 || tot_len != 512 )); then
8647 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8653 echo "FIEMAP on 2-stripe file with hole succeeded"
8655 run_test 130c "FIEMAP (2-stripe file with hole)"
8658 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8660 [ "$OSTCOUNT" -ge "10" ] &&
8661 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8663 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8664 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8666 trap cleanup_130 EXIT RETURN
8668 local fm_file=$DIR/$tfile
8669 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8670 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8671 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8673 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8674 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8675 error "dd failed on $fm_file"
8677 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8678 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8679 grep -v "ext:" | grep -v "found"`
8681 last_lun=`echo $filefrag_op | cut -d: -f5`
8686 for line in $filefrag_op
8688 frag_lun=`echo $line | cut -d: -f5`
8689 ext_len=`echo $line | cut -d: -f4`
8690 if (( $frag_lun != $last_lun )); then
8691 if (( tot_len != 1024 )); then
8693 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8700 (( tot_len += ext_len ))
8703 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8705 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8711 echo "FIEMAP on N-stripe file succeeded"
8713 run_test 130d "FIEMAP (N-stripe file)"
8716 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8718 [ "$OSTCOUNT" -ge "10" ] &&
8719 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8721 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8722 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8724 trap cleanup_130 EXIT RETURN
8726 local fm_file=$DIR/$tfile
8727 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8728 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8729 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8732 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8733 for ((i = 0; i < $NUM_BLKS; i++))
8735 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8738 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8739 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8741 last_lun=`echo $filefrag_op | cut -d: -f5`
8746 for line in $filefrag_op
8748 frag_lun=`echo $line | cut -d: -f5`
8749 ext_len=`echo $line | cut -d: -f4`
8750 if (( $frag_lun != $last_lun )); then
8751 if (( tot_len != $EXPECTED_LEN )); then
8753 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8760 (( tot_len += ext_len ))
8763 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8765 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8771 echo "FIEMAP with continuation calls succeeded"
8773 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8775 # Test for writev/readv
8777 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8778 error "writev test failed"
8779 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8780 error "readv failed"
8783 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8786 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8787 error "append writev test failed"
8788 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8789 error "append writev test failed"
8792 run_test 131b "test append writev"
8795 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8798 run_test 131c "test read/write on file w/o objects"
8801 rwv -f $DIR/$tfile -w -n 1 1572864
8802 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8803 if [ "$NOB" != 1572864 ]; then
8804 error "Short read filed: read $NOB bytes instead of 1572864"
8808 run_test 131d "test short read"
8811 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8812 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8813 error "read hitting hole failed"
8816 run_test 131e "test read hitting hole"
8821 for node in $(osts_nodes); do
8822 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8823 [ x$gl = x"" ] && gl=0
8824 gl_sum=$((gl_sum + gl))
8834 if [ x$som = x"enabled" ]; then
8835 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8836 MOUNT_OPTS=`echo $MOUNT_OPTS |
8837 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8838 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8840 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8841 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8842 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8845 # do remount to make new mount-conf parameters actual
8852 test_132() { #1028, SOM
8853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8854 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8855 local num=$(get_mds_dir $DIR)
8856 local mymds=mds${num}
8857 local MOUNT_OPTS_SAVE=$MOUNT_OPTS
8859 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8860 cancel_lru_locks osc
8862 som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8864 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8865 stat $DIR/$tfile >/dev/null
8866 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8867 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8869 som_mode_switch $som1 $gl1 $gl2
8871 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8872 cancel_lru_locks osc
8874 som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8875 if [ $som1 == $som2 ]; then
8876 error "som is still "$som2
8877 if [ x$som2 = x"enabled" ]; then
8884 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8885 stat $DIR/$tfile >/dev/null
8886 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8887 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8888 som_mode_switch $som2 $gl1 $gl2
8889 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8891 run_test 132 "som avoids glimpse rpc"
8897 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8899 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8901 *) error "Wrong argument $1" ;;
8904 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8905 # if the argument $3 is zero, it means any stat increment is ok.
8906 if [[ $3 -gt 0 ]]; then
8907 count=$(echo $res | awk '{ print $2 }')
8908 [[ $count -ne $3 ]] &&
8909 error "The $2 counter on $1 is wrong - expected $3"
8914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8915 remote_ost_nodsh && skip "remote OST with nodsh" && return
8916 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8918 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8919 { skip "MDS doesn't support rename stats"; return; }
8920 local testdir=$DIR/${tdir}/stats_testdir
8921 mkdir -p $DIR/${tdir}
8924 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8925 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8927 # verify mdt stats first.
8928 mkdir ${testdir} || error "mkdir failed"
8929 check_stats $SINGLEMDS "mkdir" 1
8930 touch ${testdir}/${tfile} || "touch failed"
8931 check_stats $SINGLEMDS "open" 1
8932 check_stats $SINGLEMDS "close" 1
8933 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8934 check_stats $SINGLEMDS "mknod" 1
8935 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8936 check_stats $SINGLEMDS "unlink" 1
8937 rm -f ${testdir}/${tfile} || error "file remove failed"
8938 check_stats $SINGLEMDS "unlink" 2
8940 # remove working dir and check mdt stats again.
8941 rmdir ${testdir} || error "rmdir failed"
8942 check_stats $SINGLEMDS "rmdir" 1
8944 local testdir1=$DIR/${tdir}/stats_testdir1
8946 mkdir -p ${testdir1}
8947 touch ${testdir1}/test1
8948 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8949 check_stats $SINGLEMDS "crossdir_rename" 1
8951 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8952 check_stats $SINGLEMDS "samedir_rename" 1
8956 run_test 133a "Verifying MDT stats ========================================"
8959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8960 remote_ost_nodsh && skip "remote OST with nodsh" && return
8961 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8962 local testdir=$DIR/${tdir}/stats_testdir
8963 mkdir -p ${testdir} || error "mkdir failed"
8964 touch ${testdir}/${tfile} || "touch failed"
8965 cancel_lru_locks mdc
8968 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8969 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8971 # extra mdt stats verification.
8972 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8973 check_stats $SINGLEMDS "setattr" 1
8974 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8975 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8977 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8978 check_stats $SINGLEMDS "getattr" 1
8980 $LFS df || error "lfs failed"
8981 check_stats $SINGLEMDS "statfs" 1
8985 run_test 133b "Verifying extra MDT stats =================================="
8988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8989 remote_ost_nodsh && skip "remote OST with nodsh" && return
8990 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8991 local testdir=$DIR/${tdir}/stats_testdir
8992 test_mkdir -p ${testdir} || error "mkdir failed"
8994 # verify obdfilter stats.
8995 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8997 cancel_lru_locks osc
8998 wait_delete_completed
9001 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9002 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9004 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9006 cancel_lru_locks osc
9007 check_stats ost "write" 1
9009 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9010 check_stats ost "read" 1
9012 > ${testdir}/${tfile} || error "truncate failed"
9013 check_stats ost "punch" 1
9015 rm -f ${testdir}/${tfile} || error "file remove failed"
9016 wait_delete_completed
9017 check_stats ost "destroy" 1
9021 run_test 133c "Verifying OST stats ========================================"
9028 while [ $value -ge 2 ]; do
9033 if [ $orig -gt $order ]; then
9041 local size=('K' 'M' 'G' 'T');
9043 local size_string=$value
9045 while [ $value -ge 1024 ]; do
9046 if [ $i -gt 3 ]; then
9047 #T is the biggest unit we get here, if that is bigger,
9049 size_string=${value}T
9052 value=$((value >> 10))
9053 if [ $value -lt 1024 ]; then
9054 size_string=${value}${size[$i]}
9065 local context=${2:-.}
9066 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9068 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9074 remote_ost_nodsh && skip "remote OST with nodsh" && return
9075 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9076 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9077 { skip "MDS doesn't support rename stats"; return; }
9079 local testdir1=$DIR/${tdir}/stats_testdir1
9080 local testdir2=$DIR/${tdir}/stats_testdir2
9082 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9084 mkdir -p ${testdir1} || error "mkdir failed"
9085 mkdir -p ${testdir2} || error "mkdir failed"
9087 createmany -o $testdir1/test 512 || error "createmany failed"
9089 # check samedir rename size
9090 mv ${testdir1}/test0 ${testdir1}/test_0
9092 local testdir1_size=$(ls -l $DIR/${tdir} |
9093 awk '/stats_testdir1/ {print $5}')
9094 local testdir2_size=$(ls -l $DIR/${tdir} |
9095 awk '/stats_testdir2/ {print $5}')
9097 testdir1_size=$(order_2 $testdir1_size)
9098 testdir2_size=$(order_2 $testdir2_size)
9100 testdir1_size=$(size_in_KMGT $testdir1_size)
9101 testdir2_size=$(size_in_KMGT $testdir2_size)
9103 echo "source rename dir size: ${testdir1_size}"
9104 echo "target rename dir size: ${testdir2_size}"
9106 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9107 eval $cmd || error "$cmd failed"
9108 local samedir=$($cmd | grep 'same_dir')
9109 local same_sample=$(get_rename_size $testdir1_size)
9110 [ -z "$samedir" ] && error "samedir_rename_size count error"
9111 [[ $same_sample -eq 1 ]] ||
9112 error "samedir_rename_size error $same_sample"
9113 echo "Check same dir rename stats success"
9115 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9117 # check crossdir rename size
9118 mv ${testdir1}/test_0 ${testdir2}/test_0
9120 testdir1_size=$(ls -l $DIR/${tdir} |
9121 awk '/stats_testdir1/ {print $5}')
9122 testdir2_size=$(ls -l $DIR/${tdir} |
9123 awk '/stats_testdir2/ {print $5}')
9125 testdir1_size=$(order_2 $testdir1_size)
9126 testdir2_size=$(order_2 $testdir2_size)
9128 testdir1_size=$(size_in_KMGT $testdir1_size)
9129 testdir2_size=$(size_in_KMGT $testdir2_size)
9131 echo "source rename dir size: ${testdir1_size}"
9132 echo "target rename dir size: ${testdir2_size}"
9134 eval $cmd || error "$cmd failed"
9135 local crossdir=$($cmd | grep 'crossdir')
9136 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9137 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9138 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9139 [[ $src_sample -eq 1 ]] ||
9140 error "crossdir_rename_size error $src_sample"
9141 [[ $tgt_sample -eq 1 ]] ||
9142 error "crossdir_rename_size error $tgt_sample"
9143 echo "Check cross dir rename stats success"
9146 run_test 133d "Verifying rename_stats ========================================"
9149 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9150 remote_ost_nodsh && skip "remote OST with nodsh" && return
9151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9152 local testdir=$DIR/${tdir}/stats_testdir
9153 local ctr f0 f1 bs=32768 count=42 sum
9155 mkdir -p ${testdir} || error "mkdir failed"
9157 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9159 for ctr in {write,read}_bytes; do
9161 cancel_lru_locks osc
9163 do_facet ost1 $LCTL set_param -n \
9164 "obdfilter.*.exports.clear=clear"
9166 if [ $ctr = write_bytes ]; then
9168 f1=${testdir}/${tfile}
9170 f0=${testdir}/${tfile}
9174 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9177 cancel_lru_locks osc
9179 sum=$(do_facet ost1 $LCTL get_param \
9180 "obdfilter.*.exports.*.stats" |
9181 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9182 $1 == ctr { sum += $7 }
9183 END { printf("%0.0f", sum) }')
9185 if ((sum != bs * count)); then
9186 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9192 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9197 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9198 /sys/fs/lustre/ /sys/fs/lnet/"
9200 for dir in $dirs; do
9201 if [ -d $dir ]; then
9202 proc_dirs="$proc_dirs $dir"
9208 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9209 remote_ost_nodsh && skip "remote OST with nodsh" && return
9210 # First without trusting modes.
9211 find $proc_dirs -exec cat '{}' \; &> /dev/null
9213 # Second verifying readability.
9216 -exec cat '{}' \; &> /dev/null ||
9217 error "proc file read failed"
9219 for facet in $SINGLEMDS ost1; do
9220 do_facet $facet find $proc_dirs \
9221 ! -name req_history \
9222 -exec cat '{}' \\\; &> /dev/null
9224 do_facet $facet find $proc_dirs \
9225 ! -name req_history \
9227 -exec cat '{}' \\\; &> /dev/null ||
9228 error "proc file read failed"
9231 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9236 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9237 /sys/fs/lustre/ /sys/fs/lnet/"
9239 for dir in $dirs; do
9240 if [ -d $dir ]; then
9241 proc_dirs="$proc_dirs $dir"
9247 # Second verifying readability.
9250 -not -name force_lbug \
9251 -not -name changelog_mask \
9252 -exec badarea_io '{}' \; &> /dev/null ||
9253 error "find $proc_dirs failed"
9255 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9256 skip "Too old lustre on MDS"
9258 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9259 skip "Too old lustre on ost1"
9261 for facet in $SINGLEMDS ost1; do
9262 do_facet $facet find $proc_dirs \
9264 -not -name force_lbug \
9265 -not -name changelog_mask \
9266 -exec badarea_io '{}' \\\; &> /dev/null ||
9267 error "$facet find $proc_dirs failed"
9271 # remount the FS in case writes/reads /proc break the FS
9272 cleanup || error "failed to unmount"
9273 setup || error "failed to setup"
9276 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9278 test_140() { #bug-17379
9279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9280 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9281 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9282 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9284 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9285 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9287 while i=`expr $i + 1`; do
9288 test_mkdir -p $i || error "Creating dir $i"
9289 cd $i || error "Changing to $i"
9290 ln -s ../stat stat || error "Creating stat symlink"
9291 # Read the symlink until ELOOP present,
9292 # not LBUGing the system is considered success,
9293 # we didn't overrun the stack.
9294 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9296 if [ $ret -eq 40 ]; then
9299 error "Open stat symlink"
9305 echo "The symlink depth = $i"
9306 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9307 error "Invalid symlink depth"
9309 # Test recursive symlink
9310 ln -s symlink_self symlink_self
9311 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9312 echo "open symlink_self returns $ret"
9313 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9315 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9319 local TF="$TMP/$tfile"
9321 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9323 cancel_lru_locks osc
9324 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9325 remount_client $MOUNT
9327 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9330 $TRUNCATE $DIR/$tfile 6000
9331 cancel_lru_locks osc
9332 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9335 echo "12345" >>$DIR/$tfile
9336 cancel_lru_locks osc
9337 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9340 echo "12345" >>$DIR/$tfile
9341 cancel_lru_locks osc
9342 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9347 run_test 150 "truncate/append tests"
9349 #LU-2902 roc_hit was not able to read all values from lproc
9350 function roc_hit_init() {
9351 local list=$(comma_list $(osts_nodes))
9352 local dir=$DIR/$tdir-check
9353 local file=$dir/file
9359 #use setstripe to do a write to every ost
9360 for i in $(seq 0 $((OSTCOUNT-1))); do
9361 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9362 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9363 idx=$(printf %04x $i)
9364 BEFORE=$(get_osd_param $list *OST*$idx stats |
9365 awk '$1 == "cache_access" {sum += $7}
9366 END { printf("%0.0f", sum) }')
9368 cancel_lru_locks osc
9369 cat $file >/dev/null
9371 AFTER=$(get_osd_param $list *OST*$idx stats |
9372 awk '$1 == "cache_access" {sum += $7}
9373 END { printf("%0.0f", sum) }')
9375 echo BEFORE:$BEFORE AFTER:$AFTER
9376 if ! let "AFTER - BEFORE == 4"; then
9378 error "roc_hit is not safe to use"
9386 function roc_hit() {
9387 local list=$(comma_list $(osts_nodes))
9388 echo $(get_osd_param $list '' stats |
9389 awk '$1 == "cache_hit" {sum += $7}
9390 END { printf("%0.0f", sum) }')
9393 function set_cache() {
9396 if [ "$2" == "off" ]; then
9399 local list=$(comma_list $(osts_nodes))
9400 set_osd_param $list '' $1_cache_enable $on
9402 cancel_lru_locks osc
9406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9407 remote_ost_nodsh && skip "remote OST with nodsh" && return
9410 local list=$(comma_list $(osts_nodes))
9412 # check whether obdfilter is cache capable at all
9413 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9414 echo "not cache-capable obdfilter"
9418 # check cache is enabled on all obdfilters
9419 if get_osd_param $list '' read_cache_enable | grep 0; then
9420 echo "oss cache is disabled"
9424 set_osd_param $list '' writethrough_cache_enable 1
9426 # check write cache is enabled on all obdfilters
9427 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9428 echo "oss write cache is NOT enabled"
9434 #define OBD_FAIL_OBD_NO_LRU 0x609
9435 do_nodes $list $LCTL set_param fail_loc=0x609
9437 # pages should be in the case right after write
9438 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9441 local BEFORE=$(roc_hit)
9442 cancel_lru_locks osc
9443 cat $DIR/$tfile >/dev/null
9444 local AFTER=$(roc_hit)
9446 do_nodes $list $LCTL set_param fail_loc=0
9448 if ! let "AFTER - BEFORE == CPAGES"; then
9449 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9452 # the following read invalidates the cache
9453 cancel_lru_locks osc
9454 set_osd_param $list '' read_cache_enable 0
9455 cat $DIR/$tfile >/dev/null
9457 # now data shouldn't be found in the cache
9459 cancel_lru_locks osc
9460 cat $DIR/$tfile >/dev/null
9462 if let "AFTER - BEFORE != 0"; then
9463 error "IN CACHE: before: $BEFORE, after: $AFTER"
9466 set_osd_param $list '' read_cache_enable 1
9469 run_test 151 "test cache on oss and controls ==============================="
9472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9473 local TF="$TMP/$tfile"
9475 # simulate ENOMEM during write
9476 #define OBD_FAIL_OST_NOMEM 0x226
9477 lctl set_param fail_loc=0x80000226
9478 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9480 sync || error "sync failed"
9481 lctl set_param fail_loc=0
9483 # discard client's cache
9484 cancel_lru_locks osc
9486 # simulate ENOMEM during read
9487 lctl set_param fail_loc=0x80000226
9488 cmp $TF $DIR/$tfile || error "cmp failed"
9489 lctl set_param fail_loc=0
9493 run_test 152 "test read/write with enomem ============================"
9496 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9498 run_test 153 "test if fdatasync does not crash ======================="
9500 dot_lustre_fid_permission_check() {
9502 local ffid=$MOUNT/.lustre/fid/$fid
9505 echo "stat fid $fid"
9506 stat $ffid > /dev/null || error "stat $ffid failed."
9507 echo "touch fid $fid"
9508 touch $ffid || error "touch $ffid failed."
9509 echo "write to fid $fid"
9510 cat /etc/hosts > $ffid || error "write $ffid failed."
9511 echo "read fid $fid"
9512 diff /etc/hosts $ffid || error "read $ffid failed."
9513 echo "append write to fid $fid"
9514 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9515 echo "rename fid $fid"
9516 mv $ffid $test_dir/$tfile.1 &&
9517 error "rename $ffid to $tfile.1 should fail."
9518 touch $test_dir/$tfile.1
9519 mv $test_dir/$tfile.1 $ffid &&
9520 error "rename $tfile.1 to $ffid should fail."
9521 rm -f $test_dir/$tfile.1
9522 echo "truncate fid $fid"
9523 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9524 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9525 echo "link fid $fid"
9526 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9528 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9529 echo "setfacl fid $fid"
9530 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9531 echo "getfacl fid $fid"
9532 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9534 echo "unlink fid $fid"
9535 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9536 echo "mknod fid $fid"
9537 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9539 fid=[0xf00000400:0x1:0x0]
9540 ffid=$MOUNT/.lustre/fid/$fid
9542 echo "stat non-exist fid $fid"
9543 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9544 echo "write to non-exist fid $fid"
9545 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9546 echo "link new fid $fid"
9547 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9549 mkdir -p $test_dir/$tdir
9550 touch $test_dir/$tdir/$tfile
9551 fid=$($LFS path2fid $test_dir/$tdir)
9554 error "error: could not get fid for $test_dir/$dir/$tfile."
9556 ffid=$MOUNT/.lustre/fid/$fid
9559 ls $ffid > /dev/null || error "ls $ffid failed."
9560 echo "touch $fid/$tfile.1"
9561 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9563 echo "touch $MOUNT/.lustre/fid/$tfile"
9564 touch $MOUNT/.lustre/fid/$tfile && \
9565 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9567 echo "setxattr to $MOUNT/.lustre/fid"
9568 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9570 echo "listxattr for $MOUNT/.lustre/fid"
9571 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9573 echo "delxattr from $MOUNT/.lustre/fid"
9574 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9576 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9577 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9578 error "touch invalid fid should fail."
9580 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9581 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9582 error "touch non-normal fid should fail."
9584 echo "rename $tdir to $MOUNT/.lustre/fid"
9585 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9586 error "rename to $MOUNT/.lustre/fid should fail."
9588 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9590 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9591 local new_obf_mode=777
9593 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9594 chmod $new_obf_mode $DIR/.lustre/fid ||
9595 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9597 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9598 [ $obf_mode -eq $new_obf_mode ] ||
9599 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9601 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9602 chmod $old_obf_mode $DIR/.lustre/fid ||
9603 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9606 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9607 fid=$($LFS path2fid $test_dir/$tfile-2)
9609 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9611 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9612 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9613 error "create lov data thru .lustre failed"
9615 echo "cp /etc/passwd $test_dir/$tfile-2"
9616 cp /etc/passwd $test_dir/$tfile-2 ||
9617 error "copy to $test_dir/$tfile-2 failed."
9618 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9619 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9620 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9622 rm -rf $test_dir/tfile.lnk
9623 rm -rf $test_dir/$tfile-2
9627 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9628 skip "Need MDS version at least 2.4.1" && return
9631 local FID=$($LFS path2fid $DIR/$tfile)
9632 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9634 # check that we get the same pathname back
9635 local FOUND=$($LFS fid2path $MOUNT $FID)
9636 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9637 [ "$FOUND" != "$DIR/$tfile" ] &&
9638 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9642 run_test 154A "lfs path2fid and fid2path basic checks"
9645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9646 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9647 { skip "Need MDS version at least 2.2.51"; return 0; }
9648 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9650 cp /etc/hosts $DIR/$tfile
9652 fid=$($LFS path2fid $DIR/$tfile)
9654 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9656 dot_lustre_fid_permission_check "$fid" $DIR ||
9657 error "dot lustre permission check $fid failed"
9659 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9661 touch $MOUNT/.lustre/file &&
9662 error "creation is not allowed under .lustre"
9664 mkdir $MOUNT/.lustre/dir &&
9665 error "mkdir is not allowed under .lustre"
9669 run_test 154a "Open-by-FID"
9672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9673 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9674 { skip "Need MDS version at least 2.2.51"; return 0; }
9676 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9678 local remote_dir=$DIR/$tdir/remote_dir
9683 $LFS mkdir -i $MDTIDX $remote_dir ||
9684 error "create remote directory failed"
9686 cp /etc/hosts $remote_dir/$tfile
9688 fid=$($LFS path2fid $remote_dir/$tfile)
9690 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9692 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9693 error "dot lustre permission check $fid failed"
9696 run_test 154b "Open-by-FID for remote directory"
9699 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9700 skip "Need MDS version at least 2.4.1" && return
9702 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9703 local FID1=$($LFS path2fid $DIR/$tfile.1)
9704 local FID2=$($LFS path2fid $DIR/$tfile.2)
9705 local FID3=$($LFS path2fid $DIR/$tfile.3)
9708 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9709 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9710 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9712 [ "$FID" = "${!want}" ] ||
9713 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9717 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9718 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9719 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9723 run_test 154c "lfs path2fid and fid2path multiple arguments"
9726 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9727 skip "Need MDS version at least 2.5.53" && return
9730 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9734 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9741 fid=$($LFS path2fid $DIR/$tfile)
9744 cmd="exec $fd<$DIR/$tfile"
9746 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9747 echo $fid_list | grep $fid
9750 cmd="exec $fd>/dev/null"
9752 if [ $rc -ne 0 ]; then
9753 error "FID $fid not found in open files list $fid_list"
9756 run_test 154d "Verify open file fid"
9760 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9761 skip "Need MDS version at least 2.6.50" && return
9763 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9764 error ".lustre returned by readdir"
9767 run_test 154e ".lustre is not returned by readdir"
9769 test_155_small_load() {
9770 local temp=$TMP/$tfile
9771 local file=$DIR/$tfile
9773 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9774 error "dd of=$temp bs=6096 count=1 failed"
9776 cancel_lru_locks osc
9777 cmp $temp $file || error "$temp $file differ"
9779 $TRUNCATE $temp 6000
9780 $TRUNCATE $file 6000
9781 cmp $temp $file || error "$temp $file differ (truncate1)"
9783 echo "12345" >>$temp
9784 echo "12345" >>$file
9785 cmp $temp $file || error "$temp $file differ (append1)"
9787 echo "12345" >>$temp
9788 echo "12345" >>$file
9789 cmp $temp $file || error "$temp $file differ (append2)"
9795 test_155_big_load() {
9796 remote_ost_nodsh && skip "remote OST with nodsh" && return
9797 local temp=$TMP/$tfile
9798 local file=$DIR/$tfile
9801 local cache_size=$(do_facet ost$((MAXI+1)) \
9802 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9803 local large_file_size=$((cache_size * 2))
9805 echo "OSS cache size: $cache_size KB"
9806 echo "Large file size: $large_file_size KB"
9808 [ $MAXV -le $large_file_size ] && \
9809 skip_env "max available OST size needs > $large_file_size KB" && \
9812 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9814 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9815 error "dd of=$temp bs=$large_file_size count=1k failed"
9818 cancel_lru_locks osc
9819 cmp $temp $file || error "$temp $file differ"
9826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9828 set_cache writethrough on
9831 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9834 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9836 set_cache writethrough off
9839 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9844 set_cache writethrough on
9847 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9852 set_cache writethrough off
9855 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9858 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9860 set_cache writethrough on
9863 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9868 set_cache writethrough off
9871 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9876 set_cache writethrough on
9879 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9884 set_cache writethrough off
9887 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9890 remote_ost_nodsh && skip "remote OST with nodsh" && return
9891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9895 local file="$DIR/$tfile"
9897 [ "$(facet_fstype ost1)" = "zfs" ] &&
9898 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9903 log "Turn on read and write cache"
9905 set_cache writethrough on
9907 log "Write data and read it back."
9908 log "Read should be satisfied from the cache."
9909 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9911 cancel_lru_locks osc
9912 cat $file >/dev/null
9914 if ! let "AFTER - BEFORE == CPAGES"; then
9915 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9917 log "cache hits:: before: $BEFORE, after: $AFTER"
9920 log "Read again; it should be satisfied from the cache."
9922 cancel_lru_locks osc
9923 cat $file >/dev/null
9925 if ! let "AFTER - BEFORE == CPAGES"; then
9926 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9928 log "cache hits:: before: $BEFORE, after: $AFTER"
9932 log "Turn off the read cache and turn on the write cache"
9934 set_cache writethrough on
9936 log "Read again; it should be satisfied from the cache."
9938 cancel_lru_locks osc
9939 cat $file >/dev/null
9941 if ! let "AFTER - BEFORE == CPAGES"; then
9942 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9944 log "cache hits:: before: $BEFORE, after: $AFTER"
9947 log "Read again; it should not be satisfied from the cache."
9949 cancel_lru_locks osc
9950 cat $file >/dev/null
9952 if ! let "AFTER - BEFORE == 0"; then
9953 error "IN CACHE: before: $BEFORE, after: $AFTER"
9955 log "cache hits:: before: $BEFORE, after: $AFTER"
9958 log "Write data and read it back."
9959 log "Read should be satisfied from the cache."
9960 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9962 cancel_lru_locks osc
9963 cat $file >/dev/null
9965 if ! let "AFTER - BEFORE == CPAGES"; then
9966 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9968 log "cache hits:: before: $BEFORE, after: $AFTER"
9971 log "Read again; it should not be satisfied from the cache."
9973 cancel_lru_locks osc
9974 cat $file >/dev/null
9976 if ! let "AFTER - BEFORE == 0"; then
9977 error "IN CACHE: before: $BEFORE, after: $AFTER"
9979 log "cache hits:: before: $BEFORE, after: $AFTER"
9983 log "Turn off read and write cache"
9985 set_cache writethrough off
9987 log "Write data and read it back"
9988 log "It should not be satisfied from the cache."
9990 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9991 cancel_lru_locks osc
9993 cat $file >/dev/null
9995 if ! let "AFTER - BEFORE == 0"; then
9996 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9998 log "cache hits:: before: $BEFORE, after: $AFTER"
10001 log "Turn on the read cache and turn off the write cache"
10003 set_cache writethrough off
10005 log "Write data and read it back"
10006 log "It should not be satisfied from the cache."
10008 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10010 cancel_lru_locks osc
10011 cat $file >/dev/null
10013 if ! let "AFTER - BEFORE == 0"; then
10014 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10016 log "cache hits:: before: $BEFORE, after: $AFTER"
10019 log "Read again; it should be satisfied from the cache."
10021 cancel_lru_locks osc
10022 cat $file >/dev/null
10024 if ! let "AFTER - BEFORE == CPAGES"; then
10025 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10027 log "cache hits:: before: $BEFORE, after: $AFTER"
10032 run_test 156 "Verification of tunables ============================"
10036 if [[ $MDSCOUNT -gt 1 ]]; then
10037 error_ignore bz17935 $*
10045 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10047 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10049 if [ $MASK -eq 1 ]; then
10050 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10052 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10056 changelog_extract_field() {
10060 local identifier=$4
10062 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10063 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10069 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10070 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10071 { skip "Need MDS version at least 2.2.0"; return; }
10073 local CL_USERS="mdd.$MDT0.changelog_users"
10074 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10075 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10076 echo "Registered as changelog user $USER"
10077 $GET_CL_USERS | grep -q $USER ||
10078 error "User $USER not found in changelog_users"
10081 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10082 touch $DIR/$tdir/pics/2008/zachy/timestamp
10083 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10084 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10085 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10086 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10087 rm $DIR/$tdir/pics/desktop.jpg
10089 $LFS changelog $MDT0 | tail -5
10091 echo "verifying changelog mask"
10092 changelog_chmask "MKDIR"
10093 changelog_chmask "CLOSE"
10095 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10096 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10098 changelog_chmask "MKDIR"
10099 changelog_chmask "CLOSE"
10101 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10102 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10104 $LFS changelog $MDT0
10105 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10106 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10107 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10108 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10111 echo "verifying target fid"
10112 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10113 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10114 [ "$fidc" == "$fidf" ] ||
10115 err17935 "fid in changelog $fidc != file fid $fidf"
10116 echo "verifying parent fid"
10117 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10118 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10119 [ "$fidc" == "$fidf" ] ||
10120 err17935 "pfid in changelog $fidc != dir fid $fidf"
10122 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10123 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10124 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10125 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10126 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10127 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10129 MIN_REC=$($GET_CL_USERS |
10130 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10131 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10132 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10133 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10134 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10136 # LU-3446 changelog index reset on MDT restart
10137 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10138 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10139 $LFS changelog_clear $MDT0 $USER 0
10140 stop $SINGLEMDS || error "Fail to stop MDT."
10141 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10142 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10143 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10144 [ $CUR_REC1 == $CUR_REC2 ] ||
10145 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10147 echo "verifying user deregister"
10148 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10149 $GET_CL_USERS | grep -q $USER &&
10150 error "User $USER still in changelog_users"
10152 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10153 if [ $USERS -eq 0 ]; then
10154 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10155 touch $DIR/$tdir/chloe
10156 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10157 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10158 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10160 echo "$USERS other changelog users; can't verify off"
10163 run_test 160a "changelog sanity"
10165 test_160b() { # LU-3587
10166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10167 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10168 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10169 { skip "Need MDS version at least 2.2.0"; return; }
10171 local CL_USERS="mdd.$MDT0.changelog_users"
10172 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10173 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10174 echo "Registered as changelog user $USER"
10175 $GET_CL_USERS | grep -q $USER ||
10176 error "User $USER not found in changelog_users"
10178 local LONGNAME1=$(str_repeat a 255)
10179 local LONGNAME2=$(str_repeat b 255)
10182 echo "creating very long named file"
10183 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10184 echo "moving very long named file"
10185 mv $LONGNAME1 $LONGNAME2
10187 $LFS changelog $MDT0 | grep RENME
10189 echo "deregistering $USER"
10190 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10194 run_test 160b "Verify that very long rename doesn't crash in changelog"
10198 local server_version=$(lustre_version_code $SINGLEMDS)
10200 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10201 [[ $server_version -gt $(version_code 2.5.1) &&
10202 $server_version -lt $(version_code 2.5.50) ]] ||
10203 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10204 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10206 # Registration step
10207 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10208 changelog_register -n)
10211 mkdir -p $DIR/$tdir
10212 $MCREATE $DIR/$tdir/foo_160c
10213 changelog_chmask "TRUNC"
10214 $TRUNCATE $DIR/$tdir/foo_160c 200
10215 changelog_chmask "TRUNC"
10216 $TRUNCATE $DIR/$tdir/foo_160c 199
10217 $LFS changelog $MDT0
10218 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10219 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10220 $LFS changelog_clear $MDT0 $USER 0
10222 # Deregistration step
10223 echo "deregistering $USER"
10224 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10226 run_test 160c "verify that changelog log catch the truncate event"
10229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10230 test_mkdir -p -c1 $DIR/$tdir
10231 cp /etc/hosts $DIR/$tdir/$tfile
10232 test_mkdir -c1 $DIR/$tdir/foo1
10233 test_mkdir -c1 $DIR/$tdir/foo2
10234 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10235 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10236 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10237 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10238 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10239 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10240 $LFS fid2path $DIR $FID
10241 err17935 "bad link ea"
10244 rm $DIR/$tdir/foo2/zachary
10246 rm $DIR/$tdir/foo2/thor
10248 rm $DIR/$tdir/$tfile
10250 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10251 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10253 $LFS fid2path $DIR $FID
10254 err17935 "bad link rename"
10256 rm $DIR/$tdir/foo2/maggie
10259 local longname=filename_avg_len_is_thirty_two_
10260 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10261 error "failed to hardlink many files"
10262 links=$($LFS fid2path $DIR $FID | wc -l)
10263 echo -n "${links}/1000 links in link EA"
10264 [[ $links -gt 60 ]] ||
10265 err17935 "expected at least 60 links in link EA"
10266 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10267 error "failed to unlink many hardlinks"
10269 run_test 161a "link ea sanity"
10272 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10273 [ $MDSCOUNT -lt 2 ] &&
10274 skip "skipping remote directory test" && return
10276 local remote_dir=$DIR/$tdir/remote_dir
10278 mkdir -p $DIR/$tdir
10279 $LFS mkdir -i $MDTIDX $remote_dir ||
10280 error "create remote directory failed"
10282 cp /etc/hosts $remote_dir/$tfile
10283 mkdir -p $remote_dir/foo1
10284 mkdir -p $remote_dir/foo2
10285 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10286 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10287 ln $remote_dir/$tfile $remote_dir/foo1/luna
10288 ln $remote_dir/$tfile $remote_dir/foo2/thor
10290 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10292 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10293 $LFS fid2path $DIR $FID
10294 err17935 "bad link ea"
10297 rm $remote_dir/foo2/zachary
10299 rm $remote_dir/foo2/thor
10301 rm $remote_dir/$tfile
10303 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10304 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10305 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10306 $LFS fid2path $DIR $FID
10307 err17935 "bad link rename"
10309 rm $remote_dir/foo2/maggie
10312 local longname=filename_avg_len_is_thirty_two_
10313 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10314 error "failed to hardlink many files"
10315 links=$($LFS fid2path $DIR $FID | wc -l)
10316 echo -n "${links}/1000 links in link EA"
10317 [[ ${links} -gt 60 ]] ||
10318 err17935 "expected at least 60 links in link EA"
10319 unlinkmany $remote_dir/foo2/$longname 1000 ||
10320 error "failed to unlink many hardlinks"
10322 run_test 161b "link ea sanity under remote directory"
10325 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10327 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10328 skip "Need MDS version at least 2.1.5" && return
10330 # define CLF_RENAME_LAST 0x0001
10331 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10332 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10333 changelog_register -n)
10335 mkdir -p $DIR/$tdir
10336 touch $DIR/$tdir/foo_161c
10337 touch $DIR/$tdir/bar_161c
10338 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10339 $LFS changelog $MDT0 | grep RENME
10340 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10342 $LFS changelog_clear $MDT0 $USER 0
10343 if [ x$flags != "x0x1" ]; then
10344 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10346 error "flag $flags is not 0x1"
10348 echo "rename overwrite a target having nlink = 1," \
10349 "changelog record has flags of $flags"
10351 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10352 touch $DIR/$tdir/foo_161c
10353 touch $DIR/$tdir/bar_161c
10354 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10355 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10356 $LFS changelog $MDT0 | grep RENME
10357 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10358 $LFS changelog_clear $MDT0 $USER 0
10359 if [ x$flags != "x0x0" ]; then
10360 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10362 error "flag $flags is not 0x0"
10364 echo "rename overwrite a target having nlink > 1," \
10365 "changelog record has flags of $flags"
10367 # rename doesn't overwrite a target (changelog flag 0x0)
10368 touch $DIR/$tdir/foo_161c
10369 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10370 $LFS changelog $MDT0 | grep RENME
10371 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10372 $LFS changelog_clear $MDT0 $USER 0
10373 if [ x$flags != "x0x0" ]; then
10374 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10376 error "flag $flags is not 0x0"
10378 echo "rename doesn't overwrite a target," \
10379 "changelog record has flags of $flags"
10381 # define CLF_UNLINK_LAST 0x0001
10382 # unlink a file having nlink = 1 (changelog flag 0x1)
10383 rm -f $DIR/$tdir/foo2_161c
10384 $LFS changelog $MDT0 | grep UNLNK
10385 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10386 $LFS changelog_clear $MDT0 $USER 0
10387 if [ x$flags != "x0x1" ]; then
10388 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10390 error "flag $flags is not 0x1"
10392 echo "unlink a file having nlink = 1," \
10393 "changelog record has flags of $flags"
10395 # unlink a file having nlink > 1 (changelog flag 0x0)
10396 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10397 rm -f $DIR/$tdir/foobar_161c
10398 $LFS changelog $MDT0 | grep UNLNK
10399 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10400 $LFS changelog_clear $MDT0 $USER 0
10401 if [ x$flags != "x0x0" ]; then
10402 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10404 error "flag $flags is not 0x0"
10406 echo "unlink a file having nlink > 1," \
10407 "changelog record has flags of $flags"
10408 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10410 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10417 local path=$(${LFS} fid2path $*)
10420 if [ $RC -ne 0 ]; then
10421 err17935 "path looked up of $expected failed. Error $RC"
10423 elif [ "${path}" != "${expected}" ]; then
10424 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10427 echo "fid $fid resolves to path $path (expected $expected)"
10431 # Make changes to filesystem
10432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10433 test_mkdir -p -c1 $DIR/$tdir/d2
10434 touch $DIR/$tdir/d2/$tfile
10435 touch $DIR/$tdir/d2/x1
10436 touch $DIR/$tdir/d2/x2
10437 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10438 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10440 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10441 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10442 error "check path $tdir/d2/$tfile failed"
10445 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10446 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10447 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10448 error "check path $tdir/d2/p/q/r/slink failed"
10450 # softlink to wrong file
10451 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10452 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10453 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10454 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10457 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10458 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10459 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10460 # fid2path dir/fsname should both work
10461 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10462 error "check path $tdir/d2/a/b/c/new_file failed"
10463 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10464 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10466 # hardlink count: check that there are 2 links
10467 # Doesnt work with CMD yet: 17935
10468 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10469 err17935 "expected 2 links"
10471 # hardlink indexing: remove the first link
10472 rm $DIR/$tdir/d2/p/q/r/hlink
10473 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10474 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10478 run_test 162 "path lookup sanity"
10481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10485 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10486 error "create striped dir failed"
10488 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10489 tail -n 1 | awk '{print $2}')
10490 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10492 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10493 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10496 for ((i=0;i<5;i++)); do
10497 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10498 error "get fid for f$i failed"
10499 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10500 error "check path $tdir/striped_dir/f$i failed"
10502 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10503 error "get fid for d$i failed"
10504 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10505 error "check path $tdir/striped_dir/d$i failed"
10510 run_test 162b "striped directory path lookup sanity"
10513 # do directio so as not to populate the page cache
10514 log "creating a 10 Mb file"
10515 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10516 log "starting reads"
10517 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10518 log "truncating the file"
10519 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10521 kill %+ || true # reads might have finished
10522 echo "wait until dd is finished"
10524 log "removing the temporary file"
10525 rm -rf $DIR/$tfile || error "tmp file removal failed"
10527 run_test 169 "parallel read and truncate should not deadlock"
10530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10531 $LCTL clear # bug 18514
10532 $LCTL debug_daemon start $TMP/${tfile}_log_good
10534 $LCTL debug_daemon stop
10535 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10536 error "sed failed to read log_good"
10538 $LCTL debug_daemon start $TMP/${tfile}_log_good
10540 $LCTL debug_daemon stop
10542 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10543 error "lctl df log_bad failed"
10545 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10546 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10548 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10549 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10551 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10552 error "bad_line good_line1 good_line2 are empty"
10554 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10555 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10556 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10558 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10559 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10560 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10562 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10563 error "bad_line_new good_line_new are empty"
10565 local expected_good=$((good_line1 + good_line2*2))
10567 rm -f $TMP/${tfile}*
10568 # LU-231, short malformed line may not be counted into bad lines
10569 if [ $bad_line -ne $bad_line_new ] &&
10570 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10571 error "expected $bad_line bad lines, but got $bad_line_new"
10575 if [ $expected_good -ne $good_line_new ]; then
10576 error "expected $expected_good good lines, but got $good_line_new"
10581 run_test 170 "test lctl df to handle corrupted log ====================="
10583 test_171() { # bug20592
10584 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10585 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10586 $LCTL set_param fail_loc=0x50e
10587 $LCTL set_param fail_val=3000
10588 multiop_bg_pause $DIR/$tfile O_s || true
10590 kill -USR1 $MULTIPID
10594 if dmesg | grep "recursive fault"; then
10595 error "caught a recursive fault"
10597 $LCTL set_param fail_loc=0
10600 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10602 # it would be good to share it with obdfilter-survey/iokit-libecho code
10603 setup_obdecho_osc () {
10606 local obdfilter_name=$2
10607 echo "Creating new osc for $obdfilter_name on $ost_nid"
10608 # make sure we can find loopback nid
10609 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10611 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10612 ${obdfilter_name}_osc_UUID || rc=2; }
10613 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10614 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10618 cleanup_obdecho_osc () {
10619 local obdfilter_name=$1
10620 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10621 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10628 local pages=${3:-64}
10633 local obd_size=$(get_obd_size $node $OBD)
10634 local page_size=$(get_page_size $node)
10635 if [[ -n "$obd_size" ]]; then
10636 local new_count=$((obd_size / (pages * page_size / 1024)))
10637 [[ $new_count -ge $count ]] || count=$new_count
10640 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10641 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10643 if [ $rc -eq 0 ]; then
10644 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10645 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10647 echo "New object id is $id"
10648 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10650 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10651 "test_brw $count w v $pages $id" || rc=4; }
10652 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10654 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10655 "cleanup" || rc=5; }
10656 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10657 "detach" || rc=6; }
10658 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10664 remote_ost_nodsh && skip "remote OST with nodsh" && return
10666 local rmmod_local=0
10668 if ! module_loaded obdecho; then
10669 load_module obdecho/obdecho
10673 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10674 local host=$(lctl get_param -n osc.$osc.import |
10675 awk '/current_connection:/ {print $2}' )
10676 local target=$(lctl get_param -n osc.$osc.import |
10677 awk '/target:/ {print $2}' )
10678 target=${target%_UUID}
10680 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10681 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10682 [[ -n $target ]] && cleanup_obdecho_osc $target
10683 [ $rmmod_local -eq 1 ] && rmmod obdecho
10686 run_test 180a "test obdecho on osc"
10689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10690 remote_ost_nodsh && skip "remote OST with nodsh" && return
10692 local rmmod_remote=0
10694 do_facet ost1 "lsmod | grep -q obdecho || " \
10695 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10696 "modprobe obdecho; }" && rmmod_remote=1
10697 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10698 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10699 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10702 run_test 180b "test obdecho directly on obdfilter"
10704 test_180c() { # LU-2598
10705 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10706 remote_ost_nodsh && skip "remote OST with nodsh" && return
10707 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10708 skip "Need MDS version at least 2.4.0" && return
10711 local rmmod_remote=false
10712 local pages=16384 # 64MB bulk I/O RPC size
10715 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10716 rmmod_remote=true || error "failed to load module obdecho"
10718 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10720 if [ -n "$target" ]; then
10721 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10723 echo "there is no obdfilter target on ost1"
10726 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10729 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10731 test_181() { # bug 22177
10732 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10733 # create enough files to index the directory
10734 createmany -o $DIR/$tdir/foobar 4000
10735 # print attributes for debug purpose
10738 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10740 # remove the files & current working dir
10741 unlinkmany $DIR/$tdir/foobar 4000
10743 kill -USR1 $MULTIPID
10745 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10748 run_test 181 "Test open-unlinked dir ========================"
10751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10752 # disable MDC RPC lock wouldn't crash client
10756 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10757 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10758 $LCTL set_param fail_loc=0x804
10760 for (( i=0; i < $tcount; i++ )) ; do
10761 mkdir $DIR/$tdir/$i
10762 createmany -o $DIR/$tdir/$i/f- $fcount &
10766 for (( i=0; i < $tcount; i++ )) ; do
10767 unlinkmany $DIR/$tdir/$i/f- $fcount &
10773 $LCTL set_param fail_loc=0
10775 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10777 test_183() { # LU-2275
10778 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10779 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10780 skip "Need MDS version at least 2.3.56" && return
10782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10783 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10784 echo aaa > $DIR/$tdir/$tfile
10786 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10787 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10789 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10790 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10792 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10794 # Flush negative dentry cache
10795 touch $DIR/$tdir/$tfile
10797 # We are not checking for any leaked references here, they'll
10798 # become evident next time we do cleanup with module unload.
10801 run_test 183 "No crash or request leak in case of strange dispositions ========"
10803 # test suite 184 is for LU-2016, LU-2017
10805 check_swap_layouts_support && return 0
10807 dir0=$DIR/$tdir/$testnum
10808 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10813 $SETSTRIPE -c1 $file1
10815 $SETSTRIPE -c2 $file2
10817 gen1=$($GETSTRIPE -g $file1)
10818 gen2=$($GETSTRIPE -g $file2)
10820 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10821 gen=$($GETSTRIPE -g $file1)
10822 [[ $gen1 != $gen ]] ||
10823 "Layout generation on $file1 does not change"
10824 gen=$($GETSTRIPE -g $file2)
10825 [[ $gen2 != $gen ]] ||
10826 "Layout generation on $file2 does not change"
10828 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10829 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10831 run_test 184a "Basic layout swap"
10834 check_swap_layouts_support && return 0
10836 dir0=$DIR/$tdir/$testnum
10837 mkdir -p $dir0 || error "creating dir $dir0"
10844 $SETSTRIPE -c1 $file1
10845 $SETSTRIPE -c2 $file2
10846 $SETSTRIPE -c1 $file3
10847 chown $RUNAS_ID $file3
10848 gen1=$($GETSTRIPE -g $file1)
10849 gen2=$($GETSTRIPE -g $file2)
10851 $LFS swap_layouts $dir1 $dir2 &&
10852 error "swap of directories layouts should fail"
10853 $LFS swap_layouts $dir1 $file1 &&
10854 error "swap of directory and file layouts should fail"
10855 $RUNAS $LFS swap_layouts $file1 $file2 &&
10856 error "swap of file we cannot write should fail"
10857 $LFS swap_layouts $file1 $file3 &&
10858 error "swap of file with different owner should fail"
10859 /bin/true # to clear error code
10861 run_test 184b "Forbidden layout swap (will generate errors)"
10864 check_swap_layouts_support && return 0
10866 local dir0=$DIR/$tdir/$testnum
10867 mkdir -p $dir0 || error "creating dir $dir0"
10869 local ref1=$dir0/ref1
10870 local ref2=$dir0/ref2
10871 local file1=$dir0/file1
10872 local file2=$dir0/file2
10873 # create a file large enough for the concurent test
10874 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10875 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10876 echo "ref file size: ref1($(stat -c %s $ref1))," \
10877 "ref2($(stat -c %s $ref2))"
10880 dd if=$ref1 of=$file1 bs=16k &
10883 # Make sure dd starts to copy file
10884 while [ ! -f $file1 ]; do sleep 0.1; done
10886 $LFS swap_layouts $file1 $file2
10889 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10890 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10892 # how many bytes copied before swapping layout
10893 local copied=$(stat -c %s $file2)
10894 local remaining=$(stat -c %s $ref1)
10895 remaining=$((remaining - copied))
10896 echo "Copied $copied bytes before swapping layout..."
10898 cmp -n $copied $file1 $ref2 | grep differ &&
10899 error "Content mismatch [0, $copied) of ref2 and file1"
10900 cmp -n $copied $file2 $ref1 ||
10901 error "Content mismatch [0, $copied) of ref1 and file2"
10902 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10903 error "Content mismatch [$copied, EOF) of ref1 and file1"
10906 rm -f $ref1 $ref2 $file1 $file2
10908 run_test 184c "Concurrent write and layout swap"
10911 check_swap_layouts_support && return 0
10912 [ -z "$(which getfattr 2>/dev/null)" ] &&
10913 skip "no getfattr command" && return 0
10915 local file1=$DIR/$tdir/$tfile-1
10916 local file2=$DIR/$tdir/$tfile-2
10917 local file3=$DIR/$tdir/$tfile-3
10921 mkdir -p $DIR/$tdir
10922 touch $file1 || error "create $file1 failed"
10923 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10924 error "create $file2 failed"
10925 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10926 error "create $file3 failed"
10927 lovea1=$($LFS getstripe $file1 | sed 1d)
10929 $LFS swap_layouts $file2 $file3 ||
10930 error "swap $file2 $file3 layouts failed"
10931 $LFS swap_layouts $file1 $file2 ||
10932 error "swap $file1 $file2 layouts failed"
10934 lovea2=$($LFS getstripe $file2 | sed 1d)
10935 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10937 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10938 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10940 run_test 184d "allow stripeless layouts swap"
10943 test_185() { # LU-2441
10944 # LU-3553 - no volatile file support in old servers
10945 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10946 { skip "Need MDS version at least 2.3.60"; return 0; }
10948 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10949 touch $DIR/$tdir/spoo
10950 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10951 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10952 error "cannot create/write a volatile file"
10953 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10954 error "FID is still valid after close"
10956 multiop_bg_pause $DIR/$tdir vVw4096_c
10963 # assume that the next FID for this client is sequential, since stdout
10964 # is unfortunately eaten by multiop_bg_pause
10965 local n=$((${fidv[1]} + 1))
10966 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10967 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10968 error "FID is missing before close"
10969 kill -USR1 $multi_pid
10970 # 1 second delay, so if mtime change we will see it
10972 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10973 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10975 run_test 185 "Volatile file support"
10978 local dir0=$DIR/$tdir/$testnum
10979 mkdir -p $dir0 || error "creating dir $dir0"
10981 local file=$dir0/file1
10982 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10983 local dv1=$($LFS data_version $file)
10984 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10985 local dv2=$($LFS data_version $file)
10986 [[ $dv1 != $dv2 ]] ||
10987 error "data version did not change on write $dv1 == $dv2"
10992 run_test 187a "Test data version change"
10995 local dir0=$DIR/$tdir/$testnum
10996 mkdir -p $dir0 || error "creating dir $dir0"
10998 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10999 [[ ${DV[0]} != ${DV[1]} ]] ||
11000 error "data version did not change on write"\
11001 " ${DV[0]} == ${DV[1]}"
11006 run_test 187b "Test data version change on volatile file"
11009 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11010 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11012 local POOL=${POOL:-cea1}
11013 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11014 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11017 local last_ost=$(($OSTCOUNT - 1))
11019 local ost_list=$(seq $first_ost $ost_step $last_ost)
11020 local ost_range="$first_ost $last_ost $ost_step"
11021 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11022 local file_dir=$POOL_ROOT/file_tst
11026 # former test_200a test_200b
11027 pool_add $POOL || { rc=$? ; break; }
11028 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11029 # former test_200c test_200d
11030 mkdir -p $test_path
11031 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11032 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11033 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11034 || { rc=$? ; break; }
11035 # former test_200e test_200f
11036 local files=$((OSTCOUNT*3))
11037 pool_alloc_files $POOL $test_path $files "$ost_list" \
11038 || { rc=$? ; break; }
11039 pool_create_files $POOL $file_dir $files "$ost_list" \
11040 || { rc=$? ; break; }
11041 # former test_200g test_200h
11042 pool_lfs_df $POOL || { rc=$? ; break; }
11043 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11045 # former test_201a test_201b test_201c
11046 pool_remove_first_target $POOL || { rc=$? ; break; }
11048 local f=$test_path/$tfile
11049 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11050 pool_remove $POOL $f || { rc=$? ; break; }
11057 run_test 200 "OST pools"
11059 # usage: default_attr <count | size | offset>
11061 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11064 # usage: check_default_stripe_attr
11065 check_default_stripe_attr() {
11066 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11068 --stripe-count|--count)
11069 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11070 --stripe-size|--size)
11071 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11072 --stripe-index|--index)
11075 error "unknown getstripe attr '$1'"
11078 [ $ACTUAL != $EXPECTED ] &&
11079 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11083 test_mkdir -p $DIR/$tdir
11084 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11086 check_default_stripe_attr --stripe-count
11087 check_default_stripe_attr --stripe-size
11088 check_default_stripe_attr --stripe-index
11092 run_test 204a "Print default stripe attributes ================="
11095 test_mkdir -p $DIR/$tdir
11096 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11098 check_default_stripe_attr --stripe-size
11099 check_default_stripe_attr --stripe-index
11103 run_test 204b "Print default stripe size and offset ==========="
11106 test_mkdir -p $DIR/$tdir
11107 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11109 check_default_stripe_attr --stripe-count
11110 check_default_stripe_attr --stripe-index
11114 run_test 204c "Print default stripe count and offset ==========="
11117 test_mkdir -p $DIR/$tdir
11118 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11120 check_default_stripe_attr --stripe-count
11121 check_default_stripe_attr --stripe-size
11125 run_test 204d "Print default stripe count and size ============="
11128 test_mkdir -p $DIR/$tdir
11129 $SETSTRIPE -d $DIR/$tdir
11131 check_default_stripe_attr --stripe-count --raw
11132 check_default_stripe_attr --stripe-size --raw
11133 check_default_stripe_attr --stripe-index --raw
11137 run_test 204e "Print raw stripe attributes ================="
11140 test_mkdir -p $DIR/$tdir
11141 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11143 check_default_stripe_attr --stripe-size --raw
11144 check_default_stripe_attr --stripe-index --raw
11148 run_test 204f "Print raw stripe size and offset ==========="
11151 test_mkdir -p $DIR/$tdir
11152 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11154 check_default_stripe_attr --stripe-count --raw
11155 check_default_stripe_attr --stripe-index --raw
11159 run_test 204g "Print raw stripe count and offset ==========="
11162 test_mkdir -p $DIR/$tdir
11163 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11165 check_default_stripe_attr --stripe-count --raw
11166 check_default_stripe_attr --stripe-size --raw
11170 run_test 204h "Print raw stripe count and size ============="
11172 # Figure out which job scheduler is being used, if any,
11173 # or use a fake one
11174 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11175 JOBENV=SLURM_JOB_ID
11176 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11178 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11180 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11181 JOBENV=LOADL_STEP_ID
11182 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11188 verify_jobstats() {
11192 # clear old jobstats
11193 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11194 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11196 # use a new JobID for this test, or we might see an old one
11197 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11201 log "Using JobID environment variable $JOBENV=$JOBVAL"
11203 if [ $JOBENV = "FAKE_JOBID" ]; then
11204 FAKE_JOBID=$JOBVAL $cmd
11209 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11210 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11211 do_facet $FACET lctl get_param mdt.*.job_stats |
11212 grep $JOBVAL || error "No job stats found on MDT $FACET"
11214 if [ "$target" = "ost" -o "$target" = "both" ]; then
11216 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11217 grep $JOBVAL || error "No job stats found on OST $FACET"
11223 NEW_JOBENV=${1:-$OLD_JOBENV}
11224 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11225 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11228 test_205() { # Job stats
11229 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11230 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11231 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11232 skip "Server doesn't support jobstats" && return 0
11233 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11236 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11237 if [ $OLD_JOBENV != $JOBENV ]; then
11238 jobstats_set $JOBENV
11239 trap jobstats_set EXIT
11243 cmd="mkdir $DIR/$tfile"
11244 verify_jobstats "$cmd" "mdt"
11246 cmd="rm -fr $DIR/$tfile"
11247 verify_jobstats "$cmd" "mdt"
11249 cmd="mknod $DIR/$tfile c 1 3"
11250 verify_jobstats "$cmd" "mdt"
11252 cmd="rm -f $DIR/$tfile"
11253 verify_jobstats "$cmd" "mdt"
11255 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11256 verify_jobstats "$cmd" "mdt"
11258 cmd="touch $DIR/$tfile"
11259 verify_jobstats "$cmd" "both"
11261 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11262 verify_jobstats "$cmd" "ost"
11264 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11265 verify_jobstats "$cmd" "ost"
11267 cmd="$TRUNCATE $DIR/$tfile 0"
11268 verify_jobstats "$cmd" "both"
11270 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11271 verify_jobstats "$cmd" "mdt"
11274 rm -f $DIR/jobstats_test_rename
11276 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11278 run_test 205 "Verify job stats"
11280 # LU-1480, LU-1773 and LU-1657
11282 mkdir -p $DIR/$tdir
11283 $SETSTRIPE -c -1 $DIR/$tdir
11284 #define OBD_FAIL_LOV_INIT 0x1403
11285 $LCTL set_param fail_loc=0xa0001403
11286 $LCTL set_param fail_val=1
11287 touch $DIR/$tdir/$tfile || true
11289 run_test 206 "fail lov_init_raid0() doesn't lbug"
11292 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11293 local fsz=`stat -c %s $DIR/$tfile`
11294 cancel_lru_locks mdc
11296 # do not return layout in getattr intent
11297 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11298 $LCTL set_param fail_loc=0x170
11299 local sz=`stat -c %s $DIR/$tfile`
11301 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11305 run_test 207a "can refresh layout at glimpse"
11308 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11309 local cksum=`md5sum $DIR/$tfile`
11310 local fsz=`stat -c %s $DIR/$tfile`
11311 cancel_lru_locks mdc
11312 cancel_lru_locks osc
11314 # do not return layout in getattr intent
11315 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11316 $LCTL set_param fail_loc=0x171
11318 # it will refresh layout after the file is opened but before read issues
11319 echo checksum is "$cksum"
11320 echo "$cksum" |md5sum -c --quiet || error "file differs"
11324 run_test 207b "can refresh layout at open"
11327 # FIXME: in this test suite, only RD lease is used. This is okay
11328 # for now as only exclusive open is supported. After generic lease
11329 # is done, this test suite should be revised. - Jinshan
11331 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11332 { skip "Need MDS version at least 2.4.52"; return 0; }
11333 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11335 echo "==== test 1: verify get lease work"
11336 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11338 echo "==== test 2: verify lease can be broken by upcoming open"
11339 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11343 $MULTIOP $DIR/$tfile oO_RDONLY:c
11344 kill -USR1 $PID && wait $PID || error "break lease error"
11346 echo "==== test 3: verify lease can't be granted if an open already exists"
11347 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11351 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11352 kill -USR1 $PID && wait $PID || error "open file error"
11354 echo "==== test 4: lease can sustain over recovery"
11355 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11361 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11363 echo "==== test 5: lease broken can't be regained by replay"
11364 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11368 # open file to break lease and then recovery
11369 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11372 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11376 run_test 208 "Exclusive open"
11379 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11380 skip_env "must have disp_stripe" && return
11383 sync; sleep 5; sync;
11385 echo 3 > /proc/sys/vm/drop_caches
11386 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11388 # open/close 500 times
11389 for i in $(seq 500); do
11393 echo 3 > /proc/sys/vm/drop_caches
11394 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11396 echo "before: $req_before, after: $req_after"
11397 [ $((req_after - req_before)) -ge 300 ] &&
11398 error "open/close requests are not freed"
11401 run_test 209 "read-only open/close requests should be freed promptly"
11405 size=$((size % 8192 + 1))
11406 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11407 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11408 rm -f $DIR/f212 $DIR/f212.xyz
11410 run_test 212 "Sendfile test ============================================"
11413 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11414 cancel_lru_locks osc
11415 lctl set_param fail_loc=0x8000040f
11416 # generate a read lock
11417 cat $DIR/$tfile > /dev/null
11418 # write to the file, it will try to cancel the above read lock.
11419 cat /etc/hosts >> $DIR/$tfile
11421 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11423 test_214() { # for bug 20133
11424 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11425 for (( i=0; i < 340; i++ )) ; do
11426 touch $DIR/$tdir/d214c/a$i
11429 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11430 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11431 ls $DIR/d214c || error "ls $DIR/d214c failed"
11432 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11433 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11435 run_test 214 "hash-indexed directory test - bug 20133"
11437 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11438 create_lnet_proc_files() {
11439 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11440 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11442 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11443 rm -f "$TMP/lnet_$1.sys_tmp"
11446 # counterpart of create_lnet_proc_files
11447 remove_lnet_proc_files() {
11448 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11451 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11452 # 3rd arg as regexp for body
11453 check_lnet_proc_stats() {
11454 local l=$(cat "$TMP/lnet_$1" |wc -l)
11455 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11457 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11460 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11461 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11462 # optional and can be regexp for 2nd line (lnet.routes case)
11463 check_lnet_proc_entry() {
11464 local blp=2 # blp stands for 'position of 1st line of body'
11465 [ -z "$5" ] || blp=3 # lnet.routes case
11467 local l=$(cat "$TMP/lnet_$1" |wc -l)
11468 # subtracting one from $blp because the body can be empty
11469 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11471 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11472 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11474 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11475 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11477 # bail out if any unexpected line happened
11478 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11479 [ "$?" != 0 ] || error "$2 misformatted"
11482 test_215() { # for bugs 18102, 21079, 21517
11483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11484 local N='(0|[1-9][0-9]*)' # non-negative numeric
11485 local P='[1-9][0-9]*' # positive numeric
11486 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11487 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11488 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11489 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11491 local L1 # regexp for 1st line
11492 local L2 # regexp for 2nd line (optional)
11493 local BR # regexp for the rest (body)
11495 # lnet.stats should look as 11 space-separated non-negative numerics
11496 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11497 create_lnet_proc_files "stats"
11498 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11499 remove_lnet_proc_files "stats"
11501 # lnet.routes should look like this:
11502 # Routing disabled/enabled
11503 # net hops priority state router
11504 # where net is a string like tcp0, hops > 0, priority >= 0,
11505 # state is up/down,
11506 # router is a string like 192.168.1.1@tcp2
11507 L1="^Routing (disabled|enabled)$"
11508 L2="^net +hops +priority +state +router$"
11509 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11510 create_lnet_proc_files "routes"
11511 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11512 remove_lnet_proc_files "routes"
11514 # lnet.routers should look like this:
11515 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11516 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11517 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11518 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11519 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11520 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11521 create_lnet_proc_files "routers"
11522 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11523 remove_lnet_proc_files "routers"
11525 # lnet.peers should look like this:
11526 # nid refs state last max rtr min tx min queue
11527 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11528 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11529 # numeric (0 or >0 or <0), queue >= 0.
11530 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11531 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11532 create_lnet_proc_files "peers"
11533 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11534 remove_lnet_proc_files "peers"
11536 # lnet.buffers should look like this:
11537 # pages count credits min
11538 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11539 L1="^pages +count +credits +min$"
11540 BR="^ +$N +$N +$I +$I$"
11541 create_lnet_proc_files "buffers"
11542 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11543 remove_lnet_proc_files "buffers"
11545 # lnet.nis should look like this:
11546 # nid status alive refs peer rtr max tx min
11547 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11548 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11549 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11550 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11551 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11552 create_lnet_proc_files "nis"
11553 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11554 remove_lnet_proc_files "nis"
11556 # can we successfully write to lnet.stats?
11557 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11558 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11560 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11562 test_216() { # bug 20317
11563 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11564 remote_ost_nodsh && skip "remote OST with nodsh" && return
11567 local facets=$(get_facets OST)
11568 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11570 save_lustre_params client "osc.*.contention_seconds" > $p
11571 save_lustre_params $facets \
11572 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11573 save_lustre_params $facets \
11574 "ldlm.namespaces.filter-*.contended_locks" >> $p
11575 save_lustre_params $facets \
11576 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11579 # agressive lockless i/o settings
11580 for node in $(osts_nodes); do
11581 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'
11583 lctl set_param -n osc.*.contention_seconds 60
11585 $DIRECTIO write $DIR/$tfile 0 10 4096
11586 $CHECKSTAT -s 40960 $DIR/$tfile
11588 # disable lockless i/o
11589 for node in $(osts_nodes); do
11590 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'
11592 lctl set_param -n osc.*.contention_seconds 0
11595 dd if=/dev/zero of=$DIR/$tfile count=0
11596 $CHECKSTAT -s 0 $DIR/$tfile
11598 restore_lustre_params <$p
11602 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11604 test_217() { # bug 22430
11605 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11609 for node in $(nodes_list); do
11610 nid=$(host_nids_address $node $NETTYPE)
11611 if [[ $nid = *-* ]] ; then
11612 echo "lctl ping $nid@$NETTYPE"
11613 lctl ping $nid@$NETTYPE
11615 echo "skipping $node (no hyphen detected)"
11619 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11622 # do directio so as not to populate the page cache
11623 log "creating a 10 Mb file"
11624 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11625 log "starting reads"
11626 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11627 log "truncating the file"
11628 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11630 kill %+ || true # reads might have finished
11631 echo "wait until dd is finished"
11633 log "removing the temporary file"
11634 rm -rf $DIR/$tfile || error "tmp file removal failed"
11636 run_test 218 "parallel read and truncate should not deadlock ======================="
11639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11640 # write one partial page
11641 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11642 # set no grant so vvp_io_commit_write will do sync write
11643 $LCTL set_param fail_loc=0x411
11644 # write a full page at the end of file
11645 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11647 $LCTL set_param fail_loc=0
11648 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11649 $LCTL set_param fail_loc=0x411
11650 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11653 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11654 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11656 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11658 test_220() { #LU-325
11659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11660 remote_ost_nodsh && skip "remote OST with nodsh" && return
11663 test_mkdir -p $DIR/$tdir
11664 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11665 awk '{print $2}' | sed -e 's/_UUID$//')
11668 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11669 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11670 osc.$mdtosc_proc1.prealloc_last_id)
11671 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11672 osc.$mdtosc_proc1.prealloc_next_id)
11676 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11677 #define OBD_FAIL_OST_ENOINO 0x229
11678 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11679 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11680 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11682 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11684 MDSOBJS=$((last_id - next_id))
11685 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11687 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11688 echo "OST still has $count kbytes free"
11690 echo "create $MDSOBJS files @next_id..."
11691 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11693 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11694 osc.$mdtosc_proc1.prealloc_last_id)
11695 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11696 osc.$mdtosc_proc1.prealloc_next_id)
11698 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11703 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11704 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11706 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11707 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11708 echo "unlink $MDSOBJS files @$next_id..."
11709 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11711 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11715 dd if=`which date` of=$MOUNT/date oflag=sync
11716 chmod +x $MOUNT/date
11718 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11719 $LCTL set_param fail_loc=0x80001401
11721 $MOUNT/date > /dev/null
11724 run_test 221 "make sure fault and truncate race to not cause OOM"
11727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11729 test_mkdir -p $DIR/$tdir
11730 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11731 createmany -o $DIR/$tdir/$tfile 10
11732 cancel_lru_locks mdc
11733 cancel_lru_locks osc
11734 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11735 $LCTL set_param fail_loc=0x31a
11736 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11737 $LCTL set_param fail_loc=0
11740 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11745 test_mkdir -p $DIR/$tdir
11746 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11747 createmany -o $DIR/$tdir/$tfile 10
11748 cancel_lru_locks mdc
11749 cancel_lru_locks osc
11750 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11751 $LCTL set_param fail_loc=0x31a
11752 rm -r $DIR/$tdir || "AGL for rmdir failed"
11753 $LCTL set_param fail_loc=0
11755 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11760 test_mkdir -p $DIR/$tdir
11761 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11762 createmany -o $DIR/$tdir/$tfile 10
11763 cancel_lru_locks mdc
11764 cancel_lru_locks osc
11765 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11766 $LCTL set_param fail_loc=0x31b
11767 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11768 $LCTL set_param fail_loc=0
11771 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11773 test_224a() { # LU-1039, MRP-303
11774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11775 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11776 $LCTL set_param fail_loc=0x508
11777 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11778 $LCTL set_param fail_loc=0
11781 run_test 224a "Don't panic on bulk IO failure"
11783 test_224b() { # LU-1039, MRP-303
11784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11785 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11786 cancel_lru_locks osc
11787 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11788 $LCTL set_param fail_loc=0x515
11789 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11790 $LCTL set_param fail_loc=0
11793 run_test 224b "Don't panic on bulk IO failure"
11795 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11797 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11798 if [ -z ${MDSSURVEY} ]; then
11799 skip_env "mds-survey not found" && return
11802 [ $MDSCOUNT -ge 2 ] &&
11803 skip "skipping now for more than one MDT" && return
11805 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11806 { skip "Need MDS version at least 2.2.51"; return; }
11808 local mds=$(facet_host $SINGLEMDS)
11809 local target=$(do_nodes $mds 'lctl dl' | \
11810 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11812 local cmd1="file_count=1000 thrhi=4"
11813 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11814 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11815 local cmd="$cmd1 $cmd2 $cmd3"
11817 rm -f ${TMP}/mds_survey*
11819 eval $cmd || error "mds-survey with zero-stripe failed"
11820 cat ${TMP}/mds_survey*
11821 rm -f ${TMP}/mds_survey*
11823 run_test 225a "Metadata survey sanity with zero-stripe"
11826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11828 if [ -z ${MDSSURVEY} ]; then
11829 skip_env "mds-survey not found" && return
11831 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11832 { skip "Need MDS version at least 2.2.51"; return; }
11834 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11835 skip_env "Need to mount OST to test" && return
11838 [ $MDSCOUNT -ge 2 ] &&
11839 skip "skipping now for more than one MDT" && return
11840 local mds=$(facet_host $SINGLEMDS)
11841 local target=$(do_nodes $mds 'lctl dl' | \
11842 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11844 local cmd1="file_count=1000 thrhi=4"
11845 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11846 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11847 local cmd="$cmd1 $cmd2 $cmd3"
11849 rm -f ${TMP}/mds_survey*
11851 eval $cmd || error "mds-survey with stripe_count failed"
11852 cat ${TMP}/mds_survey*
11853 rm -f ${TMP}/mds_survey*
11855 run_test 225b "Metadata survey sanity with stripe_count = 1"
11857 mcreate_path2fid () {
11863 local path=$DIR/$tdir/$name
11868 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11869 error "cannot create $desc"
11871 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11873 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11875 fid_path=$($LFS fid2path $MOUNT $fid)
11877 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11879 [ "$path" == "$fid_path" ] ||
11880 error "fid2path returned $fid_path, expected $path"
11882 echo "pass with $path and $fid"
11887 mkdir -p $DIR/$tdir
11889 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11890 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11891 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11892 mcreate_path2fid 0040666 0 0 dir "directory"
11893 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11894 mcreate_path2fid 0100666 0 0 file "regular file"
11895 mcreate_path2fid 0120666 0 0 link "symbolic link"
11896 mcreate_path2fid 0140666 0 0 sock "socket"
11898 run_test 226a "call path2fid and fid2path on files of all type"
11901 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11905 mkdir -p $DIR/$tdir
11906 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11907 error "create remote directory failed"
11908 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11909 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11910 "character special file (null)"
11911 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11912 "character special file (no device)"
11913 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11914 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11915 "block special file (loop)"
11916 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11917 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11918 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11920 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11922 # LU-1299 Executing or running ldd on a truncated executable does not
11923 # cause an out-of-memory condition.
11925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11926 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11927 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11928 chmod +x $MOUNT/date
11930 $MOUNT/date > /dev/null
11931 ldd $MOUNT/date > /dev/null
11934 run_test 227 "running truncated executable does not cause OOM"
11936 # LU-1512 try to reuse idle OI blocks
11938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11939 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11940 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11941 skip "non-ldiskfs backend" && return
11943 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11944 local myDIR=$DIR/$tdir
11947 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11948 $LCTL set_param fail_loc=0x80001002
11949 createmany -o $myDIR/t- 10000
11950 $LCTL set_param fail_loc=0
11951 # The guard is current the largest FID holder
11953 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11955 local IDX=$(($SEQ % 64))
11957 do_facet $SINGLEMDS sync
11958 # Make sure journal flushed.
11960 local blk1=$(do_facet $SINGLEMDS \
11961 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11962 grep Blockcount | awk '{print $4}')
11964 # Remove old files, some OI blocks will become idle.
11965 unlinkmany $myDIR/t- 10000
11966 # Create new files, idle OI blocks should be reused.
11967 createmany -o $myDIR/t- 2000
11968 do_facet $SINGLEMDS sync
11969 # Make sure journal flushed.
11971 local blk2=$(do_facet $SINGLEMDS \
11972 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11973 grep Blockcount | awk '{print $4}')
11975 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11977 run_test 228a "try to reuse idle OI blocks"
11980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11982 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11983 skip "non-ldiskfs backend" && return
11985 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11986 local myDIR=$DIR/$tdir
11989 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11990 $LCTL set_param fail_loc=0x80001002
11991 createmany -o $myDIR/t- 10000
11992 $LCTL set_param fail_loc=0
11993 # The guard is current the largest FID holder
11995 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11997 local IDX=$(($SEQ % 64))
11999 do_facet $SINGLEMDS sync
12000 # Make sure journal flushed.
12002 local blk1=$(do_facet $SINGLEMDS \
12003 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12004 grep Blockcount | awk '{print $4}')
12006 # Remove old files, some OI blocks will become idle.
12007 unlinkmany $myDIR/t- 10000
12010 stop $SINGLEMDS || error "Fail to stop MDT."
12012 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12014 df $MOUNT || error "Fail to df."
12015 # Create new files, idle OI blocks should be reused.
12016 createmany -o $myDIR/t- 2000
12017 do_facet $SINGLEMDS sync
12018 # Make sure journal flushed.
12020 local blk2=$(do_facet $SINGLEMDS \
12021 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12022 grep Blockcount | awk '{print $4}')
12024 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12026 run_test 228b "idle OI blocks can be reused after MDT restart"
12030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12031 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12032 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12033 skip "non-ldiskfs backend" && return
12035 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12036 local myDIR=$DIR/$tdir
12039 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12040 $LCTL set_param fail_loc=0x80001002
12041 # 20000 files can guarantee there are index nodes in the OI file
12042 createmany -o $myDIR/t- 20000
12043 $LCTL set_param fail_loc=0
12044 # The guard is current the largest FID holder
12046 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12048 local IDX=$(($SEQ % 64))
12050 do_facet $SINGLEMDS sync
12051 # Make sure journal flushed.
12053 local blk1=$(do_facet $SINGLEMDS \
12054 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12055 grep Blockcount | awk '{print $4}')
12057 # Remove old files, some OI blocks will become idle.
12058 unlinkmany $myDIR/t- 20000
12060 # The OI file should become empty now
12062 # Create new files, idle OI blocks should be reused.
12063 createmany -o $myDIR/t- 2000
12064 do_facet $SINGLEMDS sync
12065 # Make sure journal flushed.
12067 local blk2=$(do_facet $SINGLEMDS \
12068 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12069 grep Blockcount | awk '{print $4}')
12071 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12073 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12075 test_229() { # LU-2482, LU-3448
12076 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12077 skip "No HSM support on MDS of $(get_lustre_version)," \
12078 "need 2.4.53 at least" && return
12079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12080 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12084 # Create a file with a released layout and stripe count 2.
12085 $MULTIOP $DIR/$tfile H2c ||
12086 error "failed to create file with released layout"
12088 $GETSTRIPE -v $DIR/$tfile
12090 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12091 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12093 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12094 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12095 stat $DIR/$tfile || error "failed to stat released file"
12097 chown $RUNAS_ID $DIR/$tfile ||
12098 error "chown $RUNAS_ID $DIR/$tfile failed"
12100 chgrp $RUNAS_ID $DIR/$tfile ||
12101 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12103 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12104 rm $DIR/$tfile || error "failed to remove released file"
12106 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12110 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12113 mkdir -p $DIR/$tdir/test_230_local
12114 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12115 [ $mdt_idx -ne 0 ] &&
12116 error "create local directory on wrong MDT $mdt_idx"
12118 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12119 error "create remote directory failed"
12120 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12121 [ $mdt_idx -ne $MDTIDX ] &&
12122 error "create remote directory on wrong MDT $mdt_idx"
12124 createmany -o $DIR/$tdir/test_230/t- 10 ||
12125 error "create files on remote directory failed"
12126 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12127 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12128 rm -r $DIR/$tdir || error "unlink remote directory failed"
12130 run_test 230a "Create remote directory and files under the remote directory"
12133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12134 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12141 local migrate_dir=$DIR/$tdir/migrate_dir
12142 local other_dir=$DIR/$tdir/other_dir
12144 mkdir -p $migrate_dir
12145 mkdir -p $other_dir
12146 for ((i=0; i<10; i++)); do
12147 mkdir -p $migrate_dir/dir_${i}
12148 createmany -o $migrate_dir/dir_${i}/f 10 ||
12149 error "create files under remote dir failed $i"
12152 cp /etc/passwd $migrate_dir/$tfile
12153 cp /etc/passwd $other_dir/$tfile
12154 chattr +SAD $migrate_dir
12155 chattr +SAD $migrate_dir/$tfile
12157 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12158 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12159 local old_dir_mode=$(stat -c%f $migrate_dir)
12160 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12162 mkdir -p $migrate_dir/dir_default_stripe2
12163 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12164 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12166 mkdir -p $other_dir
12167 ln $migrate_dir/$tfile $other_dir/luna
12168 ln $migrate_dir/$tfile $migrate_dir/sofia
12169 ln $other_dir/$tfile $migrate_dir/david
12170 ln -s $migrate_dir/$tfile $other_dir/zachary
12171 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12172 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12174 $LFS mv -v -M $MDTIDX $migrate_dir ||
12175 error "migrate remote dir error"
12177 echo "migratate to MDT1, then checking.."
12178 for ((i=0; i<10; i++)); do
12179 for file in $(find $migrate_dir/dir_${i}); do
12180 mdt_index=$($LFS getstripe -M $file)
12181 [ $mdt_index == $MDTIDX ] ||
12182 error "$file is not on MDT${MDTIDX}"
12186 # the multiple link file should still in MDT0
12187 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12188 [ $mdt_index == 0 ] ||
12189 error "$file is not on MDT${MDTIDX}"
12191 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12192 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12193 error " expect $old_dir_flag get $new_dir_flag"
12195 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12196 [ "$old_file_flag" = "$new_file_flag" ] ||
12197 error " expect $old_file_flag get $new_file_flag"
12199 local new_dir_mode=$(stat -c%f $migrate_dir)
12200 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12201 error "expect mode $old_dir_mode get $new_dir_mode"
12203 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12204 [ "$old_file_mode" = "$new_file_mode" ] ||
12205 error "expect mode $old_file_mode get $new_file_mode"
12207 diff /etc/passwd $migrate_dir/$tfile ||
12208 error "$tfile different after migration"
12210 diff /etc/passwd $other_dir/luna ||
12211 error "luna different after migration"
12213 diff /etc/passwd $migrate_dir/sofia ||
12214 error "sofia different after migration"
12216 diff /etc/passwd $migrate_dir/david ||
12217 error "david different after migration"
12219 diff /etc/passwd $other_dir/zachary ||
12220 error "zachary different after migration"
12222 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12223 error "${tfile}_ln different after migration"
12225 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12226 error "${tfile}_ln_other different after migration"
12228 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12229 [ $stripe_count = 2 ] ||
12230 error "dir strpe_count $d != 2 after migration."
12232 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12233 [ $stripe_count = 2 ] ||
12234 error "file strpe_count $d != 2 after migration."
12236 #migrate back to MDT0
12238 $LFS mv -v -M $MDTIDX $migrate_dir ||
12239 error "migrate remote dir error"
12241 echo "migrate back to MDT0, checking.."
12242 for file in $(find $migrate_dir); do
12243 mdt_index=$($LFS getstripe -M $file)
12244 [ $mdt_index == $MDTIDX ] ||
12245 error "$file is not on MDT${MDTIDX}"
12248 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12249 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12250 error " expect $old_dir_flag get $new_dir_flag"
12252 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12253 [ "$old_file_flag" = "$new_file_flag" ] ||
12254 error " expect $old_file_flag get $new_file_flag"
12256 local new_dir_mode=$(stat -c%f $migrate_dir)
12257 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12258 error "expect mode $old_dir_mode get $new_dir_mode"
12260 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12261 [ "$old_file_mode" = "$new_file_mode" ] ||
12262 error "expect mode $old_file_mode get $new_file_mode"
12264 diff /etc/passwd ${migrate_dir}/$tfile ||
12265 error "$tfile different after migration"
12267 diff /etc/passwd ${other_dir}/luna ||
12268 error "luna different after migration"
12270 diff /etc/passwd ${migrate_dir}/sofia ||
12271 error "sofia different after migration"
12273 diff /etc/passwd ${other_dir}/zachary ||
12274 error "zachary different after migration"
12276 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12277 error "${tfile}_ln different after migration"
12279 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12280 error "${tfile}_ln_other different after migration"
12282 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12283 [ $stripe_count = 2 ] ||
12284 error "dir strpe_count $d != 2 after migration."
12286 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12287 [ $stripe_count = 2 ] ||
12288 error "file strpe_count $d != 2 after migration."
12290 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12292 run_test 230b "migrate directory"
12295 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12296 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12301 #If migrating directory fails in the middle, all entries of
12302 #the directory is still accessiable.
12303 mkdir -p $DIR/$tdir
12305 createmany -o $DIR/$tdir/f 10 ||
12306 error "create files under ${tdir} failed"
12308 #failed after migrating 5 entries
12309 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12310 do_facet mds1 lctl set_param fail_loc=0x20001801
12311 do_facet mds1 lctl set_param fail_val=5
12312 local t=`ls $DIR/$tdir | wc -l`
12313 $LFS mv -M $MDTIDX $DIR/$tdir &&
12314 error "migrate should failed after 5 entries"
12315 local u=`ls $DIR/$tdir | wc -l`
12316 [ "$u" == "$t" ] || error "$u != $t during migration"
12318 for file in $(find $DIR/$tdir); do
12319 stat $file || error "stat $file failed"
12322 do_facet mds1 lctl set_param fail_loc=0
12323 do_facet mds1 lctl set_param fail_val=0
12325 $LFS mv -M $MDTIDX $DIR/$tdir ||
12326 error "migrate open files should failed with open files"
12328 echo "Finish migration, then checking.."
12329 for file in $(find $DIR/$tdir); do
12330 mdt_index=$($LFS getstripe -M $file)
12331 [ $mdt_index == $MDTIDX ] ||
12332 error "$file is not on MDT${MDTIDX}"
12335 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12337 run_test 230c "check directory accessiblity if migration is failed"
12340 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12341 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12347 mkdir -p $DIR/$tdir
12349 for ((i=0; i<100; i++)); do
12350 mkdir -p $DIR/$tdir/dir_${i}
12351 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12352 error "create files under remote dir failed $i"
12355 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12357 echo "Finish migration, then checking.."
12358 for file in $(find $DIR/$tdir); do
12359 mdt_index=$($LFS getstripe -M $file)
12360 [ $mdt_index == $MDTIDX ] ||
12361 error "$file is not on MDT${MDTIDX}"
12364 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12366 run_test 230d "check migrate big directory"
12370 # For simplicity this test assumes that max_pages_per_rpc
12371 # is the same across all OSCs
12372 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12373 local bulk_size=$((max_pages * 4096))
12375 mkdir -p $DIR/$tdir
12377 # clear the OSC stats
12378 $LCTL set_param osc.*.stats=0 &>/dev/null
12380 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12381 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12382 oflag=direct &>/dev/null || error "dd failed"
12384 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12385 if [ x$nrpcs != "x1" ]; then
12386 error "found $nrpc ost_write RPCs, not 1 as expected"
12389 # Drop the OSC cache, otherwise we will read from it
12390 cancel_lru_locks osc
12392 # clear the OSC stats
12393 $LCTL set_param osc.*.stats=0 &>/dev/null
12395 # Client reads $bulk_size.
12396 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12397 iflag=direct &>/dev/null || error "dd failed"
12399 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12400 if [ x$nrpcs != "x1" ]; then
12401 error "found $nrpc ost_read RPCs, not 1 as expected"
12404 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12407 mkdir -p $DIR/$tdir
12409 for i in {0..1023}; do
12410 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12411 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12412 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12416 run_test 231b "must not assert on fully utilized OST request buffer"
12419 mkdir -p $DIR/$tdir
12420 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12421 $LCTL set_param fail_loc=0x31c
12423 # ignore dd failure
12424 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12426 $LCTL set_param fail_loc=0
12427 umount_client $MOUNT || error "umount failed"
12428 mount_client $MOUNT || error "mount failed"
12430 run_test 232 "failed lock should not block umount"
12433 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12434 { skip "Need MDS version at least 2.3.64"; return; }
12436 local fid=$($LFS path2fid $MOUNT)
12437 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12438 error "cannot access $MOUNT using its FID '$fid'"
12440 run_test 233a "checking that OBF of the FS root succeeds"
12443 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12444 { skip "Need MDS version at least 2.5.90"; return; }
12446 local fid=$($LFS path2fid $MOUNT/.lustre)
12447 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12448 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12450 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12451 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12452 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12454 run_test 233b "checking that OBF of the FS .lustre succeeds"
12457 local p="$TMP/sanityN-$TESTNAME.parameters"
12458 save_lustre_params client "llite.*.xattr_cache" > $p
12459 lctl set_param llite.*.xattr_cache 1 ||
12460 { skip "xattr cache is not supported"; return 0; }
12462 mkdir -p $DIR/$tdir || error "mkdir failed"
12463 touch $DIR/$tdir/$tfile || error "touch failed"
12464 # OBD_FAIL_LLITE_XATTR_ENOMEM
12465 $LCTL set_param fail_loc=0x1405
12466 # output of the form: attr 2 4 44 3 fc13 x86_64
12467 V=($(IFS=".-" rpm -q attr))
12468 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12469 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12470 # attr pre-2.4.44-7 had a bug with rc
12471 # LU-3703 - SLES 11 and FC13 clients have older attr
12472 getfattr -n user.attr $DIR/$tdir/$tfile &&
12473 error "getfattr should have failed with ENOMEM"
12475 skip "LU-3703: attr version $(getfattr --version) too old"
12477 $LCTL set_param fail_loc=0x0
12480 restore_lustre_params < $p
12483 run_test 234 "xattr cache should not crash on ENOMEM"
12486 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12487 skip "Need MDS version at least 2.4.52" && return
12488 flock_deadlock $DIR/$tfile
12493 124) error "process hangs on a deadlock"
12495 *) error "error executing flock_deadlock $DIR/$tfile"
12499 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12503 check_swap_layouts_support && return 0
12504 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12506 local ref1=/etc/passwd
12507 local ref2=/etc/group
12508 local file1=$DIR/$tdir/f1
12509 local file2=$DIR/$tdir/f2
12511 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12512 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12513 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12514 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12515 local fd=$(free_fd)
12516 local cmd="exec $fd<>$file2"
12519 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12520 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12523 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12528 run_test 236 "Layout swap on open unlinked file"
12530 # test to verify file handle related system calls
12531 # (name_to_handle_at/open_by_handle_at)
12532 # The new system calls are supported in glibc >= 2.14.
12535 echo "Test file_handle syscalls" > $DIR/$tfile ||
12536 error "write failed"
12537 check_fhandle_syscalls $DIR/$tfile ||
12538 error "check_fhandle_syscalls failed"
12540 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12542 # LU-4659 linkea consistency
12544 local server_version=$(lustre_version_code $SINGLEMDS)
12546 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12547 [[ $server_version -gt $(version_code 2.5.1) &&
12548 $server_version -lt $(version_code 2.5.50) ]] ||
12549 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12552 ln $DIR/$tfile $DIR/$tfile.lnk
12553 touch $DIR/$tfile.new
12554 mv $DIR/$tfile.new $DIR/$tfile
12555 local fid1=$(lfs path2fid $DIR/$tfile)
12556 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12557 local path1=$(lfs fid2path $FSNAME $fid1)
12558 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12559 local path2=$(lfs fid2path $FSNAME $fid2)
12560 [ $tfile.lnk == $path2 ] ||
12561 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12564 run_test 238 "Verify linkea consistency"
12567 local list=$(comma_list $(mdts_nodes))
12569 mkdir -p $DIR/$tdir
12570 createmany -o $DIR/$tdir/f- 5000
12571 unlinkmany $DIR/$tdir/f- 5000
12572 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12573 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12574 osc.*MDT*.sync_in_flight" | calc_sum)
12575 [ "$changes" -eq 0 ] || error "$changes not synced"
12577 run_test 239 "osp_sync test"
12580 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12582 mkdir -p $DIR/$tdir
12584 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12585 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12586 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12587 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12589 umount_client $MOUNT || error "umount failed"
12590 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12591 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12592 mount_client $MOUNT || error "failed to mount client"
12594 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12595 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12597 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12600 for LOOP in $(seq $1); do
12601 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12602 cancel_lru_locks osc
12607 for LOOP in $(seq $1); do
12608 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12609 iflag=direct 2>/dev/null
12614 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12616 cancel_lru_locks osc
12617 test_241_bio 1000 &
12622 run_test 241 "bio vs dio"
12624 cleanup_test_300() {
12628 test_striped_dir() {
12633 mkdir -p $DIR/$tdir
12635 SAVE_UMASK=$(umask)
12636 trap cleanup_test_300 RETURN EXIT
12638 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12639 $DIR/$tdir/striped_dir ||
12640 error "set striped dir error"
12642 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12643 [ "$mode" = "755" ] || error "expect 755 got $mode"
12645 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12646 if [ "$stripe_count" != "2" ]; then
12647 error "stripe_count is $stripe_count, expect 2"
12650 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12651 if [ "$stripe_index" != "$mdt_index" ]; then
12652 error "stripe_index is $stripe_index, expect $mdt_index"
12655 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12656 error "nlink error after create striped dir"
12658 mkdir $DIR/$tdir/striped_dir/a
12659 mkdir $DIR/$tdir/striped_dir/b
12661 stat $DIR/$tdir/striped_dir/a ||
12662 error "create dir under striped dir failed"
12663 stat $DIR/$tdir/striped_dir/b ||
12664 error "create dir under striped dir failed"
12666 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12667 error "nlink error after mkdir"
12669 rmdir $DIR/$tdir/striped_dir/a
12670 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12671 error "nlink error after rmdir"
12673 rmdir $DIR/$tdir/striped_dir/b
12674 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12675 error "nlink error after rmdir"
12677 rmdir $DIR/$tdir/striped_dir ||
12678 error "rmdir striped dir error"
12686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12687 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12689 test_striped_dir 0 || error "failed on striped dir on MDT0"
12690 test_striped_dir 1 || error "failed on striped dir on MDT0"
12692 run_test 300a "basic striped dir sanity test"
12695 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12696 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12702 test_mkdir $DIR/$tdir || error "mkdir fail"
12703 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12704 error "set striped dir error"
12705 for ((i=0; i<10; i++)); do
12706 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12708 touch $DIR/$tdir/striped_dir/file_$i ||
12709 error "touch error $i"
12710 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12711 [ $mtime1 -eq $mtime2 ] &&
12712 error "mtime not change after create"
12714 rm -f $DIR/$tdir/striped_dir/file_$i ||
12715 error "unlink error $i"
12716 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12717 [ $mtime2 -eq $mtime3 ] &&
12718 error "mtime did not change after unlink"
12722 run_test 300b "check ctime/mtime for striped dir"
12725 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12726 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12729 mkdir -p $DIR/$tdir
12730 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12731 error "set striped dir error"
12733 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12734 error "chown striped dir failed"
12736 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12737 error "create 5k files failed"
12739 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12741 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12745 run_test 300c "chown && check ls under striped directory"
12748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12749 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12753 mkdir -p $DIR/$tdir
12754 $SETSTRIPE -c 2 $DIR/$tdir
12756 #local striped directory
12757 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12758 error "set striped dir error"
12759 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12760 error "create 10 files failed"
12762 #remote striped directory
12763 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12764 error "set striped dir error"
12765 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12766 error "create 10 files failed"
12768 for file in $(find $DIR/$tdir); do
12769 stripe_count=$($GETSTRIPE -c $file)
12770 [ $stripe_count -eq 2 ] ||
12771 error "wrong stripe $stripe_count for $file"
12776 run_test 300d "check default stripe under striped directory"
12779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12780 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12784 mkdir -p $DIR/$tdir
12786 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12787 error "set striped dir error"
12789 touch $DIR/$tdir/striped_dir/a
12790 touch $DIR/$tdir/striped_dir/b
12791 touch $DIR/$tdir/striped_dir/c
12793 mkdir $DIR/$tdir/striped_dir/dir_a
12794 mkdir $DIR/$tdir/striped_dir/dir_b
12795 mkdir $DIR/$tdir/striped_dir/dir_c
12797 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12798 error "set striped dir under striped dir error"
12800 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12801 error "set striped dir under striped dir error"
12803 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12804 error "set striped dir under striped dir error"
12806 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12807 error "rename file under striped dir should fail"
12809 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12810 error "rename dir under striped dir should fail"
12812 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12813 error "rename dir under different stripes should fail"
12815 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12816 error "rename file under striped dir should succeed"
12818 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12819 error "rename dir under striped dir should succeed"
12823 run_test 300e "check rename under striped directory"
12826 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12827 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12832 mkdir -p $DIR/$tdir
12834 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12835 error "set striped dir error"
12837 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12838 error "set striped dir error"
12840 touch $DIR/$tdir/striped_dir/a
12841 mkdir $DIR/$tdir/striped_dir/dir_a
12842 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12843 error "create striped dir under striped dir fails"
12845 touch $DIR/$tdir/striped_dir1/b
12846 mkdir $DIR/$tdir/striped_dir1/dir_b
12847 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12848 error "create striped dir under striped dir fails"
12850 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12851 error "rename file under different striped dir should fail"
12853 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12854 error "rename dir under different striped dir should fail"
12856 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12857 error "rename striped dir under diff striped dir should fail"
12859 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12860 error "rename file under diff striped dirs fails"
12862 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12863 error "rename dir under diff striped dirs fails"
12867 run_test 300f "check rename cross striped directory"
12870 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12875 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12876 $DIR/$tdir/striped_dir ||
12877 error "set striped dir error"
12879 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12880 error "set default stripe on striped dir error"
12882 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
12883 [ $stripe_count -eq $MDSCOUNT ] ||
12884 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
12886 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12888 for dir in $(find $DIR/$tdir/striped_dir/*); do
12889 stripe_count=$($LFS getdirstripe -c $dir)
12890 [ $stripe_count -eq $MDSCOUNT ] ||
12891 error "expect $MDSCOUNT get $stripe_count for $dir"
12894 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12895 #change default stripe count to 2
12896 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12897 error "set default stripe on striped dir error"
12899 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12901 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12903 #change default stripe count to 1
12904 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
12905 error "set default stripe on striped dir error"
12907 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12908 for dir in $(find $DIR/$tdir/striped_dir/*); do
12909 stripe_count=$($LFS getdirstripe -c $dir)
12910 [ $stripe_count -eq 1 ] ||
12911 error "expect 1 get $stripe_count for $dir"
12913 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12915 run_test 300g "check default striped directory for striped directory"
12918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12919 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12925 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12926 error "set striped dir error"
12928 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
12929 error "create files under striped dir failed"
12931 # unfortunately, we need to umount to clear dir layout cache for now
12932 # once we fully implement dir layout, we can drop this
12933 umount_client $MOUNT || error "umount failed"
12934 mount_client $MOUNT || error "mount failed"
12936 #set the stripe to be unknown hash type
12937 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
12938 $LCTL set_param fail_loc=0x1901
12939 for ((i = 0; i < 10; i++)); do
12940 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
12941 error "stat f-$i failed"
12942 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
12945 touch $DIR/$tdir/striped_dir/f0 &&
12946 error "create under striped dir with unknown hash should fail"
12948 $LCTL set_param fail_loc=0
12950 umount_client $MOUNT || error "umount failed"
12951 mount_client $MOUNT || error "mount failed"
12955 run_test 300h "client handle unknown hash type striped directory"
12957 test_400a() { # LU-1606, was conf-sanity test_74
12958 local extra_flags=''
12959 local out=$TMP/$tfile
12960 local prefix=/usr/include/lustre
12963 if ! which $CC > /dev/null 2>&1; then
12964 skip_env "$CC is not installed"
12968 if ! [[ -d $prefix ]]; then
12969 # Assume we're running in tree and fixup the include path.
12970 extra_flags+=" -I$LUSTRE/../libcfs/include"
12971 extra_flags+=" -I$LUSTRE/include"
12972 extra_flags+=" -L$LUSTRE/utils"
12975 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
12976 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
12977 error "client api broken"
12980 run_test 400a "Lustre client api program can compile and link"
12982 test_400b() { # LU-1606, LU-5011
12984 local out=$TMP/$tfile
12985 local prefix=/usr/include/lustre
12987 # We use a hard coded prefix so that this test will not fail
12988 # when run in tree. There are headers in lustre/include/lustre/
12989 # that are not packaged (like lustre_idl.h) and have more
12990 # complicated include dependencies (like config.h and lnet/types.h).
12991 # Since this test about correct packaging we just skip them when
12992 # they don't exist (see below) rather than try to fixup cppflags.
12994 if ! which $CC > /dev/null 2>&1; then
12995 skip_env "$CC is not installed"
12999 for header in $prefix/*.h; do
13000 if ! [[ -f "$header" ]]; then
13004 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13005 continue # liblustreapi.h is deprecated.
13008 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13009 error "cannot compile '$header'"
13012 run_test 400b "packaged headers can be compiled"
13015 # tests that do cleanup/setup should be run at the end
13019 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13021 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13022 $LCTL set_param fail_loc=0x903
13024 cancel_lru_locks MGC
13026 FAIL_ON_ERROR=true cleanup
13027 FAIL_ON_ERROR=true setup
13029 run_test 900 "umount should not race with any mgc requeue thread"
13032 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13033 check_and_cleanup_lustre
13034 if [ "$I_MOUNTED" != "yes" ]; then
13035 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true