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 24D 27m 64b 68 71 77f 78 115 124b 230d"
63 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
64 # bug number for skipped test: LU-1593 LU-4536 LU-5242 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 65ic 78 79 80 180 184c"
66 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b 51ba"
73 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
74 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
83 check_kernel_version() {
85 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
87 patchless|patchless_client) return 0;;
88 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
90 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
94 check_swap_layouts_support()
96 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
97 { skip "Does not support layout lock."; return 0; }
101 if [ "$ONLY" == "cleanup" ]; then
106 check_and_setup_lustre
111 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
112 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
113 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
114 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
115 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
116 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
117 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
118 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
120 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
121 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
122 rm -rf $DIR/[Rdfs][0-9]*
124 # $RUNAS_ID may get set incorrectly somewhere else
125 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
127 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
131 if [ "${ONLY}" = "MOUNT" ] ; then
132 echo "Lustre is up, please go on"
136 echo "preparing for tests involving mounts"
137 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
139 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
140 echo # add a newline after mke2fs.
144 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
145 lctl set_param debug=-1 2> /dev/null || true
148 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
150 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
152 run_test 0a "touch; rm ====================="
155 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
156 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
158 run_test 0b "chmod 0755 $DIR ============================="
161 $LCTL get_param mdc.*.import | grep "state: FULL" ||
162 error "import not FULL"
163 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
166 run_test 0c "check import proc ============================="
169 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
170 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
171 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
172 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
175 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
177 run_test 1 "mkdir; remkdir; rmdir =============================="
180 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
181 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
182 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
184 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
186 run_test 2 "mkdir; touch; rmdir; check file ===================="
189 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
190 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
191 touch $DIR/$tdir/$tfile
192 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
194 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
196 run_test 3 "mkdir; touch; rmdir; check dir ====================="
198 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
202 test_mkdir $DIR/$tdir ||
203 error "Create remote directory failed"
205 touch $DIR/$tdir/$tfile ||
206 error "Create file under remote directory failed"
209 error "Expect error removing in-use dir $DIR/$tdir"
211 test -d $DIR/$tdir || error "Remote directory disappeared"
213 rm -rf $DIR/$tdir || error "remove remote dir error"
215 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
218 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
219 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
220 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
221 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
222 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
224 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
227 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
228 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
229 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
230 error "$tfile does not have perm 0666 or UID $UID"
231 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
232 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
233 error "$tfile should be 0666 and owned by UID $UID"
235 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
238 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
240 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
241 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
242 error "$tfile should be owned by UID $RUNAS_ID"
243 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
244 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
245 error "$tfile should be owned by UID $RUNAS_ID"
247 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
250 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
252 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
253 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
254 error "$tfile should be owned by GID $UID"
255 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
256 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
257 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
259 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
262 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
263 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
264 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
265 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
266 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
267 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
268 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
269 error "$tdir/d/subdir should be GID $RUNAS_GID"
271 run_test 6g "Is new dir in sgid dir inheriting group?"
273 test_6h() { # bug 7331
274 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
275 touch $DIR/$tfile || error "touch failed"
276 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
277 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
278 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
279 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
280 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
282 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
285 test_mkdir $DIR/$tdir
286 $MCREATE $DIR/$tdir/$tfile
287 chmod 0666 $DIR/$tdir/$tfile
288 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
289 error "$tdir/$tfile should be mode 0666"
291 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
294 if [ ! -d $DIR/$tdir ]; then
297 $MCREATE $DIR/$tdir/$tfile
298 echo -n foo > $DIR/$tdir/$tfile
299 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
300 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
302 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
305 test_mkdir $DIR/$tdir
306 touch $DIR/$tdir/$tfile
307 chmod 0666 $DIR/$tdir/$tfile
308 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
309 error "$tfile mode not 0666"
311 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
314 test_mkdir $DIR/$tdir
315 test_mkdir $DIR/$tdir/d2
316 test_mkdir $DIR/$tdir/d2/d3
317 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
319 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
322 test_mkdir $DIR/$tdir
323 test_mkdir $DIR/$tdir/d2
324 touch $DIR/$tdir/d2/$tfile
325 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
326 error "$tdir/d2/$tfile not a file"
328 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
331 test_mkdir $DIR/$tdir
332 test_mkdir $DIR/$tdir/d2
333 chmod 0666 $DIR/$tdir/d2
334 chmod 0705 $DIR/$tdir/d2
335 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
336 error "$tdir/d2 mode not 0705"
338 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
341 test_mkdir $DIR/$tdir
342 touch $DIR/$tdir/$tfile
343 chmod 0666 $DIR/$tdir/$tfile
344 chmod 0654 $DIR/$tdir/$tfile
345 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
346 error "$tdir/d2 mode not 0654"
348 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
351 test_mkdir $DIR/$tdir
352 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
354 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
355 error "$tdir/$tfile size not 0 after truncate"
357 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
360 test_mkdir $DIR/$tdir
361 touch $DIR/$tdir/$tfile
363 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
365 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
368 test_mkdir $DIR/$tdir
369 touch $DIR/$tdir/$tfile
370 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
371 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
372 error "$tdir/${tfile_2} not a file after rename"
374 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
377 test_mkdir $DIR/$tdir
378 touch $DIR/$tdir/$tfile
379 rm -rf $DIR/$tdir/$tfile
380 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
382 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
385 test_mkdir -p $DIR/$tdir
386 touch $DIR/$tdir/$tfile
387 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
389 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
390 error "$tdir/l-exist not a symlink"
391 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
392 error "$tdir/l-exist not referencing a file"
393 rm -f $DIR/$tdir/l-exist
394 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
396 run_test 17a "symlinks: create, remove (real) =================="
399 test_mkdir -p $DIR/$tdir
400 ln -s no-such-file $DIR/$tdir/l-dangle
402 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
403 error "$tdir/l-dangle not referencing no-such-file"
404 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
405 error "$tdir/l-dangle not referencing non-existent file"
406 rm -f $DIR/$tdir/l-dangle
407 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
409 run_test 17b "symlinks: create, remove (dangling) =============="
411 test_17c() { # bug 3440 - don't save failed open RPC for replay
412 test_mkdir -p $DIR/$tdir
413 ln -s foo $DIR/$tdir/$tfile
414 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
416 run_test 17c "symlinks: open dangling (should return error) ===="
419 test_mkdir -p $DIR/$tdir
420 ln -s foo $DIR/$tdir/$tfile
421 touch $DIR/$tdir/$tfile || error "creating to new symlink"
423 run_test 17d "symlinks: create dangling ========================"
426 test_mkdir -p $DIR/$tdir
427 local foo=$DIR/$tdir/$tfile
428 ln -s $foo $foo || error "create symlink failed"
429 ls -l $foo || error "ls -l failed"
430 ls $foo && error "ls not failed" || true
432 run_test 17e "symlinks: create recursive symlink (should return error) ===="
435 test_mkdir -p $DIR/$tdir
436 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
437 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
438 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
439 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
440 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
441 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
444 run_test 17f "symlinks: long and very long symlink name ========================"
446 # str_repeat(S, N) generate a string that is string S repeated N times
451 while [ $((n -= 1)) -ge 0 ]; do
457 # Long symlinks and LU-2241
459 test_mkdir -p $DIR/$tdir
460 local TESTS="59 60 61 4094 4095"
462 # Fix for inode size boundary in 2.1.4
463 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
466 # Patch not applied to 2.2 or 2.3 branches
467 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
468 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
471 # skip long symlink name for rhel6.5.
472 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
473 grep -q '6.5' /etc/redhat-release &>/dev/null &&
474 TESTS="59 60 61 4062 4063"
477 local SYMNAME=$(str_repeat 'x' $i)
478 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
479 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
482 run_test 17g "symlinks: really long symlink name and inode boundaries"
484 test_17h() { #bug 17378
485 remote_mds_nodsh && skip "remote MDS with nodsh" && return
486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
488 test_mkdir -p $DIR/$tdir
489 if [[ $MDSCOUNT -gt 1 ]]; then
490 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
494 $SETSTRIPE -c -1 $DIR/$tdir
495 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
496 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
497 touch $DIR/$tdir/$tfile || true
499 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
501 test_17i() { #bug 20018
502 remote_mds_nodsh && skip "remote MDS with nodsh" && return
503 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
504 test_mkdir -c1 $DIR/$tdir
505 local foo=$DIR/$tdir/$tfile
507 if [[ $MDSCOUNT -gt 1 ]]; then
508 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
512 ln -s $foo $foo || error "create symlink failed"
513 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
514 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
515 ls -l $foo && error "error not detected"
518 run_test 17i "don't panic on short symlink"
520 test_17k() { #bug 22301
521 [[ -z "$(which rsync 2>/dev/null)" ]] &&
522 skip "no rsync command" && return 0
523 rsync --help | grep -q xattr ||
524 skip_env "$(rsync --version | head -n1) does not support xattrs"
525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
526 test_mkdir -p $DIR/$tdir
527 test_mkdir -p $DIR/$tdir.new
528 touch $DIR/$tdir/$tfile
529 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
530 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
531 error "rsync failed with xattrs enabled"
533 run_test 17k "symlinks: rsync with xattrs enabled ========================="
535 test_17l() { # LU-279
536 [[ -z "$(which getfattr 2>/dev/null)" ]] &&
537 skip "no getfattr command" && return 0
539 touch $DIR/$tdir/$tfile
540 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
541 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
542 # -h to not follow symlinks. -m '' to list all the xattrs.
543 # grep to remove first line: '# file: $path'.
544 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
546 lgetxattr_size_check $path $xattr ||
547 error "lgetxattr_size_check $path $xattr failed"
551 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
555 local short_sym="0123456789"
556 local WDIR=$DIR/${tdir}m
563 remote_mds_nodsh && skip "remote MDS with nodsh" && return
564 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
565 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
566 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
568 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
569 skip "only for ldiskfs MDT" && return 0
571 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
575 # create a long symlink file
576 for ((i = 0; i < 4; ++i)); do
577 long_sym=${long_sym}${long_sym}
580 echo "create 512 short and long symlink files under $WDIR"
581 for ((i = 0; i < 256; ++i)); do
582 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
583 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
589 wait_delete_completed
591 echo "recreate the 512 symlink files with a shorter string"
592 for ((i = 0; i < 512; ++i)); do
593 # rewrite the symlink file with a shorter string
594 ln -sf ${long_sym} $WDIR/long-$i
595 ln -sf ${short_sym} $WDIR/short-$i
598 mds_index=$($LFS getstripe -M $WDIR)
599 mds_index=$((mds_index+1))
600 devname=$(mdsdevname $mds_index)
601 cmd="$E2FSCK -fnvd $devname"
603 echo "stop and checking mds${mds_index}: $cmd"
604 # e2fsck should not return error
606 do_facet mds${mds_index} $cmd || rc=$?
608 start mds${mds_index} $devname $MDS_MOUNT_OPTS || error "start failed"
609 df $MOUNT > /dev/null 2>&1
610 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
611 "short/long symlink MDT: rc=$rc"
614 run_test 17m "run e2fsck against MDT which contains short/long symlink"
616 check_fs_consistency_17n() {
622 # create/unlink in 17n only change 2 MDTs(MDT1/MDT2),
623 # so it only check MDT1/MDT2 instead of all of MDTs.
624 for mdt_index in $(seq 1 2); do
625 devname=$(mdsdevname $mdt_index)
626 cmd="$E2FSCK -fnvd $devname"
628 echo "stop and checking mds${mdt_index}: $cmd"
629 # e2fsck should not return error
631 do_facet mds${mdt_index} $cmd || rc=$?
633 start mds${mdt_index} $devname $MDS_MOUNT_OPTS ||
634 error "mount mds${mdt_index} failed"
635 df $MOUNT > /dev/null 2>&1
636 [ $rc -ne 0 ] && break
644 remote_mds_nodsh && skip "remote MDS with nodsh" && return
645 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
646 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
647 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
649 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
650 skip "only for ldiskfs MDT" && return 0
652 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
657 for ((i=0; i<10; i++)); do
658 $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
659 error "create remote dir error $i"
660 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
661 error "create files under remote dir failed $i"
664 check_fs_consistency_17n ||
665 error "e2fsck report error after create files under remote dir"
667 for ((i = 0; i < 10; i++)); do
668 rm -rf $DIR/$tdir/remote_dir_${i} ||
669 error "destroy remote dir error $i"
672 check_fs_consistency_17n ||
673 error "e2fsck report error after unlink files under remote dir"
675 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
676 skip "lustre < 2.4.50 does not support migrate mv " && return
678 for ((i = 0; i < 10; i++)); do
679 mkdir -p $DIR/$tdir/remote_dir_${i}
680 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
681 error "create files under remote dir failed $i"
682 $LFS mv --mdt-index 1 $DIR/$tdir/remote_dir_${i} ||
683 error "migrate remote dir error $i"
685 check_fs_consistency_17n || error "e2fsck report error after migration"
687 for ((i = 0; i < 10; i++)); do
688 rm -rf $DIR/$tdir/remote_dir_${i} ||
689 error "destroy remote dir error $i"
692 check_fs_consistency_17n || error "e2fsck report error after unlink"
694 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
697 remote_mds_nodsh && skip "remote MDS with nodsh" && return
698 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
699 skip "Need MDS version at least 2.3.64" && return
701 local WDIR=$DIR/${tdir}o
707 mdt_index=$($LFS getstripe -M $WDIR)
708 mdt_index=$((mdt_index+1))
709 mdtdevname=$(mdsdevname $mdt_index)
713 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS ||
714 error "mount mds${mdt_index} failed"
716 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
717 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
718 ls -l $WDIR/$tfile && rc=1
719 do_facet mds${mdt_index} lctl set_param fail_loc=0
720 [[ $rc -ne 0 ]] && error "stat file should fail"
723 run_test 17o "stat file with incompat LMA feature"
726 touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
727 ls $DIR || error "Failed to ls $DIR: $?"
729 run_test 18 "touch .../f ; ls ... =============================="
735 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
737 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
740 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
742 run_test 19b "ls -l .../f19 (should return error) =============="
745 [ $RUNAS_ID -eq $UID ] &&
746 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
747 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
749 run_test 19c "$RUNAS touch .../f19 (should return error) =="
752 cat $DIR/f19 && error || true
754 run_test 19d "cat .../f19 (should return error) =============="
766 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
768 run_test 20 "touch .../f ; ls -l ... ==========================="
771 test_mkdir -p $DIR/$tdir
772 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
773 ln -s dangle $DIR/$tdir/link
774 echo foo >> $DIR/$tdir/link
775 cat $DIR/$tdir/dangle
776 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
777 $CHECKSTAT -f -t file $DIR/$tdir/link ||
778 error "$tdir/link not linked to a file"
780 run_test 21 "write to dangling link ============================"
784 test_mkdir -p $DIR/$tdir
785 chown $RUNAS_ID:$RUNAS_GID $WDIR
786 (cd $WDIR || error "cd $WDIR failed";
787 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
789 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
790 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
791 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
793 run_test 22 "unpack tar archive as non-root user ==============="
797 test_mkdir -p $DIR/$tdir
798 local file=$DIR/$tdir/$tfile
800 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
801 openfile -f O_CREAT:O_EXCL $file &&
802 error "$file recreate succeeded" || true
804 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
806 test_23b() { # bug 18988
807 test_mkdir -p $DIR/$tdir
808 local file=$DIR/$tdir/$tfile
811 echo foo > $file || error "write filed"
812 echo bar >> $file || error "append filed"
813 $CHECKSTAT -s 8 $file || error "wrong size"
816 run_test 23b "O_APPEND check =========================="
820 echo '-- same directory rename'
821 test_mkdir $DIR/$tdir
822 touch $DIR/$tdir/$tfile.1
823 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
824 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
826 run_test 24a "rename file to non-existent target"
829 test_mkdir $DIR/$tdir
830 touch $DIR/$tdir/$tfile.{1,2}
831 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
832 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
833 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
835 run_test 24b "rename file to existing target"
838 test_mkdir $DIR/$tdir
839 test_mkdir $DIR/$tdir/d$testnum.1
840 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
841 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
842 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
844 run_test 24c "rename directory to non-existent target"
847 test_mkdir -c1 $DIR/$tdir
848 test_mkdir -c1 $DIR/$tdir/d$testnum.1
849 test_mkdir -c1 $DIR/$tdir/d$testnum.2
850 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
851 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
852 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
854 run_test 24d "rename directory to existing target"
857 echo '-- cross directory renames --'
861 mv $DIR/R5a/f $DIR/R5b/g
862 $CHECKSTAT -a $DIR/R5a/f || error
863 $CHECKSTAT -t file $DIR/R5b/g || error
865 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
870 touch $DIR/R6a/f $DIR/R6b/g
871 mv $DIR/R6a/f $DIR/R6b/g
872 $CHECKSTAT -a $DIR/R6a/f || error
873 $CHECKSTAT -t file $DIR/R6b/g || error
875 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
880 test_mkdir $DIR/R7a/d
881 mv $DIR/R7a/d $DIR/R7b/e
882 $CHECKSTAT -a $DIR/R7a/d || error
883 $CHECKSTAT -t dir $DIR/R7b/e || error
885 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
888 test_mkdir -c1 $DIR/R8a
889 test_mkdir -c1 $DIR/R8b
890 test_mkdir -c1 $DIR/R8a/d
891 test_mkdir -c1 $DIR/R8b/e
892 mrename $DIR/R8a/d $DIR/R8b/e
893 $CHECKSTAT -a $DIR/R8a/d || error
894 $CHECKSTAT -t dir $DIR/R8b/e || error
896 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
899 echo "-- rename error cases"
903 mrename $DIR/R9/f $DIR/R9/a
904 $CHECKSTAT -t file $DIR/R9/f || error
905 $CHECKSTAT -t dir $DIR/R9/a || error
906 $CHECKSTAT -a $DIR/R9/a/f || error
908 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
912 mrename $DIR/R10/f $DIR/R10/g
913 $CHECKSTAT -t dir $DIR/R10 || error
914 $CHECKSTAT -a $DIR/R10/f || error
915 $CHECKSTAT -a $DIR/R10/g || error
917 run_test 24j "source does not exist ============================"
921 test_mkdir $DIR/R11a/d
923 mv $DIR/R11a/f $DIR/R11a/d
924 $CHECKSTAT -a $DIR/R11a/f || error
925 $CHECKSTAT -t file $DIR/R11a/d/f || error
927 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
929 # bug 2429 - rename foo foo foo creates invalid file
932 $MULTIOP $f OcNs || error
934 run_test 24l "Renaming a file to itself ========================"
938 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
939 # on ext3 this does not remove either the source or target files
940 # though the "expected" operation would be to remove the source
941 $CHECKSTAT -t file ${f} || error "${f} missing"
942 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
944 run_test 24m "Renaming a file to a hard link to itself ========="
948 # this stats the old file after it was renamed, so it should fail
952 $CHECKSTAT ${f}.rename
955 run_test 24n "Statting the old file after renaming (Posix rename 2)"
958 check_kernel_version 37 || return 0
959 test_mkdir -p $DIR/d24o
960 rename_many -s random -v -n 10 $DIR/d24o
962 run_test 24o "rename of files during htree split ==============="
967 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
968 mrename $DIR/R12a $DIR/R12b
969 $CHECKSTAT -a $DIR/R12a || error
970 $CHECKSTAT -t dir $DIR/R12b || error
971 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
972 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
974 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
976 cleanup_multiop_pause() {
982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
985 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
986 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
989 trap cleanup_multiop_pause EXIT
990 mrename $DIR/R13a $DIR/R13b
991 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
992 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
993 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
994 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
995 cleanup_multiop_pause
996 wait $MULTIPID || error "multiop close failed"
998 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
1000 test_24r() { #bug 3789
1001 test_mkdir $DIR/R14a
1002 test_mkdir $DIR/R14a/b
1003 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
1004 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
1005 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
1007 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
1010 test_mkdir $DIR/R15a
1011 test_mkdir $DIR/R15a/b
1012 test_mkdir $DIR/R15a/b/c
1013 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
1014 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
1015 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
1017 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
1019 test_mkdir $DIR/R16a
1020 test_mkdir $DIR/R16a/b
1021 test_mkdir $DIR/R16a/b/c
1022 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
1023 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
1024 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1026 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1028 test_24u() { # bug12192
1029 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1030 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1032 run_test 24u "create stripe file"
1038 simple_cleanup_common() {
1041 wait_delete_completed
1044 max_pages_per_rpc() {
1045 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -n1
1049 local NRFILES=100000
1050 local FREE_INODES=$(mdt_free_inodes 0)
1051 [[ $FREE_INODES -lt $NRFILES ]] &&
1052 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1055 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1056 trap simple_cleanup_common EXIT
1058 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1059 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1062 createmany -m $DIR/$tdir/$tfile $NRFILES
1064 cancel_lru_locks mdc
1065 lctl set_param mdc.*.stats clear
1067 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1069 # LU-5 large readdir
1070 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1071 # 8 bytes for name(filename is mostly 5 in this test) +
1072 # 8 bytes for luda_type
1073 # take into account of overhead in lu_dirpage header and end mark in
1074 # each page, plus one in RPC_NUM calculation.
1076 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1077 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1078 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats |
1079 awk '/^mds_readpage/ {print $2}')
1080 [[ $mds_readpage -gt $RPC_NUM ]] &&
1081 error "large readdir doesn't take effect"
1083 simple_cleanup_common
1085 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1087 test_24w() { # bug21506
1089 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1090 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1091 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1092 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1093 [[ "$SZ1" -eq "$SZ2" ]] ||
1094 error "Error reading at the end of the file $tfile"
1096 run_test 24w "Reading a file larger than 4Gb"
1099 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 mkdir -p $DIR/$tdir/src_dir
1109 touch $DIR/$tdir/src_file
1110 mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $remote_dir $DIR/ &&
1114 error "rename dir cross MDT works!"
1116 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1117 error "rename dir cross MDT works!"
1119 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1120 error "rename file cross MDT works!"
1122 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1123 error "ln file cross MDT should not work!"
1125 rm -rf $DIR/$tdir || error "Can not delete directories"
1127 run_test 24x "cross rename/link should be failed"
1130 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1131 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1133 local remote_dir=$DIR/$tdir/remote_dir
1136 $LFS mkdir -i $MDTIDX $remote_dir ||
1137 error "create remote directory failed"
1139 mkdir -p $remote_dir/src_dir
1140 touch $remote_dir/src_file
1141 mkdir -p $remote_dir/tgt_dir
1142 touch $remote_dir/tgt_file
1144 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1145 error "rename subdir in the same remote dir failed!"
1147 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1148 error "rename files in the same remote dir failed!"
1150 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1151 error "link files in the same remote dir failed!"
1153 rm -rf $DIR/$tdir || error "Can not delete directories"
1155 run_test 24y "rename/link on the same dir should succeed"
1158 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
1159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1161 local remote_src=$DIR/$tdir/remote_dir
1162 local remote_tgt=$DIR/$tdir/remote_tgt
1165 $LFS mkdir -i $MDTIDX $remote_src ||
1166 error "create remote directory failed"
1168 $LFS mkdir -i $MDTIDX $remote_tgt ||
1169 error "create remote directory failed"
1171 mrename $remote_src $remote_tgt &&
1172 error "rename remote dirs should not work!"
1174 # If target dir does not exists, it should succeed
1176 mrename $remote_src $remote_tgt ||
1177 error "rename remote dirs(tgt dir does not exists) failed!"
1179 rm -rf $DIR/$tdir || error "Can not delete directories"
1181 run_test 24z "rename one remote dir to another remote dir should fail"
1183 test_24A() { # LU-3182
1188 createmany -m $DIR/$tdir/$tfile $NFILES
1189 local t=$(ls $DIR/$tdir | wc -l)
1190 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1191 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1192 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1193 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1196 rm -rf $DIR/$tdir || error "Can not delete directories"
1198 run_test 24A "readdir() returns correct number of entries."
1200 test_24B() { # LU-4805
1201 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1205 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
1206 error "create striped dir failed"
1208 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1209 [ $count -eq 2 ] || error "Expected 2, got $count"
1211 touch $DIR/$tdir/striped_dir/a
1213 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1214 [ $count -eq 3 ] || error "Expected 3, got $count"
1216 touch $DIR/$tdir/striped_dir/.f
1218 count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
1219 [ $count -eq 4 ] || error "Expected 4, got $count"
1221 rm -rf $DIR/$tdir || error "Can not delete directories"
1223 run_test 24B "readdir for striped dir return correct number of entries"
1226 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1232 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
1233 error "create striped dir failed"
1235 cd $DIR/$tdir/d0/striped_dir
1237 local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
1238 local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
1239 local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1241 [ "$d0_ino" = "$parent_ino" ] ||
1242 error ".. wrong, expect $d0_ino, get $parent_ino"
1244 mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
1245 error "mv striped dir failed"
1247 parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
1249 [ "$d1_ino" = "$parent_ino" ] ||
1250 error ".. wrong after mv, expect $d1_ino, get $parent_ino"
1252 run_test 24C "check .. in striped dir"
1254 test_24D() { # LU-6101
1259 createmany -m $DIR/$tdir/$tfile $NFILES
1260 local t=$(ls $DIR/$tdir | wc -l)
1261 local u=$(ls $DIR/$tdir | sort -u | wc -l)
1262 local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
1263 if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
1264 error "Expected $NFILES files, got $t ($u unique $v .&..)"
1267 rm -rf $DIR/$tdir || error "Can not delete directories"
1269 run_test 24D "readdir() returns correct number of entries after cursor reload"
1272 echo '== symlink sanity ============================================='
1276 touch $DIR/s25/foo || error
1278 run_test 25a "create file in symlinked directory ==============="
1281 [ ! -d $DIR/d25 ] && test_25a
1282 $CHECKSTAT -t file $DIR/s25/foo || error
1284 run_test 25b "lookup file in symlinked directory ==============="
1288 test_mkdir $DIR/d26/d26-2
1289 ln -s d26/d26-2 $DIR/s26
1290 touch $DIR/s26/foo || error
1292 run_test 26a "multiple component symlink ======================="
1295 test_mkdir -p $DIR/d26b/d26-2
1296 ln -s d26b/d26-2/foo $DIR/s26-2
1297 touch $DIR/s26-2 || error
1299 run_test 26b "multiple component symlink at end of lookup ======"
1302 test_mkdir $DIR/d26.2
1303 touch $DIR/d26.2/foo
1304 ln -s d26.2 $DIR/s26.2-1
1305 ln -s s26.2-1 $DIR/s26.2-2
1306 ln -s s26.2-2 $DIR/s26.2-3
1307 chmod 0666 $DIR/s26.2-3/foo
1309 run_test 26c "chain of symlinks ================================"
1311 # recursive symlinks (bug 439)
1313 ln -s d26-3/foo $DIR/d26-3
1315 run_test 26d "create multiple component recursive symlink ======"
1318 [ ! -h $DIR/d26-3 ] && test_26d
1321 run_test 26e "unlink multiple component recursive symlink ======"
1323 # recursive symlinks (bug 7022)
1325 test_mkdir -p $DIR/$tdir
1326 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1327 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1328 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1329 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1330 cd $tfile || error "cd $tfile failed"
1331 ln -s .. dotdot || error "ln dotdot failed"
1332 ln -s dotdot/lndir lndir || error "ln lndir failed"
1333 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1334 output=`ls $tfile/$tfile/lndir/bar1`
1335 [ "$output" = bar1 ] && error "unexpected output"
1336 rm -r $tfile || error "rm $tfile failed"
1337 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1339 run_test 26f "rm -r of a directory which has recursive symlink ="
1342 echo '== stripe sanity =============================================='
1343 test_mkdir -p $DIR/d27 || error "mkdir failed"
1345 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1346 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1347 log "== test_27a: write to one stripe file ========================="
1348 cp /etc/hosts $DIR/d27/f0 || error
1350 run_test 27a "one stripe file =================================="
1353 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
1354 test_mkdir -p $DIR/d27
1355 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1356 $GETSTRIPE -c $DIR/d27/f01
1357 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1358 error "two-stripe file doesn't have two stripes"
1360 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1362 run_test 27b "create and write to two stripe file"
1365 test_mkdir -p $DIR/d27
1366 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1367 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1368 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1370 run_test 27d "create file with default settings ================"
1373 test_mkdir -p $DIR/d27
1374 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1375 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1376 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1378 run_test 27e "setstripe existing file (should return error) ======"
1381 test_mkdir $DIR/$tdir
1382 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/$tdir/$tfile &&
1383 error "$SETSTRIPE $DIR/$tdir/$tfile failed"
1384 $CHECKSTAT -t file $DIR/$tdir/$tfile &&
1385 error "$CHECKSTAT -t file $DIR/$tdir/$tfile should fail"
1386 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
1387 $GETSTRIPE $DIR/$tdir/$tfile || error "$GETSTRIPE failed"
1389 run_test 27f "setstripe with bad stripe size (should return error)"
1392 test_mkdir -p $DIR/d27
1393 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1394 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1395 error "$DIR/d27/fnone has object"
1397 run_test 27g "$GETSTRIPE with no objects"
1400 touch $DIR/d27/fsome || error "touch failed"
1401 [[ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ]] || error "missing objects"
1403 run_test 27i "$GETSTRIPE with some objects"
1406 test_mkdir -p $DIR/d27
1407 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1409 run_test 27j "setstripe with bad stripe offset (should return error)"
1411 test_27k() { # bug 2844
1412 test_mkdir -p $DIR/d27
1414 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1415 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1416 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1417 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1418 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1419 dd if=/dev/zero of=$FILE bs=4k count=1
1420 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1421 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1423 run_test 27k "limit i_blksize for broken user apps ============="
1426 test_mkdir -p $DIR/d27
1427 mcreate $DIR/f27l || error "creating file"
1428 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1429 error "setstripe should have failed" || true
1431 run_test 27l "check setstripe permissions (should return error)"
1434 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1436 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1437 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1440 trap simple_cleanup_common EXIT
1441 test_mkdir -p $DIR/$tdir
1442 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1443 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1444 error "dd should fill OST0"
1446 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1448 [ $i -gt 256 ] && break
1451 touch $DIR/$tdir/f27m_$i
1452 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1453 error "OST0 was full but new created file still use it"
1455 touch $DIR/$tdir/f27m_$i
1456 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1457 error "OST0 was full but new created file still use it"
1458 simple_cleanup_common
1460 run_test 27m "create file while OST0 was full =================="
1463 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1467 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1468 # if the OST isn't full anymore.
1470 local OSTIDX=${1:-""}
1472 local list=$(comma_list $(osts_nodes))
1473 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1475 do_nodes $list lctl set_param fail_loc=0
1476 sync # initiate all OST_DESTROYs from MDS to OST
1480 exhaust_precreations() {
1483 local FAILIDX=${3:-$OSTIDX}
1484 local ofacet=ost$((OSTIDX + 1))
1486 test_mkdir -p -c1 $DIR/$tdir
1487 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1488 local mfacet=mds$((mdtidx + 1))
1489 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1491 local OST=$(ostname_from_index $OSTIDX)
1494 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1495 local last_id=$(do_facet $mfacet lctl get_param -n \
1496 osc.$mdtosc_proc1.prealloc_last_id)
1497 local next_id=$(do_facet $mfacet lctl get_param -n \
1498 osc.$mdtosc_proc1.prealloc_next_id)
1500 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1501 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1503 test_mkdir -p $DIR/$tdir/${OST}
1504 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1505 #define OBD_FAIL_OST_ENOSPC 0x215
1506 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1507 echo "Creating to objid $last_id on ost $OST..."
1508 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1509 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1510 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1514 exhaust_all_precreations() {
1516 for (( i=0; i < OSTCOUNT; i++ )) ; do
1517 exhaust_precreations $i $1 -1
1522 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1525 remote_ost_nodsh && skip "remote OST with nodsh" && return
1528 rm -f $DIR/$tdir/$tfile
1529 exhaust_precreations 0 0x80000215
1530 $SETSTRIPE -c -1 $DIR/$tdir
1531 touch $DIR/$tdir/$tfile || error
1532 $GETSTRIPE $DIR/$tdir/$tfile
1535 run_test 27n "create file with some full OSTs =================="
1538 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1540 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1541 remote_ost_nodsh && skip "remote OST with nodsh" && return
1544 rm -f $DIR/$tdir/$tfile
1545 exhaust_all_precreations 0x215
1547 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1552 run_test 27o "create file with all full OSTs (should error) ===="
1555 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1557 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1558 remote_ost_nodsh && skip "remote OST with nodsh" && return
1561 rm -f $DIR/$tdir/$tfile
1562 test_mkdir -p $DIR/$tdir
1564 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1565 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1566 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1568 exhaust_precreations 0 0x80000215
1569 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1570 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1571 $GETSTRIPE $DIR/$tdir/$tfile
1575 run_test 27p "append to a truncated file with some full OSTs ==="
1578 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1580 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1581 remote_ost_nodsh && skip "remote OST with nodsh" && return
1584 rm -f $DIR/$tdir/$tfile
1586 test_mkdir -p $DIR/$tdir
1587 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1588 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1589 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1591 exhaust_all_precreations 0x215
1593 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1594 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1598 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1601 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1603 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return
1607 rm -f $DIR/$tdir/$tfile
1608 exhaust_precreations 0 0x80000215
1610 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1614 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1616 test_27s() { # bug 10725
1617 test_mkdir -p $DIR/$tdir
1618 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1619 local stripe_count=0
1620 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1621 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1622 error "stripe width >= 2^32 succeeded" || true
1625 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1627 test_27t() { # bug 10864
1632 $WLFS getstripe $tfile
1635 run_test 27t "check that utils parse path correctly"
1637 test_27u() { # bug 4900
1638 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1639 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1641 local list=$(comma_list $(mdts_nodes))
1643 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1644 do_nodes $list $LCTL set_param fail_loc=0x139
1645 test_mkdir -p $DIR/$tdir
1647 createmany -o $DIR/$tdir/t- 1000
1648 do_nodes $list $LCTL set_param fail_loc=0
1650 TLOG=$DIR/$tfile.getstripe
1651 $GETSTRIPE $DIR/$tdir > $TLOG
1652 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1653 unlinkmany $DIR/$tdir/t- 1000
1654 [[ $OBJS -gt 0 ]] &&
1655 error "$OBJS objects created on OST-0. See $TLOG" || pass
1657 run_test 27u "skip object creation on OSC w/o objects =========="
1659 test_27v() { # bug 4900
1660 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1662 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1663 remote_ost_nodsh && skip "remote OST with nodsh" && return
1665 exhaust_all_precreations 0x215
1668 test_mkdir -p $DIR/$tdir
1669 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1671 touch $DIR/$tdir/$tfile
1672 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1674 for (( i=1; i < OSTCOUNT; i++ )); do
1675 do_facet ost$i lctl set_param fail_loc=0x705
1677 local START=`date +%s`
1678 createmany -o $DIR/$tdir/$tfile 32
1680 local FINISH=`date +%s`
1681 local TIMEOUT=`lctl get_param -n timeout`
1682 local PROCESS=$((FINISH - START))
1683 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1684 error "$FINISH - $START >= $TIMEOUT / 2"
1685 sleep $((TIMEOUT / 2 - PROCESS))
1688 run_test 27v "skip object creation on slow OST ================="
1690 test_27w() { # bug 10997
1691 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1692 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1693 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1694 error "stripe size $size != 65536" || true
1695 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1696 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1698 run_test 27w "check $SETSTRIPE -S option"
1701 [[ $OSTCOUNT -lt 2 ]] &&
1702 skip_env "skipping multiple stripe count/offset test" && return
1704 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1705 for i in $(seq 1 $OSTCOUNT); do
1707 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1708 error "setstripe -c $i -i $offset failed"
1709 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1710 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1711 [ $count -ne $i ] && error "stripe count $count != $i" || true
1712 [ $index -ne $offset ] &&
1713 error "stripe offset $index != $offset" || true
1716 run_test 27wa "check $SETSTRIPE -c -i options"
1719 remote_ost_nodsh && skip "remote OST with nodsh" && return
1720 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1721 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1722 OFFSET=$(($OSTCOUNT - 1))
1724 local OST=$(ostname_from_index $OSTIDX)
1726 test_mkdir -p $DIR/$tdir
1727 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1728 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1730 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1731 for i in `seq 0 $OFFSET`; do
1732 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1733 error "OST0 was degraded but new created file still use it"
1735 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1737 run_test 27x "create files while OST0 is degraded"
1740 [[ $OSTCOUNT -lt 2 ]] &&
1741 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1742 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1743 remote_ost_nodsh && skip "remote OST with nodsh" && return
1744 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1746 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1747 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1748 osc.$mdtosc.prealloc_last_id)
1749 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1750 osc.$mdtosc.prealloc_next_id)
1751 local fcount=$((last_id - next_id))
1752 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1753 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1755 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1756 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1757 local OST_DEACTIVE_IDX=-1
1762 for OSC in $MDS_OSCS; do
1763 OST=$(osc_to_ost $OSC)
1764 OSTIDX=$(index_from_ostuuid $OST)
1765 if [ $OST_DEACTIVE_IDX == -1 ]; then
1766 OST_DEACTIVE_IDX=$OSTIDX
1768 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1769 echo $OSC "is Deactivated:"
1770 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1774 OSTIDX=$(index_from_ostuuid $OST)
1776 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1778 for OSC in $MDS_OSCS; do
1779 OST=$(osc_to_ost $OSC)
1780 OSTIDX=$(index_from_ostuuid $OST)
1781 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1782 echo $OST "is degraded:"
1783 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1784 obdfilter.$OST.degraded=1
1789 createmany -o $DIR/$tdir/$tfile $fcount
1791 for OSC in $MDS_OSCS; do
1792 OST=$(osc_to_ost $OSC)
1793 OSTIDX=$(index_from_ostuuid $OST)
1794 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1795 echo $OST "is recovered from degraded:"
1796 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1797 obdfilter.$OST.degraded=0
1799 do_facet $SINGLEMDS lctl --device %$OSC activate
1803 # all osp devices get activated, hence -1 stripe count restored
1806 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1807 # devices get activated.
1809 $SETSTRIPE -c -1 $DIR/$tfile
1810 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1812 [ $stripecnt -ne $OSTCOUNT ] &&
1813 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1816 run_test 27y "create files while OST0 is degraded and the rest inactive"
1822 lmm_count=$($GETSTRIPE -c $1)
1823 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1824 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1826 local old_ifs="$IFS"
1828 fid=($($LFS path2fid $1))
1831 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1832 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1834 # compare lmm_seq and lu_fid->f_seq
1835 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1836 # compare lmm_object_id and lu_fid->oid
1837 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1839 # check the trusted.fid attribute of the OST objects of the file
1840 local have_obdidx=false
1842 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1843 # skip lines up to and including "obdidx"
1844 [ -z "$obdidx" ] && break
1845 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1846 $have_obdidx || continue
1848 local ost=$((obdidx + 1))
1849 local dev=$(ostdevname $ost)
1852 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1854 seq=$(echo $seq | sed -e "s/^0x//g")
1855 if [ $seq == 0 ]; then
1856 oid_hex=$(echo $oid)
1858 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1860 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1864 # Don't unmount/remount the OSTs if we don't need to do that.
1865 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1866 # update too, until that use mount/ll_decode_filter_fid/mount.
1867 # Re-enable when debugfs will understand new filter_fid.
1869 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1870 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1871 $dev 2>/dev/null" | grep "parent=")
1874 mount_fstype ost$ost
1875 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1876 $(facet_mntpt ost$ost)/$obj_file)
1877 unmount_fstype ost$ost
1878 start ost$ost $dev $OST_MOUNT_OPTS
1881 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1883 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1885 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1886 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1887 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1888 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1889 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1891 if echo $ff_parent | grep -q 'stripe='; then
1892 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1895 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1896 # into f_ver in this case. See the comment on
1899 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1903 # compare lmm_seq and filter_fid->ff_parent.f_seq
1904 [ $ff_pseq = $lmm_seq ] ||
1905 error "FF parent SEQ $ff_pseq != $lmm_seq"
1906 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1907 [ $ff_poid = $lmm_oid ] ||
1908 error "FF parent OID $ff_poid != $lmm_oid"
1909 (($ff_pstripe == $stripe_nr)) ||
1910 error "FF stripe $ff_pstripe != $stripe_nr"
1912 stripe_nr=$((stripe_nr + 1))
1917 remote_ost_nodsh && skip "remote OST with nodsh" && return
1918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1919 test_mkdir -p $DIR/$tdir
1921 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1922 { error "setstripe -c -1 failed"; return 1; }
1923 # We need to send a write to every object to get parent FID info set.
1924 # This _should_ also work for setattr, but does not currently.
1925 # touch $DIR/$tdir/$tfile-1 ||
1926 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1927 { error "dd $tfile-1 failed"; return 2; }
1928 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1929 { error "setstripe -c -1 failed"; return 3; }
1930 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1931 { error "dd $tfile-2 failed"; return 4; }
1933 # make sure write RPCs have been sent to OSTs
1936 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1937 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1939 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1941 test_27A() { # b=19102
1942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1943 local restore_size=$($GETSTRIPE -S $MOUNT)
1944 local restore_count=$($GETSTRIPE -c $MOUNT)
1945 local restore_offset=$($GETSTRIPE -i $MOUNT)
1946 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1947 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1948 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1949 local default_size=$($GETSTRIPE -S $MOUNT)
1950 local default_offset=$($GETSTRIPE -i $MOUNT)
1951 local dsize=$((1024 * 1024))
1952 [ $default_size -eq $dsize ] ||
1953 error "stripe size $default_size != $dsize"
1954 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1955 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1957 run_test 27A "check filesystem-wide default LOV EA values"
1959 test_27B() { # LU-2523
1960 test_mkdir -p $DIR/$tdir
1961 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1963 # open f1 with O_LOV_DELAY_CREATE
1965 # call setstripe ioctl on open file descriptor for f1
1967 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1971 # open f1 with O_LOV_DELAY_CREATE
1973 # call setstripe ioctl on open file descriptor for f1
1975 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1977 # Allow multiop to fail in imitation of NFS's busted semantics.
1980 run_test 27B "call setstripe on open unlinked file/rename victim"
1982 test_27C() { #LU-2871
1983 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1991 test_mkdir -p $DIR/$tdir
1993 for i in $(seq 0 $((OSTCOUNT - 1))); do
1994 # set stripe across all OSTs starting from OST$i
1995 $SETSTRIPE -i $i -c -1 $tfile$i
1996 # get striping information
1997 ost_idx=($($GETSTRIPE $tfile$i |
1998 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2002 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2003 error "${#ost_idx[@]} != $OSTCOUNT"
2005 for index in $(seq 0 $((OSTCOUNT - 1))); do
2007 for j in $(echo ${ost_idx[@]}); do
2008 if [ $index -eq $j ]; then
2014 error "Can not find $index in ${ost_idx[@]}"
2018 run_test 27C "check full striping across all OSTs"
2021 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2022 local POOL=${POOL:-testpool}
2024 local last_ost=$(($OSTCOUNT - 1))
2026 local ost_list=$(seq $first_ost $ost_step $last_ost)
2027 local ost_range="$first_ost $last_ost $ost_step"
2030 pool_add $POOL || error "pool_add failed"
2031 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2032 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2033 error "llapi_layout_test failed"
2034 cleanup_pools || error "cleanup_pools failed"
2036 run_test 27D "validate llapi_layout API"
2038 # createtest also checks that device nodes are created and
2039 # then visible correctly (#2091)
2040 test_28() { # bug 2091
2042 $CREATETEST $DIR/d28/ct || error
2044 run_test 28 "create/mknod/mkdir with bad file types ============"
2047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2048 cancel_lru_locks mdc
2054 declare -i LOCKCOUNTORIG=0
2055 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2056 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2058 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2060 declare -i LOCKUNUSEDCOUNTORIG=0
2061 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2062 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2069 declare -i LOCKCOUNTCURRENT=0
2070 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2071 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2074 declare -i LOCKUNUSEDCOUNTCURRENT=0
2075 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2076 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2079 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2080 $LCTL set_param -n ldlm.dump_namespaces ""
2081 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2082 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2083 log "dumped log to $TMP/test_29.dk (bug 5793)"
2086 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2087 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2088 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2089 log "dumped log to $TMP/test_29.dk (bug 5793)"
2093 run_test 29 "IT_GETATTR regression ============================"
2095 test_30a() { # was test_30
2096 cp $(which ls) $DIR || cp /bin/ls $DIR
2100 run_test 30a "execute binary from Lustre (execve) =============="
2103 cp `which ls` $DIR || cp /bin/ls $DIR
2105 $RUNAS $DIR/ls / || error
2108 run_test 30b "execute binary from Lustre as non-root ==========="
2110 test_30c() { # b=22376
2111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2112 cp `which ls` $DIR || cp /bin/ls $DIR
2114 cancel_lru_locks mdc
2115 cancel_lru_locks osc
2116 $RUNAS $DIR/ls / || error
2119 run_test 30c "execute binary from Lustre without read perms ===="
2122 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2123 $CHECKSTAT -a $DIR/f31 || error
2125 run_test 31a "open-unlink file =================================="
2128 touch $DIR/f31 || error
2129 ln $DIR/f31 $DIR/f31b || error
2130 $MULTIOP $DIR/f31b Ouc || error
2131 $CHECKSTAT -t file $DIR/f31 || error
2133 run_test 31b "unlink file with multiple links while open ======="
2136 touch $DIR/f31 || error
2137 ln $DIR/f31 $DIR/f31c || error
2138 multiop_bg_pause $DIR/f31 O_uc || return 1
2140 $MULTIOP $DIR/f31c Ouc
2141 kill -USR1 $MULTIPID
2144 run_test 31c "open-unlink file with multiple links ============="
2147 opendirunlink $DIR/d31d $DIR/d31d || error
2148 $CHECKSTAT -a $DIR/d31d || error
2150 run_test 31d "remove of open directory ========================="
2152 test_31e() { # bug 2904
2153 check_kernel_version 34 || return 0
2154 openfilleddirunlink $DIR/d31e || error
2156 run_test 31e "remove of open non-empty directory ==============="
2158 test_31f() { # bug 4554
2159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2161 test_mkdir $DIR/d31f
2162 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2163 cp /etc/hosts $DIR/d31f
2165 $GETSTRIPE $DIR/d31f/hosts
2166 multiop_bg_pause $DIR/d31f D_c || return 1
2169 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2170 test_mkdir $DIR/d31f
2171 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2172 cp /etc/hosts $DIR/d31f
2174 $GETSTRIPE $DIR/d31f/hosts
2175 multiop_bg_pause $DIR/d31f D_c || return 1
2178 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2179 wait $MULTIPID || error "first opendir $MULTIPID failed"
2183 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2184 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2187 run_test 31f "remove of open directory with open-unlink file ==="
2190 echo "-- cross directory link --"
2191 test_mkdir -c1 $DIR/${tdir}ga
2192 test_mkdir -c1 $DIR/${tdir}gb
2193 touch $DIR/${tdir}ga/f
2194 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2195 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2196 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2197 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2198 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2200 run_test 31g "cross directory link==============="
2203 echo "-- cross directory link --"
2204 test_mkdir -c1 $DIR/${tdir}
2205 test_mkdir -c1 $DIR/${tdir}/dir
2206 touch $DIR/${tdir}/f
2207 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2208 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2209 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2210 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2211 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2213 run_test 31h "cross directory link under child==============="
2216 echo "-- cross directory link --"
2217 test_mkdir -c1 $DIR/$tdir
2218 test_mkdir -c1 $DIR/$tdir/dir
2219 touch $DIR/$tdir/dir/f
2220 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2221 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2222 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2223 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2224 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2226 run_test 31i "cross directory link under parent==============="
2229 test_mkdir -c1 -p $DIR/$tdir
2230 test_mkdir -c1 -p $DIR/$tdir/dir1
2231 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2232 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2233 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2234 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2237 run_test 31j "link for directory==============="
2240 test_mkdir -c1 -p $DIR/$tdir
2242 touch $DIR/$tdir/exist
2243 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2244 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2245 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2246 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2247 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2248 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2249 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2252 run_test 31k "link to file: the same, non-existing, dir==============="
2258 touch $DIR/d31m2/exist
2259 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2260 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2261 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2262 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2263 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2264 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2267 run_test 31m "link to file: the same, non-existing, dir==============="
2270 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2271 nlink=$(stat --format=%h $DIR/$tfile)
2272 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2274 local cmd="exec $fd<$DIR/$tfile"
2277 trap "eval $cmd" EXIT
2278 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2279 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2280 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2281 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2282 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2285 run_test 31n "check link count of unlinked file"
2288 local TEMPNAME=$(mktemp $1_XXXXXX)
2289 mlink $TEMPNAME $1 2> /dev/null &&
2290 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2294 test_31o() { # LU-2901
2296 for LOOP in $(seq 100); do
2297 rm -f $DIR/$tdir/$tfile*
2298 for THREAD in $(seq 8); do
2299 link_one $DIR/$tdir/$tfile.$LOOP &
2302 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2303 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2304 error "$LINKS duplicate links to $tfile.$LOOP" &&
2308 run_test 31o "duplicate hard links with same filename"
2311 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2314 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2315 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2317 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2318 error "open unlink test1 failed"
2319 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2320 error "open unlink test2 failed"
2322 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2323 error "test1 still exists"
2324 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2325 error "test2 still exists"
2327 run_test 31p "remove of open striped directory"
2329 cleanup_test32_mount() {
2331 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2335 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2336 echo "== more mountpoints and symlinks ================="
2337 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2338 trap cleanup_test32_mount EXIT
2339 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2340 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2341 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2342 cleanup_test32_mount
2344 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2348 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2349 trap cleanup_test32_mount EXIT
2350 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2351 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2352 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2353 cleanup_test32_mount
2355 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2359 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2360 trap cleanup_test32_mount EXIT
2361 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2362 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2363 test_mkdir -p $DIR/$tdir/d2/test_dir
2364 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2365 cleanup_test32_mount
2367 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2370 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2371 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2372 trap cleanup_test32_mount EXIT
2373 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2374 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2375 test_mkdir -p $DIR/$tdir/d2/test_dir
2376 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2377 cleanup_test32_mount
2379 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2382 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2383 test_mkdir -p $DIR/d32e/tmp
2384 TMP_DIR=$DIR/d32e/tmp
2385 ln -s $DIR/d32e $TMP_DIR/symlink11
2386 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2387 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2388 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2390 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2393 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2394 test_mkdir -p $DIR/d32f/tmp
2395 TMP_DIR=$DIR/d32f/tmp
2396 ln -s $DIR/d32f $TMP_DIR/symlink11
2397 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2398 ls $DIR/d32f/tmp/symlink11 || error
2399 ls $DIR/d32f/symlink01 || error
2401 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2404 TMP_DIR=$DIR/$tdir/tmp
2405 test_mkdir -p $DIR/$tdir/tmp
2406 test_mkdir $DIR/${tdir}2
2407 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2408 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2409 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2410 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2411 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2412 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2414 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2417 rm -fr $DIR/$tdir $DIR/${tdir}2
2418 TMP_DIR=$DIR/$tdir/tmp
2419 test_mkdir -p $DIR/$tdir/tmp
2420 test_mkdir $DIR/${tdir}2
2421 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2422 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2423 ls $TMP_DIR/symlink12 || error
2424 ls $DIR/$tdir/symlink02 || error
2426 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2430 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2431 trap cleanup_test32_mount EXIT
2432 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2433 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2434 touch $DIR/$tdir/test_file
2435 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2436 cleanup_test32_mount
2438 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2442 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2443 trap cleanup_test32_mount EXIT
2444 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2445 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2446 touch $DIR/$tdir/test_file
2447 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2448 cleanup_test32_mount
2450 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2455 trap cleanup_test32_mount EXIT
2456 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2457 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2458 test_mkdir -p $DIR/$tdir/d2
2459 touch $DIR/$tdir/d2/test_file || error
2460 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2461 cleanup_test32_mount
2463 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2468 trap cleanup_test32_mount EXIT
2469 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2470 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2471 test_mkdir -p $DIR/$tdir/d2
2472 touch $DIR/$tdir/d2/test_file
2473 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2474 cleanup_test32_mount
2476 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2480 test_mkdir -p $DIR/d32m/tmp
2481 TMP_DIR=$DIR/d32m/tmp
2482 ln -s $DIR $TMP_DIR/symlink11
2483 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2484 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2485 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2487 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2491 test_mkdir -p $DIR/d32n/tmp
2492 TMP_DIR=$DIR/d32n/tmp
2493 ln -s $DIR $TMP_DIR/symlink11
2494 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2495 ls -l $DIR/d32n/tmp/symlink11 || error
2496 ls -l $DIR/d32n/symlink01 || error
2498 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2502 test_mkdir -p $DIR/d32o/tmp
2503 TMP_DIR=$DIR/d32o/tmp
2504 ln -s $DIR/$tfile $TMP_DIR/symlink12
2505 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2506 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2507 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2508 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2509 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2511 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2521 test_mkdir -p $DIR/d32p/tmp
2523 TMP_DIR=$DIR/d32p/tmp
2525 ln -s $DIR/$tfile $TMP_DIR/symlink12
2527 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2529 cat $DIR/d32p/tmp/symlink12 || error
2531 cat $DIR/d32p/symlink02 || error
2534 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2536 cleanup_testdir_mount() {
2538 $UMOUNT -d $DIR/$tdir
2542 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2543 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2544 trap cleanup_testdir_mount EXIT
2545 test_mkdir -p $DIR/$tdir
2546 touch $DIR/$tdir/under_the_mount
2547 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2548 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2549 cleanup_testdir_mount
2551 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2554 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2555 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2556 trap cleanup_testdir_mount EXIT
2557 test_mkdir -p $DIR/$tdir
2558 touch $DIR/$tdir/under_the_mount
2559 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2560 ls $DIR/$tdir | grep -q under_the_mount && error || true
2561 cleanup_testdir_mount
2563 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2568 chmod 444 $DIR/$tfile
2569 chown $RUNAS_ID $DIR/$tfile
2571 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2574 run_test 33aa "write file with mode 444 (should return error) ===="
2578 test_mkdir -p $DIR/d33
2579 chown $RUNAS_ID $DIR/d33
2580 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2581 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2582 error "open RDWR" || true
2584 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2588 test_mkdir -p $DIR/d33
2589 chown $RUNAS_ID $DIR/d33
2590 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2592 run_test 33b "test open file with malformed flags (No panic)"
2595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2601 remote_ost_nodsh && skip "remote OST with nodsh" && return
2604 test_mkdir -p $DIR/d33
2605 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2608 for ostnum in $(seq $OSTCOUNT); do
2609 # test-framework's OST numbering is one-based, while Lustre's
2611 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2612 # Parsing llobdstat's output sucks; we could grep the /proc
2613 # path, but that's likely to not be as portable as using the
2614 # llobdstat utility. So we parse lctl output instead.
2615 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2616 obdfilter/$ostname/stats |
2617 awk '/^write_bytes/ {print $7}' )
2618 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2619 if (( ${write_bytes:-0} > 0 ))
2626 $all_zeros || return 0
2629 echo foo > $DIR/d33/bar
2633 # Total up write_bytes after writing. We'd better find non-zeros.
2634 for ostnum in $(seq $OSTCOUNT); do
2635 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2636 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2637 obdfilter/$ostname/stats |
2638 awk '/^write_bytes/ {print $7}' )
2639 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2640 if (( ${write_bytes:-0} > 0 ))
2649 for ostnum in $(seq $OSTCOUNT); do
2650 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2651 echo "Check that write_bytes is present in obdfilter/*/stats:"
2652 do_facet ost$ostnum lctl get_param -n \
2653 obdfilter/$ostname/stats
2655 error "OST not keeping write_bytes stats (b22312)"
2658 run_test 33c "test llobdstat and write_bytes"
2661 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2664 local remote_dir=$DIR/$tdir/remote_dir
2667 $LFS mkdir -i $MDTIDX $remote_dir ||
2668 error "create remote directory failed"
2670 touch $remote_dir/$tfile
2671 chmod 444 $remote_dir/$tfile
2672 chown $RUNAS_ID $remote_dir/$tfile
2674 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2676 chown $RUNAS_ID $remote_dir
2677 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2678 error "create" || true
2679 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2680 error "open RDWR" || true
2681 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2682 error "create" || true
2684 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2687 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2691 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2692 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2693 mkdir $DIR/$tdir/local_dir
2695 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2696 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2697 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2699 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2700 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2702 rmdir $DIR/$tdir/* || error "rmdir failed"
2705 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2706 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2707 mkdir $DIR/$tdir/local_dir
2709 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2710 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2711 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2713 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2714 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2716 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2719 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2720 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2721 mkdir $DIR/$tdir/local_dir
2723 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2724 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2725 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2727 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2728 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2730 run_test 33e "mkdir and striped directory should have same mode"
2734 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2738 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2741 chmod go+rwx $DIR/$tdir
2742 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2743 trap cleanup_33f EXIT
2745 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2746 error "cannot create striped directory"
2748 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2749 error "cannot create files in striped directory"
2751 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2752 error "cannot remove files in striped directory"
2754 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2755 error "cannot remove striped directory"
2759 run_test 33f "nonroot user can create, access, and remove a striped directory"
2761 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2764 $MCREATE $DIR/f34 || error
2765 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2766 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2767 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2768 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2770 run_test 34a "truncate file that has not been opened ==========="
2773 [ ! -f $DIR/f34 ] && test_34a
2774 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2775 $OPENFILE -f O_RDONLY $DIR/f34
2776 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2777 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2779 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2782 [ ! -f $DIR/f34 ] && test_34a
2783 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2784 $OPENFILE -f O_RDWR $DIR/f34
2785 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2786 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2788 run_test 34c "O_RDWR opening file-with-size works =============="
2791 [ ! -f $DIR/f34 ] && test_34a
2792 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2793 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2796 run_test 34d "write to sparse file ============================="
2800 $MCREATE $DIR/f34e || error
2801 $TRUNCATE $DIR/f34e 1000 || error
2802 $CHECKSTAT -s 1000 $DIR/f34e || error
2803 $OPENFILE -f O_RDWR $DIR/f34e
2804 $CHECKSTAT -s 1000 $DIR/f34e || error
2806 run_test 34e "create objects, some with size and some without =="
2808 test_34f() { # bug 6242, 6243
2809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2812 $MCREATE $DIR/f34f || error
2813 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2814 dd if=$DIR/f34f of=$TMP/f34f
2815 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2816 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2817 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2818 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2819 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2821 run_test 34f "read from a file with no objects until EOF ======="
2824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2825 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2826 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2827 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2828 cancel_lru_locks osc
2829 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2830 error "wrong size after lock cancel"
2832 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2833 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2834 error "expanding truncate failed"
2835 cancel_lru_locks osc
2836 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2837 error "wrong expanded size after lock cancel"
2839 run_test 34g "truncate long file ==============================="
2842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2846 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2847 sync # Flush the cache so that multiop below does not block on cache
2848 # flush when getting the group lock
2849 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2852 # Since just timed wait is not good enough, let's do a sync write
2853 # that way we are sure enough time for a roundtrip + processing
2854 # passed + 2 seconds of extra margin.
2855 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2859 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2860 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2864 local nsz=`stat -c %s $DIR/$tfile`
2865 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2867 run_test 34h "ftruncate file under grouplock should not block"
2870 cp /bin/sh $DIR/f35a
2872 chown $RUNAS_ID $DIR/f35a
2873 $RUNAS $DIR/f35a && error || true
2876 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2880 utime $DIR/f36 || error
2882 run_test 36a "MDS utime check (mknod, utime) ==================="
2886 utime $DIR/f36 || error
2888 run_test 36b "OST utime check (open, utime) ===================="
2893 chown $RUNAS_ID $DIR/d36
2894 $RUNAS utime $DIR/d36/f36 || error
2896 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2899 [ ! -d $DIR/d36 ] && test_36c
2900 echo "" > $DIR/d36/f36
2901 $RUNAS utime $DIR/d36/f36 || error
2903 run_test 36d "non-root OST utime check (open, utime) ==========="
2906 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2907 test_mkdir -p $DIR/$tdir
2908 touch $DIR/$tdir/$tfile
2909 $RUNAS utime $DIR/$tdir/$tfile && \
2910 error "utime worked, expected failure" || true
2912 run_test 36e "utime on non-owned file (should return error) ===="
2916 local LANG_SAVE=$LANG
2917 local LC_LANG_SAVE=$LC_LANG
2918 export LANG=C LC_LANG=C # for date language
2920 DATESTR="Dec 20 2000"
2921 test_mkdir -p $DIR/$tdir
2922 lctl set_param fail_loc=$fl
2924 cp /etc/hosts $DIR/$tdir/$tfile
2925 sync & # write RPC generated with "current" inode timestamp, but delayed
2927 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2928 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2929 cancel_lru_locks osc
2930 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2932 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2933 echo "BEFORE: $LS_BEFORE" && \
2934 echo "AFTER : $LS_AFTER" && \
2935 echo "WANT : $DATESTR" && \
2936 error "$DIR/$tdir/$tfile timestamps changed" || true
2938 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2942 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2943 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2944 subr_36fh "0x80000214"
2946 run_test 36f "utime on file racing with OST BRW write =========="
2949 remote_ost_nodsh && skip "remote OST with nodsh" && return
2950 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2955 test_mkdir -p $DIR/$tdir
2956 fmd_max_age=$(do_facet ost1 \
2957 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2960 fmd_before=$(do_facet ost1 \
2961 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2962 touch $DIR/$tdir/$tfile
2963 sleep $((fmd_max_age + 12))
2964 fmd_after=$(do_facet ost1 \
2965 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2967 echo "fmd_before: $fmd_before"
2968 echo "fmd_after: $fmd_after"
2969 [[ $fmd_after -gt $fmd_before ]] &&
2970 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
2971 error "fmd didn't expire after ping" || true
2973 run_test 36g "filter mod data cache expiry ====================="
2976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2977 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2978 subr_36fh "0x80000227"
2980 run_test 36h "utime on file racing with OST BRW write =========="
2983 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2986 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
2988 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
2989 local new_mtime=$((mtime + 200))
2991 #change Modify time of striped dir
2992 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
2993 error "change mtime failed"
2995 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
2997 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
2999 run_test 36i "change mtime on striped directory"
3001 # test_37 - duplicate with tests 32q 32r
3004 local file=$DIR/$tfile
3006 openfile -f O_DIRECTORY $file
3009 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3010 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3012 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3016 touch $DIR/${tfile}2
3017 # ls -l $DIR/$tfile $DIR/${tfile}2
3018 # ls -lu $DIR/$tfile $DIR/${tfile}2
3019 # ls -lc $DIR/$tfile $DIR/${tfile}2
3021 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3022 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3024 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3026 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3028 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3029 error "O_TRUNC didn't change timestamps"
3032 run_test 39 "mtime changed on create ==========================="
3035 test_mkdir -p -c1 $DIR/$tdir
3036 cp -p /etc/passwd $DIR/$tdir/fopen
3037 cp -p /etc/passwd $DIR/$tdir/flink
3038 cp -p /etc/passwd $DIR/$tdir/funlink
3039 cp -p /etc/passwd $DIR/$tdir/frename
3040 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3043 echo "aaaaaa" >> $DIR/$tdir/fopen
3044 echo "aaaaaa" >> $DIR/$tdir/flink
3045 echo "aaaaaa" >> $DIR/$tdir/funlink
3046 echo "aaaaaa" >> $DIR/$tdir/frename
3048 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3049 local link_new=`stat -c %Y $DIR/$tdir/flink`
3050 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3051 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3053 cat $DIR/$tdir/fopen > /dev/null
3054 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3055 rm -f $DIR/$tdir/funlink2
3056 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3058 for (( i=0; i < 2; i++ )) ; do
3059 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3060 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3061 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3062 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3064 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3065 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3066 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3067 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3069 cancel_lru_locks osc
3070 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3073 run_test 39b "mtime change on open, link, unlink, rename ======"
3075 # this should be set to past
3076 TEST_39_MTIME=`date -d "1 year ago" +%s`
3082 local mtime0=`stat -c %Y $DIR1/$tfile`
3084 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3085 local mtime1=`stat -c %Y $DIR1/$tfile`
3086 [ "$mtime1" = $TEST_39_MTIME ] || \
3087 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3090 echo hello >> $DIR1/$tfile
3092 local mtime2=`stat -c %Y $DIR1/$tfile`
3093 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3094 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3096 mv $DIR1/$tfile $DIR1/$tfile-1
3098 for (( i=0; i < 2; i++ )) ; do
3099 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3100 [ "$mtime2" = "$mtime3" ] || \
3101 error "mtime ($mtime2) changed (to $mtime3) on rename"
3103 cancel_lru_locks osc
3104 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3107 run_test 39c "mtime change on rename ==========================="
3111 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3114 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3116 for (( i=0; i < 2; i++ )) ; do
3117 local mtime=`stat -c %Y $DIR1/$tfile`
3118 [ $mtime = $TEST_39_MTIME ] || \
3119 error "mtime($mtime) is not set to $TEST_39_MTIME"
3121 cancel_lru_locks osc
3122 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3125 run_test 39d "create, utime, stat =============================="
3129 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3131 local mtime1=`stat -c %Y $DIR1/$tfile`
3133 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3135 for (( i=0; i < 2; i++ )) ; do
3136 local mtime2=`stat -c %Y $DIR1/$tfile`
3137 [ $mtime2 = $TEST_39_MTIME ] || \
3138 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3140 cancel_lru_locks osc
3141 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3144 run_test 39e "create, stat, utime, stat ========================"
3148 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3150 mtime1=`stat -c %Y $DIR1/$tfile`
3153 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3155 for (( i=0; i < 2; i++ )) ; do
3156 local mtime2=`stat -c %Y $DIR1/$tfile`
3157 [ $mtime2 = $TEST_39_MTIME ] || \
3158 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3160 cancel_lru_locks osc
3161 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3164 run_test 39f "create, stat, sleep, utime, stat ================="
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3169 echo hello >> $DIR1/$tfile
3170 local mtime1=`stat -c %Y $DIR1/$tfile`
3173 chmod o+r $DIR1/$tfile
3175 for (( i=0; i < 2; i++ )) ; do
3176 local mtime2=`stat -c %Y $DIR1/$tfile`
3177 [ "$mtime1" = "$mtime2" ] || \
3178 error "lost mtime: $mtime2, should be $mtime1"
3180 cancel_lru_locks osc
3181 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3184 run_test 39g "write, chmod, stat ==============================="
3188 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3193 echo hello >> $DIR1/$tfile
3194 local mtime1=`stat -c %Y $DIR1/$tfile`
3196 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3198 if [ "$d1" != "$d2" ]; then
3199 echo "write and touch not within one second"
3201 for (( i=0; i < 2; i++ )) ; do
3202 local mtime2=`stat -c %Y $DIR1/$tfile`
3203 [ "$mtime2" = $TEST_39_MTIME ] || \
3204 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3206 cancel_lru_locks osc
3207 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3211 run_test 39h "write, utime within one second, stat ============="
3214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3218 echo hello >> $DIR1/$tfile
3219 local mtime1=`stat -c %Y $DIR1/$tfile`
3221 mv $DIR1/$tfile $DIR1/$tfile-1
3223 for (( i=0; i < 2; i++ )) ; do
3224 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3226 [ "$mtime1" = "$mtime2" ] || \
3227 error "lost mtime: $mtime2, should be $mtime1"
3229 cancel_lru_locks osc
3230 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3233 run_test 39i "write, rename, stat =============================="
3236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3237 start_full_debug_logging
3241 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3242 lctl set_param fail_loc=0x80000412
3243 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3244 error "multiop failed"
3246 local mtime1=`stat -c %Y $DIR1/$tfile`
3248 mv $DIR1/$tfile $DIR1/$tfile-1
3250 kill -USR1 $multipid
3251 wait $multipid || error "multiop close failed"
3253 for (( i=0; i < 2; i++ )) ; do
3254 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3255 [ "$mtime1" = "$mtime2" ] ||
3256 error "mtime is lost on close: $mtime2, " \
3259 cancel_lru_locks osc
3260 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3262 lctl set_param fail_loc=0
3263 stop_full_debug_logging
3265 run_test 39j "write, rename, close, stat ======================="
3268 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3272 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3274 local mtime1=`stat -c %Y $DIR1/$tfile`
3276 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3278 kill -USR1 $multipid
3279 wait $multipid || error "multiop close failed"
3281 for (( i=0; i < 2; i++ )) ; do
3282 local mtime2=`stat -c %Y $DIR1/$tfile`
3284 [ "$mtime2" = $TEST_39_MTIME ] || \
3285 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3287 cancel_lru_locks osc
3288 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3291 run_test 39k "write, utime, close, stat ========================"
3293 # this should be set to future
3294 TEST_39_ATIME=`date -d "1 year" +%s`
3297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3298 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3299 local atime_diff=$(do_facet $SINGLEMDS \
3300 lctl get_param -n mdd.*MDT0000*.atime_diff)
3304 # test setting directory atime to future
3305 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3306 local atime=$(stat -c %X $DIR/$tdir)
3307 [ "$atime" = $TEST_39_ATIME ] || \
3308 error "atime is not set to future: $atime, $TEST_39_ATIME"
3310 # test setting directory atime from future to now
3311 local d1=$(date +%s)
3313 local d2=$(date +%s)
3315 cancel_lru_locks mdc
3316 atime=$(stat -c %X $DIR/$tdir)
3317 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3318 error "atime is not updated from future: $atime, $d1<atime<$d2"
3320 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3323 # test setting directory atime when now > dir atime + atime_diff
3327 cancel_lru_locks mdc
3328 atime=$(stat -c %X $DIR/$tdir)
3329 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3330 error "atime is not updated : $atime, should be $d2"
3332 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3335 # test not setting directory atime when now < dir atime + atime_diff
3337 cancel_lru_locks mdc
3338 atime=$(stat -c %X $DIR/$tdir)
3339 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3340 error "atime is updated to $atime, should remain $d1<atime<$d2"
3342 do_facet $SINGLEMDS \
3343 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3345 run_test 39l "directory atime update ==========================="
3348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3351 local far_past_mtime=$(date -d "May 29 1953" +%s)
3352 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3354 touch -m -d @$far_past_mtime $DIR1/$tfile
3355 touch -a -d @$far_past_atime $DIR1/$tfile
3357 for (( i=0; i < 2; i++ )) ; do
3358 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3359 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3360 error "atime or mtime set incorrectly"
3362 cancel_lru_locks osc
3363 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3366 run_test 39m "test atime and mtime before 1970"
3368 test_39n() { # LU-3832
3369 local atime_diff=$(do_facet $SINGLEMDS \
3370 lctl get_param -n mdd.*MDT0000*.atime_diff)
3375 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3378 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3379 atime0=$(stat -c %X $DIR/$tfile)
3382 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3383 atime1=$(stat -c %X $DIR/$tfile)
3386 cancel_lru_locks mdc
3387 cancel_lru_locks osc
3388 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3389 atime2=$(stat -c %X $DIR/$tfile)
3391 do_facet $SINGLEMDS \
3392 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3394 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3395 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3397 run_test 39n "check that O_NOATIME is honored"
3400 TESTDIR=$DIR/$tdir/$tfile
3401 [ -e $TESTDIR ] && rm -rf $TESTDIR
3402 test_mkdir -p $TESTDIR
3408 links2=$(stat -c %h .)
3409 [ $(($links1 + 2)) != $links2 ] &&
3410 error "wrong links count $(($links1 + 2)) != $links2"
3412 links3=$(stat -c %h .)
3413 [ $(($links1 + 1)) != $links3 ] &&
3414 error "wrong links count $links1 != $links3"
3417 run_test 39o "directory cached attributes updated after create ========"
3420 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3422 TESTDIR=$DIR/$tdir/$tfile
3423 [ -e $TESTDIR ] && rm -rf $TESTDIR
3428 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3429 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3431 links2=$(stat -c %h .)
3432 [ $(($links1 + 2)) != $links2 ] &&
3433 error "wrong links count $(($links1 + 2)) != $links2"
3435 links3=$(stat -c %h .)
3436 [ $(($links1 + 1)) != $links3 ] &&
3437 error "wrong links count $links1 != $links3"
3440 run_test 39p "remote directory cached attributes updated after create ========"
3444 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3445 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3446 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3447 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3448 error "$tfile is not 4096 bytes in size"
3450 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3454 small_write $DIR/f41 18
3456 run_test 41 "test small file write + fstat ====================="
3458 count_ost_writes() {
3459 lctl get_param -n osc.*.stats |
3460 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3461 END { printf("%0.0f", writes) }'
3468 BG_DIRTY_RATIO_SAVE=10
3469 MAX_BG_DIRTY_RATIO=25
3473 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3474 # dirty_ratio, dirty_background_ratio
3475 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3476 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3477 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3478 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3480 # if file not here, we are a 2.4 kernel
3481 kill -CONT `pidof kupdated`
3486 # setup the trap first, so someone cannot exit the test at the
3487 # exact wrong time and mess up a machine
3488 trap start_writeback EXIT
3489 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3490 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3491 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3492 sysctl -w vm.dirty_writeback_centisecs=0
3493 sysctl -w vm.dirty_writeback_centisecs=0
3494 # save and increase /proc/sys/vm/dirty_ratio
3495 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3496 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3497 # save and increase /proc/sys/vm/dirty_background_ratio
3498 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3499 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3501 # if file not here, we are a 2.4 kernel
3502 kill -STOP `pidof kupdated`
3506 # ensure that all stripes have some grant before we test client-side cache
3508 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3509 dd if=/dev/zero of=$i bs=4k count=1
3514 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3515 # file truncation, and file removal.
3517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3519 cancel_lru_locks osc
3521 sync; sleep 1; sync # just to be safe
3522 BEFOREWRITES=`count_ost_writes`
3523 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3524 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3525 AFTERWRITES=`count_ost_writes`
3526 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3527 error "$BEFOREWRITES < $AFTERWRITES"
3530 run_test 42a "ensure that we don't flush on close =============="
3533 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3535 cancel_lru_locks osc
3538 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3539 BEFOREWRITES=$(count_ost_writes)
3540 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3541 AFTERWRITES=$(count_ost_writes)
3542 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3543 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3545 BEFOREWRITES=$(count_ost_writes)
3546 sync || error "sync: $?"
3547 AFTERWRITES=$(count_ost_writes)
3548 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3549 error "$BEFOREWRITES < $AFTERWRITES on sync"
3551 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3555 run_test 42b "test destroy of file with cached dirty data ======"
3557 # if these tests just want to test the effect of truncation,
3558 # they have to be very careful. consider:
3559 # - the first open gets a {0,EOF}PR lock
3560 # - the first write conflicts and gets a {0, count-1}PW
3561 # - the rest of the writes are under {count,EOF}PW
3562 # - the open for truncate tries to match a {0,EOF}PR
3563 # for the filesize and cancels the PWs.
3564 # any number of fixes (don't get {0,EOF} on open, match
3565 # composite locks, do smarter file size management) fix
3566 # this, but for now we want these tests to verify that
3567 # the cancellation with truncate intent works, so we
3568 # start the file with a full-file pw lock to match against
3569 # until the truncate.
3574 cancel_lru_locks osc
3576 # prime the file with 0,EOF PW to match
3580 # now the real test..
3581 dd if=/dev/zero of=$file bs=1024 count=100
3582 BEFOREWRITES=`count_ost_writes`
3583 $TRUNCATE $file $offset
3584 cancel_lru_locks osc
3585 AFTERWRITES=`count_ost_writes`
3590 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3592 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3593 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3596 run_test 42c "test partial truncate of file with cached dirty data"
3599 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3601 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3602 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3605 run_test 42d "test complete truncate of file with cached dirty data"
3607 test_42e() { # bug22074
3608 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3609 local TDIR=$DIR/${tdir}e
3610 local pagesz=$(page_size)
3611 local pages=16 # hardcoded 16 pages, don't change it.
3612 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3613 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3617 test_mkdir -p $DIR/${tdir}e
3618 $SETSTRIPE -c 1 $TDIR
3619 createmany -o $TDIR/f $files
3621 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3623 # we assume that with $OSTCOUNT files, at least one of them will
3624 # be allocated on OST0.
3625 warmup_files=$((OSTCOUNT * max_dirty_mb))
3626 createmany -o $TDIR/w $warmup_files
3628 # write a large amount of data into one file and sync, to get good
3629 # avail_grant number from OST.
3630 for ((i=0; i<$warmup_files; i++)); do
3631 idx=$($GETSTRIPE -i $TDIR/w$i)
3632 [ $idx -ne 0 ] && continue
3633 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3636 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3638 $LCTL get_param $proc_osc0/cur_dirty_bytes
3639 $LCTL get_param $proc_osc0/cur_grant_bytes
3641 # create as much dirty pages as we can while not to trigger the actual
3642 # RPCs directly. but depends on the env, VFS may trigger flush during this
3643 # period, hopefully we are good.
3644 for ((i=0; i<$warmup_files; i++)); do
3645 idx=$($GETSTRIPE -i $TDIR/w$i)
3646 [ $idx -ne 0 ] && continue
3647 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3649 $LCTL get_param $proc_osc0/cur_dirty_bytes
3650 $LCTL get_param $proc_osc0/cur_grant_bytes
3652 # perform the real test
3653 $LCTL set_param $proc_osc0/rpc_stats 0
3654 for ((;i<$files; i++)); do
3655 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3656 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3659 $LCTL get_param $proc_osc0/rpc_stats
3662 local have_ppr=false
3663 $LCTL get_param $proc_osc0/rpc_stats |
3664 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3665 # skip lines until we are at the RPC histogram data
3666 [ "$PPR" == "pages" ] && have_ppr=true && continue
3667 $have_ppr || continue
3669 # we only want the percent stat for < 16 pages
3670 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3672 percent=$((percent + WPCT))
3673 if [[ $percent -gt 15 ]]; then
3674 error "less than 16-pages write RPCs" \
3681 run_test 42e "verify sub-RPC writes are not done synchronously"
3684 test_mkdir -p $DIR/$tdir
3685 cp -p /bin/ls $DIR/$tdir/$tfile
3686 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3688 # give multiop a chance to open
3691 $DIR/$tdir/$tfile && error || true
3694 run_test 43 "execution of file opened for write should return -ETXTBSY"
3697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3698 test_mkdir -p $DIR/$tdir
3699 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3700 cp -p multiop $DIR/$tdir/multiop
3701 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3704 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3705 kill -USR1 $MULTIOP_PID || return 2
3706 wait $MULTIOP_PID || return 3
3707 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3709 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3713 test_mkdir -p $DIR/$tdir
3714 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3715 cp -p multiop $DIR/$tdir/multiop
3716 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3719 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3720 kill -USR1 $MULTIOP_PID || return 2
3721 wait $MULTIOP_PID || return 3
3722 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3724 run_test 43b "truncate of file being executed should return -ETXTBSY"
3727 local testdir="$DIR/$tdir"
3728 test_mkdir -p $DIR/$tdir
3730 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3731 ( cd $testdir && md5sum -c)
3733 run_test 43c "md5sum of copy into lustre========================"
3736 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3737 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3738 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3740 run_test 44 "zero length read from a sparse stripe ============="
3743 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3745 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3746 [[ $nstripe -gt $OSTCOUNT ]] &&
3747 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3749 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3751 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3752 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3756 OFFSETS="0 $((stride/2)) $((stride-1))"
3757 for offset in $OFFSETS; do
3758 for i in $(seq 0 $((nstripe-1))); do
3759 local GLOBALOFFSETS=""
3761 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3762 local myfn=$DIR/d44a-$size
3763 echo "--------writing $myfn at $size"
3764 ll_sparseness_write $myfn $size ||
3765 error "ll_sparseness_write"
3766 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3767 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3768 error "ll_sparseness_verify $GLOBALOFFSETS"
3770 for j in $(seq 0 $((nstripe-1))); do
3772 size=$((((j + $nstripe )*$stride + $offset)))
3773 ll_sparseness_write $myfn $size ||
3774 error "ll_sparseness_write"
3775 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3777 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3778 error "ll_sparseness_verify $GLOBALOFFSETS"
3783 run_test 44a "test sparse pwrite ==============================="
3787 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3793 before=`dirty_osc_total`
3794 echo executing "\"$*\""
3796 after=`dirty_osc_total`
3797 echo before $before, after $after
3800 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3802 # Obtain grants from OST if it supports it
3803 echo blah > ${f}_grant
3806 do_dirty_record "echo blah > $f"
3807 [[ $before -eq $after ]] && error "write wasn't cached"
3808 do_dirty_record "> $f"
3809 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3810 do_dirty_record "echo blah > $f"
3811 [[ $before -eq $after ]] && error "write wasn't cached"
3812 do_dirty_record "sync"
3813 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3814 do_dirty_record "echo blah > $f"
3815 [[ $before -eq $after ]] && error "write wasn't cached"
3816 do_dirty_record "cancel_lru_locks osc"
3817 [[ $before -gt $after ]] ||
3818 error "lock cancellation didn't lower dirty count"
3821 run_test 45 "osc io page accounting ============================"
3823 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3824 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3825 # objects offset and an assert hit when an rpc was built with 1023's mapped
3826 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3832 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3834 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3835 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3839 run_test 46 "dirtying a previously written page ================"
3841 # test_47 is removed "Device nodes check" is moved to test_28
3843 test_48a() { # bug 2399
3844 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3845 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3846 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3848 check_kernel_version 34 || return 0
3849 test_mkdir -p $DIR/$tdir
3851 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3852 test_mkdir $DIR/$tdir || error "recreate directory failed"
3853 touch foo || error "'touch foo' failed after recreating cwd"
3854 test_mkdir $DIR/$tdir/bar ||
3855 error "'mkdir foo' failed after recreating cwd"
3856 if check_kernel_version 44; then
3857 touch .foo || error "'touch .foo' failed after recreating cwd"
3858 test_mkdir $DIR/$tdir/.bar ||
3859 error "'mkdir .foo' failed after recreating cwd"
3861 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3862 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3863 cd . || error "'cd .' failed after recreating cwd"
3864 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3865 rmdir . && error "'rmdir .' worked after recreating cwd"
3866 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3867 cd .. || error "'cd ..' failed after recreating cwd"
3869 run_test 48a "Access renamed working dir (should return errors)="
3871 test_48b() { # bug 2399
3872 check_kernel_version 34 || return 0
3874 test_mkdir -p $DIR/$tdir
3876 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3877 touch foo && error "'touch foo' worked after removing cwd"
3878 test_mkdir $DIR/$tdir/foo &&
3879 error "'mkdir foo' worked after removing cwd"
3880 if check_kernel_version 44; then
3881 touch .foo && error "'touch .foo' worked after removing cwd"
3882 test_mkdir $DIR/$tdir/.foo &&
3883 error "'mkdir .foo' worked after removing cwd"
3885 ls . > /dev/null && error "'ls .' worked after removing cwd"
3886 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3887 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3888 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3889 rmdir . && error "'rmdir .' worked after removing cwd"
3890 ln -s . foo && error "'ln -s .' worked after removing cwd"
3891 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3893 run_test 48b "Access removed working dir (should return errors)="
3895 test_48c() { # bug 2350
3896 check_kernel_version 36 || return 0
3897 #lctl set_param debug=-1
3900 test_mkdir -p $DIR/$tdir/dir
3902 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3903 $TRACE touch foo && error "touch foo worked after removing cwd"
3904 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3905 if check_kernel_version 44; then
3906 touch .foo && error "touch .foo worked after removing cwd"
3907 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3909 $TRACE ls . && error "'ls .' worked after removing cwd"
3910 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3911 is_patchless || ( $TRACE cd . &&
3912 error "'cd .' worked after removing cwd" )
3913 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3914 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3915 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3916 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3918 run_test 48c "Access removed working subdir (should return errors)"
3920 test_48d() { # bug 2350
3921 check_kernel_version 36 || return 0
3922 #lctl set_param debug=-1
3925 test_mkdir -p $DIR/$tdir/dir
3927 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3928 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3929 $TRACE touch foo && error "'touch foo' worked after removing parent"
3930 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3931 if check_kernel_version 44; then
3932 touch .foo && error "'touch .foo' worked after removing parent"
3934 error "mkdir .foo worked after removing parent"
3936 $TRACE ls . && error "'ls .' worked after removing parent"
3937 $TRACE ls .. && error "'ls ..' worked after removing parent"
3938 is_patchless || ( $TRACE cd . &&
3939 error "'cd .' worked after recreate parent" )
3940 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3941 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3942 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3943 is_patchless || ( $TRACE cd .. &&
3944 error "'cd ..' worked after removing parent" || true )
3946 run_test 48d "Access removed parent subdir (should return errors)"
3948 test_48e() { # bug 4134
3949 check_kernel_version 41 || return 0
3950 #lctl set_param debug=-1
3953 test_mkdir -p $DIR/$tdir/dir
3955 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3956 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3957 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3958 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3959 # On a buggy kernel addition of "touch foo" after cd .. will
3960 # produce kernel oops in lookup_hash_it
3961 touch ../foo && error "'cd ..' worked after recreate parent"
3963 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3965 run_test 48e "Access to recreated parent subdir (should return errors)"
3967 test_49() { # LU-1030
3968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3969 # get ost1 size - lustre-OST0000
3970 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
3972 # write 800M at maximum
3973 [[ $ost1_size -lt 2 ]] && ost1_size=2
3974 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
3976 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
3977 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3980 # change max_pages_per_rpc while writing the file
3981 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3982 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
3983 # loop until dd process exits
3984 while ps ax -opid | grep -wq $dd_pid; do
3985 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3986 sleep $((RANDOM % 5 + 1))
3988 # restore original max_pages_per_rpc
3989 $LCTL set_param $osc1_mppc=$orig_mppc
3990 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3992 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3996 test_mkdir $DIR/$tdir
3998 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4000 run_test 50 "special situations: /proc symlinks ==============="
4002 test_51a() { # was test_51
4003 # bug 1516 - create an empty entry right after ".." then split dir
4004 test_mkdir -c1 $DIR/$tdir
4005 touch $DIR/$tdir/foo
4006 $MCREATE $DIR/$tdir/bar
4008 createmany -m $DIR/$tdir/longfile 201
4010 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4011 $MCREATE $DIR/$tdir/longfile$FNUM
4016 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4018 run_test 51a "special situations: split htree with empty entry =="
4020 export NUMTEST=70000
4022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4023 local BASE=$DIR/d${base}.${TESTSUITE}
4025 # cleanup the directory
4028 test_mkdir -p -c1 $BASE
4032 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4033 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4034 [[ $numfree -lt 21000 ]] &&
4035 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4038 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4039 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4041 # need to check free space for the directories as well
4042 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4043 numfree=$((blkfree / 4))
4044 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4045 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4047 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4051 echo "failed" > $BASE/fnum
4052 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4055 run_test 51b "exceed 64k subdirectory nlink limit"
4057 test_51ba() { # LU-993
4058 local BASE=$DIR/d${base}.${TESTSUITE}
4059 # unlink all but 100 subdirectories, then check it still works
4061 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4063 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4064 local DELETE=$((NUMTEST - LEFT))
4066 # continue on to run this test even if 51b didn't finish,
4067 # just to delete the many subdirectories created.
4068 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4070 # for ldiskfs the nlink count should be 1, but this is OSD specific
4071 # and so this is listed for informational purposes only
4072 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4073 unlinkmany -d $BASE/d $DELETE
4076 if [ $RC -ne 0 ]; then
4077 if [ "$NUMPREV" == "failed" ]; then
4078 skip "previous setup failed"
4081 error "unlink of first $DELETE subdirs failed"
4086 echo "nlink between: $(stat -c %h $BASE)"
4087 # trim the first line of ls output
4088 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4089 [ $FOUND -ne $LEFT ] &&
4090 error "can't find subdirs: found only $FOUND/$LEFT"
4092 unlinkmany -d $BASE/d $DELETE $LEFT ||
4093 error "unlink of second $LEFT subdirs failed"
4094 # regardless of whether the backing filesystem tracks nlink accurately
4095 # or not, the nlink count shouldn't be more than "." and ".." here
4096 local AFTER=$(stat -c %h $BASE)
4097 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4098 echo "nlink after: $AFTER"
4100 run_test 51ba "verify nlink for many subdirectory cleanup"
4103 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4104 [[ $OSTCOUNT -lt 3 ]] &&
4105 skip_env "skipping test with few OSTs" && return
4106 test_mkdir -p $DIR/$tdir
4107 createmany -o $DIR/$tdir/t- 1000
4108 $GETSTRIPE $DIR/$tdir > $TMP/files
4109 for N in $(seq 0 $((OSTCOUNT - 1))); do
4110 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4111 END { printf("%0.0f", objs) }' $TMP/files)
4112 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4113 '($1 == '$N') { objs += 1 } \
4114 END { printf("%0.0f", objs) }')
4115 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4117 unlinkmany $DIR/$tdir/t- 1000
4120 for N in $(seq 1 $((OSTCOUNT - 1))); do
4121 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4122 error "OST $N has less objects vs OST $NLAST" \
4123 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4124 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4125 error "OST $N has less objects vs OST $NLAST" \
4126 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4128 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4129 error "OST $N has less #0 objects vs OST $NLAST" \
4130 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4131 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4132 error "OST $N has less #0 objects vs OST $NLAST" \
4133 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4137 run_test 51d "check object distribution ===================="
4140 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4141 skip "Only applicable to ldiskfs-based MDTs"
4145 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4146 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4148 touch $DIR/$tdir/d0/foo
4149 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4150 error "file exceed 65000 nlink limit!"
4151 unlinkmany $DIR/$tdir/d0/f- 65001
4154 run_test 51e "check file nlink limit"
4157 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4158 test_mkdir -p $DIR/$tdir
4159 touch $DIR/$tdir/foo
4160 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4161 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4162 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4163 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4164 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4166 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4167 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4168 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4170 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4171 cp -r $DIR/$tdir /tmp/
4172 rm -fr $DIR/$tdir || error "cleanup rm failed"
4174 run_test 52a "append-only flag test (should return errors) ====="
4177 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4178 test_mkdir -p $DIR/$tdir
4179 touch $DIR/$tdir/foo
4180 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4181 cat test > $DIR/$tdir/foo && error "cat test worked"
4182 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4183 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4184 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4186 echo foo >> $DIR/$tdir/foo && error "echo worked"
4187 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4188 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4189 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4190 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4192 chattr -i $DIR/$tdir/foo || error "chattr failed"
4194 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4196 run_test 52b "immutable flag test (should return errors) ======="
4199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4200 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4201 remote_ost_nodsh && skip "remote OST with nodsh" && return
4214 local support_last_seq=true
4216 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4217 support_last_seq=false
4220 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4222 for value in $(do_facet $SINGLEMDS \
4223 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4224 param=$(echo ${value[0]} | cut -d "=" -f1)
4225 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4227 if $support_last_seq; then
4228 param_seq=$(echo $param |
4229 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4230 mds_last_seq=$(do_facet $SINGLEMDS \
4231 $LCTL get_param -n $param_seq)
4233 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4235 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4236 node=$(facet_active_host ost$((ostnum+1)))
4237 param="obdfilter.$ostname.last_id"
4238 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4239 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4240 ost_last_id=$ost_last
4242 if $support_last_seq; then
4243 ost_last_id=$(echo $ost_last |
4244 awk -F':' '{print $2}' |
4246 ost_last_seq=$(echo $ost_last |
4247 awk -F':' '{print $1}')
4248 [[ $ost_last_seq = $mds_last_seq ]] || continue
4251 if [[ $ost_last_id != $mds_last ]]; then
4252 error "$ost_last_id != $mds_last"
4259 $found || error "can not match last_seq/last_id for $mdtosc"
4262 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4265 $SOCKETSERVER $DIR/socket ||
4266 error "$SOCKETSERVER $DIR/socket failed: $?"
4267 $SOCKETCLIENT $DIR/socket ||
4268 error "$SOCKETCLIENT $DIR/socket failed: $?"
4269 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4271 run_test 54a "unix domain socket test =========================="
4277 dd if=/dev/zero of=$f bs=$(page_size) count=1
4279 run_test 54b "char device works in lustre ======================"
4282 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4283 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4284 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4286 for i in $(seq 3 7); do
4287 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4295 loopdev="$DIR/loop54c"
4298 $UMOUNT -d $DIR/$tdir || rc=$?
4299 losetup -d $loopdev || true
4300 losetup -d $LOOPDEV || true
4301 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4306 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4307 loopdev="$DIR/loop54c"
4310 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4311 trap cleanup_54c EXIT
4312 mknod $loopdev b 7 $LOOPNUM
4313 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4314 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4315 losetup $loopdev $DIR/$tfile ||
4316 error "can't set up $loopdev for $DIR/$tfile"
4317 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4318 test_mkdir -p $DIR/$tdir
4319 mount -t ext2 $loopdev $DIR/$tdir ||
4320 error "error mounting $loopdev on $DIR/$tdir"
4321 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4324 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4328 run_test 54c "block device works in lustre ====================="
4334 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4336 run_test 54d "fifo device works in lustre ======================"
4339 check_kernel_version 46 || return 0
4342 cp -aL /dev/console $f
4343 echo $string > $f || error "echo $string to $f failed"
4345 run_test 54e "console/tty device works in lustre ======================"
4347 #The test_55 used to be iopen test and it was removed by bz#24037.
4348 #run_test 55 "check iopen_connect_dentry() ======================"
4350 test_56a() { # was test_56
4353 test_mkdir -p $DIR/$tdir/dir
4355 NUMFILESx2=$(($NUMFILES * 2))
4356 for i in $(seq 1 $NUMFILES); do
4357 touch $DIR/$tdir/file$i
4358 touch $DIR/$tdir/dir/file$i
4361 # test lfs getstripe with --recursive
4362 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4363 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4364 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4365 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4366 [[ $FILENUM -eq $NUMFILES ]] ||
4367 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4368 echo "$GETSTRIPE --recursive passed."
4370 # test lfs getstripe with file instead of dir
4371 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4372 [[ $FILENUM -eq 1 ]] ||
4373 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4374 echo "$GETSTRIPE file1 passed."
4376 #test lfs getstripe with --verbose
4377 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4378 grep -c lmm_magic) -eq $NUMFILES ]] ||
4379 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4380 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4381 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4382 echo "$GETSTRIPE --verbose passed."
4384 #test lfs getstripe with --obd
4385 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4386 grep -q "unknown obduuid" ||
4387 error "$GETSTRIPE --obd wrong_uuid should return error message"
4389 [[ $OSTCOUNT -lt 2 ]] &&
4390 skip_env "skipping other $GETSTRIPE --obd test" && return
4393 OBDUUID=$(ostuuid_from_index $OSTIDX)
4394 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4395 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4396 [[ $FOUND -eq $FILENUM ]] ||
4397 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4398 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4399 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4400 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4401 error "$GETSTRIPE --obd: should not show file on other obd"
4402 echo "$GETSTRIPE --obd passed"
4404 run_test 56a "check $GETSTRIPE"
4409 local LOCAL_NUMFILES="$1"
4410 local LOCAL_NUMDIRS="$2"
4411 local MKDIR_PARAMS="$3"
4412 local DIR_STRIPE_PARAMS="$4"
4414 if [ ! -d "$TDIR" ] ; then
4415 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4416 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4417 for i in `seq 1 $LOCAL_NUMFILES` ; do
4420 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4421 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4422 for j in `seq 1 $LOCAL_NUMFILES` ; do
4423 touch $TDIR/dir$i/file$j
4429 setup_56_special() {
4433 if [ ! -e "$TDIR/loop1b" ] ; then
4434 for i in `seq 1 $LOCAL_NUMFILES` ; do
4435 mknod $TDIR/loop${i}b b 7 $i
4436 mknod $TDIR/null${i}c c 1 3
4437 ln -s $TDIR/file1 $TDIR/link${i}l
4439 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4440 mknod $TDIR/dir$i/loop${i}b b 7 $i
4441 mknod $TDIR/dir$i/null${i}c c 1 3
4442 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4451 setup_56 $NUMFILES $NUMDIRS
4453 EXPECTED=$(($NUMDIRS + 2))
4454 # test lfs find with -name
4455 for i in $(seq 1 $NUMFILES) ; do
4456 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4457 [ $NUMS -eq $EXPECTED ] ||
4458 error "lfs find -name \"*$i\" $TDIR wrong: "\
4459 "found $NUMS, expected $EXPECTED"
4462 run_test 56g "check lfs find -name ============================="
4468 setup_56 $NUMFILES $NUMDIRS
4470 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4471 # test lfs find with ! -name
4472 for i in $(seq 1 $NUMFILES) ; do
4473 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4474 [ $NUMS -eq $EXPECTED ] ||
4475 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4476 "found $NUMS, expected $EXPECTED"
4479 run_test 56h "check lfs find ! -name ============================="
4483 test_mkdir -p $DIR/$tdir
4484 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4485 CMD="$LFIND -ost $UUID $DIR/$tdir"
4487 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4489 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4493 setup_56_special $NUMFILES $NUMDIRS
4495 EXPECTED=$((NUMDIRS + 1))
4496 CMD="$LFIND -type d $TDIR"
4497 NUMS=$($CMD | wc -l)
4498 [ $NUMS -eq $EXPECTED ] ||
4499 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4501 run_test 56j "check lfs find -type d ============================="
4505 setup_56_special $NUMFILES $NUMDIRS
4507 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4508 CMD="$LFIND -type f $TDIR"
4509 NUMS=$($CMD | wc -l)
4510 [ $NUMS -eq $EXPECTED ] ||
4511 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4513 run_test 56k "check lfs find -type f ============================="
4517 setup_56_special $NUMFILES $NUMDIRS
4519 EXPECTED=$((NUMDIRS + NUMFILES))
4520 CMD="$LFIND -type b $TDIR"
4521 NUMS=$($CMD | wc -l)
4522 [ $NUMS -eq $EXPECTED ] ||
4523 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4525 run_test 56l "check lfs find -type b ============================="
4529 setup_56_special $NUMFILES $NUMDIRS
4531 EXPECTED=$((NUMDIRS + NUMFILES))
4532 CMD="$LFIND -type c $TDIR"
4533 NUMS=$($CMD | wc -l)
4534 [ $NUMS -eq $EXPECTED ] ||
4535 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4537 run_test 56m "check lfs find -type c ============================="
4541 setup_56_special $NUMFILES $NUMDIRS
4543 EXPECTED=$((NUMDIRS + NUMFILES))
4544 CMD="$LFIND -type l $TDIR"
4545 NUMS=$($CMD | wc -l)
4546 [ $NUMS -eq $EXPECTED ] ||
4547 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4549 run_test 56n "check lfs find -type l ============================="
4553 setup_56 $NUMFILES $NUMDIRS
4554 utime $TDIR/file1 > /dev/null || error "utime (1)"
4555 utime $TDIR/file2 > /dev/null || error "utime (2)"
4556 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4557 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4558 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4559 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4562 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4563 [ $NUMS -eq $EXPECTED ] || \
4564 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4567 CMD="$LFIND -mtime 0 $TDIR"
4568 NUMS=$($CMD | wc -l)
4569 [ $NUMS -eq $EXPECTED ] ||
4570 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4572 run_test 56o "check lfs find -mtime for old files =========================="
4575 [ $RUNAS_ID -eq $UID ] &&
4576 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4579 setup_56 $NUMFILES $NUMDIRS
4581 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4583 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4584 NUMS=$($CMD | wc -l)
4585 [ $NUMS -eq $EXPECTED ] || \
4586 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4588 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4589 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4590 NUMS=$($CMD | wc -l)
4591 [ $NUMS -eq $EXPECTED ] || \
4592 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4594 run_test 56p "check lfs find -uid and ! -uid ==============================="
4597 [ $RUNAS_ID -eq $UID ] &&
4598 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4601 setup_56 $NUMFILES $NUMDIRS
4603 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4606 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4607 NUMS=$($CMD | wc -l)
4608 [ $NUMS -eq $EXPECTED ] ||
4609 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4611 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4612 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4613 NUMS=$($CMD | wc -l)
4614 [ $NUMS -eq $EXPECTED ] ||
4615 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4617 run_test 56q "check lfs find -gid and ! -gid ==============================="
4621 setup_56 $NUMFILES $NUMDIRS
4624 CMD="$LFIND -size 0 -type f $TDIR"
4625 NUMS=$($CMD | wc -l)
4626 [ $NUMS -eq $EXPECTED ] ||
4627 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4629 CMD="$LFIND ! -size 0 -type f $TDIR"
4630 NUMS=$($CMD | wc -l)
4631 [ $NUMS -eq $EXPECTED ] ||
4632 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4633 echo "test" > $TDIR/$tfile
4634 echo "test2" > $TDIR/$tfile.2 && sync
4636 CMD="$LFIND -size 5 -type f $TDIR"
4637 NUMS=$($CMD | wc -l)
4638 [ $NUMS -eq $EXPECTED ] ||
4639 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4641 CMD="$LFIND -size +5 -type f $TDIR"
4642 NUMS=$($CMD | wc -l)
4643 [ $NUMS -eq $EXPECTED ] ||
4644 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4646 CMD="$LFIND -size +0 -type f $TDIR"
4647 NUMS=$($CMD | wc -l)
4648 [ $NUMS -eq $EXPECTED ] ||
4649 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4651 CMD="$LFIND ! -size -5 -type f $TDIR"
4652 NUMS=$($CMD | wc -l)
4653 [ $NUMS -eq $EXPECTED ] ||
4654 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4656 CMD="$LFIND -size -5 -type f $TDIR"
4657 NUMS=$($CMD | wc -l)
4658 [ $NUMS -eq $EXPECTED ] ||
4659 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4661 run_test 56r "check lfs find -size works =========================="
4663 test_56s() { # LU-611
4665 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4667 if [[ $OSTCOUNT -gt 1 ]]; then
4668 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4672 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4676 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4677 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4678 NUMS=$($CMD | wc -l)
4679 [ $NUMS -eq $EXPECTED ] || {
4681 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4684 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4685 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4686 NUMS=$($CMD | wc -l)
4687 [ $NUMS -eq $EXPECTED ] || {
4689 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4693 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4694 NUMS=$($CMD | wc -l)
4695 [ $NUMS -eq $EXPECTED ] || {
4697 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4700 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4701 NUMS=$($CMD | wc -l)
4702 [ $NUMS -eq $EXPECTED ] || {
4704 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4708 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4709 NUMS=$($CMD | wc -l)
4710 [ $NUMS -eq $EXPECTED ] || {
4712 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4715 run_test 56s "check lfs find -stripe-count works"
4717 test_56t() { # LU-611
4719 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4721 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4723 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4724 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4725 NUMS=$($CMD | wc -l)
4726 [ $NUMS -eq $EXPECTED ] ||
4727 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4729 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4730 NUMS=$($CMD | wc -l)
4731 [ $NUMS -eq $EXPECTED ] ||
4732 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4734 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4735 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4736 NUMS=$($CMD | wc -l)
4737 [ $NUMS -eq $EXPECTED ] ||
4738 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4740 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4741 NUMS=$($CMD | wc -l)
4742 [ $NUMS -eq $EXPECTED ] ||
4743 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4746 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4747 NUMS=$($CMD | wc -l)
4748 [ $NUMS -eq $EXPECTED ] ||
4749 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4751 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4752 NUMS=$($CMD | wc -l)
4753 [ $NUMS -eq $EXPECTED ] ||
4754 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4757 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4758 NUMS=$($CMD | wc -l)
4759 [ $NUMS -eq $EXPECTED ] ||
4760 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4762 run_test 56t "check lfs find -stripe-size works"
4764 test_56u() { # LU-611
4766 setup_56 $NUMFILES $NUMDIRS "-i 0"
4768 if [[ $OSTCOUNT -gt 1 ]]; then
4769 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4775 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4776 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4777 NUMS=$($CMD | wc -l)
4778 [ $NUMS -eq $EXPECTED ] ||
4779 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4782 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4783 NUMS=$($CMD | wc -l)
4784 [ $NUMS -eq $EXPECTED ] ||
4785 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4787 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4788 NUMS=$($CMD | wc -l)
4789 [ $NUMS -eq $EXPECTED ] ||
4790 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4793 # This should produce an error and not return any files
4794 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4795 NUMS=$($CMD 2>/dev/null | wc -l)
4796 [ $NUMS -eq $EXPECTED ] ||
4797 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4799 if [[ $OSTCOUNT -gt 1 ]]; then
4800 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4801 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4802 NUMS=$($CMD | wc -l)
4803 [ $NUMS -eq $EXPECTED ] ||
4804 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4807 run_test 56u "check lfs find -stripe-index works"
4814 setup_56 $NUMFILES $NUMDIRS
4816 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4817 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4819 for file in $($LFIND -mdt $UUID $TDIR); do
4820 file_mdt_idx=$($GETSTRIPE -M $file)
4821 [ $file_mdt_idx -eq $MDT_IDX ] ||
4822 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4825 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4828 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4833 rm -rf $TDIR || error "remove $TDIR failed"
4834 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4837 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4838 error "$GETSTRIPE -S -d $TDIR failed"
4839 stripe_size=${stripe_size%% *}
4841 local file_size=$((stripe_size * OSTCOUNT))
4842 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4843 local required_space=$((file_num * file_size))
4844 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4845 [[ $free_space -le $((required_space / 1024)) ]] &&
4846 skip_env "need at least $required_space bytes free space," \
4847 "have $free_space kbytes" && return
4850 local dd_count=$((file_size / dd_bs))
4852 # write data into the files
4856 for i in $(seq 1 $NUMFILES); do
4858 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4859 error "write data into $file failed"
4861 for i in $(seq 1 $NUMDIRS); do
4862 for j in $(seq 1 $NUMFILES); do
4863 file=$TDIR/dir$i/file$j
4864 yes | dd bs=$dd_bs count=$dd_count of=$file \
4866 error "write data into $file failed"
4871 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4874 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4876 eval $cmd || error "$cmd failed"
4878 check_stripe_count $TDIR/file1 $expected
4880 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4882 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4883 # OST 1 if it is on OST 0. This file is small enough to
4884 # be on only one stripe.
4885 file=$TDIR/migr_1_ost
4886 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4887 error "write data into $file failed"
4888 local obdidx=$($LFS getstripe -i $file)
4889 local oldmd5=$(md5sum $file)
4891 [[ $obdidx -eq 0 ]] && newobdidx=1
4892 cmd="$LFS migrate -i $newobdidx $file"
4894 eval $cmd || error "$cmd failed"
4895 local realobdix=$($LFS getstripe -i $file)
4896 local newmd5=$(md5sum $file)
4897 [[ $newobdidx -ne $realobdix ]] &&
4898 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4899 [[ "$oldmd5" != "$newmd5" ]] &&
4900 error "md5sum differ: $oldmd5, $newmd5"
4904 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4906 eval $cmd || error "$cmd failed"
4908 for j in $(seq 1 $NUMFILES); do
4909 check_stripe_count $TDIR/dir1/file$j $expected
4912 # lfs_migrate works with lfs find
4913 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4914 $LFS_MIGRATE -y -c $expected"
4916 eval $cmd || error "$cmd failed"
4918 for i in $(seq 2 $NUMFILES); do
4919 check_stripe_count $TDIR/file$i $expected
4921 for i in $(seq 2 $NUMDIRS); do
4922 for j in $(seq 1 $NUMFILES); do
4923 check_stripe_count $TDIR/dir$i/file$j $expected
4927 run_test 56w "check lfs_migrate -c stripe_count works"
4930 check_swap_layouts_support && return 0
4931 [[ $OSTCOUNT -lt 2 ]] &&
4932 skip_env "need 2 OST, skipping test" && return
4934 local dir0=$DIR/$tdir/$testnum
4935 mkdir -p $dir0 || error "creating dir $dir0"
4937 local ref1=/etc/passwd
4938 local file1=$dir0/file1
4940 $SETSTRIPE -c 2 $file1
4942 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4943 stripe=$($GETSTRIPE -c $file1)
4944 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4945 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4950 run_test 56x "lfs migration support"
4953 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4954 skip "No HSM support on MDS of $(get_lustre_version)," \
4955 "need 2.4.53 at least" && return
4958 local dir0=$DIR/$tdir/$testnum
4959 mkdir -p $dir0 || error "creating dir $dir0"
4960 local f1=$dir0/file1
4961 local f2=$dir0/file2
4963 touch $f1 || error "creating std file $f1"
4964 $MULTIOP $f2 H2c || error "creating released file $f2"
4966 # a directory can be raid0, so ask only for files
4967 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4968 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4970 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4971 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4973 # only files can be released, so no need to force file search
4974 res=$($LFIND $dir0 -L released)
4975 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4977 res=$($LFIND $dir0 \! -L released)
4978 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4981 run_test 56y "lfs find -L raid0|released"
4983 test_56z() { # LU-4824
4984 # This checks to make sure 'lfs find' continues after errors
4985 # There are two classes of errors that should be caught:
4986 # - If multiple paths are provided, all should be searched even if one
4988 # - If errors are encountered during the search, it should not terminate
4991 test_mkdir $DIR/$tdir
4992 for i in d{0..9}; do
4993 test_mkdir $DIR/$tdir/$i
4995 touch $DIR/$tdir/d{0..9}/$tfile
4996 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
4997 error "$LFS find did not return an error"
4998 # Make a directory unsearchable. This should NOT be the last entry in
4999 # directory order. Arbitrarily pick the 6th entry
5000 chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
5001 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5002 # The user should be able to see 10 directories and 9 files
5003 [ $count == 19 ] || error "$LFS find did not continue after error"
5005 run_test 56z "lfs find should continue after an error"
5008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5009 # note test will not do anything if MDS is not local
5010 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5011 skip "Only applicable to ldiskfs-based MDTs"
5015 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5016 local MNTDEV="osd*.*MDT*.mntdev"
5017 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5018 [ -z "$DEV" ] && error "can't access $MNTDEV"
5019 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5020 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5021 error "can't access $DEV"
5022 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5023 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5027 run_test 57a "verify MDS filesystem created with large inodes =="
5030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5031 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5032 skip "Only applicable to ldiskfs-based MDTs"
5036 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5037 local dir=$DIR/$tdir
5041 local FILEN=$dir/f$FILECOUNT
5043 rm -rf $dir || error "removing $dir"
5044 test_mkdir -p -c1 $dir || error "creating $dir"
5045 local mdtidx=$($LFS getstripe -M $dir)
5046 local mdtname=MDT$(printf %04x $mdtidx)
5047 local facet=mds$((mdtidx + 1))
5049 echo "mcreating $FILECOUNT files"
5050 createmany -m $dir/f 1 $FILECOUNT || \
5051 error "creating files in $dir"
5053 # verify that files do not have EAs yet
5054 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5055 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5059 df $dir #make sure we get new statfs data
5060 local MDSFREE=$(do_facet $facet \
5061 lctl get_param -n osd*.*$mdtname.kbytesfree)
5062 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5063 echo "opening files to create objects/EAs"
5065 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5066 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5069 # verify that files have EAs now
5070 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5071 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5073 sleep 1 #make sure we get new statfs data
5075 local MDSFREE2=$(do_facet $facet \
5076 lctl get_param -n osd*.*$mdtname.kbytesfree)
5077 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5078 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5079 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5080 error "MDC before $MDCFREE != after $MDCFREE2"
5082 echo "MDC before $MDCFREE != after $MDCFREE2"
5083 echo "unable to confirm if MDS has large inodes"
5088 run_test 57b "default LOV EAs are stored inside large inodes ==="
5091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5092 [ -z "$(which wiretest 2>/dev/null)" ] &&
5093 skip_env "could not find wiretest" && return
5096 run_test 58 "verify cross-platform wire constants =============="
5099 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5100 echo "touch 130 files"
5101 createmany -o $DIR/f59- 130
5103 unlinkmany $DIR/f59- 130
5105 # wait for commitment of removal
5106 wait_delete_completed
5108 run_test 59 "verify cancellation of llog records async ========="
5110 TEST60_HEAD="test_60 run $RANDOM"
5112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5113 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5114 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5115 skip_env "missing subtest run-llog.sh" && return
5116 log "$TEST60_HEAD - from kernel mode"
5117 do_facet mgs sh run-llog.sh
5119 run_test 60a "llog sanity tests run from kernel module =========="
5121 test_60b() { # bug 6411
5122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5124 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5136 [[ $LLOG_COUNT -gt 50 ]] &&
5137 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5139 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5143 echo "create 5000 files"
5144 createmany -o $DIR/f60c- 5000
5145 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5146 lctl set_param fail_loc=0x80000137
5147 unlinkmany $DIR/f60c- 5000
5148 lctl set_param fail_loc=0
5150 run_test 60c "unlink file when mds full"
5153 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5154 SAVEPRINTK=$(lctl get_param -n printk)
5156 # verify "lctl mark" is even working"
5157 MESSAGE="test message ID $RANDOM $$"
5158 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5159 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5161 lctl set_param printk=0 || error "set lnet.printk failed"
5162 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5163 MESSAGE="new test message ID $RANDOM $$"
5164 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5165 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5166 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5168 lctl set_param -n printk="$SAVEPRINTK"
5170 run_test 60d "test printk console message masking"
5173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5175 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5176 cancel_lru_locks osc
5177 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5180 run_test 61 "mmap() writes don't make sync hang ================"
5182 # bug 2330 - insufficient obd_match error checking causes LBUG
5184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5187 cancel_lru_locks osc
5188 lctl set_param fail_loc=0x405
5189 cat $f && error "cat succeeded, expect -EIO"
5190 lctl set_param fail_loc=0
5192 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5193 # match every page all of the time.
5194 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5196 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5197 # Though this test is irrelevant anymore, it helped to reveal some
5198 # other grant bugs (LU-4482), let's keep it.
5199 test_63a() { # was test_63
5200 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5201 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5202 for i in `seq 10` ; do
5203 dd if=/dev/zero of=$DIR/f63 bs=8k &
5209 rm -f $DIR/f63 || true
5211 run_test 63a "Verify oig_wait interruption does not crash ======="
5213 # bug 2248 - async write errors didn't return to application on sync
5214 # bug 3677 - async write errors left page locked
5216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5218 lctl set_param debug=-1
5220 # ensure we have a grant to do async writes
5221 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5224 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5225 lctl set_param fail_loc=0x80000406
5226 $MULTIOP $DIR/$tfile Owy && \
5227 error "sync didn't return ENOMEM"
5228 sync; sleep 2; sync # do a real sync this time to flush page
5229 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5230 error "locked page left in cache after async error" || true
5233 run_test 63b "async write errors should be returned to fsync ==="
5236 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5238 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5240 run_test 64a "verify filter grant calculations (in kernel) ====="
5243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5244 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5246 run_test 64b "check out-of-space detection on client ==========="
5249 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5251 run_test 64c "verify grant shrink ========================------"
5253 # bug 1414 - set/get directories' stripe info
5255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5256 test_mkdir -p $DIR/$tdir
5258 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5260 run_test 65a "directory with no stripe info ===================="
5263 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5264 test_mkdir -p $DIR/$tdir
5265 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5268 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5270 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5274 if [[ $OSTCOUNT -gt 1 ]]; then
5275 test_mkdir -p $DIR/$tdir
5276 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5277 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5279 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5282 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5285 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5286 test_mkdir -p $DIR/$tdir
5287 if [[ $STRIPECOUNT -le 0 ]]; then
5289 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5290 #LOV_MAX_STRIPE_COUNT is 2000
5291 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5293 sc=$(($STRIPECOUNT - 1))
5295 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5296 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5297 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5298 error "lverify failed"
5300 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5303 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5304 test_mkdir -p $DIR/$tdir
5306 $SETSTRIPE $DIR/$tdir || error "setstripe"
5307 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5308 error "no stripe info failed"
5310 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5312 run_test 65e "directory setstripe defaults ======================="
5315 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5316 test_mkdir -p $DIR/${tdir}f
5317 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5319 run_test 65f "dir setstripe permission (should return error) ==="
5322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5323 test_mkdir -p $DIR/$tdir
5324 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5326 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5327 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5328 error "delete default stripe failed"
5330 run_test 65g "directory setstripe -d ==========================="
5333 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5334 test_mkdir -p $DIR/$tdir
5335 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5337 test_mkdir -p $DIR/$tdir/dd1
5338 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5339 error "stripe info inherit failed"
5341 run_test 65h "directory stripe info inherit ===================="
5343 test_65i() { # bug6367
5344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5345 $SETSTRIPE -S 65536 -c -1 $MOUNT
5347 run_test 65i "set non-default striping on root directory (bug 6367)="
5349 test_65ia() { # bug12836
5350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5351 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5353 run_test 65ia "getstripe on -1 default directory striping"
5355 test_65ib() { # bug12836
5356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5357 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5359 run_test 65ib "getstripe -v on -1 default directory striping"
5361 test_65ic() { # bug12836
5362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5363 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5365 run_test 65ic "new find on -1 default directory striping"
5367 test_65j() { # bug6367
5368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5370 # if we aren't already remounting for each test, do so for this test
5371 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5372 cleanup || error "failed to unmount"
5375 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5377 run_test 65j "set default striping on root directory (bug 6367)="
5379 test_65k() { # bug11679
5380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5381 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5382 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5384 echo "Check OST status: "
5385 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5386 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5388 for OSC in $MDS_OSCS; do
5389 echo $OSC "is activate"
5390 do_facet $SINGLEMDS lctl --device %$OSC activate
5394 for INACTIVE_OSC in $MDS_OSCS; do
5395 echo "Deactivate: " $INACTIVE_OSC
5396 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5397 for STRIPE_OSC in $MDS_OSCS; do
5398 OST=`osc_to_ost $STRIPE_OSC`
5399 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5400 awk -F: /$OST/'{ print $1 }' | head -n 1`
5402 [ -f $DIR/$tdir/$IDX ] && continue
5403 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5404 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5406 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5409 echo $INACTIVE_OSC "is Activate."
5410 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5413 run_test 65k "validate manual striping works properly with deactivated OSCs"
5415 test_65l() { # bug 12836
5416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5417 test_mkdir -p $DIR/$tdir/test_dir
5418 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5419 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5421 run_test 65l "lfs find on -1 stripe dir ========================"
5423 # bug 2543 - update blocks count on client
5425 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5427 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5428 sync; sync_all_data; sync; sync_all_data
5429 cancel_lru_locks osc
5430 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5431 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5433 run_test 66 "update inode blocks count on client ==============="
5438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5440 if [ ! -z "$LLOOP" ]; then
5441 if swapon -s | grep -q $LLOOP; then
5442 swapoff $LLOOP || error "swapoff failed"
5445 $LCTL blockdev_detach $LLOOP || error "detach failed"
5449 if [ ! -z "$LLITELOOPLOAD" ]; then
5457 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5461 swapon -s | awk '($1 == "'$1'") { print $4 }'
5464 # test case for lloop driver, basic function
5466 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5467 [ "$UID" != 0 ] && skip_env "must run as root" && return
5468 llite_lloop_enabled || \
5469 { skip_env "llite_lloop module disabled" && return; }
5471 trap cleanup_68 EXIT
5473 if ! module_loaded llite_lloop; then
5474 if load_module llite/llite_lloop; then
5477 skip_env "can't find module llite_lloop"
5482 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5483 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5484 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5486 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5487 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5491 run_test 68a "lloop driver - basic test ========================"
5493 # excercise swapping to lustre by adding a high priority swapfile entry
5494 # and then consuming memory until it is used.
5495 test_68b() { # was test_68
5496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5497 [ "$UID" != 0 ] && skip_env "must run as root" && return
5498 lctl get_param -n devices | grep -q obdfilter && \
5499 skip "local OST" && return
5501 grep -q llite_lloop /proc/modules
5502 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5504 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5505 skip "can't reliably test swap with TCP" && return
5507 MEMTOTAL=`meminfo MemTotal`
5508 NR_BLOCKS=$((MEMTOTAL>>8))
5509 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5511 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5512 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5515 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5517 trap cleanup_68 EXIT
5519 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5521 echo "before: `swapon -s | grep $LLOOP`"
5522 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5523 echo "after: `swapon -s | grep $LLOOP`"
5524 SWAPUSED=`swap_used $LLOOP`
5528 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5530 run_test 68b "support swapping to Lustre ========================"
5532 # bug5265, obdfilter oa2dentry return -ENOENT
5533 # #define OBD_FAIL_OST_ENOENT 0x217
5535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5536 remote_ost_nodsh && skip "remote OST with nodsh" && return
5539 $SETSTRIPE -c 1 -i 0 $f
5541 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5543 do_facet ost1 lctl set_param fail_loc=0x217
5544 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5545 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5547 do_facet ost1 lctl set_param fail_loc=0
5548 $DIRECTIO write $f 0 2 || error "write error"
5550 cancel_lru_locks osc
5551 $DIRECTIO read $f 0 1 || error "read error"
5553 do_facet ost1 lctl set_param fail_loc=0x217
5554 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5556 do_facet ost1 lctl set_param fail_loc=0
5559 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5562 test_mkdir -p $DIR/$tdir
5563 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5565 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5567 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5568 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5569 [ "$RUNAS_ID" = "$UID" ] &&
5570 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5572 # Check that testing environment is properly set up. Skip if not
5573 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5574 skip_env "User $RUNAS_ID does not exist - skipping"
5578 chmod 777 $DIR/$tfile
5579 chmod ug+s $DIR/$tfile
5580 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5581 error "$RUNAS dd $DIR/$tfile failed"
5582 # See if we are still setuid/sgid
5583 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5584 error "S/gid is not dropped on write"
5585 # Now test that MDS is updated too
5586 cancel_lru_locks mdc
5587 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5588 error "S/gid is not dropped on MDS"
5591 run_test 72a "Test that remove suid works properly (bug5695) ===="
5593 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5596 [ "$RUNAS_ID" = "$UID" ] && \
5597 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5598 [ "$RUNAS_ID" -eq 0 ] && \
5599 skip_env "RUNAS_ID = 0 -- skipping" && return
5601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5602 # Check that testing environment is properly set up. Skip if not
5603 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5604 skip_env "User $RUNAS_ID does not exist - skipping"
5607 touch $DIR/${tfile}-f{g,u}
5608 test_mkdir $DIR/${tfile}-dg
5609 test_mkdir $DIR/${tfile}-du
5610 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5611 chmod g+s $DIR/${tfile}-{f,d}g
5612 chmod u+s $DIR/${tfile}-{f,d}u
5613 for perm in 777 2777 4777; do
5614 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5615 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5616 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5617 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5621 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5623 # bug 3462 - multiple simultaneous MDC requests
5625 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5626 test_mkdir $DIR/d73-1
5627 test_mkdir $DIR/d73-2
5628 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5631 lctl set_param fail_loc=0x80000129
5632 $MULTIOP $DIR/d73-1/f73-2 Oc &
5634 lctl set_param fail_loc=0
5636 $MULTIOP $DIR/d73-2/f73-3 Oc &
5640 wait $pid1 || return 1
5644 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5645 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5646 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5650 run_test 73 "multiple MDC requests (should not deadlock)"
5652 test_74a() { # bug 6149, 6184
5653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5654 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5656 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5657 # will spin in a tight reconnection loop
5659 $LCTL set_param fail_loc=0x8000030e
5660 # get any lock that won't be difficult - lookup works.
5662 $LCTL set_param fail_loc=0
5666 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5668 test_74b() { # bug 13310
5669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5670 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5672 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5673 # will spin in a tight reconnection loop
5674 $LCTL set_param fail_loc=0x8000030e
5675 # get a "difficult" lock
5677 $LCTL set_param fail_loc=0
5681 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5684 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5685 #define OBD_FAIL_LDLM_NEW_LOCK
5686 $LCTL set_param fail_loc=0x319
5687 touch $DIR/$tfile && error "touch successful"
5688 $LCTL set_param fail_loc=0
5691 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5694 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5697 get_inode_slab_tunables() {
5698 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5701 set_inode_slab_tunables() {
5702 echo "lustre_inode_cache $1" > /proc/slabinfo
5705 test_76() { # Now for bug 20433, added originally in bug 1443
5706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5707 local SLAB_SETTINGS=`get_inode_slab_tunables`
5708 local CPUS=`getconf _NPROCESSORS_ONLN`
5709 # we cannot set limit below 1 which means 1 inode in each
5710 # per-cpu cache is still allowed
5711 set_inode_slab_tunables "1 1 0"
5712 cancel_lru_locks osc
5713 BEFORE_INODES=$(num_inodes)
5714 echo "before inodes: $BEFORE_INODES"
5716 [ "$SLOW" = "no" ] && COUNT=100
5717 for i in $(seq $COUNT); do
5721 cancel_lru_locks osc
5722 AFTER_INODES=$(num_inodes)
5723 echo "after inodes: $AFTER_INODES"
5725 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5727 AFTER_INODES=$(num_inodes)
5729 echo "wait $wait seconds inodes: $AFTER_INODES"
5730 if [ $wait -gt 30 ]; then
5731 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5734 set_inode_slab_tunables "$SLAB_SETTINGS"
5736 run_test 76 "confirm clients recycle inodes properly ===="
5742 # Note: in sptlrpc modes which enable its own bulk checksum, the
5743 # original crc32_le bulk checksum will be automatically disabled,
5744 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5745 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5746 # In this case set_checksums() will not be no-op, because sptlrpc
5747 # bulk checksum will be enabled all through the test.
5749 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5750 lctl set_param -n osc.*.checksums $1
5754 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5755 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5756 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5757 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5760 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5761 log "set checksum type to $1"
5764 F77_TMP=$TMP/f77-temp
5767 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5768 error "error writing to $F77_TMP"
5771 test_77a() { # bug 10889
5772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5773 $GSS && skip "could not run with gss" && return
5774 [ ! -f $F77_TMP ] && setup_f77
5776 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5780 run_test 77a "normal checksum read/write operation"
5782 test_77b() { # bug 10889
5783 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5784 $GSS && skip "could not run with gss" && return
5785 [ ! -f $F77_TMP ] && setup_f77
5786 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5787 $LCTL set_param fail_loc=0x80000409
5790 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5791 error "dd error: $?"
5792 $LCTL set_param fail_loc=0
5794 for algo in $CKSUM_TYPES; do
5795 cancel_lru_locks osc
5796 set_checksum_type $algo
5797 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5798 $LCTL set_param fail_loc=0x80000408
5799 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5800 $LCTL set_param fail_loc=0
5803 set_checksum_type $ORIG_CSUM_TYPE
5806 run_test 77b "checksum error on client write, read"
5808 test_77d() { # bug 10889
5809 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5810 $GSS && skip "could not run with gss" && return
5811 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5812 $LCTL set_param fail_loc=0x80000409
5814 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5815 error "direct write: rc=$?"
5816 $LCTL set_param fail_loc=0
5819 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5820 $LCTL set_param fail_loc=0x80000408
5822 cancel_lru_locks osc
5823 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5824 error "direct read: rc=$?"
5825 $LCTL set_param fail_loc=0
5828 run_test 77d "checksum error on OST direct write, read"
5830 test_77f() { # bug 10889
5831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5832 $GSS && skip "could not run with gss" && return
5834 for algo in $CKSUM_TYPES; do
5835 cancel_lru_locks osc
5836 set_checksum_type $algo
5837 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5838 $LCTL set_param fail_loc=0x409
5839 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5840 error "direct write succeeded"
5841 $LCTL set_param fail_loc=0
5843 set_checksum_type $ORIG_CSUM_TYPE
5846 run_test 77f "repeat checksum error on write (expect error)"
5848 test_77g() { # bug 10889
5849 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5850 $GSS && skip "could not run with gss" && return
5851 remote_ost_nodsh && skip "remote OST with nodsh" && return
5853 [ ! -f $F77_TMP ] && setup_f77
5855 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5856 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5857 do_facet ost1 lctl set_param fail_loc=0x8000021a
5859 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5860 error "write error: rc=$?"
5861 do_facet ost1 lctl set_param fail_loc=0
5864 cancel_lru_locks osc
5865 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5866 do_facet ost1 lctl set_param fail_loc=0x8000021b
5868 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5869 do_facet ost1 lctl set_param fail_loc=0
5872 run_test 77g "checksum error on OST write, read"
5874 test_77i() { # bug 13805
5875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5876 $GSS && skip "could not run with gss" && return
5877 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5878 lctl set_param fail_loc=0x40b
5879 remount_client $MOUNT
5880 lctl set_param fail_loc=0
5881 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5882 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5883 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5884 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5886 remount_client $MOUNT
5888 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5890 test_77j() { # bug 13805
5891 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5892 $GSS && skip "could not run with gss" && return
5893 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5894 lctl set_param fail_loc=0x40c
5895 remount_client $MOUNT
5896 lctl set_param fail_loc=0
5897 sleep 2 # wait async osc connect to finish
5898 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5899 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5900 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5901 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5903 remount_client $MOUNT
5905 run_test 77j "client only supporting ADLER32"
5907 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5911 test_78() { # bug 10901
5912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5913 remote_ost || { skip_env "local OST" && return; }
5916 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5917 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5918 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5919 echo "MemTotal: $MEMTOTAL"
5921 # reserve 256MB of memory for the kernel and other running processes,
5922 # and then take 1/2 of the remaining memory for the read/write buffers.
5923 if [ $MEMTOTAL -gt 512 ] ;then
5924 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5926 # for those poor memory-starved high-end clusters...
5927 MEMTOTAL=$((MEMTOTAL / 2))
5929 echo "Mem to use for directio: $MEMTOTAL"
5931 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5932 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5933 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5934 SMALLESTOST=$(lfs df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5936 echo "Smallest OST: $SMALLESTOST"
5937 [[ $SMALLESTOST -lt 10240 ]] &&
5938 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5940 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5941 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5943 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5944 echo "File size: $F78SIZE"
5945 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5946 for i in $(seq 1 $NSEQ); do
5947 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5948 echo directIO rdwr round $i of $NSEQ
5949 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5954 run_test 78 "handle large O_DIRECT writes correctly ============"
5956 test_79() { # bug 12743
5957 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5958 wait_delete_completed
5960 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5961 BKFREE=$(calc_osc_kbytes kbytesfree)
5962 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5964 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5965 DFTOTAL=`echo $STRING | cut -d, -f1`
5966 DFUSED=`echo $STRING | cut -d, -f2`
5967 DFAVAIL=`echo $STRING | cut -d, -f3`
5968 DFFREE=$(($DFTOTAL - $DFUSED))
5970 ALLOWANCE=$((64 * $OSTCOUNT))
5972 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5973 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5974 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5976 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5977 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5978 error "df free($DFFREE) mismatch OST free($BKFREE)"
5980 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5981 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5982 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5985 run_test 79 "df report consistency check ======================="
5987 test_80() { # bug 10718
5988 remote_ost_nodsh && skip "remote OST with nodsh" && return
5989 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5990 # relax strong synchronous semantics for slow backends like ZFS
5991 local soc="obdfilter.*.sync_on_lock_cancel"
5992 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5994 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5995 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5996 facet_active_host $host; done | sort -u)
5997 do_nodes $hosts lctl set_param $soc=never
6000 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6002 local BEFORE=`date +%s`
6003 cancel_lru_locks osc
6004 local AFTER=`date +%s`
6005 local DIFF=$((AFTER-BEFORE))
6006 if [ $DIFF -gt 1 ] ; then
6007 error "elapsed for 1M@1T = $DIFF"
6010 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6014 run_test 80 "Page eviction is equally fast at high offsets too ===="
6016 test_81a() { # LU-456
6017 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6018 remote_ost_nodsh && skip "remote OST with nodsh" && return
6019 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6020 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6021 do_facet ost1 lctl set_param fail_loc=0x80000228
6023 # write should trigger a retry and success
6024 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6025 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6027 if [ $RC -ne 0 ] ; then
6028 error "write should success, but failed for $RC"
6031 run_test 81a "OST should retry write when get -ENOSPC ==============="
6033 test_81b() { # LU-456
6034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6035 remote_ost_nodsh && skip "remote OST with nodsh" && return
6036 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6037 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6038 do_facet ost1 lctl set_param fail_loc=0x228
6040 # write should retry several times and return -ENOSPC finally
6041 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6042 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6045 if [ $RC -ne $ENOSPC ] ; then
6046 error "dd should fail for -ENOSPC, but succeed."
6049 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6051 test_82() { # LU-1031
6052 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6056 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6058 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6060 kill -USR1 $MULTIPID2
6062 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6063 error "First grouplock does not block second one"
6065 echo "Second grouplock blocks first one"
6067 kill -USR1 $MULTIPID1
6071 run_test 82 "Basic grouplock test ==============================="
6074 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6076 test_mkdir -p $DIR/d99cvsroot
6077 chown $RUNAS_ID $DIR/d99cvsroot
6078 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6081 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6084 run_test 99a "cvs init ========================================="
6087 [ -z "$(which cvs 2>/dev/null)" ] &&
6088 skip_env "could not find cvs" && return
6089 [ ! -d $DIR/d99cvsroot ] && test_99a
6091 # some versions of cvs import exit(1) when asked to import links or
6092 # files they can't read. ignore those files.
6093 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6094 ! -perm +4 -printf '-I %f\n')
6095 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6096 d99reposname vtag rtag
6098 run_test 99b "cvs import ======================================="
6101 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6102 [ ! -d $DIR/d99cvsroot ] && test_99b
6104 test_mkdir -p $DIR/d99reposname
6105 chown $RUNAS_ID $DIR/d99reposname
6106 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6108 run_test 99c "cvs checkout ====================================="
6111 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6112 [ ! -d $DIR/d99cvsroot ] && test_99c
6113 cd $DIR/d99reposname
6115 $RUNAS cvs add -m 'addmsg' foo99
6117 run_test 99d "cvs add =========================================="
6120 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6121 [ ! -d $DIR/d99cvsroot ] && test_99c
6122 cd $DIR/d99reposname
6125 run_test 99e "cvs update ======================================="
6128 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6129 [ ! -d $DIR/d99cvsroot ] && test_99d
6130 cd $DIR/d99reposname
6131 $RUNAS cvs commit -m 'nomsg' foo99
6132 rm -fr $DIR/d99cvsroot
6134 run_test 99f "cvs commit ======================================="
6137 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6138 [ "$NETTYPE" = tcp ] || \
6139 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6142 remote_ost_nodsh && skip "remote OST with nodsh" && return
6143 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6145 { skip "useless for local single node setup" && return; }
6147 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6148 [ "$PROT" != "tcp" ] && continue
6149 RPORT=$(echo $REMOTE | cut -d: -f2)
6150 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6153 LPORT=`echo $LOCAL | cut -d: -f2`
6154 if [ $LPORT -ge 1024 ]; then
6155 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6157 error_exit "local: $LPORT > 1024, remote: $RPORT"
6160 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6162 run_test 100 "check local port using privileged port ==========="
6164 function get_named_value()
6173 echo $line | sed "s/^$tag[ ]*//"
6180 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6181 awk '/^max_cached_mb/ { print $2 }')
6184 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6189 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6190 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6194 local cache_limit=32
6196 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6197 trap cleanup_101a EXIT
6198 $LCTL set_param -n llite.*.read_ahead_stats 0
6199 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6202 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6204 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6205 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6208 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6209 get_named_value 'read but discarded' | cut -d" " -f1); do
6210 discard=$(($discard + $s))
6214 if [[ $(($discard * 10)) -gt $nreads ]]; then
6215 $LCTL get_param osc.*-osc*.rpc_stats
6216 $LCTL get_param llite.*.read_ahead_stats
6217 error "too many ($discard) discarded pages"
6219 rm -f $DIR/$tfile || true
6221 run_test 101a "check read-ahead for random reads ================"
6224 test_mkdir -p $DIR/$tdir
6225 local STRIPE_SIZE=$1
6226 local FILE_LENGTH=$2
6229 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6231 local list=$(comma_list $(osts_nodes))
6232 set_osd_param $list '' read_cache_enable 0
6233 set_osd_param $list '' writethrough_cache_enable 0
6235 trap cleanup_test101bc EXIT
6236 # prepare the read-ahead file
6237 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6239 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6240 count=$FILE_SIZE_MB 2> /dev/null
6244 cleanup_test101bc() {
6249 local list=$(comma_list $(osts_nodes))
6250 set_osd_param $list '' read_cache_enable 1
6251 set_osd_param $list '' writethrough_cache_enable 1
6255 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6260 local STRIPE_SIZE=$2
6261 local FILE_LENGTH=$3
6262 local RA_INC=1048576
6263 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6264 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6265 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6266 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6267 get_named_value 'read but discarded' |
6268 cut -d" " -f1 | calc_total)
6269 if [[ $DISCARD -gt $discard_limit ]]; then
6270 $LCTL get_param llite.*.read_ahead_stats
6271 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6273 echo "Read-ahead success for size ${READ_SIZE}"
6278 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6279 [[ $OSTCOUNT -lt 2 ]] &&
6280 skip_env "skipping stride IO stride-ahead test" && return
6281 local STRIPE_SIZE=1048576
6282 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6283 if [ $SLOW == "yes" ]; then
6284 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6286 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6289 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6291 # prepare the read-ahead file
6292 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6293 cancel_lru_locks osc
6294 for BIDX in 2 4 8 16 32 64 128 256
6296 local BSIZE=$((BIDX*4096))
6297 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6298 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6299 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6300 $LCTL set_param -n llite.*.read_ahead_stats 0
6301 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6302 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6303 cancel_lru_locks osc
6304 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6309 run_test 101b "check stride-io mode read-ahead ================="
6312 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6313 local STRIPE_SIZE=1048576
6314 local FILE_LENGTH=$((STRIPE_SIZE*100))
6318 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6320 cancel_lru_locks osc
6321 $LCTL set_param osc.*.rpc_stats 0
6322 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6323 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6324 local stats=$($LCTL get_param -n $osc_rpc_stats)
6325 local lines=$(echo "$stats" | awk 'END {print NR;}')
6328 if [ $lines -le 20 ]; then
6331 for size in 1 2 4 8; do
6332 local rpc=$(echo "$stats" |
6333 awk '($1 == "'$size':") {print $2; exit; }')
6335 error "Small $((size*4))k read IO $rpc !"
6337 echo "$osc_rpc_stats check passed!"
6342 run_test 101c "check stripe_size aligned read-ahead ================="
6345 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6346 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6351 local file=$DIR/$tfile
6352 local sz_MB=${FILESIZE_101d:-500}
6353 local ra_MB=${READAHEAD_MB:-40}
6355 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6356 [ $free_MB -lt $sz_MB ] &&
6357 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6359 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6360 $SETSTRIPE -c -1 $file || error "setstripe failed"
6362 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6363 echo Cancel LRU locks on lustre client to flush the client cache
6364 cancel_lru_locks osc
6366 echo Disable read-ahead
6367 local old_READAHEAD=$(set_read_ahead 0)
6369 echo Reading the test file $file with read-ahead disabled
6370 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6372 echo Cancel LRU locks on lustre client to flush the client cache
6373 cancel_lru_locks osc
6374 echo Enable read-ahead with ${ra_MB}MB
6375 set_read_ahead $ra_MB
6377 echo Reading the test file $file with read-ahead enabled
6378 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6380 echo "read-ahead disabled time read $raOFF"
6381 echo "read-ahead enabled time read $raON"
6383 set_read_ahead $old_READAHEAD
6385 wait_delete_completed
6387 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6388 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6390 run_test 101d "file read with and without read-ahead enabled"
6393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6394 local file=$DIR/$tfile
6395 local size_KB=500 #KB
6399 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6400 local need_KB=$((count * size_KB))
6401 [[ $free_KB -le $need_KB ]] &&
6402 skip_env "Need free space $need_KB, have $free_KB" && return
6404 echo "Creating $count ${size_KB}K test files"
6405 for ((i = 0; i < $count; i++)); do
6406 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6409 echo "Cancel LRU locks on lustre client to flush the client cache"
6410 cancel_lru_locks osc
6412 echo "Reset readahead stats"
6413 $LCTL set_param -n llite.*.read_ahead_stats 0
6415 for ((i = 0; i < $count; i++)); do
6416 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6419 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6420 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6422 for ((i = 0; i < $count; i++)); do
6423 rm -rf $file.$i 2>/dev/null
6426 #10000 means 20% reads are missing in readahead
6427 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6429 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6431 cleanup_test101f() {
6433 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6434 rm -rf $DIR/$tfile 2>/dev/null
6438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6439 local file=$DIR/$tfile
6442 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6443 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6444 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6445 trap cleanup_test101f EXIT
6447 echo Cancel LRU locks on lustre client to flush the client cache
6448 cancel_lru_locks osc
6450 echo Reset readahead stats
6451 $LCTL set_param -n llite.*.read_ahead_stats 0
6452 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6453 # readahead should read in 2M file on second read, so only miss
6455 echo Random 4K reads on 2M file for 1000 times
6456 $READS -f $file -s 2097152 -b 4096 -n $nreads
6458 echo checking missing pages
6459 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6460 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6462 [ $miss -lt 3 ] || error "misses too much pages!"
6465 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6468 test_mkdir -p $DIR/$tdir
6469 chown $RUNAS_ID $DIR/$tdir
6472 STRIPE_COUNT=$OSTCOUNT
6473 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6475 trap cleanup_test102 EXIT
6477 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6479 for num in 1 2 3 4; do
6480 for count in $(seq 1 $STRIPE_COUNT); do
6481 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6482 local size=`expr $STRIPE_SIZE \* $num`
6483 local file=file"$num-$idx-$count"
6484 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6490 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6496 rm -rf $DIR/d0.sanity/d102
6500 local testfile=$DIR/$tfile
6504 [ "$UID" != 0 ] && skip_env "must run as root" && return
6505 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6506 skip_env "must have user_xattr" && return
6508 [ -z "$(which setfattr 2>/dev/null)" ] &&
6509 skip_env "could not find setfattr" && return
6511 echo "set/get xattr..."
6512 setfattr -n trusted.name1 -v value1 $testfile ||
6513 error "setfattr -n trusted.name1=value1 $testfile failed"
6514 getfattr -n trusted.name1 $testfile 2> /dev/null |
6515 grep "trusted.name1=.value1" ||
6516 error "$testfile missing trusted.name1=value1"
6518 setfattr -n user.author1 -v author1 $testfile ||
6519 error "setfattr -n user.author1=author1 $testfile failed"
6520 getfattr -n user.author1 $testfile 2> /dev/null |
6521 grep "user.author1=.author1" ||
6522 error "$testfile missing trusted.author1=author1"
6525 setfattr -n trusted.name2 -v value2 $testfile ||
6526 error "$testfile unable to set trusted.name2"
6527 setfattr -n trusted.name3 -v value3 $testfile ||
6528 error "$testfile unable to set trusted.name3"
6529 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6530 grep "trusted.name" | wc -l) -eq 3 ] ||
6531 error "$testfile missing 3 trusted.name xattrs"
6533 setfattr -n user.author2 -v author2 $testfile ||
6534 error "$testfile unable to set user.author2"
6535 setfattr -n user.author3 -v author3 $testfile ||
6536 error "$testfile unable to set user.author3"
6537 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6538 grep "user.author" | wc -l) -eq 3 ] ||
6539 error "$testfile missing 3 user.author xattrs"
6541 echo "remove xattr..."
6542 setfattr -x trusted.name1 $testfile ||
6543 error "$testfile error deleting trusted.name1"
6544 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6545 error "$testfile did not delete trusted.name1 xattr"
6547 setfattr -x user.author1 $testfile ||
6548 error "$testfile error deleting user.author1"
6549 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6550 error "$testfile did not delete trusted.name1 xattr"
6552 # b10667: setting lustre special xattr be silently discarded
6553 echo "set lustre special xattr ..."
6554 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6555 error "$testfile allowed setting trusted.lov"
6557 run_test 102a "user xattr test =================================="
6560 [ -z "$(which setfattr 2>/dev/null)" ] &&
6561 skip_env "could not find setfattr" && return
6563 # b10930: get/set/list trusted.lov xattr
6564 echo "get/set/list trusted.lov xattr ..."
6565 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6566 local testfile=$DIR/$tfile
6567 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6568 error "setstripe failed"
6569 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6570 error "getstripe failed"
6571 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6572 error "can't get trusted.lov from $testfile"
6574 local testfile2=${testfile}2
6575 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6576 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6579 setfattr -n trusted.lov -v $value $testfile2
6580 local stripe_size=$($GETSTRIPE -S $testfile2)
6581 local stripe_count=$($GETSTRIPE -c $testfile2)
6582 [[ $stripe_size -eq 65536 ]] ||
6583 error "stripe size $stripe_size != 65536"
6584 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6585 error "stripe count $stripe_count != $STRIPECOUNT"
6588 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6591 [ -z "$(which setfattr 2>/dev/null)" ] &&
6592 skip_env "could not find setfattr" && return
6594 # b10930: get/set/list lustre.lov xattr
6595 echo "get/set/list lustre.lov xattr ..."
6596 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6597 test_mkdir -p $DIR/$tdir
6598 chown $RUNAS_ID $DIR/$tdir
6599 local testfile=$DIR/$tdir/$tfile
6600 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6601 error "setstripe failed"
6602 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6603 error "getstripe failed"
6604 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6605 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6607 local testfile2=${testfile}2
6608 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6609 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6611 $RUNAS $MCREATE $testfile2
6612 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6613 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6614 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6615 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6616 [ $stripe_count -eq $STRIPECOUNT ] ||
6617 error "stripe count $stripe_count != $STRIPECOUNT"
6619 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6621 compare_stripe_info1() {
6622 local stripe_index_all_zero=true
6624 for num in 1 2 3 4; do
6625 for count in $(seq 1 $STRIPE_COUNT); do
6626 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6627 local size=$((STRIPE_SIZE * num))
6628 local file=file"$num-$offset-$count"
6629 stripe_size=$(lfs getstripe -S $PWD/$file)
6630 [[ $stripe_size -ne $size ]] &&
6631 error "$file: size $stripe_size != $size"
6632 stripe_count=$(lfs getstripe -c $PWD/$file)
6633 # allow fewer stripes to be created, ORI-601
6634 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6635 error "$file: count $stripe_count != $count"
6636 stripe_index=$(lfs getstripe -i $PWD/$file)
6637 [[ $stripe_index -ne 0 ]] &&
6638 stripe_index_all_zero=false
6642 $stripe_index_all_zero &&
6643 error "all files are being extracted starting from OST index 0"
6648 [ -n "$(which tar 2>/dev/null)" ] &&
6649 strings $(which tar) | grep -q "lustre" && echo tar
6653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6654 # b10930: tar test for trusted.lov xattr
6655 TAR=$(find_lustre_tar)
6656 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6657 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6659 test_mkdir -p $DIR/d102d
6660 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6662 compare_stripe_info1
6664 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6667 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6668 # b10930: tar test for trusted.lov xattr
6669 TAR=$(find_lustre_tar)
6670 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6671 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6673 test_mkdir -p $DIR/d102f
6675 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6677 compare_stripe_info1
6679 run_test 102f "tar copy files, not keep osts ==========="
6682 local xsize=${1:-1024} # in bytes
6683 local file=$DIR/$tfile
6685 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6686 skip "must have user_xattr" && return 0
6687 [ -z "$(which setfattr 2>/dev/null)" ] &&
6688 skip_env "could not find setfattr" && return 0
6689 [ -z "$(which getfattr 2>/dev/null)" ] &&
6690 skip_env "could not find getfattr" && return 0
6694 local value="$(generate_string $xsize)"
6696 local xbig=trusted.big
6697 log "save $xbig on $file"
6698 setfattr -n $xbig -v $value $file ||
6699 error "saving $xbig on $file failed"
6701 local orig=$(get_xattr_value $xbig $file)
6702 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6704 local xsml=trusted.sml
6705 log "save $xsml on $file"
6706 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6708 local new=$(get_xattr_value $xbig $file)
6709 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6711 log "grow $xsml on $file"
6712 setfattr -n $xsml -v "$value" $file ||
6713 error "growing $xsml on $file failed"
6715 new=$(get_xattr_value $xbig $file)
6716 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6717 log "$xbig still valid after growing $xsml"
6722 test_102h() { # bug 15777
6725 run_test 102h "grow xattr from inside inode to external block"
6728 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6729 grow_xattr $(max_xattr_size)
6731 run_test 102ha "grow xattr from inside inode to external inode"
6733 test_102i() { # bug 17038
6734 [ -z "$(which getfattr 2>/dev/null)" ] &&
6735 skip "could not find getfattr" && return
6737 ln -s $DIR/$tfile $DIR/${tfile}link
6738 getfattr -n trusted.lov $DIR/$tfile ||
6739 error "lgetxattr on $DIR/$tfile failed"
6740 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6741 grep -i "no such attr" ||
6742 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6743 rm -f $DIR/$tfile $DIR/${tfile}link
6745 run_test 102i "lgetxattr test on symbolic link ============"
6748 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6749 TAR=$(find_lustre_tar)
6750 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6751 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6752 setup_test102 "$RUNAS"
6753 test_mkdir -p $DIR/d102j
6754 chown $RUNAS_ID $DIR/d102j
6755 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6757 compare_stripe_info1 "$RUNAS"
6759 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6762 [ -z "$(which setfattr 2>/dev/null)" ] &&
6763 skip "could not find setfattr" && return
6765 # b22187 just check that does not crash for regular file.
6766 setfattr -n trusted.lov $DIR/$tfile
6767 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6768 local test_kdir=$DIR/d102k
6769 test_mkdir $test_kdir
6770 local default_size=`$GETSTRIPE -S $test_kdir`
6771 local default_count=`$GETSTRIPE -c $test_kdir`
6772 local default_offset=`$GETSTRIPE -i $test_kdir`
6773 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6774 error 'dir setstripe failed'
6775 setfattr -n trusted.lov $test_kdir
6776 local stripe_size=`$GETSTRIPE -S $test_kdir`
6777 local stripe_count=`$GETSTRIPE -c $test_kdir`
6778 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6779 [ $stripe_size -eq $default_size ] ||
6780 error "stripe size $stripe_size != $default_size"
6781 [ $stripe_count -eq $default_count ] ||
6782 error "stripe count $stripe_count != $default_count"
6783 [ $stripe_offset -eq $default_offset ] ||
6784 error "stripe offset $stripe_offset != $default_offset"
6785 rm -rf $DIR/$tfile $test_kdir
6787 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6790 [ -z "$(which getfattr 2>/dev/null)" ] &&
6791 skip "could not find getfattr" && return
6793 # LU-532 trusted. xattr is invisible to non-root
6794 local testfile=$DIR/$tfile
6798 echo "listxattr as user..."
6799 chown $RUNAS_ID $testfile
6800 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6801 grep -q "trusted" &&
6802 error "$testfile trusted xattrs are user visible"
6806 run_test 102l "listxattr size test =================================="
6808 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6809 local path=$DIR/$tfile
6812 listxattr_size_check $path || error "listattr_size_check $path failed"
6814 run_test 102m "Ensure listxattr fails on small bufffer ========"
6818 getxattr() { # getxattr path name
6819 # Return the base64 encoding of the value of xattr name on path.
6823 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6825 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6827 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6829 getfattr --absolute-names --encoding=base64 --name=$name $path |
6830 awk -F= -v name=$name '$1 == name {
6831 print substr($0, index($0, "=") + 1);
6835 test_102n() { # LU-4101 mdt: protect internal xattrs
6836 local file0=$DIR/$tfile.0
6837 local file1=$DIR/$tfile.1
6838 local xattr0=$TMP/$tfile.0
6839 local xattr1=$TMP/$tfile.1
6843 [ -z "$(which setfattr 2>/dev/null)" ] &&
6844 skip "could not find setfattr" && return
6846 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6848 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6852 rm -rf $file0 $file1 $xattr0 $xattr1
6855 # Get 'before' xattrs of $file1.
6856 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6858 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6859 # Try to copy xattr from $file0 to $file1.
6860 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6862 setfattr --name=trusted.$name --value="$value" $file1 ||
6863 error "setxattr 'trusted.$name' failed"
6865 # Try to set a garbage xattr.
6866 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6868 setfattr --name=trusted.$name --value="$value" $file1 ||
6869 error "setxattr 'trusted.$name' failed"
6871 # Try to remove the xattr from $file1. We don't care if this
6872 # appears to succeed or fail, we just don't want there to be
6873 # any changes or crashes.
6874 setfattr --remove=$trusted.$name $file1 2> /dev/null
6877 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6880 # Try to copy xattr from $file0 to $file1.
6881 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6883 setfattr --name=trusted.$name --value="$value" $file1 ||
6884 error "setxattr 'trusted.$name' failed"
6886 # Try to set a garbage xattr.
6887 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6889 setfattr --name=trusted.$name --value="$value" $file1 ||
6890 error "setxattr 'trusted.$name' failed"
6892 # Try to remove the xattr from $file1. We don't care if this
6893 # appears to succeed or fail, we just don't want there to be
6894 # any changes or crashes.
6895 setfattr --remove=$trusted.$name $file1 2> /dev/null
6898 # Get 'after' xattrs of file1.
6899 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6901 if ! diff $xattr0 $xattr1; then
6902 error "before and after xattrs of '$file1' differ"
6905 rm -rf $file0 $file1 $xattr0 $xattr1
6909 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6911 test_102p() { # LU-4703 setxattr did not check ownership
6912 local testfile=$DIR/$tfile
6914 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6915 skip "MDS needs to be at least 2.5.56" && return
6919 echo "setfacl as user..."
6920 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6921 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6923 echo "setfattr as user..."
6924 setfacl -m "u:$RUNAS_ID:---" $testfile
6925 $RUNAS setfattr -x system.posix_acl_access $testfile
6926 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6928 run_test 102p "check setxattr(2) correctly fails without permission"
6931 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
6933 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
6936 touch $DIR/$tfile || error "touch"
6937 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
6938 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
6939 rm $DIR/$tfile || error "rm"
6941 run_test 102r "set EAs with empty values"
6945 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6950 [ "$UID" != 0 ] && skip_env "must run as root" && return
6951 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6952 skip "must have acl enabled" && return
6953 [ -z "$(which setfacl 2>/dev/null)" ] &&
6954 skip_env "could not find setfacl" && return
6955 $GSS && skip "could not run under gss" && return
6957 gpasswd -a daemon bin # LU-5641
6958 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
6960 declare -a identity_old
6962 for num in $(seq $MDSCOUNT); do
6963 switch_identity $num true || identity_old[$num]=$?
6970 echo "performing cp ..."
6971 run_acl_subtest cp || error "run_acl_subtest cp failed"
6972 echo "performing getfacl-noacl..."
6973 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6974 echo "performing misc..."
6975 run_acl_subtest misc || error "misc test failed"
6976 echo "performing permissions..."
6977 run_acl_subtest permissions || error "permissions failed"
6978 echo "performing setfacl..."
6979 run_acl_subtest setfacl || error "setfacl test failed"
6981 # inheritance test got from HP
6982 echo "performing inheritance..."
6983 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6984 chmod +x make-tree || error "chmod +x failed"
6985 run_acl_subtest inheritance || error "inheritance test failed"
6988 echo "LU-974 ignore umask when acl is enabled..."
6989 run_acl_subtest 974 || error "LU-974 umask test failed"
6990 if [ $MDSCOUNT -ge 2 ]; then
6991 run_acl_subtest 974_remote ||
6992 error "LU-974 umask test failed under remote dir"
6995 echo "LU-2561 newly created file is same size as directory..."
6996 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
6997 run_acl_subtest 2561 || error "LU-2561 test failed"
6999 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7002 run_acl_subtest 4924 || error "LU-4924 test failed"
7007 for num in $(seq $MDSCOUNT); do
7008 if [ "${identity_old[$num]}" = 1 ]; then
7009 switch_identity $num false || identity_old[$num]=$?
7013 run_test 103a "acl test ========================================="
7017 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7018 local mountopts=$MDS_MOUNT_OPTS
7020 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7024 stop $SINGLEMDS || error "failed to stop MDT."
7026 if [ -z "$MDS_MOUNT_OPTS" ]; then
7027 MDS_MOUNT_OPTS="-o noacl"
7029 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7031 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7032 error "failed to start MDT."
7033 MDS_MOUNT_OPTS=$mountopts
7037 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7041 stop $SINGLEMDS || error "failed to stop MDT."
7043 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7044 error "failed to start MDT."
7049 run_test 103b "MDS mount option 'noacl'"
7053 cp -rp $DIR/$tdir $DIR/$tdir.bak
7055 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7056 error "$DIR/$tdir shouldn't contain default ACL"
7057 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7058 error "$DIR/$tdir.bak shouldn't contain default ACL"
7061 run_test 103c "'cp -rp' won't set empty acl"
7064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7066 lfs df || error "lfs df failed"
7067 lfs df -ih || error "lfs df -ih failed"
7068 lfs df -h $DIR || error "lfs df -h $DIR failed"
7069 lfs df -i $DIR || error "lfs df -i $DIR failed"
7070 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7071 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7073 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7074 lctl --device %$OSC deactivate
7075 lfs df || error "lfs df with deactivated OSC failed"
7076 lctl --device %$OSC activate
7077 # wait the osc back to normal
7078 wait_osc_import_state client ost FULL
7080 lfs df || error "lfs df with reactivated OSC failed"
7083 run_test 104a "lfs df [-ih] [path] test ========================="
7086 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7087 [ $RUNAS_ID -eq $UID ] &&
7088 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7090 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7091 grep "Permission denied" | wc -l)))
7092 if [ $denied_cnt -ne 0 ]; then
7093 error "lfs check servers test failed"
7096 run_test 104b "$RUNAS lfs check servers test ===================="
7099 # doesn't work on 2.4 kernels
7101 if $(flock_is_enabled); then
7102 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7104 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7108 run_test 105a "flock when mounted without -o flock test ========"
7112 if $(flock_is_enabled); then
7113 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7115 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7119 run_test 105b "fcntl when mounted without -o flock test ========"
7123 if $(flock_is_enabled); then
7124 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7126 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7130 run_test 105c "lockf when mounted without -o flock test ========"
7132 test_105d() { # bug 15924
7133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7134 test_mkdir -p $DIR/$tdir
7135 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7136 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7137 $LCTL set_param fail_loc=0x80000315
7138 flocks_test 2 $DIR/$tdir
7140 run_test 105d "flock race (should not freeze) ========"
7142 test_105e() { # bug 22660 && 22040
7143 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7145 flocks_test 3 $DIR/$tfile
7147 run_test 105e "Two conflicting flocks from same process ======="
7149 test_106() { #bug 10921
7150 test_mkdir -p $DIR/$tdir
7151 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7152 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7154 run_test 106 "attempt exec of dir followed by chown of that dir"
7157 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7164 local save_pattern=$(sysctl -n kernel.core_pattern)
7165 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7166 sysctl -w kernel.core_pattern=$file
7167 sysctl -w kernel.core_uses_pid=0
7175 kill -s 11 $SLEEPPID
7177 if [ -e $file ]; then
7178 size=`stat -c%s $file`
7179 [ $size -eq 0 ] && error "Fail to create core file $file"
7181 error "Fail to create core file $file"
7184 sysctl -w kernel.core_pattern=$save_pattern
7185 sysctl -w kernel.core_uses_pid=$save_uses_pid
7188 run_test 107 "Coredump on SIG"
7191 test_mkdir -p $DIR/$tdir
7192 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7193 error "mkdir with 255 char failed"
7194 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7195 error "mkdir with 256 char should fail, but did not"
7196 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7197 error "create with 255 char failed"
7198 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7199 error "create with 256 char should fail, but did not"
7204 run_test 110 "filename length checking"
7207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7208 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7209 tail -1 | cut -c11-20)
7210 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7211 echo "Starting with $OSTIO_pre threads"
7214 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7215 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7216 echo "$NUMTEST creates/unlinks"
7217 test_mkdir -p $DIR/$tdir
7218 createmany -o $DIR/$tdir/$tfile $NUMTEST
7219 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7221 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7222 tail -1 | cut -c11-20)
7224 # don't return an error
7225 [ $OSTIO_post == $OSTIO_pre ] && echo \
7226 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7227 echo "This may be fine, depending on what ran before this test" &&
7228 echo "and how fast this system is." && return
7230 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7232 run_test 115 "verify dynamic thread creation===================="
7235 wait_delete_completed
7236 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7237 echo OST kbytes available: ${AVAIL[@]}
7238 MAXI=0; MAXV=${AVAIL[0]}
7239 MINI=0; MINV=${AVAIL[0]}
7240 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7241 #echo OST $i: ${AVAIL[i]}kb
7242 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7243 MAXV=${AVAIL[i]}; MAXI=$i
7245 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7246 MINV=${AVAIL[i]}; MINI=$i
7249 echo Min free space: OST $MINI: $MINV
7250 echo Max free space: OST $MAXI: $MAXV
7253 test_116a() { # was previously test_116()
7254 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7255 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7257 echo -n "Free space priority "
7258 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7263 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7264 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7266 trap simple_cleanup_common EXIT
7269 # Check if we need to generate uneven OSTs
7270 test_mkdir -p $DIR/$tdir/OST${MINI}
7271 local FILL=$(($MINV / 4))
7272 local DIFF=$(($MAXV - $MINV))
7273 local DIFF2=$(($DIFF * 100 / $MINV))
7275 local threshold=$(do_facet $SINGLEMDS \
7276 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7277 threshold=${threshold%%%}
7278 echo -n "Check for uneven OSTs: "
7279 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7281 if [[ $DIFF2 -gt $threshold ]]; then
7283 echo "Don't need to fill OST$MINI"
7285 # generate uneven OSTs. Write 2% over the QOS threshold value
7287 DIFF=$(($threshold - $DIFF2 + 2))
7288 DIFF2=$(( ($MINV * $DIFF)/100 ))
7289 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7290 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7291 error "setstripe failed"
7292 DIFF=$(($DIFF2 / 2048))
7294 while [ $i -lt $DIFF ]; do
7296 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7297 bs=2M count=1 2>/dev/null
7306 DIFF=$(($MAXV - $MINV))
7307 DIFF2=$(($DIFF * 100 / $MINV))
7308 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7309 if [[ $DIFF2 -gt $threshold ]]; then
7312 echo "failed - QOS mode won't be used"
7313 skip "QOS imbalance criteria not met"
7314 simple_cleanup_common
7318 MINI1=$MINI; MINV1=$MINV
7319 MAXI1=$MAXI; MAXV1=$MAXV
7321 # now fill using QOS
7322 $SETSTRIPE -c 1 $DIR/$tdir
7323 FILL=$(($FILL / 200))
7324 if [ $FILL -gt 600 ]; then
7327 echo "writing $FILL files to QOS-assigned OSTs"
7329 while [ $i -lt $FILL ]; do
7331 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7335 echo "wrote $i 200k files"
7339 echo "Note: free space may not be updated, so measurements might be off"
7341 DIFF2=$(($MAXV - $MINV))
7342 echo "free space delta: orig $DIFF final $DIFF2"
7343 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7344 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7345 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7346 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7347 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7348 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7350 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7352 # Figure out which files were written where
7353 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7354 awk '/'$MINI1': / {print $2; exit}')
7356 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7357 echo "$MINC files created on smaller OST $MINI1"
7358 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7359 awk '/'$MAXI1': / {print $2; exit}')
7361 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7362 echo "$MAXC files created on larger OST $MAXI1"
7363 FILL=$(($MAXC * 100 / $MINC - 100))
7364 [[ $MINC -gt 0 ]] &&
7365 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7366 [[ $MAXC -gt $MINC ]] ||
7367 error_ignore LU-9 "stripe QOS didn't balance free space"
7368 simple_cleanup_common
7370 run_test 116a "stripe QOS: free space balance ==================="
7372 test_116b() { # LU-2093
7373 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7374 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7375 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7376 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7377 [ -z "$old_rr" ] && skip "no QOS" && return 0
7378 do_facet $SINGLEMDS lctl set_param \
7379 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7381 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7382 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7383 do_facet $SINGLEMDS lctl set_param fail_loc=0
7385 do_facet $SINGLEMDS lctl set_param \
7386 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7388 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7390 test_117() # bug 10891
7392 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7393 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7394 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7395 lctl set_param fail_loc=0x21e
7396 > $DIR/$tfile || error "truncate failed"
7397 lctl set_param fail_loc=0
7398 echo "Truncate succeeded."
7401 run_test 117 "verify osd extend =========="
7403 NO_SLOW_RESENDCOUNT=4
7404 export OLD_RESENDCOUNT=""
7405 set_resend_count () {
7406 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7407 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7408 lctl set_param -n $PROC_RESENDCOUNT $1
7409 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7412 # for reduce test_118* time (b=14842)
7413 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7415 # Reset async IO behavior after error case
7417 FILE=$DIR/reset_async
7419 # Ensure all OSCs are cleared
7420 $SETSTRIPE -c -1 $FILE
7421 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7426 test_118a() #bug 11710
7428 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7431 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7432 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7433 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7435 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7436 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7441 run_test 118a "verify O_SYNC works =========="
7445 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7446 remote_ost_nodsh && skip "remote OST with nodsh" && return
7450 #define OBD_FAIL_OST_ENOENT 0x217
7451 set_nodes_failloc "$(osts_nodes)" 0x217
7452 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7454 set_nodes_failloc "$(osts_nodes)" 0
7455 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7456 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7459 if [[ $RC -eq 0 ]]; then
7460 error "Must return error due to dropped pages, rc=$RC"
7464 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7465 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7469 echo "Dirty pages not leaked on ENOENT"
7471 # Due to the above error the OSC will issue all RPCs syncronously
7472 # until a subsequent RPC completes successfully without error.
7473 $MULTIOP $DIR/$tfile Ow4096yc
7478 run_test 118b "Reclaim dirty pages on fatal error =========="
7482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7484 # for 118c, restore the original resend count, LU-1940
7485 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7486 set_resend_count $OLD_RESENDCOUNT
7487 remote_ost_nodsh && skip "remote OST with nodsh" && return
7491 #define OBD_FAIL_OST_EROFS 0x216
7492 set_nodes_failloc "$(osts_nodes)" 0x216
7494 # multiop should block due to fsync until pages are written
7495 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7499 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7500 error "Multiop failed to block on fsync, pid=$MULTIPID"
7503 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7505 if [[ $WRITEBACK -eq 0 ]]; then
7506 error "No page in writeback, writeback=$WRITEBACK"
7509 set_nodes_failloc "$(osts_nodes)" 0
7512 if [[ $RC -ne 0 ]]; then
7513 error "Multiop fsync failed, rc=$RC"
7516 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7517 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7519 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7520 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7524 echo "Dirty pages flushed via fsync on EROFS"
7527 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7529 # continue to use small resend count to reduce test_118* time (b=14842)
7530 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7534 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7535 remote_ost_nodsh && skip "remote OST with nodsh" && return
7539 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7540 set_nodes_failloc "$(osts_nodes)" 0x214
7541 # multiop should block due to fsync until pages are written
7542 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7546 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7547 error "Multiop failed to block on fsync, pid=$MULTIPID"
7550 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7552 if [[ $WRITEBACK -eq 0 ]]; then
7553 error "No page in writeback, writeback=$WRITEBACK"
7556 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7557 set_nodes_failloc "$(osts_nodes)" 0
7559 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7560 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7562 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7563 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7567 echo "Dirty pages gaurenteed flushed via fsync"
7570 run_test 118d "Fsync validation inject a delay of the bulk =========="
7573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7576 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7577 lctl set_param fail_loc=0x8000040a
7579 # Should simulate EINVAL error which is fatal
7580 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7582 if [[ $RC -eq 0 ]]; then
7583 error "Must return error due to dropped pages, rc=$RC"
7586 lctl set_param fail_loc=0x0
7588 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7589 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7590 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7592 if [[ $LOCKED -ne 0 ]]; then
7593 error "Locked pages remain in cache, locked=$LOCKED"
7596 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7597 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7601 echo "No pages locked after fsync"
7606 run_test 118f "Simulate unrecoverable OSC side error =========="
7609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7612 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7613 lctl set_param fail_loc=0x406
7615 # simulate local -ENOMEM
7616 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7619 lctl set_param fail_loc=0
7620 if [[ $RC -eq 0 ]]; then
7621 error "Must return error due to dropped pages, rc=$RC"
7624 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7625 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7626 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7628 if [[ $LOCKED -ne 0 ]]; then
7629 error "Locked pages remain in cache, locked=$LOCKED"
7632 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7633 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7637 echo "No pages locked after fsync"
7642 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7646 remote_ost_nodsh && skip "remote OST with nodsh" && return
7650 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7651 set_nodes_failloc "$(osts_nodes)" 0x20e
7652 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7653 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7656 set_nodes_failloc "$(osts_nodes)" 0
7657 if [[ $RC -eq 0 ]]; then
7658 error "Must return error due to dropped pages, rc=$RC"
7661 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7662 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7663 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7665 if [[ $LOCKED -ne 0 ]]; then
7666 error "Locked pages remain in cache, locked=$LOCKED"
7669 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7670 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7674 echo "No pages locked after fsync"
7678 run_test 118h "Verify timeout in handling recoverables errors =========="
7680 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7683 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7684 remote_ost_nodsh && skip "remote OST with nodsh" && return
7688 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7689 set_nodes_failloc "$(osts_nodes)" 0x20e
7691 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7692 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7695 set_nodes_failloc "$(osts_nodes)" 0
7699 if [[ $RC -ne 0 ]]; then
7700 error "got error, but should be not, rc=$RC"
7703 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7704 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7705 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7706 if [[ $LOCKED -ne 0 ]]; then
7707 error "Locked pages remain in cache, locked=$LOCKED"
7710 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7711 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7715 echo "No pages locked after fsync"
7719 run_test 118i "Fix error before timeout in recoverable error =========="
7721 [ "$SLOW" = "no" ] && set_resend_count 4
7724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7725 remote_ost_nodsh && skip "remote OST with nodsh" && return
7729 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7730 set_nodes_failloc "$(osts_nodes)" 0x220
7732 # return -EIO from OST
7733 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7735 set_nodes_failloc "$(osts_nodes)" 0x0
7736 if [[ $RC -eq 0 ]]; then
7737 error "Must return error due to dropped pages, rc=$RC"
7740 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7741 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7742 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7743 if [[ $LOCKED -ne 0 ]]; then
7744 error "Locked pages remain in cache, locked=$LOCKED"
7747 # in recoverable error on OST we want resend and stay until it finished
7748 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7749 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7753 echo "No pages locked after fsync"
7757 run_test 118j "Simulate unrecoverable OST side error =========="
7761 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7762 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7764 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7765 set_nodes_failloc "$(osts_nodes)" 0x20e
7766 test_mkdir -p $DIR/$tdir
7768 for ((i=0;i<10;i++)); do
7769 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7770 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7777 set_nodes_failloc "$(osts_nodes)" 0
7780 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7784 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7786 test_mkdir -p $DIR/$tdir
7787 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7790 run_test 118l "fsync dir ========="
7792 test_118m() # LU-3066
7794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7795 test_mkdir -p $DIR/$tdir
7796 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7799 run_test 118m "fdatasync dir ========="
7801 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7803 test_119a() # bug 11737
7805 BSIZE=$((512 * 1024))
7806 directio write $DIR/$tfile 0 1 $BSIZE
7807 # We ask to read two blocks, which is more than a file size.
7808 # directio will indicate an error when requested and actual
7809 # sizes aren't equeal (a normal situation in this case) and
7810 # print actual read amount.
7811 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7812 if [ "$NOB" != "$BSIZE" ]; then
7813 error "read $NOB bytes instead of $BSIZE"
7817 run_test 119a "Short directIO read must return actual read amount"
7819 test_119b() # bug 11737
7821 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7823 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7824 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7826 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7827 error "direct read failed"
7830 run_test 119b "Sparse directIO read must return actual read amount"
7832 test_119c() # bug 13099
7835 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7836 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7839 run_test 119c "Testing for direct read hitting hole"
7841 test_119d() # bug 15950
7843 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7844 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7845 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7847 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7848 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7849 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7850 lctl set_param fail_loc=0x40d
7851 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7854 cat $DIR/$tfile > /dev/null &
7855 lctl set_param fail_loc=0
7858 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7860 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7861 error "the read rpcs have not completed in 2s"
7863 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7865 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7868 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7869 test_mkdir -p $DIR/$tdir
7870 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7871 skip "no early lock cancel on server" && return 0
7873 lru_resize_disable mdc
7874 lru_resize_disable osc
7875 cancel_lru_locks mdc
7876 # asynchronous object destroy at MDT could cause bl ast to client
7877 cancel_lru_locks osc
7879 stat $DIR/$tdir > /dev/null
7880 can1=$(do_facet $SINGLEMDS \
7881 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7882 awk '/ldlm_cancel/ {print $2}')
7883 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7884 awk '/ldlm_bl_callback/ {print $2}')
7885 test_mkdir -c1 $DIR/$tdir/d1
7886 can2=$(do_facet $SINGLEMDS \
7887 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7888 awk '/ldlm_cancel/ {print $2}')
7889 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7890 awk '/ldlm_bl_callback/ {print $2}')
7891 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7892 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7893 lru_resize_enable mdc
7894 lru_resize_enable osc
7896 run_test 120a "Early Lock Cancel: mkdir test"
7899 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7900 test_mkdir $DIR/$tdir
7901 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7902 skip "no early lock cancel on server" && return 0
7903 lru_resize_disable mdc
7904 lru_resize_disable osc
7905 cancel_lru_locks mdc
7906 stat $DIR/$tdir > /dev/null
7907 can1=$(do_facet $SINGLEMDS \
7908 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7909 awk '/ldlm_cancel/ {print $2}')
7910 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7911 awk '/ldlm_bl_callback/ {print $2}')
7913 can2=$(do_facet $SINGLEMDS \
7914 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7915 awk '/ldlm_cancel/ {print $2}')
7916 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7917 awk '/ldlm_bl_callback/ {print $2}')
7918 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7919 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7920 lru_resize_enable mdc
7921 lru_resize_enable osc
7923 run_test 120b "Early Lock Cancel: create test"
7926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7927 test_mkdir -c1 $DIR/$tdir
7928 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7929 skip "no early lock cancel on server" && return 0
7930 lru_resize_disable mdc
7931 lru_resize_disable osc
7932 test_mkdir -p -c1 $DIR/$tdir/d1
7933 test_mkdir -p -c1 $DIR/$tdir/d2
7934 touch $DIR/$tdir/d1/f1
7935 cancel_lru_locks mdc
7936 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7937 can1=$(do_facet $SINGLEMDS \
7938 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7939 awk '/ldlm_cancel/ {print $2}')
7940 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7941 awk '/ldlm_bl_callback/ {print $2}')
7942 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7943 can2=$(do_facet $SINGLEMDS \
7944 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7945 awk '/ldlm_cancel/ {print $2}')
7946 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7947 awk '/ldlm_bl_callback/ {print $2}')
7948 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7949 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7950 lru_resize_enable mdc
7951 lru_resize_enable osc
7953 run_test 120c "Early Lock Cancel: link test"
7956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7957 test_mkdir -p -c1 $DIR/$tdir
7958 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7959 skip "no early lock cancel on server" && return 0
7960 lru_resize_disable mdc
7961 lru_resize_disable osc
7963 cancel_lru_locks mdc
7964 stat $DIR/$tdir > /dev/null
7965 can1=$(do_facet $SINGLEMDS \
7966 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7967 awk '/ldlm_cancel/ {print $2}')
7968 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7969 awk '/ldlm_bl_callback/ {print $2}')
7970 chmod a+x $DIR/$tdir
7971 can2=$(do_facet $SINGLEMDS \
7972 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7973 awk '/ldlm_cancel/ {print $2}')
7974 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7975 awk '/ldlm_bl_callback/ {print $2}')
7976 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7977 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7978 lru_resize_enable mdc
7979 lru_resize_enable osc
7981 run_test 120d "Early Lock Cancel: setattr test"
7984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7985 test_mkdir -p -c1 $DIR/$tdir
7986 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7987 skip "no early lock cancel on server" && return 0
7988 lru_resize_disable mdc
7989 lru_resize_disable osc
7990 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7991 cancel_lru_locks mdc
7992 cancel_lru_locks osc
7993 dd if=$DIR/$tdir/f1 of=/dev/null
7994 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7995 # XXX client can not do early lock cancel of OST lock
7996 # during unlink (LU-4206), so cancel osc lock now.
7997 cancel_lru_locks osc
7998 can1=$(do_facet $SINGLEMDS \
7999 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8000 awk '/ldlm_cancel/ {print $2}')
8001 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8002 awk '/ldlm_bl_callback/ {print $2}')
8003 unlink $DIR/$tdir/f1
8005 can2=$(do_facet $SINGLEMDS \
8006 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8007 awk '/ldlm_cancel/ {print $2}')
8008 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8009 awk '/ldlm_bl_callback/ {print $2}')
8010 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8011 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8012 lru_resize_enable mdc
8013 lru_resize_enable osc
8015 run_test 120e "Early Lock Cancel: unlink test"
8018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8019 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8020 skip "no early lock cancel on server" && return 0
8021 test_mkdir -p -c1 $DIR/$tdir
8022 lru_resize_disable mdc
8023 lru_resize_disable osc
8024 test_mkdir -p -c1 $DIR/$tdir/d1
8025 test_mkdir -p -c1 $DIR/$tdir/d2
8026 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8027 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8028 cancel_lru_locks mdc
8029 cancel_lru_locks osc
8030 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8031 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8032 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8033 # XXX client can not do early lock cancel of OST lock
8034 # during rename (LU-4206), so cancel osc lock now.
8035 cancel_lru_locks osc
8036 can1=$(do_facet $SINGLEMDS \
8037 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8038 awk '/ldlm_cancel/ {print $2}')
8039 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8040 awk '/ldlm_bl_callback/ {print $2}')
8041 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8043 can2=$(do_facet $SINGLEMDS \
8044 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8045 awk '/ldlm_cancel/ {print $2}')
8046 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8047 awk '/ldlm_bl_callback/ {print $2}')
8048 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8049 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8050 lru_resize_enable mdc
8051 lru_resize_enable osc
8053 run_test 120f "Early Lock Cancel: rename test"
8056 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8057 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8058 skip "no early lock cancel on server" && return 0
8059 lru_resize_disable mdc
8060 lru_resize_disable osc
8062 echo create $count files
8063 test_mkdir -p $DIR/$tdir
8064 cancel_lru_locks mdc
8065 cancel_lru_locks osc
8068 can0=$(do_facet $SINGLEMDS \
8069 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8070 awk '/ldlm_cancel/ {print $2}')
8071 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8072 awk '/ldlm_bl_callback/ {print $2}')
8073 createmany -o $DIR/$tdir/f $count
8075 can1=$(do_facet $SINGLEMDS \
8076 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8077 awk '/ldlm_cancel/ {print $2}')
8078 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8079 awk '/ldlm_bl_callback/ {print $2}')
8081 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8082 echo rm $count files
8085 can2=$(do_facet $SINGLEMDS \
8086 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8087 awk '/ldlm_cancel/ {print $2}')
8088 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8089 awk '/ldlm_bl_callback/ {print $2}')
8091 echo total: $count removes in $((t2-t1))
8092 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8094 # wait for commitment of removal
8095 lru_resize_enable mdc
8096 lru_resize_enable osc
8098 run_test 120g "Early Lock Cancel: performance test"
8100 test_121() { #bug #10589
8101 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8103 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8104 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8105 lctl set_param fail_loc=0x310
8106 cancel_lru_locks osc > /dev/null
8107 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8108 lctl set_param fail_loc=0
8109 [[ $reads -eq $writes ]] ||
8110 error "read $reads blocks, must be $writes blocks"
8112 run_test 121 "read cancel race ========="
8114 test_123a() { # was test 123, statahead(bug 11401)
8115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8117 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8118 log "testing on UP system. Performance may be not as good as expected."
8123 test_mkdir -p $DIR/$tdir
8124 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8125 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8127 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8128 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8130 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8131 lctl set_param -n llite.*.statahead_max 0
8132 lctl get_param llite.*.statahead_max
8133 cancel_lru_locks mdc
8134 cancel_lru_locks osc
8136 time ls -l $DIR/$tdir | wc -l
8138 delta=$((etime - stime))
8139 log "ls $i files without statahead: $delta sec"
8140 lctl set_param llite.*.statahead_max=$max
8142 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8143 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8144 cancel_lru_locks mdc
8145 cancel_lru_locks osc
8147 time ls -l $DIR/$tdir | wc -l
8149 delta_sa=$((etime - stime))
8150 log "ls $i files with statahead: $delta_sa sec"
8151 lctl get_param -n llite.*.statahead_stats
8152 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8154 [[ $swrong -lt $ewrong ]] &&
8155 log "statahead was stopped, maybe too many locks held!"
8156 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8158 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8159 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8160 lctl set_param -n llite.*.statahead_max 0
8161 lctl get_param llite.*.statahead_max
8162 cancel_lru_locks mdc
8163 cancel_lru_locks osc
8165 time ls -l $DIR/$tdir | wc -l
8167 delta=$((etime - stime))
8168 log "ls $i files again without statahead: $delta sec"
8169 lctl set_param llite.*.statahead_max=$max
8170 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8171 if [ $SLOWOK -eq 0 ]; then
8172 error "ls $i files is slower with statahead!"
8174 log "ls $i files is slower with statahead!"
8180 [ $delta -gt 20 ] && break
8181 [ $delta -gt 8 ] && MULT=$((50 / delta))
8182 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8190 delta=$((etime - stime))
8191 log "rm -r $DIR/$tdir/: $delta seconds"
8193 lctl get_param -n llite.*.statahead_stats
8195 run_test 123a "verify statahead work"
8197 test_123b () { # statahead(bug 15027)
8198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8199 test_mkdir -p $DIR/$tdir
8200 createmany -o $DIR/$tdir/$tfile-%d 1000
8202 cancel_lru_locks mdc
8203 cancel_lru_locks osc
8205 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8206 lctl set_param fail_loc=0x80000803
8207 ls -lR $DIR/$tdir > /dev/null
8209 lctl set_param fail_loc=0x0
8210 lctl get_param -n llite.*.statahead_stats
8215 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8218 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8219 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8220 skip "no lru resize on server" && return 0
8222 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8224 log "create $NR files at $DIR/$tdir"
8225 createmany -o $DIR/$tdir/f $NR ||
8226 error "failed to create $NR files in $DIR/$tdir"
8228 cancel_lru_locks mdc
8229 ls -l $DIR/$tdir > /dev/null
8233 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8234 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8235 LRU_SIZE=$($LCTL get_param -n $PARAM)
8236 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8237 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8239 log "NS=$(basename $NSDIR)"
8244 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8245 skip "Not enough cached locks created!"
8252 # We know that lru resize allows one client to hold $LIMIT locks
8253 # for 10h. After that locks begin to be killed by client.
8255 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8257 if [ $LIMIT -lt $LRU_SIZE ]; then
8258 skip "Limit is too small $LIMIT"
8262 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8263 # killing locks. Some time was spent for creating locks. This means
8264 # that up to the moment of sleep finish we must have killed some of
8265 # them (10-100 locks). This depends on how fast ther were created.
8266 # Many of them were touched in almost the same moment and thus will
8267 # be killed in groups.
8268 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8270 # Use $LRU_SIZE_B here to take into account real number of locks
8271 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8272 local LRU_SIZE_B=$LRU_SIZE
8274 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8275 log "OLD_LVF=$OLD_LVF"
8276 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8278 # Let's make sure that we really have some margin. Client checks
8279 # cached locks every 10 sec.
8281 log "Sleep ${SLEEP} sec"
8283 while ((SEC<$SLEEP)); do
8287 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8291 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8292 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8294 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8295 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8296 unlinkmany $DIR/$tdir/f $NR
8300 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8301 log "unlink $NR files at $DIR/$tdir"
8302 unlinkmany $DIR/$tdir/f $NR
8304 run_test 124a "lru resize ======================================="
8306 get_max_pool_limit()
8308 local limit=$($LCTL get_param \
8309 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8312 if [[ $l -gt $max ]]; then
8320 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8321 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8322 skip "no lru resize on server" && return 0
8324 LIMIT=$(get_max_pool_limit)
8326 NR=$(($(default_lru_size)*20))
8327 if [[ $NR -gt $LIMIT ]]; then
8328 log "Limit lock number by $LIMIT locks"
8331 lru_resize_disable mdc
8332 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8333 error "failed to create $DIR/$tdir/disable_lru_resize"
8335 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8336 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8337 cancel_lru_locks mdc
8340 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8343 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8346 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8350 nolruresize_delta=$((etime-stime))
8351 log "ls -la time: $nolruresize_delta seconds"
8352 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8353 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8355 lru_resize_enable mdc
8356 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8357 error "failed to create $DIR/$tdir/enable_lru_resize"
8359 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8360 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8361 cancel_lru_locks mdc
8364 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8367 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8370 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8374 lruresize_delta=$((etime-stime))
8375 log "ls -la time: $lruresize_delta seconds"
8376 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8378 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8379 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8380 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8381 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8383 log "lru resize performs the same with no lru resize"
8385 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8387 run_test 124b "lru resize (performance test) ======================="
8389 test_125() { # 13358
8390 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8391 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8392 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8393 test_mkdir -p $DIR/d125 || error "mkdir failed"
8394 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8395 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8396 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8398 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8400 test_126() { # bug 12829/13455
8401 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8402 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8403 $GSS && skip "must run as gss disabled" && return
8405 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8406 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8408 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8410 run_test 126 "check that the fsgid provided by the client is taken into account"
8412 test_127a() { # bug 15521
8413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8414 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8415 $LCTL set_param osc.*.stats=0
8416 FSIZE=$((2048 * 1024))
8417 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8418 cancel_lru_locks osc
8419 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8421 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8422 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8423 echo "got $COUNT $NAME"
8424 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8425 eval $NAME=$COUNT || error "Wrong proc format"
8428 read_bytes|write_bytes)
8429 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8430 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8431 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8432 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8433 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8434 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8435 error "sumsquare is too small: $SUMSQ"
8436 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8437 error "sumsquare is too big: $SUMSQ"
8441 done < $DIR/${tfile}.tmp
8443 #check that we actually got some stats
8444 [ "$read_bytes" ] || error "Missing read_bytes stats"
8445 [ "$write_bytes" ] || error "Missing write_bytes stats"
8446 [ "$read_bytes" != 0 ] || error "no read done"
8447 [ "$write_bytes" != 0 ] || error "no write done"
8449 run_test 127a "verify the client stats are sane"
8451 test_127b() { # bug LU-333
8452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8453 $LCTL set_param llite.*.stats=0
8454 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8455 # perform 2 reads and writes so MAX is different from SUM.
8456 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8457 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8458 cancel_lru_locks osc
8459 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8460 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8462 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8463 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8464 echo "got $COUNT $NAME"
8465 eval $NAME=$COUNT || error "Wrong proc format"
8469 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8470 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8471 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8472 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8475 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8476 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8477 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8478 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8482 done < $TMP/${tfile}.tmp
8484 #check that we actually got some stats
8485 [ "$read_bytes" ] || error "Missing read_bytes stats"
8486 [ "$write_bytes" ] || error "Missing write_bytes stats"
8487 [ "$read_bytes" != 0 ] || error "no read done"
8488 [ "$write_bytes" != 0 ] || error "no write done"
8490 run_test 127b "verify the llite client stats are sane"
8492 test_128() { # bug 15212
8494 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8499 result=$(grep error $TMP/$tfile.log)
8501 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8503 run_test 128 "interactive lfs for 2 consecutive find's"
8510 local LDPROC=/proc/fs/ldiskfs
8511 local facets=$(get_facets MDS)
8513 for facet in ${facets//,/ }; do
8514 canondev=$(ldiskfs_canon \
8515 *.$(convert_facet2label $facet).mntdev $facet)
8516 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8517 LDPROC=/sys/fs/ldiskfs
8518 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8523 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8524 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8525 skip "Only applicable to ldiskfs-based MDTs"
8528 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8533 test_mkdir -p $DIR/$tdir
8535 # block size of mds1
8536 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8537 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8538 local MAX=$((MDSBLOCKSIZE * 3))
8540 local I=$(stat -c%s "$DIR/$tdir")
8542 local STRIPE_COUNT=1
8543 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8544 MAX=$((MAX*STRIPE_COUNT))
8545 while [[ $I -le $MAX ]]; do
8546 $MULTIOP $DIR/$tdir/$J Oc
8548 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8549 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8550 #and EFBIG for previous versions
8551 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8553 echo "return code $rc received as expected"
8554 multiop $DIR/$tdir/$J Oc ||
8555 error_exit "multiop failed w/o dir size limit"
8557 I=$(stat -c%s "$DIR/$tdir")
8559 if [ $(lustre_version_code $SINGLEMDS) -lt \
8560 $(version_code 2.4.51) ]
8562 [[ $I -eq $MAX ]] && return 0
8564 [[ $I -gt $MAX ]] && return 0
8566 error_exit "current dir size $I, previous limit $MAX"
8567 elif [ $rc -ne 0 ]; then
8569 error_exit "return code $rc received instead of expected " \
8570 "$EFBIG or $ENOSPC, files in dir $I"
8573 I=$(stat -c%s "$DIR/$tdir")
8577 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8579 run_test 129 "test directory size limit ========================"
8588 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8589 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8592 trap cleanup_130 EXIT RETURN
8594 local fm_file=$DIR/$tfile
8595 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8596 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8597 error "dd failed for $fm_file"
8599 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8600 filefrag -ves $fm_file
8602 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8603 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8604 [ $RC != 0 ] && error "filefrag $fm_file failed"
8606 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8607 grep -v "ext:" | grep -v "found")
8608 lun=$($GETSTRIPE -i $fm_file)
8610 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8613 for line in $filefrag_op
8615 frag_lun=`echo $line | cut -d: -f5`
8616 ext_len=`echo $line | cut -d: -f4`
8617 if (( $frag_lun != $lun )); then
8619 error "FIEMAP on 1-stripe file($fm_file) failed"
8622 (( tot_len += ext_len ))
8625 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8627 error "FIEMAP on 1-stripe file($fm_file) failed;"
8633 echo "FIEMAP on single striped file succeeded"
8635 run_test 130a "FIEMAP (1-stripe file)"
8638 [ "$OSTCOUNT" -lt "2" ] &&
8639 skip_env "skipping FIEMAP on 2-stripe file test" && return
8641 [ "$OSTCOUNT" -ge "10" ] &&
8642 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8644 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8645 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8648 trap cleanup_130 EXIT RETURN
8650 local fm_file=$DIR/$tfile
8651 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8652 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8653 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8655 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8656 error "dd failed on $fm_file"
8658 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8659 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8660 grep -v "ext:" | grep -v "found")
8662 last_lun=$(echo $filefrag_op | cut -d: -f5)
8667 for line in $filefrag_op
8669 frag_lun=`echo $line | cut -d: -f5`
8670 ext_len=`echo $line | cut -d: -f4`
8671 if (( $frag_lun != $last_lun )); then
8672 if (( tot_len != 1024 )); then
8674 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8681 (( tot_len += ext_len ))
8684 if (( num_luns != 2 || tot_len != 1024 )); then
8686 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8692 echo "FIEMAP on 2-stripe file succeeded"
8694 run_test 130b "FIEMAP (2-stripe file)"
8697 [ "$OSTCOUNT" -lt "2" ] &&
8698 skip_env "skipping FIEMAP on 2-stripe file" && return
8700 [ "$OSTCOUNT" -ge "10" ] &&
8701 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8703 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8704 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8707 trap cleanup_130 EXIT RETURN
8709 local fm_file=$DIR/$tfile
8710 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8711 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8712 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8714 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8716 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8717 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8719 last_lun=`echo $filefrag_op | cut -d: -f5`
8724 for line in $filefrag_op
8726 frag_lun=`echo $line | cut -d: -f5`
8727 ext_len=`echo $line | cut -d: -f4`
8728 if (( $frag_lun != $last_lun )); then
8729 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8730 if (( logical != 512 )); then
8732 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8735 if (( tot_len != 512 )); then
8737 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8744 (( tot_len += ext_len ))
8747 if (( num_luns != 2 || tot_len != 512 )); then
8749 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8755 echo "FIEMAP on 2-stripe file with hole succeeded"
8757 run_test 130c "FIEMAP (2-stripe file with hole)"
8760 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8762 [ "$OSTCOUNT" -ge "10" ] &&
8763 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8765 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8766 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8768 trap cleanup_130 EXIT RETURN
8770 local fm_file=$DIR/$tfile
8771 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8772 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8773 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8775 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8776 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8777 error "dd failed on $fm_file"
8779 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8780 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8781 grep -v "ext:" | grep -v "found"`
8783 last_lun=`echo $filefrag_op | cut -d: -f5`
8788 for line in $filefrag_op
8790 frag_lun=`echo $line | cut -d: -f5`
8791 ext_len=`echo $line | cut -d: -f4`
8792 if (( $frag_lun != $last_lun )); then
8793 if (( tot_len != 1024 )); then
8795 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8802 (( tot_len += ext_len ))
8805 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8807 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8813 echo "FIEMAP on N-stripe file succeeded"
8815 run_test 130d "FIEMAP (N-stripe file)"
8818 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8820 [ "$OSTCOUNT" -ge "10" ] &&
8821 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8823 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8824 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8826 trap cleanup_130 EXIT RETURN
8828 local fm_file=$DIR/$tfile
8829 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8830 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8831 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8834 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8835 for ((i = 0; i < $NUM_BLKS; i++))
8837 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8840 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8841 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8843 last_lun=`echo $filefrag_op | cut -d: -f5`
8848 for line in $filefrag_op
8850 frag_lun=`echo $line | cut -d: -f5`
8851 ext_len=`echo $line | cut -d: -f4`
8852 if (( $frag_lun != $last_lun )); then
8853 if (( tot_len != $EXPECTED_LEN )); then
8855 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8862 (( tot_len += ext_len ))
8865 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8867 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8873 echo "FIEMAP with continuation calls succeeded"
8875 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8877 # Test for writev/readv
8879 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8880 error "writev test failed"
8881 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8882 error "readv failed"
8885 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8888 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8889 error "append writev test failed"
8890 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8891 error "append writev test failed"
8894 run_test 131b "test append writev"
8897 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8900 run_test 131c "test read/write on file w/o objects"
8903 rwv -f $DIR/$tfile -w -n 1 1572864
8904 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8905 if [ "$NOB" != 1572864 ]; then
8906 error "Short read filed: read $NOB bytes instead of 1572864"
8910 run_test 131d "test short read"
8913 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8914 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8915 error "read hitting hole failed"
8918 run_test 131e "test read hitting hole"
8923 for node in $(osts_nodes); do
8924 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8925 [ x$gl = x"" ] && gl=0
8926 gl_sum=$((gl_sum + gl))
8936 if [ x$som = x"enabled" ]; then
8937 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8938 MOUNT_OPTS=`echo $MOUNT_OPTS |
8939 sed 's/som_preview,\|,som_preview\|som_preview//g'`
8940 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8942 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8943 MOUNT_OPTS="${MOUNT_OPTS:+$MOUNT_OPTS,}som_preview"
8944 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8947 # do remount to make new mount-conf parameters actual
8954 test_132() { #1028, SOM
8955 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8956 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8957 local mdtidx=$($LFS getstripe -M $DIR)
8958 local facet=mds$((mdtidx + 1))
8960 local MOUNTOPT_SAVE=$MOUNTOPT
8962 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8963 cancel_lru_locks osc
8964 som1=$(do_facet $facet "$LCTL get_param mdt.*.som" |
8965 awk -F= ' {print $2}' | head -n 1)
8967 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8968 stat $DIR/$tfile >/dev/null
8969 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8970 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8972 som_mode_switch $som1 $gl1 $gl2
8974 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8975 cancel_lru_locks osc
8977 som2=$(do_facet $facet "$LCTL get_param mdt.*.som" |
8978 awk -F= ' {print $2}' | head -n 1)
8979 if [ $som1 == $som2 ]; then
8980 error "som is still "$som2
8981 if [ x$som2 = x"enabled" ]; then
8988 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8989 stat $DIR/$tfile >/dev/null
8990 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8991 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8992 som_mode_switch $som2 $gl1 $gl2
8993 MOUNT_OPTS=$MOUNT_OPTS_SAVE
8995 run_test 132 "som avoids glimpse rpc"
9001 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
9003 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
9005 *) error "Wrong argument $1" ;;
9008 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
9009 # if the argument $3 is zero, it means any stat increment is ok.
9010 if [[ $3 -gt 0 ]]; then
9011 count=$(echo $res | awk '{ print $2 }')
9012 [[ $count -ne $3 ]] &&
9013 error "The $2 counter on $1 is wrong - expected $3"
9018 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9019 remote_ost_nodsh && skip "remote OST with nodsh" && return
9020 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9022 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9023 { skip "MDS doesn't support rename stats"; return; }
9024 local testdir=$DIR/${tdir}/stats_testdir
9025 mkdir -p $DIR/${tdir}
9028 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9029 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9031 # verify mdt stats first.
9032 mkdir ${testdir} || error "mkdir failed"
9033 check_stats $SINGLEMDS "mkdir" 1
9034 touch ${testdir}/${tfile} || "touch failed"
9035 check_stats $SINGLEMDS "open" 1
9036 check_stats $SINGLEMDS "close" 1
9037 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9038 check_stats $SINGLEMDS "mknod" 1
9039 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9040 check_stats $SINGLEMDS "unlink" 1
9041 rm -f ${testdir}/${tfile} || error "file remove failed"
9042 check_stats $SINGLEMDS "unlink" 2
9044 # remove working dir and check mdt stats again.
9045 rmdir ${testdir} || error "rmdir failed"
9046 check_stats $SINGLEMDS "rmdir" 1
9048 local testdir1=$DIR/${tdir}/stats_testdir1
9050 mkdir -p ${testdir1}
9051 touch ${testdir1}/test1
9052 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9053 check_stats $SINGLEMDS "crossdir_rename" 1
9055 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9056 check_stats $SINGLEMDS "samedir_rename" 1
9060 run_test 133a "Verifying MDT stats ========================================"
9063 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9064 remote_ost_nodsh && skip "remote OST with nodsh" && return
9065 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9066 local testdir=$DIR/${tdir}/stats_testdir
9067 mkdir -p ${testdir} || error "mkdir failed"
9068 touch ${testdir}/${tfile} || "touch failed"
9069 cancel_lru_locks mdc
9072 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9073 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9075 # extra mdt stats verification.
9076 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9077 check_stats $SINGLEMDS "setattr" 1
9078 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9079 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9081 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9082 check_stats $SINGLEMDS "getattr" 1
9084 $LFS df || error "lfs failed"
9085 check_stats $SINGLEMDS "statfs" 1
9089 run_test 133b "Verifying extra MDT stats =================================="
9092 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9093 remote_ost_nodsh && skip "remote OST with nodsh" && return
9094 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9095 local testdir=$DIR/${tdir}/stats_testdir
9096 test_mkdir -p ${testdir} || error "mkdir failed"
9098 # verify obdfilter stats.
9099 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9101 cancel_lru_locks osc
9102 wait_delete_completed
9105 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9106 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9108 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9110 cancel_lru_locks osc
9111 check_stats ost "write" 1
9113 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9114 check_stats ost "read" 1
9116 > ${testdir}/${tfile} || error "truncate failed"
9117 check_stats ost "punch" 1
9119 rm -f ${testdir}/${tfile} || error "file remove failed"
9120 wait_delete_completed
9121 check_stats ost "destroy" 1
9125 run_test 133c "Verifying OST stats ========================================"
9132 while [ $value -ge 2 ]; do
9137 if [ $orig -gt $order ]; then
9145 local size=('K' 'M' 'G' 'T');
9147 local size_string=$value
9149 while [ $value -ge 1024 ]; do
9150 if [ $i -gt 3 ]; then
9151 #T is the biggest unit we get here, if that is bigger,
9153 size_string=${value}T
9156 value=$((value >> 10))
9157 if [ $value -lt 1024 ]; then
9158 size_string=${value}${size[$i]}
9169 local context=${2:-.}
9170 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9172 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9178 remote_ost_nodsh && skip "remote OST with nodsh" && return
9179 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9180 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9181 { skip "MDS doesn't support rename stats"; return; }
9183 local testdir1=$DIR/${tdir}/stats_testdir1
9184 local testdir2=$DIR/${tdir}/stats_testdir2
9186 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9188 mkdir -p ${testdir1} || error "mkdir failed"
9189 mkdir -p ${testdir2} || error "mkdir failed"
9191 createmany -o $testdir1/test 512 || error "createmany failed"
9193 # check samedir rename size
9194 mv ${testdir1}/test0 ${testdir1}/test_0
9196 local testdir1_size=$(ls -l $DIR/${tdir} |
9197 awk '/stats_testdir1/ {print $5}')
9198 local testdir2_size=$(ls -l $DIR/${tdir} |
9199 awk '/stats_testdir2/ {print $5}')
9201 testdir1_size=$(order_2 $testdir1_size)
9202 testdir2_size=$(order_2 $testdir2_size)
9204 testdir1_size=$(size_in_KMGT $testdir1_size)
9205 testdir2_size=$(size_in_KMGT $testdir2_size)
9207 echo "source rename dir size: ${testdir1_size}"
9208 echo "target rename dir size: ${testdir2_size}"
9210 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9211 eval $cmd || error "$cmd failed"
9212 local samedir=$($cmd | grep 'same_dir')
9213 local same_sample=$(get_rename_size $testdir1_size)
9214 [ -z "$samedir" ] && error "samedir_rename_size count error"
9215 [[ $same_sample -eq 1 ]] ||
9216 error "samedir_rename_size error $same_sample"
9217 echo "Check same dir rename stats success"
9219 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9221 # check crossdir rename size
9222 mv ${testdir1}/test_0 ${testdir2}/test_0
9224 testdir1_size=$(ls -l $DIR/${tdir} |
9225 awk '/stats_testdir1/ {print $5}')
9226 testdir2_size=$(ls -l $DIR/${tdir} |
9227 awk '/stats_testdir2/ {print $5}')
9229 testdir1_size=$(order_2 $testdir1_size)
9230 testdir2_size=$(order_2 $testdir2_size)
9232 testdir1_size=$(size_in_KMGT $testdir1_size)
9233 testdir2_size=$(size_in_KMGT $testdir2_size)
9235 echo "source rename dir size: ${testdir1_size}"
9236 echo "target rename dir size: ${testdir2_size}"
9238 eval $cmd || error "$cmd failed"
9239 local crossdir=$($cmd | grep 'crossdir')
9240 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9241 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9242 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9243 [[ $src_sample -eq 1 ]] ||
9244 error "crossdir_rename_size error $src_sample"
9245 [[ $tgt_sample -eq 1 ]] ||
9246 error "crossdir_rename_size error $tgt_sample"
9247 echo "Check cross dir rename stats success"
9250 run_test 133d "Verifying rename_stats ========================================"
9253 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9254 remote_ost_nodsh && skip "remote OST with nodsh" && return
9255 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9256 local testdir=$DIR/${tdir}/stats_testdir
9257 local ctr f0 f1 bs=32768 count=42 sum
9259 mkdir -p ${testdir} || error "mkdir failed"
9261 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9263 for ctr in {write,read}_bytes; do
9265 cancel_lru_locks osc
9267 do_facet ost1 $LCTL set_param -n \
9268 "obdfilter.*.exports.clear=clear"
9270 if [ $ctr = write_bytes ]; then
9272 f1=${testdir}/${tfile}
9274 f0=${testdir}/${tfile}
9278 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9281 cancel_lru_locks osc
9283 sum=$(do_facet ost1 $LCTL get_param \
9284 "obdfilter.*.exports.*.stats" |
9285 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9286 $1 == ctr { sum += $7 }
9287 END { printf("%0.0f", sum) }')
9289 if ((sum != bs * count)); then
9290 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9296 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9301 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9302 /sys/fs/lustre/ /sys/fs/lnet/"
9304 for dir in $dirs; do
9305 if [ -d $dir ]; then
9306 proc_dirs="$proc_dirs $dir"
9312 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9313 remote_ost_nodsh && skip "remote OST with nodsh" && return
9314 # First without trusting modes.
9315 find $proc_dirs -exec cat '{}' \; &> /dev/null
9317 # Second verifying readability.
9320 -exec cat '{}' \; &> /dev/null ||
9321 error "proc file read failed"
9323 for facet in $SINGLEMDS ost1; do
9324 do_facet $facet find $proc_dirs \
9325 ! -name req_history \
9326 -exec cat '{}' \\\; &> /dev/null
9328 do_facet $facet find $proc_dirs \
9329 ! -name req_history \
9331 -exec cat '{}' \\\; &> /dev/null ||
9332 error "proc file read failed"
9335 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9340 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9341 /sys/fs/lustre/ /sys/fs/lnet/"
9343 for dir in $dirs; do
9344 if [ -d $dir ]; then
9345 proc_dirs="$proc_dirs $dir"
9351 # Second verifying readability.
9354 -not -name force_lbug \
9355 -not -name changelog_mask \
9356 -exec badarea_io '{}' \; &> /dev/null ||
9357 error "find $proc_dirs failed"
9359 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9360 skip "Too old lustre on MDS" && return
9362 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9363 skip "Too old lustre on ost1" && return
9365 for facet in $SINGLEMDS ost1; do
9366 do_facet $facet find $proc_dirs \
9368 -not -name force_lbug \
9369 -not -name changelog_mask \
9370 -exec badarea_io '{}' \\\; &> /dev/null ||
9371 error "$facet find $proc_dirs failed"
9375 # remount the FS in case writes/reads /proc break the FS
9376 cleanup || error "failed to unmount"
9377 setup || error "failed to setup"
9380 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9382 test_140() { #bug-17379
9383 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9384 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9385 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9386 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9388 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9389 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9391 while i=`expr $i + 1`; do
9392 test_mkdir -p $i || error "Creating dir $i"
9393 cd $i || error "Changing to $i"
9394 ln -s ../stat stat || error "Creating stat symlink"
9395 # Read the symlink until ELOOP present,
9396 # not LBUGing the system is considered success,
9397 # we didn't overrun the stack.
9398 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9400 if [ $ret -eq 40 ]; then
9403 error "Open stat symlink"
9409 echo "The symlink depth = $i"
9410 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9411 error "Invalid symlink depth"
9413 # Test recursive symlink
9414 ln -s symlink_self symlink_self
9415 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9416 echo "open symlink_self returns $ret"
9417 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9419 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9423 local TF="$TMP/$tfile"
9425 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9427 cancel_lru_locks osc
9428 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9429 remount_client $MOUNT
9431 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9434 $TRUNCATE $DIR/$tfile 6000
9435 cancel_lru_locks osc
9436 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9439 echo "12345" >>$DIR/$tfile
9440 cancel_lru_locks osc
9441 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9444 echo "12345" >>$DIR/$tfile
9445 cancel_lru_locks osc
9446 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9451 run_test 150 "truncate/append tests"
9453 #LU-2902 roc_hit was not able to read all values from lproc
9454 function roc_hit_init() {
9455 local list=$(comma_list $(osts_nodes))
9456 local dir=$DIR/$tdir-check
9457 local file=$dir/file
9463 #use setstripe to do a write to every ost
9464 for i in $(seq 0 $((OSTCOUNT-1))); do
9465 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9466 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9467 idx=$(printf %04x $i)
9468 BEFORE=$(get_osd_param $list *OST*$idx stats |
9469 awk '$1 == "cache_access" {sum += $7}
9470 END { printf("%0.0f", sum) }')
9472 cancel_lru_locks osc
9473 cat $file >/dev/null
9475 AFTER=$(get_osd_param $list *OST*$idx stats |
9476 awk '$1 == "cache_access" {sum += $7}
9477 END { printf("%0.0f", sum) }')
9479 echo BEFORE:$BEFORE AFTER:$AFTER
9480 if ! let "AFTER - BEFORE == 4"; then
9482 error "roc_hit is not safe to use"
9490 function roc_hit() {
9491 local list=$(comma_list $(osts_nodes))
9492 echo $(get_osd_param $list '' stats |
9493 awk '$1 == "cache_hit" {sum += $7}
9494 END { printf("%0.0f", sum) }')
9497 function set_cache() {
9500 if [ "$2" == "off" ]; then
9503 local list=$(comma_list $(osts_nodes))
9504 set_osd_param $list '' $1_cache_enable $on
9506 cancel_lru_locks osc
9510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9511 remote_ost_nodsh && skip "remote OST with nodsh" && return
9514 local list=$(comma_list $(osts_nodes))
9516 # check whether obdfilter is cache capable at all
9517 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9518 echo "not cache-capable obdfilter"
9522 # check cache is enabled on all obdfilters
9523 if get_osd_param $list '' read_cache_enable | grep 0; then
9524 echo "oss cache is disabled"
9528 set_osd_param $list '' writethrough_cache_enable 1
9530 # check write cache is enabled on all obdfilters
9531 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9532 echo "oss write cache is NOT enabled"
9538 #define OBD_FAIL_OBD_NO_LRU 0x609
9539 do_nodes $list $LCTL set_param fail_loc=0x609
9541 # pages should be in the case right after write
9542 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9545 local BEFORE=$(roc_hit)
9546 cancel_lru_locks osc
9547 cat $DIR/$tfile >/dev/null
9548 local AFTER=$(roc_hit)
9550 do_nodes $list $LCTL set_param fail_loc=0
9552 if ! let "AFTER - BEFORE == CPAGES"; then
9553 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9556 # the following read invalidates the cache
9557 cancel_lru_locks osc
9558 set_osd_param $list '' read_cache_enable 0
9559 cat $DIR/$tfile >/dev/null
9561 # now data shouldn't be found in the cache
9563 cancel_lru_locks osc
9564 cat $DIR/$tfile >/dev/null
9566 if let "AFTER - BEFORE != 0"; then
9567 error "IN CACHE: before: $BEFORE, after: $AFTER"
9570 set_osd_param $list '' read_cache_enable 1
9573 run_test 151 "test cache on oss and controls ==============================="
9576 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9577 local TF="$TMP/$tfile"
9579 # simulate ENOMEM during write
9580 #define OBD_FAIL_OST_NOMEM 0x226
9581 lctl set_param fail_loc=0x80000226
9582 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9584 sync || error "sync failed"
9585 lctl set_param fail_loc=0
9587 # discard client's cache
9588 cancel_lru_locks osc
9590 # simulate ENOMEM during read
9591 lctl set_param fail_loc=0x80000226
9592 cmp $TF $DIR/$tfile || error "cmp failed"
9593 lctl set_param fail_loc=0
9597 run_test 152 "test read/write with enomem ============================"
9600 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9602 run_test 153 "test if fdatasync does not crash ======================="
9604 dot_lustre_fid_permission_check() {
9606 local ffid=$MOUNT/.lustre/fid/$fid
9609 echo "stat fid $fid"
9610 stat $ffid > /dev/null || error "stat $ffid failed."
9611 echo "touch fid $fid"
9612 touch $ffid || error "touch $ffid failed."
9613 echo "write to fid $fid"
9614 cat /etc/hosts > $ffid || error "write $ffid failed."
9615 echo "read fid $fid"
9616 diff /etc/hosts $ffid || error "read $ffid failed."
9617 echo "append write to fid $fid"
9618 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9619 echo "rename fid $fid"
9620 mv $ffid $test_dir/$tfile.1 &&
9621 error "rename $ffid to $tfile.1 should fail."
9622 touch $test_dir/$tfile.1
9623 mv $test_dir/$tfile.1 $ffid &&
9624 error "rename $tfile.1 to $ffid should fail."
9625 rm -f $test_dir/$tfile.1
9626 echo "truncate fid $fid"
9627 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9628 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9629 echo "link fid $fid"
9630 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9632 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9633 echo "setfacl fid $fid"
9634 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9635 echo "getfacl fid $fid"
9636 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9638 echo "unlink fid $fid"
9639 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9640 echo "mknod fid $fid"
9641 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9643 fid=[0xf00000400:0x1:0x0]
9644 ffid=$MOUNT/.lustre/fid/$fid
9646 echo "stat non-exist fid $fid"
9647 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9648 echo "write to non-exist fid $fid"
9649 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9650 echo "link new fid $fid"
9651 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9653 mkdir -p $test_dir/$tdir
9654 touch $test_dir/$tdir/$tfile
9655 fid=$($LFS path2fid $test_dir/$tdir)
9658 error "error: could not get fid for $test_dir/$dir/$tfile."
9660 ffid=$MOUNT/.lustre/fid/$fid
9663 ls $ffid > /dev/null || error "ls $ffid failed."
9664 echo "touch $fid/$tfile.1"
9665 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9667 echo "touch $MOUNT/.lustre/fid/$tfile"
9668 touch $MOUNT/.lustre/fid/$tfile && \
9669 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9671 echo "setxattr to $MOUNT/.lustre/fid"
9672 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9674 echo "listxattr for $MOUNT/.lustre/fid"
9675 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9677 echo "delxattr from $MOUNT/.lustre/fid"
9678 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9680 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9681 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9682 error "touch invalid fid should fail."
9684 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9685 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9686 error "touch non-normal fid should fail."
9688 echo "rename $tdir to $MOUNT/.lustre/fid"
9689 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9690 error "rename to $MOUNT/.lustre/fid should fail."
9692 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9694 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9695 local new_obf_mode=777
9697 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9698 chmod $new_obf_mode $DIR/.lustre/fid ||
9699 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9701 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9702 [ $obf_mode -eq $new_obf_mode ] ||
9703 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9705 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9706 chmod $old_obf_mode $DIR/.lustre/fid ||
9707 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9710 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9711 fid=$($LFS path2fid $test_dir/$tfile-2)
9713 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9715 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9716 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9717 error "create lov data thru .lustre failed"
9719 echo "cp /etc/passwd $test_dir/$tfile-2"
9720 cp /etc/passwd $test_dir/$tfile-2 ||
9721 error "copy to $test_dir/$tfile-2 failed."
9722 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9723 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9724 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9726 rm -rf $test_dir/tfile.lnk
9727 rm -rf $test_dir/$tfile-2
9731 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9732 skip "Need MDS version at least 2.4.1" && return
9735 local FID=$($LFS path2fid $DIR/$tfile)
9736 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9738 # check that we get the same pathname back
9739 local FOUND=$($LFS fid2path $MOUNT $FID)
9740 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9741 [ "$FOUND" != "$DIR/$tfile" ] &&
9742 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9746 run_test 154A "lfs path2fid and fid2path basic checks"
9749 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9750 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9751 { skip "Need MDS version at least 2.2.51"; return 0; }
9752 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9754 cp /etc/hosts $DIR/$tfile
9756 fid=$($LFS path2fid $DIR/$tfile)
9758 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9760 dot_lustre_fid_permission_check "$fid" $DIR ||
9761 error "dot lustre permission check $fid failed"
9763 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9765 touch $MOUNT/.lustre/file &&
9766 error "creation is not allowed under .lustre"
9768 mkdir $MOUNT/.lustre/dir &&
9769 error "mkdir is not allowed under .lustre"
9773 run_test 154a "Open-by-FID"
9776 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9777 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9778 { skip "Need MDS version at least 2.2.51"; return 0; }
9780 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9782 local remote_dir=$DIR/$tdir/remote_dir
9787 $LFS mkdir -i $MDTIDX $remote_dir ||
9788 error "create remote directory failed"
9790 cp /etc/hosts $remote_dir/$tfile
9792 fid=$($LFS path2fid $remote_dir/$tfile)
9794 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9796 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9797 error "dot lustre permission check $fid failed"
9800 run_test 154b "Open-by-FID for remote directory"
9803 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9804 skip "Need MDS version at least 2.4.1" && return
9806 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9807 local FID1=$($LFS path2fid $DIR/$tfile.1)
9808 local FID2=$($LFS path2fid $DIR/$tfile.2)
9809 local FID3=$($LFS path2fid $DIR/$tfile.3)
9812 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9813 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9814 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9816 [ "$FID" = "${!want}" ] ||
9817 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9821 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9822 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9823 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9827 run_test 154c "lfs path2fid and fid2path multiple arguments"
9830 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9831 skip "Need MDS version at least 2.5.53" && return
9834 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9838 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9845 fid=$($LFS path2fid $DIR/$tfile)
9848 cmd="exec $fd<$DIR/$tfile"
9850 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9851 echo $fid_list | grep $fid
9854 cmd="exec $fd>/dev/null"
9856 if [ $rc -ne 0 ]; then
9857 error "FID $fid not found in open files list $fid_list"
9860 run_test 154d "Verify open file fid"
9864 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9865 skip "Need MDS version at least 2.6.50" && return
9867 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9868 error ".lustre returned by readdir"
9871 run_test 154e ".lustre is not returned by readdir"
9874 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9875 test_mkdir -p -c1 $DIR/$tdir/d
9876 # test dirs inherit from its stripe
9877 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9878 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9879 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9880 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9883 # get fid of parents
9884 local FID0=$($LFS path2fid $DIR/$tdir/d)
9885 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9886 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9887 local FID3=$($LFS path2fid $DIR)
9889 # check that path2fid --parents returns expected <parent_fid>/name
9890 # 1) test for a directory (single parent)
9891 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9892 [ "$parent" == "$FID0/foo1" ] ||
9893 error "expected parent: $FID0/foo1, got: $parent"
9895 # 2) test for a file with nlink > 1 (multiple parents)
9896 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9897 echo "$parent" | grep -F "$FID1/$tfile" ||
9898 error "$FID1/$tfile not returned in parent list"
9899 echo "$parent" | grep -F "$FID2/link" ||
9900 error "$FID2/link not returned in parent list"
9902 # 3) get parent by fid
9903 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9904 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9905 echo "$parent" | grep -F "$FID1/$tfile" ||
9906 error "$FID1/$tfile not returned in parent list (by fid)"
9907 echo "$parent" | grep -F "$FID2/link" ||
9908 error "$FID2/link not returned in parent list (by fid)"
9910 # 4) test for entry in root directory
9911 parent=$($LFS path2fid --parents $DIR/f)
9912 echo "$parent" | grep -F "$FID3/f" ||
9913 error "$FID3/f not returned in parent list"
9915 # 5) test it on root directory
9916 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9917 error "$MOUNT should not have parents"
9919 # enable xattr caching and check that linkea is correctly updated
9920 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9921 save_lustre_params client "llite.*.xattr_cache" > $save
9922 lctl set_param llite.*.xattr_cache 1
9924 # 6.1) linkea update on rename
9925 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
9927 # get parents by fid
9928 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9929 # foo1 should no longer be returned in parent list
9930 echo "$parent" | grep -F "$FID1" &&
9931 error "$FID1 should no longer be in parent list"
9932 # the new path should appear
9933 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
9934 error "$FID2/$tfile.moved is not in parent list"
9936 # 6.2) linkea update on unlink
9937 rm -f $DIR/$tdir/d/foo2/link
9938 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9939 # foo2/link should no longer be returned in parent list
9940 echo "$parent" | grep -F "$FID2/link" &&
9941 error "$FID2/link should no longer be in parent list"
9945 restore_lustre_params < $save
9947 run_test 154f "get parent fids by reading link ea"
9949 test_155_small_load() {
9950 local temp=$TMP/$tfile
9951 local file=$DIR/$tfile
9953 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9954 error "dd of=$temp bs=6096 count=1 failed"
9956 cancel_lru_locks osc
9957 cmp $temp $file || error "$temp $file differ"
9959 $TRUNCATE $temp 6000
9960 $TRUNCATE $file 6000
9961 cmp $temp $file || error "$temp $file differ (truncate1)"
9963 echo "12345" >>$temp
9964 echo "12345" >>$file
9965 cmp $temp $file || error "$temp $file differ (append1)"
9967 echo "12345" >>$temp
9968 echo "12345" >>$file
9969 cmp $temp $file || error "$temp $file differ (append2)"
9975 test_155_big_load() {
9976 remote_ost_nodsh && skip "remote OST with nodsh" && return
9977 local temp=$TMP/$tfile
9978 local file=$DIR/$tfile
9981 local cache_size=$(do_facet ost$((MAXI+1)) \
9982 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9983 local large_file_size=$((cache_size * 2))
9985 echo "OSS cache size: $cache_size KB"
9986 echo "Large file size: $large_file_size KB"
9988 [ $MAXV -le $large_file_size ] && \
9989 skip_env "max available OST size needs > $large_file_size KB" && \
9992 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9994 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9995 error "dd of=$temp bs=$large_file_size count=1k failed"
9998 cancel_lru_locks osc
9999 cmp $temp $file || error "$temp $file differ"
10006 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10008 set_cache writethrough on
10009 test_155_small_load
10011 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
10014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10016 set_cache writethrough off
10017 test_155_small_load
10019 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10022 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10024 set_cache writethrough on
10025 test_155_small_load
10027 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10032 set_cache writethrough off
10033 test_155_small_load
10035 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10038 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10040 set_cache writethrough on
10043 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10046 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10048 set_cache writethrough off
10051 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10054 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10056 set_cache writethrough on
10059 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10064 set_cache writethrough off
10067 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10070 remote_ost_nodsh && skip "remote OST with nodsh" && return
10071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10075 local file="$DIR/$tfile"
10077 [ "$(facet_fstype ost1)" = "zfs" ] &&
10078 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
10083 log "Turn on read and write cache"
10085 set_cache writethrough on
10087 log "Write data and read it back."
10088 log "Read should be satisfied from the cache."
10089 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10091 cancel_lru_locks osc
10092 cat $file >/dev/null
10094 if ! let "AFTER - BEFORE == CPAGES"; then
10095 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10097 log "cache hits:: before: $BEFORE, after: $AFTER"
10100 log "Read again; it should be satisfied from the cache."
10102 cancel_lru_locks osc
10103 cat $file >/dev/null
10105 if ! let "AFTER - BEFORE == CPAGES"; then
10106 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10108 log "cache hits:: before: $BEFORE, after: $AFTER"
10112 log "Turn off the read cache and turn on the write cache"
10114 set_cache writethrough on
10116 log "Read again; it should be satisfied from the cache."
10118 cancel_lru_locks osc
10119 cat $file >/dev/null
10121 if ! let "AFTER - BEFORE == CPAGES"; then
10122 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10124 log "cache hits:: before: $BEFORE, after: $AFTER"
10127 log "Read again; it should not be satisfied from the cache."
10129 cancel_lru_locks osc
10130 cat $file >/dev/null
10132 if ! let "AFTER - BEFORE == 0"; then
10133 error "IN CACHE: before: $BEFORE, after: $AFTER"
10135 log "cache hits:: before: $BEFORE, after: $AFTER"
10138 log "Write data and read it back."
10139 log "Read should be satisfied from the cache."
10140 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10142 cancel_lru_locks osc
10143 cat $file >/dev/null
10145 if ! let "AFTER - BEFORE == CPAGES"; then
10146 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10148 log "cache hits:: before: $BEFORE, after: $AFTER"
10151 log "Read again; it should not be satisfied from the cache."
10153 cancel_lru_locks osc
10154 cat $file >/dev/null
10156 if ! let "AFTER - BEFORE == 0"; then
10157 error "IN CACHE: before: $BEFORE, after: $AFTER"
10159 log "cache hits:: before: $BEFORE, after: $AFTER"
10163 log "Turn off read and write cache"
10165 set_cache writethrough off
10167 log "Write data and read it back"
10168 log "It should not be satisfied from the cache."
10170 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10171 cancel_lru_locks osc
10173 cat $file >/dev/null
10175 if ! let "AFTER - BEFORE == 0"; then
10176 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10178 log "cache hits:: before: $BEFORE, after: $AFTER"
10181 log "Turn on the read cache and turn off the write cache"
10183 set_cache writethrough off
10185 log "Write data and read it back"
10186 log "It should not be satisfied from the cache."
10188 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10190 cancel_lru_locks osc
10191 cat $file >/dev/null
10193 if ! let "AFTER - BEFORE == 0"; then
10194 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10196 log "cache hits:: before: $BEFORE, after: $AFTER"
10199 log "Read again; it should be satisfied from the cache."
10201 cancel_lru_locks osc
10202 cat $file >/dev/null
10204 if ! let "AFTER - BEFORE == CPAGES"; then
10205 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10207 log "cache hits:: before: $BEFORE, after: $AFTER"
10212 run_test 156 "Verification of tunables ============================"
10216 if [[ $MDSCOUNT -gt 1 ]]; then
10217 error_ignore bz17935 $*
10225 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10227 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10229 if [ $MASK -eq 1 ]; then
10230 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10232 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10236 changelog_extract_field() {
10240 local identifier=$4
10242 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10243 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10248 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10249 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10250 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10251 { skip "Need MDS version at least 2.2.0"; return; }
10253 local CL_USERS="mdd.$MDT0.changelog_users"
10254 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10255 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10256 echo "Registered as changelog user $USER"
10257 $GET_CL_USERS | grep -q $USER ||
10258 error "User $USER not found in changelog_users"
10261 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10262 touch $DIR/$tdir/pics/2008/zachy/timestamp
10263 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10264 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10265 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10266 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10267 rm $DIR/$tdir/pics/desktop.jpg
10269 $LFS changelog $MDT0 | tail -5
10271 echo "verifying changelog mask"
10272 changelog_chmask "MKDIR"
10273 changelog_chmask "CLOSE"
10275 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10276 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10278 changelog_chmask "MKDIR"
10279 changelog_chmask "CLOSE"
10281 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10282 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10284 $LFS changelog $MDT0
10285 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10286 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10287 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10288 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10291 echo "verifying target fid"
10292 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10293 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10294 [ "$fidc" == "$fidf" ] ||
10295 err17935 "fid in changelog $fidc != file fid $fidf"
10296 echo "verifying parent fid"
10297 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10298 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10299 [ "$fidc" == "$fidf" ] ||
10300 err17935 "pfid in changelog $fidc != dir fid $fidf"
10302 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10303 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10304 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10305 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10306 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10307 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10309 MIN_REC=$($GET_CL_USERS |
10310 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10311 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10312 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10313 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10314 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10316 # LU-3446 changelog index reset on MDT restart
10317 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10318 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10319 $LFS changelog_clear $MDT0 $USER 0
10320 stop $SINGLEMDS || error "Fail to stop MDT."
10321 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10322 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10323 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10324 [ $CUR_REC1 == $CUR_REC2 ] ||
10325 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10327 echo "verifying user deregister"
10328 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10329 $GET_CL_USERS | grep -q $USER &&
10330 error "User $USER still in changelog_users"
10332 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10333 if [ $USERS -eq 0 ]; then
10334 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10335 touch $DIR/$tdir/chloe
10336 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10337 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10338 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10340 echo "$USERS other changelog users; can't verify off"
10343 run_test 160a "changelog sanity"
10345 test_160b() { # LU-3587
10346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10347 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10348 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10349 { skip "Need MDS version at least 2.2.0"; return; }
10351 local CL_USERS="mdd.$MDT0.changelog_users"
10352 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10353 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10354 echo "Registered as changelog user $USER"
10355 $GET_CL_USERS | grep -q $USER ||
10356 error "User $USER not found in changelog_users"
10358 local LONGNAME1=$(str_repeat a 255)
10359 local LONGNAME2=$(str_repeat b 255)
10362 echo "creating very long named file"
10363 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10364 echo "moving very long named file"
10365 mv $LONGNAME1 $LONGNAME2
10367 $LFS changelog $MDT0 | grep RENME
10369 echo "deregistering $USER"
10370 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10374 run_test 160b "Verify that very long rename doesn't crash in changelog"
10378 local server_version=$(lustre_version_code $SINGLEMDS)
10380 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10381 [[ $server_version -gt $(version_code 2.5.1) &&
10382 $server_version -lt $(version_code 2.5.50) ]] ||
10383 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10384 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10386 # Registration step
10387 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10388 changelog_register -n)
10391 mkdir -p $DIR/$tdir
10392 $MCREATE $DIR/$tdir/foo_160c
10393 changelog_chmask "TRUNC"
10394 $TRUNCATE $DIR/$tdir/foo_160c 200
10395 changelog_chmask "TRUNC"
10396 $TRUNCATE $DIR/$tdir/foo_160c 199
10397 $LFS changelog $MDT0
10398 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10399 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10400 $LFS changelog_clear $MDT0 $USER 0
10402 # Deregistration step
10403 echo "deregistering $USER"
10404 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10406 run_test 160c "verify that changelog log catch the truncate event"
10409 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10410 test_mkdir -p -c1 $DIR/$tdir
10411 cp /etc/hosts $DIR/$tdir/$tfile
10412 test_mkdir -c1 $DIR/$tdir/foo1
10413 test_mkdir -c1 $DIR/$tdir/foo2
10414 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10415 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10416 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10417 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10418 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10419 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10420 $LFS fid2path $DIR $FID
10421 err17935 "bad link ea"
10424 rm $DIR/$tdir/foo2/zachary
10426 rm $DIR/$tdir/foo2/thor
10428 rm $DIR/$tdir/$tfile
10430 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10431 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10433 $LFS fid2path $DIR $FID
10434 err17935 "bad link rename"
10436 rm $DIR/$tdir/foo2/maggie
10439 local longname=filename_avg_len_is_thirty_two_
10440 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10441 error "failed to hardlink many files"
10442 links=$($LFS fid2path $DIR $FID | wc -l)
10443 echo -n "${links}/1000 links in link EA"
10444 [[ $links -gt 60 ]] ||
10445 err17935 "expected at least 60 links in link EA"
10446 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10447 error "failed to unlink many hardlinks"
10449 run_test 161a "link ea sanity"
10452 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10453 [ $MDSCOUNT -lt 2 ] &&
10454 skip "skipping remote directory test" && return
10456 local remote_dir=$DIR/$tdir/remote_dir
10458 mkdir -p $DIR/$tdir
10459 $LFS mkdir -i $MDTIDX $remote_dir ||
10460 error "create remote directory failed"
10462 cp /etc/hosts $remote_dir/$tfile
10463 mkdir -p $remote_dir/foo1
10464 mkdir -p $remote_dir/foo2
10465 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10466 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10467 ln $remote_dir/$tfile $remote_dir/foo1/luna
10468 ln $remote_dir/$tfile $remote_dir/foo2/thor
10470 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10472 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10473 $LFS fid2path $DIR $FID
10474 err17935 "bad link ea"
10477 rm $remote_dir/foo2/zachary
10479 rm $remote_dir/foo2/thor
10481 rm $remote_dir/$tfile
10483 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10484 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10485 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10486 $LFS fid2path $DIR $FID
10487 err17935 "bad link rename"
10489 rm $remote_dir/foo2/maggie
10492 local longname=filename_avg_len_is_thirty_two_
10493 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10494 error "failed to hardlink many files"
10495 links=$($LFS fid2path $DIR $FID | wc -l)
10496 echo -n "${links}/1000 links in link EA"
10497 [[ ${links} -gt 60 ]] ||
10498 err17935 "expected at least 60 links in link EA"
10499 unlinkmany $remote_dir/foo2/$longname 1000 ||
10500 error "failed to unlink many hardlinks"
10502 run_test 161b "link ea sanity under remote directory"
10505 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10506 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10507 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10508 skip "Need MDS version at least 2.1.5" && return
10510 # define CLF_RENAME_LAST 0x0001
10511 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10512 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10513 changelog_register -n)
10515 mkdir -p $DIR/$tdir
10516 touch $DIR/$tdir/foo_161c
10517 touch $DIR/$tdir/bar_161c
10518 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10519 $LFS changelog $MDT0 | grep RENME
10520 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10522 $LFS changelog_clear $MDT0 $USER 0
10523 if [ x$flags != "x0x1" ]; then
10524 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10526 error "flag $flags is not 0x1"
10528 echo "rename overwrite a target having nlink = 1," \
10529 "changelog record has flags of $flags"
10531 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10532 touch $DIR/$tdir/foo_161c
10533 touch $DIR/$tdir/bar_161c
10534 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10535 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10536 $LFS changelog $MDT0 | grep RENME
10537 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10538 $LFS changelog_clear $MDT0 $USER 0
10539 if [ x$flags != "x0x0" ]; then
10540 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10542 error "flag $flags is not 0x0"
10544 echo "rename overwrite a target having nlink > 1," \
10545 "changelog record has flags of $flags"
10547 # rename doesn't overwrite a target (changelog flag 0x0)
10548 touch $DIR/$tdir/foo_161c
10549 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10550 $LFS changelog $MDT0 | grep RENME
10551 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10552 $LFS changelog_clear $MDT0 $USER 0
10553 if [ x$flags != "x0x0" ]; then
10554 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10556 error "flag $flags is not 0x0"
10558 echo "rename doesn't overwrite a target," \
10559 "changelog record has flags of $flags"
10561 # define CLF_UNLINK_LAST 0x0001
10562 # unlink a file having nlink = 1 (changelog flag 0x1)
10563 rm -f $DIR/$tdir/foo2_161c
10564 $LFS changelog $MDT0 | grep UNLNK
10565 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10566 $LFS changelog_clear $MDT0 $USER 0
10567 if [ x$flags != "x0x1" ]; then
10568 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10570 error "flag $flags is not 0x1"
10572 echo "unlink a file having nlink = 1," \
10573 "changelog record has flags of $flags"
10575 # unlink a file having nlink > 1 (changelog flag 0x0)
10576 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10577 rm -f $DIR/$tdir/foobar_161c
10578 $LFS changelog $MDT0 | grep UNLNK
10579 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10580 $LFS changelog_clear $MDT0 $USER 0
10581 if [ x$flags != "x0x0" ]; then
10582 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10584 error "flag $flags is not 0x0"
10586 echo "unlink a file having nlink > 1," \
10587 "changelog record has flags of $flags"
10588 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10590 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10597 local path=$(${LFS} fid2path $*)
10598 # Remove the '//' indicating a remote directory
10599 path=$(echo $path | sed 's#//#/#g')
10602 if [ $RC -ne 0 ]; then
10603 err17935 "path looked up of $expected failed. Error $RC"
10605 elif [ "${path}" != "${expected}" ]; then
10606 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10609 echo "fid $fid resolves to path $path (expected $expected)"
10613 # Make changes to filesystem
10614 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10615 test_mkdir -p -c1 $DIR/$tdir/d2
10616 touch $DIR/$tdir/d2/$tfile
10617 touch $DIR/$tdir/d2/x1
10618 touch $DIR/$tdir/d2/x2
10619 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10620 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10622 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10623 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10624 error "check path $tdir/d2/$tfile failed"
10627 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10628 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10629 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10630 error "check path $tdir/d2/p/q/r/slink failed"
10632 # softlink to wrong file
10633 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10634 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10635 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10636 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10639 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10640 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10641 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10642 # fid2path dir/fsname should both work
10643 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10644 error "check path $tdir/d2/a/b/c/new_file failed"
10645 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10646 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10648 # hardlink count: check that there are 2 links
10649 # Doesnt work with CMD yet: 17935
10650 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10651 err17935 "expected 2 links"
10653 # hardlink indexing: remove the first link
10654 rm $DIR/$tdir/d2/p/q/r/hlink
10655 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10656 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10660 run_test 162 "path lookup sanity"
10663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10664 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10667 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10668 error "create striped dir failed"
10670 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10671 tail -n 1 | awk '{print $2}')
10672 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10674 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10675 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10678 for ((i=0;i<5;i++)); do
10679 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10680 error "get fid for f$i failed"
10681 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10682 error "check path $tdir/striped_dir/f$i failed"
10684 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10685 error "get fid for d$i failed"
10686 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10687 error "check path $tdir/striped_dir/d$i failed"
10692 run_test 162b "striped directory path lookup sanity"
10694 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10696 test_mkdir $DIR/$tdir.local
10697 test_mkdir $DIR/$tdir.remote
10698 local lpath=$tdir.local
10699 local rpath=$tdir.remote
10701 for ((i = 0; i <= 101; i++)); do
10704 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10705 error "get fid for local directory $DIR/$lpath failed"
10706 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10707 error "check path for local directory $DIR/$lpath failed"
10710 test_mkdir $DIR/$rpath
10711 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10712 error "get fid for remote directory $DIR/$rpath failed"
10713 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10714 error "check path for remote directory $DIR/$rpath failed"
10719 run_test 162c "fid2path works with paths 100 or more directories deep"
10722 # do directio so as not to populate the page cache
10723 log "creating a 10 Mb file"
10724 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10725 log "starting reads"
10726 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10727 log "truncating the file"
10728 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10730 kill %+ || true # reads might have finished
10731 echo "wait until dd is finished"
10733 log "removing the temporary file"
10734 rm -rf $DIR/$tfile || error "tmp file removal failed"
10736 run_test 169 "parallel read and truncate should not deadlock"
10739 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10740 $LCTL clear # bug 18514
10741 $LCTL debug_daemon start $TMP/${tfile}_log_good
10743 $LCTL debug_daemon stop
10744 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10745 error "sed failed to read log_good"
10747 $LCTL debug_daemon start $TMP/${tfile}_log_good
10749 $LCTL debug_daemon stop
10751 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10752 error "lctl df log_bad failed"
10754 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10755 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10757 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10758 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10760 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10761 error "bad_line good_line1 good_line2 are empty"
10763 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10764 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10765 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10767 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10768 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10769 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10771 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10772 error "bad_line_new good_line_new are empty"
10774 local expected_good=$((good_line1 + good_line2*2))
10776 rm -f $TMP/${tfile}*
10777 # LU-231, short malformed line may not be counted into bad lines
10778 if [ $bad_line -ne $bad_line_new ] &&
10779 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10780 error "expected $bad_line bad lines, but got $bad_line_new"
10784 if [ $expected_good -ne $good_line_new ]; then
10785 error "expected $expected_good good lines, but got $good_line_new"
10790 run_test 170 "test lctl df to handle corrupted log ====================="
10792 test_171() { # bug20592
10793 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10794 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10795 $LCTL set_param fail_loc=0x50e
10796 $LCTL set_param fail_val=3000
10797 multiop_bg_pause $DIR/$tfile O_s || true
10799 kill -USR1 $MULTIPID
10803 if dmesg | grep "recursive fault"; then
10804 error "caught a recursive fault"
10806 $LCTL set_param fail_loc=0
10809 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10811 # it would be good to share it with obdfilter-survey/iokit-libecho code
10812 setup_obdecho_osc () {
10815 local obdfilter_name=$2
10816 echo "Creating new osc for $obdfilter_name on $ost_nid"
10817 # make sure we can find loopback nid
10818 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10820 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10821 ${obdfilter_name}_osc_UUID || rc=2; }
10822 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10823 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10827 cleanup_obdecho_osc () {
10828 local obdfilter_name=$1
10829 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10830 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10837 local pages=${3:-64}
10842 local obd_size=$(get_obd_size $node $OBD)
10843 local page_size=$(get_page_size $node)
10844 if [[ -n "$obd_size" ]]; then
10845 local new_count=$((obd_size / (pages * page_size / 1024)))
10846 [[ $new_count -ge $count ]] || count=$new_count
10849 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10850 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10852 if [ $rc -eq 0 ]; then
10853 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10854 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10856 echo "New object id is $id"
10857 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10859 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10860 "test_brw $count w v $pages $id" || rc=4; }
10861 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10863 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10864 "cleanup" || rc=5; }
10865 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10866 "detach" || rc=6; }
10867 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10873 remote_ost_nodsh && skip "remote OST with nodsh" && return
10875 local rmmod_local=0
10877 if ! module_loaded obdecho; then
10878 load_module obdecho/obdecho
10882 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10883 local host=$(lctl get_param -n osc.$osc.import |
10884 awk '/current_connection:/ {print $2}' )
10885 local target=$(lctl get_param -n osc.$osc.import |
10886 awk '/target:/ {print $2}' )
10887 target=${target%_UUID}
10889 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10890 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10891 [[ -n $target ]] && cleanup_obdecho_osc $target
10892 [ $rmmod_local -eq 1 ] && rmmod obdecho
10895 run_test 180a "test obdecho on osc"
10898 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10899 remote_ost_nodsh && skip "remote OST with nodsh" && return
10901 local rmmod_remote=0
10903 do_facet ost1 "lsmod | grep -q obdecho || " \
10904 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10905 "modprobe obdecho; }" && rmmod_remote=1
10906 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10907 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10908 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10911 run_test 180b "test obdecho directly on obdfilter"
10913 test_180c() { # LU-2598
10914 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10915 remote_ost_nodsh && skip "remote OST with nodsh" && return
10916 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10917 skip "Need MDS version at least 2.4.0" && return
10920 local rmmod_remote=false
10921 local pages=16384 # 64MB bulk I/O RPC size
10924 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10925 rmmod_remote=true || error "failed to load module obdecho"
10927 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10929 if [ -n "$target" ]; then
10930 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10932 echo "there is no obdfilter target on ost1"
10935 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10938 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10940 test_181() { # bug 22177
10941 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10942 # create enough files to index the directory
10943 createmany -o $DIR/$tdir/foobar 4000
10944 # print attributes for debug purpose
10947 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10949 # remove the files & current working dir
10950 unlinkmany $DIR/$tdir/foobar 4000
10952 kill -USR1 $MULTIPID
10954 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10957 run_test 181 "Test open-unlinked dir ========================"
10960 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10961 # disable MDC RPC lock wouldn't crash client
10965 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10966 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10967 $LCTL set_param fail_loc=0x804
10969 for (( i=0; i < $tcount; i++ )) ; do
10970 mkdir $DIR/$tdir/$i
10971 createmany -o $DIR/$tdir/$i/f- $fcount &
10975 for (( i=0; i < $tcount; i++ )) ; do
10976 unlinkmany $DIR/$tdir/$i/f- $fcount &
10982 $LCTL set_param fail_loc=0
10984 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10986 test_183() { # LU-2275
10987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10988 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10989 skip "Need MDS version at least 2.3.56" && return
10991 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10992 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10993 echo aaa > $DIR/$tdir/$tfile
10995 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10996 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10998 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10999 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
11001 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
11003 # Flush negative dentry cache
11004 touch $DIR/$tdir/$tfile
11006 # We are not checking for any leaked references here, they'll
11007 # become evident next time we do cleanup with module unload.
11010 run_test 183 "No crash or request leak in case of strange dispositions ========"
11012 # test suite 184 is for LU-2016, LU-2017
11014 check_swap_layouts_support && return 0
11016 dir0=$DIR/$tdir/$testnum
11017 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11022 $SETSTRIPE -c1 $file1
11024 $SETSTRIPE -c2 $file2
11026 gen1=$($GETSTRIPE -g $file1)
11027 gen2=$($GETSTRIPE -g $file2)
11029 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11030 gen=$($GETSTRIPE -g $file1)
11031 [[ $gen1 != $gen ]] ||
11032 "Layout generation on $file1 does not change"
11033 gen=$($GETSTRIPE -g $file2)
11034 [[ $gen2 != $gen ]] ||
11035 "Layout generation on $file2 does not change"
11037 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11038 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11040 run_test 184a "Basic layout swap"
11043 check_swap_layouts_support && return 0
11045 dir0=$DIR/$tdir/$testnum
11046 mkdir -p $dir0 || error "creating dir $dir0"
11053 $SETSTRIPE -c1 $file1
11054 $SETSTRIPE -c2 $file2
11055 $SETSTRIPE -c1 $file3
11056 chown $RUNAS_ID $file3
11057 gen1=$($GETSTRIPE -g $file1)
11058 gen2=$($GETSTRIPE -g $file2)
11060 $LFS swap_layouts $dir1 $dir2 &&
11061 error "swap of directories layouts should fail"
11062 $LFS swap_layouts $dir1 $file1 &&
11063 error "swap of directory and file layouts should fail"
11064 $RUNAS $LFS swap_layouts $file1 $file2 &&
11065 error "swap of file we cannot write should fail"
11066 $LFS swap_layouts $file1 $file3 &&
11067 error "swap of file with different owner should fail"
11068 /bin/true # to clear error code
11070 run_test 184b "Forbidden layout swap (will generate errors)"
11073 check_swap_layouts_support && return 0
11075 local dir0=$DIR/$tdir/$testnum
11076 mkdir -p $dir0 || error "creating dir $dir0"
11078 local ref1=$dir0/ref1
11079 local ref2=$dir0/ref2
11080 local file1=$dir0/file1
11081 local file2=$dir0/file2
11082 # create a file large enough for the concurent test
11083 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11084 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11085 echo "ref file size: ref1($(stat -c %s $ref1))," \
11086 "ref2($(stat -c %s $ref2))"
11089 dd if=$ref1 of=$file1 bs=16k &
11092 # Make sure dd starts to copy file
11093 while [ ! -f $file1 ]; do sleep 0.1; done
11095 $LFS swap_layouts $file1 $file2
11098 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11099 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11101 # how many bytes copied before swapping layout
11102 local copied=$(stat -c %s $file2)
11103 local remaining=$(stat -c %s $ref1)
11104 remaining=$((remaining - copied))
11105 echo "Copied $copied bytes before swapping layout..."
11107 cmp -n $copied $file1 $ref2 | grep differ &&
11108 error "Content mismatch [0, $copied) of ref2 and file1"
11109 cmp -n $copied $file2 $ref1 ||
11110 error "Content mismatch [0, $copied) of ref1 and file2"
11111 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11112 error "Content mismatch [$copied, EOF) of ref1 and file1"
11115 rm -f $ref1 $ref2 $file1 $file2
11117 run_test 184c "Concurrent write and layout swap"
11120 check_swap_layouts_support && return 0
11121 [ -z "$(which getfattr 2>/dev/null)" ] &&
11122 skip "no getfattr command" && return 0
11124 local file1=$DIR/$tdir/$tfile-1
11125 local file2=$DIR/$tdir/$tfile-2
11126 local file3=$DIR/$tdir/$tfile-3
11130 mkdir -p $DIR/$tdir
11131 touch $file1 || error "create $file1 failed"
11132 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11133 error "create $file2 failed"
11134 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11135 error "create $file3 failed"
11136 lovea1=$($LFS getstripe $file1 | sed 1d)
11138 $LFS swap_layouts $file2 $file3 ||
11139 error "swap $file2 $file3 layouts failed"
11140 $LFS swap_layouts $file1 $file2 ||
11141 error "swap $file1 $file2 layouts failed"
11143 lovea2=$($LFS getstripe $file2 | sed 1d)
11144 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11146 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11147 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11149 run_test 184d "allow stripeless layouts swap"
11152 check_swap_layouts_support && return 0
11153 [ -z "$(which getfattr 2>/dev/null)" ] &&
11154 skip "no getfattr command" && return 0
11156 local file1=$DIR/$tdir/$tfile-1
11157 local file2=$DIR/$tdir/$tfile-2
11158 local file3=$DIR/$tdir/$tfile-3
11161 mkdir -p $DIR/$tdir
11162 touch $file1 || error "create $file1 failed"
11163 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11164 error "create $file2 failed"
11165 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11166 error "create $file3 failed"
11168 $LFS swap_layouts $file1 $file2 ||
11169 error "swap $file1 $file2 layouts failed"
11171 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11172 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11174 echo 123 > $file1 || error "Should be able to write into $file1"
11176 $LFS swap_layouts $file1 $file3 ||
11177 error "swap $file1 $file3 layouts failed"
11179 echo 123 > $file1 || error "Should be able to write into $file1"
11181 rm -rf $file1 $file2 $file3
11183 run_test 184e "Recreate layout after stripeless layout swaps"
11185 test_185() { # LU-2441
11186 # LU-3553 - no volatile file support in old servers
11187 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11188 { skip "Need MDS version at least 2.3.60"; return 0; }
11190 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11191 touch $DIR/$tdir/spoo
11192 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11193 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11194 error "cannot create/write a volatile file"
11195 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11196 error "FID is still valid after close"
11198 multiop_bg_pause $DIR/$tdir vVw4096_c
11205 # assume that the next FID for this client is sequential, since stdout
11206 # is unfortunately eaten by multiop_bg_pause
11207 local n=$((${fidv[1]} + 1))
11208 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11209 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11210 error "FID is missing before close"
11211 kill -USR1 $multi_pid
11212 # 1 second delay, so if mtime change we will see it
11214 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11215 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11217 run_test 185 "Volatile file support"
11220 local dir0=$DIR/$tdir/$testnum
11221 mkdir -p $dir0 || error "creating dir $dir0"
11223 local file=$dir0/file1
11224 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11225 local dv1=$($LFS data_version $file)
11226 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11227 local dv2=$($LFS data_version $file)
11228 [[ $dv1 != $dv2 ]] ||
11229 error "data version did not change on write $dv1 == $dv2"
11234 run_test 187a "Test data version change"
11237 local dir0=$DIR/$tdir/$testnum
11238 mkdir -p $dir0 || error "creating dir $dir0"
11240 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11241 [[ ${DV[0]} != ${DV[1]} ]] ||
11242 error "data version did not change on write"\
11243 " ${DV[0]} == ${DV[1]}"
11248 run_test 187b "Test data version change on volatile file"
11251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11252 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11254 local POOL=${POOL:-cea1}
11255 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11256 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11259 local last_ost=$(($OSTCOUNT - 1))
11261 local ost_list=$(seq $first_ost $ost_step $last_ost)
11262 local ost_range="$first_ost $last_ost $ost_step"
11263 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11264 local file_dir=$POOL_ROOT/file_tst
11265 local subdir=$test_path/subdir
11269 # former test_200a test_200b
11270 pool_add $POOL || { rc=$? ; break; }
11271 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11272 # former test_200c test_200d
11273 mkdir -p $test_path
11274 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11275 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11277 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11278 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11279 || { rc=$? ; break; }
11280 # former test_200e test_200f
11281 local files=$((OSTCOUNT*3))
11282 pool_alloc_files $POOL $test_path $files "$ost_list" \
11283 || { rc=$? ; break; }
11284 pool_create_files $POOL $file_dir $files "$ost_list" \
11285 || { rc=$? ; break; }
11286 # former test_200g test_200h
11287 pool_lfs_df $POOL || { rc=$? ; break; }
11288 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11290 # former test_201a test_201b test_201c
11291 pool_remove_first_target $POOL || { rc=$? ; break; }
11293 local f=$test_path/$tfile
11294 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11295 pool_remove $POOL $f || { rc=$? ; break; }
11302 run_test 200 "OST pools"
11304 # usage: default_attr <count | size | offset>
11306 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11309 # usage: check_default_stripe_attr
11310 check_default_stripe_attr() {
11311 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11313 --stripe-count|--count)
11314 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11315 --stripe-size|--size)
11316 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11317 --stripe-index|--index)
11320 error "unknown getstripe attr '$1'"
11323 [ $ACTUAL != $EXPECTED ] &&
11324 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11328 test_mkdir -p $DIR/$tdir
11329 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11331 check_default_stripe_attr --stripe-count
11332 check_default_stripe_attr --stripe-size
11333 check_default_stripe_attr --stripe-index
11337 run_test 204a "Print default stripe attributes ================="
11340 test_mkdir -p $DIR/$tdir
11341 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11343 check_default_stripe_attr --stripe-size
11344 check_default_stripe_attr --stripe-index
11348 run_test 204b "Print default stripe size and offset ==========="
11351 test_mkdir -p $DIR/$tdir
11352 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11354 check_default_stripe_attr --stripe-count
11355 check_default_stripe_attr --stripe-index
11359 run_test 204c "Print default stripe count and offset ==========="
11362 test_mkdir -p $DIR/$tdir
11363 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11365 check_default_stripe_attr --stripe-count
11366 check_default_stripe_attr --stripe-size
11370 run_test 204d "Print default stripe count and size ============="
11373 test_mkdir -p $DIR/$tdir
11374 $SETSTRIPE -d $DIR/$tdir
11376 check_default_stripe_attr --stripe-count --raw
11377 check_default_stripe_attr --stripe-size --raw
11378 check_default_stripe_attr --stripe-index --raw
11382 run_test 204e "Print raw stripe attributes ================="
11385 test_mkdir -p $DIR/$tdir
11386 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11388 check_default_stripe_attr --stripe-size --raw
11389 check_default_stripe_attr --stripe-index --raw
11393 run_test 204f "Print raw stripe size and offset ==========="
11396 test_mkdir -p $DIR/$tdir
11397 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11399 check_default_stripe_attr --stripe-count --raw
11400 check_default_stripe_attr --stripe-index --raw
11404 run_test 204g "Print raw stripe count and offset ==========="
11407 test_mkdir -p $DIR/$tdir
11408 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11410 check_default_stripe_attr --stripe-count --raw
11411 check_default_stripe_attr --stripe-size --raw
11415 run_test 204h "Print raw stripe count and size ============="
11417 # Figure out which job scheduler is being used, if any,
11418 # or use a fake one
11419 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11420 JOBENV=SLURM_JOB_ID
11421 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11423 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11425 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11426 JOBENV=LOADL_STEP_ID
11427 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11433 verify_jobstats() {
11437 # clear old jobstats
11438 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11439 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11441 # use a new JobID for this test, or we might see an old one
11442 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11446 log "Using JobID environment variable $JOBENV=$JOBVAL"
11448 if [ $JOBENV = "FAKE_JOBID" ]; then
11449 FAKE_JOBID=$JOBVAL $cmd
11454 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11455 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11456 do_facet $FACET lctl get_param mdt.*.job_stats |
11457 grep $JOBVAL || error "No job stats found on MDT $FACET"
11459 if [ "$target" = "ost" -o "$target" = "both" ]; then
11461 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11462 grep $JOBVAL || error "No job stats found on OST $FACET"
11468 NEW_JOBENV=${1:-$OLD_JOBENV}
11469 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11470 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11473 test_205() { # Job stats
11474 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11475 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11476 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11477 skip "Server doesn't support jobstats" && return 0
11478 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11481 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11482 if [ $OLD_JOBENV != $JOBENV ]; then
11483 jobstats_set $JOBENV
11484 trap jobstats_set EXIT
11487 local user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11488 changelog_register -n)
11489 echo "Registered as changelog user $user"
11492 cmd="mkdir $DIR/$tfile"
11493 verify_jobstats "$cmd" "mdt"
11495 cmd="rm -fr $DIR/$tfile"
11496 verify_jobstats "$cmd" "mdt"
11498 cmd="mknod $DIR/$tfile c 1 3"
11499 verify_jobstats "$cmd" "mdt"
11501 cmd="rm -f $DIR/$tfile"
11502 verify_jobstats "$cmd" "mdt"
11504 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11505 verify_jobstats "$cmd" "mdt"
11507 cmd="touch $DIR/$tfile"
11508 verify_jobstats "$cmd" "both"
11510 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11511 verify_jobstats "$cmd" "ost"
11513 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11514 verify_jobstats "$cmd" "ost"
11516 cmd="$TRUNCATE $DIR/$tfile 0"
11517 verify_jobstats "$cmd" "both"
11519 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11520 verify_jobstats "$cmd" "mdt"
11522 # Ensure that jobid are present in changelog (if supported by MDS)
11523 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11525 $LFS changelog $MDT0 | tail -9
11526 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11527 [ $jobids -eq 9 ] ||
11528 error "Wrong changelog jobid count $jobids != 9"
11532 jobstats_set $JOBENV
11534 $LFS changelog $MDT0 | tail -1
11535 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11536 [ $jobids -eq 0 ] ||
11537 error "Unexpected jobids when jobid_var=$JOBENV"
11541 rm -f $DIR/jobstats_test_rename
11543 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11545 run_test 205 "Verify job stats"
11547 # LU-1480, LU-1773 and LU-1657
11549 mkdir -p $DIR/$tdir
11550 $SETSTRIPE -c -1 $DIR/$tdir
11551 #define OBD_FAIL_LOV_INIT 0x1403
11552 $LCTL set_param fail_loc=0xa0001403
11553 $LCTL set_param fail_val=1
11554 touch $DIR/$tdir/$tfile || true
11556 run_test 206 "fail lov_init_raid0() doesn't lbug"
11559 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11560 local fsz=`stat -c %s $DIR/$tfile`
11561 cancel_lru_locks mdc
11563 # do not return layout in getattr intent
11564 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11565 $LCTL set_param fail_loc=0x170
11566 local sz=`stat -c %s $DIR/$tfile`
11568 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11572 run_test 207a "can refresh layout at glimpse"
11575 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11576 local cksum=`md5sum $DIR/$tfile`
11577 local fsz=`stat -c %s $DIR/$tfile`
11578 cancel_lru_locks mdc
11579 cancel_lru_locks osc
11581 # do not return layout in getattr intent
11582 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11583 $LCTL set_param fail_loc=0x171
11585 # it will refresh layout after the file is opened but before read issues
11586 echo checksum is "$cksum"
11587 echo "$cksum" |md5sum -c --quiet || error "file differs"
11591 run_test 207b "can refresh layout at open"
11594 # FIXME: in this test suite, only RD lease is used. This is okay
11595 # for now as only exclusive open is supported. After generic lease
11596 # is done, this test suite should be revised. - Jinshan
11598 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11599 { skip "Need MDS version at least 2.4.52"; return 0; }
11600 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11602 echo "==== test 1: verify get lease work"
11603 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11605 echo "==== test 2: verify lease can be broken by upcoming open"
11606 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11610 $MULTIOP $DIR/$tfile oO_RDONLY:c
11611 kill -USR1 $PID && wait $PID || error "break lease error"
11613 echo "==== test 3: verify lease can't be granted if an open already exists"
11614 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11618 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11619 kill -USR1 $PID && wait $PID || error "open file error"
11621 echo "==== test 4: lease can sustain over recovery"
11622 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11628 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11630 echo "==== test 5: lease broken can't be regained by replay"
11631 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11635 # open file to break lease and then recovery
11636 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11639 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11643 run_test 208 "Exclusive open"
11646 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11647 skip_env "must have disp_stripe" && return
11650 sync; sleep 5; sync;
11652 echo 3 > /proc/sys/vm/drop_caches
11653 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11655 # open/close 500 times
11656 for i in $(seq 500); do
11660 echo 3 > /proc/sys/vm/drop_caches
11661 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11663 echo "before: $req_before, after: $req_after"
11664 [ $((req_after - req_before)) -ge 300 ] &&
11665 error "open/close requests are not freed"
11668 run_test 209 "read-only open/close requests should be freed promptly"
11672 size=$((size % 8192 + 1))
11673 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11674 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11675 rm -f $DIR/f212 $DIR/f212.xyz
11677 run_test 212 "Sendfile test ============================================"
11680 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11681 cancel_lru_locks osc
11682 lctl set_param fail_loc=0x8000040f
11683 # generate a read lock
11684 cat $DIR/$tfile > /dev/null
11685 # write to the file, it will try to cancel the above read lock.
11686 cat /etc/hosts >> $DIR/$tfile
11688 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11690 test_214() { # for bug 20133
11691 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11692 for (( i=0; i < 340; i++ )) ; do
11693 touch $DIR/$tdir/d214c/a$i
11696 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11697 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11698 ls $DIR/d214c || error "ls $DIR/d214c failed"
11699 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11700 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11702 run_test 214 "hash-indexed directory test - bug 20133"
11704 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11705 create_lnet_proc_files() {
11706 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11707 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11709 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11710 rm -f "$TMP/lnet_$1.sys_tmp"
11713 # counterpart of create_lnet_proc_files
11714 remove_lnet_proc_files() {
11715 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11718 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11719 # 3rd arg as regexp for body
11720 check_lnet_proc_stats() {
11721 local l=$(cat "$TMP/lnet_$1" |wc -l)
11722 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11724 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11727 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11728 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11729 # optional and can be regexp for 2nd line (lnet.routes case)
11730 check_lnet_proc_entry() {
11731 local blp=2 # blp stands for 'position of 1st line of body'
11732 [ -z "$5" ] || blp=3 # lnet.routes case
11734 local l=$(cat "$TMP/lnet_$1" |wc -l)
11735 # subtracting one from $blp because the body can be empty
11736 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11738 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11739 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11741 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11742 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11744 # bail out if any unexpected line happened
11745 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11746 [ "$?" != 0 ] || error "$2 misformatted"
11749 test_215() { # for bugs 18102, 21079, 21517
11750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11751 local N='(0|[1-9][0-9]*)' # non-negative numeric
11752 local P='[1-9][0-9]*' # positive numeric
11753 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11754 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11755 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11756 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11758 local L1 # regexp for 1st line
11759 local L2 # regexp for 2nd line (optional)
11760 local BR # regexp for the rest (body)
11762 # lnet.stats should look as 11 space-separated non-negative numerics
11763 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11764 create_lnet_proc_files "stats"
11765 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11766 remove_lnet_proc_files "stats"
11768 # lnet.routes should look like this:
11769 # Routing disabled/enabled
11770 # net hops priority state router
11771 # where net is a string like tcp0, hops > 0, priority >= 0,
11772 # state is up/down,
11773 # router is a string like 192.168.1.1@tcp2
11774 L1="^Routing (disabled|enabled)$"
11775 L2="^net +hops +priority +state +router$"
11776 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11777 create_lnet_proc_files "routes"
11778 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11779 remove_lnet_proc_files "routes"
11781 # lnet.routers should look like this:
11782 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11783 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11784 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11785 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11786 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11787 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11788 create_lnet_proc_files "routers"
11789 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11790 remove_lnet_proc_files "routers"
11792 # lnet.peers should look like this:
11793 # nid refs state last max rtr min tx min queue
11794 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11795 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11796 # numeric (0 or >0 or <0), queue >= 0.
11797 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11798 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11799 create_lnet_proc_files "peers"
11800 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11801 remove_lnet_proc_files "peers"
11803 # lnet.buffers should look like this:
11804 # pages count credits min
11805 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11806 L1="^pages +count +credits +min$"
11807 BR="^ +$N +$N +$I +$I$"
11808 create_lnet_proc_files "buffers"
11809 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11810 remove_lnet_proc_files "buffers"
11812 # lnet.nis should look like this:
11813 # nid status alive refs peer rtr max tx min
11814 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11815 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11816 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11817 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11818 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11819 create_lnet_proc_files "nis"
11820 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11821 remove_lnet_proc_files "nis"
11823 # can we successfully write to lnet.stats?
11824 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11825 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11827 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11829 test_216() { # bug 20317
11830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11831 remote_ost_nodsh && skip "remote OST with nodsh" && return
11834 local facets=$(get_facets OST)
11835 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11837 save_lustre_params client "osc.*.contention_seconds" > $p
11838 save_lustre_params $facets \
11839 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11840 save_lustre_params $facets \
11841 "ldlm.namespaces.filter-*.contended_locks" >> $p
11842 save_lustre_params $facets \
11843 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11846 # agressive lockless i/o settings
11847 for node in $(osts_nodes); do
11848 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'
11850 lctl set_param -n osc.*.contention_seconds 60
11852 $DIRECTIO write $DIR/$tfile 0 10 4096
11853 $CHECKSTAT -s 40960 $DIR/$tfile
11855 # disable lockless i/o
11856 for node in $(osts_nodes); do
11857 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'
11859 lctl set_param -n osc.*.contention_seconds 0
11862 dd if=/dev/zero of=$DIR/$tfile count=0
11863 $CHECKSTAT -s 0 $DIR/$tfile
11865 restore_lustre_params <$p
11869 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11871 test_217() { # bug 22430
11872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11876 for node in $(nodes_list); do
11877 nid=$(host_nids_address $node $NETTYPE)
11878 if [[ $nid = *-* ]] ; then
11879 echo "lctl ping $nid@$NETTYPE"
11880 lctl ping $nid@$NETTYPE
11882 echo "skipping $node (no hyphen detected)"
11886 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11889 # do directio so as not to populate the page cache
11890 log "creating a 10 Mb file"
11891 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11892 log "starting reads"
11893 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11894 log "truncating the file"
11895 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11897 kill %+ || true # reads might have finished
11898 echo "wait until dd is finished"
11900 log "removing the temporary file"
11901 rm -rf $DIR/$tfile || error "tmp file removal failed"
11903 run_test 218 "parallel read and truncate should not deadlock ======================="
11906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11907 # write one partial page
11908 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11909 # set no grant so vvp_io_commit_write will do sync write
11910 $LCTL set_param fail_loc=0x411
11911 # write a full page at the end of file
11912 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11914 $LCTL set_param fail_loc=0
11915 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11916 $LCTL set_param fail_loc=0x411
11917 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11920 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11921 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11923 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11925 test_220() { #LU-325
11926 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11927 remote_ost_nodsh && skip "remote OST with nodsh" && return
11930 test_mkdir -p $DIR/$tdir
11931 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11932 awk '{print $2}' | sed -e 's/_UUID$//')
11935 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11936 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11937 osc.$mdtosc_proc1.prealloc_last_id)
11938 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11939 osc.$mdtosc_proc1.prealloc_next_id)
11943 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11944 #define OBD_FAIL_OST_ENOINO 0x229
11945 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11946 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11947 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11949 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11951 MDSOBJS=$((last_id - next_id))
11952 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11954 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11955 echo "OST still has $count kbytes free"
11957 echo "create $MDSOBJS files @next_id..."
11958 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11960 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11961 osc.$mdtosc_proc1.prealloc_last_id)
11962 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11963 osc.$mdtosc_proc1.prealloc_next_id)
11965 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11970 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11971 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11973 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11974 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11975 echo "unlink $MDSOBJS files @$next_id..."
11976 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11978 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11982 dd if=`which date` of=$MOUNT/date oflag=sync
11983 chmod +x $MOUNT/date
11985 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11986 $LCTL set_param fail_loc=0x80001401
11988 $MOUNT/date > /dev/null
11991 run_test 221 "make sure fault and truncate race to not cause OOM"
11994 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11996 test_mkdir -p $DIR/$tdir
11997 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11998 createmany -o $DIR/$tdir/$tfile 10
11999 cancel_lru_locks mdc
12000 cancel_lru_locks osc
12001 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12002 $LCTL set_param fail_loc=0x31a
12003 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
12004 $LCTL set_param fail_loc=0
12007 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
12010 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12012 test_mkdir -p $DIR/$tdir
12013 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12014 createmany -o $DIR/$tdir/$tfile 10
12015 cancel_lru_locks mdc
12016 cancel_lru_locks osc
12017 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
12018 $LCTL set_param fail_loc=0x31a
12019 rm -r $DIR/$tdir || "AGL for rmdir failed"
12020 $LCTL set_param fail_loc=0
12022 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12025 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12027 test_mkdir -p $DIR/$tdir
12028 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12029 createmany -o $DIR/$tdir/$tfile 10
12030 cancel_lru_locks mdc
12031 cancel_lru_locks osc
12032 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12033 $LCTL set_param fail_loc=0x31b
12034 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12035 $LCTL set_param fail_loc=0
12038 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12040 test_224a() { # LU-1039, MRP-303
12041 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12042 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12043 $LCTL set_param fail_loc=0x508
12044 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12045 $LCTL set_param fail_loc=0
12048 run_test 224a "Don't panic on bulk IO failure"
12050 test_224b() { # LU-1039, MRP-303
12051 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12052 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12053 cancel_lru_locks osc
12054 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12055 $LCTL set_param fail_loc=0x515
12056 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12057 $LCTL set_param fail_loc=0
12060 run_test 224b "Don't panic on bulk IO failure"
12062 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12064 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12065 if [ -z ${MDSSURVEY} ]; then
12066 skip_env "mds-survey not found" && return
12069 [ $MDSCOUNT -ge 2 ] &&
12070 skip "skipping now for more than one MDT" && return
12072 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12073 { skip "Need MDS version at least 2.2.51"; return; }
12075 local mds=$(facet_host $SINGLEMDS)
12076 local target=$(do_nodes $mds 'lctl dl' | \
12077 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12079 local cmd1="file_count=1000 thrhi=4"
12080 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12081 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12082 local cmd="$cmd1 $cmd2 $cmd3"
12084 rm -f ${TMP}/mds_survey*
12086 eval $cmd || error "mds-survey with zero-stripe failed"
12087 cat ${TMP}/mds_survey*
12088 rm -f ${TMP}/mds_survey*
12090 run_test 225a "Metadata survey sanity with zero-stripe"
12093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12095 if [ -z ${MDSSURVEY} ]; then
12096 skip_env "mds-survey not found" && return
12098 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12099 { skip "Need MDS version at least 2.2.51"; return; }
12101 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12102 skip_env "Need to mount OST to test" && return
12105 [ $MDSCOUNT -ge 2 ] &&
12106 skip "skipping now for more than one MDT" && return
12107 local mds=$(facet_host $SINGLEMDS)
12108 local target=$(do_nodes $mds 'lctl dl' | \
12109 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12111 local cmd1="file_count=1000 thrhi=4"
12112 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12113 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12114 local cmd="$cmd1 $cmd2 $cmd3"
12116 rm -f ${TMP}/mds_survey*
12118 eval $cmd || error "mds-survey with stripe_count failed"
12119 cat ${TMP}/mds_survey*
12120 rm -f ${TMP}/mds_survey*
12122 run_test 225b "Metadata survey sanity with stripe_count = 1"
12124 mcreate_path2fid () {
12130 local path=$DIR/$tdir/$name
12135 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12136 error "cannot create $desc"
12138 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12140 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12142 fid_path=$($LFS fid2path $MOUNT $fid)
12144 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12146 [ "$path" == "$fid_path" ] ||
12147 error "fid2path returned $fid_path, expected $path"
12149 echo "pass with $path and $fid"
12154 mkdir -p $DIR/$tdir
12156 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12157 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12158 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12159 mcreate_path2fid 0040666 0 0 dir "directory"
12160 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12161 mcreate_path2fid 0100666 0 0 file "regular file"
12162 mcreate_path2fid 0120666 0 0 link "symbolic link"
12163 mcreate_path2fid 0140666 0 0 sock "socket"
12165 run_test 226a "call path2fid and fid2path on files of all type"
12168 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12172 mkdir -p $DIR/$tdir
12173 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12174 error "create remote directory failed"
12175 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12176 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12177 "character special file (null)"
12178 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12179 "character special file (no device)"
12180 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12181 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12182 "block special file (loop)"
12183 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12184 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12185 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12187 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12189 # LU-1299 Executing or running ldd on a truncated executable does not
12190 # cause an out-of-memory condition.
12192 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12193 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12194 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12195 chmod +x $MOUNT/date
12197 $MOUNT/date > /dev/null
12198 ldd $MOUNT/date > /dev/null
12201 run_test 227 "running truncated executable does not cause OOM"
12203 # LU-1512 try to reuse idle OI blocks
12205 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12206 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12207 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12208 skip "non-ldiskfs backend" && return
12210 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12211 local myDIR=$DIR/$tdir
12214 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12215 $LCTL set_param fail_loc=0x80001002
12216 createmany -o $myDIR/t- 10000
12217 $LCTL set_param fail_loc=0
12218 # The guard is current the largest FID holder
12220 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12222 local IDX=$(($SEQ % 64))
12224 do_facet $SINGLEMDS sync
12225 # Make sure journal flushed.
12227 local blk1=$(do_facet $SINGLEMDS \
12228 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12229 grep Blockcount | awk '{print $4}')
12231 # Remove old files, some OI blocks will become idle.
12232 unlinkmany $myDIR/t- 10000
12233 # Create new files, idle OI blocks should be reused.
12234 createmany -o $myDIR/t- 2000
12235 do_facet $SINGLEMDS sync
12236 # Make sure journal flushed.
12238 local blk2=$(do_facet $SINGLEMDS \
12239 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12240 grep Blockcount | awk '{print $4}')
12242 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12244 run_test 228a "try to reuse idle OI blocks"
12247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12248 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12249 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12250 skip "non-ldiskfs backend" && return
12252 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12253 local myDIR=$DIR/$tdir
12256 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12257 $LCTL set_param fail_loc=0x80001002
12258 createmany -o $myDIR/t- 10000
12259 $LCTL set_param fail_loc=0
12260 # The guard is current the largest FID holder
12262 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12264 local IDX=$(($SEQ % 64))
12266 do_facet $SINGLEMDS sync
12267 # Make sure journal flushed.
12269 local blk1=$(do_facet $SINGLEMDS \
12270 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12271 grep Blockcount | awk '{print $4}')
12273 # Remove old files, some OI blocks will become idle.
12274 unlinkmany $myDIR/t- 10000
12277 stop $SINGLEMDS || error "Fail to stop MDT."
12279 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12281 df $MOUNT || error "Fail to df."
12282 # Create new files, idle OI blocks should be reused.
12283 createmany -o $myDIR/t- 2000
12284 do_facet $SINGLEMDS sync
12285 # Make sure journal flushed.
12287 local blk2=$(do_facet $SINGLEMDS \
12288 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12289 grep Blockcount | awk '{print $4}')
12291 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12293 run_test 228b "idle OI blocks can be reused after MDT restart"
12297 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12298 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12299 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12300 skip "non-ldiskfs backend" && return
12302 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12303 local myDIR=$DIR/$tdir
12306 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12307 $LCTL set_param fail_loc=0x80001002
12308 # 20000 files can guarantee there are index nodes in the OI file
12309 createmany -o $myDIR/t- 20000
12310 $LCTL set_param fail_loc=0
12311 # The guard is current the largest FID holder
12313 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12315 local IDX=$(($SEQ % 64))
12317 do_facet $SINGLEMDS sync
12318 # Make sure journal flushed.
12320 local blk1=$(do_facet $SINGLEMDS \
12321 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12322 grep Blockcount | awk '{print $4}')
12324 # Remove old files, some OI blocks will become idle.
12325 unlinkmany $myDIR/t- 20000
12327 # The OI file should become empty now
12329 # Create new files, idle OI blocks should be reused.
12330 createmany -o $myDIR/t- 2000
12331 do_facet $SINGLEMDS sync
12332 # Make sure journal flushed.
12334 local blk2=$(do_facet $SINGLEMDS \
12335 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12336 grep Blockcount | awk '{print $4}')
12338 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12340 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12342 test_229() { # LU-2482, LU-3448
12343 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12344 skip "No HSM support on MDS of $(get_lustre_version)," \
12345 "need 2.4.53 at least" && return
12346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12347 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12351 # Create a file with a released layout and stripe count 2.
12352 $MULTIOP $DIR/$tfile H2c ||
12353 error "failed to create file with released layout"
12355 $GETSTRIPE -v $DIR/$tfile
12357 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12358 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12360 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12361 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12362 stat $DIR/$tfile || error "failed to stat released file"
12364 chown $RUNAS_ID $DIR/$tfile ||
12365 error "chown $RUNAS_ID $DIR/$tfile failed"
12367 chgrp $RUNAS_ID $DIR/$tfile ||
12368 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12370 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12371 rm $DIR/$tfile || error "failed to remove released file"
12373 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12376 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12377 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12380 mkdir -p $DIR/$tdir/test_230_local
12381 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12382 [ $mdt_idx -ne 0 ] &&
12383 error "create local directory on wrong MDT $mdt_idx"
12385 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12386 error "create remote directory failed"
12387 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12388 [ $mdt_idx -ne $MDTIDX ] &&
12389 error "create remote directory on wrong MDT $mdt_idx"
12391 createmany -o $DIR/$tdir/test_230/t- 10 ||
12392 error "create files on remote directory failed"
12393 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12394 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12395 rm -r $DIR/$tdir || error "unlink remote directory failed"
12397 run_test 230a "Create remote directory and files under the remote directory"
12400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12401 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12408 local migrate_dir=$DIR/$tdir/migrate_dir
12409 local other_dir=$DIR/$tdir/other_dir
12411 mkdir -p $migrate_dir
12412 mkdir -p $other_dir
12413 for ((i=0; i<10; i++)); do
12414 mkdir -p $migrate_dir/dir_${i}
12415 createmany -o $migrate_dir/dir_${i}/f 10 ||
12416 error "create files under remote dir failed $i"
12419 cp /etc/passwd $migrate_dir/$tfile
12420 cp /etc/passwd $other_dir/$tfile
12421 chattr +SAD $migrate_dir
12422 chattr +SAD $migrate_dir/$tfile
12424 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12425 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12426 local old_dir_mode=$(stat -c%f $migrate_dir)
12427 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12429 mkdir -p $migrate_dir/dir_default_stripe2
12430 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12431 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12433 mkdir -p $other_dir
12434 ln $migrate_dir/$tfile $other_dir/luna
12435 ln $migrate_dir/$tfile $migrate_dir/sofia
12436 ln $other_dir/$tfile $migrate_dir/david
12437 ln -s $migrate_dir/$tfile $other_dir/zachary
12438 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12439 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12441 $LFS mv -v -M $MDTIDX $migrate_dir ||
12442 error "migrate remote dir error"
12444 echo "migratate to MDT1, then checking.."
12445 for ((i = 0; i < 10; i++)); do
12446 for file in $(find $migrate_dir/dir_${i}); do
12447 mdt_index=$($LFS getstripe -M $file)
12448 [ $mdt_index == $MDTIDX ] ||
12449 error "$file is not on MDT${MDTIDX}"
12453 # the multiple link file should still in MDT0
12454 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12455 [ $mdt_index == 0 ] ||
12456 error "$file is not on MDT${MDTIDX}"
12458 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12459 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12460 error " expect $old_dir_flag get $new_dir_flag"
12462 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12463 [ "$old_file_flag" = "$new_file_flag" ] ||
12464 error " expect $old_file_flag get $new_file_flag"
12466 local new_dir_mode=$(stat -c%f $migrate_dir)
12467 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12468 error "expect mode $old_dir_mode get $new_dir_mode"
12470 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12471 [ "$old_file_mode" = "$new_file_mode" ] ||
12472 error "expect mode $old_file_mode get $new_file_mode"
12474 diff /etc/passwd $migrate_dir/$tfile ||
12475 error "$tfile different after migration"
12477 diff /etc/passwd $other_dir/luna ||
12478 error "luna different after migration"
12480 diff /etc/passwd $migrate_dir/sofia ||
12481 error "sofia different after migration"
12483 diff /etc/passwd $migrate_dir/david ||
12484 error "david different after migration"
12486 diff /etc/passwd $other_dir/zachary ||
12487 error "zachary different after migration"
12489 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12490 error "${tfile}_ln different after migration"
12492 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12493 error "${tfile}_ln_other different after migration"
12495 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12496 [ $stripe_count = 2 ] ||
12497 error "dir strpe_count $d != 2 after migration."
12499 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12500 [ $stripe_count = 2 ] ||
12501 error "file strpe_count $d != 2 after migration."
12503 #migrate back to MDT0
12505 $LFS mv -v -M $MDTIDX $migrate_dir ||
12506 error "migrate remote dir error"
12508 echo "migrate back to MDT0, checking.."
12509 for file in $(find $migrate_dir); do
12510 mdt_index=$($LFS getstripe -M $file)
12511 [ $mdt_index == $MDTIDX ] ||
12512 error "$file is not on MDT${MDTIDX}"
12515 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12516 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12517 error " expect $old_dir_flag get $new_dir_flag"
12519 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12520 [ "$old_file_flag" = "$new_file_flag" ] ||
12521 error " expect $old_file_flag get $new_file_flag"
12523 local new_dir_mode=$(stat -c%f $migrate_dir)
12524 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12525 error "expect mode $old_dir_mode get $new_dir_mode"
12527 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12528 [ "$old_file_mode" = "$new_file_mode" ] ||
12529 error "expect mode $old_file_mode get $new_file_mode"
12531 diff /etc/passwd ${migrate_dir}/$tfile ||
12532 error "$tfile different after migration"
12534 diff /etc/passwd ${other_dir}/luna ||
12535 error "luna different after migration"
12537 diff /etc/passwd ${migrate_dir}/sofia ||
12538 error "sofia different after migration"
12540 diff /etc/passwd ${other_dir}/zachary ||
12541 error "zachary different after migration"
12543 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12544 error "${tfile}_ln different after migration"
12546 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12547 error "${tfile}_ln_other different after migration"
12549 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12550 [ $stripe_count = 2 ] ||
12551 error "dir strpe_count $d != 2 after migration."
12553 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12554 [ $stripe_count = 2 ] ||
12555 error "file strpe_count $d != 2 after migration."
12557 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12559 run_test 230b "migrate directory"
12562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12563 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12568 #If migrating directory fails in the middle, all entries of
12569 #the directory is still accessiable.
12570 mkdir -p $DIR/$tdir
12572 createmany -o $DIR/$tdir/f 10 ||
12573 error "create files under ${tdir} failed"
12575 #failed after migrating 5 entries
12576 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12577 do_facet mds1 lctl set_param fail_loc=0x20001801
12578 do_facet mds1 lctl set_param fail_val=5
12579 local t=$(ls $DIR/$tdir | wc -l)
12580 $LFS mv --mdt-index $MDTIDX $DIR/$tdir &&
12581 error "migrate should fail after 5 entries"
12582 local u=$(ls $DIR/$tdir | wc -l)
12583 [ "$u" == "$t" ] || error "$u != $t during migration"
12585 for file in $(find $DIR/$tdir); do
12586 stat $file || error "stat $file failed"
12589 do_facet mds1 lctl set_param fail_loc=0
12590 do_facet mds1 lctl set_param fail_val=0
12592 $LFS mv -M $MDTIDX $DIR/$tdir ||
12593 error "migrate open files should failed with open files"
12595 echo "Finish migration, then checking.."
12596 for file in $(find $DIR/$tdir); do
12597 mdt_index=$($LFS getstripe -M $file)
12598 [ $mdt_index == $MDTIDX ] ||
12599 error "$file is not on MDT${MDTIDX}"
12602 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12604 run_test 230c "check directory accessiblity if migration is failed"
12607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12608 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12614 mkdir -p $DIR/$tdir
12616 for ((i=0; i<100; i++)); do
12617 mkdir -p $DIR/$tdir/dir_${i}
12618 createmany -o $DIR/$tdir/dir_${i}/f 100 ||
12619 error "create files under remote dir failed $i"
12622 $LFS mv -M $MDTIDX -v $DIR/$tdir || error "migrate remote dir error"
12624 echo "Finish migration, then checking.."
12625 for file in $(find $DIR/$tdir); do
12626 mdt_index=$($LFS getstripe -M $file)
12627 [ $mdt_index == $MDTIDX ] ||
12628 error "$file is not on MDT${MDTIDX}"
12631 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12633 run_test 230d "check migrate big directory"
12637 # For simplicity this test assumes that max_pages_per_rpc
12638 # is the same across all OSCs
12639 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12640 local bulk_size=$((max_pages * 4096))
12642 mkdir -p $DIR/$tdir
12644 # clear the OSC stats
12645 $LCTL set_param osc.*.stats=0 &>/dev/null
12647 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12648 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12649 oflag=direct &>/dev/null || error "dd failed"
12651 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12652 if [ x$nrpcs != "x1" ]; then
12653 error "found $nrpc ost_write RPCs, not 1 as expected"
12656 # Drop the OSC cache, otherwise we will read from it
12657 cancel_lru_locks osc
12659 # clear the OSC stats
12660 $LCTL set_param osc.*.stats=0 &>/dev/null
12662 # Client reads $bulk_size.
12663 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12664 iflag=direct &>/dev/null || error "dd failed"
12666 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12667 if [ x$nrpcs != "x1" ]; then
12668 error "found $nrpc ost_read RPCs, not 1 as expected"
12671 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12674 mkdir -p $DIR/$tdir
12676 for i in {0..1023}; do
12677 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12678 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12679 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12683 run_test 231b "must not assert on fully utilized OST request buffer"
12686 mkdir -p $DIR/$tdir
12687 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12688 $LCTL set_param fail_loc=0x31c
12690 # ignore dd failure
12691 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12693 $LCTL set_param fail_loc=0
12694 umount_client $MOUNT || error "umount failed"
12695 mount_client $MOUNT || error "mount failed"
12697 run_test 232 "failed lock should not block umount"
12700 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12701 { skip "Need MDS version at least 2.3.64"; return; }
12703 local fid=$($LFS path2fid $MOUNT)
12704 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12705 error "cannot access $MOUNT using its FID '$fid'"
12707 run_test 233a "checking that OBF of the FS root succeeds"
12710 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12711 { skip "Need MDS version at least 2.5.90"; return; }
12713 local fid=$($LFS path2fid $MOUNT/.lustre)
12714 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12715 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12717 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12718 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12719 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12721 run_test 233b "checking that OBF of the FS .lustre succeeds"
12724 local p="$TMP/sanityN-$TESTNAME.parameters"
12725 save_lustre_params client "llite.*.xattr_cache" > $p
12726 lctl set_param llite.*.xattr_cache 1 ||
12727 { skip "xattr cache is not supported"; return 0; }
12729 mkdir -p $DIR/$tdir || error "mkdir failed"
12730 touch $DIR/$tdir/$tfile || error "touch failed"
12731 # OBD_FAIL_LLITE_XATTR_ENOMEM
12732 $LCTL set_param fail_loc=0x1405
12733 # output of the form: attr 2 4 44 3 fc13 x86_64
12734 V=($(IFS=".-" rpm -q attr))
12735 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12736 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12737 # attr pre-2.4.44-7 had a bug with rc
12738 # LU-3703 - SLES 11 and FC13 clients have older attr
12739 getfattr -n user.attr $DIR/$tdir/$tfile &&
12740 error "getfattr should have failed with ENOMEM"
12742 skip "LU-3703: attr version $(getfattr --version) too old"
12744 $LCTL set_param fail_loc=0x0
12747 restore_lustre_params < $p
12750 run_test 234 "xattr cache should not crash on ENOMEM"
12753 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12754 skip "Need MDS version at least 2.4.52" && return
12755 flock_deadlock $DIR/$tfile
12760 124) error "process hangs on a deadlock"
12762 *) error "error executing flock_deadlock $DIR/$tfile"
12766 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12770 check_swap_layouts_support && return 0
12771 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12773 local ref1=/etc/passwd
12774 local ref2=/etc/group
12775 local file1=$DIR/$tdir/f1
12776 local file2=$DIR/$tdir/f2
12778 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12779 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12780 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12781 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12782 local fd=$(free_fd)
12783 local cmd="exec $fd<>$file2"
12786 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12787 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12790 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12795 run_test 236 "Layout swap on open unlinked file"
12797 # test to verify file handle related system calls
12798 # (name_to_handle_at/open_by_handle_at)
12799 # The new system calls are supported in glibc >= 2.14.
12802 echo "Test file_handle syscalls" > $DIR/$tfile ||
12803 error "write failed"
12804 check_fhandle_syscalls $DIR/$tfile ||
12805 error "check_fhandle_syscalls failed"
12807 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12809 # LU-4659 linkea consistency
12811 local server_version=$(lustre_version_code $SINGLEMDS)
12813 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12814 [[ $server_version -gt $(version_code 2.5.1) &&
12815 $server_version -lt $(version_code 2.5.50) ]] ||
12816 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12819 ln $DIR/$tfile $DIR/$tfile.lnk
12820 touch $DIR/$tfile.new
12821 mv $DIR/$tfile.new $DIR/$tfile
12822 local fid1=$(lfs path2fid $DIR/$tfile)
12823 local fid2=$(lfs path2fid $DIR/$tfile.lnk)
12824 local path1=$(lfs fid2path $FSNAME $fid1)
12825 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12826 local path2=$(lfs fid2path $FSNAME $fid2)
12827 [ $tfile.lnk == $path2 ] ||
12828 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12831 run_test 238 "Verify linkea consistency"
12834 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
12835 skip "Need MDS version at least 2.5.60" && return
12836 local list=$(comma_list $(mdts_nodes))
12838 mkdir -p $DIR/$tdir
12839 createmany -o $DIR/$tdir/f- 5000
12840 unlinkmany $DIR/$tdir/f- 5000
12841 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12842 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12843 osc.*MDT*.sync_in_flight" | calc_sum)
12844 [ "$changes" -eq 0 ] || error "$changes not synced"
12846 run_test 239 "osp_sync test"
12849 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12851 mkdir -p $DIR/$tdir
12853 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12854 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12855 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12856 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12858 umount_client $MOUNT || error "umount failed"
12859 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12860 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12861 mount_client $MOUNT || error "failed to mount client"
12863 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12864 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12866 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12869 for LOOP in $(seq $1); do
12870 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12871 cancel_lru_locks osc
12876 for LOOP in $(seq $1); do
12877 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12878 iflag=direct 2>/dev/null
12883 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12885 cancel_lru_locks osc
12886 test_241_bio 1000 &
12891 run_test 241 "bio vs dio"
12894 mkdir -p $DIR/$tdir
12895 touch $DIR/$tdir/$tfile
12897 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
12898 do_facet mds1 lctl set_param fail_loc=0x105
12899 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
12901 do_facet mds1 lctl set_param fail_loc=0
12902 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
12904 run_test 242 "mdt_readpage failure should not cause directory unreadable"
12908 test_mkdir -p $DIR/$tdir
12909 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
12911 run_test 243 "various group lock tests"
12913 cleanup_test_300() {
12917 test_striped_dir() {
12922 mkdir -p $DIR/$tdir
12924 SAVE_UMASK=$(umask)
12925 trap cleanup_test_300 RETURN EXIT
12927 $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
12928 $DIR/$tdir/striped_dir ||
12929 error "set striped dir error"
12931 local mode=$(stat -c%a $DIR/$tdir/striped_dir)
12932 [ "$mode" = "755" ] || error "expect 755 got $mode"
12934 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
12935 if [ "$stripe_count" != "2" ]; then
12936 error "stripe_count is $stripe_count, expect 2"
12939 stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
12940 if [ "$stripe_index" != "$mdt_index" ]; then
12941 error "stripe_index is $stripe_index, expect $mdt_index"
12944 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12945 error "nlink error after create striped dir"
12947 mkdir $DIR/$tdir/striped_dir/a
12948 mkdir $DIR/$tdir/striped_dir/b
12950 stat $DIR/$tdir/striped_dir/a ||
12951 error "create dir under striped dir failed"
12952 stat $DIR/$tdir/striped_dir/b ||
12953 error "create dir under striped dir failed"
12955 [ $(stat -c%h $DIR/$tdir/striped_dir) == '4' ] ||
12956 error "nlink error after mkdir"
12958 rmdir $DIR/$tdir/striped_dir/a
12959 [ $(stat -c%h $DIR/$tdir/striped_dir) == '3' ] ||
12960 error "nlink error after rmdir"
12962 rmdir $DIR/$tdir/striped_dir/b
12963 [ $(stat -c%h $DIR/$tdir/striped_dir) == '2' ] ||
12964 error "nlink error after rmdir"
12966 rmdir $DIR/$tdir/striped_dir ||
12967 error "rmdir striped dir error"
12975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12976 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12978 test_striped_dir 0 || error "failed on striped dir on MDT0"
12979 test_striped_dir 1 || error "failed on striped dir on MDT0"
12981 run_test 300a "basic striped dir sanity test"
12984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12985 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12991 test_mkdir $DIR/$tdir || error "mkdir fail"
12992 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
12993 error "set striped dir error"
12994 for ((i=0; i<10; i++)); do
12995 mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
12997 touch $DIR/$tdir/striped_dir/file_$i ||
12998 error "touch error $i"
12999 mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
13000 [ $mtime1 -eq $mtime2 ] &&
13001 error "mtime not change after create"
13003 rm -f $DIR/$tdir/striped_dir/file_$i ||
13004 error "unlink error $i"
13005 mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
13006 [ $mtime2 -eq $mtime3 ] &&
13007 error "mtime did not change after unlink"
13011 run_test 300b "check ctime/mtime for striped dir"
13014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13018 mkdir -p $DIR/$tdir
13019 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
13020 error "set striped dir error"
13022 chown $RUNAS_ID:$RUNAS_GID $DIR/$tdir/striped_dir ||
13023 error "chown striped dir failed"
13025 $RUNAS createmany -o $DIR/$tdir/striped_dir/f 5000 ||
13026 error "create 5k files failed"
13028 file_count=$(ls $DIR/$tdir/striped_dir | wc -l)
13030 [ "$file_count" = 5000 ] || error "file count $file_count != 5000"
13034 run_test 300c "chown && check ls under striped directory"
13037 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13038 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13042 mkdir -p $DIR/$tdir
13043 $SETSTRIPE -c 2 $DIR/$tdir
13045 #local striped directory
13046 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13047 error "set striped dir error"
13048 createmany -o $DIR/$tdir/striped_dir/f 10 ||
13049 error "create 10 files failed"
13051 #remote striped directory
13052 $LFS setdirstripe -i 1 -c 2 $DIR/$tdir/remote_striped_dir ||
13053 error "set striped dir error"
13054 createmany -o $DIR/$tdir/remote_striped_dir/f 10 ||
13055 error "create 10 files failed"
13057 for file in $(find $DIR/$tdir); do
13058 stripe_count=$($GETSTRIPE -c $file)
13059 [ $stripe_count -eq 2 ] ||
13060 error "wrong stripe $stripe_count for $file"
13065 run_test 300d "check default stripe under striped directory"
13068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13069 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13073 mkdir -p $DIR/$tdir
13075 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13076 error "set striped dir error"
13078 touch $DIR/$tdir/striped_dir/a
13079 touch $DIR/$tdir/striped_dir/b
13080 touch $DIR/$tdir/striped_dir/c
13082 mkdir $DIR/$tdir/striped_dir/dir_a
13083 mkdir $DIR/$tdir/striped_dir/dir_b
13084 mkdir $DIR/$tdir/striped_dir/dir_c
13086 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
13087 error "set striped dir under striped dir error"
13089 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
13090 error "set striped dir under striped dir error"
13092 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
13093 error "set striped dir under striped dir error"
13095 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/b &&
13096 error "rename file under striped dir should fail"
13098 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b &&
13099 error "rename dir under striped dir should fail"
13101 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir/stp_b &&
13102 error "rename dir under different stripes should fail"
13104 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir/c ||
13105 error "rename file under striped dir should succeed"
13107 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_c ||
13108 error "rename dir under striped dir should succeed"
13112 run_test 300e "check rename under striped directory"
13115 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13121 mkdir -p $DIR/$tdir
13123 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
13124 error "set striped dir error"
13126 $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
13127 error "set striped dir error"
13129 touch $DIR/$tdir/striped_dir/a
13130 mkdir $DIR/$tdir/striped_dir/dir_a
13131 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_a ||
13132 error "create striped dir under striped dir fails"
13134 touch $DIR/$tdir/striped_dir1/b
13135 mkdir $DIR/$tdir/striped_dir1/dir_b
13136 $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir/stp_b ||
13137 error "create striped dir under striped dir fails"
13139 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/b &&
13140 error "rename file under different striped dir should fail"
13142 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_b &&
13143 error "rename dir under different striped dir should fail"
13145 mrename $DIR/$tdir/striped_dir/stp_a $DIR/$tdir/striped_dir1/stp_b &&
13146 error "rename striped dir under diff striped dir should fail"
13148 mrename $DIR/$tdir/striped_dir/a $DIR/$tdir/striped_dir1/a ||
13149 error "rename file under diff striped dirs fails"
13151 mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir1/dir_a ||
13152 error "rename dir under diff striped dirs fails"
13156 run_test 300f "check rename cross striped directory"
13159 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13164 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13165 $DIR/$tdir/striped_dir ||
13166 error "set striped dir error"
13168 $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13169 error "set default stripe on striped dir error"
13171 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
13172 [ $stripe_count -eq $MDSCOUNT ] ||
13173 error "default stripe wrong expect $MDSCOUNT get $stripe_count"
13175 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13177 for dir in $(find $DIR/$tdir/striped_dir/*); do
13178 stripe_count=$($LFS getdirstripe -c $dir)
13179 [ $stripe_count -eq $MDSCOUNT ] ||
13180 error "expect $MDSCOUNT get $stripe_count for $dir"
13183 rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
13184 #change default stripe count to 2
13185 $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
13186 error "set default stripe on striped dir error"
13188 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13190 rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
13192 #change default stripe count to 1
13193 $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
13194 error "set default stripe on striped dir error"
13196 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13197 for dir in $(find $DIR/$tdir/striped_dir/*); do
13198 stripe_count=$($LFS getdirstripe -c $dir)
13199 [ $stripe_count -eq 1 ] ||
13200 error "expect 1 get $stripe_count for $dir"
13202 rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
13204 run_test 300g "check default striped directory for striped directory"
13207 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13208 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13214 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13215 error "set striped dir error"
13217 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13218 error "create files under striped dir failed"
13220 # unfortunately, we need to umount to clear dir layout cache for now
13221 # once we fully implement dir layout, we can drop this
13222 umount_client $MOUNT || error "umount failed"
13223 mount_client $MOUNT || error "mount failed"
13225 #set the stripe to be unknown hash type
13226 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13227 $LCTL set_param fail_loc=0x1901
13228 for ((i = 0; i < 10; i++)); do
13229 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13230 error "stat f-$i failed"
13231 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13234 touch $DIR/$tdir/striped_dir/f0 &&
13235 error "create under striped dir with unknown hash should fail"
13237 $LCTL set_param fail_loc=0
13239 umount_client $MOUNT || error "umount failed"
13240 mount_client $MOUNT || error "mount failed"
13244 run_test 300h "client handle unknown hash type striped directory"
13246 test_400a() { # LU-1606, was conf-sanity test_74
13247 local extra_flags=''
13248 local out=$TMP/$tfile
13249 local prefix=/usr/include/lustre
13252 if ! which $CC > /dev/null 2>&1; then
13253 skip_env "$CC is not installed"
13257 if ! [[ -d $prefix ]]; then
13258 # Assume we're running in tree and fixup the include path.
13259 extra_flags+=" -I$LUSTRE/../libcfs/include"
13260 extra_flags+=" -I$LUSTRE/include"
13261 extra_flags+=" -L$LUSTRE/utils"
13264 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13265 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13266 error "client api broken"
13269 run_test 400a "Lustre client api program can compile and link"
13271 test_400b() { # LU-1606, LU-5011
13273 local out=$TMP/$tfile
13274 local prefix=/usr/include/lustre
13276 # We use a hard coded prefix so that this test will not fail
13277 # when run in tree. There are headers in lustre/include/lustre/
13278 # that are not packaged (like lustre_idl.h) and have more
13279 # complicated include dependencies (like config.h and lnet/types.h).
13280 # Since this test about correct packaging we just skip them when
13281 # they don't exist (see below) rather than try to fixup cppflags.
13283 if ! which $CC > /dev/null 2>&1; then
13284 skip_env "$CC is not installed"
13288 for header in $prefix/*.h; do
13289 if ! [[ -f "$header" ]]; then
13293 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13294 continue # liblustreapi.h is deprecated.
13297 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13298 error "cannot compile '$header'"
13301 run_test 400b "packaged headers can be compiled"
13304 # tests that do cleanup/setup should be run at the end
13308 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13310 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13311 $LCTL set_param fail_loc=0x903
13313 cancel_lru_locks MGC
13315 FAIL_ON_ERROR=true cleanup
13316 FAIL_ON_ERROR=true setup
13318 run_test 900 "umount should not race with any mgc requeue thread"
13321 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13322 check_and_cleanup_lustre
13323 if [ "$I_MOUNTED" != "yes" ]; then
13324 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true