2 # -*- tab-width: 8; indent-tabs-mode: t; -*-
4 # Run select tests by setting ONLY, or as arguments to the script.
5 # Skip specific tests by setting EXCEPT.
7 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
11 # bug number for skipped test: 13297 2108 9789 3637 9789 3561 12622 5188
12 ALWAYS_EXCEPT=" 42a 42b 42c 42d 45 51d 68b $SANITY_EXCEPT"
13 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
15 # with LOD/OSP landing
16 # bug number for skipped tests: LU-2036
17 ALWAYS_EXCEPT=" 76 $ALWAYS_EXCEPT"
19 SRCDIR=$(cd $(dirname $0); echo $PWD)
20 export PATH=$PATH:/sbin
25 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
26 CREATETEST=${CREATETEST:-createtest}
28 LFIND=${LFIND:-"$LFS find"}
29 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
31 OPENFILE=${OPENFILE:-openfile}
32 OPENUNLINK=${OPENUNLINK:-openunlink}
33 export MULTIOP=${MULTIOP:-multiop}
34 READS=${READS:-"reads"}
35 MUNLINK=${MUNLINK:-munlink}
36 SOCKETSERVER=${SOCKETSERVER:-socketserver}
37 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
38 MEMHOG=${MEMHOG:-memhog}
39 DIRECTIO=${DIRECTIO:-directio}
40 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
41 UMOUNT=${UMOUNT:-"umount -d"}
43 CHECK_GRANT=${CHECK_GRANT:-"yes"}
44 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
45 export PARALLEL=${PARALLEL:-"no"}
47 export NAME=${NAME:-local}
54 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
55 LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b 230d"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
110 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
196 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
200 test_mkdir $DIR/$tdir ||
201 error "Create remote directory failed"
203 touch $DIR/$tdir/$tfile ||
204 error "Create file under remote directory failed"
207 error "Expect error removing in-use dir $DIR/$tdir"
209 test -d $DIR/$tdir || error "Remote directory disappeared"
211 rm -rf $DIR/$tdir || error "remove remote dir error"
213 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
216 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
217 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
218 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
219 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
220 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
222 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
225 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
226 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
227 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
228 error "$tfile does not have perm 0666 or UID $UID"
229 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
230 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
231 error "$tfile should be 0666 and owned by UID $UID"
233 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
236 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
238 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
239 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
240 error "$tfile should be owned by UID $RUNAS_ID"
241 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
242 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
243 error "$tfile should be owned by UID $RUNAS_ID"
245 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
248 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
250 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
251 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
252 error "$tfile should be owned by GID $UID"
253 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
254 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
255 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
257 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
260 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
261 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
262 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
263 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
264 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
265 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
266 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
267 error "$tdir/d/subdir should be GID $RUNAS_GID"
269 run_test 6g "Is new dir in sgid dir inheriting group?"
271 test_6h() { # bug 7331
272 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
273 touch $DIR/$tfile || error "touch failed"
274 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
275 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
276 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
277 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
278 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
280 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
283 test_mkdir $DIR/$tdir
284 $MCREATE $DIR/$tdir/$tfile
285 chmod 0666 $DIR/$tdir/$tfile
286 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
287 error "$tdir/$tfile should be mode 0666"
289 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
292 if [ ! -d $DIR/$tdir ]; then
295 $MCREATE $DIR/$tdir/$tfile
296 echo -n foo > $DIR/$tdir/$tfile
297 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
298 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
300 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
303 test_mkdir $DIR/$tdir
304 touch $DIR/$tdir/$tfile
305 chmod 0666 $DIR/$tdir/$tfile
306 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
307 error "$tfile mode not 0666"
309 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
312 test_mkdir $DIR/$tdir
313 test_mkdir $DIR/$tdir/d2
314 test_mkdir $DIR/$tdir/d2/d3
315 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
317 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
320 test_mkdir $DIR/$tdir
321 test_mkdir $DIR/$tdir/d2
322 touch $DIR/$tdir/d2/$tfile
323 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
324 error "$tdir/d2/$tfile not a file"
326 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
329 test_mkdir $DIR/$tdir
330 test_mkdir $DIR/$tdir/d2
331 chmod 0666 $DIR/$tdir/d2
332 chmod 0705 $DIR/$tdir/d2
333 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
334 error "$tdir/d2 mode not 0705"
336 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
341 chmod 0666 $DIR/$tdir/$tfile
342 chmod 0654 $DIR/$tdir/$tfile
343 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
344 error "$tdir/d2 mode not 0654"
346 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
349 test_mkdir $DIR/$tdir
350 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
352 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
353 error "$tdir/$tfile size not 0 after truncate"
355 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
358 test_mkdir $DIR/$tdir
359 touch $DIR/$tdir/$tfile
361 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
363 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
366 test_mkdir $DIR/$tdir
367 touch $DIR/$tdir/$tfile
368 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
369 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
370 error "$tdir/${tfile_2} not a file after rename"
372 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
375 test_mkdir $DIR/$tdir
376 touch $DIR/$tdir/$tfile
377 rm -rf $DIR/$tdir/$tfile
378 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
380 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
383 test_mkdir -p $DIR/$tdir
384 touch $DIR/$tdir/$tfile
385 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
387 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
388 error "$tdir/l-exist not a symlink"
389 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not referencing a file"
391 rm -f $DIR/$tdir/l-exist
392 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
394 run_test 17a "symlinks: create, remove (real) =================="
397 test_mkdir -p $DIR/$tdir
398 ln -s no-such-file $DIR/$tdir/l-dangle
400 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
401 error "$tdir/l-dangle not referencing no-such-file"
402 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing non-existent file"
404 rm -f $DIR/$tdir/l-dangle
405 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
407 run_test 17b "symlinks: create, remove (dangling) =============="
409 test_17c() { # bug 3440 - don't save failed open RPC for replay
410 test_mkdir -p $DIR/$tdir
411 ln -s foo $DIR/$tdir/$tfile
412 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
414 run_test 17c "symlinks: open dangling (should return error) ===="
417 test_mkdir -p $DIR/$tdir
418 ln -s foo $DIR/$tdir/$tfile
419 touch $DIR/$tdir/$tfile || error "creating to new symlink"
421 run_test 17d "symlinks: create dangling ========================"
424 test_mkdir -p $DIR/$tdir
425 local foo=$DIR/$tdir/$tfile
426 ln -s $foo $foo || error "create symlink failed"
427 ls -l $foo || error "ls -l failed"
428 ls $foo && error "ls not failed" || true
430 run_test 17e "symlinks: create recursive symlink (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
435 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
436 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
442 run_test 17f "symlinks: long and very long symlink name ========================"
444 # str_repeat(S, N) generate a string that is string S repeated N times
449 while [ $((n -= 1)) -ge 0 ]; do
455 # Long symlinks and LU-2241
457 test_mkdir -p $DIR/$tdir
458 local TESTS="59 60 61 4094 4095"
460 # Fix for inode size boundary in 2.1.4
461 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
464 # Patch not applied to 2.2 or 2.3 branches
465 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
466 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
469 # skip long symlink name for rhel6.5.
470 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
471 grep -q '6.5' /etc/redhat-release &>/dev/null &&
472 TESTS="59 60 61 4062 4063"
475 local SYMNAME=$(str_repeat 'x' $i)
476 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
477 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
480 run_test 17g "symlinks: really long symlink name and inode boundaries"
482 test_17h() { #bug 17378
483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
486 test_mkdir -p $DIR/$tdir
487 if [[ $MDSCOUNT -gt 1 ]]; then
488 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
492 $SETSTRIPE -c -1 $DIR/$tdir
493 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
494 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
495 touch $DIR/$tdir/$tfile || true
497 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
499 test_17i() { #bug 20018
500 remote_mds_nodsh && skip "remote MDS with nodsh" && return
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -c1 $DIR/$tdir
503 local foo=$DIR/$tdir/$tfile
505 if [[ $MDSCOUNT -gt 1 ]]; then
506 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
510 ln -s $foo $foo || error "create symlink failed"
511 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
512 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
513 ls -l $foo && error "error not detected"
516 run_test 17i "don't panic on short symlink"
518 test_17k() { #bug 22301
519 [[ -z "$(which rsync 2>/dev/null)" ]] &&
520 skip "no rsync command" && return 0
521 rsync --help | grep -q xattr ||
522 skip_env "$(rsync --version | head -n1) does not support xattrs"
523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
524 test_mkdir -p $DIR/$tdir
525 test_mkdir -p $DIR/$tdir.new
526 touch $DIR/$tdir/$tfile
527 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
528 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
529 error "rsync failed with xattrs enabled"
531 run_test 17k "symlinks: rsync with xattrs enabled ========================="
533 test_17l() { # LU-279
534 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
535 skip "no getfattr command" && return 0
537 touch $DIR/$tdir/$tfile
538 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
539 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
540 # -h to not follow symlinks. -m '' to list all the xattrs.
541 # grep to remove first line: '# file: $path'.
542 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
544 lgetxattr_size_check $path $xattr ||
545 error "lgetxattr_size_check $path $xattr failed"
549 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
553 local short_sym="0123456789"
554 local WDIR=$DIR/${tdir}m
561 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 -p $DIR/d27
1363 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1364 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1365 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1367 run_test 27f "setstripe with bad stripe size (should return error)"
1370 test_mkdir -p $DIR/d27
1371 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1372 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1373 error "$DIR/d27/fnone has object"
1375 run_test 27g "$GETSTRIPE with no objects"
1378 touch $DIR/d27/fsome || error "touch failed"
1379 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1381 run_test 27i "$GETSTRIPE with some objects"
1384 test_mkdir -p $DIR/d27
1385 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1387 run_test 27j "setstripe with bad stripe offset (should return error)"
1389 test_27k() { # bug 2844
1390 test_mkdir -p $DIR/d27
1392 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1393 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1394 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1395 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1396 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1397 dd if=/dev/zero of=$FILE bs=4k count=1
1398 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1399 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1401 run_test 27k "limit i_blksize for broken user apps ============="
1404 test_mkdir -p $DIR/d27
1405 mcreate $DIR/f27l || error "creating file"
1406 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1407 error "setstripe should have failed" || true
1409 run_test 27l "check setstripe permissions (should return error)"
1412 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1414 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1415 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1418 trap simple_cleanup_common EXIT
1419 test_mkdir -p $DIR/$tdir
1420 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1421 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1422 error "dd should fill OST0"
1424 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1426 [ $i -gt 256 ] && break
1429 touch $DIR/$tdir/f27m_$i
1430 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1431 error "OST0 was full but new created file still use it"
1433 touch $DIR/$tdir/f27m_$i
1434 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1435 error "OST0 was full but new created file still use it"
1436 simple_cleanup_common
1438 run_test 27m "create file while OST0 was full =================="
1441 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1445 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1446 # if the OST isn't full anymore.
1448 local OSTIDX=${1:-""}
1450 local list=$(comma_list $(osts_nodes))
1451 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1453 do_nodes $list lctl set_param fail_loc=0
1454 sync # initiate all OST_DESTROYs from MDS to OST
1458 exhaust_precreations() {
1461 local FAILIDX=${3:-$OSTIDX}
1463 test_mkdir -p $DIR/$tdir
1464 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1465 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1467 local OST=$(ostname_from_index $OSTIDX)
1468 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1469 sed -e 's/_UUID$//;s/^.*-//')
1472 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1473 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1474 osc.$mdtosc_proc1.prealloc_last_id)
1475 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1476 osc.$mdtosc_proc1.prealloc_next_id)
1478 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1479 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1481 test_mkdir -p $DIR/$tdir/${OST}
1482 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1483 #define OBD_FAIL_OST_ENOSPC 0x215
1484 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1485 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1486 echo "Creating to objid $last_id on ost $OST..."
1487 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1488 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1489 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1493 exhaust_all_precreations() {
1495 for (( i=0; i < OSTCOUNT; i++ )) ; do
1496 exhaust_precreations $i $1 -1
1501 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1503 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1504 remote_ost_nodsh && skip "remote OST with nodsh" && return
1507 rm -f $DIR/$tdir/$tfile
1508 exhaust_precreations 0 0x80000215
1509 $SETSTRIPE -c -1 $DIR/$tdir
1510 touch $DIR/$tdir/$tfile || error
1511 $GETSTRIPE $DIR/$tdir/$tfile
1514 run_test 27n "create file with some full OSTs =================="
1517 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1518 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1519 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1520 remote_ost_nodsh && skip "remote OST with nodsh" && return
1523 rm -f $DIR/$tdir/$tfile
1524 exhaust_all_precreations 0x215
1526 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1531 run_test 27o "create file with all full OSTs (should error) ===="
1534 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1537 remote_ost_nodsh && skip "remote OST with nodsh" && return
1540 rm -f $DIR/$tdir/$tfile
1541 test_mkdir -p $DIR/$tdir
1543 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1544 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1545 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1547 exhaust_precreations 0 0x80000215
1548 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1549 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1550 $GETSTRIPE $DIR/$tdir/$tfile
1554 run_test 27p "append to a truncated file with some full OSTs ==="
1557 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1559 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1560 remote_ost_nodsh && skip "remote OST with nodsh" && return
1563 rm -f $DIR/$tdir/$tfile
1565 test_mkdir -p $DIR/$tdir
1566 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1567 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1568 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1570 exhaust_all_precreations 0x215
1572 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1573 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1577 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1580 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1582 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1583 remote_ost_nodsh && skip "remote OST with nodsh" && return
1586 rm -f $DIR/$tdir/$tfile
1587 exhaust_precreations 0 0x80000215
1589 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1593 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1595 test_27s() { # bug 10725
1596 test_mkdir -p $DIR/$tdir
1597 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1598 local stripe_count=0
1599 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1600 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1601 error "stripe width >= 2^32 succeeded" || true
1604 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1606 test_27t() { # bug 10864
1611 $WLFS getstripe $tfile
1614 run_test 27t "check that utils parse path correctly"
1616 test_27u() { # bug 4900
1617 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1618 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1620 local list=$(comma_list $(mdts_nodes))
1622 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1623 do_nodes $list $LCTL set_param fail_loc=0x139
1624 test_mkdir -p $DIR/$tdir
1626 createmany -o $DIR/$tdir/t- 1000
1627 do_nodes $list $LCTL set_param fail_loc=0
1629 TLOG=$DIR/$tfile.getstripe
1630 $GETSTRIPE $DIR/$tdir > $TLOG
1631 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1632 unlinkmany $DIR/$tdir/t- 1000
1633 [[ $OBJS -gt 0 ]] &&
1634 error "$OBJS objects created on OST-0. See $TLOG" || pass
1636 run_test 27u "skip object creation on OSC w/o objects =========="
1638 test_27v() { # bug 4900
1639 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1641 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1642 remote_ost_nodsh && skip "remote OST with nodsh" && return
1644 exhaust_all_precreations 0x215
1647 test_mkdir -p $DIR/$tdir
1648 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1650 touch $DIR/$tdir/$tfile
1651 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1653 for (( i=1; i < OSTCOUNT; i++ )); do
1654 do_facet ost$i lctl set_param fail_loc=0x705
1656 local START=`date +%s`
1657 createmany -o $DIR/$tdir/$tfile 32
1659 local FINISH=`date +%s`
1660 local TIMEOUT=`lctl get_param -n timeout`
1661 local PROCESS=$((FINISH - START))
1662 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1663 error "$FINISH - $START >= $TIMEOUT / 2"
1664 sleep $((TIMEOUT / 2 - PROCESS))
1667 run_test 27v "skip object creation on slow OST ================="
1669 test_27w() { # bug 10997
1670 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1671 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1672 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1673 error "stripe size $size != 65536" || true
1674 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1675 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1677 run_test 27w "check $SETSTRIPE -S option"
1680 [[ $OSTCOUNT -lt 2 ]] &&
1681 skip_env "skipping multiple stripe count/offset test" && return
1683 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1684 for i in $(seq 1 $OSTCOUNT); do
1686 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1687 error "setstripe -c $i -i $offset failed"
1688 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1689 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1690 [ $count -ne $i ] && error "stripe count $count != $i" || true
1691 [ $index -ne $offset ] &&
1692 error "stripe offset $index != $offset" || true
1695 run_test 27wa "check $SETSTRIPE -c -i options"
1698 remote_ost_nodsh && skip "remote OST with nodsh" && return
1699 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1701 OFFSET=$(($OSTCOUNT - 1))
1703 local OST=$(ostname_from_index $OSTIDX)
1705 test_mkdir -p $DIR/$tdir
1706 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1707 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1709 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1710 for i in `seq 0 $OFFSET`; do
1711 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1712 error "OST0 was degraded but new created file still use it"
1714 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1716 run_test 27x "create files while OST0 is degraded"
1719 [[ $OSTCOUNT -lt 2 ]] &&
1720 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1721 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1722 remote_ost_nodsh && skip "remote OST with nodsh" && return
1723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1725 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1726 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1727 osc.$mdtosc.prealloc_last_id)
1728 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1729 osc.$mdtosc.prealloc_next_id)
1730 local fcount=$((last_id - next_id))
1731 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1732 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1734 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1735 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1736 local OST_DEACTIVE_IDX=-1
1741 for OSC in $MDS_OSCS; do
1742 OST=$(osc_to_ost $OSC)
1743 OSTIDX=$(index_from_ostuuid $OST)
1744 if [ $OST_DEACTIVE_IDX == -1 ]; then
1745 OST_DEACTIVE_IDX=$OSTIDX
1747 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1748 echo $OSC "is Deactivated:"
1749 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1753 OSTIDX=$(index_from_ostuuid $OST)
1755 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1757 for OSC in $MDS_OSCS; do
1758 OST=$(osc_to_ost $OSC)
1759 OSTIDX=$(index_from_ostuuid $OST)
1760 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1761 echo $OST "is degraded:"
1762 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1763 obdfilter.$OST.degraded=1
1768 createmany -o $DIR/$tdir/$tfile $fcount
1770 for OSC in $MDS_OSCS; do
1771 OST=$(osc_to_ost $OSC)
1772 OSTIDX=$(index_from_ostuuid $OST)
1773 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1774 echo $OST "is recovered from degraded:"
1775 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1776 obdfilter.$OST.degraded=0
1778 do_facet $SINGLEMDS lctl --device %$OSC activate
1782 # all osp devices get activated, hence -1 stripe count restored
1785 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1786 # devices get activated.
1788 $SETSTRIPE -c -1 $DIR/$tfile
1789 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1791 [ $stripecnt -ne $OSTCOUNT ] &&
1792 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1795 run_test 27y "create files while OST0 is degraded and the rest inactive"
1801 lmm_count=$($GETSTRIPE -c $1)
1802 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1803 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1805 local old_ifs="$IFS"
1807 fid=($($LFS path2fid $1))
1810 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1811 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1813 # compare lmm_seq and lu_fid->f_seq
1814 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1815 # compare lmm_object_id and lu_fid->oid
1816 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1818 # check the trusted.fid attribute of the OST objects of the file
1819 local have_obdidx=false
1821 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1822 # skip lines up to and including "obdidx"
1823 [ -z "$obdidx" ] && break
1824 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1825 $have_obdidx || continue
1827 local ost=$((obdidx + 1))
1828 local dev=$(ostdevname $ost)
1831 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1833 seq=$(echo $seq | sed -e "s/^0x//g")
1834 if [ $seq == 0 ]; then
1835 oid_hex=$(echo $oid)
1837 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1839 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1843 # Don't unmount/remount the OSTs if we don't need to do that.
1844 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1845 # update too, until that use mount/ll_decode_filter_fid/mount.
1846 # Re-enable when debugfs will understand new filter_fid.
1848 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1849 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1850 $dev 2>/dev/null" | grep "parent=")
1853 mount_fstype ost$ost
1854 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1855 $(facet_mntpt ost$ost)/$obj_file)
1856 unmount_fstype ost$ost
1857 start ost$ost $dev $OST_MOUNT_OPTS
1860 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1862 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1864 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1865 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1866 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1867 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1868 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1870 if echo $ff_parent | grep -q 'stripe='; then
1871 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1874 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1875 # into f_ver in this case. See the comment on
1878 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1882 # compare lmm_seq and filter_fid->ff_parent.f_seq
1883 [ $ff_pseq = $lmm_seq ] ||
1884 error "FF parent SEQ $ff_pseq != $lmm_seq"
1885 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1886 [ $ff_poid = $lmm_oid ] ||
1887 error "FF parent OID $ff_poid != $lmm_oid"
1888 (($ff_pstripe == $stripe_nr)) ||
1889 error "FF stripe $ff_pstripe != $stripe_nr"
1891 stripe_nr=$((stripe_nr + 1))
1896 remote_ost_nodsh && skip "remote OST with nodsh" && return
1897 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1898 test_mkdir -p $DIR/$tdir
1900 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1901 { error "setstripe -c -1 failed"; return 1; }
1902 # We need to send a write to every object to get parent FID info set.
1903 # This _should_ also work for setattr, but does not currently.
1904 # touch $DIR/$tdir/$tfile-1 ||
1905 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1906 { error "dd $tfile-1 failed"; return 2; }
1907 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1908 { error "setstripe -c -1 failed"; return 3; }
1909 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1910 { error "dd $tfile-2 failed"; return 4; }
1912 # make sure write RPCs have been sent to OSTs
1915 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1916 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1918 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1920 test_27A() { # b=19102
1921 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1922 local restore_size=$($GETSTRIPE -S $MOUNT)
1923 local restore_count=$($GETSTRIPE -c $MOUNT)
1924 local restore_offset=$($GETSTRIPE -i $MOUNT)
1925 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1926 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1927 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1928 local default_size=$($GETSTRIPE -S $MOUNT)
1929 local default_offset=$($GETSTRIPE -i $MOUNT)
1930 local dsize=$((1024 * 1024))
1931 [ $default_size -eq $dsize ] ||
1932 error "stripe size $default_size != $dsize"
1933 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1934 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1936 run_test 27A "check filesystem-wide default LOV EA values"
1938 test_27B() { # LU-2523
1939 test_mkdir -p $DIR/$tdir
1940 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1942 # open f1 with O_LOV_DELAY_CREATE
1944 # call setstripe ioctl on open file descriptor for f1
1946 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1950 # open f1 with O_LOV_DELAY_CREATE
1952 # call setstripe ioctl on open file descriptor for f1
1954 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1956 # Allow multiop to fail in imitation of NFS's busted semantics.
1959 run_test 27B "call setstripe on open unlinked file/rename victim"
1961 test_27C() { #LU-2871
1962 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1970 test_mkdir -p $DIR/$tdir
1972 for i in $(seq 0 $((OSTCOUNT - 1))); do
1973 # set stripe across all OSTs starting from OST$i
1974 $SETSTRIPE -i $i -c -1 $tfile$i
1975 # get striping information
1976 ost_idx=($($GETSTRIPE $tfile$i |
1977 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1981 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1982 error "${#ost_idx[@]} != $OSTCOUNT"
1984 for index in $(seq 0 $((OSTCOUNT - 1))); do
1986 for j in $(echo ${ost_idx[@]}); do
1987 if [ $index -eq $j ]; then
1993 error "Can not find $index in ${ost_idx[@]}"
1997 run_test 27C "check full striping across all OSTs"
2000 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2001 local POOL=${POOL:-testpool}
2003 local last_ost=$(($OSTCOUNT - 1))
2005 local ost_list=$(seq $first_ost $ost_step $last_ost)
2006 local ost_range="$first_ost $last_ost $ost_step"
2009 pool_add $POOL || error "pool_add failed"
2010 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2011 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2012 error "llapi_layout_test failed"
2013 cleanup_pools || error "cleanup_pools failed"
2015 run_test 27D "validate llapi_layout API"
2017 # createtest also checks that device nodes are created and
2018 # then visible correctly (#2091)
2019 test_28() { # bug 2091
2021 $CREATETEST $DIR/d28/ct || error
2023 run_test 28 "create/mknod/mkdir with bad file types ============"
2026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2027 cancel_lru_locks mdc
2033 declare -i LOCKCOUNTORIG=0
2034 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2035 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2037 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2039 declare -i LOCKUNUSEDCOUNTORIG=0
2040 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2041 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2048 declare -i LOCKCOUNTCURRENT=0
2049 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2050 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2053 declare -i LOCKUNUSEDCOUNTCURRENT=0
2054 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2055 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2058 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2059 $LCTL set_param -n ldlm.dump_namespaces ""
2060 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2061 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2062 log "dumped log to $TMP/test_29.dk (bug 5793)"
2065 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2066 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2067 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2068 log "dumped log to $TMP/test_29.dk (bug 5793)"
2072 run_test 29 "IT_GETATTR regression ============================"
2074 test_30a() { # was test_30
2075 cp $(which ls) $DIR || cp /bin/ls $DIR
2079 run_test 30a "execute binary from Lustre (execve) =============="
2082 cp `which ls` $DIR || cp /bin/ls $DIR
2084 $RUNAS $DIR/ls / || error
2087 run_test 30b "execute binary from Lustre as non-root ==========="
2089 test_30c() { # b=22376
2090 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2091 cp `which ls` $DIR || cp /bin/ls $DIR
2093 cancel_lru_locks mdc
2094 cancel_lru_locks osc
2095 $RUNAS $DIR/ls / || error
2098 run_test 30c "execute binary from Lustre without read perms ===="
2101 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2102 $CHECKSTAT -a $DIR/f31 || error
2104 run_test 31a "open-unlink file =================================="
2107 touch $DIR/f31 || error
2108 ln $DIR/f31 $DIR/f31b || error
2109 $MULTIOP $DIR/f31b Ouc || error
2110 $CHECKSTAT -t file $DIR/f31 || error
2112 run_test 31b "unlink file with multiple links while open ======="
2115 touch $DIR/f31 || error
2116 ln $DIR/f31 $DIR/f31c || error
2117 multiop_bg_pause $DIR/f31 O_uc || return 1
2119 $MULTIOP $DIR/f31c Ouc
2120 kill -USR1 $MULTIPID
2123 run_test 31c "open-unlink file with multiple links ============="
2126 opendirunlink $DIR/d31d $DIR/d31d || error
2127 $CHECKSTAT -a $DIR/d31d || error
2129 run_test 31d "remove of open directory ========================="
2131 test_31e() { # bug 2904
2132 check_kernel_version 34 || return 0
2133 openfilleddirunlink $DIR/d31e || error
2135 run_test 31e "remove of open non-empty directory ==============="
2137 test_31f() { # bug 4554
2138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2140 test_mkdir $DIR/d31f
2141 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2142 cp /etc/hosts $DIR/d31f
2144 $GETSTRIPE $DIR/d31f/hosts
2145 multiop_bg_pause $DIR/d31f D_c || return 1
2148 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2149 test_mkdir $DIR/d31f
2150 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2151 cp /etc/hosts $DIR/d31f
2153 $GETSTRIPE $DIR/d31f/hosts
2154 multiop_bg_pause $DIR/d31f D_c || return 1
2157 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2158 wait $MULTIPID || error "first opendir $MULTIPID failed"
2162 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2163 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2166 run_test 31f "remove of open directory with open-unlink file ==="
2169 echo "-- cross directory link --"
2170 test_mkdir -c1 $DIR/${tdir}ga
2171 test_mkdir -c1 $DIR/${tdir}gb
2172 touch $DIR/${tdir}ga/f
2173 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2174 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2175 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2176 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2177 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2179 run_test 31g "cross directory link==============="
2182 echo "-- cross directory link --"
2183 test_mkdir -c1 $DIR/${tdir}
2184 test_mkdir -c1 $DIR/${tdir}/dir
2185 touch $DIR/${tdir}/f
2186 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2187 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2188 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2189 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2190 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2192 run_test 31h "cross directory link under child==============="
2195 echo "-- cross directory link --"
2196 test_mkdir -c1 $DIR/$tdir
2197 test_mkdir -c1 $DIR/$tdir/dir
2198 touch $DIR/$tdir/dir/f
2199 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2200 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2201 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2202 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2203 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2205 run_test 31i "cross directory link under parent==============="
2208 test_mkdir -c1 -p $DIR/$tdir
2209 test_mkdir -c1 -p $DIR/$tdir/dir1
2210 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2211 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2212 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2213 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2216 run_test 31j "link for directory==============="
2219 test_mkdir -c1 -p $DIR/$tdir
2221 touch $DIR/$tdir/exist
2222 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2223 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2224 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2225 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2226 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2227 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2228 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2231 run_test 31k "link to file: the same, non-existing, dir==============="
2237 touch $DIR/d31m2/exist
2238 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2239 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2240 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2241 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2242 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2243 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2246 run_test 31m "link to file: the same, non-existing, dir==============="
2249 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2250 nlink=$(stat --format=%h $DIR/$tfile)
2251 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2253 local cmd="exec $fd<$DIR/$tfile"
2256 trap "eval $cmd" EXIT
2257 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2258 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2259 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2260 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2261 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2264 run_test 31n "check link count of unlinked file"
2267 local TEMPNAME=$(mktemp $1_XXXXXX)
2268 mlink $TEMPNAME $1 2> /dev/null &&
2269 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2273 test_31o() { # LU-2901
2275 for LOOP in $(seq 100); do
2276 rm -f $DIR/$tdir/$tfile*
2277 for THREAD in $(seq 8); do
2278 link_one $DIR/$tdir/$tfile.$LOOP &
2281 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2282 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2283 error "$LINKS duplicate links to $tfile.$LOOP" &&
2287 run_test 31o "duplicate hard links with same filename"
2290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2293 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2294 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2296 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2297 error "open unlink test1 failed"
2298 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2299 error "open unlink test2 failed"
2301 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2302 error "test1 still exists"
2303 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2304 error "test2 still exists"
2306 run_test 31p "remove of open striped directory"
2308 cleanup_test32_mount() {
2310 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2315 echo "== more mountpoints and symlinks ================="
2316 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2317 trap cleanup_test32_mount EXIT
2318 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2319 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2320 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2321 cleanup_test32_mount
2323 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2327 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2328 trap cleanup_test32_mount EXIT
2329 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2330 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2331 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2332 cleanup_test32_mount
2334 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2338 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2339 trap cleanup_test32_mount EXIT
2340 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2341 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2342 test_mkdir -p $DIR/$tdir/d2/test_dir
2343 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2344 cleanup_test32_mount
2346 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2349 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2350 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2351 trap cleanup_test32_mount EXIT
2352 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2353 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2354 test_mkdir -p $DIR/$tdir/d2/test_dir
2355 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2356 cleanup_test32_mount
2358 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2361 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2362 test_mkdir -p $DIR/d32e/tmp
2363 TMP_DIR=$DIR/d32e/tmp
2364 ln -s $DIR/d32e $TMP_DIR/symlink11
2365 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2366 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2367 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2369 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2372 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2373 test_mkdir -p $DIR/d32f/tmp
2374 TMP_DIR=$DIR/d32f/tmp
2375 ln -s $DIR/d32f $TMP_DIR/symlink11
2376 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2377 ls $DIR/d32f/tmp/symlink11 || error
2378 ls $DIR/d32f/symlink01 || error
2380 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2383 TMP_DIR=$DIR/$tdir/tmp
2384 test_mkdir -p $DIR/$tdir/tmp
2385 test_mkdir $DIR/${tdir}2
2386 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2387 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2388 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2389 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2390 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2391 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2393 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2396 rm -fr $DIR/$tdir $DIR/${tdir}2
2397 TMP_DIR=$DIR/$tdir/tmp
2398 test_mkdir -p $DIR/$tdir/tmp
2399 test_mkdir $DIR/${tdir}2
2400 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2401 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2402 ls $TMP_DIR/symlink12 || error
2403 ls $DIR/$tdir/symlink02 || error
2405 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2409 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2410 trap cleanup_test32_mount EXIT
2411 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2412 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2413 touch $DIR/$tdir/test_file
2414 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2415 cleanup_test32_mount
2417 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2420 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2421 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2422 trap cleanup_test32_mount EXIT
2423 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2424 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2425 touch $DIR/$tdir/test_file
2426 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2427 cleanup_test32_mount
2429 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2432 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2434 trap cleanup_test32_mount EXIT
2435 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2436 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2437 test_mkdir -p $DIR/$tdir/d2
2438 touch $DIR/$tdir/d2/test_file || error
2439 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2440 cleanup_test32_mount
2442 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2447 trap cleanup_test32_mount EXIT
2448 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2449 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2450 test_mkdir -p $DIR/$tdir/d2
2451 touch $DIR/$tdir/d2/test_file
2452 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2453 cleanup_test32_mount
2455 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2459 test_mkdir -p $DIR/d32m/tmp
2460 TMP_DIR=$DIR/d32m/tmp
2461 ln -s $DIR $TMP_DIR/symlink11
2462 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2463 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2464 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2466 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2470 test_mkdir -p $DIR/d32n/tmp
2471 TMP_DIR=$DIR/d32n/tmp
2472 ln -s $DIR $TMP_DIR/symlink11
2473 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2474 ls -l $DIR/d32n/tmp/symlink11 || error
2475 ls -l $DIR/d32n/symlink01 || error
2477 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2481 test_mkdir -p $DIR/d32o/tmp
2482 TMP_DIR=$DIR/d32o/tmp
2483 ln -s $DIR/$tfile $TMP_DIR/symlink12
2484 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2485 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2486 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2487 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2488 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2490 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2500 test_mkdir -p $DIR/d32p/tmp
2502 TMP_DIR=$DIR/d32p/tmp
2504 ln -s $DIR/$tfile $TMP_DIR/symlink12
2506 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2508 cat $DIR/d32p/tmp/symlink12 || error
2510 cat $DIR/d32p/symlink02 || error
2513 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2515 cleanup_testdir_mount() {
2517 $UMOUNT -d $DIR/$tdir
2521 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2522 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2523 trap cleanup_testdir_mount EXIT
2524 test_mkdir -p $DIR/$tdir
2525 touch $DIR/$tdir/under_the_mount
2526 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2527 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2528 cleanup_testdir_mount
2530 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2534 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2535 trap cleanup_testdir_mount EXIT
2536 test_mkdir -p $DIR/$tdir
2537 touch $DIR/$tdir/under_the_mount
2538 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2539 ls $DIR/$tdir | grep -q under_the_mount && error || true
2540 cleanup_testdir_mount
2542 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2547 chmod 444 $DIR/$tfile
2548 chown $RUNAS_ID $DIR/$tfile
2550 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2553 run_test 33aa "write file with mode 444 (should return error) ===="
2557 test_mkdir -p $DIR/d33
2558 chown $RUNAS_ID $DIR/d33
2559 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2560 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2561 error "open RDWR" || true
2563 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2567 test_mkdir -p $DIR/d33
2568 chown $RUNAS_ID $DIR/d33
2569 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
2571 run_test 33b "test open file with malformed flags (No panic)"
2574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2580 remote_ost_nodsh && skip "remote OST with nodsh" && return
2583 test_mkdir -p $DIR/d33
2584 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2587 for ostnum in $(seq $OSTCOUNT); do
2588 # test-framework's OST numbering is one-based, while Lustre's
2590 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2591 # Parsing llobdstat's output sucks; we could grep the /proc
2592 # path, but that's likely to not be as portable as using the
2593 # llobdstat utility. So we parse lctl output instead.
2594 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2595 obdfilter/$ostname/stats |
2596 awk '/^write_bytes/ {print $7}' )
2597 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2598 if (( ${write_bytes:-0} > 0 ))
2605 $all_zeros || return 0
2608 echo foo > $DIR/d33/bar
2612 # Total up write_bytes after writing. We'd better find non-zeros.
2613 for ostnum in $(seq $OSTCOUNT); do
2614 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2615 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2616 obdfilter/$ostname/stats |
2617 awk '/^write_bytes/ {print $7}' )
2618 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2619 if (( ${write_bytes:-0} > 0 ))
2628 for ostnum in $(seq $OSTCOUNT); do
2629 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2630 echo "Check that write_bytes is present in obdfilter/*/stats:"
2631 do_facet ost$ostnum lctl get_param -n \
2632 obdfilter/$ostname/stats
2634 error "OST not keeping write_bytes stats (b22312)"
2637 run_test 33c "test llobdstat and write_bytes"
2640 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2643 local remote_dir=$DIR/$tdir/remote_dir
2646 $LFS mkdir -i $MDTIDX $remote_dir ||
2647 error "create remote directory failed"
2649 touch $remote_dir/$tfile
2650 chmod 444 $remote_dir/$tfile
2651 chown $RUNAS_ID $remote_dir/$tfile
2653 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2655 chown $RUNAS_ID $remote_dir
2656 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2657 error "create" || true
2658 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2659 error "open RDWR" || true
2660 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2661 error "create" || true
2663 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2666 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2670 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2671 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2672 mkdir $DIR/$tdir/local_dir
2674 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2675 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2676 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2678 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2679 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2681 rmdir $DIR/$tdir/* || error "rmdir failed"
2684 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2685 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2686 mkdir $DIR/$tdir/local_dir
2688 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2689 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2690 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2692 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2693 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2695 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2698 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2699 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2700 mkdir $DIR/$tdir/local_dir
2702 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2703 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2704 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2706 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2707 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2709 run_test 33e "mkdir and striped directory should have same mode"
2711 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2714 $MCREATE $DIR/f34 || error
2715 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2716 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2717 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2718 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2720 run_test 34a "truncate file that has not been opened ==========="
2723 [ ! -f $DIR/f34 ] && test_34a
2724 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2725 $OPENFILE -f O_RDONLY $DIR/f34
2726 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2727 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2729 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2732 [ ! -f $DIR/f34 ] && test_34a
2733 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2734 $OPENFILE -f O_RDWR $DIR/f34
2735 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2736 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2738 run_test 34c "O_RDWR opening file-with-size works =============="
2741 [ ! -f $DIR/f34 ] && test_34a
2742 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2743 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2746 run_test 34d "write to sparse file ============================="
2750 $MCREATE $DIR/f34e || error
2751 $TRUNCATE $DIR/f34e 1000 || error
2752 $CHECKSTAT -s 1000 $DIR/f34e || error
2753 $OPENFILE -f O_RDWR $DIR/f34e
2754 $CHECKSTAT -s 1000 $DIR/f34e || error
2756 run_test 34e "create objects, some with size and some without =="
2758 test_34f() { # bug 6242, 6243
2759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2762 $MCREATE $DIR/f34f || error
2763 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2764 dd if=$DIR/f34f of=$TMP/f34f
2765 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2766 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2767 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2768 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2769 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2771 run_test 34f "read from a file with no objects until EOF ======="
2774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2775 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2776 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2777 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2778 cancel_lru_locks osc
2779 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2780 error "wrong size after lock cancel"
2782 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2783 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2784 error "expanding truncate failed"
2785 cancel_lru_locks osc
2786 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2787 error "wrong expanded size after lock cancel"
2789 run_test 34g "truncate long file ==============================="
2792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2796 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2797 sync # Flush the cache so that multiop below does not block on cache
2798 # flush when getting the group lock
2799 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2802 # Since just timed wait is not good enough, let's do a sync write
2803 # that way we are sure enough time for a roundtrip + processing
2804 # passed + 2 seconds of extra margin.
2805 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2809 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2810 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2814 local nsz=`stat -c %s $DIR/$tfile`
2815 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2817 run_test 34h "ftruncate file under grouplock should not block"
2820 cp /bin/sh $DIR/f35a
2822 chown $RUNAS_ID $DIR/f35a
2823 $RUNAS $DIR/f35a && error || true
2826 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2830 utime $DIR/f36 || error
2832 run_test 36a "MDS utime check (mknod, utime) ==================="
2836 utime $DIR/f36 || error
2838 run_test 36b "OST utime check (open, utime) ===================="
2843 chown $RUNAS_ID $DIR/d36
2844 $RUNAS utime $DIR/d36/f36 || error
2846 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2849 [ ! -d $DIR/d36 ] && test_36c
2850 echo "" > $DIR/d36/f36
2851 $RUNAS utime $DIR/d36/f36 || error
2853 run_test 36d "non-root OST utime check (open, utime) ==========="
2856 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2857 test_mkdir -p $DIR/$tdir
2858 touch $DIR/$tdir/$tfile
2859 $RUNAS utime $DIR/$tdir/$tfile && \
2860 error "utime worked, expected failure" || true
2862 run_test 36e "utime on non-owned file (should return error) ===="
2866 local LANG_SAVE=$LANG
2867 local LC_LANG_SAVE=$LC_LANG
2868 export LANG=C LC_LANG=C # for date language
2870 DATESTR="Dec 20 2000"
2871 test_mkdir -p $DIR/$tdir
2872 lctl set_param fail_loc=$fl
2874 cp /etc/hosts $DIR/$tdir/$tfile
2875 sync & # write RPC generated with "current" inode timestamp, but delayed
2877 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2878 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2879 cancel_lru_locks osc
2880 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2882 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2883 echo "BEFORE: $LS_BEFORE" && \
2884 echo "AFTER : $LS_AFTER" && \
2885 echo "WANT : $DATESTR" && \
2886 error "$DIR/$tdir/$tfile timestamps changed" || true
2888 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2893 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2894 subr_36fh "0x80000214"
2896 run_test 36f "utime on file racing with OST BRW write =========="
2899 remote_ost_nodsh && skip "remote OST with nodsh" && return
2900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2905 test_mkdir -p $DIR/$tdir
2906 fmd_max_age=$(do_facet ost1 \
2907 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2910 fmd_before=$(do_facet ost1 \
2911 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2912 touch $DIR/$tdir/$tfile
2913 sleep $((fmd_max_age + 12))
2914 fmd_after=$(do_facet ost1 \
2915 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2917 echo "fmd_before: $fmd_before"
2918 echo "fmd_after: $fmd_after"
2919 [[ $fmd_after -gt $fmd_before ]] &&
2920 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2921 error "fmd didn't expire after ping" || true
2923 run_test 36g "filter mod data cache expiry ====================="
2926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2927 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2928 subr_36fh "0x80000227"
2930 run_test 36h "utime on file racing with OST BRW write =========="
2933 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2936 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2938 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2939 local new_mtime=$((mtime + 200))
2941 #change Modify time of striped dir
2942 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2943 error "change mtime failed"
2945 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2947 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2949 run_test 36i "change mtime on striped directory"
2951 # test_37 - duplicate with tests 32q 32r
2954 local file=$DIR/$tfile
2956 openfile -f O_DIRECTORY $file
2959 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2960 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2962 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2966 touch $DIR/${tfile}2
2967 # ls -l $DIR/$tfile $DIR/${tfile}2
2968 # ls -lu $DIR/$tfile $DIR/${tfile}2
2969 # ls -lc $DIR/$tfile $DIR/${tfile}2
2971 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2972 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2974 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2976 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2978 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2979 error "O_TRUNC didn't change timestamps"
2982 run_test 39 "mtime changed on create ==========================="
2985 test_mkdir -p -c1 $DIR/$tdir
2986 cp -p /etc/passwd $DIR/$tdir/fopen
2987 cp -p /etc/passwd $DIR/$tdir/flink
2988 cp -p /etc/passwd $DIR/$tdir/funlink
2989 cp -p /etc/passwd $DIR/$tdir/frename
2990 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2993 echo "aaaaaa" >> $DIR/$tdir/fopen
2994 echo "aaaaaa" >> $DIR/$tdir/flink
2995 echo "aaaaaa" >> $DIR/$tdir/funlink
2996 echo "aaaaaa" >> $DIR/$tdir/frename
2998 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2999 local link_new=`stat -c %Y $DIR/$tdir/flink`
3000 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3001 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3003 cat $DIR/$tdir/fopen > /dev/null
3004 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3005 rm -f $DIR/$tdir/funlink2
3006 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3008 for (( i=0; i < 2; i++ )) ; do
3009 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3010 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3011 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3012 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3014 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3015 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3016 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3017 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3019 cancel_lru_locks osc
3020 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3023 run_test 39b "mtime change on open, link, unlink, rename ======"
3025 # this should be set to past
3026 TEST_39_MTIME=`date -d "1 year ago" +%s`
3032 local mtime0=`stat -c %Y $DIR1/$tfile`
3034 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3035 local mtime1=`stat -c %Y $DIR1/$tfile`
3036 [ "$mtime1" = $TEST_39_MTIME ] || \
3037 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3040 echo hello >> $DIR1/$tfile
3042 local mtime2=`stat -c %Y $DIR1/$tfile`
3043 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3044 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3046 mv $DIR1/$tfile $DIR1/$tfile-1
3048 for (( i=0; i < 2; i++ )) ; do
3049 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3050 [ "$mtime2" = "$mtime3" ] || \
3051 error "mtime ($mtime2) changed (to $mtime3) on rename"
3053 cancel_lru_locks osc
3054 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3057 run_test 39c "mtime change on rename ==========================="
3061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3064 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3066 for (( i=0; i < 2; i++ )) ; do
3067 local mtime=`stat -c %Y $DIR1/$tfile`
3068 [ $mtime = $TEST_39_MTIME ] || \
3069 error "mtime($mtime) is not set to $TEST_39_MTIME"
3071 cancel_lru_locks osc
3072 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3075 run_test 39d "create, utime, stat =============================="
3079 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3081 local mtime1=`stat -c %Y $DIR1/$tfile`
3083 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3085 for (( i=0; i < 2; i++ )) ; do
3086 local mtime2=`stat -c %Y $DIR1/$tfile`
3087 [ $mtime2 = $TEST_39_MTIME ] || \
3088 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3090 cancel_lru_locks osc
3091 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3094 run_test 39e "create, stat, utime, stat ========================"
3098 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3100 mtime1=`stat -c %Y $DIR1/$tfile`
3103 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3105 for (( i=0; i < 2; i++ )) ; do
3106 local mtime2=`stat -c %Y $DIR1/$tfile`
3107 [ $mtime2 = $TEST_39_MTIME ] || \
3108 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3110 cancel_lru_locks osc
3111 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3114 run_test 39f "create, stat, sleep, utime, stat ================="
3118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3119 echo hello >> $DIR1/$tfile
3120 local mtime1=`stat -c %Y $DIR1/$tfile`
3123 chmod o+r $DIR1/$tfile
3125 for (( i=0; i < 2; i++ )) ; do
3126 local mtime2=`stat -c %Y $DIR1/$tfile`
3127 [ "$mtime1" = "$mtime2" ] || \
3128 error "lost mtime: $mtime2, should be $mtime1"
3130 cancel_lru_locks osc
3131 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3134 run_test 39g "write, chmod, stat ==============================="
3138 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3143 echo hello >> $DIR1/$tfile
3144 local mtime1=`stat -c %Y $DIR1/$tfile`
3146 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3148 if [ "$d1" != "$d2" ]; then
3149 echo "write and touch not within one second"
3151 for (( i=0; i < 2; i++ )) ; do
3152 local mtime2=`stat -c %Y $DIR1/$tfile`
3153 [ "$mtime2" = $TEST_39_MTIME ] || \
3154 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3156 cancel_lru_locks osc
3157 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3161 run_test 39h "write, utime within one second, stat ============="
3164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3168 echo hello >> $DIR1/$tfile
3169 local mtime1=`stat -c %Y $DIR1/$tfile`
3171 mv $DIR1/$tfile $DIR1/$tfile-1
3173 for (( i=0; i < 2; i++ )) ; do
3174 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3176 [ "$mtime1" = "$mtime2" ] || \
3177 error "lost mtime: $mtime2, should be $mtime1"
3179 cancel_lru_locks osc
3180 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3183 run_test 39i "write, rename, stat =============================="
3186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3187 start_full_debug_logging
3191 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3192 lctl set_param fail_loc=0x80000412
3193 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3194 error "multiop failed"
3196 local mtime1=`stat -c %Y $DIR1/$tfile`
3198 mv $DIR1/$tfile $DIR1/$tfile-1
3200 kill -USR1 $multipid
3201 wait $multipid || error "multiop close failed"
3203 for (( i=0; i < 2; i++ )) ; do
3204 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3205 [ "$mtime1" = "$mtime2" ] ||
3206 error "mtime is lost on close: $mtime2, " \
3209 cancel_lru_locks osc
3210 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3212 lctl set_param fail_loc=0
3213 stop_full_debug_logging
3215 run_test 39j "write, rename, close, stat ======================="
3218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3222 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3224 local mtime1=`stat -c %Y $DIR1/$tfile`
3226 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3228 kill -USR1 $multipid
3229 wait $multipid || error "multiop close failed"
3231 for (( i=0; i < 2; i++ )) ; do
3232 local mtime2=`stat -c %Y $DIR1/$tfile`
3234 [ "$mtime2" = $TEST_39_MTIME ] || \
3235 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3237 cancel_lru_locks osc
3238 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3241 run_test 39k "write, utime, close, stat ========================"
3243 # this should be set to future
3244 TEST_39_ATIME=`date -d "1 year" +%s`
3247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3248 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3249 local atime_diff=$(do_facet $SINGLEMDS \
3250 lctl get_param -n mdd.*MDT0000*.atime_diff)
3254 # test setting directory atime to future
3255 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3256 local atime=$(stat -c %X $DIR/$tdir)
3257 [ "$atime" = $TEST_39_ATIME ] || \
3258 error "atime is not set to future: $atime, $TEST_39_ATIME"
3260 # test setting directory atime from future to now
3261 local d1=$(date +%s)
3263 local d2=$(date +%s)
3265 cancel_lru_locks mdc
3266 atime=$(stat -c %X $DIR/$tdir)
3267 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3268 error "atime is not updated from future: $atime, $d1<atime<$d2"
3270 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3273 # test setting directory atime when now > dir atime + atime_diff
3277 cancel_lru_locks mdc
3278 atime=$(stat -c %X $DIR/$tdir)
3279 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3280 error "atime is not updated : $atime, should be $d2"
3282 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3285 # test not setting directory atime when now < dir atime + atime_diff
3287 cancel_lru_locks mdc
3288 atime=$(stat -c %X $DIR/$tdir)
3289 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3290 error "atime is updated to $atime, should remain $d1<atime<$d2"
3292 do_facet $SINGLEMDS \
3293 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3295 run_test 39l "directory atime update ==========================="
3298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3301 local far_past_mtime=$(date -d "May 29 1953" +%s)
3302 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3304 touch -m -d @$far_past_mtime $DIR1/$tfile
3305 touch -a -d @$far_past_atime $DIR1/$tfile
3307 for (( i=0; i < 2; i++ )) ; do
3308 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3309 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3310 error "atime or mtime set incorrectly"
3312 cancel_lru_locks osc
3313 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3316 run_test 39m "test atime and mtime before 1970"
3318 test_39n() { # LU-3832
3319 local atime_diff=$(do_facet $SINGLEMDS \
3320 lctl get_param -n mdd.*MDT0000*.atime_diff)
3325 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3328 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3329 atime0=$(stat -c %X $DIR/$tfile)
3332 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3333 atime1=$(stat -c %X $DIR/$tfile)
3336 cancel_lru_locks mdc
3337 cancel_lru_locks osc
3338 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3339 atime2=$(stat -c %X $DIR/$tfile)
3341 do_facet $SINGLEMDS \
3342 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3344 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3345 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3347 run_test 39n "check that O_NOATIME is honored"
3350 TESTDIR=$DIR/$tdir/$tfile
3351 [ -e $TESTDIR ] && rm -rf $TESTDIR
3352 test_mkdir -p $TESTDIR
3358 links2=$(stat -c %h .)
3359 [ $(($links1 + 2)) != $links2 ] &&
3360 error "wrong links count $(($links1 + 2)) != $links2"
3362 links3=$(stat -c %h .)
3363 [ $(($links1 + 1)) != $links3 ] &&
3364 error "wrong links count $links1 != $links3"
3367 run_test 39o "directory cached attributes updated after create ========"
3370 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3372 TESTDIR=$DIR/$tdir/$tfile
3373 [ -e $TESTDIR ] && rm -rf $TESTDIR
3378 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3379 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3381 links2=$(stat -c %h .)
3382 [ $(($links1 + 2)) != $links2 ] &&
3383 error "wrong links count $(($links1 + 2)) != $links2"
3385 links3=$(stat -c %h .)
3386 [ $(($links1 + 1)) != $links3 ] &&
3387 error "wrong links count $links1 != $links3"
3390 run_test 39p "remote directory cached attributes updated after create ========"
3394 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3395 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3396 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3397 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3398 error "$tfile is not 4096 bytes in size"
3400 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3404 small_write $DIR/f41 18
3406 run_test 41 "test small file write + fstat ====================="
3408 count_ost_writes() {
3409 lctl get_param -n osc.*.stats |
3410 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3411 END { printf("%0.0f", writes) }'
3418 BG_DIRTY_RATIO_SAVE=10
3419 MAX_BG_DIRTY_RATIO=25
3423 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3424 # dirty_ratio, dirty_background_ratio
3425 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3426 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3427 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3428 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3430 # if file not here, we are a 2.4 kernel
3431 kill -CONT `pidof kupdated`
3436 # setup the trap first, so someone cannot exit the test at the
3437 # exact wrong time and mess up a machine
3438 trap start_writeback EXIT
3439 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3440 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3441 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3442 sysctl -w vm.dirty_writeback_centisecs=0
3443 sysctl -w vm.dirty_writeback_centisecs=0
3444 # save and increase /proc/sys/vm/dirty_ratio
3445 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3446 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3447 # save and increase /proc/sys/vm/dirty_background_ratio
3448 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3449 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3451 # if file not here, we are a 2.4 kernel
3452 kill -STOP `pidof kupdated`
3456 # ensure that all stripes have some grant before we test client-side cache
3458 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3459 dd if=/dev/zero of=$i bs=4k count=1
3464 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3465 # file truncation, and file removal.
3467 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3469 cancel_lru_locks osc
3471 sync; sleep 1; sync # just to be safe
3472 BEFOREWRITES=`count_ost_writes`
3473 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3474 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3475 AFTERWRITES=`count_ost_writes`
3476 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3477 error "$BEFOREWRITES < $AFTERWRITES"
3480 run_test 42a "ensure that we don't flush on close =============="
3483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3485 cancel_lru_locks osc
3488 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3489 BEFOREWRITES=$(count_ost_writes)
3490 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3491 AFTERWRITES=$(count_ost_writes)
3492 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3493 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3495 BEFOREWRITES=$(count_ost_writes)
3496 sync || error "sync: $?"
3497 AFTERWRITES=$(count_ost_writes)
3498 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3499 error "$BEFOREWRITES < $AFTERWRITES on sync"
3501 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3505 run_test 42b "test destroy of file with cached dirty data ======"
3507 # if these tests just want to test the effect of truncation,
3508 # they have to be very careful. consider:
3509 # - the first open gets a {0,EOF}PR lock
3510 # - the first write conflicts and gets a {0, count-1}PW
3511 # - the rest of the writes are under {count,EOF}PW
3512 # - the open for truncate tries to match a {0,EOF}PR
3513 # for the filesize and cancels the PWs.
3514 # any number of fixes (don't get {0,EOF} on open, match
3515 # composite locks, do smarter file size management) fix
3516 # this, but for now we want these tests to verify that
3517 # the cancellation with truncate intent works, so we
3518 # start the file with a full-file pw lock to match against
3519 # until the truncate.
3524 cancel_lru_locks osc
3526 # prime the file with 0,EOF PW to match
3530 # now the real test..
3531 dd if=/dev/zero of=$file bs=1024 count=100
3532 BEFOREWRITES=`count_ost_writes`
3533 $TRUNCATE $file $offset
3534 cancel_lru_locks osc
3535 AFTERWRITES=`count_ost_writes`
3540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3542 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3543 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3546 run_test 42c "test partial truncate of file with cached dirty data"
3549 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3551 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3552 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3555 run_test 42d "test complete truncate of file with cached dirty data"
3557 test_42e() { # bug22074
3558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3559 local TDIR=$DIR/${tdir}e
3560 local pagesz=$(page_size)
3561 local pages=16 # hardcoded 16 pages, don't change it.
3562 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3563 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3567 test_mkdir -p $DIR/${tdir}e
3568 $SETSTRIPE -c 1 $TDIR
3569 createmany -o $TDIR/f $files
3571 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3573 # we assume that with $OSTCOUNT files, at least one of them will
3574 # be allocated on OST0.
3575 warmup_files=$((OSTCOUNT * max_dirty_mb))
3576 createmany -o $TDIR/w $warmup_files
3578 # write a large amount of data into one file and sync, to get good
3579 # avail_grant number from OST.
3580 for ((i=0; i<$warmup_files; i++)); do
3581 idx=$($GETSTRIPE -i $TDIR/w$i)
3582 [ $idx -ne 0 ] && continue
3583 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3586 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3588 $LCTL get_param $proc_osc0/cur_dirty_bytes
3589 $LCTL get_param $proc_osc0/cur_grant_bytes
3591 # create as much dirty pages as we can while not to trigger the actual
3592 # RPCs directly. but depends on the env, VFS may trigger flush during this
3593 # period, hopefully we are good.
3594 for ((i=0; i<$warmup_files; i++)); do
3595 idx=$($GETSTRIPE -i $TDIR/w$i)
3596 [ $idx -ne 0 ] && continue
3597 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3599 $LCTL get_param $proc_osc0/cur_dirty_bytes
3600 $LCTL get_param $proc_osc0/cur_grant_bytes
3602 # perform the real test
3603 $LCTL set_param $proc_osc0/rpc_stats 0
3604 for ((;i<$files; i++)); do
3605 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3606 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3609 $LCTL get_param $proc_osc0/rpc_stats
3612 local have_ppr=false
3613 $LCTL get_param $proc_osc0/rpc_stats |
3614 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3615 # skip lines until we are at the RPC histogram data
3616 [ "$PPR" == "pages" ] && have_ppr=true && continue
3617 $have_ppr || continue
3619 # we only want the percent stat for < 16 pages
3620 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3622 percent=$((percent + WPCT))
3623 if [[ $percent -gt 15 ]]; then
3624 error "less than 16-pages write RPCs" \
3631 run_test 42e "verify sub-RPC writes are not done synchronously"
3634 test_mkdir -p $DIR/$tdir
3635 cp -p /bin/ls $DIR/$tdir/$tfile
3636 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3638 # give multiop a chance to open
3641 $DIR/$tdir/$tfile && error || true
3644 run_test 43 "execution of file opened for write should return -ETXTBSY"
3647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3648 test_mkdir -p $DIR/$tdir
3649 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3650 cp -p multiop $DIR/$tdir/multiop
3651 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3654 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3655 kill -USR1 $MULTIOP_PID || return 2
3656 wait $MULTIOP_PID || return 3
3657 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3659 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3663 test_mkdir -p $DIR/$tdir
3664 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3665 cp -p multiop $DIR/$tdir/multiop
3666 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3669 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3670 kill -USR1 $MULTIOP_PID || return 2
3671 wait $MULTIOP_PID || return 3
3672 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3674 run_test 43b "truncate of file being executed should return -ETXTBSY"
3677 local testdir="$DIR/$tdir"
3678 test_mkdir -p $DIR/$tdir
3680 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3681 ( cd $testdir && md5sum -c)
3683 run_test 43c "md5sum of copy into lustre========================"
3686 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3687 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3688 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3690 run_test 44 "zero length read from a sparse stripe ============="
3693 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3695 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3696 [[ $nstripe -gt $OSTCOUNT ]] &&
3697 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3699 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3701 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3702 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3706 OFFSETS="0 $((stride/2)) $((stride-1))"
3707 for offset in $OFFSETS; do
3708 for i in $(seq 0 $((nstripe-1))); do
3709 local GLOBALOFFSETS=""
3711 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3712 local myfn=$DIR/d44a-$size
3713 echo "--------writing $myfn at $size"
3714 ll_sparseness_write $myfn $size ||
3715 error "ll_sparseness_write"
3716 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3717 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3718 error "ll_sparseness_verify $GLOBALOFFSETS"
3720 for j in $(seq 0 $((nstripe-1))); do
3722 size=$((((j + $nstripe )*$stride + $offset)))
3723 ll_sparseness_write $myfn $size ||
3724 error "ll_sparseness_write"
3725 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3727 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3728 error "ll_sparseness_verify $GLOBALOFFSETS"
3733 run_test 44a "test sparse pwrite ==============================="
3737 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3743 before=`dirty_osc_total`
3744 echo executing "\"$*\""
3746 after=`dirty_osc_total`
3747 echo before $before, after $after
3750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3752 # Obtain grants from OST if it supports it
3753 echo blah > ${f}_grant
3756 do_dirty_record "echo blah > $f"
3757 [[ $before -eq $after ]] && error "write wasn't cached"
3758 do_dirty_record "> $f"
3759 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3760 do_dirty_record "echo blah > $f"
3761 [[ $before -eq $after ]] && error "write wasn't cached"
3762 do_dirty_record "sync"
3763 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3764 do_dirty_record "echo blah > $f"
3765 [[ $before -eq $after ]] && error "write wasn't cached"
3766 do_dirty_record "cancel_lru_locks osc"
3767 [[ $before -gt $after ]] ||
3768 error "lock cancellation didn't lower dirty count"
3771 run_test 45 "osc io page accounting ============================"
3773 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3774 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3775 # objects offset and an assert hit when an rpc was built with 1023's mapped
3776 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3778 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3782 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3784 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3785 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3789 run_test 46 "dirtying a previously written page ================"
3791 # test_47 is removed "Device nodes check" is moved to test_28
3793 test_48a() { # bug 2399
3794 check_kernel_version 34 || return 0
3795 test_mkdir -p $DIR/$tdir
3797 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3798 test_mkdir $DIR/$tdir || error "recreate directory failed"
3799 touch foo || error "'touch foo' failed after recreating cwd"
3800 test_mkdir $DIR/$tdir/bar ||
3801 error "'mkdir foo' failed after recreating cwd"
3802 if check_kernel_version 44; then
3803 touch .foo || error "'touch .foo' failed after recreating cwd"
3804 test_mkdir $DIR/$tdir/.bar ||
3805 error "'mkdir .foo' failed after recreating cwd"
3807 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3808 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3809 cd . || error "'cd .' failed after recreating cwd"
3810 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3811 rmdir . && error "'rmdir .' worked after recreating cwd"
3812 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3813 cd .. || error "'cd ..' failed after recreating cwd"
3815 run_test 48a "Access renamed working dir (should return errors)="
3817 test_48b() { # bug 2399
3818 check_kernel_version 34 || return 0
3820 test_mkdir -p $DIR/$tdir
3822 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3823 touch foo && error "'touch foo' worked after removing cwd"
3824 test_mkdir $DIR/$tdir/foo &&
3825 error "'mkdir foo' worked after removing cwd"
3826 if check_kernel_version 44; then
3827 touch .foo && error "'touch .foo' worked after removing cwd"
3828 test_mkdir $DIR/$tdir/.foo &&
3829 error "'mkdir .foo' worked after removing cwd"
3831 ls . > /dev/null && error "'ls .' worked after removing cwd"
3832 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3833 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3834 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3835 rmdir . && error "'rmdir .' worked after removing cwd"
3836 ln -s . foo && error "'ln -s .' worked after removing cwd"
3837 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3839 run_test 48b "Access removed working dir (should return errors)="
3841 test_48c() { # bug 2350
3842 check_kernel_version 36 || return 0
3843 #lctl set_param debug=-1
3846 test_mkdir -p $DIR/$tdir/dir
3848 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3849 $TRACE touch foo && error "touch foo worked after removing cwd"
3850 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3851 if check_kernel_version 44; then
3852 touch .foo && error "touch .foo worked after removing cwd"
3853 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3855 $TRACE ls . && error "'ls .' worked after removing cwd"
3856 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3857 is_patchless || ( $TRACE cd . &&
3858 error "'cd .' worked after removing cwd" )
3859 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3860 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3861 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3862 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3864 run_test 48c "Access removed working subdir (should return errors)"
3866 test_48d() { # bug 2350
3867 check_kernel_version 36 || return 0
3868 #lctl set_param debug=-1
3871 test_mkdir -p $DIR/$tdir/dir
3873 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3874 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3875 $TRACE touch foo && error "'touch foo' worked after removing parent"
3876 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3877 if check_kernel_version 44; then
3878 touch .foo && error "'touch .foo' worked after removing parent"
3880 error "mkdir .foo worked after removing parent"
3882 $TRACE ls . && error "'ls .' worked after removing parent"
3883 $TRACE ls .. && error "'ls ..' worked after removing parent"
3884 is_patchless || ( $TRACE cd . &&
3885 error "'cd .' worked after recreate parent" )
3886 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3887 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3888 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3889 is_patchless || ( $TRACE cd .. &&
3890 error "'cd ..' worked after removing parent" || true )
3892 run_test 48d "Access removed parent subdir (should return errors)"
3894 test_48e() { # bug 4134
3895 check_kernel_version 41 || return 0
3896 #lctl set_param debug=-1
3899 test_mkdir -p $DIR/$tdir/dir
3901 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3902 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3903 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3904 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3905 # On a buggy kernel addition of "touch foo" after cd .. will
3906 # produce kernel oops in lookup_hash_it
3907 touch ../foo && error "'cd ..' worked after recreate parent"
3909 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3911 run_test 48e "Access to recreated parent subdir (should return errors)"
3913 test_49() { # LU-1030
3914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3915 # get ost1 size - lustre-OST0000
3916 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3918 # write 800M at maximum
3919 [[ $ost1_size -lt 2 ]] && ost1_size=2
3920 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3922 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3923 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3926 # change max_pages_per_rpc while writing the file
3927 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3928 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3929 # loop until dd process exits
3930 while ps ax -opid | grep -wq $dd_pid; do
3931 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3932 sleep $((RANDOM % 5 + 1))
3934 # restore original max_pages_per_rpc
3935 $LCTL set_param $osc1_mppc=$orig_mppc
3936 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3938 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3942 test_mkdir $DIR/$tdir
3944 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3946 run_test 50 "special situations: /proc symlinks ==============="
3948 test_51a() { # was test_51
3949 # bug 1516 - create an empty entry right after ".." then split dir
3950 test_mkdir -c1 $DIR/$tdir
3951 touch $DIR/$tdir/foo
3952 $MCREATE $DIR/$tdir/bar
3954 createmany -m $DIR/$tdir/longfile 201
3956 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
3957 $MCREATE $DIR/$tdir/longfile$FNUM
3962 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3964 run_test 51a "special situations: split htree with empty entry =="
3966 export NUMTEST=70000
3968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3969 local BASE=$DIR/d${base}.${TESTSUITE}
3971 # cleanup the directory
3974 test_mkdir -p -c1 $BASE
3976 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3977 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3978 [[ $numfree -lt 21000 ]] && skip "not enough free inodes ($numfree)" &&
3981 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3982 echo "reduced count to $NUMTEST due to inodes"
3984 # need to check free space for the directories as well
3985 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3986 numfree=$((blkfree / 4))
3987 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
3988 echo "reduced count to $NUMTEST due to blocks"
3990 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3991 echo "failed" > $BASE/fnum
3993 run_test 51b "exceed 64k subdirectory nlink limit"
3995 test_51ba() { # LU-993
3996 local BASE=$DIR/d${base}.${TESTSUITE}
3997 # unlink all but 100 subdirectories, then check it still works
3999 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4001 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4002 local DELETE=$((NUMTEST - LEFT))
4004 # continue on to run this test even if 51b didn't finish,
4005 # just to delete the many subdirectories created.
4006 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4008 # for ldiskfs the nlink count should be 1, but this is OSD specific
4009 # and so this is listed for informational purposes only
4010 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4011 unlinkmany -d $BASE/d $DELETE
4014 if [ $RC -ne 0 ]; then
4015 if [ "$NUMPREV" == "failed" ]; then
4016 skip "previous setup failed"
4019 error "unlink of first $DELETE subdirs failed"
4024 echo "nlink between: $(stat -c %h $BASE)"
4025 # trim the first line of ls output
4026 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4027 [ $FOUND -ne $LEFT ] &&
4028 error "can't find subdirs: found only $FOUND/$LEFT"
4030 unlinkmany -d $BASE/d $DELETE $LEFT ||
4031 error "unlink of second $LEFT subdirs failed"
4032 # regardless of whether the backing filesystem tracks nlink accurately
4033 # or not, the nlink count shouldn't be more than "." and ".." here
4034 local AFTER=$(stat -c %h $BASE)
4035 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4036 echo "nlink after: $AFTER"
4038 run_test 51ba "verify nlink for many subdirectory cleanup"
4041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4042 [[ $OSTCOUNT -lt 3 ]] &&
4043 skip_env "skipping test with few OSTs" && return
4044 test_mkdir -p $DIR/$tdir
4045 createmany -o $DIR/$tdir/t- 1000
4046 $GETSTRIPE $DIR/$tdir > $TMP/files
4047 for N in $(seq 0 $((OSTCOUNT - 1))); do
4048 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4049 END { printf("%0.0f", objs) }' $TMP/files)
4050 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4051 '($1 == '$N') { objs += 1 } \
4052 END { printf("%0.0f", objs) }')
4053 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4055 unlinkmany $DIR/$tdir/t- 1000
4058 for N in $(seq 1 $((OSTCOUNT - 1))); do
4059 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4060 error "OST $N has less objects vs OST $NLAST" \
4061 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4062 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4063 error "OST $N has less objects vs OST $NLAST" \
4064 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4066 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4067 error "OST $N has less #0 objects vs OST $NLAST" \
4068 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4069 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4070 error "OST $N has less #0 objects vs OST $NLAST" \
4071 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4075 run_test 51d "check object distribution ===================="
4078 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4079 skip "Only applicable to ldiskfs-based MDTs"
4083 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4084 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4086 touch $DIR/$tdir/d0/foo
4087 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4088 error "file exceed 65000 nlink limit!"
4089 unlinkmany $DIR/$tdir/d0/f- 65001
4092 run_test 51e "check file nlink limit"
4095 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4096 test_mkdir -p $DIR/$tdir
4097 touch $DIR/$tdir/foo
4098 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4099 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4100 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4101 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4102 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4104 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4105 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4106 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4108 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4109 cp -r $DIR/$tdir /tmp/
4110 rm -fr $DIR/$tdir || error "cleanup rm failed"
4112 run_test 52a "append-only flag test (should return errors) ====="
4115 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4116 test_mkdir -p $DIR/$tdir
4117 touch $DIR/$tdir/foo
4118 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4119 cat test > $DIR/$tdir/foo && error "cat test worked"
4120 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4121 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4122 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4124 echo foo >> $DIR/$tdir/foo && error "echo worked"
4125 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4126 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4127 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4128 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4130 chattr -i $DIR/$tdir/foo || error "chattr failed"
4132 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4134 run_test 52b "immutable flag test (should return errors) ======="
4137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4138 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4139 remote_ost_nodsh && skip "remote OST with nodsh" && return
4152 local support_last_seq=true
4154 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4155 support_last_seq=false
4158 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4160 for value in $(do_facet $SINGLEMDS \
4161 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4162 param=$(echo ${value[0]} | cut -d "=" -f1)
4163 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4165 if $support_last_seq; then
4166 param_seq=$(echo $param |
4167 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4168 mds_last_seq=$(do_facet $SINGLEMDS \
4169 $LCTL get_param -n $param_seq)
4171 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4173 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4174 node=$(facet_active_host ost$((ostnum+1)))
4175 param="obdfilter.$ostname.last_id"
4176 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4177 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4178 ost_last_id=$ost_last
4180 if $support_last_seq; then
4181 ost_last_id=$(echo $ost_last |
4182 awk -F':' '{print $2}' |
4184 ost_last_seq=$(echo $ost_last |
4185 awk -F':' '{print $1}')
4186 [[ $ost_last_seq = $mds_last_seq ]] || continue
4189 if [[ $ost_last_id != $mds_last ]]; then
4190 error "$ost_last_id != $mds_last"
4197 $found || error "can not match last_seq/last_id for $mdtosc"
4200 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4203 $SOCKETSERVER $DIR/socket ||
4204 error "$SOCKETSERVER $DIR/socket failed: $?"
4205 $SOCKETCLIENT $DIR/socket ||
4206 error "$SOCKETCLIENT $DIR/socket failed: $?"
4207 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4209 run_test 54a "unix domain socket test =========================="
4215 dd if=/dev/zero of=$f bs=$(page_size) count=1
4217 run_test 54b "char device works in lustre ======================"
4220 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4221 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4222 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4224 for i in $(seq 3 7); do
4225 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4233 loopdev="$DIR/loop54c"
4236 $UMOUNT -d $DIR/$tdir || rc=$?
4237 losetup -d $loopdev || true
4238 losetup -d $LOOPDEV || true
4239 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4245 loopdev="$DIR/loop54c"
4248 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4249 trap cleanup_54c EXIT
4250 mknod $loopdev b 7 $LOOPNUM
4251 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4252 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4253 losetup $loopdev $DIR/$tfile ||
4254 error "can't set up $loopdev for $DIR/$tfile"
4255 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4256 test_mkdir -p $DIR/$tdir
4257 mount -t ext2 $loopdev $DIR/$tdir ||
4258 error "error mounting $loopdev on $DIR/$tdir"
4259 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4262 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4266 run_test 54c "block device works in lustre ====================="
4272 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4274 run_test 54d "fifo device works in lustre ======================"
4277 check_kernel_version 46 || return 0
4280 cp -aL /dev/console $f
4281 echo $string > $f || error "echo $string to $f failed"
4283 run_test 54e "console/tty device works in lustre ======================"
4285 #The test_55 used to be iopen test and it was removed by bz#24037.
4286 #run_test 55 "check iopen_connect_dentry() ======================"
4288 test_56a() { # was test_56
4291 test_mkdir -p $DIR/$tdir/dir
4293 NUMFILESx2=$(($NUMFILES * 2))
4294 for i in $(seq 1 $NUMFILES); do
4295 touch $DIR/$tdir/file$i
4296 touch $DIR/$tdir/dir/file$i
4299 # test lfs getstripe with --recursive
4300 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4301 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4302 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4303 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4304 [[ $FILENUM -eq $NUMFILES ]] ||
4305 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4306 echo "$GETSTRIPE --recursive passed."
4308 # test lfs getstripe with file instead of dir
4309 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4310 [[ $FILENUM -eq 1 ]] ||
4311 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4312 echo "$GETSTRIPE file1 passed."
4314 #test lfs getstripe with --verbose
4315 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4316 grep -c lmm_magic) -eq $NUMFILES ]] ||
4317 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4318 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4319 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4320 echo "$GETSTRIPE --verbose passed."
4322 #test lfs getstripe with --obd
4323 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4324 grep -q "unknown obduuid" ||
4325 error "$GETSTRIPE --obd wrong_uuid should return error message"
4327 [[ $OSTCOUNT -lt 2 ]] &&
4328 skip_env "skipping other $GETSTRIPE --obd test" && return
4331 OBDUUID=$(ostuuid_from_index $OSTIDX)
4332 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4333 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4334 [[ $FOUND -eq $FILENUM ]] ||
4335 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4336 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4337 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4338 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4339 error "$GETSTRIPE --obd: should not show file on other obd"
4340 echo "$GETSTRIPE --obd passed"
4342 run_test 56a "check $GETSTRIPE"
4347 local LOCAL_NUMFILES="$1"
4348 local LOCAL_NUMDIRS="$2"
4349 local MKDIR_PARAMS="$3"
4350 local DIR_STRIPE_PARAMS="$4"
4352 if [ ! -d "$TDIR" ] ; then
4353 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4354 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4355 for i in `seq 1 $LOCAL_NUMFILES` ; do
4358 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4359 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4360 for j in `seq 1 $LOCAL_NUMFILES` ; do
4361 touch $TDIR/dir$i/file$j
4367 setup_56_special() {
4371 if [ ! -e "$TDIR/loop1b" ] ; then
4372 for i in `seq 1 $LOCAL_NUMFILES` ; do
4373 mknod $TDIR/loop${i}b b 7 $i
4374 mknod $TDIR/null${i}c c 1 3
4375 ln -s $TDIR/file1 $TDIR/link${i}l
4377 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4378 mknod $TDIR/dir$i/loop${i}b b 7 $i
4379 mknod $TDIR/dir$i/null${i}c c 1 3
4380 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4389 setup_56 $NUMFILES $NUMDIRS
4391 EXPECTED=$(($NUMDIRS + 2))
4392 # test lfs find with -name
4393 for i in $(seq 1 $NUMFILES) ; do
4394 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4395 [ $NUMS -eq $EXPECTED ] ||
4396 error "lfs find -name \"*$i\" $TDIR wrong: "\
4397 "found $NUMS, expected $EXPECTED"
4400 run_test 56g "check lfs find -name ============================="
4406 setup_56 $NUMFILES $NUMDIRS
4408 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4409 # test lfs find with ! -name
4410 for i in $(seq 1 $NUMFILES) ; do
4411 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4412 [ $NUMS -eq $EXPECTED ] ||
4413 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4414 "found $NUMS, expected $EXPECTED"
4417 run_test 56h "check lfs find ! -name ============================="
4421 test_mkdir -p $DIR/$tdir
4422 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4423 CMD="$LFIND -ost $UUID $DIR/$tdir"
4425 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4427 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4431 setup_56_special $NUMFILES $NUMDIRS
4433 EXPECTED=$((NUMDIRS + 1))
4434 CMD="$LFIND -type d $TDIR"
4435 NUMS=$($CMD | wc -l)
4436 [ $NUMS -eq $EXPECTED ] ||
4437 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4439 run_test 56j "check lfs find -type d ============================="
4443 setup_56_special $NUMFILES $NUMDIRS
4445 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4446 CMD="$LFIND -type f $TDIR"
4447 NUMS=$($CMD | wc -l)
4448 [ $NUMS -eq $EXPECTED ] ||
4449 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4451 run_test 56k "check lfs find -type f ============================="
4455 setup_56_special $NUMFILES $NUMDIRS
4457 EXPECTED=$((NUMDIRS + NUMFILES))
4458 CMD="$LFIND -type b $TDIR"
4459 NUMS=$($CMD | wc -l)
4460 [ $NUMS -eq $EXPECTED ] ||
4461 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4463 run_test 56l "check lfs find -type b ============================="
4467 setup_56_special $NUMFILES $NUMDIRS
4469 EXPECTED=$((NUMDIRS + NUMFILES))
4470 CMD="$LFIND -type c $TDIR"
4471 NUMS=$($CMD | wc -l)
4472 [ $NUMS -eq $EXPECTED ] ||
4473 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4475 run_test 56m "check lfs find -type c ============================="
4479 setup_56_special $NUMFILES $NUMDIRS
4481 EXPECTED=$((NUMDIRS + NUMFILES))
4482 CMD="$LFIND -type l $TDIR"
4483 NUMS=$($CMD | wc -l)
4484 [ $NUMS -eq $EXPECTED ] ||
4485 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4487 run_test 56n "check lfs find -type l ============================="
4491 setup_56 $NUMFILES $NUMDIRS
4492 utime $TDIR/file1 > /dev/null || error "utime (1)"
4493 utime $TDIR/file2 > /dev/null || error "utime (2)"
4494 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4495 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4496 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4497 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4500 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4501 [ $NUMS -eq $EXPECTED ] || \
4502 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4505 CMD="$LFIND -mtime 0 $TDIR"
4506 NUMS=$($CMD | wc -l)
4507 [ $NUMS -eq $EXPECTED ] ||
4508 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4510 run_test 56o "check lfs find -mtime for old files =========================="
4513 [ $RUNAS_ID -eq $UID ] &&
4514 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4517 setup_56 $NUMFILES $NUMDIRS
4519 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4521 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4522 NUMS=$($CMD | wc -l)
4523 [ $NUMS -eq $EXPECTED ] || \
4524 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4526 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4527 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4528 NUMS=$($CMD | wc -l)
4529 [ $NUMS -eq $EXPECTED ] || \
4530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4532 run_test 56p "check lfs find -uid and ! -uid ==============================="
4535 [ $RUNAS_ID -eq $UID ] &&
4536 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4539 setup_56 $NUMFILES $NUMDIRS
4541 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4544 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4545 NUMS=$($CMD | wc -l)
4546 [ $NUMS -eq $EXPECTED ] ||
4547 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4550 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4551 NUMS=$($CMD | wc -l)
4552 [ $NUMS -eq $EXPECTED ] ||
4553 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4555 run_test 56q "check lfs find -gid and ! -gid ==============================="
4559 setup_56 $NUMFILES $NUMDIRS
4562 CMD="$LFIND -size 0 -type f $TDIR"
4563 NUMS=$($CMD | wc -l)
4564 [ $NUMS -eq $EXPECTED ] ||
4565 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4567 CMD="$LFIND ! -size 0 -type f $TDIR"
4568 NUMS=$($CMD | wc -l)
4569 [ $NUMS -eq $EXPECTED ] ||
4570 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4571 echo "test" > $TDIR/$tfile
4572 echo "test2" > $TDIR/$tfile.2 && sync
4574 CMD="$LFIND -size 5 -type f $TDIR"
4575 NUMS=$($CMD | wc -l)
4576 [ $NUMS -eq $EXPECTED ] ||
4577 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4579 CMD="$LFIND -size +5 -type f $TDIR"
4580 NUMS=$($CMD | wc -l)
4581 [ $NUMS -eq $EXPECTED ] ||
4582 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4584 CMD="$LFIND -size +0 -type f $TDIR"
4585 NUMS=$($CMD | wc -l)
4586 [ $NUMS -eq $EXPECTED ] ||
4587 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4589 CMD="$LFIND ! -size -5 -type f $TDIR"
4590 NUMS=$($CMD | wc -l)
4591 [ $NUMS -eq $EXPECTED ] ||
4592 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4594 CMD="$LFIND -size -5 -type f $TDIR"
4595 NUMS=$($CMD | wc -l)
4596 [ $NUMS -eq $EXPECTED ] ||
4597 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4599 run_test 56r "check lfs find -size works =========================="
4601 test_56s() { # LU-611
4603 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4605 if [[ $OSTCOUNT -gt 1 ]]; then
4606 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4610 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4614 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4615 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4616 NUMS=$($CMD | wc -l)
4617 [ $NUMS -eq $EXPECTED ] || {
4619 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4622 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4623 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4624 NUMS=$($CMD | wc -l)
4625 [ $NUMS -eq $EXPECTED ] || {
4627 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4631 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4632 NUMS=$($CMD | wc -l)
4633 [ $NUMS -eq $EXPECTED ] || {
4635 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4638 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4639 NUMS=$($CMD | wc -l)
4640 [ $NUMS -eq $EXPECTED ] || {
4642 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4646 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4647 NUMS=$($CMD | wc -l)
4648 [ $NUMS -eq $EXPECTED ] || {
4650 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4653 run_test 56s "check lfs find -stripe-count works"
4655 test_56t() { # LU-611
4657 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4659 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4661 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4662 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4663 NUMS=$($CMD | wc -l)
4664 [ $NUMS -eq $EXPECTED ] ||
4665 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4667 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4668 NUMS=$($CMD | wc -l)
4669 [ $NUMS -eq $EXPECTED ] ||
4670 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4672 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4673 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4674 NUMS=$($CMD | wc -l)
4675 [ $NUMS -eq $EXPECTED ] ||
4676 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4678 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4679 NUMS=$($CMD | wc -l)
4680 [ $NUMS -eq $EXPECTED ] ||
4681 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4684 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4685 NUMS=$($CMD | wc -l)
4686 [ $NUMS -eq $EXPECTED ] ||
4687 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4689 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4690 NUMS=$($CMD | wc -l)
4691 [ $NUMS -eq $EXPECTED ] ||
4692 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4695 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4696 NUMS=$($CMD | wc -l)
4697 [ $NUMS -eq $EXPECTED ] ||
4698 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4700 run_test 56t "check lfs find -stripe-size works"
4702 test_56u() { # LU-611
4704 setup_56 $NUMFILES $NUMDIRS "-i 0"
4706 if [[ $OSTCOUNT -gt 1 ]]; then
4707 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4713 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4714 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4715 NUMS=$($CMD | wc -l)
4716 [ $NUMS -eq $EXPECTED ] ||
4717 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4720 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4721 NUMS=$($CMD | wc -l)
4722 [ $NUMS -eq $EXPECTED ] ||
4723 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4725 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4726 NUMS=$($CMD | wc -l)
4727 [ $NUMS -eq $EXPECTED ] ||
4728 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4731 # This should produce an error and not return any files
4732 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4733 NUMS=$($CMD 2>/dev/null | wc -l)
4734 [ $NUMS -eq $EXPECTED ] ||
4735 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4737 if [[ $OSTCOUNT -gt 1 ]]; then
4738 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4739 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4740 NUMS=$($CMD | wc -l)
4741 [ $NUMS -eq $EXPECTED ] ||
4742 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4745 run_test 56u "check lfs find -stripe-index works"
4752 setup_56 $NUMFILES $NUMDIRS
4754 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4755 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4757 for file in $($LFIND -mdt $UUID $TDIR); do
4758 file_mdt_idx=$($GETSTRIPE -M $file)
4759 [ $file_mdt_idx -eq $MDT_IDX ] ||
4760 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4763 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4765 # Get and check the actual stripe count of one file.
4766 # Usage: check_stripe_count <file> <expected_stripe_count>
4767 check_stripe_count() {
4772 [[ -z "$file" || -z "$expected" ]] &&
4773 error "check_stripe_count: invalid argument!"
4775 local cmd="$GETSTRIPE -c $file"
4776 actual=$($cmd) || error "$cmd failed"
4777 actual=${actual%% *}
4779 if [[ $actual -ne $expected ]]; then
4780 [[ $expected -eq -1 ]] ||
4781 error "$cmd wrong: found $actual, expected $expected"
4782 [[ $actual -eq $OSTCOUNT ]] ||
4783 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4791 rm -rf $TDIR || error "remove $TDIR failed"
4792 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4795 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4796 error "$GETSTRIPE -S -d $TDIR failed"
4797 stripe_size=${stripe_size%% *}
4799 local file_size=$((stripe_size * OSTCOUNT))
4800 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4801 local required_space=$((file_num * file_size))
4802 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4803 [[ $free_space -le $((required_space / 1024)) ]] &&
4804 skip_env "need at least $required_space bytes free space," \
4805 "have $free_space kbytes" && return
4808 local dd_count=$((file_size / dd_bs))
4810 # write data into the files
4814 for i in $(seq 1 $NUMFILES); do
4816 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4817 error "write data into $file failed"
4819 for i in $(seq 1 $NUMDIRS); do
4820 for j in $(seq 1 $NUMFILES); do
4821 file=$TDIR/dir$i/file$j
4822 yes | dd bs=$dd_bs count=$dd_count of=$file \
4824 error "write data into $file failed"
4829 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4832 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4834 eval $cmd || error "$cmd failed"
4836 check_stripe_count $TDIR/file1 $expected
4839 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4841 eval $cmd || error "$cmd failed"
4843 for j in $(seq 1 $NUMFILES); do
4844 check_stripe_count $TDIR/dir1/file$j $expected
4847 # lfs_migrate works with lfs find
4848 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4849 $LFS_MIGRATE -y -c $expected"
4851 eval $cmd || error "$cmd failed"
4853 for i in $(seq 2 $NUMFILES); do
4854 check_stripe_count $TDIR/file$i $expected
4856 for i in $(seq 2 $NUMDIRS); do
4857 for j in $(seq 1 $NUMFILES); do
4858 check_stripe_count $TDIR/dir$i/file$j $expected
4862 run_test 56w "check lfs_migrate -c stripe_count works"
4865 check_swap_layouts_support && return 0
4866 [[ $OSTCOUNT -lt 2 ]] &&
4867 skip_env "need 2 OST, skipping test" && return
4869 local dir0=$DIR/$tdir/$testnum
4870 mkdir -p $dir0 || error "creating dir $dir0"
4872 local ref1=/etc/passwd
4873 local file1=$dir0/file1
4875 $SETSTRIPE -c 2 $file1
4877 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4878 stripe=$($GETSTRIPE -c $file1)
4879 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4880 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4885 run_test 56x "lfs migration support"
4888 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4889 skip "No HSM support on MDS of $(get_lustre_version)," \
4890 "need 2.4.53 at least" && return
4893 local dir0=$DIR/$tdir/$testnum
4894 mkdir -p $dir0 || error "creating dir $dir0"
4895 local f1=$dir0/file1
4896 local f2=$dir0/file2
4898 touch $f1 || error "creating std file $f1"
4899 $MULTIOP $f2 H2c || error "creating released file $f2"
4901 # a directory can be raid0, so ask only for files
4902 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4903 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4905 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4906 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4908 # only files can be released, so no need to force file search
4909 res=$($LFIND $dir0 -L released)
4910 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4912 res=$($LFIND $dir0 \! -L released)
4913 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4916 run_test 56y "lfs find -L raid0|released"
4918 test_56z() { # LU-4824
4919 # This checks to make sure 'lfs find' continues after errors
4920 # There are two classes of errors that should be caught:
4921 # - If multiple paths are provided, all should be searched even if one
4923 # - If errors are encountered during the search, it should not terminate
4926 test_mkdir $DIR/$tdir
4927 for i in d{0..9}; do
4928 test_mkdir $DIR/$tdir/$i
4930 touch $DIR/$tdir/d{0..9}/$tfile
4931 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4932 error "$LFS find did not return an error"
4933 # Make a directory unsearchable. This should NOT be the last entry in
4934 # directory order. Arbitrarily pick the 6th entry
4935 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
4936 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
4937 # The user should be able to see 10 directories and 9 files
4938 [ $count == 19 ] || error "$LFS find did not continue after error"
4940 run_test 56z "lfs find should continue after an error"
4943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4944 # note test will not do anything if MDS is not local
4945 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4946 skip "Only applicable to ldiskfs-based MDTs"
4950 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4951 local MNTDEV="osd*.*MDT*.mntdev"
4952 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4953 [ -z "$DEV" ] && error "can't access $MNTDEV"
4954 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4955 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4956 error "can't access $DEV"
4957 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
4958 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
4962 run_test 57a "verify MDS filesystem created with large inodes =="
4965 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4966 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4967 skip "Only applicable to ldiskfs-based MDTs"
4971 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4976 local FILEN=$dir/f$FILECOUNT
4978 rm -rf $dir || error "removing $dir"
4979 test_mkdir -p $dir || error "creating $dir"
4980 local num=$(get_mds_dir $dir)
4983 echo "mcreating $FILECOUNT files"
4984 createmany -m $dir/f 1 $FILECOUNT || \
4985 error "creating files in $dir"
4987 # verify that files do not have EAs yet
4988 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4989 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4993 df $dir #make sure we get new statfs data
4994 local MDSFREE=$(do_facet $mymds \
4995 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4996 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4997 echo "opening files to create objects/EAs"
4999 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5000 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5003 # verify that files have EAs now
5004 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5005 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5007 sleep 1 #make sure we get new statfs data
5009 local MDSFREE2=$(do_facet $mymds \
5010 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
5011 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
5012 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5013 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5014 error "MDC before $MDCFREE != after $MDCFREE2"
5016 echo "MDC before $MDCFREE != after $MDCFREE2"
5017 echo "unable to confirm if MDS has large inodes"
5022 run_test 57b "default LOV EAs are stored inside large inodes ==="
5025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5026 [ -z "$(which wiretest 2>/dev/null)" ] &&
5027 skip_env "could not find wiretest" && return
5030 run_test 58 "verify cross-platform wire constants =============="
5033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5034 echo "touch 130 files"
5035 createmany -o $DIR/f59- 130
5037 unlinkmany $DIR/f59- 130
5039 # wait for commitment of removal
5040 wait_delete_completed
5042 run_test 59 "verify cancellation of llog records async ========="
5044 TEST60_HEAD="test_60 run $RANDOM"
5046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5047 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5048 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5049 skip_env "missing subtest run-llog.sh" && return
5050 log "$TEST60_HEAD - from kernel mode"
5051 do_facet mgs sh run-llog.sh
5053 run_test 60a "llog sanity tests run from kernel module =========="
5055 test_60b() { # bug 6411
5056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5058 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5070 [[ $LLOG_COUNT -gt 50 ]] &&
5071 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5073 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5077 echo "create 5000 files"
5078 createmany -o $DIR/f60c- 5000
5079 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5080 lctl set_param fail_loc=0x80000137
5081 unlinkmany $DIR/f60c- 5000
5082 lctl set_param fail_loc=0
5084 run_test 60c "unlink file when mds full"
5087 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5088 SAVEPRINTK=$(lctl get_param -n printk)
5090 # verify "lctl mark" is even working"
5091 MESSAGE="test message ID $RANDOM $$"
5092 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5093 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5095 lctl set_param printk=0 || error "set lnet.printk failed"
5096 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5097 MESSAGE="new test message ID $RANDOM $$"
5098 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5099 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5100 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5102 lctl set_param -n printk="$SAVEPRINTK"
5104 run_test 60d "test printk console message masking"
5107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5109 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5110 cancel_lru_locks osc
5111 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5114 run_test 61 "mmap() writes don't make sync hang ================"
5116 # bug 2330 - insufficient obd_match error checking causes LBUG
5118 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5121 cancel_lru_locks osc
5122 lctl set_param fail_loc=0x405
5123 cat $f && error "cat succeeded, expect -EIO"
5124 lctl set_param fail_loc=0
5126 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5127 # match every page all of the time.
5128 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5130 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5131 # Though this test is irrelevant anymore, it helped to reveal some
5132 # other grant bugs (LU-4482), let's keep it.
5133 test_63a() { # was test_63
5134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5135 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5136 for i in `seq 10` ; do
5137 dd if=/dev/zero of=$DIR/f63 bs=8k &
5143 rm -f $DIR/f63 || true
5145 run_test 63a "Verify oig_wait interruption does not crash ======="
5147 # bug 2248 - async write errors didn't return to application on sync
5148 # bug 3677 - async write errors left page locked
5150 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5152 lctl set_param debug=-1
5154 # ensure we have a grant to do async writes
5155 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5158 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5159 lctl set_param fail_loc=0x80000406
5160 $MULTIOP $DIR/$tfile Owy && \
5161 error "sync didn't return ENOMEM"
5162 sync; sleep 2; sync # do a real sync this time to flush page
5163 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5164 error "locked page left in cache after async error" || true
5167 run_test 63b "async write errors should be returned to fsync ==="
5170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5172 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5174 run_test 64a "verify filter grant calculations (in kernel) ====="
5177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5178 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5180 run_test 64b "check out-of-space detection on client ==========="
5183 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5185 run_test 64c "verify grant shrink ========================------"
5187 # bug 1414 - set/get directories' stripe info
5189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5190 test_mkdir -p $DIR/$tdir
5192 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5194 run_test 65a "directory with no stripe info ===================="
5197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5198 test_mkdir -p $DIR/$tdir
5199 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5202 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5204 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5208 if [[ $OSTCOUNT -gt 1 ]]; then
5209 test_mkdir -p $DIR/$tdir
5210 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5211 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5213 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5216 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5220 test_mkdir -p $DIR/$tdir
5221 if [[ $STRIPECOUNT -le 0 ]]; then
5223 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5224 #LOV_MAX_STRIPE_COUNT is 2000
5225 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5227 sc=$(($STRIPECOUNT - 1))
5229 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5230 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5231 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5232 error "lverify failed"
5234 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5237 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5238 test_mkdir -p $DIR/$tdir
5240 $SETSTRIPE $DIR/$tdir || error "setstripe"
5241 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5242 error "no stripe info failed"
5244 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5246 run_test 65e "directory setstripe defaults ======================="
5249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5250 test_mkdir -p $DIR/${tdir}f
5251 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5253 run_test 65f "dir setstripe permission (should return error) ==="
5256 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5257 test_mkdir -p $DIR/$tdir
5258 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5260 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5261 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5262 error "delete default stripe failed"
5264 run_test 65g "directory setstripe -d ==========================="
5267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5268 test_mkdir -p $DIR/$tdir
5269 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5271 test_mkdir -p $DIR/$tdir/dd1
5272 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5273 error "stripe info inherit failed"
5275 run_test 65h "directory stripe info inherit ===================="
5277 test_65i() { # bug6367
5278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5279 $SETSTRIPE -S 65536 -c -1 $MOUNT
5281 run_test 65i "set non-default striping on root directory (bug 6367)="
5283 test_65ia() { # bug12836
5284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5285 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5287 run_test 65ia "getstripe on -1 default directory striping"
5289 test_65ib() { # bug12836
5290 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5291 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5293 run_test 65ib "getstripe -v on -1 default directory striping"
5295 test_65ic() { # bug12836
5296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5297 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5299 run_test 65ic "new find on -1 default directory striping"
5301 test_65j() { # bug6367
5302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5304 # if we aren't already remounting for each test, do so for this test
5305 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5306 cleanup || error "failed to unmount"
5309 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5311 run_test 65j "set default striping on root directory (bug 6367)="
5313 test_65k() { # bug11679
5314 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5315 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5316 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5318 echo "Check OST status: "
5319 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5320 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5322 for OSC in $MDS_OSCS; do
5323 echo $OSC "is activate"
5324 do_facet $SINGLEMDS lctl --device %$OSC activate
5328 for INACTIVE_OSC in $MDS_OSCS; do
5329 echo "Deactivate: " $INACTIVE_OSC
5330 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5331 for STRIPE_OSC in $MDS_OSCS; do
5332 OST=`osc_to_ost $STRIPE_OSC`
5333 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5334 awk -F: /$OST/'{ print $1 }' | head -n 1`
5336 [ -f $DIR/$tdir/$IDX ] && continue
5337 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5338 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5340 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5343 echo $INACTIVE_OSC "is Activate."
5344 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5347 run_test 65k "validate manual striping works properly with deactivated OSCs"
5349 test_65l() { # bug 12836
5350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5351 test_mkdir -p $DIR/$tdir/test_dir
5352 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5353 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5355 run_test 65l "lfs find on -1 stripe dir ========================"
5357 # bug 2543 - update blocks count on client
5359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5361 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5362 sync; sync_all_data; sync; sync_all_data
5363 cancel_lru_locks osc
5364 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5365 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5367 run_test 66 "update inode blocks count on client ==============="
5372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5374 if [ ! -z "$LLOOP" ]; then
5375 if swapon -s | grep -q $LLOOP; then
5376 swapoff $LLOOP || error "swapoff failed"
5379 $LCTL blockdev_detach $LLOOP || error "detach failed"
5383 if [ ! -z "$LLITELOOPLOAD" ]; then
5391 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5395 swapon -s | awk '($1 == "'$1'") { print $4 }'
5398 # test case for lloop driver, basic function
5400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5401 [ "$UID" != 0 ] && skip_env "must run as root" && return
5402 llite_lloop_enabled || \
5403 { skip_env "llite_lloop module disabled" && return; }
5405 trap cleanup_68 EXIT
5407 if ! module_loaded llite_lloop; then
5408 if load_module llite/llite_lloop; then
5411 skip_env "can't find module llite_lloop"
5416 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5417 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5418 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5420 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5421 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5425 run_test 68a "lloop driver - basic test ========================"
5427 # excercise swapping to lustre by adding a high priority swapfile entry
5428 # and then consuming memory until it is used.
5429 test_68b() { # was test_68
5430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5431 [ "$UID" != 0 ] && skip_env "must run as root" && return
5432 lctl get_param -n devices | grep -q obdfilter && \
5433 skip "local OST" && return
5435 grep -q llite_lloop /proc/modules
5436 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5438 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5439 skip "can't reliably test swap with TCP" && return
5441 MEMTOTAL=`meminfo MemTotal`
5442 NR_BLOCKS=$((MEMTOTAL>>8))
5443 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5445 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5446 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5449 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5451 trap cleanup_68 EXIT
5453 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5455 echo "before: `swapon -s | grep $LLOOP`"
5456 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5457 echo "after: `swapon -s | grep $LLOOP`"
5458 SWAPUSED=`swap_used $LLOOP`
5462 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5464 run_test 68b "support swapping to Lustre ========================"
5466 # bug5265, obdfilter oa2dentry return -ENOENT
5467 # #define OBD_FAIL_OST_ENOENT 0x217
5469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5470 remote_ost_nodsh && skip "remote OST with nodsh" && return
5473 $SETSTRIPE -c 1 -i 0 $f
5475 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5477 do_facet ost1 lctl set_param fail_loc=0x217
5478 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5479 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5481 do_facet ost1 lctl set_param fail_loc=0
5482 $DIRECTIO write $f 0 2 || error "write error"
5484 cancel_lru_locks osc
5485 $DIRECTIO read $f 0 1 || error "read error"
5487 do_facet ost1 lctl set_param fail_loc=0x217
5488 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5490 do_facet ost1 lctl set_param fail_loc=0
5493 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5496 test_mkdir -p $DIR/$tdir
5497 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5499 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5501 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5502 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5503 [ "$RUNAS_ID" = "$UID" ] &&
5504 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5506 # Check that testing environment is properly set up. Skip if not
5507 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5508 skip_env "User $RUNAS_ID does not exist - skipping"
5512 chmod 777 $DIR/$tfile
5513 chmod ug+s $DIR/$tfile
5514 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5515 error "$RUNAS dd $DIR/$tfile failed"
5516 # See if we are still setuid/sgid
5517 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5518 error "S/gid is not dropped on write"
5519 # Now test that MDS is updated too
5520 cancel_lru_locks mdc
5521 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5522 error "S/gid is not dropped on MDS"
5525 run_test 72a "Test that remove suid works properly (bug5695) ===="
5527 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5530 [ "$RUNAS_ID" = "$UID" ] && \
5531 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5532 [ "$RUNAS_ID" -eq 0 ] && \
5533 skip_env "RUNAS_ID = 0 -- skipping" && return
5535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5536 # Check that testing environment is properly set up. Skip if not
5537 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5538 skip_env "User $RUNAS_ID does not exist - skipping"
5541 touch $DIR/${tfile}-f{g,u}
5542 test_mkdir $DIR/${tfile}-dg
5543 test_mkdir $DIR/${tfile}-du
5544 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5545 chmod g+s $DIR/${tfile}-{f,d}g
5546 chmod u+s $DIR/${tfile}-{f,d}u
5547 for perm in 777 2777 4777; do
5548 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5549 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5550 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5551 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5555 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5557 # bug 3462 - multiple simultaneous MDC requests
5559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5560 test_mkdir $DIR/d73-1
5561 test_mkdir $DIR/d73-2
5562 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5565 lctl set_param fail_loc=0x80000129
5566 $MULTIOP $DIR/d73-1/f73-2 Oc &
5568 lctl set_param fail_loc=0
5570 $MULTIOP $DIR/d73-2/f73-3 Oc &
5574 wait $pid1 || return 1
5578 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5579 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5580 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5584 run_test 73 "multiple MDC requests (should not deadlock)"
5586 test_74a() { # bug 6149, 6184
5587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5588 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5590 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5591 # will spin in a tight reconnection loop
5593 $LCTL set_param fail_loc=0x8000030e
5594 # get any lock that won't be difficult - lookup works.
5596 $LCTL set_param fail_loc=0
5600 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5602 test_74b() { # bug 13310
5603 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5604 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5606 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5607 # will spin in a tight reconnection loop
5608 $LCTL set_param fail_loc=0x8000030e
5609 # get a "difficult" lock
5611 $LCTL set_param fail_loc=0
5615 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5618 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5619 #define OBD_FAIL_LDLM_NEW_LOCK
5620 $LCTL set_param fail_loc=0x319
5621 touch $DIR/$tfile && error "touch successful"
5622 $LCTL set_param fail_loc=0
5625 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5628 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5631 get_inode_slab_tunables() {
5632 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5635 set_inode_slab_tunables() {
5636 echo "lustre_inode_cache $1" > /proc/slabinfo
5639 test_76() { # Now for bug 20433, added originally in bug 1443
5640 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5641 local SLAB_SETTINGS=`get_inode_slab_tunables`
5642 local CPUS=`getconf _NPROCESSORS_ONLN`
5643 # we cannot set limit below 1 which means 1 inode in each
5644 # per-cpu cache is still allowed
5645 set_inode_slab_tunables "1 1 0"
5646 cancel_lru_locks osc
5647 BEFORE_INODES=$(num_inodes)
5648 echo "before inodes: $BEFORE_INODES"
5650 [ "$SLOW" = "no" ] && COUNT=100
5651 for i in $(seq $COUNT); do
5655 cancel_lru_locks osc
5656 AFTER_INODES=$(num_inodes)
5657 echo "after inodes: $AFTER_INODES"
5659 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5661 AFTER_INODES=$(num_inodes)
5663 echo "wait $wait seconds inodes: $AFTER_INODES"
5664 if [ $wait -gt 30 ]; then
5665 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5668 set_inode_slab_tunables "$SLAB_SETTINGS"
5670 run_test 76 "confirm clients recycle inodes properly ===="
5676 # Note: in sptlrpc modes which enable its own bulk checksum, the
5677 # original crc32_le bulk checksum will be automatically disabled,
5678 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5679 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5680 # In this case set_checksums() will not be no-op, because sptlrpc
5681 # bulk checksum will be enabled all through the test.
5683 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5684 lctl set_param -n osc.*.checksums $1
5688 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5689 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5690 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5691 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5694 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5695 log "set checksum type to $1"
5698 F77_TMP=$TMP/f77-temp
5701 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5702 error "error writing to $F77_TMP"
5705 test_77a() { # bug 10889
5706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5707 $GSS && skip "could not run with gss" && return
5708 [ ! -f $F77_TMP ] && setup_f77
5710 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5714 run_test 77a "normal checksum read/write operation"
5716 test_77b() { # bug 10889
5717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5718 $GSS && skip "could not run with gss" && return
5719 [ ! -f $F77_TMP ] && setup_f77
5720 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5721 $LCTL set_param fail_loc=0x80000409
5724 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5725 error "dd error: $?"
5726 $LCTL set_param fail_loc=0
5728 for algo in $CKSUM_TYPES; do
5729 cancel_lru_locks osc
5730 set_checksum_type $algo
5731 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5732 $LCTL set_param fail_loc=0x80000408
5733 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5734 $LCTL set_param fail_loc=0
5737 set_checksum_type $ORIG_CSUM_TYPE
5740 run_test 77b "checksum error on client write, read"
5742 test_77d() { # bug 10889
5743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5744 $GSS && skip "could not run with gss" && return
5745 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5746 $LCTL set_param fail_loc=0x80000409
5748 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5749 error "direct write: rc=$?"
5750 $LCTL set_param fail_loc=0
5753 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5754 $LCTL set_param fail_loc=0x80000408
5756 cancel_lru_locks osc
5757 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5758 error "direct read: rc=$?"
5759 $LCTL set_param fail_loc=0
5762 run_test 77d "checksum error on OST direct write, read"
5764 test_77f() { # bug 10889
5765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5766 $GSS && skip "could not run with gss" && return
5768 for algo in $CKSUM_TYPES; do
5769 cancel_lru_locks osc
5770 set_checksum_type $algo
5771 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5772 $LCTL set_param fail_loc=0x409
5773 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5774 error "direct write succeeded"
5775 $LCTL set_param fail_loc=0
5777 set_checksum_type $ORIG_CSUM_TYPE
5780 run_test 77f "repeat checksum error on write (expect error)"
5782 test_77g() { # bug 10889
5783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5784 $GSS && skip "could not run with gss" && return
5785 remote_ost_nodsh && skip "remote OST with nodsh" && return
5787 [ ! -f $F77_TMP ] && setup_f77
5789 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5790 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5791 do_facet ost1 lctl set_param fail_loc=0x8000021a
5793 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5794 error "write error: rc=$?"
5795 do_facet ost1 lctl set_param fail_loc=0
5798 cancel_lru_locks osc
5799 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5800 do_facet ost1 lctl set_param fail_loc=0x8000021b
5802 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5803 do_facet ost1 lctl set_param fail_loc=0
5806 run_test 77g "checksum error on OST write, read"
5808 test_77i() { # bug 13805
5809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5810 $GSS && skip "could not run with gss" && return
5811 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5812 lctl set_param fail_loc=0x40b
5813 remount_client $MOUNT
5814 lctl set_param fail_loc=0
5815 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5816 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5817 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5818 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5820 remount_client $MOUNT
5822 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5824 test_77j() { # bug 13805
5825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5826 $GSS && skip "could not run with gss" && return
5827 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5828 lctl set_param fail_loc=0x40c
5829 remount_client $MOUNT
5830 lctl set_param fail_loc=0
5831 sleep 2 # wait async osc connect to finish
5832 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5833 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5834 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5835 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5837 remount_client $MOUNT
5839 run_test 77j "client only supporting ADLER32"
5841 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5845 test_78() { # bug 10901
5846 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5847 remote_ost || { skip_env "local OST" && return; }
5850 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5851 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5852 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5853 echo "MemTotal: $MEMTOTAL"
5855 # reserve 256MB of memory for the kernel and other running processes,
5856 # and then take 1/2 of the remaining memory for the read/write buffers.
5857 if [ $MEMTOTAL -gt 512 ] ;then
5858 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5860 # for those poor memory-starved high-end clusters...
5861 MEMTOTAL=$((MEMTOTAL / 2))
5863 echo "Mem to use for directio: $MEMTOTAL"
5865 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5866 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5867 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5868 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5870 echo "Smallest OST: $SMALLESTOST"
5871 [[ $SMALLESTOST -lt 10240 ]] &&
5872 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5874 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5875 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5877 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5878 echo "File size: $F78SIZE"
5879 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5880 for i in $(seq 1 $NSEQ); do
5881 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5882 echo directIO rdwr round $i of $NSEQ
5883 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5888 run_test 78 "handle large O_DIRECT writes correctly ============"
5890 test_79() { # bug 12743
5891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5892 wait_delete_completed
5894 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5895 BKFREE=$(calc_osc_kbytes kbytesfree)
5896 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5898 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5899 DFTOTAL=`echo $STRING | cut -d, -f1`
5900 DFUSED=`echo $STRING | cut -d, -f2`
5901 DFAVAIL=`echo $STRING | cut -d, -f3`
5902 DFFREE=$(($DFTOTAL - $DFUSED))
5904 ALLOWANCE=$((64 * $OSTCOUNT))
5906 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5907 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5908 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5910 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5911 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5912 error "df free($DFFREE) mismatch OST free($BKFREE)"
5914 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5915 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5916 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5919 run_test 79 "df report consistency check ======================="
5921 test_80() { # bug 10718
5922 remote_ost_nodsh && skip "remote OST with nodsh" && return
5923 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5924 # relax strong synchronous semantics for slow backends like ZFS
5925 local soc="obdfilter.*.sync_on_lock_cancel"
5926 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5928 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5929 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5930 facet_active_host $host; done | sort -u)
5931 do_nodes $hosts lctl set_param $soc=never
5934 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5936 local BEFORE=`date +%s`
5937 cancel_lru_locks osc
5938 local AFTER=`date +%s`
5939 local DIFF=$((AFTER-BEFORE))
5940 if [ $DIFF -gt 1 ] ; then
5941 error "elapsed for 1M@1T = $DIFF"
5944 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5948 run_test 80 "Page eviction is equally fast at high offsets too ===="
5950 test_81a() { # LU-456
5951 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5952 remote_ost_nodsh && skip "remote OST with nodsh" && return
5953 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5954 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5955 do_facet ost1 lctl set_param fail_loc=0x80000228
5957 # write should trigger a retry and success
5958 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5959 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5961 if [ $RC -ne 0 ] ; then
5962 error "write should success, but failed for $RC"
5965 run_test 81a "OST should retry write when get -ENOSPC ==============="
5967 test_81b() { # LU-456
5968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5969 remote_ost_nodsh && skip "remote OST with nodsh" && return
5970 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5971 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5972 do_facet ost1 lctl set_param fail_loc=0x228
5974 # write should retry several times and return -ENOSPC finally
5975 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5976 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5979 if [ $RC -ne $ENOSPC ] ; then
5980 error "dd should fail for -ENOSPC, but succeed."
5983 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5985 test_82() { # LU-1031
5986 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5990 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5992 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5994 kill -USR1 $MULTIPID2
5996 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5997 error "First grouplock does not block second one"
5999 echo "Second grouplock blocks first one"
6001 kill -USR1 $MULTIPID1
6005 run_test 82 "Basic grouplock test ==============================="
6008 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6010 test_mkdir -p $DIR/d99cvsroot
6011 chown $RUNAS_ID $DIR/d99cvsroot
6012 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6015 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6018 run_test 99a "cvs init ========================================="
6021 [ -z "$(which cvs 2>/dev/null)" ] &&
6022 skip_env "could not find cvs" && return
6023 [ ! -d $DIR/d99cvsroot ] && test_99a
6025 # some versions of cvs import exit(1) when asked to import links or
6026 # files they can't read. ignore those files.
6027 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6028 ! -perm +4 -printf '-I %f\n')
6029 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6030 d99reposname vtag rtag
6032 run_test 99b "cvs import ======================================="
6035 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6036 [ ! -d $DIR/d99cvsroot ] && test_99b
6038 test_mkdir -p $DIR/d99reposname
6039 chown $RUNAS_ID $DIR/d99reposname
6040 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6042 run_test 99c "cvs checkout ====================================="
6045 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6046 [ ! -d $DIR/d99cvsroot ] && test_99c
6047 cd $DIR/d99reposname
6049 $RUNAS cvs add -m 'addmsg' foo99
6051 run_test 99d "cvs add =========================================="
6054 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6055 [ ! -d $DIR/d99cvsroot ] && test_99c
6056 cd $DIR/d99reposname
6059 run_test 99e "cvs update ======================================="
6062 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6063 [ ! -d $DIR/d99cvsroot ] && test_99d
6064 cd $DIR/d99reposname
6065 $RUNAS cvs commit -m 'nomsg' foo99
6066 rm -fr $DIR/d99cvsroot
6068 run_test 99f "cvs commit ======================================="
6071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6072 [ "$NETTYPE" = tcp ] || \
6073 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6076 remote_ost_nodsh && skip "remote OST with nodsh" && return
6077 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6079 { skip "useless for local single node setup" && return; }
6081 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6082 [ "$PROT" != "tcp" ] && continue
6083 RPORT=$(echo $REMOTE | cut -d: -f2)
6084 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6087 LPORT=`echo $LOCAL | cut -d: -f2`
6088 if [ $LPORT -ge 1024 ]; then
6089 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6091 error_exit "local: $LPORT > 1024, remote: $RPORT"
6094 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6096 run_test 100 "check local port using privileged port ==========="
6098 function get_named_value()
6107 echo $line | sed "s/^$tag[ ]*//"
6114 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6115 awk '/^max_cached_mb/ { print $2 }')
6118 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6123 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6124 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6128 local cache_limit=32
6130 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6131 trap cleanup_101a EXIT
6132 $LCTL set_param -n llite.*.read_ahead_stats 0
6133 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6136 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6138 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6139 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6142 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6143 get_named_value 'read but discarded' | cut -d" " -f1); do
6144 discard=$(($discard + $s))
6148 if [[ $(($discard * 10)) -gt $nreads ]]; then
6149 $LCTL get_param osc.*-osc*.rpc_stats
6150 $LCTL get_param llite.*.read_ahead_stats
6151 error "too many ($discard) discarded pages"
6153 rm -f $DIR/$tfile || true
6155 run_test 101a "check read-ahead for random reads ================"
6158 test_mkdir -p $DIR/$tdir
6159 local STRIPE_SIZE=$1
6160 local FILE_LENGTH=$2
6163 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6165 local list=$(comma_list $(osts_nodes))
6166 set_osd_param $list '' read_cache_enable 0
6167 set_osd_param $list '' writethrough_cache_enable 0
6169 trap cleanup_test101bc EXIT
6170 # prepare the read-ahead file
6171 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6173 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6174 count=$FILE_SIZE_MB 2> /dev/null
6178 cleanup_test101bc() {
6183 local list=$(comma_list $(osts_nodes))
6184 set_osd_param $list '' read_cache_enable 1
6185 set_osd_param $list '' writethrough_cache_enable 1
6189 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6194 local STRIPE_SIZE=$2
6195 local FILE_LENGTH=$3
6196 local RA_INC=1048576
6197 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6198 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6199 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6200 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6201 get_named_value 'read but discarded' |
6202 cut -d" " -f1 | calc_total)
6203 if [[ $DISCARD -gt $discard_limit ]]; then
6204 $LCTL get_param llite.*.read_ahead_stats
6205 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6207 echo "Read-ahead success for size ${READ_SIZE}"
6212 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6213 [[ $OSTCOUNT -lt 2 ]] &&
6214 skip_env "skipping stride IO stride-ahead test" && return
6215 local STRIPE_SIZE=1048576
6216 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6217 if [ $SLOW == "yes" ]; then
6218 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6220 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6223 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6225 # prepare the read-ahead file
6226 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6227 cancel_lru_locks osc
6228 for BIDX in 2 4 8 16 32 64 128 256
6230 local BSIZE=$((BIDX*4096))
6231 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6232 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6233 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6234 $LCTL set_param -n llite.*.read_ahead_stats 0
6235 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6236 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6237 cancel_lru_locks osc
6238 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6243 run_test 101b "check stride-io mode read-ahead ================="
6246 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6247 local STRIPE_SIZE=1048576
6248 local FILE_LENGTH=$((STRIPE_SIZE*100))
6252 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6254 cancel_lru_locks osc
6255 $LCTL set_param osc.*.rpc_stats 0
6256 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6257 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6258 local stats=$($LCTL get_param -n $osc_rpc_stats)
6259 local lines=$(echo "$stats" | awk 'END {print NR;}')
6262 if [ $lines -le 20 ]; then
6265 for size in 1 2 4 8; do
6266 local rpc=$(echo "$stats" |
6267 awk '($1 == "'$size':") {print $2; exit; }')
6269 error "Small $((size*4))k read IO $rpc !"
6271 echo "$osc_rpc_stats check passed!"
6276 run_test 101c "check stripe_size aligned read-ahead ================="
6279 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6280 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6285 local file=$DIR/$tfile
6286 local sz_MB=${FILESIZE_101d:-500}
6287 local ra_MB=${READAHEAD_MB:-40}
6289 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6290 [ $free_MB -lt $sz_MB ] &&
6291 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6293 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6294 $SETSTRIPE -c -1 $file || error "setstripe failed"
6296 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6297 echo Cancel LRU locks on lustre client to flush the client cache
6298 cancel_lru_locks osc
6300 echo Disable read-ahead
6301 local old_READAHEAD=$(set_read_ahead 0)
6303 echo Reading the test file $file with read-ahead disabled
6304 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6306 echo Cancel LRU locks on lustre client to flush the client cache
6307 cancel_lru_locks osc
6308 echo Enable read-ahead with ${ra_MB}MB
6309 set_read_ahead $ra_MB
6311 echo Reading the test file $file with read-ahead enabled
6312 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6314 echo "read-ahead disabled time read $raOFF"
6315 echo "read-ahead enabled time read $raON"
6317 set_read_ahead $old_READAHEAD
6319 wait_delete_completed
6321 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6322 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6324 run_test 101d "file read with and without read-ahead enabled"
6327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6328 local file=$DIR/$tfile
6329 local size_KB=500 #KB
6333 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6334 local need_KB=$((count * size_KB))
6335 [[ $free_KB -le $need_KB ]] &&
6336 skip_env "Need free space $need_KB, have $free_KB" && return
6338 echo "Creating $count ${size_KB}K test files"
6339 for ((i = 0; i < $count; i++)); do
6340 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6343 echo "Cancel LRU locks on lustre client to flush the client cache"
6344 cancel_lru_locks osc
6346 echo "Reset readahead stats"
6347 $LCTL set_param -n llite.*.read_ahead_stats 0
6349 for ((i = 0; i < $count; i++)); do
6350 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6353 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6354 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6356 for ((i = 0; i < $count; i++)); do
6357 rm -rf $file.$i 2>/dev/null
6360 #10000 means 20% reads are missing in readahead
6361 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6363 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6365 cleanup_test101f() {
6367 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6368 rm -rf $DIR/$tfile 2>/dev/null
6372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6373 local file=$DIR/$tfile
6376 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6377 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6378 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6379 trap cleanup_test101f EXIT
6381 echo Cancel LRU locks on lustre client to flush the client cache
6382 cancel_lru_locks osc
6384 echo Reset readahead stats
6385 $LCTL set_param -n llite.*.read_ahead_stats 0
6386 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6387 # readahead should read in 2M file on second read, so only miss
6389 echo Random 4K reads on 2M file for 1000 times
6390 $READS -f $file -s 2097152 -b 4096 -n $nreads
6392 echo checking missing pages
6393 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6394 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6396 [ $miss -lt 3 ] || error "misses too much pages!"
6399 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6402 test_mkdir -p $DIR/$tdir
6403 chown $RUNAS_ID $DIR/$tdir
6406 STRIPE_COUNT=$OSTCOUNT
6407 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6409 trap cleanup_test102 EXIT
6411 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6413 for num in 1 2 3 4; do
6414 for count in $(seq 1 $STRIPE_COUNT); do
6415 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6416 local size=`expr $STRIPE_SIZE \* $num`
6417 local file=file"$num-$idx-$count"
6418 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6424 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6430 rm -rf $DIR/d0.sanity/d102
6434 local testfile=$DIR/$tfile
6438 [ "$UID" != 0 ] && skip_env "must run as root" && return
6439 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6440 skip_env "must have user_xattr" && return
6442 [ -z "$(which setfattr 2>/dev/null)" ] &&
6443 skip_env "could not find setfattr" && return
6445 echo "set/get xattr..."
6446 setfattr -n trusted.name1 -v value1 $testfile ||
6447 error "setfattr -n trusted.name1=value1 $testfile failed"
6448 getfattr -n trusted.name1 $testfile 2> /dev/null |
6449 grep "trusted.name1=.value1" ||
6450 error "$testfile missing trusted.name1=value1"
6452 setfattr -n user.author1 -v author1 $testfile ||
6453 error "setfattr -n user.author1=author1 $testfile failed"
6454 getfattr -n user.author1 $testfile 2> /dev/null |
6455 grep "user.author1=.author1" ||
6456 error "$testfile missing trusted.author1=author1"
6459 setfattr -n trusted.name2 -v value2 $testfile ||
6460 error "$testfile unable to set trusted.name2"
6461 setfattr -n trusted.name3 -v value3 $testfile ||
6462 error "$testfile unable to set trusted.name3"
6463 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6464 grep "trusted.name" | wc -l) -eq 3 ] ||
6465 error "$testfile missing 3 trusted.name xattrs"
6467 setfattr -n user.author2 -v author2 $testfile ||
6468 error "$testfile unable to set user.author2"
6469 setfattr -n user.author3 -v author3 $testfile ||
6470 error "$testfile unable to set user.author3"
6471 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6472 grep "user.author" | wc -l) -eq 3 ] ||
6473 error "$testfile missing 3 user.author xattrs"
6475 echo "remove xattr..."
6476 setfattr -x trusted.name1 $testfile ||
6477 error "$testfile error deleting trusted.name1"
6478 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6479 error "$testfile did not delete trusted.name1 xattr"
6481 setfattr -x user.author1 $testfile ||
6482 error "$testfile error deleting user.author1"
6483 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6484 error "$testfile did not delete trusted.name1 xattr"
6486 # b10667: setting lustre special xattr be silently discarded
6487 echo "set lustre special xattr ..."
6488 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6489 error "$testfile allowed setting trusted.lov"
6491 run_test 102a "user xattr test =================================="
6494 [ -z "$(which setfattr 2>/dev/null)" ] &&
6495 skip_env "could not find setfattr" && return
6497 # b10930: get/set/list trusted.lov xattr
6498 echo "get/set/list trusted.lov xattr ..."
6499 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6500 local testfile=$DIR/$tfile
6501 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6502 error "setstripe failed"
6503 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6504 error "getstripe failed"
6505 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6506 error "can't get trusted.lov from $testfile"
6508 local testfile2=${testfile}2
6509 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6510 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6513 setfattr -n trusted.lov -v $value $testfile2
6514 local stripe_size=$($GETSTRIPE -S $testfile2)
6515 local stripe_count=$($GETSTRIPE -c $testfile2)
6516 [[ $stripe_size -eq 65536 ]] ||
6517 error "stripe size $stripe_size != 65536"
6518 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6519 error "stripe count $stripe_count != $STRIPECOUNT"
6522 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6525 [ -z "$(which setfattr 2>/dev/null)" ] &&
6526 skip_env "could not find setfattr" && return
6528 # b10930: get/set/list lustre.lov xattr
6529 echo "get/set/list lustre.lov xattr ..."
6530 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6531 test_mkdir -p $DIR/$tdir
6532 chown $RUNAS_ID $DIR/$tdir
6533 local testfile=$DIR/$tdir/$tfile
6534 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6535 error "setstripe failed"
6536 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6537 error "getstripe failed"
6538 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6539 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6541 local testfile2=${testfile}2
6542 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6543 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6545 $RUNAS $MCREATE $testfile2
6546 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6547 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6548 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6549 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6550 [ $stripe_count -eq $STRIPECOUNT ] ||
6551 error "stripe count $stripe_count != $STRIPECOUNT"
6553 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6555 compare_stripe_info1() {
6556 local stripe_index_all_zero=true
6558 for num in 1 2 3 4; do
6559 for count in $(seq 1 $STRIPE_COUNT); do
6560 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6561 local size=$((STRIPE_SIZE * num))
6562 local file=file"$num-$offset-$count"
6563 stripe_size=$(lfs getstripe -S $PWD/$file)
6564 [[ $stripe_size -ne $size ]] &&
6565 error "$file: size $stripe_size != $size"
6566 stripe_count=$(lfs getstripe -c $PWD/$file)
6567 # allow fewer stripes to be created, ORI-601
6568 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6569 error "$file: count $stripe_count != $count"
6570 stripe_index=$(lfs getstripe -i $PWD/$file)
6571 [[ $stripe_index -ne 0 ]] &&
6572 stripe_index_all_zero=false
6576 $stripe_index_all_zero &&
6577 error "all files are being extracted starting from OST index 0"
6582 [ -n "$(which tar 2>/dev/null)" ] &&
6583 strings $(which tar) | grep -q "lustre" && echo tar
6587 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6588 # b10930: tar test for trusted.lov xattr
6589 TAR=$(find_lustre_tar)
6590 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6591 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6593 test_mkdir -p $DIR/d102d
6594 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6596 compare_stripe_info1
6598 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6602 # b10930: tar test for trusted.lov xattr
6603 TAR=$(find_lustre_tar)
6604 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6605 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6607 test_mkdir -p $DIR/d102f
6609 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6611 compare_stripe_info1
6613 run_test 102f "tar copy files, not keep osts ==========="
6616 local xsize=${1:-1024} # in bytes
6617 local file=$DIR/$tfile
6619 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6620 skip "must have user_xattr" && return 0
6621 [ -z "$(which setfattr 2>/dev/null)" ] &&
6622 skip_env "could not find setfattr" && return 0
6623 [ -z "$(which getfattr 2>/dev/null)" ] &&
6624 skip_env "could not find getfattr" && return 0
6628 local value="$(generate_string $xsize)"
6630 local xbig=trusted.big
6631 log "save $xbig on $file"
6632 setfattr -n $xbig -v $value $file ||
6633 error "saving $xbig on $file failed"
6635 local orig=$(get_xattr_value $xbig $file)
6636 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6638 local xsml=trusted.sml
6639 log "save $xsml on $file"
6640 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6642 local new=$(get_xattr_value $xbig $file)
6643 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6645 log "grow $xsml on $file"
6646 setfattr -n $xsml -v "$value" $file ||
6647 error "growing $xsml on $file failed"
6649 new=$(get_xattr_value $xbig $file)
6650 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6651 log "$xbig still valid after growing $xsml"
6656 test_102h() { # bug 15777
6659 run_test 102h "grow xattr from inside inode to external block"
6662 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6663 grow_xattr $(max_xattr_size)
6665 run_test 102ha "grow xattr from inside inode to external inode"
6667 test_102i() { # bug 17038
6668 [ -z "$(which getfattr 2>/dev/null)" ] &&
6669 skip "could not find getfattr" && return
6671 ln -s $DIR/$tfile $DIR/${tfile}link
6672 getfattr -n trusted.lov $DIR/$tfile ||
6673 error "lgetxattr on $DIR/$tfile failed"
6674 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6675 grep -i "no such attr" ||
6676 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6677 rm -f $DIR/$tfile $DIR/${tfile}link
6679 run_test 102i "lgetxattr test on symbolic link ============"
6682 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6683 TAR=$(find_lustre_tar)
6684 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6685 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6686 setup_test102 "$RUNAS"
6687 test_mkdir -p $DIR/d102j
6688 chown $RUNAS_ID $DIR/d102j
6689 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6691 compare_stripe_info1 "$RUNAS"
6693 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6696 [ -z "$(which setfattr 2>/dev/null)" ] &&
6697 skip "could not find setfattr" && return
6699 # b22187 just check that does not crash for regular file.
6700 setfattr -n trusted.lov $DIR/$tfile
6701 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6702 local test_kdir=$DIR/d102k
6703 test_mkdir $test_kdir
6704 local default_size=`$GETSTRIPE -S $test_kdir`
6705 local default_count=`$GETSTRIPE -c $test_kdir`
6706 local default_offset=`$GETSTRIPE -i $test_kdir`
6707 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6708 error 'dir setstripe failed'
6709 setfattr -n trusted.lov $test_kdir
6710 local stripe_size=`$GETSTRIPE -S $test_kdir`
6711 local stripe_count=`$GETSTRIPE -c $test_kdir`
6712 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6713 [ $stripe_size -eq $default_size ] ||
6714 error "stripe size $stripe_size != $default_size"
6715 [ $stripe_count -eq $default_count ] ||
6716 error "stripe count $stripe_count != $default_count"
6717 [ $stripe_offset -eq $default_offset ] ||
6718 error "stripe offset $stripe_offset != $default_offset"
6719 rm -rf $DIR/$tfile $test_kdir
6721 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6724 [ -z "$(which getfattr 2>/dev/null)" ] &&
6725 skip "could not find getfattr" && return
6727 # LU-532 trusted. xattr is invisible to non-root
6728 local testfile=$DIR/$tfile
6732 echo "listxattr as user..."
6733 chown $RUNAS_ID $testfile
6734 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6735 grep -q "trusted" &&
6736 error "$testfile trusted xattrs are user visible"
6740 run_test 102l "listxattr size test =================================="
6742 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6743 local path=$DIR/$tfile
6746 listxattr_size_check $path || error "listattr_size_check $path failed"
6748 run_test 102m "Ensure listxattr fails on small bufffer ========"
6752 getxattr() { # getxattr path name
6753 # Return the base64 encoding of the value of xattr name on path.
6757 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6759 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6761 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6763 getfattr --absolute-names --encoding=base64 --name=$name $path |
6764 awk -F= -v name=$name '$1 == name {
6765 print substr($0, index($0, "=") + 1);
6769 test_102n() { # LU-4101 mdt: protect internal xattrs
6770 local file0=$DIR/$tfile.0
6771 local file1=$DIR/$tfile.1
6772 local xattr0=$TMP/$tfile.0
6773 local xattr1=$TMP/$tfile.1
6777 [ -z "$(which setfattr 2>/dev/null)" ] &&
6778 skip "could not find setfattr" && return
6780 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6782 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6786 rm -rf $file0 $file1 $xattr0 $xattr1
6789 # Get 'before' xattrs of $file1.
6790 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6792 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6793 # Try to copy xattr from $file0 to $file1.
6794 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6796 setfattr --name=trusted.$name --value="$value" $file1 ||
6797 error "setxattr 'trusted.$name' failed"
6799 # Try to set a garbage xattr.
6800 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6802 setfattr --name=trusted.$name --value="$value" $file1 ||
6803 error "setxattr 'trusted.$name' failed"
6805 # Try to remove the xattr from $file1. We don't care if this
6806 # appears to succeed or fail, we just don't want there to be
6807 # any changes or crashes.
6808 setfattr --remove=$trusted.$name $file1 2> /dev/null
6811 # Get 'after' xattrs of file1.
6812 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6814 if ! diff $xattr0 $xattr1; then
6815 error "before and after xattrs of '$file1' differ"
6818 rm -rf $file0 $file1 $xattr0 $xattr1
6822 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6824 test_102p() { # LU-4703 setxattr did not check ownership
6825 local testfile=$DIR/$tfile
6827 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6828 skip "MDS needs to be at least 2.5.56" && return
6832 echo "setfacl as user..."
6833 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6834 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6836 echo "setfattr as user..."
6837 setfacl -m "u:$RUNAS_ID:---" $testfile
6838 $RUNAS setfattr -x system.posix_acl_access $testfile
6839 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6841 run_test 102p "check setxattr(2) correctly fails without permission"
6845 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6850 [ "$UID" != 0 ] && skip_env "must run as root" && return
6851 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6852 skip "must have acl enabled" && return
6853 [ -z "$(which setfacl 2>/dev/null)" ] &&
6854 skip_env "could not find setfacl" && return
6855 $GSS && skip "could not run under gss" && return
6857 declare -a identity_old
6859 for num in $(seq $MDSCOUNT); do
6860 switch_identity $num true || identity_old[$num]=$?
6867 echo "performing cp ..."
6868 run_acl_subtest cp || error "run_acl_subtest cp failed"
6869 echo "performing getfacl-noacl..."
6870 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6871 echo "performing misc..."
6872 run_acl_subtest misc || error "misc test failed"
6873 echo "performing permissions..."
6874 run_acl_subtest permissions || error "permissions failed"
6875 echo "performing setfacl..."
6876 run_acl_subtest setfacl || error "setfacl test failed"
6878 # inheritance test got from HP
6879 echo "performing inheritance..."
6880 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6881 chmod +x make-tree || error "chmod +x failed"
6882 run_acl_subtest inheritance || error "inheritance test failed"
6885 echo "LU-974 ignore umask when acl is enabled..."
6886 run_acl_subtest 974 || error "LU-974 umask test failed"
6887 if [ $MDSCOUNT -ge 2 ]; then
6888 run_acl_subtest 974_remote ||
6889 error "LU-974 umask test failed under remote dir"
6892 echo "LU-2561 newly created file is same size as directory..."
6893 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6894 run_acl_subtest 2561 || error "LU-2561 test failed"
6896 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
6899 run_acl_subtest 4924 || error "LU-4924 test failed"
6904 for num in $(seq $MDSCOUNT); do
6905 if [ "${identity_old[$num]}" = 1 ]; then
6906 switch_identity $num false || identity_old[$num]=$?
6910 run_test 103a "acl test ========================================="
6914 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
6915 local mountopts=$MDS_MOUNT_OPTS
6917 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
6921 stop $SINGLEMDS || error "failed to stop MDT."
6923 if [ -z "$MDS_MOUNT_OPTS" ]; then
6924 MDS_MOUNT_OPTS="-o noacl"
6926 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
6928 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6929 error "failed to start MDT."
6930 MDS_MOUNT_OPTS=$mountopts
6934 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
6938 stop $SINGLEMDS || error "failed to stop MDT."
6940 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
6941 error "failed to start MDT."
6946 run_test 103b "MDS mount option 'noacl'"
6950 cp -rp $DIR/$tdir $DIR/$tdir.bak
6952 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
6953 error "$DIR/$tdir shouldn't contain default ACL"
6954 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
6955 error "$DIR/$tdir.bak shouldn't contain default ACL"
6958 run_test 103c "'cp -rp' won't set empty acl"
6961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6963 lfs df || error "lfs df failed"
6964 lfs df -ih || error "lfs df -ih failed"
6965 lfs df -h $DIR || error "lfs df -h $DIR failed"
6966 lfs df -i $DIR || error "lfs df -i $DIR failed"
6967 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6968 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6970 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6971 lctl --device %$OSC deactivate
6972 lfs df || error "lfs df with deactivated OSC failed"
6973 lctl --device %$OSC activate
6974 # wait the osc back to normal
6975 wait_osc_import_state client ost FULL
6977 lfs df || error "lfs df with reactivated OSC failed"
6980 run_test 104a "lfs df [-ih] [path] test ========================="
6983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6984 [ $RUNAS_ID -eq $UID ] &&
6985 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6987 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6988 grep "Permission denied" | wc -l)))
6989 if [ $denied_cnt -ne 0 ]; then
6990 error "lfs check servers test failed"
6993 run_test 104b "$RUNAS lfs check servers test ===================="
6996 # doesn't work on 2.4 kernels
6998 if $(flock_is_enabled); then
6999 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7001 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7005 run_test 105a "flock when mounted without -o flock test ========"
7009 if $(flock_is_enabled); then
7010 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7012 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7016 run_test 105b "fcntl when mounted without -o flock test ========"
7020 if $(flock_is_enabled); then
7021 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7023 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7027 run_test 105c "lockf when mounted without -o flock test ========"
7029 test_105d() { # bug 15924
7030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7031 test_mkdir -p $DIR/$tdir
7032 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7033 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7034 $LCTL set_param fail_loc=0x80000315
7035 flocks_test 2 $DIR/$tdir
7037 run_test 105d "flock race (should not freeze) ========"
7039 test_105e() { # bug 22660 && 22040
7040 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7042 flocks_test 3 $DIR/$tfile
7044 run_test 105e "Two conflicting flocks from same process ======="
7046 test_106() { #bug 10921
7047 test_mkdir -p $DIR/$tdir
7048 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7049 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7051 run_test 106 "attempt exec of dir followed by chown of that dir"
7054 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7061 local save_pattern=$(sysctl -n kernel.core_pattern)
7062 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7063 sysctl -w kernel.core_pattern=$file
7064 sysctl -w kernel.core_uses_pid=0
7072 kill -s 11 $SLEEPPID
7074 if [ -e $file ]; then
7075 size=`stat -c%s $file`
7076 [ $size -eq 0 ] && error "Fail to create core file $file"
7078 error "Fail to create core file $file"
7081 sysctl -w kernel.core_pattern=$save_pattern
7082 sysctl -w kernel.core_uses_pid=$save_uses_pid
7085 run_test 107 "Coredump on SIG"
7088 test_mkdir -p $DIR/$tdir
7089 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7090 error "mkdir with 255 char failed"
7091 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7092 error "mkdir with 256 char should fail, but did not"
7093 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7094 error "create with 255 char failed"
7095 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7096 error "create with 256 char should fail, but did not"
7101 run_test 110 "filename length checking"
7104 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7105 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7106 tail -1 | cut -c11-20)
7107 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7108 echo "Starting with $OSTIO_pre threads"
7111 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7112 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7113 echo "$NUMTEST creates/unlinks"
7114 test_mkdir -p $DIR/$tdir
7115 createmany -o $DIR/$tdir/$tfile $NUMTEST
7116 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7118 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7119 tail -1 | cut -c11-20)
7121 # don't return an error
7122 [ $OSTIO_post == $OSTIO_pre ] && echo \
7123 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7124 echo "This may be fine, depending on what ran before this test" &&
7125 echo "and how fast this system is." && return
7127 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7129 run_test 115 "verify dynamic thread creation===================="
7132 wait_delete_completed
7133 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7134 echo OST kbytes available: ${AVAIL[@]}
7135 MAXI=0; MAXV=${AVAIL[0]}
7136 MINI=0; MINV=${AVAIL[0]}
7137 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7138 #echo OST $i: ${AVAIL[i]}kb
7139 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7140 MAXV=${AVAIL[i]}; MAXI=$i
7142 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7143 MINV=${AVAIL[i]}; MINI=$i
7146 echo Min free space: OST $MINI: $MINV
7147 echo Max free space: OST $MAXI: $MAXV
7150 test_116a() { # was previously test_116()
7151 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7152 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7154 echo -n "Free space priority "
7155 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7160 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7161 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7163 trap simple_cleanup_common EXIT
7166 # Check if we need to generate uneven OSTs
7167 test_mkdir -p $DIR/$tdir/OST${MINI}
7168 local FILL=$(($MINV / 4))
7169 local DIFF=$(($MAXV - $MINV))
7170 local DIFF2=$(($DIFF * 100 / $MINV))
7172 local threshold=$(do_facet $SINGLEMDS \
7173 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7174 threshold=${threshold%%%}
7175 echo -n "Check for uneven OSTs: "
7176 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7178 if [[ $DIFF2 -gt $threshold ]]; then
7180 echo "Don't need to fill OST$MINI"
7182 # generate uneven OSTs. Write 2% over the QOS threshold value
7184 DIFF=$(($threshold - $DIFF2 + 2))
7185 DIFF2=$(( ($MINV * $DIFF)/100 ))
7186 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7187 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7188 error "setstripe failed"
7189 DIFF=$(($DIFF2 / 2048))
7191 while [ $i -lt $DIFF ]; do
7193 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7194 bs=2M count=1 2>/dev/null
7203 DIFF=$(($MAXV - $MINV))
7204 DIFF2=$(($DIFF * 100 / $MINV))
7205 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7206 if [[ $DIFF2 -gt $threshold ]]; then
7209 echo "failed - QOS mode won't be used"
7210 skip "QOS imbalance criteria not met"
7211 simple_cleanup_common
7215 MINI1=$MINI; MINV1=$MINV
7216 MAXI1=$MAXI; MAXV1=$MAXV
7218 # now fill using QOS
7219 $SETSTRIPE -c 1 $DIR/$tdir
7220 FILL=$(($FILL / 200))
7221 if [ $FILL -gt 600 ]; then
7224 echo "writing $FILL files to QOS-assigned OSTs"
7226 while [ $i -lt $FILL ]; do
7228 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7232 echo "wrote $i 200k files"
7236 echo "Note: free space may not be updated, so measurements might be off"
7238 DIFF2=$(($MAXV - $MINV))
7239 echo "free space delta: orig $DIFF final $DIFF2"
7240 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7241 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7242 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7243 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7244 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7245 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7247 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7249 # Figure out which files were written where
7250 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7251 awk '/'$MINI1': / {print $2; exit}')
7253 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7254 echo "$MINC files created on smaller OST $MINI1"
7255 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7256 awk '/'$MAXI1': / {print $2; exit}')
7258 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7259 echo "$MAXC files created on larger OST $MAXI1"
7260 FILL=$(($MAXC * 100 / $MINC - 100))
7261 [[ $MINC -gt 0 ]] &&
7262 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7263 [[ $MAXC -gt $MINC ]] ||
7264 error_ignore LU-9 "stripe QOS didn't balance free space"
7265 simple_cleanup_common
7267 run_test 116a "stripe QOS: free space balance ==================="
7269 test_116b() { # LU-2093
7270 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7271 [ -z "$($LCTL get_param -n lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr |
7272 head -1 2>/dev/null)" ] && skip "no QOS" && return
7273 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7275 old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7276 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7277 do_facet $SINGLEMDS lctl set_param \
7278 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7280 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7281 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7282 do_facet $SINGLEMDS lctl set_param fail_loc=0
7284 do_facet $SINGLEMDS lctl set_param \
7285 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7287 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7289 test_117() # bug 10891
7291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7292 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7293 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7294 lctl set_param fail_loc=0x21e
7295 > $DIR/$tfile || error "truncate failed"
7296 lctl set_param fail_loc=0
7297 echo "Truncate succeeded."
7300 run_test 117 "verify osd extend =========="
7302 NO_SLOW_RESENDCOUNT=4
7303 export OLD_RESENDCOUNT=""
7304 set_resend_count () {
7305 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7306 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7307 lctl set_param -n $PROC_RESENDCOUNT $1
7308 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7311 # for reduce test_118* time (b=14842)
7312 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7314 # Reset async IO behavior after error case
7316 FILE=$DIR/reset_async
7318 # Ensure all OSCs are cleared
7319 $SETSTRIPE -c -1 $FILE
7320 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7325 test_118a() #bug 11710
7327 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7330 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7331 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7332 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7334 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7335 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7340 run_test 118a "verify O_SYNC works =========="
7344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7345 remote_ost_nodsh && skip "remote OST with nodsh" && return
7349 #define OBD_FAIL_OST_ENOENT 0x217
7350 set_nodes_failloc "$(osts_nodes)" 0x217
7351 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7353 set_nodes_failloc "$(osts_nodes)" 0
7354 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7355 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7358 if [[ $RC -eq 0 ]]; then
7359 error "Must return error due to dropped pages, rc=$RC"
7363 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7364 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7368 echo "Dirty pages not leaked on ENOENT"
7370 # Due to the above error the OSC will issue all RPCs syncronously
7371 # until a subsequent RPC completes successfully without error.
7372 $MULTIOP $DIR/$tfile Ow4096yc
7377 run_test 118b "Reclaim dirty pages on fatal error =========="
7381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7383 # for 118c, restore the original resend count, LU-1940
7384 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7385 set_resend_count $OLD_RESENDCOUNT
7386 remote_ost_nodsh && skip "remote OST with nodsh" && return
7390 #define OBD_FAIL_OST_EROFS 0x216
7391 set_nodes_failloc "$(osts_nodes)" 0x216
7393 # multiop should block due to fsync until pages are written
7394 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7398 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7399 error "Multiop failed to block on fsync, pid=$MULTIPID"
7402 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7404 if [[ $WRITEBACK -eq 0 ]]; then
7405 error "No page in writeback, writeback=$WRITEBACK"
7408 set_nodes_failloc "$(osts_nodes)" 0
7411 if [[ $RC -ne 0 ]]; then
7412 error "Multiop fsync failed, rc=$RC"
7415 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7416 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7418 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7419 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7423 echo "Dirty pages flushed via fsync on EROFS"
7426 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7428 # continue to use small resend count to reduce test_118* time (b=14842)
7429 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7433 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7434 remote_ost_nodsh && skip "remote OST with nodsh" && return
7438 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7439 set_nodes_failloc "$(osts_nodes)" 0x214
7440 # multiop should block due to fsync until pages are written
7441 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7445 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7446 error "Multiop failed to block on fsync, pid=$MULTIPID"
7449 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7451 if [[ $WRITEBACK -eq 0 ]]; then
7452 error "No page in writeback, writeback=$WRITEBACK"
7455 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7456 set_nodes_failloc "$(osts_nodes)" 0
7458 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7459 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7461 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7462 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7466 echo "Dirty pages gaurenteed flushed via fsync"
7469 run_test 118d "Fsync validation inject a delay of the bulk =========="
7472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7475 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7476 lctl set_param fail_loc=0x8000040a
7478 # Should simulate EINVAL error which is fatal
7479 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7481 if [[ $RC -eq 0 ]]; then
7482 error "Must return error due to dropped pages, rc=$RC"
7485 lctl set_param fail_loc=0x0
7487 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7488 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7489 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7491 if [[ $LOCKED -ne 0 ]]; then
7492 error "Locked pages remain in cache, locked=$LOCKED"
7495 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7496 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7500 echo "No pages locked after fsync"
7505 run_test 118f "Simulate unrecoverable OSC side error =========="
7508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7511 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7512 lctl set_param fail_loc=0x406
7514 # simulate local -ENOMEM
7515 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7518 lctl set_param fail_loc=0
7519 if [[ $RC -eq 0 ]]; then
7520 error "Must return error due to dropped pages, rc=$RC"
7523 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7524 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7525 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7527 if [[ $LOCKED -ne 0 ]]; then
7528 error "Locked pages remain in cache, locked=$LOCKED"
7531 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7532 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7536 echo "No pages locked after fsync"
7541 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7545 remote_ost_nodsh && skip "remote OST with nodsh" && return
7549 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7550 set_nodes_failloc "$(osts_nodes)" 0x20e
7551 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7552 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7555 set_nodes_failloc "$(osts_nodes)" 0
7556 if [[ $RC -eq 0 ]]; then
7557 error "Must return error due to dropped pages, rc=$RC"
7560 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7561 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7562 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7564 if [[ $LOCKED -ne 0 ]]; then
7565 error "Locked pages remain in cache, locked=$LOCKED"
7568 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7569 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7573 echo "No pages locked after fsync"
7577 run_test 118h "Verify timeout in handling recoverables errors =========="
7579 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7583 remote_ost_nodsh && skip "remote OST with nodsh" && return
7587 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7588 set_nodes_failloc "$(osts_nodes)" 0x20e
7590 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7591 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7594 set_nodes_failloc "$(osts_nodes)" 0
7598 if [[ $RC -ne 0 ]]; then
7599 error "got error, but should be not, rc=$RC"
7602 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7603 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7604 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7605 if [[ $LOCKED -ne 0 ]]; then
7606 error "Locked pages remain in cache, locked=$LOCKED"
7609 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7610 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7614 echo "No pages locked after fsync"
7618 run_test 118i "Fix error before timeout in recoverable error =========="
7620 [ "$SLOW" = "no" ] && set_resend_count 4
7623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7624 remote_ost_nodsh && skip "remote OST with nodsh" && return
7628 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7629 set_nodes_failloc "$(osts_nodes)" 0x220
7631 # return -EIO from OST
7632 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7634 set_nodes_failloc "$(osts_nodes)" 0x0
7635 if [[ $RC -eq 0 ]]; then
7636 error "Must return error due to dropped pages, rc=$RC"
7639 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7640 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7641 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7642 if [[ $LOCKED -ne 0 ]]; then
7643 error "Locked pages remain in cache, locked=$LOCKED"
7646 # in recoverable error on OST we want resend and stay until it finished
7647 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7648 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7652 echo "No pages locked after fsync"
7656 run_test 118j "Simulate unrecoverable OST side error =========="
7660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7661 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7663 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7664 set_nodes_failloc "$(osts_nodes)" 0x20e
7665 test_mkdir -p $DIR/$tdir
7667 for ((i=0;i<10;i++)); do
7668 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7669 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7676 set_nodes_failloc "$(osts_nodes)" 0
7679 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7685 test_mkdir -p $DIR/$tdir
7686 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7689 run_test 118l "fsync dir ========="
7691 test_118m() # LU-3066
7693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7694 test_mkdir -p $DIR/$tdir
7695 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7698 run_test 118m "fdatasync dir ========="
7700 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7702 test_119a() # bug 11737
7704 BSIZE=$((512 * 1024))
7705 directio write $DIR/$tfile 0 1 $BSIZE
7706 # We ask to read two blocks, which is more than a file size.
7707 # directio will indicate an error when requested and actual
7708 # sizes aren't equeal (a normal situation in this case) and
7709 # print actual read amount.
7710 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7711 if [ "$NOB" != "$BSIZE" ]; then
7712 error "read $NOB bytes instead of $BSIZE"
7716 run_test 119a "Short directIO read must return actual read amount"
7718 test_119b() # bug 11737
7720 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7722 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7723 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7725 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7726 error "direct read failed"
7729 run_test 119b "Sparse directIO read must return actual read amount"
7731 test_119c() # bug 13099
7734 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7735 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7738 run_test 119c "Testing for direct read hitting hole"
7740 test_119d() # bug 15950
7742 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7743 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7744 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7746 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7747 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7748 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7749 lctl set_param fail_loc=0x40d
7750 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7753 cat $DIR/$tfile > /dev/null &
7754 lctl set_param fail_loc=0
7757 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7759 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7760 error "the read rpcs have not completed in 2s"
7762 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7764 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7767 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7768 test_mkdir -p $DIR/$tdir
7769 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7770 skip "no early lock cancel on server" && return 0
7772 lru_resize_disable mdc
7773 lru_resize_disable osc
7774 cancel_lru_locks mdc
7775 # asynchronous object destroy at MDT could cause bl ast to client
7776 cancel_lru_locks osc
7778 stat $DIR/$tdir > /dev/null
7779 can1=$(do_facet $SINGLEMDS \
7780 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7781 awk '/ldlm_cancel/ {print $2}')
7782 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7783 awk '/ldlm_bl_callback/ {print $2}')
7784 test_mkdir -c1 $DIR/$tdir/d1
7785 can2=$(do_facet $SINGLEMDS \
7786 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7787 awk '/ldlm_cancel/ {print $2}')
7788 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7789 awk '/ldlm_bl_callback/ {print $2}')
7790 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7791 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7792 lru_resize_enable mdc
7793 lru_resize_enable osc
7795 run_test 120a "Early Lock Cancel: mkdir test"
7798 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7799 test_mkdir $DIR/$tdir
7800 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7801 skip "no early lock cancel on server" && return 0
7802 lru_resize_disable mdc
7803 lru_resize_disable osc
7804 cancel_lru_locks mdc
7805 stat $DIR/$tdir > /dev/null
7806 can1=$(do_facet $SINGLEMDS \
7807 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7808 awk '/ldlm_cancel/ {print $2}')
7809 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7810 awk '/ldlm_bl_callback/ {print $2}')
7812 can2=$(do_facet $SINGLEMDS \
7813 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7814 awk '/ldlm_cancel/ {print $2}')
7815 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7816 awk '/ldlm_bl_callback/ {print $2}')
7817 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7818 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7819 lru_resize_enable mdc
7820 lru_resize_enable osc
7822 run_test 120b "Early Lock Cancel: create test"
7825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7826 test_mkdir -c1 $DIR/$tdir
7827 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7828 skip "no early lock cancel on server" && return 0
7829 lru_resize_disable mdc
7830 lru_resize_disable osc
7831 test_mkdir -p -c1 $DIR/$tdir/d1
7832 test_mkdir -p -c1 $DIR/$tdir/d2
7833 touch $DIR/$tdir/d1/f1
7834 cancel_lru_locks mdc
7835 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7836 can1=$(do_facet $SINGLEMDS \
7837 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7838 awk '/ldlm_cancel/ {print $2}')
7839 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7840 awk '/ldlm_bl_callback/ {print $2}')
7841 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7842 can2=$(do_facet $SINGLEMDS \
7843 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7844 awk '/ldlm_cancel/ {print $2}')
7845 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7846 awk '/ldlm_bl_callback/ {print $2}')
7847 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7848 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7849 lru_resize_enable mdc
7850 lru_resize_enable osc
7852 run_test 120c "Early Lock Cancel: link test"
7855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7856 test_mkdir -p -c1 $DIR/$tdir
7857 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7858 skip "no early lock cancel on server" && return 0
7859 lru_resize_disable mdc
7860 lru_resize_disable osc
7862 cancel_lru_locks mdc
7863 stat $DIR/$tdir > /dev/null
7864 can1=$(do_facet $SINGLEMDS \
7865 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7866 awk '/ldlm_cancel/ {print $2}')
7867 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7868 awk '/ldlm_bl_callback/ {print $2}')
7869 chmod a+x $DIR/$tdir
7870 can2=$(do_facet $SINGLEMDS \
7871 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7872 awk '/ldlm_cancel/ {print $2}')
7873 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7874 awk '/ldlm_bl_callback/ {print $2}')
7875 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7876 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7877 lru_resize_enable mdc
7878 lru_resize_enable osc
7880 run_test 120d "Early Lock Cancel: setattr test"
7883 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7884 test_mkdir -p -c1 $DIR/$tdir
7885 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7886 skip "no early lock cancel on server" && return 0
7887 lru_resize_disable mdc
7888 lru_resize_disable osc
7889 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7890 cancel_lru_locks mdc
7891 cancel_lru_locks osc
7892 dd if=$DIR/$tdir/f1 of=/dev/null
7893 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7894 # XXX client can not do early lock cancel of OST lock
7895 # during unlink (LU-4206), so cancel osc lock now.
7896 cancel_lru_locks osc
7897 can1=$(do_facet $SINGLEMDS \
7898 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7899 awk '/ldlm_cancel/ {print $2}')
7900 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7901 awk '/ldlm_bl_callback/ {print $2}')
7902 unlink $DIR/$tdir/f1
7904 can2=$(do_facet $SINGLEMDS \
7905 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7906 awk '/ldlm_cancel/ {print $2}')
7907 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7908 awk '/ldlm_bl_callback/ {print $2}')
7909 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7910 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7911 lru_resize_enable mdc
7912 lru_resize_enable osc
7914 run_test 120e "Early Lock Cancel: unlink test"
7917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7918 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7919 skip "no early lock cancel on server" && return 0
7920 test_mkdir -p -c1 $DIR/$tdir
7921 lru_resize_disable mdc
7922 lru_resize_disable osc
7923 test_mkdir -p -c1 $DIR/$tdir/d1
7924 test_mkdir -p -c1 $DIR/$tdir/d2
7925 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7926 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7927 cancel_lru_locks mdc
7928 cancel_lru_locks osc
7929 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7930 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7931 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7932 # XXX client can not do early lock cancel of OST lock
7933 # during rename (LU-4206), so cancel osc lock now.
7934 cancel_lru_locks osc
7935 can1=$(do_facet $SINGLEMDS \
7936 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7937 awk '/ldlm_cancel/ {print $2}')
7938 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7939 awk '/ldlm_bl_callback/ {print $2}')
7940 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7942 can2=$(do_facet $SINGLEMDS \
7943 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7944 awk '/ldlm_cancel/ {print $2}')
7945 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7946 awk '/ldlm_bl_callback/ {print $2}')
7947 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7948 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7949 lru_resize_enable mdc
7950 lru_resize_enable osc
7952 run_test 120f "Early Lock Cancel: rename test"
7955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7956 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7957 skip "no early lock cancel on server" && return 0
7958 lru_resize_disable mdc
7959 lru_resize_disable osc
7961 echo create $count files
7962 test_mkdir -p $DIR/$tdir
7963 cancel_lru_locks mdc
7964 cancel_lru_locks osc
7967 can0=$(do_facet $SINGLEMDS \
7968 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7969 awk '/ldlm_cancel/ {print $2}')
7970 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7971 awk '/ldlm_bl_callback/ {print $2}')
7972 createmany -o $DIR/$tdir/f $count
7974 can1=$(do_facet $SINGLEMDS \
7975 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7976 awk '/ldlm_cancel/ {print $2}')
7977 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7978 awk '/ldlm_bl_callback/ {print $2}')
7980 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7981 echo rm $count files
7984 can2=$(do_facet $SINGLEMDS \
7985 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7986 awk '/ldlm_cancel/ {print $2}')
7987 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7988 awk '/ldlm_bl_callback/ {print $2}')
7990 echo total: $count removes in $((t2-t1))
7991 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7993 # wait for commitment of removal
7994 lru_resize_enable mdc
7995 lru_resize_enable osc
7997 run_test 120g "Early Lock Cancel: performance test"
7999 test_121() { #bug #10589
8000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8002 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8003 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8004 lctl set_param fail_loc=0x310
8005 cancel_lru_locks osc > /dev/null
8006 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8007 lctl set_param fail_loc=0
8008 [[ $reads -eq $writes ]] ||
8009 error "read $reads blocks, must be $writes blocks"
8011 run_test 121 "read cancel race ========="
8013 test_123a() { # was test 123, statahead(bug 11401)
8014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8016 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8017 log "testing on UP system. Performance may be not as good as expected."
8022 test_mkdir -p $DIR/$tdir
8023 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8024 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8026 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8027 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8029 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8030 lctl set_param -n llite.*.statahead_max 0
8031 lctl get_param llite.*.statahead_max
8032 cancel_lru_locks mdc
8033 cancel_lru_locks osc
8035 time ls -l $DIR/$tdir | wc -l
8037 delta=$((etime - stime))
8038 log "ls $i files without statahead: $delta sec"
8039 lctl set_param llite.*.statahead_max=$max
8041 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8042 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8043 cancel_lru_locks mdc
8044 cancel_lru_locks osc
8046 time ls -l $DIR/$tdir | wc -l
8048 delta_sa=$((etime - stime))
8049 log "ls $i files with statahead: $delta_sa sec"
8050 lctl get_param -n llite.*.statahead_stats
8051 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8053 [[ $swrong -lt $ewrong ]] &&
8054 log "statahead was stopped, maybe too many locks held!"
8055 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8057 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8058 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8059 lctl set_param -n llite.*.statahead_max 0
8060 lctl get_param llite.*.statahead_max
8061 cancel_lru_locks mdc
8062 cancel_lru_locks osc
8064 time ls -l $DIR/$tdir | wc -l
8066 delta=$((etime - stime))
8067 log "ls $i files again without statahead: $delta sec"
8068 lctl set_param llite.*.statahead_max=$max
8069 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8070 if [ $SLOWOK -eq 0 ]; then
8071 error "ls $i files is slower with statahead!"
8073 log "ls $i files is slower with statahead!"
8079 [ $delta -gt 20 ] && break
8080 [ $delta -gt 8 ] && MULT=$((50 / delta))
8081 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8089 delta=$((etime - stime))
8090 log "rm -r $DIR/$tdir/: $delta seconds"
8092 lctl get_param -n llite.*.statahead_stats
8094 run_test 123a "verify statahead work"
8096 test_123b () { # statahead(bug 15027)
8097 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8098 test_mkdir -p $DIR/$tdir
8099 createmany -o $DIR/$tdir/$tfile-%d 1000
8101 cancel_lru_locks mdc
8102 cancel_lru_locks osc
8104 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8105 lctl set_param fail_loc=0x80000803
8106 ls -lR $DIR/$tdir > /dev/null
8108 lctl set_param fail_loc=0x0
8109 lctl get_param -n llite.*.statahead_stats
8114 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8117 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8118 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8119 skip "no lru resize on server" && return 0
8121 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8123 log "create $NR files at $DIR/$tdir"
8124 createmany -o $DIR/$tdir/f $NR ||
8125 error "failed to create $NR files in $DIR/$tdir"
8127 cancel_lru_locks mdc
8128 ls -l $DIR/$tdir > /dev/null
8132 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8133 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8134 LRU_SIZE=$($LCTL get_param -n $PARAM)
8135 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8136 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8138 log "NS=$(basename $NSDIR)"
8143 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8144 skip "Not enough cached locks created!"
8151 # We know that lru resize allows one client to hold $LIMIT locks
8152 # for 10h. After that locks begin to be killed by client.
8154 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8157 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8158 # killing locks. Some time was spent for creating locks. This means
8159 # that up to the moment of sleep finish we must have killed some of
8160 # them (10-100 locks). This depends on how fast ther were created.
8161 # Many of them were touched in almost the same moment and thus will
8162 # be killed in groups.
8163 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8165 # Use $LRU_SIZE_B here to take into account real number of locks
8166 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8167 local LRU_SIZE_B=$LRU_SIZE
8169 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8170 log "OLD_LVF=$OLD_LVF"
8171 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8173 # Let's make sure that we really have some margin. Client checks
8174 # cached locks every 10 sec.
8176 log "Sleep ${SLEEP} sec"
8178 while ((SEC<$SLEEP)); do
8182 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8186 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8187 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8189 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8190 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8191 unlinkmany $DIR/$tdir/f $NR
8195 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8196 log "unlink $NR files at $DIR/$tdir"
8197 unlinkmany $DIR/$tdir/f $NR
8199 run_test 124a "lru resize ======================================="
8201 get_max_pool_limit()
8203 local limit=$($LCTL get_param \
8204 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8207 if [[ $l -gt $max ]]; then
8215 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8216 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8217 skip "no lru resize on server" && return 0
8219 LIMIT=$(get_max_pool_limit)
8221 NR=$(($(default_lru_size)*20))
8222 if [[ $NR -gt $LIMIT ]]; then
8223 log "Limit lock number by $LIMIT locks"
8226 lru_resize_disable mdc
8227 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8228 error "failed to create $DIR/$tdir/disable_lru_resize"
8230 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8231 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8232 cancel_lru_locks mdc
8235 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8238 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8241 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8245 nolruresize_delta=$((etime-stime))
8246 log "ls -la time: $nolruresize_delta seconds"
8247 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8248 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8250 lru_resize_enable mdc
8251 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8252 error "failed to create $DIR/$tdir/enable_lru_resize"
8254 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8255 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8256 cancel_lru_locks mdc
8259 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8262 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8265 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8269 lruresize_delta=$((etime-stime))
8270 log "ls -la time: $lruresize_delta seconds"
8271 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8273 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8274 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8275 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8276 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8278 log "lru resize performs the same with no lru resize"
8280 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8282 run_test 124b "lru resize (performance test) ======================="
8284 test_125() { # 13358
8285 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8286 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8287 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8288 test_mkdir -p $DIR/d125 || error "mkdir failed"
8289 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8290 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8291 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8293 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8295 test_126() { # bug 12829/13455
8296 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8297 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8298 $GSS && skip "must run as gss disabled" && return
8300 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8301 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8303 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8305 run_test 126 "check that the fsgid provided by the client is taken into account"
8307 test_127a() { # bug 15521
8308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8309 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8310 $LCTL set_param osc.*.stats=0
8311 FSIZE=$((2048 * 1024))
8312 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8313 cancel_lru_locks osc
8314 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8316 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8317 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8318 echo "got $COUNT $NAME"
8319 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8320 eval $NAME=$COUNT || error "Wrong proc format"
8323 read_bytes|write_bytes)
8324 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8325 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8326 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8327 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8328 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8329 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8330 error "sumsquare is too small: $SUMSQ"
8331 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8332 error "sumsquare is too big: $SUMSQ"
8336 done < $DIR/${tfile}.tmp
8338 #check that we actually got some stats
8339 [ "$read_bytes" ] || error "Missing read_bytes stats"
8340 [ "$write_bytes" ] || error "Missing write_bytes stats"
8341 [ "$read_bytes" != 0 ] || error "no read done"
8342 [ "$write_bytes" != 0 ] || error "no write done"
8344 run_test 127a "verify the client stats are sane"
8346 test_127b() { # bug LU-333
8347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8348 $LCTL set_param llite.*.stats=0
8349 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8350 # perform 2 reads and writes so MAX is different from SUM.
8351 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8352 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8353 cancel_lru_locks osc
8354 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8355 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8357 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8358 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8359 echo "got $COUNT $NAME"
8360 eval $NAME=$COUNT || error "Wrong proc format"
8364 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8365 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8366 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8367 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8370 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8371 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8372 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8373 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8377 done < $TMP/${tfile}.tmp
8379 #check that we actually got some stats
8380 [ "$read_bytes" ] || error "Missing read_bytes stats"
8381 [ "$write_bytes" ] || error "Missing write_bytes stats"
8382 [ "$read_bytes" != 0 ] || error "no read done"
8383 [ "$write_bytes" != 0 ] || error "no write done"
8385 run_test 127b "verify the llite client stats are sane"
8387 test_128() { # bug 15212
8389 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8394 result=$(grep error $TMP/$tfile.log)
8396 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8398 run_test 128 "interactive lfs for 2 consecutive find's"
8405 local LDPROC=/proc/fs/ldiskfs
8406 local facets=$(get_facets MDS)
8408 for facet in ${facets//,/ }; do
8409 canondev=$(ldiskfs_canon \
8410 *.$(convert_facet2label $facet).mntdev $facet)
8411 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8412 LDPROC=/sys/fs/ldiskfs
8413 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8418 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8419 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8420 skip "Only applicable to ldiskfs-based MDTs"
8423 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8428 test_mkdir -p $DIR/$tdir
8430 # block size of mds1
8431 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8432 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8433 local MAX=$((MDSBLOCKSIZE * 3))
8435 local I=$(stat -c%s "$DIR/$tdir")
8437 local STRIPE_COUNT=1
8438 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8439 MAX=$((MAX*STRIPE_COUNT))
8440 while [[ $I -le $MAX ]]; do
8441 $MULTIOP $DIR/$tdir/$J Oc
8443 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8444 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8445 #and EFBIG for previous versions
8446 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8448 echo "return code $rc received as expected"
8449 multiop $DIR/$tdir/$J Oc ||
8450 error_exit "multiop failed w/o dir size limit"
8452 I=$(stat -c%s "$DIR/$tdir")
8454 if [ $(lustre_version_code $SINGLEMDS) -lt \
8455 $(version_code 2.4.51) ]
8457 [[ $I -eq $MAX ]] && return 0
8459 [[ $I -gt $MAX ]] && return 0
8461 error_exit "current dir size $I, previous limit $MAX"
8462 elif [ $rc -ne 0 ]; then
8464 error_exit "return code $rc received instead of expected " \
8465 "$EFBIG or $ENOSPC, files in dir $I"
8468 I=$(stat -c%s "$DIR/$tdir")
8472 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8474 run_test 129 "test directory size limit ========================"
8483 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8484 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8487 trap cleanup_130 EXIT RETURN
8489 local fm_file=$DIR/$tfile
8490 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8491 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8492 error "dd failed for $fm_file"
8494 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8495 filefrag -ves $fm_file
8497 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8498 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8499 [ $RC != 0 ] && error "filefrag $fm_file failed"
8501 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8502 grep -v "ext:" | grep -v "found")
8503 lun=$($GETSTRIPE -i $fm_file)
8505 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8508 for line in $filefrag_op
8510 frag_lun=`echo $line | cut -d: -f5`
8511 ext_len=`echo $line | cut -d: -f4`
8512 if (( $frag_lun != $lun )); then
8514 error "FIEMAP on 1-stripe file($fm_file) failed"
8517 (( tot_len += ext_len ))
8520 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8522 error "FIEMAP on 1-stripe file($fm_file) failed;"
8528 echo "FIEMAP on single striped file succeeded"
8530 run_test 130a "FIEMAP (1-stripe file)"
8533 [ "$OSTCOUNT" -lt "2" ] &&
8534 skip_env "skipping FIEMAP on 2-stripe file test" && return
8536 [ "$OSTCOUNT" -ge "10" ] &&
8537 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8539 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8540 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8543 trap cleanup_130 EXIT RETURN
8545 local fm_file=$DIR/$tfile
8546 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8547 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8548 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8550 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8551 error "dd failed on $fm_file"
8553 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8554 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8555 grep -v "ext:" | grep -v "found")
8557 last_lun=$(echo $filefrag_op | cut -d: -f5)
8562 for line in $filefrag_op
8564 frag_lun=`echo $line | cut -d: -f5`
8565 ext_len=`echo $line | cut -d: -f4`
8566 if (( $frag_lun != $last_lun )); then
8567 if (( tot_len != 1024 )); then
8569 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8576 (( tot_len += ext_len ))
8579 if (( num_luns != 2 || tot_len != 1024 )); then
8581 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8587 echo "FIEMAP on 2-stripe file succeeded"
8589 run_test 130b "FIEMAP (2-stripe file)"
8592 [ "$OSTCOUNT" -lt "2" ] &&
8593 skip_env "skipping FIEMAP on 2-stripe file" && return
8595 [ "$OSTCOUNT" -ge "10" ] &&
8596 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8598 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8599 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8602 trap cleanup_130 EXIT RETURN
8604 local fm_file=$DIR/$tfile
8605 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8606 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8607 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8609 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8611 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8612 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8614 last_lun=`echo $filefrag_op | cut -d: -f5`
8619 for line in $filefrag_op
8621 frag_lun=`echo $line | cut -d: -f5`
8622 ext_len=`echo $line | cut -d: -f4`
8623 if (( $frag_lun != $last_lun )); then
8624 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8625 if (( logical != 512 )); then
8627 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8630 if (( tot_len != 512 )); then
8632 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8639 (( tot_len += ext_len ))
8642 if (( num_luns != 2 || tot_len != 512 )); then
8644 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8650 echo "FIEMAP on 2-stripe file with hole succeeded"
8652 run_test 130c "FIEMAP (2-stripe file with hole)"
8655 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8657 [ "$OSTCOUNT" -ge "10" ] &&
8658 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8660 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8661 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8663 trap cleanup_130 EXIT RETURN
8665 local fm_file=$DIR/$tfile
8666 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8667 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8668 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8670 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8671 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8672 error "dd failed on $fm_file"
8674 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8675 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8676 grep -v "ext:" | grep -v "found"`
8678 last_lun=`echo $filefrag_op | cut -d: -f5`
8683 for line in $filefrag_op
8685 frag_lun=`echo $line | cut -d: -f5`
8686 ext_len=`echo $line | cut -d: -f4`
8687 if (( $frag_lun != $last_lun )); then
8688 if (( tot_len != 1024 )); then
8690 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8697 (( tot_len += ext_len ))
8700 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8702 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8708 echo "FIEMAP on N-stripe file succeeded"
8710 run_test 130d "FIEMAP (N-stripe file)"
8713 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8715 [ "$OSTCOUNT" -ge "10" ] &&
8716 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8718 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8719 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8721 trap cleanup_130 EXIT RETURN
8723 local fm_file=$DIR/$tfile
8724 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8725 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8726 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8729 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8730 for ((i = 0; i < $NUM_BLKS; i++))
8732 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8735 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8736 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8738 last_lun=`echo $filefrag_op | cut -d: -f5`
8743 for line in $filefrag_op
8745 frag_lun=`echo $line | cut -d: -f5`
8746 ext_len=`echo $line | cut -d: -f4`
8747 if (( $frag_lun != $last_lun )); then
8748 if (( tot_len != $EXPECTED_LEN )); then
8750 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8757 (( tot_len += ext_len ))
8760 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8762 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8768 echo "FIEMAP with continuation calls succeeded"
8770 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8772 # Test for writev/readv
8774 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8775 error "writev test failed"
8776 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8777 error "readv failed"
8780 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8783 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8784 error "append writev test failed"
8785 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8786 error "append writev test failed"
8789 run_test 131b "test append writev"
8792 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8795 run_test 131c "test read/write on file w/o objects"
8798 rwv -f $DIR/$tfile -w -n 1 1572864
8799 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8800 if [ "$NOB" != 1572864 ]; then
8801 error "Short read filed: read $NOB bytes instead of 1572864"
8805 run_test 131d "test short read"
8808 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8809 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8810 error "read hitting hole failed"
8813 run_test 131e "test read hitting hole"
8818 for node in $(osts_nodes); do
8819 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8820 [ x$gl = x"" ] && gl=0
8821 gl_sum=$((gl_sum + gl))
8831 if [ x$som = x"enabled" ]; then
8832 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8833 MOUNT_OPTS=`echo $MOUNT_OPTS |
8834 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8835 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8837 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8838 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8839 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8842 # do remount to make new mount-conf parameters actual
8849 test_132() { #1028, SOM
8850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8851 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8852 local num=$(get_mds_dir $DIR)
8853 local mymds=mds${num}
8854 local MOUNT_OPTS_SAVE=$MOUNT_OPTS
8856 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8857 cancel_lru_locks osc
8859 som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8861 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8862 stat $DIR/$tfile >/dev/null
8863 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8864 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8866 som_mode_switch $som1 $gl1 $gl2
8868 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8869 cancel_lru_locks osc
8871 som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
8872 if [ $som1 == $som2 ]; then
8873 error "som is still "$som2
8874 if [ x$som2 = x"enabled" ]; then
8881 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8882 stat $DIR/$tfile >/dev/null
8883 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8884 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8885 som_mode_switch $som2 $gl1 $gl2
8886 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8888 run_test 132 "som avoids glimpse rpc"
8894 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8896 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8898 *) error "Wrong argument $1" ;;
8901 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8902 # if the argument $3 is zero, it means any stat increment is ok.
8903 if [[ $3 -gt 0 ]]; then
8904 count=$(echo $res | awk '{ print $2 }')
8905 [[ $count -ne $3 ]] &&
8906 error "The $2 counter on $1 is wrong - expected $3"
8911 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8912 remote_ost_nodsh && skip "remote OST with nodsh" && return
8913 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8915 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8916 { skip "MDS doesn't support rename stats"; return; }
8917 local testdir=$DIR/${tdir}/stats_testdir
8918 mkdir -p $DIR/${tdir}
8921 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8922 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8924 # verify mdt stats first.
8925 mkdir ${testdir} || error "mkdir failed"
8926 check_stats $SINGLEMDS "mkdir" 1
8927 touch ${testdir}/${tfile} || "touch failed"
8928 check_stats $SINGLEMDS "open" 1
8929 check_stats $SINGLEMDS "close" 1
8930 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8931 check_stats $SINGLEMDS "mknod" 1
8932 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8933 check_stats $SINGLEMDS "unlink" 1
8934 rm -f ${testdir}/${tfile} || error "file remove failed"
8935 check_stats $SINGLEMDS "unlink" 2
8937 # remove working dir and check mdt stats again.
8938 rmdir ${testdir} || error "rmdir failed"
8939 check_stats $SINGLEMDS "rmdir" 1
8941 local testdir1=$DIR/${tdir}/stats_testdir1
8943 mkdir -p ${testdir1}
8944 touch ${testdir1}/test1
8945 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8946 check_stats $SINGLEMDS "crossdir_rename" 1
8948 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8949 check_stats $SINGLEMDS "samedir_rename" 1
8953 run_test 133a "Verifying MDT stats ========================================"
8956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8957 remote_ost_nodsh && skip "remote OST with nodsh" && return
8958 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8959 local testdir=$DIR/${tdir}/stats_testdir
8960 mkdir -p ${testdir} || error "mkdir failed"
8961 touch ${testdir}/${tfile} || "touch failed"
8962 cancel_lru_locks mdc
8965 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8966 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8968 # extra mdt stats verification.
8969 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8970 check_stats $SINGLEMDS "setattr" 1
8971 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8972 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8974 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8975 check_stats $SINGLEMDS "getattr" 1
8977 $LFS df || error "lfs failed"
8978 check_stats $SINGLEMDS "statfs" 1
8982 run_test 133b "Verifying extra MDT stats =================================="
8985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8986 remote_ost_nodsh && skip "remote OST with nodsh" && return
8987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8988 local testdir=$DIR/${tdir}/stats_testdir
8989 test_mkdir -p ${testdir} || error "mkdir failed"
8991 # verify obdfilter stats.
8992 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8994 cancel_lru_locks osc
8995 wait_delete_completed
8998 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8999 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9001 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9003 cancel_lru_locks osc
9004 check_stats ost "write" 1
9006 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9007 check_stats ost "read" 1
9009 > ${testdir}/${tfile} || error "truncate failed"
9010 check_stats ost "punch" 1
9012 rm -f ${testdir}/${tfile} || error "file remove failed"
9013 wait_delete_completed
9014 check_stats ost "destroy" 1
9018 run_test 133c "Verifying OST stats ========================================"
9025 while [ $value -ge 2 ]; do
9030 if [ $orig -gt $order ]; then
9038 local size=('K' 'M' 'G' 'T');
9040 local size_string=$value
9042 while [ $value -ge 1024 ]; do
9043 if [ $i -gt 3 ]; then
9044 #T is the biggest unit we get here, if that is bigger,
9046 size_string=${value}T
9049 value=$((value >> 10))
9050 if [ $value -lt 1024 ]; then
9051 size_string=${value}${size[$i]}
9062 local context=${2:-.}
9063 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9065 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9070 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9071 remote_ost_nodsh && skip "remote OST with nodsh" && return
9072 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9073 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9074 { skip "MDS doesn't support rename stats"; return; }
9076 local testdir1=$DIR/${tdir}/stats_testdir1
9077 local testdir2=$DIR/${tdir}/stats_testdir2
9079 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9081 mkdir -p ${testdir1} || error "mkdir failed"
9082 mkdir -p ${testdir2} || error "mkdir failed"
9084 createmany -o $testdir1/test 512 || error "createmany failed"
9086 # check samedir rename size
9087 mv ${testdir1}/test0 ${testdir1}/test_0
9089 local testdir1_size=$(ls -l $DIR/${tdir} |
9090 awk '/stats_testdir1/ {print $5}')
9091 local testdir2_size=$(ls -l $DIR/${tdir} |
9092 awk '/stats_testdir2/ {print $5}')
9094 testdir1_size=$(order_2 $testdir1_size)
9095 testdir2_size=$(order_2 $testdir2_size)
9097 testdir1_size=$(size_in_KMGT $testdir1_size)
9098 testdir2_size=$(size_in_KMGT $testdir2_size)
9100 echo "source rename dir size: ${testdir1_size}"
9101 echo "target rename dir size: ${testdir2_size}"
9103 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9104 eval $cmd || error "$cmd failed"
9105 local samedir=$($cmd | grep 'same_dir')
9106 local same_sample=$(get_rename_size $testdir1_size)
9107 [ -z "$samedir" ] && error "samedir_rename_size count error"
9108 [[ $same_sample -eq 1 ]] ||
9109 error "samedir_rename_size error $same_sample"
9110 echo "Check same dir rename stats success"
9112 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9114 # check crossdir rename size
9115 mv ${testdir1}/test_0 ${testdir2}/test_0
9117 testdir1_size=$(ls -l $DIR/${tdir} |
9118 awk '/stats_testdir1/ {print $5}')
9119 testdir2_size=$(ls -l $DIR/${tdir} |
9120 awk '/stats_testdir2/ {print $5}')
9122 testdir1_size=$(order_2 $testdir1_size)
9123 testdir2_size=$(order_2 $testdir2_size)
9125 testdir1_size=$(size_in_KMGT $testdir1_size)
9126 testdir2_size=$(size_in_KMGT $testdir2_size)
9128 echo "source rename dir size: ${testdir1_size}"
9129 echo "target rename dir size: ${testdir2_size}"
9131 eval $cmd || error "$cmd failed"
9132 local crossdir=$($cmd | grep 'crossdir')
9133 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9134 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9135 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9136 [[ $src_sample -eq 1 ]] ||
9137 error "crossdir_rename_size error $src_sample"
9138 [[ $tgt_sample -eq 1 ]] ||
9139 error "crossdir_rename_size error $tgt_sample"
9140 echo "Check cross dir rename stats success"
9143 run_test 133d "Verifying rename_stats ========================================"
9146 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9147 remote_ost_nodsh && skip "remote OST with nodsh" && return
9148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9149 local testdir=$DIR/${tdir}/stats_testdir
9150 local ctr f0 f1 bs=32768 count=42 sum
9152 mkdir -p ${testdir} || error "mkdir failed"
9154 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9156 for ctr in {write,read}_bytes; do
9158 cancel_lru_locks osc
9160 do_facet ost1 $LCTL set_param -n \
9161 "obdfilter.*.exports.clear=clear"
9163 if [ $ctr = write_bytes ]; then
9165 f1=${testdir}/${tfile}
9167 f0=${testdir}/${tfile}
9171 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9174 cancel_lru_locks osc
9176 sum=$(do_facet ost1 $LCTL get_param \
9177 "obdfilter.*.exports.*.stats" |
9178 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9179 $1 == ctr { sum += $7 }
9180 END { printf("%0.0f", sum) }')
9182 if ((sum != bs * count)); then
9183 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9189 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9194 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9195 /sys/fs/lustre/ /sys/fs/lnet/"
9197 for dir in $dirs; do
9198 if [ -d $dir ]; then
9199 proc_dirs="$proc_dirs $dir"
9205 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9206 remote_ost_nodsh && skip "remote OST with nodsh" && return
9207 # First without trusting modes.
9208 find $proc_dirs -exec cat '{}' \; &> /dev/null
9210 # Second verifying readability.
9213 -exec cat '{}' \; &> /dev/null ||
9214 error "proc file read failed"
9216 for facet in $SINGLEMDS ost1; do
9217 do_facet $facet find $proc_dirs \
9218 ! -name req_history \
9219 -exec cat '{}' \\\; &> /dev/null
9221 do_facet $facet find $proc_dirs \
9222 ! -name req_history \
9224 -exec cat '{}' \\\; &> /dev/null ||
9225 error "proc file read failed"
9228 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9233 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9234 /sys/fs/lustre/ /sys/fs/lnet/"
9236 for dir in $dirs; do
9237 if [ -d $dir ]; then
9238 proc_dirs="$proc_dirs $dir"
9244 # Second verifying readability.
9247 -not -name force_lbug \
9248 -not -name changelog_mask \
9249 -exec badarea_io '{}' \; &> /dev/null ||
9250 error "find $proc_dirs failed"
9252 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9253 skip "Too old lustre on MDS"
9255 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9256 skip "Too old lustre on ost1"
9258 for facet in $SINGLEMDS ost1; do
9259 do_facet $facet find $proc_dirs \
9261 -not -name force_lbug \
9262 -not -name changelog_mask \
9263 -exec badarea_io '{}' \\\; &> /dev/null ||
9264 error "$facet find $proc_dirs failed"
9268 # remount the FS in case writes/reads /proc break the FS
9269 cleanup || error "failed to unmount"
9270 setup || error "failed to setup"
9273 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9275 test_140() { #bug-17379
9276 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9277 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9278 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9279 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9281 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9282 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9284 while i=`expr $i + 1`; do
9285 test_mkdir -p $i || error "Creating dir $i"
9286 cd $i || error "Changing to $i"
9287 ln -s ../stat stat || error "Creating stat symlink"
9288 # Read the symlink until ELOOP present,
9289 # not LBUGing the system is considered success,
9290 # we didn't overrun the stack.
9291 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9293 if [ $ret -eq 40 ]; then
9296 error "Open stat symlink"
9302 echo "The symlink depth = $i"
9303 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9304 error "Invalid symlink depth"
9306 # Test recursive symlink
9307 ln -s symlink_self symlink_self
9308 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9309 echo "open symlink_self returns $ret"
9310 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9312 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9316 local TF="$TMP/$tfile"
9318 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9320 cancel_lru_locks osc
9321 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9322 remount_client $MOUNT
9324 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9327 $TRUNCATE $DIR/$tfile 6000
9328 cancel_lru_locks osc
9329 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9332 echo "12345" >>$DIR/$tfile
9333 cancel_lru_locks osc
9334 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9337 echo "12345" >>$DIR/$tfile
9338 cancel_lru_locks osc
9339 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9344 run_test 150 "truncate/append tests"
9346 #LU-2902 roc_hit was not able to read all values from lproc
9347 function roc_hit_init() {
9348 local list=$(comma_list $(osts_nodes))
9349 local dir=$DIR/$tdir-check
9350 local file=$dir/file
9356 #use setstripe to do a write to every ost
9357 for i in $(seq 0 $((OSTCOUNT-1))); do
9358 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9359 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9360 idx=$(printf %04x $i)
9361 BEFORE=$(get_osd_param $list *OST*$idx stats |
9362 awk '$1 == "cache_access" {sum += $7}
9363 END { printf("%0.0f", sum) }')
9365 cancel_lru_locks osc
9366 cat $file >/dev/null
9368 AFTER=$(get_osd_param $list *OST*$idx stats |
9369 awk '$1 == "cache_access" {sum += $7}
9370 END { printf("%0.0f", sum) }')
9372 echo BEFORE:$BEFORE AFTER:$AFTER
9373 if ! let "AFTER - BEFORE == 4"; then
9375 error "roc_hit is not safe to use"
9383 function roc_hit() {
9384 local list=$(comma_list $(osts_nodes))
9385 echo $(get_osd_param $list '' stats |
9386 awk '$1 == "cache_hit" {sum += $7}
9387 END { printf("%0.0f", sum) }')
9390 function set_cache() {
9393 if [ "$2" == "off" ]; then
9396 local list=$(comma_list $(osts_nodes))
9397 set_osd_param $list '' $1_cache_enable $on
9399 cancel_lru_locks osc
9403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9404 remote_ost_nodsh && skip "remote OST with nodsh" && return
9407 local list=$(comma_list $(osts_nodes))
9409 # check whether obdfilter is cache capable at all
9410 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9411 echo "not cache-capable obdfilter"
9415 # check cache is enabled on all obdfilters
9416 if get_osd_param $list '' read_cache_enable | grep 0; then
9417 echo "oss cache is disabled"
9421 set_osd_param $list '' writethrough_cache_enable 1
9423 # check write cache is enabled on all obdfilters
9424 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9425 echo "oss write cache is NOT enabled"
9431 #define OBD_FAIL_OBD_NO_LRU 0x609
9432 do_nodes $list $LCTL set_param fail_loc=0x609
9434 # pages should be in the case right after write
9435 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9438 local BEFORE=$(roc_hit)
9439 cancel_lru_locks osc
9440 cat $DIR/$tfile >/dev/null
9441 local AFTER=$(roc_hit)
9443 do_nodes $list $LCTL set_param fail_loc=0
9445 if ! let "AFTER - BEFORE == CPAGES"; then
9446 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9449 # the following read invalidates the cache
9450 cancel_lru_locks osc
9451 set_osd_param $list '' read_cache_enable 0
9452 cat $DIR/$tfile >/dev/null
9454 # now data shouldn't be found in the cache
9456 cancel_lru_locks osc
9457 cat $DIR/$tfile >/dev/null
9459 if let "AFTER - BEFORE != 0"; then
9460 error "IN CACHE: before: $BEFORE, after: $AFTER"
9463 set_osd_param $list '' read_cache_enable 1
9466 run_test 151 "test cache on oss and controls ==============================="
9469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9470 local TF="$TMP/$tfile"
9472 # simulate ENOMEM during write
9473 #define OBD_FAIL_OST_NOMEM 0x226
9474 lctl set_param fail_loc=0x80000226
9475 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9477 sync || error "sync failed"
9478 lctl set_param fail_loc=0
9480 # discard client's cache
9481 cancel_lru_locks osc
9483 # simulate ENOMEM during read
9484 lctl set_param fail_loc=0x80000226
9485 cmp $TF $DIR/$tfile || error "cmp failed"
9486 lctl set_param fail_loc=0
9490 run_test 152 "test read/write with enomem ============================"
9493 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9495 run_test 153 "test if fdatasync does not crash ======================="
9497 dot_lustre_fid_permission_check() {
9499 local ffid=$MOUNT/.lustre/fid/$fid
9502 echo "stat fid $fid"
9503 stat $ffid > /dev/null || error "stat $ffid failed."
9504 echo "touch fid $fid"
9505 touch $ffid || error "touch $ffid failed."
9506 echo "write to fid $fid"
9507 cat /etc/hosts > $ffid || error "write $ffid failed."
9508 echo "read fid $fid"
9509 diff /etc/hosts $ffid || error "read $ffid failed."
9510 echo "append write to fid $fid"
9511 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9512 echo "rename fid $fid"
9513 mv $ffid $test_dir/$tfile.1 &&
9514 error "rename $ffid to $tfile.1 should fail."
9515 touch $test_dir/$tfile.1
9516 mv $test_dir/$tfile.1 $ffid &&
9517 error "rename $tfile.1 to $ffid should fail."
9518 rm -f $test_dir/$tfile.1
9519 echo "truncate fid $fid"
9520 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9521 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9522 echo "link fid $fid"
9523 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9525 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9526 echo "setfacl fid $fid"
9527 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9528 echo "getfacl fid $fid"
9529 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9531 echo "unlink fid $fid"
9532 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9533 echo "mknod fid $fid"
9534 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9536 fid=[0xf00000400:0x1:0x0]
9537 ffid=$MOUNT/.lustre/fid/$fid
9539 echo "stat non-exist fid $fid"
9540 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9541 echo "write to non-exist fid $fid"
9542 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9543 echo "link new fid $fid"
9544 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9546 mkdir -p $test_dir/$tdir
9547 touch $test_dir/$tdir/$tfile
9548 fid=$($LFS path2fid $test_dir/$tdir)
9551 error "error: could not get fid for $test_dir/$dir/$tfile."
9553 ffid=$MOUNT/.lustre/fid/$fid
9556 ls $ffid > /dev/null || error "ls $ffid failed."
9557 echo "touch $fid/$tfile.1"
9558 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9560 echo "touch $MOUNT/.lustre/fid/$tfile"
9561 touch $MOUNT/.lustre/fid/$tfile && \
9562 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9564 echo "setxattr to $MOUNT/.lustre/fid"
9565 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9567 echo "listxattr for $MOUNT/.lustre/fid"
9568 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9570 echo "delxattr from $MOUNT/.lustre/fid"
9571 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9573 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9574 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9575 error "touch invalid fid should fail."
9577 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9578 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9579 error "touch non-normal fid should fail."
9581 echo "rename $tdir to $MOUNT/.lustre/fid"
9582 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9583 error "rename to $MOUNT/.lustre/fid should fail."
9585 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9587 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9588 local new_obf_mode=777
9590 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9591 chmod $new_obf_mode $DIR/.lustre/fid ||
9592 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9594 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9595 [ $obf_mode -eq $new_obf_mode ] ||
9596 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9598 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9599 chmod $old_obf_mode $DIR/.lustre/fid ||
9600 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9603 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9604 fid=$($LFS path2fid $test_dir/$tfile-2)
9606 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9608 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9609 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9610 error "create lov data thru .lustre failed"
9612 echo "cp /etc/passwd $test_dir/$tfile-2"
9613 cp /etc/passwd $test_dir/$tfile-2 ||
9614 error "copy to $test_dir/$tfile-2 failed."
9615 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9616 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9617 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9619 rm -rf $test_dir/tfile.lnk
9620 rm -rf $test_dir/$tfile-2
9624 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9625 skip "Need MDS version at least 2.4.1" && return
9628 local FID=$($LFS path2fid $DIR/$tfile)
9629 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9631 # check that we get the same pathname back
9632 local FOUND=$($LFS fid2path $MOUNT $FID)
9633 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9634 [ "$FOUND" != "$DIR/$tfile" ] &&
9635 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9639 run_test 154A "lfs path2fid and fid2path basic checks"
9642 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9643 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9644 { skip "Need MDS version at least 2.2.51"; return 0; }
9645 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9647 cp /etc/hosts $DIR/$tfile
9649 fid=$($LFS path2fid $DIR/$tfile)
9651 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9653 dot_lustre_fid_permission_check "$fid" $DIR ||
9654 error "dot lustre permission check $fid failed"
9656 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9658 touch $MOUNT/.lustre/file &&
9659 error "creation is not allowed under .lustre"
9661 mkdir $MOUNT/.lustre/dir &&
9662 error "mkdir is not allowed under .lustre"
9666 run_test 154a "Open-by-FID"
9669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9670 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9671 { skip "Need MDS version at least 2.2.51"; return 0; }
9673 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9675 local remote_dir=$DIR/$tdir/remote_dir
9680 $LFS mkdir -i $MDTIDX $remote_dir ||
9681 error "create remote directory failed"
9683 cp /etc/hosts $remote_dir/$tfile
9685 fid=$($LFS path2fid $remote_dir/$tfile)
9687 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9689 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9690 error "dot lustre permission check $fid failed"
9693 run_test 154b "Open-by-FID for remote directory"
9696 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9697 skip "Need MDS version at least 2.4.1" && return
9699 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9700 local FID1=$($LFS path2fid $DIR/$tfile.1)
9701 local FID2=$($LFS path2fid $DIR/$tfile.2)
9702 local FID3=$($LFS path2fid $DIR/$tfile.3)
9705 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9706 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9707 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9709 [ "$FID" = "${!want}" ] ||
9710 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9714 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9715 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9716 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9720 run_test 154c "lfs path2fid and fid2path multiple arguments"
9723 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9724 skip "Need MDS version at least 2.5.53" && return
9727 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9731 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9738 fid=$($LFS path2fid $DIR/$tfile)
9741 cmd="exec $fd<$DIR/$tfile"
9743 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9744 echo $fid_list | grep $fid
9747 cmd="exec $fd>/dev/null"
9749 if [ $rc -ne 0 ]; then
9750 error "FID $fid not found in open files list $fid_list"
9753 run_test 154d "Verify open file fid"
9757 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9758 skip "Need MDS version at least 2.6.50" && return
9760 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9761 error ".lustre returned by readdir"
9764 run_test 154e ".lustre is not returned by readdir"
9766 test_155_small_load() {
9767 local temp=$TMP/$tfile
9768 local file=$DIR/$tfile
9770 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9771 error "dd of=$temp bs=6096 count=1 failed"
9773 cancel_lru_locks osc
9774 cmp $temp $file || error "$temp $file differ"
9776 $TRUNCATE $temp 6000
9777 $TRUNCATE $file 6000
9778 cmp $temp $file || error "$temp $file differ (truncate1)"
9780 echo "12345" >>$temp
9781 echo "12345" >>$file
9782 cmp $temp $file || error "$temp $file differ (append1)"
9784 echo "12345" >>$temp
9785 echo "12345" >>$file
9786 cmp $temp $file || error "$temp $file differ (append2)"
9792 test_155_big_load() {
9793 remote_ost_nodsh && skip "remote OST with nodsh" && return
9794 local temp=$TMP/$tfile
9795 local file=$DIR/$tfile
9798 local cache_size=$(do_facet ost$((MAXI+1)) \
9799 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9800 local large_file_size=$((cache_size * 2))
9802 echo "OSS cache size: $cache_size KB"
9803 echo "Large file size: $large_file_size KB"
9805 [ $MAXV -le $large_file_size ] && \
9806 skip_env "max available OST size needs > $large_file_size KB" && \
9809 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9811 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9812 error "dd of=$temp bs=$large_file_size count=1k failed"
9815 cancel_lru_locks osc
9816 cmp $temp $file || error "$temp $file differ"
9823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9825 set_cache writethrough on
9828 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9833 set_cache writethrough off
9836 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9839 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9841 set_cache writethrough on
9844 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9847 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9849 set_cache writethrough off
9852 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9857 set_cache writethrough on
9860 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9863 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9865 set_cache writethrough off
9868 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9873 set_cache writethrough on
9876 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9879 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9881 set_cache writethrough off
9884 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9887 remote_ost_nodsh && skip "remote OST with nodsh" && return
9888 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9892 local file="$DIR/$tfile"
9894 [ "$(facet_fstype ost1)" = "zfs" ] &&
9895 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9900 log "Turn on read and write cache"
9902 set_cache writethrough on
9904 log "Write data and read it back."
9905 log "Read should be satisfied from the cache."
9906 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9908 cancel_lru_locks osc
9909 cat $file >/dev/null
9911 if ! let "AFTER - BEFORE == CPAGES"; then
9912 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9914 log "cache hits:: before: $BEFORE, after: $AFTER"
9917 log "Read again; it should be satisfied from the cache."
9919 cancel_lru_locks osc
9920 cat $file >/dev/null
9922 if ! let "AFTER - BEFORE == CPAGES"; then
9923 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9925 log "cache hits:: before: $BEFORE, after: $AFTER"
9929 log "Turn off the read cache and turn on the write cache"
9931 set_cache writethrough on
9933 log "Read again; it should be satisfied from the cache."
9935 cancel_lru_locks osc
9936 cat $file >/dev/null
9938 if ! let "AFTER - BEFORE == CPAGES"; then
9939 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9941 log "cache hits:: before: $BEFORE, after: $AFTER"
9944 log "Read again; it should not be satisfied from the cache."
9946 cancel_lru_locks osc
9947 cat $file >/dev/null
9949 if ! let "AFTER - BEFORE == 0"; then
9950 error "IN CACHE: before: $BEFORE, after: $AFTER"
9952 log "cache hits:: before: $BEFORE, after: $AFTER"
9955 log "Write data and read it back."
9956 log "Read should be satisfied from the cache."
9957 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9959 cancel_lru_locks osc
9960 cat $file >/dev/null
9962 if ! let "AFTER - BEFORE == CPAGES"; then
9963 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9965 log "cache hits:: before: $BEFORE, after: $AFTER"
9968 log "Read again; it should not be satisfied from the cache."
9970 cancel_lru_locks osc
9971 cat $file >/dev/null
9973 if ! let "AFTER - BEFORE == 0"; then
9974 error "IN CACHE: before: $BEFORE, after: $AFTER"
9976 log "cache hits:: before: $BEFORE, after: $AFTER"
9980 log "Turn off read and write cache"
9982 set_cache writethrough off
9984 log "Write data and read it back"
9985 log "It should not be satisfied from the cache."
9987 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9988 cancel_lru_locks osc
9990 cat $file >/dev/null
9992 if ! let "AFTER - BEFORE == 0"; then
9993 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9995 log "cache hits:: before: $BEFORE, after: $AFTER"
9998 log "Turn on the read cache and turn off the write cache"
10000 set_cache writethrough off
10002 log "Write data and read it back"
10003 log "It should not be satisfied from the cache."
10005 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10007 cancel_lru_locks osc
10008 cat $file >/dev/null
10010 if ! let "AFTER - BEFORE == 0"; then
10011 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10013 log "cache hits:: before: $BEFORE, after: $AFTER"
10016 log "Read again; it should be satisfied from the cache."
10018 cancel_lru_locks osc
10019 cat $file >/dev/null
10021 if ! let "AFTER - BEFORE == CPAGES"; then
10022 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10024 log "cache hits:: before: $BEFORE, after: $AFTER"
10029 run_test 156 "Verification of tunables ============================"
10033 if [[ $MDSCOUNT -gt 1 ]]; then
10034 error_ignore bz17935 $*
10042 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10044 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10046 if [ $MASK -eq 1 ]; then
10047 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10049 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10053 changelog_extract_field() {
10057 local identifier=$4
10059 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10060 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10066 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10067 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10068 { skip "Need MDS version at least 2.2.0"; return; }
10070 local CL_USERS="mdd.$MDT0.changelog_users"
10071 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10072 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10073 echo "Registered as changelog user $USER"
10074 $GET_CL_USERS | grep -q $USER ||
10075 error "User $USER not found in changelog_users"
10078 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10079 touch $DIR/$tdir/pics/2008/zachy/timestamp
10080 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10081 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10082 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10083 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10084 rm $DIR/$tdir/pics/desktop.jpg
10086 $LFS changelog $MDT0 | tail -5
10088 echo "verifying changelog mask"
10089 changelog_chmask "MKDIR"
10090 changelog_chmask "CLOSE"
10092 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10093 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10095 changelog_chmask "MKDIR"
10096 changelog_chmask "CLOSE"
10098 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10099 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10101 $LFS changelog $MDT0
10102 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10103 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10104 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10105 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10108 echo "verifying target fid"
10109 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10110 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10111 [ "$fidc" == "$fidf" ] ||
10112 err17935 "fid in changelog $fidc != file fid $fidf"
10113 echo "verifying parent fid"
10114 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10115 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10116 [ "$fidc" == "$fidf" ] ||
10117 err17935 "pfid in changelog $fidc != dir fid $fidf"
10119 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10120 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10121 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10122 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10123 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10124 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10126 MIN_REC=$($GET_CL_USERS |
10127 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10128 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10129 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10130 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10131 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10133 # LU-3446 changelog index reset on MDT restart
10134 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10135 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10136 $LFS changelog_clear $MDT0 $USER 0
10137 stop $SINGLEMDS || error "Fail to stop MDT."
10138 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10139 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10140 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10141 [ $CUR_REC1 == $CUR_REC2 ] ||
10142 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10144 echo "verifying user deregister"
10145 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10146 $GET_CL_USERS | grep -q $USER &&
10147 error "User $USER still in changelog_users"
10149 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10150 if [ $USERS -eq 0 ]; then
10151 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10152 touch $DIR/$tdir/chloe
10153 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10154 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10155 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10157 echo "$USERS other changelog users; can't verify off"
10160 run_test 160a "changelog sanity"
10162 test_160b() { # LU-3587
10163 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10164 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10165 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10166 { skip "Need MDS version at least 2.2.0"; return; }
10168 local CL_USERS="mdd.$MDT0.changelog_users"
10169 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10170 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10171 echo "Registered as changelog user $USER"
10172 $GET_CL_USERS | grep -q $USER ||
10173 error "User $USER not found in changelog_users"
10175 local LONGNAME1=$(str_repeat a 255)
10176 local LONGNAME2=$(str_repeat b 255)
10179 echo "creating very long named file"
10180 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10181 echo "moving very long named file"
10182 mv $LONGNAME1 $LONGNAME2
10184 $LFS changelog $MDT0 | grep RENME
10186 echo "deregistering $USER"
10187 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10191 run_test 160b "Verify that very long rename doesn't crash in changelog"
10195 local server_version=$(lustre_version_code $SINGLEMDS)
10197 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10198 [[ $server_version -gt $(version_code 2.5.1) &&
10199 $server_version -lt $(version_code 2.5.50) ]] ||
10200 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10203 # Registration step
10204 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10205 changelog_register -n)
10208 mkdir -p $DIR/$tdir
10209 $MCREATE $DIR/$tdir/foo_160c
10210 changelog_chmask "TRUNC"
10211 $TRUNCATE $DIR/$tdir/foo_160c 200
10212 changelog_chmask "TRUNC"
10213 $TRUNCATE $DIR/$tdir/foo_160c 199
10214 $LFS changelog $MDT0
10215 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10216 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10217 $LFS changelog_clear $MDT0 $USER 0
10219 # Deregistration step
10220 echo "deregistering $USER"
10221 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10223 run_test 160c "verify that changelog log catch the truncate event"
10226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10227 test_mkdir -p -c1 $DIR/$tdir
10228 cp /etc/hosts $DIR/$tdir/$tfile
10229 test_mkdir -c1 $DIR/$tdir/foo1
10230 test_mkdir -c1 $DIR/$tdir/foo2
10231 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10232 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10233 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10234 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10235 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10236 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10237 $LFS fid2path $DIR $FID
10238 err17935 "bad link ea"
10241 rm $DIR/$tdir/foo2/zachary
10243 rm $DIR/$tdir/foo2/thor
10245 rm $DIR/$tdir/$tfile
10247 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10248 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10250 $LFS fid2path $DIR $FID
10251 err17935 "bad link rename"
10253 rm $DIR/$tdir/foo2/maggie
10256 local longname=filename_avg_len_is_thirty_two_
10257 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10258 error "failed to hardlink many files"
10259 links=$($LFS fid2path $DIR $FID | wc -l)
10260 echo -n "${links}/1000 links in link EA"
10261 [[ $links -gt 60 ]] ||
10262 err17935 "expected at least 60 links in link EA"
10263 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10264 error "failed to unlink many hardlinks"
10266 run_test 161a "link ea sanity"
10269 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10270 [ $MDSCOUNT -lt 2 ] &&
10271 skip "skipping remote directory test" && return
10273 local remote_dir=$DIR/$tdir/remote_dir
10275 mkdir -p $DIR/$tdir
10276 $LFS mkdir -i $MDTIDX $remote_dir ||
10277 error "create remote directory failed"
10279 cp /etc/hosts $remote_dir/$tfile
10280 mkdir -p $remote_dir/foo1
10281 mkdir -p $remote_dir/foo2
10282 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10283 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10284 ln $remote_dir/$tfile $remote_dir/foo1/luna
10285 ln $remote_dir/$tfile $remote_dir/foo2/thor
10287 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10289 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10290 $LFS fid2path $DIR $FID
10291 err17935 "bad link ea"
10294 rm $remote_dir/foo2/zachary
10296 rm $remote_dir/foo2/thor
10298 rm $remote_dir/$tfile
10300 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10301 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10302 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10303 $LFS fid2path $DIR $FID
10304 err17935 "bad link rename"
10306 rm $remote_dir/foo2/maggie
10309 local longname=filename_avg_len_is_thirty_two_
10310 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10311 error "failed to hardlink many files"
10312 links=$($LFS fid2path $DIR $FID | wc -l)
10313 echo -n "${links}/1000 links in link EA"
10314 [[ ${links} -gt 60 ]] ||
10315 err17935 "expected at least 60 links in link EA"
10316 unlinkmany $remote_dir/foo2/$longname 1000 ||
10317 error "failed to unlink many hardlinks"
10319 run_test 161b "link ea sanity under remote directory"
10322 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10323 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10324 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10325 skip "Need MDS version at least 2.1.5" && return
10327 # define CLF_RENAME_LAST 0x0001
10328 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10329 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10330 changelog_register -n)
10332 mkdir -p $DIR/$tdir
10333 touch $DIR/$tdir/foo_161c
10334 touch $DIR/$tdir/bar_161c
10335 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10336 $LFS changelog $MDT0 | grep RENME
10337 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10339 $LFS changelog_clear $MDT0 $USER 0
10340 if [ x$flags != "x0x1" ]; then
10341 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10343 error "flag $flags is not 0x1"
10345 echo "rename overwrite a target having nlink = 1," \
10346 "changelog record has flags of $flags"
10348 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10349 touch $DIR/$tdir/foo_161c
10350 touch $DIR/$tdir/bar_161c
10351 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10352 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10353 $LFS changelog $MDT0 | grep RENME
10354 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10355 $LFS changelog_clear $MDT0 $USER 0
10356 if [ x$flags != "x0x0" ]; then
10357 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10359 error "flag $flags is not 0x0"
10361 echo "rename overwrite a target having nlink > 1," \
10362 "changelog record has flags of $flags"
10364 # rename doesn't overwrite a target (changelog flag 0x0)
10365 touch $DIR/$tdir/foo_161c
10366 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10367 $LFS changelog $MDT0 | grep RENME
10368 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10369 $LFS changelog_clear $MDT0 $USER 0
10370 if [ x$flags != "x0x0" ]; then
10371 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10373 error "flag $flags is not 0x0"
10375 echo "rename doesn't overwrite a target," \
10376 "changelog record has flags of $flags"
10378 # define CLF_UNLINK_LAST 0x0001
10379 # unlink a file having nlink = 1 (changelog flag 0x1)
10380 rm -f $DIR/$tdir/foo2_161c
10381 $LFS changelog $MDT0 | grep UNLNK
10382 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10383 $LFS changelog_clear $MDT0 $USER 0
10384 if [ x$flags != "x0x1" ]; then
10385 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10387 error "flag $flags is not 0x1"
10389 echo "unlink a file having nlink = 1," \
10390 "changelog record has flags of $flags"
10392 # unlink a file having nlink > 1 (changelog flag 0x0)
10393 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10394 rm -f $DIR/$tdir/foobar_161c
10395 $LFS changelog $MDT0 | grep UNLNK
10396 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10397 $LFS changelog_clear $MDT0 $USER 0
10398 if [ x$flags != "x0x0" ]; then
10399 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10401 error "flag $flags is not 0x0"
10403 echo "unlink a file having nlink > 1," \
10404 "changelog record has flags of $flags"
10405 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10407 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10414 local path=$(${LFS} fid2path $*)
10417 if [ $RC -ne 0 ]; then
10418 err17935 "path looked up of $expected failed. Error $RC"
10420 elif [ "${path}" != "${expected}" ]; then
10421 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10424 echo "fid $fid resolves to path $path (expected $expected)"
10428 # Make changes to filesystem
10429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10430 test_mkdir -p -c1 $DIR/$tdir/d2
10431 touch $DIR/$tdir/d2/$tfile
10432 touch $DIR/$tdir/d2/x1
10433 touch $DIR/$tdir/d2/x2
10434 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10435 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10437 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10438 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10439 error "check path $tdir/d2/$tfile failed"
10442 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10443 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10444 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10445 error "check path $tdir/d2/p/q/r/slink failed"
10447 # softlink to wrong file
10448 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10449 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10450 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10451 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10454 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10455 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10456 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10457 # fid2path dir/fsname should both work
10458 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10459 error "check path $tdir/d2/a/b/c/new_file failed"
10460 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10461 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10463 # hardlink count: check that there are 2 links
10464 # Doesnt work with CMD yet: 17935
10465 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10466 err17935 "expected 2 links"
10468 # hardlink indexing: remove the first link
10469 rm $DIR/$tdir/d2/p/q/r/hlink
10470 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10471 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10475 run_test 162 "path lookup sanity"
10478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10479 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10482 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10483 error "create striped dir failed"
10485 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10486 tail -n 1 | awk '{print $2}')
10487 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10489 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10490 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10493 for ((i=0;i<5;i++)); do
10494 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10495 error "get fid for f$i failed"
10496 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10497 error "check path $tdir/striped_dir/f$i failed"
10499 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10500 error "get fid for d$i failed"
10501 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10502 error "check path $tdir/striped_dir/d$i failed"
10507 run_test 162b "striped directory path lookup sanity"
10510 # do directio so as not to populate the page cache
10511 log "creating a 10 Mb file"
10512 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10513 log "starting reads"
10514 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10515 log "truncating the file"
10516 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10518 kill %+ || true # reads might have finished
10519 echo "wait until dd is finished"
10521 log "removing the temporary file"
10522 rm -rf $DIR/$tfile || error "tmp file removal failed"
10524 run_test 169 "parallel read and truncate should not deadlock"
10527 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10528 $LCTL clear # bug 18514
10529 $LCTL debug_daemon start $TMP/${tfile}_log_good
10531 $LCTL debug_daemon stop
10532 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10533 error "sed failed to read log_good"
10535 $LCTL debug_daemon start $TMP/${tfile}_log_good
10537 $LCTL debug_daemon stop
10539 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10540 error "lctl df log_bad failed"
10542 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10543 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10545 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10546 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10548 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10549 error "bad_line good_line1 good_line2 are empty"
10551 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10552 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10553 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10555 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10556 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10557 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10559 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10560 error "bad_line_new good_line_new are empty"
10562 local expected_good=$((good_line1 + good_line2*2))
10564 rm -f $TMP/${tfile}*
10565 # LU-231, short malformed line may not be counted into bad lines
10566 if [ $bad_line -ne $bad_line_new ] &&
10567 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10568 error "expected $bad_line bad lines, but got $bad_line_new"
10572 if [ $expected_good -ne $good_line_new ]; then
10573 error "expected $expected_good good lines, but got $good_line_new"
10578 run_test 170 "test lctl df to handle corrupted log ====================="
10580 test_171() { # bug20592
10581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10582 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10583 $LCTL set_param fail_loc=0x50e
10584 $LCTL set_param fail_val=3000
10585 multiop_bg_pause $DIR/$tfile O_s || true
10587 kill -USR1 $MULTIPID
10591 if dmesg | grep "recursive fault"; then
10592 error "caught a recursive fault"
10594 $LCTL set_param fail_loc=0
10597 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10599 # it would be good to share it with obdfilter-survey/iokit-libecho code
10600 setup_obdecho_osc () {
10603 local obdfilter_name=$2
10604 echo "Creating new osc for $obdfilter_name on $ost_nid"
10605 # make sure we can find loopback nid
10606 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10608 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10609 ${obdfilter_name}_osc_UUID || rc=2; }
10610 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10611 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10615 cleanup_obdecho_osc () {
10616 local obdfilter_name=$1
10617 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10618 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10625 local pages=${3:-64}
10630 local obd_size=$(get_obd_size $node $OBD)
10631 local page_size=$(get_page_size $node)
10632 if [[ -n "$obd_size" ]]; then
10633 local new_count=$((obd_size / (pages * page_size / 1024)))
10634 [[ $new_count -ge $count ]] || count=$new_count
10637 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10638 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10640 if [ $rc -eq 0 ]; then
10641 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10642 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10644 echo "New object id is $id"
10645 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10647 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10648 "test_brw $count w v $pages $id" || rc=4; }
10649 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10651 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10652 "cleanup" || rc=5; }
10653 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10654 "detach" || rc=6; }
10655 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10661 remote_ost_nodsh && skip "remote OST with nodsh" && return
10663 local rmmod_local=0
10665 if ! module_loaded obdecho; then
10666 load_module obdecho/obdecho
10670 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10671 local host=$(lctl get_param -n osc.$osc.import |
10672 awk '/current_connection:/ {print $2}' )
10673 local target=$(lctl get_param -n osc.$osc.import |
10674 awk '/target:/ {print $2}' )
10675 target=${target%_UUID}
10677 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10678 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10679 [[ -n $target ]] && cleanup_obdecho_osc $target
10680 [ $rmmod_local -eq 1 ] && rmmod obdecho
10683 run_test 180a "test obdecho on osc"
10686 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10687 remote_ost_nodsh && skip "remote OST with nodsh" && return
10689 local rmmod_remote=0
10691 do_facet ost1 "lsmod | grep -q obdecho || " \
10692 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10693 "modprobe obdecho; }" && rmmod_remote=1
10694 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10695 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10696 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10699 run_test 180b "test obdecho directly on obdfilter"
10701 test_180c() { # LU-2598
10702 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10703 remote_ost_nodsh && skip "remote OST with nodsh" && return
10704 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10705 skip "Need MDS version at least 2.4.0" && return
10708 local rmmod_remote=false
10709 local pages=16384 # 64MB bulk I/O RPC size
10712 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10713 rmmod_remote=true || error "failed to load module obdecho"
10715 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10717 if [ -n "$target" ]; then
10718 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10720 echo "there is no obdfilter target on ost1"
10723 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10726 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10728 test_181() { # bug 22177
10729 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10730 # create enough files to index the directory
10731 createmany -o $DIR/$tdir/foobar 4000
10732 # print attributes for debug purpose
10735 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10737 # remove the files & current working dir
10738 unlinkmany $DIR/$tdir/foobar 4000
10740 kill -USR1 $MULTIPID
10742 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10745 run_test 181 "Test open-unlinked dir ========================"
10748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10749 # disable MDC RPC lock wouldn't crash client
10753 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10754 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10755 $LCTL set_param fail_loc=0x804
10757 for (( i=0; i < $tcount; i++ )) ; do
10758 mkdir $DIR/$tdir/$i
10759 createmany -o $DIR/$tdir/$i/f- $fcount &
10763 for (( i=0; i < $tcount; i++ )) ; do
10764 unlinkmany $DIR/$tdir/$i/f- $fcount &
10770 $LCTL set_param fail_loc=0
10772 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10774 test_183() { # LU-2275
10775 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10776 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10777 skip "Need MDS version at least 2.3.56" && return
10779 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10780 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10781 echo aaa > $DIR/$tdir/$tfile
10783 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10784 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10786 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10787 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10789 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10791 # Flush negative dentry cache
10792 touch $DIR/$tdir/$tfile
10794 # We are not checking for any leaked references here, they'll
10795 # become evident next time we do cleanup with module unload.
10798 run_test 183 "No crash or request leak in case of strange dispositions ========"
10800 # test suite 184 is for LU-2016, LU-2017
10802 check_swap_layouts_support && return 0
10804 dir0=$DIR/$tdir/$testnum
10805 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
10810 $SETSTRIPE -c1 $file1
10812 $SETSTRIPE -c2 $file2
10814 gen1=$($GETSTRIPE -g $file1)
10815 gen2=$($GETSTRIPE -g $file2)
10817 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10818 gen=$($GETSTRIPE -g $file1)
10819 [[ $gen1 != $gen ]] ||
10820 "Layout generation on $file1 does not change"
10821 gen=$($GETSTRIPE -g $file2)
10822 [[ $gen2 != $gen ]] ||
10823 "Layout generation on $file2 does not change"
10825 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10826 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10828 run_test 184a "Basic layout swap"
10831 check_swap_layouts_support && return 0
10833 dir0=$DIR/$tdir/$testnum
10834 mkdir -p $dir0 || error "creating dir $dir0"
10841 $SETSTRIPE -c1 $file1
10842 $SETSTRIPE -c2 $file2
10843 $SETSTRIPE -c1 $file3
10844 chown $RUNAS_ID $file3
10845 gen1=$($GETSTRIPE -g $file1)
10846 gen2=$($GETSTRIPE -g $file2)
10848 $LFS swap_layouts $dir1 $dir2 &&
10849 error "swap of directories layouts should fail"
10850 $LFS swap_layouts $dir1 $file1 &&
10851 error "swap of directory and file layouts should fail"
10852 $RUNAS $LFS swap_layouts $file1 $file2 &&
10853 error "swap of file we cannot write should fail"
10854 $LFS swap_layouts $file1 $file3 &&
10855 error "swap of file with different owner should fail"
10856 /bin/true # to clear error code
10858 run_test 184b "Forbidden layout swap (will generate errors)"
10861 check_swap_layouts_support && return 0
10863 local dir0=$DIR/$tdir/$testnum
10864 mkdir -p $dir0 || error "creating dir $dir0"
10866 local ref1=$dir0/ref1
10867 local ref2=$dir0/ref2
10868 local file1=$dir0/file1
10869 local file2=$dir0/file2
10870 # create a file large enough for the concurent test
10871 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10872 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10873 echo "ref file size: ref1($(stat -c %s $ref1))," \
10874 "ref2($(stat -c %s $ref2))"
10877 dd if=$ref1 of=$file1 bs=16k &
10880 # Make sure dd starts to copy file
10881 while [ ! -f $file1 ]; do sleep 0.1; done
10883 $LFS swap_layouts $file1 $file2
10886 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10887 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10889 # how many bytes copied before swapping layout
10890 local copied=$(stat -c %s $file2)
10891 local remaining=$(stat -c %s $ref1)
10892 remaining=$((remaining - copied))
10893 echo "Copied $copied bytes before swapping layout..."
10895 cmp -n $copied $file1 $ref2 | grep differ &&
10896 error "Content mismatch [0, $copied) of ref2 and file1"
10897 cmp -n $copied $file2 $ref1 ||
10898 error "Content mismatch [0, $copied) of ref1 and file2"
10899 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10900 error "Content mismatch [$copied, EOF) of ref1 and file1"
10903 rm -f $ref1 $ref2 $file1 $file2
10905 run_test 184c "Concurrent write and layout swap"
10908 check_swap_layouts_support && return 0
10909 [ -z "$(which getfattr 2>/dev/null)" ] &&
10910 skip "no getfattr command" && return 0
10912 local file1=$DIR/$tdir/$tfile-1
10913 local file2=$DIR/$tdir/$tfile-2
10914 local file3=$DIR/$tdir/$tfile-3
10918 mkdir -p $DIR/$tdir
10919 touch $file1 || error "create $file1 failed"
10920 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10921 error "create $file2 failed"
10922 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10923 error "create $file3 failed"
10924 lovea1=$($LFS getstripe $file1 | sed 1d)
10926 $LFS swap_layouts $file2 $file3 ||
10927 error "swap $file2 $file3 layouts failed"
10928 $LFS swap_layouts $file1 $file2 ||
10929 error "swap $file1 $file2 layouts failed"
10931 lovea2=$($LFS getstripe $file2 | sed 1d)
10932 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10934 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10935 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
10937 run_test 184d "allow stripeless layouts swap"
10940 test_185() { # LU-2441
10941 # LU-3553 - no volatile file support in old servers
10942 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10943 { skip "Need MDS version at least 2.3.60"; return 0; }
10945 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10946 touch $DIR/$tdir/spoo
10947 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10948 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10949 error "cannot create/write a volatile file"
10950 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10951 error "FID is still valid after close"
10953 multiop_bg_pause $DIR/$tdir vVw4096_c
10960 # assume that the next FID for this client is sequential, since stdout
10961 # is unfortunately eaten by multiop_bg_pause
10962 local n=$((${fidv[1]} + 1))
10963 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10964 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10965 error "FID is missing before close"
10966 kill -USR1 $multi_pid
10967 # 1 second delay, so if mtime change we will see it
10969 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10970 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10972 run_test 185 "Volatile file support"
10975 local dir0=$DIR/$tdir/$testnum
10976 mkdir -p $dir0 || error "creating dir $dir0"
10978 local file=$dir0/file1
10979 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10980 local dv1=$($LFS data_version $file)
10981 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10982 local dv2=$($LFS data_version $file)
10983 [[ $dv1 != $dv2 ]] ||
10984 error "data version did not change on write $dv1 == $dv2"
10989 run_test 187a "Test data version change"
10992 local dir0=$DIR/$tdir/$testnum
10993 mkdir -p $dir0 || error "creating dir $dir0"
10995 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10996 [[ ${DV[0]} != ${DV[1]} ]] ||
10997 error "data version did not change on write"\
10998 " ${DV[0]} == ${DV[1]}"
11003 run_test 187b "Test data version change on volatile file"
11006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11007 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11009 local POOL=${POOL:-cea1}
11010 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11011 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11014 local last_ost=$(($OSTCOUNT - 1))
11016 local ost_list=$(seq $first_ost $ost_step $last_ost)
11017 local ost_range="$first_ost $last_ost $ost_step"
11018 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11019 local file_dir=$POOL_ROOT/file_tst
11023 # former test_200a test_200b
11024 pool_add $POOL || { rc=$? ; break; }
11025 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11026 # former test_200c test_200d
11027 mkdir -p $test_path
11028 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11029 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11030 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11031 || { rc=$? ; break; }
11032 # former test_200e test_200f
11033 local files=$((OSTCOUNT*3))
11034 pool_alloc_files $POOL $test_path $files "$ost_list" \
11035 || { rc=$? ; break; }
11036 pool_create_files $POOL $file_dir $files "$ost_list" \
11037 || { rc=$? ; break; }
11038 # former test_200g test_200h
11039 pool_lfs_df $POOL || { rc=$? ; break; }
11040 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11042 # former test_201a test_201b test_201c
11043 pool_remove_first_target $POOL || { rc=$? ; break; }
11045 local f=$test_path/$tfile
11046 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11047 pool_remove $POOL $f || { rc=$? ; break; }
11054 run_test 200 "OST pools"
11056 # usage: default_attr <count | size | offset>
11058 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11061 # usage: check_default_stripe_attr
11062 check_default_stripe_attr() {
11063 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11065 --stripe-count|--count)
11066 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11067 --stripe-size|--size)
11068 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11069 --stripe-index|--index)
11072 error "unknown getstripe attr '$1'"
11075 [ $ACTUAL != $EXPECTED ] &&
11076 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11080 test_mkdir -p $DIR/$tdir
11081 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11083 check_default_stripe_attr --stripe-count
11084 check_default_stripe_attr --stripe-size
11085 check_default_stripe_attr --stripe-index
11089 run_test 204a "Print default stripe attributes ================="
11092 test_mkdir -p $DIR/$tdir
11093 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11095 check_default_stripe_attr --stripe-size
11096 check_default_stripe_attr --stripe-index
11100 run_test 204b "Print default stripe size and offset ==========="
11103 test_mkdir -p $DIR/$tdir
11104 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11106 check_default_stripe_attr --stripe-count
11107 check_default_stripe_attr --stripe-index
11111 run_test 204c "Print default stripe count and offset ==========="
11114 test_mkdir -p $DIR/$tdir
11115 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11117 check_default_stripe_attr --stripe-count
11118 check_default_stripe_attr --stripe-size
11122 run_test 204d "Print default stripe count and size ============="
11125 test_mkdir -p $DIR/$tdir
11126 $SETSTRIPE -d $DIR/$tdir
11128 check_default_stripe_attr --stripe-count --raw
11129 check_default_stripe_attr --stripe-size --raw
11130 check_default_stripe_attr --stripe-index --raw
11134 run_test 204e "Print raw stripe attributes ================="
11137 test_mkdir -p $DIR/$tdir
11138 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11140 check_default_stripe_attr --stripe-size --raw
11141 check_default_stripe_attr --stripe-index --raw
11145 run_test 204f "Print raw stripe size and offset ==========="
11148 test_mkdir -p $DIR/$tdir
11149 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11151 check_default_stripe_attr --stripe-count --raw
11152 check_default_stripe_attr --stripe-index --raw
11156 run_test 204g "Print raw stripe count and offset ==========="
11159 test_mkdir -p $DIR/$tdir
11160 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11162 check_default_stripe_attr --stripe-count --raw
11163 check_default_stripe_attr --stripe-size --raw
11167 run_test 204h "Print raw stripe count and size ============="
11169 # Figure out which job scheduler is being used, if any,
11170 # or use a fake one
11171 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11172 JOBENV=SLURM_JOB_ID
11173 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11175 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11177 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11178 JOBENV=LOADL_STEP_ID
11179 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11185 verify_jobstats() {
11189 # clear old jobstats
11190 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11191 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11193 # use a new JobID for this test, or we might see an old one
11194 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11198 log "Using JobID environment variable $JOBENV=$JOBVAL"
11200 if [ $JOBENV = "FAKE_JOBID" ]; then
11201 FAKE_JOBID=$JOBVAL $cmd
11206 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11207 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11208 do_facet $FACET lctl get_param mdt.*.job_stats |
11209 grep $JOBVAL || error "No job stats found on MDT $FACET"
11211 if [ "$target" = "ost" -o "$target" = "both" ]; then
11213 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11214 grep $JOBVAL || error "No job stats found on OST $FACET"
11220 NEW_JOBENV=${1:-$OLD_JOBENV}
11221 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11222 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11225 test_205() { # Job stats
11226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11227 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11228 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11229 skip "Server doesn't support jobstats" && return 0
11230 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11233 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11234 if [ $OLD_JOBENV != $JOBENV ]; then
11235 jobstats_set $JOBENV
11236 trap jobstats_set EXIT
11240 cmd="mkdir $DIR/$tfile"
11241 verify_jobstats "$cmd" "mdt"
11243 cmd="rm -fr $DIR/$tfile"
11244 verify_jobstats "$cmd" "mdt"
11246 cmd="mknod $DIR/$tfile c 1 3"
11247 verify_jobstats "$cmd" "mdt"
11249 cmd="rm -f $DIR/$tfile"
11250 verify_jobstats "$cmd" "mdt"
11252 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11253 verify_jobstats "$cmd" "mdt"
11255 cmd="touch $DIR/$tfile"
11256 verify_jobstats "$cmd" "both"
11258 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11259 verify_jobstats "$cmd" "ost"
11261 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11262 verify_jobstats "$cmd" "ost"
11264 cmd="$TRUNCATE $DIR/$tfile 0"
11265 verify_jobstats "$cmd" "both"
11267 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11268 verify_jobstats "$cmd" "mdt"
11271 rm -f $DIR/jobstats_test_rename
11273 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11275 run_test 205 "Verify job stats"
11277 # LU-1480, LU-1773 and LU-1657
11279 mkdir -p $DIR/$tdir
11280 $SETSTRIPE -c -1 $DIR/$tdir
11281 #define OBD_FAIL_LOV_INIT 0x1403
11282 $LCTL set_param fail_loc=0xa0001403
11283 $LCTL set_param fail_val=1
11284 touch $DIR/$tdir/$tfile || true
11286 run_test 206 "fail lov_init_raid0() doesn't lbug"
11289 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11290 local fsz=`stat -c %s $DIR/$tfile`
11291 cancel_lru_locks mdc
11293 # do not return layout in getattr intent
11294 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11295 $LCTL set_param fail_loc=0x170
11296 local sz=`stat -c %s $DIR/$tfile`
11298 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11302 run_test 207a "can refresh layout at glimpse"
11305 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11306 local cksum=`md5sum $DIR/$tfile`
11307 local fsz=`stat -c %s $DIR/$tfile`
11308 cancel_lru_locks mdc
11309 cancel_lru_locks osc
11311 # do not return layout in getattr intent
11312 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11313 $LCTL set_param fail_loc=0x171
11315 # it will refresh layout after the file is opened but before read issues
11316 echo checksum is "$cksum"
11317 echo "$cksum" |md5sum -c --quiet || error "file differs"
11321 run_test 207b "can refresh layout at open"
11324 # FIXME: in this test suite, only RD lease is used. This is okay
11325 # for now as only exclusive open is supported. After generic lease
11326 # is done, this test suite should be revised. - Jinshan
11328 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11329 { skip "Need MDS version at least 2.4.52"; return 0; }
11330 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11332 echo "==== test 1: verify get lease work"
11333 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11335 echo "==== test 2: verify lease can be broken by upcoming open"
11336 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11340 $MULTIOP $DIR/$tfile oO_RDONLY:c
11341 kill -USR1 $PID && wait $PID || error "break lease error"
11343 echo "==== test 3: verify lease can't be granted if an open already exists"
11344 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11348 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11349 kill -USR1 $PID && wait $PID || error "open file error"
11351 echo "==== test 4: lease can sustain over recovery"
11352 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11358 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11360 echo "==== test 5: lease broken can't be regained by replay"
11361 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11365 # open file to break lease and then recovery
11366 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11369 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11373 run_test 208 "Exclusive open"
11376 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11377 skip_env "must have disp_stripe" && return
11380 sync; sleep 5; sync;
11382 echo 3 > /proc/sys/vm/drop_caches
11383 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11385 # open/close 500 times
11386 for i in $(seq 500); do
11390 echo 3 > /proc/sys/vm/drop_caches
11391 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11393 echo "before: $req_before, after: $req_after"
11394 [ $((req_after - req_before)) -ge 300 ] &&
11395 error "open/close requests are not freed"
11398 run_test 209 "read-only open/close requests should be freed promptly"
11402 size=$((size % 8192 + 1))
11403 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11404 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11405 rm -f $DIR/f212 $DIR/f212.xyz
11407 run_test 212 "Sendfile test ============================================"
11410 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11411 cancel_lru_locks osc
11412 lctl set_param fail_loc=0x8000040f
11413 # generate a read lock
11414 cat $DIR/$tfile > /dev/null
11415 # write to the file, it will try to cancel the above read lock.
11416 cat /etc/hosts >> $DIR/$tfile
11418 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11420 test_214() { # for bug 20133
11421 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11422 for (( i=0; i < 340; i++ )) ; do
11423 touch $DIR/$tdir/d214c/a$i
11426 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11427 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11428 ls $DIR/d214c || error "ls $DIR/d214c failed"
11429 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11430 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11432 run_test 214 "hash-indexed directory test - bug 20133"
11434 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11435 create_lnet_proc_files() {
11436 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11437 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11439 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11440 rm -f "$TMP/lnet_$1.sys_tmp"
11443 # counterpart of create_lnet_proc_files
11444 remove_lnet_proc_files() {
11445 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11448 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11449 # 3rd arg as regexp for body
11450 check_lnet_proc_stats() {
11451 local l=$(cat "$TMP/lnet_$1" |wc -l)
11452 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11454 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11457 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11458 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11459 # optional and can be regexp for 2nd line (lnet.routes case)
11460 check_lnet_proc_entry() {
11461 local blp=2 # blp stands for 'position of 1st line of body'
11462 [ -z "$5" ] || blp=3 # lnet.routes case
11464 local l=$(cat "$TMP/lnet_$1" |wc -l)
11465 # subtracting one from $blp because the body can be empty
11466 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11468 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11469 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11471 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11472 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11474 # bail out if any unexpected line happened
11475 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11476 [ "$?" != 0 ] || error "$2 misformatted"
11479 test_215() { # for bugs 18102, 21079, 21517
11480 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11481 local N='(0|[1-9][0-9]*)' # non-negative numeric
11482 local P='[1-9][0-9]*' # positive numeric
11483 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11484 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11485 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11486 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11488 local L1 # regexp for 1st line
11489 local L2 # regexp for 2nd line (optional)
11490 local BR # regexp for the rest (body)
11492 # lnet.stats should look as 11 space-separated non-negative numerics
11493 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11494 create_lnet_proc_files "stats"
11495 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11496 remove_lnet_proc_files "stats"
11498 # lnet.routes should look like this:
11499 # Routing disabled/enabled
11500 # net hops priority state router
11501 # where net is a string like tcp0, hops > 0, priority >= 0,
11502 # state is up/down,
11503 # router is a string like 192.168.1.1@tcp2
11504 L1="^Routing (disabled|enabled)$"
11505 L2="^net +hops +priority +state +router$"
11506 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11507 create_lnet_proc_files "routes"
11508 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11509 remove_lnet_proc_files "routes"
11511 # lnet.routers should look like this:
11512 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11513 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11514 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11515 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11516 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11517 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11518 create_lnet_proc_files "routers"
11519 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11520 remove_lnet_proc_files "routers"
11522 # lnet.peers should look like this:
11523 # nid refs state last max rtr min tx min queue
11524 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11525 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11526 # numeric (0 or >0 or <0), queue >= 0.
11527 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11528 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11529 create_lnet_proc_files "peers"
11530 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11531 remove_lnet_proc_files "peers"
11533 # lnet.buffers should look like this:
11534 # pages count credits min
11535 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11536 L1="^pages +count +credits +min$"
11537 BR="^ +$N +$N +$I +$I$"
11538 create_lnet_proc_files "buffers"
11539 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11540 remove_lnet_proc_files "buffers"
11542 # lnet.nis should look like this:
11543 # nid status alive refs peer rtr max tx min
11544 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11545 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11546 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11547 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11548 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11549 create_lnet_proc_files "nis"
11550 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11551 remove_lnet_proc_files "nis"
11553 # can we successfully write to lnet.stats?
11554 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11555 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11557 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11559 test_216() { # bug 20317
11560 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11561 remote_ost_nodsh && skip "remote OST with nodsh" && return
11564 local facets=$(get_facets OST)
11565 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11567 save_lustre_params client "osc.*.contention_seconds" > $p
11568 save_lustre_params $facets \
11569 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11570 save_lustre_params $facets \
11571 "ldlm.namespaces.filter-*.contended_locks" >> $p
11572 save_lustre_params $facets \
11573 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11576 # agressive lockless i/o settings
11577 for node in $(osts_nodes); do
11578 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'
11580 lctl set_param -n osc.*.contention_seconds 60
11582 $DIRECTIO write $DIR/$tfile 0 10 4096
11583 $CHECKSTAT -s 40960 $DIR/$tfile
11585 # disable lockless i/o
11586 for node in $(osts_nodes); do
11587 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'
11589 lctl set_param -n osc.*.contention_seconds 0
11592 dd if=/dev/zero of=$DIR/$tfile count=0
11593 $CHECKSTAT -s 0 $DIR/$tfile
11595 restore_lustre_params <$p
11599 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11601 test_217() { # bug 22430
11602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11606 for node in $(nodes_list); do
11607 nid=$(host_nids_address $node $NETTYPE)
11608 if [[ $nid = *-* ]] ; then
11609 echo "lctl ping $nid@$NETTYPE"
11610 lctl ping $nid@$NETTYPE
11612 echo "skipping $node (no hyphen detected)"
11616 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11619 # do directio so as not to populate the page cache
11620 log "creating a 10 Mb file"
11621 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11622 log "starting reads"
11623 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11624 log "truncating the file"
11625 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11627 kill %+ || true # reads might have finished
11628 echo "wait until dd is finished"
11630 log "removing the temporary file"
11631 rm -rf $DIR/$tfile || error "tmp file removal failed"
11633 run_test 218 "parallel read and truncate should not deadlock ======================="
11636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11637 # write one partial page
11638 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11639 # set no grant so vvp_io_commit_write will do sync write
11640 $LCTL set_param fail_loc=0x411
11641 # write a full page at the end of file
11642 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11644 $LCTL set_param fail_loc=0
11645 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11646 $LCTL set_param fail_loc=0x411
11647 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11650 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11651 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11653 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11655 test_220() { #LU-325
11656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11657 remote_ost_nodsh && skip "remote OST with nodsh" && return
11660 test_mkdir -p $DIR/$tdir
11661 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11662 awk '{print $2}' | sed -e 's/_UUID$//')
11665 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11666 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11667 osc.$mdtosc_proc1.prealloc_last_id)
11668 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11669 osc.$mdtosc_proc1.prealloc_next_id)
11673 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11674 #define OBD_FAIL_OST_ENOINO 0x229
11675 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11676 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11677 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11679 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11681 MDSOBJS=$((last_id - next_id))
11682 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11684 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11685 echo "OST still has $count kbytes free"
11687 echo "create $MDSOBJS files @next_id..."
11688 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11690 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11691 osc.$mdtosc_proc1.prealloc_last_id)
11692 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11693 osc.$mdtosc_proc1.prealloc_next_id)
11695 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11700 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11701 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11703 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11704 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11705 echo "unlink $MDSOBJS files @$next_id..."
11706 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11708 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11712 dd if=`which date` of=$MOUNT/date oflag=sync
11713 chmod +x $MOUNT/date
11715 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11716 $LCTL set_param fail_loc=0x80001401
11718 $MOUNT/date > /dev/null
11721 run_test 221 "make sure fault and truncate race to not cause OOM"
11724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11726 test_mkdir -p $DIR/$tdir
11727 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11728 createmany -o $DIR/$tdir/$tfile 10
11729 cancel_lru_locks mdc
11730 cancel_lru_locks osc
11731 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11732 $LCTL set_param fail_loc=0x31a
11733 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11734 $LCTL set_param fail_loc=0
11737 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11742 test_mkdir -p $DIR/$tdir
11743 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11744 createmany -o $DIR/$tdir/$tfile 10
11745 cancel_lru_locks mdc
11746 cancel_lru_locks osc
11747 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11748 $LCTL set_param fail_loc=0x31a
11749 rm -r $DIR/$tdir || "AGL for rmdir failed"
11750 $LCTL set_param fail_loc=0
11752 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11755 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11757 test_mkdir -p $DIR/$tdir
11758 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11759 createmany -o $DIR/$tdir/$tfile 10
11760 cancel_lru_locks mdc
11761 cancel_lru_locks osc
11762 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11763 $LCTL set_param fail_loc=0x31b
11764 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11765 $LCTL set_param fail_loc=0
11768 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11770 test_224a() { # LU-1039, MRP-303
11771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11772 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11773 $LCTL set_param fail_loc=0x508
11774 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11775 $LCTL set_param fail_loc=0
11778 run_test 224a "Don't panic on bulk IO failure"
11780 test_224b() { # LU-1039, MRP-303
11781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11782 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11783 cancel_lru_locks osc
11784 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11785 $LCTL set_param fail_loc=0x515
11786 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11787 $LCTL set_param fail_loc=0
11790 run_test 224b "Don't panic on bulk IO failure"
11792 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11795 if [ -z ${MDSSURVEY} ]; then
11796 skip_env "mds-survey not found" && return
11799 [ $MDSCOUNT -ge 2 ] &&
11800 skip "skipping now for more than one MDT" && return
11802 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11803 { skip "Need MDS version at least 2.2.51"; return; }
11805 local mds=$(facet_host $SINGLEMDS)
11806 local target=$(do_nodes $mds 'lctl dl' | \
11807 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11809 local cmd1="file_count=1000 thrhi=4"
11810 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11811 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11812 local cmd="$cmd1 $cmd2 $cmd3"
11814 rm -f ${TMP}/mds_survey*
11816 eval $cmd || error "mds-survey with zero-stripe failed"
11817 cat ${TMP}/mds_survey*
11818 rm -f ${TMP}/mds_survey*
11820 run_test 225a "Metadata survey sanity with zero-stripe"
11823 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11825 if [ -z ${MDSSURVEY} ]; then
11826 skip_env "mds-survey not found" && return
11828 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11829 { skip "Need MDS version at least 2.2.51"; return; }
11831 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11832 skip_env "Need to mount OST to test" && return
11835 [ $MDSCOUNT -ge 2 ] &&
11836 skip "skipping now for more than one MDT" && return
11837 local mds=$(facet_host $SINGLEMDS)
11838 local target=$(do_nodes $mds 'lctl dl' | \
11839 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11841 local cmd1="file_count=1000 thrhi=4"
11842 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11843 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11844 local cmd="$cmd1 $cmd2 $cmd3"
11846 rm -f ${TMP}/mds_survey*
11848 eval $cmd || error "mds-survey with stripe_count failed"
11849 cat ${TMP}/mds_survey*
11850 rm -f ${TMP}/mds_survey*
11852 run_test 225b "Metadata survey sanity with stripe_count = 1"
11854 mcreate_path2fid () {
11860 local path=$DIR/$tdir/$name
11865 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11866 error "cannot create $desc"
11868 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11870 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11872 fid_path=$($LFS fid2path $MOUNT $fid)
11874 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11876 [ "$path" == "$fid_path" ] ||
11877 error "fid2path returned $fid_path, expected $path"
11879 echo "pass with $path and $fid"
11884 mkdir -p $DIR/$tdir
11886 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11887 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11888 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11889 mcreate_path2fid 0040666 0 0 dir "directory"
11890 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11891 mcreate_path2fid 0100666 0 0 file "regular file"
11892 mcreate_path2fid 0120666 0 0 link "symbolic link"
11893 mcreate_path2fid 0140666 0 0 sock "socket"
11895 run_test 226a "call path2fid and fid2path on files of all type"
11898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11902 mkdir -p $DIR/$tdir
11903 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11904 error "create remote directory failed"
11905 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11906 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11907 "character special file (null)"
11908 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11909 "character special file (no device)"
11910 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11911 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11912 "block special file (loop)"
11913 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11914 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11915 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11917 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11919 # LU-1299 Executing or running ldd on a truncated executable does not
11920 # cause an out-of-memory condition.
11922 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11923 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
11924 dd if=$(which date) of=$MOUNT/date bs=1k count=1
11925 chmod +x $MOUNT/date
11927 $MOUNT/date > /dev/null
11928 ldd $MOUNT/date > /dev/null
11931 run_test 227 "running truncated executable does not cause OOM"
11933 # LU-1512 try to reuse idle OI blocks
11935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11936 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11937 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11938 skip "non-ldiskfs backend" && return
11940 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11941 local myDIR=$DIR/$tdir
11944 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11945 $LCTL set_param fail_loc=0x80001002
11946 createmany -o $myDIR/t- 10000
11947 $LCTL set_param fail_loc=0
11948 # The guard is current the largest FID holder
11950 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11952 local IDX=$(($SEQ % 64))
11954 do_facet $SINGLEMDS sync
11955 # Make sure journal flushed.
11957 local blk1=$(do_facet $SINGLEMDS \
11958 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11959 grep Blockcount | awk '{print $4}')
11961 # Remove old files, some OI blocks will become idle.
11962 unlinkmany $myDIR/t- 10000
11963 # Create new files, idle OI blocks should be reused.
11964 createmany -o $myDIR/t- 2000
11965 do_facet $SINGLEMDS sync
11966 # Make sure journal flushed.
11968 local blk2=$(do_facet $SINGLEMDS \
11969 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11970 grep Blockcount | awk '{print $4}')
11972 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11974 run_test 228a "try to reuse idle OI blocks"
11977 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11978 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11979 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11980 skip "non-ldiskfs backend" && return
11982 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11983 local myDIR=$DIR/$tdir
11986 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11987 $LCTL set_param fail_loc=0x80001002
11988 createmany -o $myDIR/t- 10000
11989 $LCTL set_param fail_loc=0
11990 # The guard is current the largest FID holder
11992 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11994 local IDX=$(($SEQ % 64))
11996 do_facet $SINGLEMDS sync
11997 # Make sure journal flushed.
11999 local blk1=$(do_facet $SINGLEMDS \
12000 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12001 grep Blockcount | awk '{print $4}')
12003 # Remove old files, some OI blocks will become idle.
12004 unlinkmany $myDIR/t- 10000
12007 stop $SINGLEMDS || error "Fail to stop MDT."
12009 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12011 df $MOUNT || error "Fail to df."
12012 # Create new files, idle OI blocks should be reused.
12013 createmany -o $myDIR/t- 2000
12014 do_facet $SINGLEMDS sync
12015 # Make sure journal flushed.
12017 local blk2=$(do_facet $SINGLEMDS \
12018 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12019 grep Blockcount | awk '{print $4}')
12021 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12023 run_test 228b "idle OI blocks can be reused after MDT restart"
12027 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12028 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12029 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12030 skip "non-ldiskfs backend" && return
12032 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12033 local myDIR=$DIR/$tdir
12036 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12037 $LCTL set_param fail_loc=0x80001002
12038 # 20000 files can guarantee there are index nodes in the OI file
12039 createmany -o $myDIR/t- 20000
12040 $LCTL set_param fail_loc=0
12041 # The guard is current the largest FID holder
12043 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12045 local IDX=$(($SEQ % 64))
12047 do_facet $SINGLEMDS sync
12048 # Make sure journal flushed.
12050 local blk1=$(do_facet $SINGLEMDS \
12051 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12052 grep Blockcount | awk '{print $4}')
12054 # Remove old files, some OI blocks will become idle.
12055 unlinkmany $myDIR/t- 20000
12057 # The OI file should become empty now
12059 # Create new files, idle OI blocks should be reused.
12060 createmany -o $myDIR/t- 2000
12061 do_facet $SINGLEMDS sync
12062 # Make sure journal flushed.
12064 local blk2=$(do_facet $SINGLEMDS \
12065 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12066 grep Blockcount | awk '{print $4}')
12068 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12070 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12072 test_229() { # LU-2482, LU-3448
12073 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12074 skip "No HSM support on MDS of $(get_lustre_version)," \
12075 "need 2.4.53 at least" && return
12076 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12077 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12081 # Create a file with a released layout and stripe count 2.
12082 $MULTIOP $DIR/$tfile H2c ||
12083 error "failed to create file with released layout"
12085 $GETSTRIPE -v $DIR/$tfile
12087 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12088 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12090 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12091 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12092 stat $DIR/$tfile || error "failed to stat released file"
12094 chown $RUNAS_ID $DIR/$tfile ||
12095 error "chown $RUNAS_ID $DIR/$tfile failed"
12097 chgrp $RUNAS_ID $DIR/$tfile ||
12098 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12100 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12101 rm $DIR/$tfile || error "failed to remove released file"
12103 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12110 mkdir -p $DIR/$tdir/test_230_local
12111 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12112 [ $mdt_idx -ne 0 ] &&
12113 error "create local directory on wrong MDT $mdt_idx"
12115 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12116 error "create remote directory failed"
12117 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12118 [ $mdt_idx -ne $MDTIDX ] &&
12119 error "create remote directory on wrong MDT $mdt_idx"
12121 createmany -o $DIR/$tdir/test_230/t- 10 ||
12122 error "create files on remote directory failed"
12123 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12124 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12125 rm -r $DIR/$tdir || error "unlink remote directory failed"
12127 run_test 230a "Create remote directory and files under the remote directory"
12130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12131 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12138 local migrate_dir=$DIR/$tdir/migrate_dir
12139 local other_dir=$DIR/$tdir/other_dir
12141 mkdir -p $migrate_dir
12142 mkdir -p $other_dir
12143 for ((i=0; i<10; i++)); do
12144 mkdir -p $migrate_dir/dir_${i}
12145 createmany -o $migrate_dir/dir_${i}/f 10 ||
12146 error "create files under remote dir failed $i"
12149 cp /etc/passwd $migrate_dir/$tfile
12150 cp /etc/passwd $other_dir/$tfile
12151 chattr +SAD $migrate_dir
12152 chattr +SAD $migrate_dir/$tfile
12154 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12155 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12156 local old_dir_mode=$(stat -c%f $migrate_dir)
12157 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12159 mkdir -p $migrate_dir/dir_default_stripe2
12160 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12161 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12163 mkdir -p $other_dir
12164 ln $migrate_dir/$tfile $other_dir/luna
12165 ln $migrate_dir/$tfile $migrate_dir/sofia
12166 ln $other_dir/$tfile $migrate_dir/david
12167 ln -s $migrate_dir/$tfile $other_dir/zachary
12168 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12169 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12171 $LFS mv -v -M $MDTIDX $migrate_dir ||
12172 error "migrate remote dir error"
12174 echo "migratate to MDT1, then checking.."
12175 for ((i=0; i<10; i++)); do
12176 for file in $(find $migrate_dir/dir_${i}); do
12177 mdt_index=$($LFS getstripe -M $file)
12178 [ $mdt_index == $MDTIDX ] ||
12179 error "$file is not on MDT${MDTIDX}"
12183 # the multiple link file should still in MDT0
12184 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12185 [ $mdt_index == 0 ] ||
12186 error "$file is not on MDT${MDTIDX}"
12188 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12189 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12190 error " expect $old_dir_flag get $new_dir_flag"
12192 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12193 [ "$old_file_flag" = "$new_file_flag" ] ||
12194 error " expect $old_file_flag get $new_file_flag"
12196 local new_dir_mode=$(stat -c%f $migrate_dir)
12197 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12198 error "expect mode $old_dir_mode get $new_dir_mode"
12200 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12201 [ "$old_file_mode" = "$new_file_mode" ] ||
12202 error "expect mode $old_file_mode get $new_file_mode"
12204 diff /etc/passwd $migrate_dir/$tfile ||
12205 error "$tfile different after migration"
12207 diff /etc/passwd $other_dir/luna ||
12208 error "luna different after migration"
12210 diff /etc/passwd $migrate_dir/sofia ||
12211 error "sofia different after migration"
12213 diff /etc/passwd $migrate_dir/david ||
12214 error "david different after migration"
12216 diff /etc/passwd $other_dir/zachary ||
12217 error "zachary different after migration"
12219 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12220 error "${tfile}_ln different after migration"
12222 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12223 error "${tfile}_ln_other different after migration"
12225 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12226 [ $stripe_count = 2 ] ||
12227 error "dir strpe_count $d != 2 after migration."
12229 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12230 [ $stripe_count = 2 ] ||
12231 error "file strpe_count $d != 2 after migration."
12233 #migrate back to MDT0
12235 $LFS mv -v -M $MDTIDX $migrate_dir ||
12236 error "migrate remote dir error"
12238 echo "migrate back to MDT0, checking.."
12239 for file in $(find $migrate_dir); do
12240 mdt_index=$($LFS getstripe -M $file)
12241 [ $mdt_index == $MDTIDX ] ||
12242 error "$file is not on MDT${MDTIDX}"
12245 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12246 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12247 error " expect $old_dir_flag get $new_dir_flag"
12249 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12250 [ "$old_file_flag" = "$new_file_flag" ] ||
12251 error " expect $old_file_flag get $new_file_flag"
12253 local new_dir_mode=$(stat -c%f $migrate_dir)
12254 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12255 error "expect mode $old_dir_mode get $new_dir_mode"
12257 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12258 [ "$old_file_mode" = "$new_file_mode" ] ||
12259 error "expect mode $old_file_mode get $new_file_mode"
12261 diff /etc/passwd ${migrate_dir}/$tfile ||
12262 error "$tfile different after migration"
12264 diff /etc/passwd ${other_dir}/luna ||
12265 error "luna different after migration"
12267 diff /etc/passwd ${migrate_dir}/sofia ||
12268 error "sofia different after migration"
12270 diff /etc/passwd ${other_dir}/zachary ||
12271 error "zachary different after migration"
12273 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12274 error "${tfile}_ln different after migration"
12276 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12277 error "${tfile}_ln_other different after migration"
12279 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12280 [ $stripe_count = 2 ] ||
12281 error "dir strpe_count $d != 2 after migration."
12283 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12284 [ $stripe_count = 2 ] ||
12285 error "file strpe_count $d != 2 after migration."
12287 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12289 run_test 230b "migrate directory"
12292 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12293 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12298 #If migrating directory fails in the middle, all entries of
12299 #the directory is still accessiable.
12300 mkdir -p $DIR/$tdir
12302 createmany -o $DIR/$tdir/f 10 ||
12303 error "create files under ${tdir} failed"
12305 #failed after migrating 5 entries
12306 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12307 do_facet mds1 lctl set_param fail_loc=0x20001801
12308 do_facet mds1 lctl set_param fail_val=5
12309 local t=`ls $DIR/$tdir | wc -l`
12310 $LFS mv -M $MDTIDX $DIR/$tdir &&
12311 error "migrate should failed after 5 entries"
12312 local u=`ls $DIR/$tdir | wc -l`
12313 [ "$u" == "$t" ] || error "$u != $t during migration"
12315 for file in $(find $DIR/$tdir); do
12316 stat $file || error "stat $file failed"
12319 do_facet mds1 lctl set_param fail_loc=0
12320 do_facet mds1 lctl set_param fail_val=0
12322 $LFS mv -M $MDTIDX $DIR/$tdir ||
12323 error "migrate open files should failed with open files"
12325 echo "Finish migration, then checking.."
12326 for file in $(find $DIR/$tdir); do
12327 mdt_index=$($LFS getstripe -M $file)
12328 [ $mdt_index == $MDTIDX ] ||
12329 error "$file is not on MDT${MDTIDX}"
12332 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12334 run_test 230c "check directory accessiblity if migration is failed"
12337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12338 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12344 mkdir -p $DIR/$tdir
12346 for ((i=0; i<100; i++)); do
12347 mkdir -p $DIR/$tdir/dir_${i}
12348 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12349 error "create files under remote dir failed $i"
12352 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12354 echo "Finish migration, then checking.."
12355 for file in $(find $DIR/$tdir); do
12356 mdt_index=$($LFS getstripe -M $file)
12357 [ $mdt_index == $MDTIDX ] ||
12358 error "$file is not on MDT${MDTIDX}"
12361 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12363 run_test 230d "check migrate big directory"
12367 # For simplicity this test assumes that max_pages_per_rpc
12368 # is the same across all OSCs
12369 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12370 local bulk_size=$((max_pages * 4096))
12372 mkdir -p $DIR/$tdir
12374 # clear the OSC stats
12375 $LCTL set_param osc.*.stats=0 &>/dev/null
12377 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12378 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12379 oflag=direct &>/dev/null || error "dd failed"
12381 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12382 if [ x$nrpcs != "x1" ]; then
12383 error "found $nrpc ost_write RPCs, not 1 as expected"
12386 # Drop the OSC cache, otherwise we will read from it
12387 cancel_lru_locks osc
12389 # clear the OSC stats
12390 $LCTL set_param osc.*.stats=0 &>/dev/null
12392 # Client reads $bulk_size.
12393 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12394 iflag=direct &>/dev/null || error "dd failed"
12396 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12397 if [ x$nrpcs != "x1" ]; then
12398 error "found $nrpc ost_read RPCs, not 1 as expected"
12401 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12404 mkdir -p $DIR/$tdir
12406 for i in {0..1023}; do
12407 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12408 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12409 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12413 run_test 231b "must not assert on fully utilized OST request buffer"
12416 mkdir -p $DIR/$tdir
12417 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12418 $LCTL set_param fail_loc=0x31c
12420 # ignore dd failure
12421 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12423 $LCTL set_param fail_loc=0
12424 umount_client $MOUNT || error "umount failed"
12425 mount_client $MOUNT || error "mount failed"
12427 run_test 232 "failed lock should not block umount"
12430 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12431 { skip "Need MDS version at least 2.3.64"; return; }
12433 local fid=$($LFS path2fid $MOUNT)
12434 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12435 error "cannot access $MOUNT using its FID '$fid'"
12437 run_test 233a "checking that OBF of the FS root succeeds"
12440 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12441 { skip "Need MDS version at least 2.5.90"; return; }
12443 local fid=$($LFS path2fid $MOUNT/.lustre)
12444 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12445 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12447 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12448 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12449 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12451 run_test 233b "checking that OBF of the FS .lustre succeeds"
12454 local p="$TMP/sanityN-$TESTNAME.parameters"
12455 save_lustre_params client "llite.*.xattr_cache" > $p
12456 lctl set_param llite.*.xattr_cache 1 ||
12457 { skip "xattr cache is not supported"; return 0; }
12459 mkdir -p $DIR/$tdir || error "mkdir failed"
12460 touch $DIR/$tdir/$tfile || error "touch failed"
12461 # OBD_FAIL_LLITE_XATTR_ENOMEM
12462 $LCTL set_param fail_loc=0x1405
12463 if [ ! -f /etc/SuSE-release ]; then
12464 # attr pre-2.4.44-7 had a bug with rc
12465 # LU-3703 - SLES clients have older attr
12466 getfattr -n user.attr $DIR/$tdir/$tfile &&
12467 error "getfattr should have failed with ENOMEM"
12469 $LCTL set_param fail_loc=0x0
12472 restore_lustre_params < $p
12475 run_test 234 "xattr cache should not crash on ENOMEM"
12478 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12479 skip "Need MDS version at least 2.4.52" && return
12480 flock_deadlock $DIR/$tfile
12485 124) error "process hangs on a deadlock"
12487 *) error "error executing flock_deadlock $DIR/$tfile"
12491 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12495 check_swap_layouts_support && return 0
12496 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12498 local ref1=/etc/passwd
12499 local ref2=/etc/group
12500 local file1=$DIR/$tdir/f1
12501 local file2=$DIR/$tdir/f2
12503 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12504 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12505 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12506 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12507 local fd=$(free_fd)
12508 local cmd="exec $fd<>$file2"
12511 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12512 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12515 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12520 run_test 236 "Layout swap on open unlinked file"
12522 # test to verify file handle related system calls
12523 # (name_to_handle_at/open_by_handle_at)
12524 # The new system calls are supported in glibc >= 2.14.
12527 echo "Test file_handle syscalls" > $DIR/$tfile ||
12528 error "write failed"
12529 check_fhandle_syscalls $DIR/$tfile ||
12530 error "check_fhandle_syscalls failed"
12532 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12534 # LU-4659 linkea consistency
12536 local server_version=$(lustre_version_code $SINGLEMDS)
12538 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12539 [[ $server_version -gt $(version_code 2.5.1) &&
12540 $server_version -lt $(version_code 2.5.50) ]] ||
12541 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12544 ln $DIR/$tfile $DIR/$tfile.lnk
12545 touch $DIR/$tfile.new
12546 mv $DIR/$tfile.new $DIR/$tfile
12547 local fid1=$(lfs path2fid $DIR/$tfile)
12548 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12549 local path1=$(lfs fid2path $FSNAME $fid1)
12550 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12551 local path2=$(lfs fid2path $FSNAME $fid2)
12552 [ $tfile.lnk == $path2 ] ||
12553 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12556 run_test 238 "Verify linkea consistency"
12559 local list=$(comma_list $(mdts_nodes))
12561 mkdir -p $DIR/$tdir
12562 createmany -o $DIR/$tdir/f- 5000
12563 unlinkmany $DIR/$tdir/f- 5000
12564 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12565 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12566 osc.*MDT*.sync_in_flight" | calc_sum)
12567 [ "$changes" -eq 0 ] || error "$changes not synced"
12569 run_test 239 "osp_sync test"
12572 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12574 mkdir -p $DIR/$tdir
12576 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12577 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12578 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12579 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12581 umount_client $MOUNT || error "umount failed"
12582 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12583 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12584 mount_client $MOUNT || error "failed to mount client"
12586 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12587 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12589 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12592 for LOOP in $(seq $1); do
12593 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12594 cancel_lru_locks osc
12599 for LOOP in $(seq $1); do
12600 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12601 iflag=direct 2>/dev/null
12606 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12608 cancel_lru_locks osc
12609 test_241_bio 1000 &
12614 run_test 241 "bio vs dio"
12616 cleanup_test_300() {
12620 test_striped_dir() {
12625 mkdir -p $DIR/$tdir
12627 SAVE_UMASK=$(umask)
12628 trap cleanup_test_300 RETURN EXIT
12630 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12631 $DIR/$tdir/striped_dir ||
12632 error "set striped dir error"
12634 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12635 [ "$mode" = "755" ] || error "expect 755 got $mode"
12637 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12638 if [ "$stripe_count" != "2" ]; then
12639 error "stripe_count is $stripe_count, expect 2"
12642 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12643 if [ "$stripe_index" != "$mdt_index" ]; then
12644 error "stripe_index is $stripe_index, expect $mdt_index"
12647 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12648 error "nlink error after create striped dir"
12650 mkdir $DIR/$tdir/striped_dir/a
12651 mkdir $DIR/$tdir/striped_dir/b
12653 stat $DIR/$tdir/striped_dir/a ||
12654 error "create dir under striped dir failed"
12655 stat $DIR/$tdir/striped_dir/b ||
12656 error "create dir under striped dir failed"
12658 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12659 error "nlink error after mkdir"
12661 rmdir $DIR/$tdir/striped_dir/a
12662 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12663 error "nlink error after rmdir"
12665 rmdir $DIR/$tdir/striped_dir/b
12666 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12667 error "nlink error after rmdir"
12669 rmdir $DIR/$tdir/striped_dir ||
12670 error "rmdir striped dir error"
12678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12679 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12681 test_striped_dir 0 || error "failed on striped dir on MDT0"
12682 test_striped_dir 1 || error "failed on striped dir on MDT0"
12684 run_test 300a "basic striped dir sanity test"
12687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12688 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12694 test_mkdir $DIR/$tdir || error "mkdir fail"
12695 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12696 error "set striped dir error"
12697 for ((i=0; i<10; i++)); do
12698 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12700 touch $DIR/$tdir/striped_dir/file_$i ||
12701 error "touch error $i"
12702 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
12703 [ $mtime1 -eq $mtime2 ] &&
12704 error "mtime not change after create"
12706 rm -f $DIR/$tdir/striped_dir/file_$i ||
12707 error "unlink error $i"
12708 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
12709 [ $mtime2 -eq $mtime3 ] &&
12710 error "mtime did not change after unlink"
12714 run_test 300b "check ctime/mtime for striped dir"
12717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12718 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12721 mkdir -p $DIR/$tdir
12722 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
12723 error "set striped dir error"
12725 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
12726 error "chown striped dir failed"
12728 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
12729 error "create 5k files failed"
12731 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
12733 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
12737 run_test 300c "chown && check ls under striped directory"
12740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12741 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12745 mkdir -p $DIR/$tdir
12746 $SETSTRIPE -c 2 $DIR/$tdir
12748 #local striped directory
12749 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12750 error "set striped dir error"
12751 createmany -o $DIR/$tdir/striped_dir/f 10 ||
12752 error "create 10 files failed"
12754 #remote striped directory
12755 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
12756 error "set striped dir error"
12757 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
12758 error "create 10 files failed"
12760 for file in $(find $DIR/$tdir); do
12761 stripe_count=$($GETSTRIPE -c $file)
12762 [ $stripe_count -eq 2 ] ||
12763 error "wrong stripe $stripe_count for $file"
12768 run_test 300d "check default stripe under striped directory"
12771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12772 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12776 mkdir -p $DIR/$tdir
12778 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12779 error "set striped dir error"
12781 touch $DIR/$tdir/striped_dir/a
12782 touch $DIR/$tdir/striped_dir/b
12783 touch $DIR/$tdir/striped_dir/c
12785 mkdir $DIR/$tdir/striped_dir/dir_a
12786 mkdir $DIR/$tdir/striped_dir/dir_b
12787 mkdir $DIR/$tdir/striped_dir/dir_c
12789 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
12790 error "set striped dir under striped dir error"
12792 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
12793 error "set striped dir under striped dir error"
12795 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
12796 error "set striped dir under striped dir error"
12798 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
12799 error "rename file under striped dir should fail"
12801 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
12802 error "rename dir under striped dir should fail"
12804 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
12805 error "rename dir under different stripes should fail"
12807 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
12808 error "rename file under striped dir should succeed"
12810 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
12811 error "rename dir under striped dir should succeed"
12815 run_test 300e "check rename under striped directory"
12818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12819 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12824 mkdir -p $DIR/$tdir
12826 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12827 error "set striped dir error"
12829 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
12830 error "set striped dir error"
12832 touch $DIR/$tdir/striped_dir/a
12833 mkdir $DIR/$tdir/striped_dir/dir_a
12834 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
12835 error "create striped dir under striped dir fails"
12837 touch $DIR/$tdir/striped_dir1/b
12838 mkdir $DIR/$tdir/striped_dir1/dir_b
12839 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
12840 error "create striped dir under striped dir fails"
12842 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
12843 error "rename file under different striped dir should fail"
12845 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
12846 error "rename dir under different striped dir should fail"
12848 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
12849 error "rename striped dir under diff striped dir should fail"
12851 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
12852 error "rename file under diff striped dirs fails"
12854 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
12855 error "rename dir under diff striped dirs fails"
12859 run_test 300f "check rename cross striped directory"
12862 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12867 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
12868 $DIR/$tdir/striped_dir ||
12869 error "set striped dir error"
12871 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12872 error "set default stripe on striped dir error"
12874 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
12875 [ $stripe_count -eq $MDSCOUNT ] ||
12876 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
12878 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12880 for dir in $(find $DIR/$tdir/striped_dir/*); do
12881 stripe_count=$($LFS getdirstripe -c $dir)
12882 [ $stripe_count -eq $MDSCOUNT ] ||
12883 error "expect $MDSCOUNT get $stripe_count for $dir"
12886 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
12887 #change default stripe count to 2
12888 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
12889 error "set default stripe on striped dir error"
12891 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
12893 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
12895 #change default stripe count to 1
12896 $LFS setdirstripe -D -c 1 -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}
12900 for dir in $(find $DIR/$tdir/striped_dir/*); do
12901 stripe_count=$($LFS getdirstripe -c $dir)
12902 [ $stripe_count -eq 1 ] ||
12903 error "expect 1 get $stripe_count for $dir"
12905 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
12907 run_test 300g "check default striped directory for striped directory"
12910 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12911 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12917 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
12918 error "set striped dir error"
12920 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
12921 error "create files under striped dir failed"
12923 # unfortunately, we need to umount to clear dir layout cache for now
12924 # once we fully implement dir layout, we can drop this
12925 umount_client $MOUNT || error "umount failed"
12926 mount_client $MOUNT || error "mount failed"
12928 #set the stripe to be unknown hash type
12929 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
12930 $LCTL set_param fail_loc=0x1901
12931 for ((i = 0; i < 10; i++)); do
12932 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
12933 error "stat f-$i failed"
12934 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
12937 touch $DIR/$tdir/striped_dir/f0 &&
12938 error "create under striped dir with unknown hash should fail"
12940 $LCTL set_param fail_loc=0
12942 umount_client $MOUNT || error "umount failed"
12943 mount_client $MOUNT || error "mount failed"
12947 run_test 300h "client handle unknown hash type striped directory"
12949 test_400a() { # LU-1606, was conf-sanity test_74
12950 local extra_flags=''
12951 local out=$TMP/$tfile
12952 local prefix=/usr/include/lustre
12955 if ! which $CC > /dev/null 2>&1; then
12956 skip_env "$CC is not installed"
12960 if ! [[ -d $prefix ]]; then
12961 # Assume we're running in tree and fixup the include path.
12962 extra_flags+=" -I$LUSTRE/../libcfs/include"
12963 extra_flags+=" -I$LUSTRE/include"
12964 extra_flags+=" -L$LUSTRE/utils"
12967 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
12968 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
12969 error "client api broken"
12972 run_test 400a "Lustre client api program can compile and link"
12974 test_400b() { # LU-1606, LU-5011
12976 local out=$TMP/$tfile
12977 local prefix=/usr/include/lustre
12979 # We use a hard coded prefix so that this test will not fail
12980 # when run in tree. There are headers in lustre/include/lustre/
12981 # that are not packaged (like lustre_idl.h) and have more
12982 # complicated include dependencies (like config.h and lnet/types.h).
12983 # Since this test about correct packaging we just skip them when
12984 # they don't exist (see below) rather than try to fixup cppflags.
12986 if ! which $CC > /dev/null 2>&1; then
12987 skip_env "$CC is not installed"
12991 for header in $prefix/*.h; do
12992 if ! [[ -f "$header" ]]; then
12996 if [[ "$(basename $header)" == liblustreapi.h ]]; then
12997 continue # liblustreapi.h is deprecated.
13000 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13001 error "cannot compile '$header'"
13004 run_test 400b "packaged headers can be compiled"
13007 # tests that do cleanup/setup should be run at the end
13011 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13013 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13014 $LCTL set_param fail_loc=0x903
13016 cancel_lru_locks MGC
13018 FAIL_ON_ERROR=true cleanup
13019 FAIL_ON_ERROR=true setup
13021 run_test 900 "umount should not race with any mgc requeue thread"
13024 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13025 check_and_cleanup_lustre
13026 if [ "$I_MOUNTED" != "yes" ]; then
13027 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true