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-4536 LU-5242 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 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 test_mkdir $DIR/$tdir
1401 touch $DIR/$tdir/$tfile || error "touch failed"
1402 [[ $($GETSTRIPE -c $DIR/$tdir/$tfile) -gt 0 ]] ||
1403 error "missing objects"
1405 run_test 27i "$GETSTRIPE with some objects"
1408 test_mkdir -p $DIR/d27
1409 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1411 run_test 27j "setstripe with bad stripe offset (should return error)"
1413 test_27k() { # bug 2844
1414 test_mkdir -p $DIR/d27
1416 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1417 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1418 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1419 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1420 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1421 dd if=/dev/zero of=$FILE bs=4k count=1
1422 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1423 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1425 run_test 27k "limit i_blksize for broken user apps ============="
1428 test_mkdir -p $DIR/d27
1429 mcreate $DIR/f27l || error "creating file"
1430 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1431 error "setstripe should have failed" || true
1433 run_test 27l "check setstripe permissions (should return error)"
1436 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1438 if [[ $ORIGFREE -gt $MAXFREE ]]; then
1439 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1442 trap simple_cleanup_common EXIT
1443 test_mkdir -p $DIR/$tdir
1444 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1445 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1446 error "dd should fill OST0"
1448 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1450 [ $i -gt 256 ] && break
1453 touch $DIR/$tdir/f27m_$i
1454 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1455 error "OST0 was full but new created file still use it"
1457 touch $DIR/$tdir/f27m_$i
1458 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1459 error "OST0 was full but new created file still use it"
1460 simple_cleanup_common
1462 run_test 27m "create file while OST0 was full =================="
1465 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1469 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1470 # if the OST isn't full anymore.
1472 local OSTIDX=${1:-""}
1474 local list=$(comma_list $(osts_nodes))
1475 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1477 do_nodes $list lctl set_param fail_loc=0
1478 sync # initiate all OST_DESTROYs from MDS to OST
1482 exhaust_precreations() {
1485 local FAILIDX=${3:-$OSTIDX}
1486 local ofacet=ost$((OSTIDX + 1))
1488 test_mkdir -p -c1 $DIR/$tdir
1489 local mdtidx=$($LFS getstripe -M $DIR/$tdir)
1490 local mfacet=mds$((mdtidx + 1))
1491 echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
1493 local OST=$(ostname_from_index $OSTIDX)
1496 local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
1497 local last_id=$(do_facet $mfacet lctl get_param -n \
1498 osc.$mdtosc_proc1.prealloc_last_id)
1499 local next_id=$(do_facet $mfacet lctl get_param -n \
1500 osc.$mdtosc_proc1.prealloc_next_id)
1502 local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
1503 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1505 test_mkdir -p $DIR/$tdir/${OST}
1506 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1507 #define OBD_FAIL_OST_ENOSPC 0x215
1508 do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
1509 echo "Creating to objid $last_id on ost $OST..."
1510 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1511 do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
1512 do_facet $ofacet lctl set_param fail_loc=$FAILLOC
1516 exhaust_all_precreations() {
1518 for (( i=0; i < OSTCOUNT; i++ )) ; do
1519 exhaust_precreations $i $1 -1
1524 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1526 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1527 remote_ost_nodsh && skip "remote OST with nodsh" && return
1530 rm -f $DIR/$tdir/$tfile
1531 exhaust_precreations 0 0x80000215
1532 $SETSTRIPE -c -1 $DIR/$tdir
1533 touch $DIR/$tdir/$tfile || error
1534 $GETSTRIPE $DIR/$tdir/$tfile
1537 run_test 27n "create file with some full OSTs =================="
1540 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1542 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1543 remote_ost_nodsh && skip "remote OST with nodsh" && return
1546 rm -f $DIR/$tdir/$tfile
1547 exhaust_all_precreations 0x215
1549 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1554 run_test 27o "create file with all full OSTs (should error) ===="
1557 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1558 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1559 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1560 remote_ost_nodsh && skip "remote OST with nodsh" && return
1563 rm -f $DIR/$tdir/$tfile
1564 test_mkdir -p $DIR/$tdir
1566 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1567 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1568 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1570 exhaust_precreations 0 0x80000215
1571 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1572 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1573 $GETSTRIPE $DIR/$tdir/$tfile
1577 run_test 27p "append to a truncated file with some full OSTs ==="
1580 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1581 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1582 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1583 remote_ost_nodsh && skip "remote OST with nodsh" && return
1586 rm -f $DIR/$tdir/$tfile
1588 test_mkdir -p $DIR/$tdir
1589 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1590 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1591 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1593 exhaust_all_precreations 0x215
1595 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1596 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1600 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1603 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1606 remote_ost_nodsh && skip "remote OST with nodsh" && return
1609 rm -f $DIR/$tdir/$tfile
1610 exhaust_precreations 0 0x80000215
1612 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1616 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1618 test_27s() { # bug 10725
1619 test_mkdir -p $DIR/$tdir
1620 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1621 local stripe_count=0
1622 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1623 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1624 error "stripe width >= 2^32 succeeded" || true
1627 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1629 test_27t() { # bug 10864
1634 $WLFS getstripe $tfile
1637 run_test 27t "check that utils parse path correctly"
1639 test_27u() { # bug 4900
1640 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1641 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1643 local list=$(comma_list $(mdts_nodes))
1645 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1646 do_nodes $list $LCTL set_param fail_loc=0x139
1647 test_mkdir -p $DIR/$tdir
1649 createmany -o $DIR/$tdir/t- 1000
1650 do_nodes $list $LCTL set_param fail_loc=0
1652 TLOG=$DIR/$tfile.getstripe
1653 $GETSTRIPE $DIR/$tdir > $TLOG
1654 OBJS=$(awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj; }' $TLOG)
1655 unlinkmany $DIR/$tdir/t- 1000
1656 [[ $OBJS -gt 0 ]] &&
1657 error "$OBJS objects created on OST-0. See $TLOG" || pass
1659 run_test 27u "skip object creation on OSC w/o objects =========="
1661 test_27v() { # bug 4900
1662 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
1663 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1664 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1665 remote_ost_nodsh && skip "remote OST with nodsh" && return
1667 exhaust_all_precreations 0x215
1670 test_mkdir -p $DIR/$tdir
1671 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1673 touch $DIR/$tdir/$tfile
1674 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1676 for (( i=1; i < OSTCOUNT; i++ )); do
1677 do_facet ost$i lctl set_param fail_loc=0x705
1679 local START=`date +%s`
1680 createmany -o $DIR/$tdir/$tfile 32
1682 local FINISH=`date +%s`
1683 local TIMEOUT=`lctl get_param -n timeout`
1684 local PROCESS=$((FINISH - START))
1685 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1686 error "$FINISH - $START >= $TIMEOUT / 2"
1687 sleep $((TIMEOUT / 2 - PROCESS))
1690 run_test 27v "skip object creation on slow OST ================="
1692 test_27w() { # bug 10997
1693 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1694 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1695 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1696 error "stripe size $size != 65536" || true
1697 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1698 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1700 run_test 27w "check $SETSTRIPE -S option"
1703 [[ $OSTCOUNT -lt 2 ]] &&
1704 skip_env "skipping multiple stripe count/offset test" && return
1706 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1707 for i in $(seq 1 $OSTCOUNT); do
1709 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1710 error "setstripe -c $i -i $offset failed"
1711 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1712 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1713 [ $count -ne $i ] && error "stripe count $count != $i" || true
1714 [ $index -ne $offset ] &&
1715 error "stripe offset $index != $offset" || true
1718 run_test 27wa "check $SETSTRIPE -c -i options"
1721 remote_ost_nodsh && skip "remote OST with nodsh" && return
1722 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
1723 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1724 OFFSET=$(($OSTCOUNT - 1))
1726 local OST=$(ostname_from_index $OSTIDX)
1728 test_mkdir -p $DIR/$tdir
1729 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1730 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1732 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1733 for i in `seq 0 $OFFSET`; do
1734 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1735 error "OST0 was degraded but new created file still use it"
1737 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1739 run_test 27x "create files while OST0 is degraded"
1742 [[ $OSTCOUNT -lt 2 ]] &&
1743 skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1744 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1745 remote_ost_nodsh && skip "remote OST with nodsh" && return
1746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1748 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1749 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1750 osc.$mdtosc.prealloc_last_id)
1751 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1752 osc.$mdtosc.prealloc_next_id)
1753 local fcount=$((last_id - next_id))
1754 [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
1755 [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
1757 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1758 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1759 local OST_DEACTIVE_IDX=-1
1764 for OSC in $MDS_OSCS; do
1765 OST=$(osc_to_ost $OSC)
1766 OSTIDX=$(index_from_ostuuid $OST)
1767 if [ $OST_DEACTIVE_IDX == -1 ]; then
1768 OST_DEACTIVE_IDX=$OSTIDX
1770 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1771 echo $OSC "is Deactivated:"
1772 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1776 OSTIDX=$(index_from_ostuuid $OST)
1778 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1780 for OSC in $MDS_OSCS; do
1781 OST=$(osc_to_ost $OSC)
1782 OSTIDX=$(index_from_ostuuid $OST)
1783 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1784 echo $OST "is degraded:"
1785 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1786 obdfilter.$OST.degraded=1
1791 createmany -o $DIR/$tdir/$tfile $fcount
1793 for OSC in $MDS_OSCS; do
1794 OST=$(osc_to_ost $OSC)
1795 OSTIDX=$(index_from_ostuuid $OST)
1796 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1797 echo $OST "is recovered from degraded:"
1798 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1799 obdfilter.$OST.degraded=0
1801 do_facet $SINGLEMDS lctl --device %$OSC activate
1805 # all osp devices get activated, hence -1 stripe count restored
1808 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1809 # devices get activated.
1811 $SETSTRIPE -c -1 $DIR/$tfile
1812 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1814 [ $stripecnt -ne $OSTCOUNT ] &&
1815 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1818 run_test 27y "create files while OST0 is degraded and the rest inactive"
1824 lmm_count=$($GETSTRIPE -c $1)
1825 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1826 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1828 local old_ifs="$IFS"
1830 fid=($($LFS path2fid $1))
1833 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1834 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1836 # compare lmm_seq and lu_fid->f_seq
1837 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1838 # compare lmm_object_id and lu_fid->oid
1839 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1841 # check the trusted.fid attribute of the OST objects of the file
1842 local have_obdidx=false
1844 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1845 # skip lines up to and including "obdidx"
1846 [ -z "$obdidx" ] && break
1847 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1848 $have_obdidx || continue
1850 local ost=$((obdidx + 1))
1851 local dev=$(ostdevname $ost)
1854 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1856 seq=$(echo $seq | sed -e "s/^0x//g")
1857 if [ $seq == 0 ]; then
1858 oid_hex=$(echo $oid)
1860 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1862 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1866 # Don't unmount/remount the OSTs if we don't need to do that.
1867 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1868 # update too, until that use mount/ll_decode_filter_fid/mount.
1869 # Re-enable when debugfs will understand new filter_fid.
1871 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1872 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1873 $dev 2>/dev/null" | grep "parent=")
1876 mount_fstype ost$ost
1877 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1878 $(facet_mntpt ost$ost)/$obj_file)
1879 unmount_fstype ost$ost
1880 start ost$ost $dev $OST_MOUNT_OPTS
1883 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1885 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1887 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1888 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1889 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1890 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1891 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1893 if echo $ff_parent | grep -q 'stripe='; then
1894 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1897 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1898 # into f_ver in this case. See the comment on
1901 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1905 # compare lmm_seq and filter_fid->ff_parent.f_seq
1906 [ $ff_pseq = $lmm_seq ] ||
1907 error "FF parent SEQ $ff_pseq != $lmm_seq"
1908 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1909 [ $ff_poid = $lmm_oid ] ||
1910 error "FF parent OID $ff_poid != $lmm_oid"
1911 (($ff_pstripe == $stripe_nr)) ||
1912 error "FF stripe $ff_pstripe != $stripe_nr"
1914 stripe_nr=$((stripe_nr + 1))
1919 remote_ost_nodsh && skip "remote OST with nodsh" && return
1920 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1921 test_mkdir -p $DIR/$tdir
1923 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1924 { error "setstripe -c -1 failed"; return 1; }
1925 # We need to send a write to every object to get parent FID info set.
1926 # This _should_ also work for setattr, but does not currently.
1927 # touch $DIR/$tdir/$tfile-1 ||
1928 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1929 { error "dd $tfile-1 failed"; return 2; }
1930 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1931 { error "setstripe -c -1 failed"; return 3; }
1932 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1933 { error "dd $tfile-2 failed"; return 4; }
1935 # make sure write RPCs have been sent to OSTs
1938 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1939 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1941 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1943 test_27A() { # b=19102
1944 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1945 local restore_size=$($GETSTRIPE -S $MOUNT)
1946 local restore_count=$($GETSTRIPE -c $MOUNT)
1947 local restore_offset=$($GETSTRIPE -i $MOUNT)
1948 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1949 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1950 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1951 local default_size=$($GETSTRIPE -S $MOUNT)
1952 local default_offset=$($GETSTRIPE -i $MOUNT)
1953 local dsize=$((1024 * 1024))
1954 [ $default_size -eq $dsize ] ||
1955 error "stripe size $default_size != $dsize"
1956 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1957 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1959 run_test 27A "check filesystem-wide default LOV EA values"
1961 test_27B() { # LU-2523
1962 test_mkdir -p $DIR/$tdir
1963 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1965 # open f1 with O_LOV_DELAY_CREATE
1967 # call setstripe ioctl on open file descriptor for f1
1969 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1973 # open f1 with O_LOV_DELAY_CREATE
1975 # call setstripe ioctl on open file descriptor for f1
1977 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1979 # Allow multiop to fail in imitation of NFS's busted semantics.
1982 run_test 27B "call setstripe on open unlinked file/rename victim"
1984 test_27C() { #LU-2871
1985 [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
1993 test_mkdir -p $DIR/$tdir
1995 for i in $(seq 0 $((OSTCOUNT - 1))); do
1996 # set stripe across all OSTs starting from OST$i
1997 $SETSTRIPE -i $i -c -1 $tfile$i
1998 # get striping information
1999 ost_idx=($($GETSTRIPE $tfile$i |
2000 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
2004 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
2005 error "${#ost_idx[@]} != $OSTCOUNT"
2007 for index in $(seq 0 $((OSTCOUNT - 1))); do
2009 for j in $(echo ${ost_idx[@]}); do
2010 if [ $index -eq $j ]; then
2016 error "Can not find $index in ${ost_idx[@]}"
2020 run_test 27C "check full striping across all OSTs"
2023 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2024 local POOL=${POOL:-testpool}
2026 local last_ost=$(($OSTCOUNT - 1))
2028 local ost_list=$(seq $first_ost $ost_step $last_ost)
2029 local ost_range="$first_ost $last_ost $ost_step"
2032 pool_add $POOL || error "pool_add failed"
2033 pool_add_targets $POOL $ost_range || error "pool_add_targets failed"
2034 llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT ||
2035 error "llapi_layout_test failed"
2036 cleanup_pools || error "cleanup_pools failed"
2038 run_test 27D "validate llapi_layout API"
2040 # Verify that default_easize is increased from its initial value after
2041 # accessing a widely striped file.
2043 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
2045 # 72 bytes is the minimum space required to store striping
2046 # information for a file striped across one OST:
2047 # (sizeof(struct lov_user_md_v3) +
2048 # sizeof(struct lov_user_ost_data_v1))
2050 $LCTL set_param -n llite.*.default_easize $min_easize ||
2051 error "lctl set_param failed"
2052 local easize=$($LCTL get_param -n llite.*.default_easize)
2054 [ $easize -eq $min_easize ] ||
2055 error "failed to set default_easize"
2057 $LFS setstripe -c $OSTCOUNT $DIR/$tfile ||
2058 error "setstripe failed"
2062 easize=$($LCTL get_param -n llite.*.default_easize)
2064 [ $easize -gt $min_easize ] ||
2065 error "default_easize not updated"
2067 run_test 27E "check that default extended attribute size properly increases"
2069 # createtest also checks that device nodes are created and
2070 # then visible correctly (#2091)
2071 test_28() { # bug 2091
2073 $CREATETEST $DIR/d28/ct || error
2075 run_test 28 "create/mknod/mkdir with bad file types ============"
2078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2079 cancel_lru_locks mdc
2085 declare -i LOCKCOUNTORIG=0
2086 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2087 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
2089 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
2091 declare -i LOCKUNUSEDCOUNTORIG=0
2092 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2093 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
2100 declare -i LOCKCOUNTCURRENT=0
2101 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
2102 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
2105 declare -i LOCKUNUSEDCOUNTCURRENT=0
2106 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
2107 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
2110 if [[ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]]; then
2111 $LCTL set_param -n ldlm.dump_namespaces ""
2112 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
2113 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2114 log "dumped log to $TMP/test_29.dk (bug 5793)"
2117 if [[ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]]; then
2118 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
2119 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
2120 log "dumped log to $TMP/test_29.dk (bug 5793)"
2124 run_test 29 "IT_GETATTR regression ============================"
2126 test_30a() { # was test_30
2127 cp $(which ls) $DIR || cp /bin/ls $DIR
2131 run_test 30a "execute binary from Lustre (execve) =============="
2134 cp `which ls` $DIR || cp /bin/ls $DIR
2136 $RUNAS $DIR/ls / || error
2139 run_test 30b "execute binary from Lustre as non-root ==========="
2141 test_30c() { # b=22376
2142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2143 cp `which ls` $DIR || cp /bin/ls $DIR
2145 cancel_lru_locks mdc
2146 cancel_lru_locks osc
2147 $RUNAS $DIR/ls / || error
2150 run_test 30c "execute binary from Lustre without read perms ===="
2153 $OPENUNLINK $DIR/f31 $DIR/f31 || error
2154 $CHECKSTAT -a $DIR/f31 || error
2156 run_test 31a "open-unlink file =================================="
2159 touch $DIR/f31 || error
2160 ln $DIR/f31 $DIR/f31b || error
2161 $MULTIOP $DIR/f31b Ouc || error
2162 $CHECKSTAT -t file $DIR/f31 || error
2164 run_test 31b "unlink file with multiple links while open ======="
2167 touch $DIR/f31 || error
2168 ln $DIR/f31 $DIR/f31c || error
2169 multiop_bg_pause $DIR/f31 O_uc || return 1
2171 $MULTIOP $DIR/f31c Ouc
2172 kill -USR1 $MULTIPID
2175 run_test 31c "open-unlink file with multiple links ============="
2178 opendirunlink $DIR/d31d $DIR/d31d || error
2179 $CHECKSTAT -a $DIR/d31d || error
2181 run_test 31d "remove of open directory ========================="
2183 test_31e() { # bug 2904
2184 check_kernel_version 34 || return 0
2185 openfilleddirunlink $DIR/d31e || error
2187 run_test 31e "remove of open non-empty directory ==============="
2189 test_31f() { # bug 4554
2190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2192 test_mkdir $DIR/d31f
2193 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2194 cp /etc/hosts $DIR/d31f
2196 $GETSTRIPE $DIR/d31f/hosts
2197 multiop_bg_pause $DIR/d31f D_c || return 1
2200 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2201 test_mkdir $DIR/d31f
2202 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2203 cp /etc/hosts $DIR/d31f
2205 $GETSTRIPE $DIR/d31f/hosts
2206 multiop_bg_pause $DIR/d31f D_c || return 1
2209 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2210 wait $MULTIPID || error "first opendir $MULTIPID failed"
2214 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2215 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2218 run_test 31f "remove of open directory with open-unlink file ==="
2221 echo "-- cross directory link --"
2222 test_mkdir -c1 $DIR/${tdir}ga
2223 test_mkdir -c1 $DIR/${tdir}gb
2224 touch $DIR/${tdir}ga/f
2225 ln $DIR/${tdir}ga/f $DIR/${tdir}gb/g
2226 $CHECKSTAT -t file $DIR/${tdir}ga/f || error "source"
2227 [ `stat -c%h $DIR/${tdir}ga/f` == '2' ] || error "source nlink"
2228 $CHECKSTAT -t file $DIR/${tdir}gb/g || error "target"
2229 [ `stat -c%h $DIR/${tdir}gb/g` == '2' ] || error "target nlink"
2231 run_test 31g "cross directory link==============="
2234 echo "-- cross directory link --"
2235 test_mkdir -c1 $DIR/${tdir}
2236 test_mkdir -c1 $DIR/${tdir}/dir
2237 touch $DIR/${tdir}/f
2238 ln $DIR/${tdir}/f $DIR/${tdir}/dir/g
2239 $CHECKSTAT -t file $DIR/${tdir}/f || error "source"
2240 [ `stat -c%h $DIR/${tdir}/f` == '2' ] || error "source nlink"
2241 $CHECKSTAT -t file $DIR/${tdir}/dir/g || error "target"
2242 [ `stat -c%h $DIR/${tdir}/dir/g` == '2' ] || error "target nlink"
2244 run_test 31h "cross directory link under child==============="
2247 echo "-- cross directory link --"
2248 test_mkdir -c1 $DIR/$tdir
2249 test_mkdir -c1 $DIR/$tdir/dir
2250 touch $DIR/$tdir/dir/f
2251 ln $DIR/$tdir/dir/f $DIR/$tdir/g
2252 $CHECKSTAT -t file $DIR/$tdir/dir/f || error "source"
2253 [ `stat -c%h $DIR/$tdir/dir/f` == '2' ] || error "source nlink"
2254 $CHECKSTAT -t file $DIR/$tdir/g || error "target"
2255 [ `stat -c%h $DIR/$tdir/g` == '2' ] || error "target nlink"
2257 run_test 31i "cross directory link under parent==============="
2260 test_mkdir -c1 -p $DIR/$tdir
2261 test_mkdir -c1 -p $DIR/$tdir/dir1
2262 ln $DIR/$tdir/dir1 $DIR/$tdir/dir2 && error "ln for dir"
2263 link $DIR/$tdir/dir1 $DIR/$tdir/dir3 && error "link for dir"
2264 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir4 && error "mlink for dir"
2265 mlink $DIR/$tdir/dir1 $DIR/$tdir/dir1 && error "mlink to the same dir"
2268 run_test 31j "link for directory==============="
2271 test_mkdir -c1 -p $DIR/$tdir
2273 touch $DIR/$tdir/exist
2274 mlink $DIR/$tdir/s $DIR/$tdir/t || error "mlink"
2275 mlink $DIR/$tdir/s $DIR/$tdir/exist && error "mlink to exist file"
2276 mlink $DIR/$tdir/s $DIR/$tdir/s && error "mlink to the same file"
2277 mlink $DIR/$tdir/s $DIR/$tdir && error "mlink to parent dir"
2278 mlink $DIR/$tdir $DIR/$tdir/s && error "mlink parent dir to target"
2279 mlink $DIR/$tdir/not-exist $DIR/$tdir/foo && error "mlink non-existing to new"
2280 mlink $DIR/$tdir/not-exist $DIR/$tdir/s && error "mlink non-existing to exist"
2283 run_test 31k "link to file: the same, non-existing, dir==============="
2289 touch $DIR/d31m2/exist
2290 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2291 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2292 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2293 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2294 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2295 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2298 run_test 31m "link to file: the same, non-existing, dir==============="
2301 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2302 nlink=$(stat --format=%h $DIR/$tfile)
2303 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2305 local cmd="exec $fd<$DIR/$tfile"
2308 trap "eval $cmd" EXIT
2309 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2310 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2311 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2312 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2313 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2316 run_test 31n "check link count of unlinked file"
2319 local TEMPNAME=$(mktemp $1_XXXXXX)
2320 mlink $TEMPNAME $1 2> /dev/null &&
2321 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2325 test_31o() { # LU-2901
2327 for LOOP in $(seq 100); do
2328 rm -f $DIR/$tdir/$tfile*
2329 for THREAD in $(seq 8); do
2330 link_one $DIR/$tdir/$tfile.$LOOP &
2333 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2334 [[ $LINKS -gt 1 ]] && ls $DIR/$tdir &&
2335 error "$LINKS duplicate links to $tfile.$LOOP" &&
2339 run_test 31o "duplicate hard links with same filename"
2342 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2345 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2346 $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
2348 opendirunlink $DIR/$tdir/striped_dir/test1 ||
2349 error "open unlink test1 failed"
2350 opendirunlink $DIR/$tdir/striped_dir/test2 ||
2351 error "open unlink test2 failed"
2353 $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
2354 error "test1 still exists"
2355 $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
2356 error "test2 still exists"
2358 run_test 31p "remove of open striped directory"
2360 cleanup_test32_mount() {
2362 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2367 echo "== more mountpoints and symlinks ================="
2368 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2369 trap cleanup_test32_mount EXIT
2370 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2371 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2372 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2373 cleanup_test32_mount
2375 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2378 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2379 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2380 trap cleanup_test32_mount EXIT
2381 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2382 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2383 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2384 cleanup_test32_mount
2386 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2390 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2391 trap cleanup_test32_mount EXIT
2392 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2393 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2394 test_mkdir -p $DIR/$tdir/d2/test_dir
2395 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2396 cleanup_test32_mount
2398 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2401 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2402 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2403 trap cleanup_test32_mount EXIT
2404 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2405 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2406 test_mkdir -p $DIR/$tdir/d2/test_dir
2407 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2408 cleanup_test32_mount
2410 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2413 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2414 test_mkdir -p $DIR/d32e/tmp
2415 TMP_DIR=$DIR/d32e/tmp
2416 ln -s $DIR/d32e $TMP_DIR/symlink11
2417 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2418 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2419 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2421 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2424 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2425 test_mkdir -p $DIR/d32f/tmp
2426 TMP_DIR=$DIR/d32f/tmp
2427 ln -s $DIR/d32f $TMP_DIR/symlink11
2428 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2429 ls $DIR/d32f/tmp/symlink11 || error
2430 ls $DIR/d32f/symlink01 || error
2432 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2435 TMP_DIR=$DIR/$tdir/tmp
2436 test_mkdir -p $DIR/$tdir/tmp
2437 test_mkdir $DIR/${tdir}2
2438 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2439 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2440 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2441 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2442 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2443 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2445 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2448 rm -fr $DIR/$tdir $DIR/${tdir}2
2449 TMP_DIR=$DIR/$tdir/tmp
2450 test_mkdir -p $DIR/$tdir/tmp
2451 test_mkdir $DIR/${tdir}2
2452 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2453 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2454 ls $TMP_DIR/symlink12 || error
2455 ls $DIR/$tdir/symlink02 || error
2457 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2461 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2462 trap cleanup_test32_mount EXIT
2463 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2464 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2465 touch $DIR/$tdir/test_file
2466 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2467 cleanup_test32_mount
2469 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2473 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2474 trap cleanup_test32_mount EXIT
2475 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2476 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2477 touch $DIR/$tdir/test_file
2478 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2479 cleanup_test32_mount
2481 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2486 trap cleanup_test32_mount EXIT
2487 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2488 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2489 test_mkdir -p $DIR/$tdir/d2
2490 touch $DIR/$tdir/d2/test_file || error
2491 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2492 cleanup_test32_mount
2494 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2497 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2499 trap cleanup_test32_mount EXIT
2500 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2501 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2502 test_mkdir -p $DIR/$tdir/d2
2503 touch $DIR/$tdir/d2/test_file
2504 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2505 cleanup_test32_mount
2507 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2511 test_mkdir -p $DIR/d32m/tmp
2512 TMP_DIR=$DIR/d32m/tmp
2513 ln -s $DIR $TMP_DIR/symlink11
2514 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2515 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2516 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2518 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2522 test_mkdir -p $DIR/d32n/tmp
2523 TMP_DIR=$DIR/d32n/tmp
2524 ln -s $DIR $TMP_DIR/symlink11
2525 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2526 ls -l $DIR/d32n/tmp/symlink11 || error
2527 ls -l $DIR/d32n/symlink01 || error
2529 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2533 test_mkdir -p $DIR/d32o/tmp
2534 TMP_DIR=$DIR/d32o/tmp
2535 ln -s $DIR/$tfile $TMP_DIR/symlink12
2536 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2537 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2538 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2539 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2540 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2542 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2552 test_mkdir -p $DIR/d32p/tmp
2554 TMP_DIR=$DIR/d32p/tmp
2556 ln -s $DIR/$tfile $TMP_DIR/symlink12
2558 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2560 cat $DIR/d32p/tmp/symlink12 || error
2562 cat $DIR/d32p/symlink02 || error
2565 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2567 cleanup_testdir_mount() {
2569 $UMOUNT -d $DIR/$tdir
2573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2574 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2575 trap cleanup_testdir_mount EXIT
2576 test_mkdir -p $DIR/$tdir
2577 touch $DIR/$tdir/under_the_mount
2578 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2579 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2580 cleanup_testdir_mount
2582 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2585 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2586 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2587 trap cleanup_testdir_mount EXIT
2588 test_mkdir -p $DIR/$tdir
2589 touch $DIR/$tdir/under_the_mount
2590 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2591 ls $DIR/$tdir | grep -q under_the_mount && error || true
2592 cleanup_testdir_mount
2594 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2599 chmod 444 $DIR/$tfile
2600 chown $RUNAS_ID $DIR/$tfile
2602 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2605 run_test 33aa "write file with mode 444 (should return error) ===="
2609 test_mkdir -p $DIR/d33
2610 chown $RUNAS_ID $DIR/d33
2611 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2612 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2613 error "open RDWR" || true
2615 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2619 test_mkdir -p $DIR/d33
2620 chown $RUNAS_ID $DIR/d33
2621 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
2623 run_test 33b "test open file with malformed flags (No panic)"
2626 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2632 remote_ost_nodsh && skip "remote OST with nodsh" && return
2635 test_mkdir -p $DIR/d33
2636 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2639 for ostnum in $(seq $OSTCOUNT); do
2640 # test-framework's OST numbering is one-based, while Lustre's
2642 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2643 # Parsing llobdstat's output sucks; we could grep the /proc
2644 # path, but that's likely to not be as portable as using the
2645 # llobdstat utility. So we parse lctl output instead.
2646 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2647 obdfilter/$ostname/stats |
2648 awk '/^write_bytes/ {print $7}' )
2649 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2650 if (( ${write_bytes:-0} > 0 ))
2657 $all_zeros || return 0
2660 echo foo > $DIR/d33/bar
2664 # Total up write_bytes after writing. We'd better find non-zeros.
2665 for ostnum in $(seq $OSTCOUNT); do
2666 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2667 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2668 obdfilter/$ostname/stats |
2669 awk '/^write_bytes/ {print $7}' )
2670 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2671 if (( ${write_bytes:-0} > 0 ))
2680 for ostnum in $(seq $OSTCOUNT); do
2681 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2682 echo "Check that write_bytes is present in obdfilter/*/stats:"
2683 do_facet ost$ostnum lctl get_param -n \
2684 obdfilter/$ostname/stats
2686 error "OST not keeping write_bytes stats (b22312)"
2689 run_test 33c "test llobdstat and write_bytes"
2692 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
2693 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2695 local remote_dir=$DIR/$tdir/remote_dir
2698 $LFS mkdir -i $MDTIDX $remote_dir ||
2699 error "create remote directory failed"
2701 touch $remote_dir/$tfile
2702 chmod 444 $remote_dir/$tfile
2703 chown $RUNAS_ID $remote_dir/$tfile
2705 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2707 chown $RUNAS_ID $remote_dir
2708 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2709 error "create" || true
2710 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2711 error "open RDWR" || true
2712 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2713 error "create" || true
2715 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2718 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2722 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2723 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2724 mkdir $DIR/$tdir/local_dir
2726 local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2727 local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2728 local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2730 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2731 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
2733 rmdir $DIR/$tdir/* || error "rmdir failed"
2736 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2737 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2738 mkdir $DIR/$tdir/local_dir
2740 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2741 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2742 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2744 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2745 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
2747 rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
2750 $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
2751 $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
2752 mkdir $DIR/$tdir/local_dir
2754 s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
2755 s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
2756 l_mode=$(stat -c%f $DIR/$tdir/local_dir)
2758 [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
2759 error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
2761 run_test 33e "mkdir and striped directory should have same mode"
2765 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=0
2769 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2772 chmod go+rwx $DIR/$tdir
2773 do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
2774 trap cleanup_33f EXIT
2776 $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
2777 error "cannot create striped directory"
2779 $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
2780 error "cannot create files in striped directory"
2782 $RUNAS rm $DIR/$tdir/striped_dir/{0..16} ||
2783 error "cannot remove files in striped directory"
2785 $RUNAS rmdir $DIR/$tdir/striped_dir ||
2786 error "cannot remove striped directory"
2790 run_test 33f "nonroot user can create, access, and remove a striped directory"
2792 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2795 $MCREATE $DIR/f34 || error
2796 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2797 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2798 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2799 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2801 run_test 34a "truncate file that has not been opened ==========="
2804 [ ! -f $DIR/f34 ] && test_34a
2805 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2806 $OPENFILE -f O_RDONLY $DIR/f34
2807 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2808 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2810 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2813 [ ! -f $DIR/f34 ] && test_34a
2814 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2815 $OPENFILE -f O_RDWR $DIR/f34
2816 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2817 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2819 run_test 34c "O_RDWR opening file-with-size works =============="
2822 [ ! -f $DIR/f34 ] && test_34a
2823 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2824 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2827 run_test 34d "write to sparse file ============================="
2831 $MCREATE $DIR/f34e || error
2832 $TRUNCATE $DIR/f34e 1000 || error
2833 $CHECKSTAT -s 1000 $DIR/f34e || error
2834 $OPENFILE -f O_RDWR $DIR/f34e
2835 $CHECKSTAT -s 1000 $DIR/f34e || error
2837 run_test 34e "create objects, some with size and some without =="
2839 test_34f() { # bug 6242, 6243
2840 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2843 $MCREATE $DIR/f34f || error
2844 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2845 dd if=$DIR/f34f of=$TMP/f34f
2846 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2847 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2848 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2849 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2850 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2852 run_test 34f "read from a file with no objects until EOF ======="
2855 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2856 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2857 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2858 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2859 cancel_lru_locks osc
2860 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2861 error "wrong size after lock cancel"
2863 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2864 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2865 error "expanding truncate failed"
2866 cancel_lru_locks osc
2867 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2868 error "wrong expanded size after lock cancel"
2870 run_test 34g "truncate long file ==============================="
2873 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2877 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2878 sync # Flush the cache so that multiop below does not block on cache
2879 # flush when getting the group lock
2880 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2883 # Since just timed wait is not good enough, let's do a sync write
2884 # that way we are sure enough time for a roundtrip + processing
2885 # passed + 2 seconds of extra margin.
2886 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2890 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2891 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2895 local nsz=`stat -c %s $DIR/$tfile`
2896 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2898 run_test 34h "ftruncate file under grouplock should not block"
2901 cp /bin/sh $DIR/f35a
2903 chown $RUNAS_ID $DIR/f35a
2904 $RUNAS $DIR/f35a && error || true
2907 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2911 utime $DIR/f36 || error
2913 run_test 36a "MDS utime check (mknod, utime) ==================="
2917 utime $DIR/f36 || error
2919 run_test 36b "OST utime check (open, utime) ===================="
2924 chown $RUNAS_ID $DIR/d36
2925 $RUNAS utime $DIR/d36/f36 || error
2927 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2930 [ ! -d $DIR/d36 ] && test_36c
2931 echo "" > $DIR/d36/f36
2932 $RUNAS utime $DIR/d36/f36 || error
2934 run_test 36d "non-root OST utime check (open, utime) ==========="
2937 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2938 test_mkdir -p $DIR/$tdir
2939 touch $DIR/$tdir/$tfile
2940 $RUNAS utime $DIR/$tdir/$tfile && \
2941 error "utime worked, expected failure" || true
2943 run_test 36e "utime on non-owned file (should return error) ===="
2947 local LANG_SAVE=$LANG
2948 local LC_LANG_SAVE=$LC_LANG
2949 export LANG=C LC_LANG=C # for date language
2951 DATESTR="Dec 20 2000"
2952 test_mkdir -p $DIR/$tdir
2953 lctl set_param fail_loc=$fl
2955 cp /etc/hosts $DIR/$tdir/$tfile
2956 sync & # write RPC generated with "current" inode timestamp, but delayed
2958 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2959 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2960 cancel_lru_locks osc
2961 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2963 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2964 echo "BEFORE: $LS_BEFORE" && \
2965 echo "AFTER : $LS_AFTER" && \
2966 echo "WANT : $DATESTR" && \
2967 error "$DIR/$tdir/$tfile timestamps changed" || true
2969 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2974 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2975 subr_36fh "0x80000214"
2977 run_test 36f "utime on file racing with OST BRW write =========="
2980 remote_ost_nodsh && skip "remote OST with nodsh" && return
2981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2986 test_mkdir -p $DIR/$tdir
2987 fmd_max_age=$(do_facet ost1 \
2988 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2991 fmd_before=$(do_facet ost1 \
2992 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2993 touch $DIR/$tdir/$tfile
2994 sleep $((fmd_max_age + 12))
2995 fmd_after=$(do_facet ost1 \
2996 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2998 echo "fmd_before: $fmd_before"
2999 echo "fmd_after: $fmd_after"
3000 [[ $fmd_after -gt $fmd_before ]] &&
3001 echo "AFTER: $fmd_after > BEFORE: $fmd_before" &&
3002 error "fmd didn't expire after ping" || true
3004 run_test 36g "filter mod data cache expiry ====================="
3007 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3008 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3009 subr_36fh "0x80000227"
3011 run_test 36h "utime on file racing with OST BRW write =========="
3014 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3017 $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
3019 local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
3020 local new_mtime=$((mtime + 200))
3022 #change Modify time of striped dir
3023 touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
3024 error "change mtime failed"
3026 local got=$(stat -c%Y $DIR/$tdir/striped_dir)
3028 [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
3030 run_test 36i "change mtime on striped directory"
3032 # test_37 - duplicate with tests 32q 32r
3035 local file=$DIR/$tfile
3037 openfile -f O_DIRECTORY $file
3040 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
3041 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
3043 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
3047 touch $DIR/${tfile}2
3048 # ls -l $DIR/$tfile $DIR/${tfile}2
3049 # ls -lu $DIR/$tfile $DIR/${tfile}2
3050 # ls -lc $DIR/$tfile $DIR/${tfile}2
3052 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
3053 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
3055 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
3057 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
3059 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
3060 error "O_TRUNC didn't change timestamps"
3063 run_test 39 "mtime changed on create ==========================="
3066 test_mkdir -p -c1 $DIR/$tdir
3067 cp -p /etc/passwd $DIR/$tdir/fopen
3068 cp -p /etc/passwd $DIR/$tdir/flink
3069 cp -p /etc/passwd $DIR/$tdir/funlink
3070 cp -p /etc/passwd $DIR/$tdir/frename
3071 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
3074 echo "aaaaaa" >> $DIR/$tdir/fopen
3075 echo "aaaaaa" >> $DIR/$tdir/flink
3076 echo "aaaaaa" >> $DIR/$tdir/funlink
3077 echo "aaaaaa" >> $DIR/$tdir/frename
3079 local open_new=`stat -c %Y $DIR/$tdir/fopen`
3080 local link_new=`stat -c %Y $DIR/$tdir/flink`
3081 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
3082 local rename_new=`stat -c %Y $DIR/$tdir/frename`
3084 cat $DIR/$tdir/fopen > /dev/null
3085 ln $DIR/$tdir/flink $DIR/$tdir/flink2
3086 rm -f $DIR/$tdir/funlink2
3087 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
3089 for (( i=0; i < 2; i++ )) ; do
3090 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
3091 local link_new2=`stat -c %Y $DIR/$tdir/flink`
3092 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
3093 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
3095 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
3096 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
3097 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
3098 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
3100 cancel_lru_locks osc
3101 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3104 run_test 39b "mtime change on open, link, unlink, rename ======"
3106 # this should be set to past
3107 TEST_39_MTIME=`date -d "1 year ago" +%s`
3113 local mtime0=`stat -c %Y $DIR1/$tfile`
3115 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3116 local mtime1=`stat -c %Y $DIR1/$tfile`
3117 [ "$mtime1" = $TEST_39_MTIME ] || \
3118 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
3121 echo hello >> $DIR1/$tfile
3123 local mtime2=`stat -c %Y $DIR1/$tfile`
3124 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
3125 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
3127 mv $DIR1/$tfile $DIR1/$tfile-1
3129 for (( i=0; i < 2; i++ )) ; do
3130 local mtime3=`stat -c %Y $DIR1/$tfile-1`
3131 [ "$mtime2" = "$mtime3" ] || \
3132 error "mtime ($mtime2) changed (to $mtime3) on rename"
3134 cancel_lru_locks osc
3135 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3138 run_test 39c "mtime change on rename ==========================="
3142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3145 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3147 for (( i=0; i < 2; i++ )) ; do
3148 local mtime=`stat -c %Y $DIR1/$tfile`
3149 [ $mtime = $TEST_39_MTIME ] || \
3150 error "mtime($mtime) is not set to $TEST_39_MTIME"
3152 cancel_lru_locks osc
3153 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3156 run_test 39d "create, utime, stat =============================="
3160 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3162 local mtime1=`stat -c %Y $DIR1/$tfile`
3164 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3166 for (( i=0; i < 2; i++ )) ; do
3167 local mtime2=`stat -c %Y $DIR1/$tfile`
3168 [ $mtime2 = $TEST_39_MTIME ] || \
3169 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3171 cancel_lru_locks osc
3172 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3175 run_test 39e "create, stat, utime, stat ========================"
3179 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3181 mtime1=`stat -c %Y $DIR1/$tfile`
3184 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3186 for (( i=0; i < 2; i++ )) ; do
3187 local mtime2=`stat -c %Y $DIR1/$tfile`
3188 [ $mtime2 = $TEST_39_MTIME ] || \
3189 error "mtime($mtime2) is not set to $TEST_39_MTIME"
3191 cancel_lru_locks osc
3192 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3195 run_test 39f "create, stat, sleep, utime, stat ================="
3199 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3200 echo hello >> $DIR1/$tfile
3201 local mtime1=`stat -c %Y $DIR1/$tfile`
3204 chmod o+r $DIR1/$tfile
3206 for (( i=0; i < 2; i++ )) ; do
3207 local mtime2=`stat -c %Y $DIR1/$tfile`
3208 [ "$mtime1" = "$mtime2" ] || \
3209 error "lost mtime: $mtime2, should be $mtime1"
3211 cancel_lru_locks osc
3212 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3215 run_test 39g "write, chmod, stat ==============================="
3219 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3224 echo hello >> $DIR1/$tfile
3225 local mtime1=`stat -c %Y $DIR1/$tfile`
3227 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3229 if [ "$d1" != "$d2" ]; then
3230 echo "write and touch not within one second"
3232 for (( i=0; i < 2; i++ )) ; do
3233 local mtime2=`stat -c %Y $DIR1/$tfile`
3234 [ "$mtime2" = $TEST_39_MTIME ] || \
3235 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
3237 cancel_lru_locks osc
3238 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3242 run_test 39h "write, utime within one second, stat ============="
3245 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3249 echo hello >> $DIR1/$tfile
3250 local mtime1=`stat -c %Y $DIR1/$tfile`
3252 mv $DIR1/$tfile $DIR1/$tfile-1
3254 for (( i=0; i < 2; i++ )) ; do
3255 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3257 [ "$mtime1" = "$mtime2" ] || \
3258 error "lost mtime: $mtime2, should be $mtime1"
3260 cancel_lru_locks osc
3261 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3264 run_test 39i "write, rename, stat =============================="
3267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3268 start_full_debug_logging
3272 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
3273 lctl set_param fail_loc=0x80000412
3274 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
3275 error "multiop failed"
3277 local mtime1=`stat -c %Y $DIR1/$tfile`
3279 mv $DIR1/$tfile $DIR1/$tfile-1
3281 kill -USR1 $multipid
3282 wait $multipid || error "multiop close failed"
3284 for (( i=0; i < 2; i++ )) ; do
3285 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3286 [ "$mtime1" = "$mtime2" ] ||
3287 error "mtime is lost on close: $mtime2, " \
3290 cancel_lru_locks osc
3291 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3293 lctl set_param fail_loc=0
3294 stop_full_debug_logging
3296 run_test 39j "write, rename, close, stat ======================="
3299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3303 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3305 local mtime1=`stat -c %Y $DIR1/$tfile`
3307 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3309 kill -USR1 $multipid
3310 wait $multipid || error "multiop close failed"
3312 for (( i=0; i < 2; i++ )) ; do
3313 local mtime2=`stat -c %Y $DIR1/$tfile`
3315 [ "$mtime2" = $TEST_39_MTIME ] || \
3316 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3318 cancel_lru_locks osc
3319 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3322 run_test 39k "write, utime, close, stat ========================"
3324 # this should be set to future
3325 TEST_39_ATIME=`date -d "1 year" +%s`
3328 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3329 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3330 local atime_diff=$(do_facet $SINGLEMDS \
3331 lctl get_param -n mdd.*MDT0000*.atime_diff)
3335 # test setting directory atime to future
3336 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3337 local atime=$(stat -c %X $DIR/$tdir)
3338 [ "$atime" = $TEST_39_ATIME ] || \
3339 error "atime is not set to future: $atime, $TEST_39_ATIME"
3341 # test setting directory atime from future to now
3342 local d1=$(date +%s)
3344 local d2=$(date +%s)
3346 cancel_lru_locks mdc
3347 atime=$(stat -c %X $DIR/$tdir)
3348 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3349 error "atime is not updated from future: $atime, $d1<atime<$d2"
3351 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3354 # test setting directory atime when now > dir atime + atime_diff
3358 cancel_lru_locks mdc
3359 atime=$(stat -c %X $DIR/$tdir)
3360 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3361 error "atime is not updated : $atime, should be $d2"
3363 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3366 # test not setting directory atime when now < dir atime + atime_diff
3368 cancel_lru_locks mdc
3369 atime=$(stat -c %X $DIR/$tdir)
3370 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3371 error "atime is updated to $atime, should remain $d1<atime<$d2"
3373 do_facet $SINGLEMDS \
3374 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3376 run_test 39l "directory atime update ==========================="
3379 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3382 local far_past_mtime=$(date -d "May 29 1953" +%s)
3383 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3385 touch -m -d @$far_past_mtime $DIR1/$tfile
3386 touch -a -d @$far_past_atime $DIR1/$tfile
3388 for (( i=0; i < 2; i++ )) ; do
3389 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3390 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3391 error "atime or mtime set incorrectly"
3393 cancel_lru_locks osc
3394 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3397 run_test 39m "test atime and mtime before 1970"
3399 test_39n() { # LU-3832
3400 local atime_diff=$(do_facet $SINGLEMDS \
3401 lctl get_param -n mdd.*MDT0000*.atime_diff)
3406 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3409 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3410 atime0=$(stat -c %X $DIR/$tfile)
3413 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3414 atime1=$(stat -c %X $DIR/$tfile)
3417 cancel_lru_locks mdc
3418 cancel_lru_locks osc
3419 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3420 atime2=$(stat -c %X $DIR/$tfile)
3422 do_facet $SINGLEMDS \
3423 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3425 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3426 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3428 run_test 39n "check that O_NOATIME is honored"
3431 TESTDIR=$DIR/$tdir/$tfile
3432 [ -e $TESTDIR ] && rm -rf $TESTDIR
3433 test_mkdir -p $TESTDIR
3439 links2=$(stat -c %h .)
3440 [ $(($links1 + 2)) != $links2 ] &&
3441 error "wrong links count $(($links1 + 2)) != $links2"
3443 links3=$(stat -c %h .)
3444 [ $(($links1 + 1)) != $links3 ] &&
3445 error "wrong links count $links1 != $links3"
3448 run_test 39o "directory cached attributes updated after create ========"
3451 [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
3453 TESTDIR=$DIR/$tdir/$tfile
3454 [ -e $TESTDIR ] && rm -rf $TESTDIR
3459 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3460 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3462 links2=$(stat -c %h .)
3463 [ $(($links1 + 2)) != $links2 ] &&
3464 error "wrong links count $(($links1 + 2)) != $links2"
3466 links3=$(stat -c %h .)
3467 [ $(($links1 + 1)) != $links3 ] &&
3468 error "wrong links count $links1 != $links3"
3471 run_test 39p "remote directory cached attributes updated after create ========"
3475 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3476 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3477 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3478 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3479 error "$tfile is not 4096 bytes in size"
3481 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3485 small_write $DIR/f41 18
3487 run_test 41 "test small file write + fstat ====================="
3489 count_ost_writes() {
3490 lctl get_param -n osc.*.stats |
3491 awk -vwrites=0 '/ost_write/ { writes += $2 } \
3492 END { printf("%0.0f", writes) }'
3499 BG_DIRTY_RATIO_SAVE=10
3500 MAX_BG_DIRTY_RATIO=25
3504 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3505 # dirty_ratio, dirty_background_ratio
3506 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3507 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3508 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3509 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3511 # if file not here, we are a 2.4 kernel
3512 kill -CONT `pidof kupdated`
3517 # setup the trap first, so someone cannot exit the test at the
3518 # exact wrong time and mess up a machine
3519 trap start_writeback EXIT
3520 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3521 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3522 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3523 sysctl -w vm.dirty_writeback_centisecs=0
3524 sysctl -w vm.dirty_writeback_centisecs=0
3525 # save and increase /proc/sys/vm/dirty_ratio
3526 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3527 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3528 # save and increase /proc/sys/vm/dirty_background_ratio
3529 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3530 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3532 # if file not here, we are a 2.4 kernel
3533 kill -STOP `pidof kupdated`
3537 # ensure that all stripes have some grant before we test client-side cache
3539 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3540 dd if=/dev/zero of=$i bs=4k count=1
3545 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3546 # file truncation, and file removal.
3548 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3550 cancel_lru_locks osc
3552 sync; sleep 1; sync # just to be safe
3553 BEFOREWRITES=`count_ost_writes`
3554 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3555 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3556 AFTERWRITES=`count_ost_writes`
3557 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3558 error "$BEFOREWRITES < $AFTERWRITES"
3561 run_test 42a "ensure that we don't flush on close =============="
3564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3566 cancel_lru_locks osc
3569 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3570 BEFOREWRITES=$(count_ost_writes)
3571 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3572 AFTERWRITES=$(count_ost_writes)
3573 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3574 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3576 BEFOREWRITES=$(count_ost_writes)
3577 sync || error "sync: $?"
3578 AFTERWRITES=$(count_ost_writes)
3579 if [[ $BEFOREWRITES -lt $AFTERWRITES ]]; then
3580 error "$BEFOREWRITES < $AFTERWRITES on sync"
3582 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3586 run_test 42b "test destroy of file with cached dirty data ======"
3588 # if these tests just want to test the effect of truncation,
3589 # they have to be very careful. consider:
3590 # - the first open gets a {0,EOF}PR lock
3591 # - the first write conflicts and gets a {0, count-1}PW
3592 # - the rest of the writes are under {count,EOF}PW
3593 # - the open for truncate tries to match a {0,EOF}PR
3594 # for the filesize and cancels the PWs.
3595 # any number of fixes (don't get {0,EOF} on open, match
3596 # composite locks, do smarter file size management) fix
3597 # this, but for now we want these tests to verify that
3598 # the cancellation with truncate intent works, so we
3599 # start the file with a full-file pw lock to match against
3600 # until the truncate.
3605 cancel_lru_locks osc
3607 # prime the file with 0,EOF PW to match
3611 # now the real test..
3612 dd if=/dev/zero of=$file bs=1024 count=100
3613 BEFOREWRITES=`count_ost_writes`
3614 $TRUNCATE $file $offset
3615 cancel_lru_locks osc
3616 AFTERWRITES=`count_ost_writes`
3621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3623 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3624 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3627 run_test 42c "test partial truncate of file with cached dirty data"
3630 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3632 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3633 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3636 run_test 42d "test complete truncate of file with cached dirty data"
3638 test_42e() { # bug22074
3639 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3640 local TDIR=$DIR/${tdir}e
3641 local pagesz=$(page_size)
3642 local pages=16 # hardcoded 16 pages, don't change it.
3643 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3644 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3648 test_mkdir -p $DIR/${tdir}e
3649 $SETSTRIPE -c 1 $TDIR
3650 createmany -o $TDIR/f $files
3652 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3654 # we assume that with $OSTCOUNT files, at least one of them will
3655 # be allocated on OST0.
3656 warmup_files=$((OSTCOUNT * max_dirty_mb))
3657 createmany -o $TDIR/w $warmup_files
3659 # write a large amount of data into one file and sync, to get good
3660 # avail_grant number from OST.
3661 for ((i=0; i<$warmup_files; i++)); do
3662 idx=$($GETSTRIPE -i $TDIR/w$i)
3663 [ $idx -ne 0 ] && continue
3664 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3667 [[ $i -gt $warmup_files ]] && error "OST0 is still cold"
3669 $LCTL get_param $proc_osc0/cur_dirty_bytes
3670 $LCTL get_param $proc_osc0/cur_grant_bytes
3672 # create as much dirty pages as we can while not to trigger the actual
3673 # RPCs directly. but depends on the env, VFS may trigger flush during this
3674 # period, hopefully we are good.
3675 for ((i=0; i<$warmup_files; i++)); do
3676 idx=$($GETSTRIPE -i $TDIR/w$i)
3677 [ $idx -ne 0 ] && continue
3678 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3680 $LCTL get_param $proc_osc0/cur_dirty_bytes
3681 $LCTL get_param $proc_osc0/cur_grant_bytes
3683 # perform the real test
3684 $LCTL set_param $proc_osc0/rpc_stats 0
3685 for ((;i<$files; i++)); do
3686 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3687 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3690 $LCTL get_param $proc_osc0/rpc_stats
3693 local have_ppr=false
3694 $LCTL get_param $proc_osc0/rpc_stats |
3695 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3696 # skip lines until we are at the RPC histogram data
3697 [ "$PPR" == "pages" ] && have_ppr=true && continue
3698 $have_ppr || continue
3700 # we only want the percent stat for < 16 pages
3701 [[ $(echo $PPR | tr -d ':') -ge $pages ]] && break
3703 percent=$((percent + WPCT))
3704 if [[ $percent -gt 15 ]]; then
3705 error "less than 16-pages write RPCs" \
3712 run_test 42e "verify sub-RPC writes are not done synchronously"
3715 test_mkdir -p $DIR/$tdir
3716 cp -p /bin/ls $DIR/$tdir/$tfile
3717 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3719 # give multiop a chance to open
3722 $DIR/$tdir/$tfile && error || true
3725 run_test 43 "execution of file opened for write should return -ETXTBSY"
3728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3729 test_mkdir -p $DIR/$tdir
3730 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3731 cp -p multiop $DIR/$tdir/multiop
3732 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3735 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3736 kill -USR1 $MULTIOP_PID || return 2
3737 wait $MULTIOP_PID || return 3
3738 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3740 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3744 test_mkdir -p $DIR/$tdir
3745 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3746 cp -p multiop $DIR/$tdir/multiop
3747 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3750 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3751 kill -USR1 $MULTIOP_PID || return 2
3752 wait $MULTIOP_PID || return 3
3753 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3755 run_test 43b "truncate of file being executed should return -ETXTBSY"
3758 local testdir="$DIR/$tdir"
3759 test_mkdir -p $DIR/$tdir
3761 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3762 ( cd $testdir && md5sum -c)
3764 run_test 43c "md5sum of copy into lustre========================"
3767 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
3768 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3769 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3771 run_test 44 "zero length read from a sparse stripe ============="
3774 local nstripe=$($LCTL lov_getconfig $DIR | grep default_stripe_count: |
3776 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3777 [[ $nstripe -gt $OSTCOUNT ]] &&
3778 skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
3780 local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
3782 if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
3783 nstripe=$($LCTL lov_getconfig $DIR | grep obd_count: |
3787 OFFSETS="0 $((stride/2)) $((stride-1))"
3788 for offset in $OFFSETS; do
3789 for i in $(seq 0 $((nstripe-1))); do
3790 local GLOBALOFFSETS=""
3792 local size=$((((i + 2 * $nstripe )*$stride + $offset)))
3793 local myfn=$DIR/d44a-$size
3794 echo "--------writing $myfn at $size"
3795 ll_sparseness_write $myfn $size ||
3796 error "ll_sparseness_write"
3797 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3798 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3799 error "ll_sparseness_verify $GLOBALOFFSETS"
3801 for j in $(seq 0 $((nstripe-1))); do
3803 size=$((((j + $nstripe )*$stride + $offset)))
3804 ll_sparseness_write $myfn $size ||
3805 error "ll_sparseness_write"
3806 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3808 ll_sparseness_verify $myfn $GLOBALOFFSETS ||
3809 error "ll_sparseness_verify $GLOBALOFFSETS"
3814 run_test 44a "test sparse pwrite ==============================="
3818 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3824 before=`dirty_osc_total`
3825 echo executing "\"$*\""
3827 after=`dirty_osc_total`
3828 echo before $before, after $after
3831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3833 # Obtain grants from OST if it supports it
3834 echo blah > ${f}_grant
3837 do_dirty_record "echo blah > $f"
3838 [[ $before -eq $after ]] && error "write wasn't cached"
3839 do_dirty_record "> $f"
3840 [[ $before -gt $after ]] || error "truncate didn't lower dirty count"
3841 do_dirty_record "echo blah > $f"
3842 [[ $before -eq $after ]] && error "write wasn't cached"
3843 do_dirty_record "sync"
3844 [[ $before -gt $after ]] || error "writeback didn't lower dirty count"
3845 do_dirty_record "echo blah > $f"
3846 [[ $before -eq $after ]] && error "write wasn't cached"
3847 do_dirty_record "cancel_lru_locks osc"
3848 [[ $before -gt $after ]] ||
3849 error "lock cancellation didn't lower dirty count"
3852 run_test 45 "osc io page accounting ============================"
3854 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3855 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3856 # objects offset and an assert hit when an rpc was built with 1023's mapped
3857 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3863 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3865 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3866 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3870 run_test 46 "dirtying a previously written page ================"
3872 # test_47 is removed "Device nodes check" is moved to test_28
3874 test_48a() { # bug 2399
3875 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
3876 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
3877 skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
3879 check_kernel_version 34 || return 0
3880 test_mkdir -p $DIR/$tdir
3882 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3883 test_mkdir $DIR/$tdir || error "recreate directory failed"
3884 touch foo || error "'touch foo' failed after recreating cwd"
3885 test_mkdir $DIR/$tdir/bar ||
3886 error "'mkdir foo' failed after recreating cwd"
3887 if check_kernel_version 44; then
3888 touch .foo || error "'touch .foo' failed after recreating cwd"
3889 test_mkdir $DIR/$tdir/.bar ||
3890 error "'mkdir .foo' failed after recreating cwd"
3892 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3893 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3894 cd . || error "'cd .' failed after recreating cwd"
3895 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3896 rmdir . && error "'rmdir .' worked after recreating cwd"
3897 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3898 cd .. || error "'cd ..' failed after recreating cwd"
3900 run_test 48a "Access renamed working dir (should return errors)="
3902 test_48b() { # bug 2399
3903 check_kernel_version 34 || return 0
3905 test_mkdir -p $DIR/$tdir
3907 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3908 touch foo && error "'touch foo' worked after removing cwd"
3909 test_mkdir $DIR/$tdir/foo &&
3910 error "'mkdir foo' worked after removing cwd"
3911 if check_kernel_version 44; then
3912 touch .foo && error "'touch .foo' worked after removing cwd"
3913 test_mkdir $DIR/$tdir/.foo &&
3914 error "'mkdir .foo' worked after removing cwd"
3916 ls . > /dev/null && error "'ls .' worked after removing cwd"
3917 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3918 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3919 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3920 rmdir . && error "'rmdir .' worked after removing cwd"
3921 ln -s . foo && error "'ln -s .' worked after removing cwd"
3922 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3924 run_test 48b "Access removed working dir (should return errors)="
3926 test_48c() { # bug 2350
3927 check_kernel_version 36 || return 0
3928 #lctl set_param debug=-1
3931 test_mkdir -p $DIR/$tdir/dir
3933 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3934 $TRACE touch foo && error "touch foo worked after removing cwd"
3935 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3936 if check_kernel_version 44; then
3937 touch .foo && error "touch .foo worked after removing cwd"
3938 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3940 $TRACE ls . && error "'ls .' worked after removing cwd"
3941 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3942 is_patchless || ( $TRACE cd . &&
3943 error "'cd .' worked after removing cwd" )
3944 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3945 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3946 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3947 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3949 run_test 48c "Access removed working subdir (should return errors)"
3951 test_48d() { # bug 2350
3952 check_kernel_version 36 || return 0
3953 #lctl set_param debug=-1
3956 test_mkdir -p $DIR/$tdir/dir
3958 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3959 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3960 $TRACE touch foo && error "'touch foo' worked after removing parent"
3961 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3962 if check_kernel_version 44; then
3963 touch .foo && error "'touch .foo' worked after removing parent"
3965 error "mkdir .foo worked after removing parent"
3967 $TRACE ls . && error "'ls .' worked after removing parent"
3968 $TRACE ls .. && error "'ls ..' worked after removing parent"
3969 is_patchless || ( $TRACE cd . &&
3970 error "'cd .' worked after recreate parent" )
3971 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3972 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3973 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3974 is_patchless || ( $TRACE cd .. &&
3975 error "'cd ..' worked after removing parent" || true )
3977 run_test 48d "Access removed parent subdir (should return errors)"
3979 test_48e() { # bug 4134
3980 check_kernel_version 41 || return 0
3981 #lctl set_param debug=-1
3984 test_mkdir -p $DIR/$tdir/dir
3986 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3987 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3988 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3989 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3990 # On a buggy kernel addition of "touch foo" after cd .. will
3991 # produce kernel oops in lookup_hash_it
3992 touch ../foo && error "'cd ..' worked after recreate parent"
3994 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3996 run_test 48e "Access to recreated parent subdir (should return errors)"
3998 test_49() { # LU-1030
3999 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4000 # get ost1 size - lustre-OST0000
4001 ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
4003 # write 800M at maximum
4004 [[ $ost1_size -lt 2 ]] && ost1_size=2
4005 [[ $ost1_size -gt 819200 ]] && ost1_size=819200
4007 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
4008 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
4011 # change max_pages_per_rpc while writing the file
4012 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
4013 local orig_mppc=$($LCTL get_param -n $osc1_mppc)
4014 # loop until dd process exits
4015 while ps ax -opid | grep -wq $dd_pid; do
4016 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
4017 sleep $((RANDOM % 5 + 1))
4019 # restore original max_pages_per_rpc
4020 $LCTL set_param $osc1_mppc=$orig_mppc
4021 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
4023 run_test 49 "Change max_pages_per_rpc won't break osc extent"
4027 test_mkdir $DIR/$tdir
4029 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
4031 run_test 50 "special situations: /proc symlinks ==============="
4033 test_51a() { # was test_51
4034 # bug 1516 - create an empty entry right after ".." then split dir
4035 test_mkdir -c1 $DIR/$tdir
4036 touch $DIR/$tdir/foo
4037 $MCREATE $DIR/$tdir/bar
4039 createmany -m $DIR/$tdir/longfile 201
4041 while [[ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]]; do
4042 $MCREATE $DIR/$tdir/longfile$FNUM
4047 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
4049 run_test 51a "special situations: split htree with empty entry =="
4051 export NUMTEST=70000
4053 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4054 local BASE=$DIR/d${base}.${TESTSUITE}
4056 # cleanup the directory
4059 test_mkdir -p -c1 $BASE
4063 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
4064 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
4065 [[ $numfree -lt 21000 ]] &&
4066 skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
4069 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$(($numfree - 50)) &&
4070 echo "reduced count to $NUMTEST due to inodes on MDT$mdtidx"
4072 # need to check free space for the directories as well
4073 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
4074 numfree=$((blkfree / 4))
4075 [[ $numfree -lt $NUMTEST ]] && NUMTEST=$((numfree - 50)) &&
4076 echo "reduced count to $NUMTEST due to blocks on MDT$mdtidx"
4078 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
4082 echo "failed" > $BASE/fnum
4083 error "failed to create $NUMTEST subdirs in MDT$mdtidx:$BASE"
4086 run_test 51b "exceed 64k subdirectory nlink limit"
4088 test_51ba() { # LU-993
4089 local BASE=$DIR/d${base}.${TESTSUITE}
4090 # unlink all but 100 subdirectories, then check it still works
4092 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
4094 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
4095 local DELETE=$((NUMTEST - LEFT))
4097 # continue on to run this test even if 51b didn't finish,
4098 # just to delete the many subdirectories created.
4099 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
4101 # for ldiskfs the nlink count should be 1, but this is OSD specific
4102 # and so this is listed for informational purposes only
4103 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
4104 unlinkmany -d $BASE/d $DELETE
4107 if [ $RC -ne 0 ]; then
4108 if [ "$NUMPREV" == "failed" ]; then
4109 skip "previous setup failed"
4112 error "unlink of first $DELETE subdirs failed"
4117 echo "nlink between: $(stat -c %h $BASE)"
4118 # trim the first line of ls output
4119 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
4120 [ $FOUND -ne $LEFT ] &&
4121 error "can't find subdirs: found only $FOUND/$LEFT"
4123 unlinkmany -d $BASE/d $DELETE $LEFT ||
4124 error "unlink of second $LEFT subdirs failed"
4125 # regardless of whether the backing filesystem tracks nlink accurately
4126 # or not, the nlink count shouldn't be more than "." and ".." here
4127 local AFTER=$(stat -c %h $BASE)
4128 [[ $AFTER -gt 2 ]] && error "nlink after: $AFTER > 2" ||
4129 echo "nlink after: $AFTER"
4131 run_test 51ba "verify nlink for many subdirectory cleanup"
4134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4135 [[ $OSTCOUNT -lt 3 ]] &&
4136 skip_env "skipping test with few OSTs" && return
4137 test_mkdir -p $DIR/$tdir
4138 createmany -o $DIR/$tdir/t- 1000
4139 $GETSTRIPE $DIR/$tdir > $TMP/files
4140 for N in $(seq 0 $((OSTCOUNT - 1))); do
4141 OBJS[$N]=$(awk -vobjs=0 '($1 == '$N') { objs += 1 } \
4142 END { printf("%0.0f", objs) }' $TMP/files)
4143 OBJS0[$N]=$(grep -A 1 idx $TMP/files | awk -vobjs=0 \
4144 '($1 == '$N') { objs += 1 } \
4145 END { printf("%0.0f", objs) }')
4146 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
4148 unlinkmany $DIR/$tdir/t- 1000
4151 for N in $(seq 1 $((OSTCOUNT - 1))); do
4152 [[ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ]] &&
4153 error "OST $N has less objects vs OST $NLAST" \
4154 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4155 [[ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ]] &&
4156 error "OST $N has less objects vs OST $NLAST" \
4157 " (${OBJS[$N]} < ${OBJS[$NLAST]}"
4159 [[ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ]] &&
4160 error "OST $N has less #0 objects vs OST $NLAST" \
4161 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4162 [[ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ]] &&
4163 error "OST $N has less #0 objects vs OST $NLAST" \
4164 " (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
4168 run_test 51d "check object distribution ===================="
4171 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4172 skip "Only applicable to ldiskfs-based MDTs"
4176 test_mkdir -c1 $DIR/$tdir || error "create $tdir failed"
4177 test_mkdir -c1 $DIR/$tdir/d0 || error "create d0 failed"
4179 touch $DIR/$tdir/d0/foo
4180 createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
4181 error "file exceed 65000 nlink limit!"
4182 unlinkmany $DIR/$tdir/d0/f- 65001
4185 run_test 51e "check file nlink limit"
4188 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
4189 test_mkdir -p $DIR/$tdir
4190 touch $DIR/$tdir/foo
4191 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
4192 echo bar >> $DIR/$tdir/foo || error "append bar failed"
4193 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4194 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4195 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4197 echo foo >> $DIR/$tdir/foo || error "append foo failed"
4198 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4199 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
4201 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
4202 cp -r $DIR/$tdir /tmp/
4203 rm -fr $DIR/$tdir || error "cleanup rm failed"
4205 run_test 52a "append-only flag test (should return errors) ====="
4208 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
4209 test_mkdir -p $DIR/$tdir
4210 touch $DIR/$tdir/foo
4211 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
4212 cat test > $DIR/$tdir/foo && error "cat test worked"
4213 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
4214 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
4215 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
4217 echo foo >> $DIR/$tdir/foo && error "echo worked"
4218 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
4219 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
4220 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
4221 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
4223 chattr -i $DIR/$tdir/foo || error "chattr failed"
4225 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
4227 run_test 52b "immutable flag test (should return errors) ======="
4230 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4231 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4232 remote_ost_nodsh && skip "remote OST with nodsh" && return
4245 local support_last_seq=true
4247 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
4248 support_last_seq=false
4251 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
4253 for value in $(do_facet $SINGLEMDS \
4254 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
4255 param=$(echo ${value[0]} | cut -d "=" -f1)
4256 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
4258 if $support_last_seq; then
4259 param_seq=$(echo $param |
4260 sed -e s/prealloc_last_id/prealloc_last_seq/g)
4261 mds_last_seq=$(do_facet $SINGLEMDS \
4262 $LCTL get_param -n $param_seq)
4264 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
4266 ostnum=$(index_from_ostuuid ${ostname}_UUID)
4267 node=$(facet_active_host ost$((ostnum+1)))
4268 param="obdfilter.$ostname.last_id"
4269 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
4270 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
4271 ost_last_id=$ost_last
4273 if $support_last_seq; then
4274 ost_last_id=$(echo $ost_last |
4275 awk -F':' '{print $2}' |
4277 ost_last_seq=$(echo $ost_last |
4278 awk -F':' '{print $1}')
4279 [[ $ost_last_seq = $mds_last_seq ]] || continue
4282 if [[ $ost_last_id != $mds_last ]]; then
4283 error "$ost_last_id != $mds_last"
4290 $found || error "can not match last_seq/last_id for $mdtosc"
4293 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
4296 $SOCKETSERVER $DIR/socket ||
4297 error "$SOCKETSERVER $DIR/socket failed: $?"
4298 $SOCKETCLIENT $DIR/socket ||
4299 error "$SOCKETCLIENT $DIR/socket failed: $?"
4300 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
4302 run_test 54a "unix domain socket test =========================="
4308 dd if=/dev/zero of=$f bs=$(page_size) count=1
4310 run_test 54b "char device works in lustre ======================"
4313 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
4314 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
4315 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
4317 for i in $(seq 3 7); do
4318 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
4326 loopdev="$DIR/loop54c"
4329 $UMOUNT -d $DIR/$tdir || rc=$?
4330 losetup -d $loopdev || true
4331 losetup -d $LOOPDEV || true
4332 rm -rf $loopdev $DIR/$tfile $DIR/$tdir
4337 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4338 loopdev="$DIR/loop54c"
4341 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
4342 trap cleanup_54c EXIT
4343 mknod $loopdev b 7 $LOOPNUM
4344 echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
4345 dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
4346 losetup $loopdev $DIR/$tfile ||
4347 error "can't set up $loopdev for $DIR/$tfile"
4348 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4349 test_mkdir -p $DIR/$tdir
4350 mount -t ext2 $loopdev $DIR/$tdir ||
4351 error "error mounting $loopdev on $DIR/$tdir"
4352 dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
4355 dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
4359 run_test 54c "block device works in lustre ====================="
4365 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4367 run_test 54d "fifo device works in lustre ======================"
4370 check_kernel_version 46 || return 0
4373 cp -aL /dev/console $f
4374 echo $string > $f || error "echo $string to $f failed"
4376 run_test 54e "console/tty device works in lustre ======================"
4378 #The test_55 used to be iopen test and it was removed by bz#24037.
4379 #run_test 55 "check iopen_connect_dentry() ======================"
4381 test_56a() { # was test_56
4384 test_mkdir -p $DIR/$tdir/dir
4386 NUMFILESx2=$(($NUMFILES * 2))
4387 for i in $(seq 1 $NUMFILES); do
4388 touch $DIR/$tdir/file$i
4389 touch $DIR/$tdir/dir/file$i
4392 # test lfs getstripe with --recursive
4393 FILENUM=$($GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx)
4394 [[ $FILENUM -eq $NUMFILESx2 ]] ||
4395 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4396 FILENUM=$($GETSTRIPE $DIR/$tdir | grep -c obdidx)
4397 [[ $FILENUM -eq $NUMFILES ]] ||
4398 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4399 echo "$GETSTRIPE --recursive passed."
4401 # test lfs getstripe with file instead of dir
4402 FILENUM=$($GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx)
4403 [[ $FILENUM -eq 1 ]] ||
4404 error "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4405 echo "$GETSTRIPE file1 passed."
4407 #test lfs getstripe with --verbose
4408 [[ $($GETSTRIPE --verbose $DIR/$tdir |
4409 grep -c lmm_magic) -eq $NUMFILES ]] ||
4410 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4411 [[ $($GETSTRIPE $DIR/$tdir | grep -c lmm_magic) -eq 0 ]] ||
4412 rror "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4413 echo "$GETSTRIPE --verbose passed."
4415 #test lfs getstripe with --obd
4416 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4417 grep -q "unknown obduuid" ||
4418 error "$GETSTRIPE --obd wrong_uuid should return error message"
4420 [[ $OSTCOUNT -lt 2 ]] &&
4421 skip_env "skipping other $GETSTRIPE --obd test" && return
4424 OBDUUID=$(ostuuid_from_index $OSTIDX)
4425 FILENUM=$($GETSTRIPE -ir $DIR/$tdir | grep "^$OSTIDX\$" | wc -l)
4426 FOUND=$($GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l)
4427 [[ $FOUND -eq $FILENUM ]] ||
4428 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4429 [[ $($GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4430 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4431 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l) -eq 0 ]] ||
4432 error "$GETSTRIPE --obd: should not show file on other obd"
4433 echo "$GETSTRIPE --obd passed"
4435 run_test 56a "check $GETSTRIPE"
4440 local LOCAL_NUMFILES="$1"
4441 local LOCAL_NUMDIRS="$2"
4442 local MKDIR_PARAMS="$3"
4443 local DIR_STRIPE_PARAMS="$4"
4445 if [ ! -d "$TDIR" ] ; then
4446 test_mkdir -p $DIR_STRIPE_PARAMS $TDIR
4447 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4448 for i in `seq 1 $LOCAL_NUMFILES` ; do
4451 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4452 test_mkdir $DIR_STRIPE_PARAMS $TDIR/dir$i
4453 for j in `seq 1 $LOCAL_NUMFILES` ; do
4454 touch $TDIR/dir$i/file$j
4460 setup_56_special() {
4464 if [ ! -e "$TDIR/loop1b" ] ; then
4465 for i in `seq 1 $LOCAL_NUMFILES` ; do
4466 mknod $TDIR/loop${i}b b 7 $i
4467 mknod $TDIR/null${i}c c 1 3
4468 ln -s $TDIR/file1 $TDIR/link${i}l
4470 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4471 mknod $TDIR/dir$i/loop${i}b b 7 $i
4472 mknod $TDIR/dir$i/null${i}c c 1 3
4473 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4482 setup_56 $NUMFILES $NUMDIRS
4484 EXPECTED=$(($NUMDIRS + 2))
4485 # test lfs find with -name
4486 for i in $(seq 1 $NUMFILES) ; do
4487 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4488 [ $NUMS -eq $EXPECTED ] ||
4489 error "lfs find -name \"*$i\" $TDIR wrong: "\
4490 "found $NUMS, expected $EXPECTED"
4493 run_test 56g "check lfs find -name ============================="
4499 setup_56 $NUMFILES $NUMDIRS
4501 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4502 # test lfs find with ! -name
4503 for i in $(seq 1 $NUMFILES) ; do
4504 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4505 [ $NUMS -eq $EXPECTED ] ||
4506 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4507 "found $NUMS, expected $EXPECTED"
4510 run_test 56h "check lfs find ! -name ============================="
4514 test_mkdir -p $DIR/$tdir
4515 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4516 CMD="$LFIND -ost $UUID $DIR/$tdir"
4518 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4520 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4524 setup_56_special $NUMFILES $NUMDIRS
4526 EXPECTED=$((NUMDIRS + 1))
4527 CMD="$LFIND -type d $TDIR"
4528 NUMS=$($CMD | wc -l)
4529 [ $NUMS -eq $EXPECTED ] ||
4530 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4532 run_test 56j "check lfs find -type d ============================="
4536 setup_56_special $NUMFILES $NUMDIRS
4538 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4539 CMD="$LFIND -type f $TDIR"
4540 NUMS=$($CMD | wc -l)
4541 [ $NUMS -eq $EXPECTED ] ||
4542 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4544 run_test 56k "check lfs find -type f ============================="
4548 setup_56_special $NUMFILES $NUMDIRS
4550 EXPECTED=$((NUMDIRS + NUMFILES))
4551 CMD="$LFIND -type b $TDIR"
4552 NUMS=$($CMD | wc -l)
4553 [ $NUMS -eq $EXPECTED ] ||
4554 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4556 run_test 56l "check lfs find -type b ============================="
4560 setup_56_special $NUMFILES $NUMDIRS
4562 EXPECTED=$((NUMDIRS + NUMFILES))
4563 CMD="$LFIND -type c $TDIR"
4564 NUMS=$($CMD | wc -l)
4565 [ $NUMS -eq $EXPECTED ] ||
4566 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4568 run_test 56m "check lfs find -type c ============================="
4572 setup_56_special $NUMFILES $NUMDIRS
4574 EXPECTED=$((NUMDIRS + NUMFILES))
4575 CMD="$LFIND -type l $TDIR"
4576 NUMS=$($CMD | wc -l)
4577 [ $NUMS -eq $EXPECTED ] ||
4578 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4580 run_test 56n "check lfs find -type l ============================="
4584 setup_56 $NUMFILES $NUMDIRS
4585 utime $TDIR/file1 > /dev/null || error "utime (1)"
4586 utime $TDIR/file2 > /dev/null || error "utime (2)"
4587 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4588 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4589 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4590 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4593 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4594 [ $NUMS -eq $EXPECTED ] || \
4595 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4598 CMD="$LFIND -mtime 0 $TDIR"
4599 NUMS=$($CMD | wc -l)
4600 [ $NUMS -eq $EXPECTED ] ||
4601 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4603 run_test 56o "check lfs find -mtime for old files =========================="
4606 [ $RUNAS_ID -eq $UID ] &&
4607 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4610 setup_56 $NUMFILES $NUMDIRS
4612 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4614 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4615 NUMS=$($CMD | wc -l)
4616 [ $NUMS -eq $EXPECTED ] || \
4617 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4619 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4620 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4621 NUMS=$($CMD | wc -l)
4622 [ $NUMS -eq $EXPECTED ] || \
4623 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4625 run_test 56p "check lfs find -uid and ! -uid ==============================="
4628 [ $RUNAS_ID -eq $UID ] &&
4629 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4632 setup_56 $NUMFILES $NUMDIRS
4634 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4637 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4638 NUMS=$($CMD | wc -l)
4639 [ $NUMS -eq $EXPECTED ] ||
4640 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4642 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4643 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4644 NUMS=$($CMD | wc -l)
4645 [ $NUMS -eq $EXPECTED ] ||
4646 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4648 run_test 56q "check lfs find -gid and ! -gid ==============================="
4652 setup_56 $NUMFILES $NUMDIRS
4655 CMD="$LFIND -size 0 -type f $TDIR"
4656 NUMS=$($CMD | wc -l)
4657 [ $NUMS -eq $EXPECTED ] ||
4658 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4660 CMD="$LFIND ! -size 0 -type f $TDIR"
4661 NUMS=$($CMD | wc -l)
4662 [ $NUMS -eq $EXPECTED ] ||
4663 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4664 echo "test" > $TDIR/$tfile
4665 echo "test2" > $TDIR/$tfile.2 && sync
4667 CMD="$LFIND -size 5 -type f $TDIR"
4668 NUMS=$($CMD | wc -l)
4669 [ $NUMS -eq $EXPECTED ] ||
4670 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4672 CMD="$LFIND -size +5 -type f $TDIR"
4673 NUMS=$($CMD | wc -l)
4674 [ $NUMS -eq $EXPECTED ] ||
4675 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4677 CMD="$LFIND -size +0 -type f $TDIR"
4678 NUMS=$($CMD | wc -l)
4679 [ $NUMS -eq $EXPECTED ] ||
4680 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4682 CMD="$LFIND ! -size -5 -type f $TDIR"
4683 NUMS=$($CMD | wc -l)
4684 [ $NUMS -eq $EXPECTED ] ||
4685 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4687 CMD="$LFIND -size -5 -type f $TDIR"
4688 NUMS=$($CMD | wc -l)
4689 [ $NUMS -eq $EXPECTED ] ||
4690 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4692 run_test 56r "check lfs find -size works =========================="
4694 test_56s() { # LU-611
4696 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4698 if [[ $OSTCOUNT -gt 1 ]]; then
4699 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4703 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4707 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4708 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4709 NUMS=$($CMD | wc -l)
4710 [ $NUMS -eq $EXPECTED ] || {
4712 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4715 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4716 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4717 NUMS=$($CMD | wc -l)
4718 [ $NUMS -eq $EXPECTED ] || {
4720 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4724 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4725 NUMS=$($CMD | wc -l)
4726 [ $NUMS -eq $EXPECTED ] || {
4728 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4731 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4732 NUMS=$($CMD | wc -l)
4733 [ $NUMS -eq $EXPECTED ] || {
4735 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4739 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4740 NUMS=$($CMD | wc -l)
4741 [ $NUMS -eq $EXPECTED ] || {
4743 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4746 run_test 56s "check lfs find -stripe-count works"
4748 test_56t() { # LU-611
4750 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4752 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4754 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4755 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4756 NUMS=$($CMD | wc -l)
4757 [ $NUMS -eq $EXPECTED ] ||
4758 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4760 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4761 NUMS=$($CMD | wc -l)
4762 [ $NUMS -eq $EXPECTED ] ||
4763 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4765 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4766 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4767 NUMS=$($CMD | wc -l)
4768 [ $NUMS -eq $EXPECTED ] ||
4769 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4771 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4772 NUMS=$($CMD | wc -l)
4773 [ $NUMS -eq $EXPECTED ] ||
4774 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4777 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4778 NUMS=$($CMD | wc -l)
4779 [ $NUMS -eq $EXPECTED ] ||
4780 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4782 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4783 NUMS=$($CMD | wc -l)
4784 [ $NUMS -eq $EXPECTED ] ||
4785 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4788 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4789 NUMS=$($CMD | wc -l)
4790 [ $NUMS -eq $EXPECTED ] ||
4791 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4793 run_test 56t "check lfs find -stripe-size works"
4795 test_56u() { # LU-611
4797 setup_56 $NUMFILES $NUMDIRS "-i 0"
4799 if [[ $OSTCOUNT -gt 1 ]]; then
4800 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4806 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4807 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4808 NUMS=$($CMD | wc -l)
4809 [ $NUMS -eq $EXPECTED ] ||
4810 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4813 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4814 NUMS=$($CMD | wc -l)
4815 [ $NUMS -eq $EXPECTED ] ||
4816 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4818 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4819 NUMS=$($CMD | wc -l)
4820 [ $NUMS -eq $EXPECTED ] ||
4821 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4824 # This should produce an error and not return any files
4825 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4826 NUMS=$($CMD 2>/dev/null | wc -l)
4827 [ $NUMS -eq $EXPECTED ] ||
4828 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4830 if [[ $OSTCOUNT -gt 1 ]]; then
4831 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4832 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4833 NUMS=$($CMD | wc -l)
4834 [ $NUMS -eq $EXPECTED ] ||
4835 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4838 run_test 56u "check lfs find -stripe-index works"
4845 setup_56 $NUMFILES $NUMDIRS
4847 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4848 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4850 for file in $($LFIND -mdt $UUID $TDIR); do
4851 file_mdt_idx=$($GETSTRIPE -M $file)
4852 [ $file_mdt_idx -eq $MDT_IDX ] ||
4853 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4856 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4859 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
4861 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4864 rm -rf $TDIR || error "remove $TDIR failed"
4865 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
4868 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4869 error "$GETSTRIPE -S -d $TDIR failed"
4870 stripe_size=${stripe_size%% *}
4872 local file_size=$((stripe_size * OSTCOUNT))
4873 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4874 local required_space=$((file_num * file_size))
4875 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4876 [[ $free_space -le $((required_space / 1024)) ]] &&
4877 skip_env "need at least $required_space bytes free space," \
4878 "have $free_space kbytes" && return
4881 local dd_count=$((file_size / dd_bs))
4883 # write data into the files
4887 for i in $(seq 1 $NUMFILES); do
4889 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4890 error "write data into $file failed"
4892 for i in $(seq 1 $NUMDIRS); do
4893 for j in $(seq 1 $NUMFILES); do
4894 file=$TDIR/dir$i/file$j
4895 yes | dd bs=$dd_bs count=$dd_count of=$file \
4897 error "write data into $file failed"
4902 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4905 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4907 eval $cmd || error "$cmd failed"
4909 check_stripe_count $TDIR/file1 $expected
4911 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ];
4913 # lfs_migrate file onto OST 0 if it is on OST 1, or onto
4914 # OST 1 if it is on OST 0. This file is small enough to
4915 # be on only one stripe.
4916 file=$TDIR/migr_1_ost
4917 dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 ||
4918 error "write data into $file failed"
4919 local obdidx=$($LFS getstripe -i $file)
4920 local oldmd5=$(md5sum $file)
4922 [[ $obdidx -eq 0 ]] && newobdidx=1
4923 cmd="$LFS migrate -i $newobdidx $file"
4925 eval $cmd || error "$cmd failed"
4926 local realobdix=$($LFS getstripe -i $file)
4927 local newmd5=$(md5sum $file)
4928 [[ $newobdidx -ne $realobdix ]] &&
4929 error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)"
4930 [[ "$oldmd5" != "$newmd5" ]] &&
4931 error "md5sum differ: $oldmd5, $newmd5"
4935 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4937 eval $cmd || error "$cmd failed"
4939 for j in $(seq 1 $NUMFILES); do
4940 check_stripe_count $TDIR/dir1/file$j $expected
4943 # lfs_migrate works with lfs find
4944 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4945 $LFS_MIGRATE -y -c $expected"
4947 eval $cmd || error "$cmd failed"
4949 for i in $(seq 2 $NUMFILES); do
4950 check_stripe_count $TDIR/file$i $expected
4952 for i in $(seq 2 $NUMDIRS); do
4953 for j in $(seq 1 $NUMFILES); do
4954 check_stripe_count $TDIR/dir$i/file$j $expected
4958 run_test 56w "check lfs_migrate -c stripe_count works"
4961 check_swap_layouts_support && return 0
4962 [[ $OSTCOUNT -lt 2 ]] &&
4963 skip_env "need 2 OST, skipping test" && return
4965 local dir0=$DIR/$tdir/$testnum
4966 mkdir -p $dir0 || error "creating dir $dir0"
4968 local ref1=/etc/passwd
4969 local file1=$dir0/file1
4971 $SETSTRIPE -c 2 $file1
4973 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4974 stripe=$($GETSTRIPE -c $file1)
4975 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4976 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4981 run_test 56x "lfs migration support"
4984 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4985 skip "No HSM support on MDS of $(get_lustre_version)," \
4986 "need 2.4.53 at least" && return
4989 local dir0=$DIR/$tdir/$testnum
4990 mkdir -p $dir0 || error "creating dir $dir0"
4991 local f1=$dir0/file1
4992 local f2=$dir0/file2
4994 touch $f1 || error "creating std file $f1"
4995 $MULTIOP $f2 H2c || error "creating released file $f2"
4997 # a directory can be raid0, so ask only for files
4998 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4999 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
5001 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
5002 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
5004 # only files can be released, so no need to force file search
5005 res=$($LFIND $dir0 -L released)
5006 [[ $res == $f2 ]] || error "search released: found $res != $f2"
5008 res=$($LFIND $dir0 \! -L released)
5009 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
5012 run_test 56y "lfs find -L raid0|released"
5014 test_56z() { # LU-4824
5015 # This checks to make sure 'lfs find' continues after errors
5016 # There are two classes of errors that should be caught:
5017 # - If multiple paths are provided, all should be searched even if one
5019 # - If errors are encountered during the search, it should not terminate
5022 test_mkdir $DIR/$tdir
5023 for i in d{0..9}; do
5024 test_mkdir $DIR/$tdir/$i
5026 touch $DIR/$tdir/d{0..9}/$tfile
5027 $LFS find $DIR/non_existent_dir $DIR/$tdir &&
5028 error "$LFS find did not return an error"
5029 # Make a directory unsearchable. This should NOT be the last entry in
5030 # directory order. Arbitrarily pick the 6th entry
5031 chmod 700 $($LFS find $DIR/$tdir -type d | sed '6!d')
5032 local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
5033 # The user should be able to see 10 directories and 9 files
5034 [ $count == 19 ] || error "$LFS find did not continue after error"
5036 run_test 56z "lfs find should continue after an error"
5038 test_56aa() { # LU-5937
5039 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
5042 $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
5044 createmany -o $DIR/$tdir/striped_dir/${tfile}- 1024
5045 local dirs=$(lfs find --size +8k $DIR/$tdir/)
5047 [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
5049 run_test 56aa "lfs find --size under striped dir"
5052 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5053 # note test will not do anything if MDS is not local
5054 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5055 skip "Only applicable to ldiskfs-based MDTs"
5059 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5060 local MNTDEV="osd*.*MDT*.mntdev"
5061 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
5062 [ -z "$DEV" ] && error "can't access $MNTDEV"
5063 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
5064 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
5065 error "can't access $DEV"
5066 DEVISIZE=$(awk '/Inode size:/ { print $3 }' $TMP/t57a.dump)
5067 [[ $DEVISIZE -gt 128 ]] || error "inode size $DEVISIZE"
5071 run_test 57a "verify MDS filesystem created with large inodes =="
5074 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5075 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
5076 skip "Only applicable to ldiskfs-based MDTs"
5080 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5081 local dir=$DIR/$tdir
5085 local FILEN=$dir/f$FILECOUNT
5087 rm -rf $dir || error "removing $dir"
5088 test_mkdir -p -c1 $dir || error "creating $dir"
5089 local mdtidx=$($LFS getstripe -M $dir)
5090 local mdtname=MDT$(printf %04x $mdtidx)
5091 local facet=mds$((mdtidx + 1))
5093 echo "mcreating $FILECOUNT files"
5094 createmany -m $dir/f 1 $FILECOUNT || \
5095 error "creating files in $dir"
5097 # verify that files do not have EAs yet
5098 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
5099 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
5103 df $dir #make sure we get new statfs data
5104 local MDSFREE=$(do_facet $facet \
5105 lctl get_param -n osd*.*$mdtname.kbytesfree)
5106 local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5107 echo "opening files to create objects/EAs"
5109 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
5110 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
5113 # verify that files have EAs now
5114 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
5115 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
5117 sleep 1 #make sure we get new statfs data
5119 local MDSFREE2=$(do_facet $facet \
5120 lctl get_param -n osd*.*$mdtname.kbytesfree)
5121 local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
5122 if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
5123 if [ "$MDSFREE" != "$MDSFREE2" ]; then
5124 error "MDC before $MDCFREE != after $MDCFREE2"
5126 echo "MDC before $MDCFREE != after $MDCFREE2"
5127 echo "unable to confirm if MDS has large inodes"
5132 run_test 57b "default LOV EAs are stored inside large inodes ==="
5135 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5136 [ -z "$(which wiretest 2>/dev/null)" ] &&
5137 skip_env "could not find wiretest" && return
5140 run_test 58 "verify cross-platform wire constants =============="
5143 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5144 echo "touch 130 files"
5145 createmany -o $DIR/f59- 130
5147 unlinkmany $DIR/f59- 130
5149 # wait for commitment of removal
5150 wait_delete_completed
5152 run_test 59 "verify cancellation of llog records async ========="
5154 TEST60_HEAD="test_60 run $RANDOM"
5156 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5157 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
5158 do_facet mgs "! which run-llog.sh &> /dev/null" &&
5159 skip_env "missing subtest run-llog.sh" && return
5160 log "$TEST60_HEAD - from kernel mode"
5161 do_facet mgs sh run-llog.sh
5163 run_test 60a "llog sanity tests run from kernel module =========="
5165 test_60b() { # bug 6411
5166 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5168 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
5180 [[ $LLOG_COUNT -gt 50 ]] &&
5181 error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)" || true
5183 run_test 60b "limit repeated messages from CERROR/CWARN ========"
5186 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5187 echo "create 5000 files"
5188 createmany -o $DIR/f60c- 5000
5189 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
5190 lctl set_param fail_loc=0x80000137
5191 unlinkmany $DIR/f60c- 5000
5192 lctl set_param fail_loc=0
5194 run_test 60c "unlink file when mds full"
5197 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5198 SAVEPRINTK=$(lctl get_param -n printk)
5200 # verify "lctl mark" is even working"
5201 MESSAGE="test message ID $RANDOM $$"
5202 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5203 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
5205 lctl set_param printk=0 || error "set lnet.printk failed"
5206 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
5207 MESSAGE="new test message ID $RANDOM $$"
5208 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
5209 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
5210 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
5212 lctl set_param -n printk="$SAVEPRINTK"
5214 run_test 60d "test printk console message masking"
5217 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5219 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
5220 cancel_lru_locks osc
5221 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
5224 run_test 61 "mmap() writes don't make sync hang ================"
5226 # bug 2330 - insufficient obd_match error checking causes LBUG
5228 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5231 cancel_lru_locks osc
5232 lctl set_param fail_loc=0x405
5233 cat $f && error "cat succeeded, expect -EIO"
5234 lctl set_param fail_loc=0
5236 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
5237 # match every page all of the time.
5238 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
5240 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
5241 # Though this test is irrelevant anymore, it helped to reveal some
5242 # other grant bugs (LU-4482), let's keep it.
5243 test_63a() { # was test_63
5244 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5245 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
5246 for i in `seq 10` ; do
5247 dd if=/dev/zero of=$DIR/f63 bs=8k &
5253 rm -f $DIR/f63 || true
5255 run_test 63a "Verify oig_wait interruption does not crash ======="
5257 # bug 2248 - async write errors didn't return to application on sync
5258 # bug 3677 - async write errors left page locked
5260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5262 lctl set_param debug=-1
5264 # ensure we have a grant to do async writes
5265 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
5268 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
5269 lctl set_param fail_loc=0x80000406
5270 $MULTIOP $DIR/$tfile Owy && \
5271 error "sync didn't return ENOMEM"
5272 sync; sleep 2; sync # do a real sync this time to flush page
5273 lctl get_param -n llite.*.dump_page_cache | grep locked && \
5274 error "locked page left in cache after async error" || true
5277 run_test 63b "async write errors should be returned to fsync ==="
5280 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5282 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
5284 run_test 64a "verify filter grant calculations (in kernel) ====="
5287 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5288 sh oos.sh $MOUNT || error "oos.sh failed: $?"
5290 run_test 64b "check out-of-space detection on client ==========="
5293 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
5295 run_test 64c "verify grant shrink ========================------"
5297 # bug 1414 - set/get directories' stripe info
5299 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5300 test_mkdir -p $DIR/$tdir
5302 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
5304 run_test 65a "directory with no stripe info ===================="
5307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5308 test_mkdir -p $DIR/$tdir
5309 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5312 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
5314 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
5317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5318 if [[ $OSTCOUNT -gt 1 ]]; then
5319 test_mkdir -p $DIR/$tdir
5320 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
5321 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
5323 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
5326 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
5329 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5330 test_mkdir -p $DIR/$tdir
5331 if [[ $STRIPECOUNT -le 0 ]]; then
5333 elif [[ $STRIPECOUNT -gt 2000 ]]; then
5334 #LOV_MAX_STRIPE_COUNT is 2000
5335 [[ $OSTCOUNT -gt 2000 ]] && sc=2000 || sc=$(($OSTCOUNT - 1))
5337 sc=$(($STRIPECOUNT - 1))
5339 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
5340 touch $DIR/$tdir/f4 $DIR/$tdir/f5
5341 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
5342 error "lverify failed"
5344 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
5347 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5348 test_mkdir -p $DIR/$tdir
5350 $SETSTRIPE $DIR/$tdir || error "setstripe"
5351 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5352 error "no stripe info failed"
5354 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
5356 run_test 65e "directory setstripe defaults ======================="
5359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5360 test_mkdir -p $DIR/${tdir}f
5361 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
5363 run_test 65f "dir setstripe permission (should return error) ==="
5366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5367 test_mkdir -p $DIR/$tdir
5368 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5370 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
5371 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
5372 error "delete default stripe failed"
5374 run_test 65g "directory setstripe -d ==========================="
5377 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5378 test_mkdir -p $DIR/$tdir
5379 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
5381 test_mkdir -p $DIR/$tdir/dd1
5382 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
5383 error "stripe info inherit failed"
5385 run_test 65h "directory stripe info inherit ===================="
5387 test_65i() { # bug6367
5388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5389 $SETSTRIPE -S 65536 -c -1 $MOUNT
5391 run_test 65i "set non-default striping on root directory (bug 6367)="
5393 test_65ia() { # bug12836
5394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5395 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
5397 run_test 65ia "getstripe on -1 default directory striping"
5399 test_65ib() { # bug12836
5400 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5401 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5403 run_test 65ib "getstripe -v on -1 default directory striping"
5405 test_65ic() { # bug12836
5406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5407 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5409 run_test 65ic "new find on -1 default directory striping"
5411 test_65j() { # bug6367
5412 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5414 # if we aren't already remounting for each test, do so for this test
5415 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5416 cleanup || error "failed to unmount"
5419 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5421 run_test 65j "set default striping on root directory (bug 6367)="
5423 test_65k() { # bug11679
5424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5425 [[ $OSTCOUNT -lt 2 ]] && skip_env "too few OSTs" && return
5426 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5428 echo "Check OST status: "
5429 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5430 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5432 for OSC in $MDS_OSCS; do
5433 echo $OSC "is activate"
5434 do_facet $SINGLEMDS lctl --device %$OSC activate
5438 for INACTIVE_OSC in $MDS_OSCS; do
5439 echo "Deactivate: " $INACTIVE_OSC
5440 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5441 for STRIPE_OSC in $MDS_OSCS; do
5442 OST=`osc_to_ost $STRIPE_OSC`
5443 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5444 awk -F: /$OST/'{ print $1 }' | head -n 1`
5446 [ -f $DIR/$tdir/$IDX ] && continue
5447 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5448 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5450 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5453 echo $INACTIVE_OSC "is Activate."
5454 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5457 run_test 65k "validate manual striping works properly with deactivated OSCs"
5459 test_65l() { # bug 12836
5460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5461 test_mkdir -p $DIR/$tdir/test_dir
5462 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5463 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5465 run_test 65l "lfs find on -1 stripe dir ========================"
5467 # bug 2543 - update blocks count on client
5469 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5471 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5472 sync; sync_all_data; sync; sync_all_data
5473 cancel_lru_locks osc
5474 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5475 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5477 run_test 66 "update inode blocks count on client ==============="
5482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5484 if [ ! -z "$LLOOP" ]; then
5485 if swapon -s | grep -q $LLOOP; then
5486 swapoff $LLOOP || error "swapoff failed"
5489 $LCTL blockdev_detach $LLOOP || error "detach failed"
5493 if [ ! -z "$LLITELOOPLOAD" ]; then
5501 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5505 swapon -s | awk '($1 == "'$1'") { print $4 }'
5508 # test case for lloop driver, basic function
5510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5511 [ "$UID" != 0 ] && skip_env "must run as root" && return
5512 llite_lloop_enabled || \
5513 { skip_env "llite_lloop module disabled" && return; }
5515 trap cleanup_68 EXIT
5517 if ! module_loaded llite_lloop; then
5518 if load_module llite/llite_lloop; then
5521 skip_env "can't find module llite_lloop"
5526 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5527 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5528 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5530 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5531 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5535 run_test 68a "lloop driver - basic test ========================"
5537 # excercise swapping to lustre by adding a high priority swapfile entry
5538 # and then consuming memory until it is used.
5539 test_68b() { # was test_68
5540 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5541 [ "$UID" != 0 ] && skip_env "must run as root" && return
5542 lctl get_param -n devices | grep -q obdfilter && \
5543 skip "local OST" && return
5545 grep -q llite_lloop /proc/modules
5546 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5548 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5549 skip "can't reliably test swap with TCP" && return
5551 MEMTOTAL=`meminfo MemTotal`
5552 NR_BLOCKS=$((MEMTOTAL>>8))
5553 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5555 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5556 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5559 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5561 trap cleanup_68 EXIT
5563 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5565 echo "before: `swapon -s | grep $LLOOP`"
5566 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5567 echo "after: `swapon -s | grep $LLOOP`"
5568 SWAPUSED=`swap_used $LLOOP`
5572 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5574 run_test 68b "support swapping to Lustre ========================"
5576 # bug5265, obdfilter oa2dentry return -ENOENT
5577 # #define OBD_FAIL_OST_ENOENT 0x217
5579 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5580 remote_ost_nodsh && skip "remote OST with nodsh" && return
5583 $SETSTRIPE -c 1 -i 0 $f
5585 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5587 do_facet ost1 lctl set_param fail_loc=0x217
5588 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5589 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5591 do_facet ost1 lctl set_param fail_loc=0
5592 $DIRECTIO write $f 0 2 || error "write error"
5594 cancel_lru_locks osc
5595 $DIRECTIO read $f 0 1 || error "read error"
5597 do_facet ost1 lctl set_param fail_loc=0x217
5598 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5600 do_facet ost1 lctl set_param fail_loc=0
5603 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5606 test_mkdir -p $DIR/$tdir
5607 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5609 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5611 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5612 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5613 [ "$RUNAS_ID" = "$UID" ] &&
5614 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5616 # Check that testing environment is properly set up. Skip if not
5617 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5618 skip_env "User $RUNAS_ID does not exist - skipping"
5622 chmod 777 $DIR/$tfile
5623 chmod ug+s $DIR/$tfile
5624 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5625 error "$RUNAS dd $DIR/$tfile failed"
5626 # See if we are still setuid/sgid
5627 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5628 error "S/gid is not dropped on write"
5629 # Now test that MDS is updated too
5630 cancel_lru_locks mdc
5631 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5632 error "S/gid is not dropped on MDS"
5635 run_test 72a "Test that remove suid works properly (bug5695) ===="
5637 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5640 [ "$RUNAS_ID" = "$UID" ] && \
5641 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5642 [ "$RUNAS_ID" -eq 0 ] && \
5643 skip_env "RUNAS_ID = 0 -- skipping" && return
5645 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5646 # Check that testing environment is properly set up. Skip if not
5647 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5648 skip_env "User $RUNAS_ID does not exist - skipping"
5651 touch $DIR/${tfile}-f{g,u}
5652 test_mkdir $DIR/${tfile}-dg
5653 test_mkdir $DIR/${tfile}-du
5654 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5655 chmod g+s $DIR/${tfile}-{f,d}g
5656 chmod u+s $DIR/${tfile}-{f,d}u
5657 for perm in 777 2777 4777; do
5658 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5659 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5660 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5661 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5665 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5667 # bug 3462 - multiple simultaneous MDC requests
5669 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5670 test_mkdir $DIR/d73-1
5671 test_mkdir $DIR/d73-2
5672 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5675 lctl set_param fail_loc=0x80000129
5676 $MULTIOP $DIR/d73-1/f73-2 Oc &
5678 lctl set_param fail_loc=0
5680 $MULTIOP $DIR/d73-2/f73-3 Oc &
5684 wait $pid1 || return 1
5688 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5689 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5690 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5694 run_test 73 "multiple MDC requests (should not deadlock)"
5696 test_74a() { # bug 6149, 6184
5697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5698 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5700 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5701 # will spin in a tight reconnection loop
5703 $LCTL set_param fail_loc=0x8000030e
5704 # get any lock that won't be difficult - lookup works.
5706 $LCTL set_param fail_loc=0
5710 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5712 test_74b() { # bug 13310
5713 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5714 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5716 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5717 # will spin in a tight reconnection loop
5718 $LCTL set_param fail_loc=0x8000030e
5719 # get a "difficult" lock
5721 $LCTL set_param fail_loc=0
5725 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5728 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5729 #define OBD_FAIL_LDLM_NEW_LOCK
5730 $LCTL set_param fail_loc=0x319
5731 touch $DIR/$tfile && error "touch successful"
5732 $LCTL set_param fail_loc=0
5735 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5738 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5741 get_inode_slab_tunables() {
5742 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5745 set_inode_slab_tunables() {
5746 echo "lustre_inode_cache $1" > /proc/slabinfo
5749 test_76() { # Now for bug 20433, added originally in bug 1443
5750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5751 local SLAB_SETTINGS=`get_inode_slab_tunables`
5752 local CPUS=`getconf _NPROCESSORS_ONLN`
5753 # we cannot set limit below 1 which means 1 inode in each
5754 # per-cpu cache is still allowed
5755 set_inode_slab_tunables "1 1 0"
5756 cancel_lru_locks osc
5757 BEFORE_INODES=$(num_inodes)
5758 echo "before inodes: $BEFORE_INODES"
5760 [ "$SLOW" = "no" ] && COUNT=100
5761 for i in $(seq $COUNT); do
5765 cancel_lru_locks osc
5766 AFTER_INODES=$(num_inodes)
5767 echo "after inodes: $AFTER_INODES"
5769 while [[ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]]; do
5771 AFTER_INODES=$(num_inodes)
5773 echo "wait $wait seconds inodes: $AFTER_INODES"
5774 if [ $wait -gt 30 ]; then
5775 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5778 set_inode_slab_tunables "$SLAB_SETTINGS"
5780 run_test 76 "confirm clients recycle inodes properly ===="
5786 # Note: in sptlrpc modes which enable its own bulk checksum, the
5787 # original crc32_le bulk checksum will be automatically disabled,
5788 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5789 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5790 # In this case set_checksums() will not be no-op, because sptlrpc
5791 # bulk checksum will be enabled all through the test.
5793 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5794 lctl set_param -n osc.*.checksums $1
5798 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5799 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5800 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5801 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5804 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5805 log "set checksum type to $1"
5808 F77_TMP=$TMP/f77-temp
5811 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5812 error "error writing to $F77_TMP"
5815 test_77a() { # bug 10889
5816 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5817 $GSS && skip "could not run with gss" && return
5818 [ ! -f $F77_TMP ] && setup_f77
5820 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5824 run_test 77a "normal checksum read/write operation"
5826 test_77b() { # bug 10889
5827 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5828 $GSS && skip "could not run with gss" && return
5829 [ ! -f $F77_TMP ] && setup_f77
5830 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5831 $LCTL set_param fail_loc=0x80000409
5834 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5835 error "dd error: $?"
5836 $LCTL set_param fail_loc=0
5838 for algo in $CKSUM_TYPES; do
5839 cancel_lru_locks osc
5840 set_checksum_type $algo
5841 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5842 $LCTL set_param fail_loc=0x80000408
5843 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5844 $LCTL set_param fail_loc=0
5847 set_checksum_type $ORIG_CSUM_TYPE
5850 run_test 77b "checksum error on client write, read"
5852 test_77d() { # bug 10889
5853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5854 $GSS && skip "could not run with gss" && return
5855 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5856 $LCTL set_param fail_loc=0x80000409
5858 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5859 error "direct write: rc=$?"
5860 $LCTL set_param fail_loc=0
5863 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5864 $LCTL set_param fail_loc=0x80000408
5866 cancel_lru_locks osc
5867 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5868 error "direct read: rc=$?"
5869 $LCTL set_param fail_loc=0
5872 run_test 77d "checksum error on OST direct write, read"
5874 test_77f() { # bug 10889
5875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5876 $GSS && skip "could not run with gss" && return
5878 for algo in $CKSUM_TYPES; do
5879 cancel_lru_locks osc
5880 set_checksum_type $algo
5881 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5882 $LCTL set_param fail_loc=0x409
5883 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5884 error "direct write succeeded"
5885 $LCTL set_param fail_loc=0
5887 set_checksum_type $ORIG_CSUM_TYPE
5890 run_test 77f "repeat checksum error on write (expect error)"
5892 test_77g() { # bug 10889
5893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5894 $GSS && skip "could not run with gss" && return
5895 remote_ost_nodsh && skip "remote OST with nodsh" && return
5897 [ ! -f $F77_TMP ] && setup_f77
5899 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5900 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5901 do_facet ost1 lctl set_param fail_loc=0x8000021a
5903 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5904 error "write error: rc=$?"
5905 do_facet ost1 lctl set_param fail_loc=0
5908 cancel_lru_locks osc
5909 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5910 do_facet ost1 lctl set_param fail_loc=0x8000021b
5912 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5913 do_facet ost1 lctl set_param fail_loc=0
5916 run_test 77g "checksum error on OST write, read"
5918 test_77i() { # bug 13805
5919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5920 $GSS && skip "could not run with gss" && return
5921 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5922 lctl set_param fail_loc=0x40b
5923 remount_client $MOUNT
5924 lctl set_param fail_loc=0
5925 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5926 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5927 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5928 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5930 remount_client $MOUNT
5932 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5934 test_77j() { # bug 13805
5935 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5936 $GSS && skip "could not run with gss" && return
5937 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5938 lctl set_param fail_loc=0x40c
5939 remount_client $MOUNT
5940 lctl set_param fail_loc=0
5941 sleep 2 # wait async osc connect to finish
5942 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5943 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5944 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5945 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5947 remount_client $MOUNT
5949 run_test 77j "client only supporting ADLER32"
5951 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5955 test_78() { # bug 10901
5956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5957 remote_ost || { skip_env "local OST" && return; }
5960 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5961 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5962 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5963 echo "MemTotal: $MEMTOTAL"
5965 # reserve 256MB of memory for the kernel and other running processes,
5966 # and then take 1/2 of the remaining memory for the read/write buffers.
5967 if [ $MEMTOTAL -gt 512 ] ;then
5968 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5970 # for those poor memory-starved high-end clusters...
5971 MEMTOTAL=$((MEMTOTAL / 2))
5973 echo "Mem to use for directio: $MEMTOTAL"
5975 [[ $F78SIZE -gt $MEMTOTAL ]] && F78SIZE=$MEMTOTAL
5976 [[ $F78SIZE -gt 512 ]] && F78SIZE=512
5977 [[ $F78SIZE -gt $((MAXFREE / 1024)) ]] && F78SIZE=$((MAXFREE / 1024))
5978 SMALLESTOST=$($LFS df $DIR | grep OST | awk '{ print $4 }' | sort -n |
5980 echo "Smallest OST: $SMALLESTOST"
5981 [[ $SMALLESTOST -lt 10240 ]] &&
5982 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5984 [[ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ]] &&
5985 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5987 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5988 echo "File size: $F78SIZE"
5989 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5990 for i in $(seq 1 $NSEQ); do
5991 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5992 echo directIO rdwr round $i of $NSEQ
5993 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5998 run_test 78 "handle large O_DIRECT writes correctly ============"
6000 test_79() { # bug 12743
6001 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6002 wait_delete_completed
6004 BKTOTAL=$(calc_osc_kbytes kbytestotal)
6005 BKFREE=$(calc_osc_kbytes kbytesfree)
6006 BKAVAIL=$(calc_osc_kbytes kbytesavail)
6008 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
6009 DFTOTAL=`echo $STRING | cut -d, -f1`
6010 DFUSED=`echo $STRING | cut -d, -f2`
6011 DFAVAIL=`echo $STRING | cut -d, -f3`
6012 DFFREE=$(($DFTOTAL - $DFUSED))
6014 ALLOWANCE=$((64 * $OSTCOUNT))
6016 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
6017 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
6018 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
6020 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
6021 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
6022 error "df free($DFFREE) mismatch OST free($BKFREE)"
6024 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
6025 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
6026 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
6029 run_test 79 "df report consistency check ======================="
6031 test_80() { # bug 10718
6032 remote_ost_nodsh && skip "remote OST with nodsh" && return
6033 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6034 # relax strong synchronous semantics for slow backends like ZFS
6035 local soc="obdfilter.*.sync_on_lock_cancel"
6036 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
6038 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
6039 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
6040 facet_active_host $host; done | sort -u)
6041 do_nodes $hosts lctl set_param $soc=never
6044 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
6046 local BEFORE=`date +%s`
6047 cancel_lru_locks osc
6048 local AFTER=`date +%s`
6049 local DIFF=$((AFTER-BEFORE))
6050 if [ $DIFF -gt 1 ] ; then
6051 error "elapsed for 1M@1T = $DIFF"
6054 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
6058 run_test 80 "Page eviction is equally fast at high offsets too ===="
6060 test_81a() { # LU-456
6061 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6062 remote_ost_nodsh && skip "remote OST with nodsh" && return
6063 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6064 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
6065 do_facet ost1 lctl set_param fail_loc=0x80000228
6067 # write should trigger a retry and success
6068 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6069 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6071 if [ $RC -ne 0 ] ; then
6072 error "write should success, but failed for $RC"
6075 run_test 81a "OST should retry write when get -ENOSPC ==============="
6077 test_81b() { # LU-456
6078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6079 remote_ost_nodsh && skip "remote OST with nodsh" && return
6080 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
6081 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
6082 do_facet ost1 lctl set_param fail_loc=0x228
6084 # write should retry several times and return -ENOSPC finally
6085 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
6086 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6089 if [ $RC -ne $ENOSPC ] ; then
6090 error "dd should fail for -ENOSPC, but succeed."
6093 run_test 81b "OST should return -ENOSPC when retry still fails ======="
6095 test_82() { # LU-1031
6096 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
6100 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
6102 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
6104 kill -USR1 $MULTIPID2
6106 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
6107 error "First grouplock does not block second one"
6109 echo "Second grouplock blocks first one"
6111 kill -USR1 $MULTIPID1
6115 run_test 82 "Basic grouplock test ==============================="
6118 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
6120 test_mkdir -p $DIR/d99cvsroot
6121 chown $RUNAS_ID $DIR/d99cvsroot
6122 local oldPWD=$PWD # bug 13584, use $TMP as working dir
6125 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
6128 run_test 99a "cvs init ========================================="
6131 [ -z "$(which cvs 2>/dev/null)" ] &&
6132 skip_env "could not find cvs" && return
6133 [ ! -d $DIR/d99cvsroot ] && test_99a
6135 # some versions of cvs import exit(1) when asked to import links or
6136 # files they can't read. ignore those files.
6137 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
6138 ! -perm +4 -printf '-I %f\n')
6139 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
6140 d99reposname vtag rtag
6142 run_test 99b "cvs import ======================================="
6145 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6146 [ ! -d $DIR/d99cvsroot ] && test_99b
6148 test_mkdir -p $DIR/d99reposname
6149 chown $RUNAS_ID $DIR/d99reposname
6150 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
6152 run_test 99c "cvs checkout ====================================="
6155 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6156 [ ! -d $DIR/d99cvsroot ] && test_99c
6157 cd $DIR/d99reposname
6159 $RUNAS cvs add -m 'addmsg' foo99
6161 run_test 99d "cvs add =========================================="
6164 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6165 [ ! -d $DIR/d99cvsroot ] && test_99c
6166 cd $DIR/d99reposname
6169 run_test 99e "cvs update ======================================="
6172 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
6173 [ ! -d $DIR/d99cvsroot ] && test_99d
6174 cd $DIR/d99reposname
6175 $RUNAS cvs commit -m 'nomsg' foo99
6176 rm -fr $DIR/d99cvsroot
6178 run_test 99f "cvs commit ======================================="
6181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6182 [ "$NETTYPE" = tcp ] || \
6183 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
6186 remote_ost_nodsh && skip "remote OST with nodsh" && return
6187 remote_mds_nodsh && skip "remote MDS with nodsh" && return
6189 { skip "useless for local single node setup" && return; }
6191 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
6192 [ "$PROT" != "tcp" ] && continue
6193 RPORT=$(echo $REMOTE | cut -d: -f2)
6194 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
6197 LPORT=`echo $LOCAL | cut -d: -f2`
6198 if [ $LPORT -ge 1024 ]; then
6199 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
6201 error_exit "local: $LPORT > 1024, remote: $RPORT"
6204 [ "$rc" = 0 ] || error_exit "privileged port not found" )
6206 run_test 100 "check local port using privileged port ==========="
6208 function get_named_value()
6217 echo $line | sed "s/^$tag[ ]*//"
6224 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
6225 awk '/^max_cached_mb/ { print $2 }')
6228 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
6233 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6234 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
6238 local cache_limit=32
6240 $LCTL set_param -n osc.*-osc*.rpc_stats 0
6241 trap cleanup_101a EXIT
6242 $LCTL set_param -n llite.*.read_ahead_stats 0
6243 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
6246 # randomly read 10000 of 64K chunks from file 3x 32MB in size
6248 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
6249 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
6252 for s in $($LCTL get_param -n llite.*.read_ahead_stats |
6253 get_named_value 'read but discarded' | cut -d" " -f1); do
6254 discard=$(($discard + $s))
6258 if [[ $(($discard * 10)) -gt $nreads ]]; then
6259 $LCTL get_param osc.*-osc*.rpc_stats
6260 $LCTL get_param llite.*.read_ahead_stats
6261 error "too many ($discard) discarded pages"
6263 rm -f $DIR/$tfile || true
6265 run_test 101a "check read-ahead for random reads ================"
6268 test_mkdir -p $DIR/$tdir
6269 local STRIPE_SIZE=$1
6270 local FILE_LENGTH=$2
6273 local FILE_SIZE_MB=$((FILE_LENGTH / STRIPE_SIZE))
6275 local list=$(comma_list $(osts_nodes))
6276 set_osd_param $list '' read_cache_enable 0
6277 set_osd_param $list '' writethrough_cache_enable 0
6279 trap cleanup_test101bc EXIT
6280 # prepare the read-ahead file
6281 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
6283 dd if=/dev/zero of=$DIR/$tfile bs=$STRIPE_SIZE \
6284 count=$FILE_SIZE_MB 2> /dev/null
6288 cleanup_test101bc() {
6293 local list=$(comma_list $(osts_nodes))
6294 set_osd_param $list '' read_cache_enable 1
6295 set_osd_param $list '' writethrough_cache_enable 1
6299 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
6304 local STRIPE_SIZE=$2
6305 local FILE_LENGTH=$3
6306 local RA_INC=1048576
6307 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
6308 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
6309 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
6310 DISCARD=$($LCTL get_param -n llite.*.read_ahead_stats |
6311 get_named_value 'read but discarded' |
6312 cut -d" " -f1 | calc_total)
6313 if [[ $DISCARD -gt $discard_limit ]]; then
6314 $LCTL get_param llite.*.read_ahead_stats
6315 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
6317 echo "Read-ahead success for size ${READ_SIZE}"
6322 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6323 [[ $OSTCOUNT -lt 2 ]] &&
6324 skip_env "skipping stride IO stride-ahead test" && return
6325 local STRIPE_SIZE=1048576
6326 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
6327 if [ $SLOW == "yes" ]; then
6328 local FILE_LENGTH=$((STRIDE_SIZE * 64))
6330 local FILE_LENGTH=$((STRIDE_SIZE * 8))
6333 local ITERATION=$((FILE_LENGTH / STRIDE_SIZE))
6335 # prepare the read-ahead file
6336 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6337 cancel_lru_locks osc
6338 for BIDX in 2 4 8 16 32 64 128 256
6340 local BSIZE=$((BIDX*4096))
6341 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
6342 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
6343 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
6344 $LCTL set_param -n llite.*.read_ahead_stats 0
6345 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
6346 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
6347 cancel_lru_locks osc
6348 ra_check_101 $BSIZE $STRIPE_SIZE $FILE_LENGTH
6353 run_test 101b "check stride-io mode read-ahead ================="
6356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6357 local STRIPE_SIZE=1048576
6358 local FILE_LENGTH=$((STRIPE_SIZE*100))
6362 setup_test101bc $STRIPE_SIZE $FILE_LENGTH
6364 cancel_lru_locks osc
6365 $LCTL set_param osc.*.rpc_stats 0
6366 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
6367 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
6368 local stats=$($LCTL get_param -n $osc_rpc_stats)
6369 local lines=$(echo "$stats" | awk 'END {print NR;}')
6372 if [ $lines -le 20 ]; then
6375 for size in 1 2 4 8; do
6376 local rpc=$(echo "$stats" |
6377 awk '($1 == "'$size':") {print $2; exit; }')
6379 error "Small $((size*4))k read IO $rpc !"
6381 echo "$osc_rpc_stats check passed!"
6386 run_test 101c "check stripe_size aligned read-ahead ================="
6389 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
6390 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
6394 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6395 local file=$DIR/$tfile
6396 local sz_MB=${FILESIZE_101d:-500}
6397 local ra_MB=${READAHEAD_MB:-40}
6399 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
6400 [ $free_MB -lt $sz_MB ] &&
6401 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
6403 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
6404 $SETSTRIPE -c -1 $file || error "setstripe failed"
6406 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
6407 echo Cancel LRU locks on lustre client to flush the client cache
6408 cancel_lru_locks osc
6410 echo Disable read-ahead
6411 local old_READAHEAD=$(set_read_ahead 0)
6413 echo Reading the test file $file with read-ahead disabled
6414 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6416 echo Cancel LRU locks on lustre client to flush the client cache
6417 cancel_lru_locks osc
6418 echo Enable read-ahead with ${ra_MB}MB
6419 set_read_ahead $ra_MB
6421 echo Reading the test file $file with read-ahead enabled
6422 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6424 echo "read-ahead disabled time read $raOFF"
6425 echo "read-ahead enabled time read $raON"
6427 set_read_ahead $old_READAHEAD
6429 wait_delete_completed
6431 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6432 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6434 run_test 101d "file read with and without read-ahead enabled"
6437 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6438 local file=$DIR/$tfile
6439 local size_KB=500 #KB
6443 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6444 local need_KB=$((count * size_KB))
6445 [[ $free_KB -le $need_KB ]] &&
6446 skip_env "Need free space $need_KB, have $free_KB" && return
6448 echo "Creating $count ${size_KB}K test files"
6449 for ((i = 0; i < $count; i++)); do
6450 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6453 echo "Cancel LRU locks on lustre client to flush the client cache"
6454 cancel_lru_locks osc
6456 echo "Reset readahead stats"
6457 $LCTL set_param -n llite.*.read_ahead_stats 0
6459 for ((i = 0; i < $count; i++)); do
6460 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6463 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6464 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6466 for ((i = 0; i < $count; i++)); do
6467 rm -rf $file.$i 2>/dev/null
6470 #10000 means 20% reads are missing in readahead
6471 [[ $miss -lt 10000 ]] || error "misses too much for small reads"
6473 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6475 cleanup_test101f() {
6477 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6478 rm -rf $DIR/$tfile 2>/dev/null
6482 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6483 local file=$DIR/$tfile
6486 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6487 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6488 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6489 trap cleanup_test101f EXIT
6491 echo Cancel LRU locks on lustre client to flush the client cache
6492 cancel_lru_locks osc
6494 echo Reset readahead stats
6495 $LCTL set_param -n llite.*.read_ahead_stats 0
6496 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6497 # readahead should read in 2M file on second read, so only miss
6499 echo Random 4K reads on 2M file for 1000 times
6500 $READS -f $file -s 2097152 -b 4096 -n $nreads
6502 echo checking missing pages
6503 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6504 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6506 [ $miss -lt 3 ] || error "misses too much pages!"
6509 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6512 test_mkdir -p $DIR/$tdir
6513 chown $RUNAS_ID $DIR/$tdir
6516 STRIPE_COUNT=$OSTCOUNT
6517 [[ $OSTCOUNT -gt 4 ]] && STRIPE_COUNT=4
6519 trap cleanup_test102 EXIT
6521 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6523 for num in 1 2 3 4; do
6524 for count in $(seq 1 $STRIPE_COUNT); do
6525 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6526 local size=`expr $STRIPE_SIZE \* $num`
6527 local file=file"$num-$idx-$count"
6528 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6534 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6540 rm -rf $DIR/d0.sanity/d102
6544 local testfile=$DIR/$tfile
6548 [ "$UID" != 0 ] && skip_env "must run as root" && return
6549 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6550 skip_env "must have user_xattr" && return
6552 [ -z "$(which setfattr 2>/dev/null)" ] &&
6553 skip_env "could not find setfattr" && return
6555 echo "set/get xattr..."
6556 setfattr -n trusted.name1 -v value1 $testfile ||
6557 error "setfattr -n trusted.name1=value1 $testfile failed"
6558 getfattr -n trusted.name1 $testfile 2> /dev/null |
6559 grep "trusted.name1=.value1" ||
6560 error "$testfile missing trusted.name1=value1"
6562 setfattr -n user.author1 -v author1 $testfile ||
6563 error "setfattr -n user.author1=author1 $testfile failed"
6564 getfattr -n user.author1 $testfile 2> /dev/null |
6565 grep "user.author1=.author1" ||
6566 error "$testfile missing trusted.author1=author1"
6569 setfattr -n trusted.name2 -v value2 $testfile ||
6570 error "$testfile unable to set trusted.name2"
6571 setfattr -n trusted.name3 -v value3 $testfile ||
6572 error "$testfile unable to set trusted.name3"
6573 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6574 grep "trusted.name" | wc -l) -eq 3 ] ||
6575 error "$testfile missing 3 trusted.name xattrs"
6577 setfattr -n user.author2 -v author2 $testfile ||
6578 error "$testfile unable to set user.author2"
6579 setfattr -n user.author3 -v author3 $testfile ||
6580 error "$testfile unable to set user.author3"
6581 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6582 grep "user.author" | wc -l) -eq 3 ] ||
6583 error "$testfile missing 3 user.author xattrs"
6585 echo "remove xattr..."
6586 setfattr -x trusted.name1 $testfile ||
6587 error "$testfile error deleting trusted.name1"
6588 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6589 error "$testfile did not delete trusted.name1 xattr"
6591 setfattr -x user.author1 $testfile ||
6592 error "$testfile error deleting user.author1"
6593 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6594 error "$testfile did not delete trusted.name1 xattr"
6596 # b10667: setting lustre special xattr be silently discarded
6597 echo "set lustre special xattr ..."
6598 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6599 error "$testfile allowed setting trusted.lov"
6601 run_test 102a "user xattr test =================================="
6604 [ -z "$(which setfattr 2>/dev/null)" ] &&
6605 skip_env "could not find setfattr" && return
6607 # b10930: get/set/list trusted.lov xattr
6608 echo "get/set/list trusted.lov xattr ..."
6609 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6610 local testfile=$DIR/$tfile
6611 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6612 error "setstripe failed"
6613 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6614 error "getstripe failed"
6615 getfattr -d -m "^trusted" $testfile 2>/dev/null | grep "trusted.lov" ||
6616 error "can't get trusted.lov from $testfile"
6618 local testfile2=${testfile}2
6619 local value=$(getfattr -n trusted.lov $testfile 2>/dev/null |
6620 grep "trusted.lov" | sed -e 's/[^=]\+=//')
6623 setfattr -n trusted.lov -v $value $testfile2
6624 local stripe_size=$($GETSTRIPE -S $testfile2)
6625 local stripe_count=$($GETSTRIPE -c $testfile2)
6626 [[ $stripe_size -eq 65536 ]] ||
6627 error "stripe size $stripe_size != 65536"
6628 [[ $stripe_count -eq $STRIPECOUNT ]] ||
6629 error "stripe count $stripe_count != $STRIPECOUNT"
6632 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6635 [ -z "$(which setfattr 2>/dev/null)" ] &&
6636 skip_env "could not find setfattr" && return
6638 # b10930: get/set/list lustre.lov xattr
6639 echo "get/set/list lustre.lov xattr ..."
6640 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping 2-stripe test" && return
6641 test_mkdir -p $DIR/$tdir
6642 chown $RUNAS_ID $DIR/$tdir
6643 local testfile=$DIR/$tdir/$tfile
6644 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6645 error "setstripe failed"
6646 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6647 error "getstripe failed"
6648 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6649 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6651 local testfile2=${testfile}2
6652 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6653 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6655 $RUNAS $MCREATE $testfile2
6656 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6657 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6658 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6659 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6660 [ $stripe_count -eq $STRIPECOUNT ] ||
6661 error "stripe count $stripe_count != $STRIPECOUNT"
6663 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6665 compare_stripe_info1() {
6666 local stripe_index_all_zero=true
6668 for num in 1 2 3 4; do
6669 for count in $(seq 1 $STRIPE_COUNT); do
6670 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6671 local size=$((STRIPE_SIZE * num))
6672 local file=file"$num-$offset-$count"
6673 stripe_size=$($LFS getstripe -S $PWD/$file)
6674 [[ $stripe_size -ne $size ]] &&
6675 error "$file: size $stripe_size != $size"
6676 stripe_count=$($LFS getstripe -c $PWD/$file)
6677 # allow fewer stripes to be created, ORI-601
6678 [[ $stripe_count -lt $(((3 * count + 3) / 4)) ]] &&
6679 error "$file: count $stripe_count != $count"
6680 stripe_index=$($LFS getstripe -i $PWD/$file)
6681 [[ $stripe_index -ne 0 ]] &&
6682 stripe_index_all_zero=false
6686 $stripe_index_all_zero &&
6687 error "all files are being extracted starting from OST index 0"
6692 [ -n "$(which tar 2>/dev/null)" ] &&
6693 strings $(which tar) | grep -q "lustre" && echo tar
6697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6698 # b10930: tar test for trusted.lov xattr
6699 TAR=$(find_lustre_tar)
6700 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6701 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6703 test_mkdir -p $DIR/d102d
6704 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6706 compare_stripe_info1
6708 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6711 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6712 # b10930: tar test for trusted.lov xattr
6713 TAR=$(find_lustre_tar)
6714 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6715 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6717 test_mkdir -p $DIR/d102f
6719 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6721 compare_stripe_info1
6723 run_test 102f "tar copy files, not keep osts ==========="
6726 local xsize=${1:-1024} # in bytes
6727 local file=$DIR/$tfile
6729 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6730 skip "must have user_xattr" && return 0
6731 [ -z "$(which setfattr 2>/dev/null)" ] &&
6732 skip_env "could not find setfattr" && return 0
6733 [ -z "$(which getfattr 2>/dev/null)" ] &&
6734 skip_env "could not find getfattr" && return 0
6738 local value="$(generate_string $xsize)"
6740 local xbig=trusted.big
6741 log "save $xbig on $file"
6742 setfattr -n $xbig -v $value $file ||
6743 error "saving $xbig on $file failed"
6745 local orig=$(get_xattr_value $xbig $file)
6746 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6748 local xsml=trusted.sml
6749 log "save $xsml on $file"
6750 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6752 local new=$(get_xattr_value $xbig $file)
6753 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6755 log "grow $xsml on $file"
6756 setfattr -n $xsml -v "$value" $file ||
6757 error "growing $xsml on $file failed"
6759 new=$(get_xattr_value $xbig $file)
6760 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6761 log "$xbig still valid after growing $xsml"
6766 test_102h() { # bug 15777
6769 run_test 102h "grow xattr from inside inode to external block"
6772 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6773 grow_xattr $(max_xattr_size)
6775 run_test 102ha "grow xattr from inside inode to external inode"
6777 test_102i() { # bug 17038
6778 [ -z "$(which getfattr 2>/dev/null)" ] &&
6779 skip "could not find getfattr" && return
6781 ln -s $DIR/$tfile $DIR/${tfile}link
6782 getfattr -n trusted.lov $DIR/$tfile ||
6783 error "lgetxattr on $DIR/$tfile failed"
6784 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 |
6785 grep -i "no such attr" ||
6786 error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6787 rm -f $DIR/$tfile $DIR/${tfile}link
6789 run_test 102i "lgetxattr test on symbolic link ============"
6792 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6793 TAR=$(find_lustre_tar)
6794 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6795 [[ $OSTCOUNT -lt 2 ]] && skip_env "skipping N-stripe test" && return
6796 setup_test102 "$RUNAS"
6797 test_mkdir -p $DIR/d102j
6798 chown $RUNAS_ID $DIR/d102j
6799 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6801 compare_stripe_info1 "$RUNAS"
6803 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6806 [ -z "$(which setfattr 2>/dev/null)" ] &&
6807 skip "could not find setfattr" && return
6809 # b22187 just check that does not crash for regular file.
6810 setfattr -n trusted.lov $DIR/$tfile
6811 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6812 local test_kdir=$DIR/d102k
6813 test_mkdir $test_kdir
6814 local default_size=`$GETSTRIPE -S $test_kdir`
6815 local default_count=`$GETSTRIPE -c $test_kdir`
6816 local default_offset=`$GETSTRIPE -i $test_kdir`
6817 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6818 error 'dir setstripe failed'
6819 setfattr -n trusted.lov $test_kdir
6820 local stripe_size=`$GETSTRIPE -S $test_kdir`
6821 local stripe_count=`$GETSTRIPE -c $test_kdir`
6822 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6823 [ $stripe_size -eq $default_size ] ||
6824 error "stripe size $stripe_size != $default_size"
6825 [ $stripe_count -eq $default_count ] ||
6826 error "stripe count $stripe_count != $default_count"
6827 [ $stripe_offset -eq $default_offset ] ||
6828 error "stripe offset $stripe_offset != $default_offset"
6829 rm -rf $DIR/$tfile $test_kdir
6831 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6834 [ -z "$(which getfattr 2>/dev/null)" ] &&
6835 skip "could not find getfattr" && return
6837 # LU-532 trusted. xattr is invisible to non-root
6838 local testfile=$DIR/$tfile
6842 echo "listxattr as user..."
6843 chown $RUNAS_ID $testfile
6844 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6845 grep -q "trusted" &&
6846 error "$testfile trusted xattrs are user visible"
6850 run_test 102l "listxattr size test =================================="
6852 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6853 local path=$DIR/$tfile
6856 listxattr_size_check $path || error "listattr_size_check $path failed"
6858 run_test 102m "Ensure listxattr fails on small bufffer ========"
6862 getxattr() { # getxattr path name
6863 # Return the base64 encoding of the value of xattr name on path.
6867 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6869 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6871 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6873 getfattr --absolute-names --encoding=base64 --name=$name $path |
6874 awk -F= -v name=$name '$1 == name {
6875 print substr($0, index($0, "=") + 1);
6879 test_102n() { # LU-4101 mdt: protect internal xattrs
6880 local file0=$DIR/$tfile.0
6881 local file1=$DIR/$tfile.1
6882 local xattr0=$TMP/$tfile.0
6883 local xattr1=$TMP/$tfile.1
6887 [ -z "$(which setfattr 2>/dev/null)" ] &&
6888 skip "could not find setfattr" && return
6890 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6892 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6896 rm -rf $file0 $file1 $xattr0 $xattr1
6899 # Get 'before' xattrs of $file1.
6900 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6902 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6903 # Try to copy xattr from $file0 to $file1.
6904 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6906 setfattr --name=trusted.$name --value="$value" $file1 ||
6907 error "setxattr 'trusted.$name' failed"
6909 # Try to set a garbage xattr.
6910 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6912 setfattr --name=trusted.$name --value="$value" $file1 ||
6913 error "setxattr 'trusted.$name' failed"
6915 # Try to remove the xattr from $file1. We don't care if this
6916 # appears to succeed or fail, we just don't want there to be
6917 # any changes or crashes.
6918 setfattr --remove=$trusted.$name $file1 2> /dev/null
6921 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.6.50) ]
6924 # Try to copy xattr from $file0 to $file1.
6925 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6927 setfattr --name=trusted.$name --value="$value" $file1 ||
6928 error "setxattr 'trusted.$name' failed"
6930 # Try to set a garbage xattr.
6931 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6933 setfattr --name=trusted.$name --value="$value" $file1 ||
6934 error "setxattr 'trusted.$name' failed"
6936 # Try to remove the xattr from $file1. We don't care if this
6937 # appears to succeed or fail, we just don't want there to be
6938 # any changes or crashes.
6939 setfattr --remove=$trusted.$name $file1 2> /dev/null
6942 # Get 'after' xattrs of file1.
6943 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6945 if ! diff $xattr0 $xattr1; then
6946 error "before and after xattrs of '$file1' differ"
6949 rm -rf $file0 $file1 $xattr0 $xattr1
6953 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6955 test_102p() { # LU-4703 setxattr did not check ownership
6956 local testfile=$DIR/$tfile
6958 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
6959 skip "MDS needs to be at least 2.5.56" && return
6963 echo "setfacl as user..."
6964 $RUNAS setfacl -m "u:$RUNAS_ID:rwx" $testfile
6965 [ $? -ne 0 ] || error "setfacl by $RUNAS_ID was allowed on $testfile"
6967 echo "setfattr as user..."
6968 setfacl -m "u:$RUNAS_ID:---" $testfile
6969 $RUNAS setfattr -x system.posix_acl_access $testfile
6970 [ $? -ne 0 ] || error "setfattr by $RUNAS_ID was allowed on $testfile"
6972 run_test 102p "check setxattr(2) correctly fails without permission"
6975 orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
6977 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
6980 touch $DIR/$tfile || error "touch"
6981 setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
6982 getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
6983 rm $DIR/$tfile || error "rm"
6985 run_test 102r "set EAs with empty values"
6989 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6994 [ "$UID" != 0 ] && skip_env "must run as root" && return
6995 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6996 skip "must have acl enabled" && return
6997 [ -z "$(which setfacl 2>/dev/null)" ] &&
6998 skip_env "could not find setfacl" && return
6999 $GSS && skip "could not run under gss" && return
7001 gpasswd -a daemon bin # LU-5641
7002 do_facet $SINGLEMDS gpasswd -a daemon bin # LU-5641
7004 declare -a identity_old
7006 for num in $(seq $MDSCOUNT); do
7007 switch_identity $num true || identity_old[$num]=$?
7014 echo "performing cp ..."
7015 run_acl_subtest cp || error "run_acl_subtest cp failed"
7016 echo "performing getfacl-noacl..."
7017 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
7018 echo "performing misc..."
7019 run_acl_subtest misc || error "misc test failed"
7020 echo "performing permissions..."
7021 run_acl_subtest permissions || error "permissions failed"
7022 echo "performing setfacl..."
7023 run_acl_subtest setfacl || error "setfacl test failed"
7025 # inheritance test got from HP
7026 echo "performing inheritance..."
7027 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
7028 chmod +x make-tree || error "chmod +x failed"
7029 run_acl_subtest inheritance || error "inheritance test failed"
7032 echo "LU-974 ignore umask when acl is enabled..."
7033 run_acl_subtest 974 || error "LU-974 umask test failed"
7034 if [ $MDSCOUNT -ge 2 ]; then
7035 run_acl_subtest 974_remote ||
7036 error "LU-974 umask test failed under remote dir"
7039 echo "LU-2561 newly created file is same size as directory..."
7040 if [ $(facet_fstype $SINGLEMDS) != "zfs" ]; then
7041 run_acl_subtest 2561 || error "LU-2561 test failed"
7043 run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
7046 run_acl_subtest 4924 || error "LU-4924 test failed"
7051 for num in $(seq $MDSCOUNT); do
7052 if [ "${identity_old[$num]}" = 1 ]; then
7053 switch_identity $num false || identity_old[$num]=$?
7057 run_test 103a "acl test ========================================="
7061 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7062 local mountopts=$MDS_MOUNT_OPTS
7064 if [[ "$MDS_MOUNT_OPTS" =~ "noacl" ]]; then
7068 stop $SINGLEMDS || error "failed to stop MDT."
7070 if [ -z "$MDS_MOUNT_OPTS" ]; then
7071 MDS_MOUNT_OPTS="-o noacl"
7073 MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
7075 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7076 error "failed to start MDT."
7077 MDS_MOUNT_OPTS=$mountopts
7081 setfacl -m u:bin:rw $DIR/$tfile && error "setfacl should fail"
7085 stop $SINGLEMDS || error "failed to stop MDT."
7087 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS ||
7088 error "failed to start MDT."
7093 run_test 103b "MDS mount option 'noacl'"
7097 cp -rp $DIR/$tdir $DIR/$tdir.bak
7099 [ -n "$(getfattr -d -m. $DIR/$tdir | grep posix_acl_default)" ] &&
7100 error "$DIR/$tdir shouldn't contain default ACL"
7101 [ -n "$(getfattr -d -m. $DIR/$tdir.bak | grep posix_acl_default)" ] &&
7102 error "$DIR/$tdir.bak shouldn't contain default ACL"
7105 run_test 103c "'cp -rp' won't set empty acl"
7108 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7110 lfs df || error "lfs df failed"
7111 lfs df -ih || error "lfs df -ih failed"
7112 lfs df -h $DIR || error "lfs df -h $DIR failed"
7113 lfs df -i $DIR || error "lfs df -i $DIR failed"
7114 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
7115 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
7117 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
7118 lctl --device %$OSC deactivate
7119 lfs df || error "lfs df with deactivated OSC failed"
7120 lctl --device %$OSC activate
7121 # wait the osc back to normal
7122 wait_osc_import_state client ost FULL
7124 lfs df || error "lfs df with reactivated OSC failed"
7127 run_test 104a "lfs df [-ih] [path] test ========================="
7130 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7131 [ $RUNAS_ID -eq $UID ] &&
7132 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
7134 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
7135 grep "Permission denied" | wc -l)))
7136 if [ $denied_cnt -ne 0 ]; then
7137 error "lfs check servers test failed"
7140 run_test 104b "$RUNAS lfs check servers test ===================="
7143 # doesn't work on 2.4 kernels
7145 if $(flock_is_enabled); then
7146 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
7148 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
7152 run_test 105a "flock when mounted without -o flock test ========"
7156 if $(flock_is_enabled); then
7157 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
7159 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
7163 run_test 105b "fcntl when mounted without -o flock test ========"
7167 if $(flock_is_enabled); then
7168 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
7170 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
7174 run_test 105c "lockf when mounted without -o flock test ========"
7176 test_105d() { # bug 15924
7177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7178 test_mkdir -p $DIR/$tdir
7179 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7180 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
7181 $LCTL set_param fail_loc=0x80000315
7182 flocks_test 2 $DIR/$tdir
7184 run_test 105d "flock race (should not freeze) ========"
7186 test_105e() { # bug 22660 && 22040
7187 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
7189 flocks_test 3 $DIR/$tfile
7191 run_test 105e "Two conflicting flocks from same process ======="
7193 test_106() { #bug 10921
7194 test_mkdir -p $DIR/$tdir
7195 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
7196 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
7198 run_test 106 "attempt exec of dir followed by chown of that dir"
7201 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7208 local save_pattern=$(sysctl -n kernel.core_pattern)
7209 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
7210 sysctl -w kernel.core_pattern=$file
7211 sysctl -w kernel.core_uses_pid=0
7219 kill -s 11 $SLEEPPID
7221 if [ -e $file ]; then
7222 size=`stat -c%s $file`
7223 [ $size -eq 0 ] && error "Fail to create core file $file"
7225 error "Fail to create core file $file"
7228 sysctl -w kernel.core_pattern=$save_pattern
7229 sysctl -w kernel.core_uses_pid=$save_uses_pid
7232 run_test 107 "Coredump on SIG"
7235 test_mkdir -p $DIR/$tdir
7236 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
7237 error "mkdir with 255 char failed"
7238 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
7239 error "mkdir with 256 char should fail, but did not"
7240 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
7241 error "create with 255 char failed"
7242 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
7243 error "create with 256 char should fail, but did not"
7248 run_test 110 "filename length checking"
7251 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7252 OSTIO_pre=$(ps -e | grep ll_ost_io | awk '{ print $4 }'| sort -n |
7253 tail -1 | cut -c11-20)
7254 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && return
7255 echo "Starting with $OSTIO_pre threads"
7258 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
7259 [[ $NUMFREE -lt $NUMTEST ]] && NUMTEST=$(($NUMFREE - 1000))
7260 echo "$NUMTEST creates/unlinks"
7261 test_mkdir -p $DIR/$tdir
7262 createmany -o $DIR/$tdir/$tfile $NUMTEST
7263 unlinkmany $DIR/$tdir/$tfile $NUMTEST
7265 OSTIO_post=$(ps -e | grep ll_ost_io | awk '{ print $4 }' | sort -n |
7266 tail -1 | cut -c11-20)
7268 # don't return an error
7269 [ $OSTIO_post == $OSTIO_pre ] && echo \
7270 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
7271 echo "This may be fine, depending on what ran before this test" &&
7272 echo "and how fast this system is." && return
7274 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
7276 run_test 115 "verify dynamic thread creation===================="
7279 wait_delete_completed
7280 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
7281 echo OST kbytes available: ${AVAIL[@]}
7282 MAXI=0; MAXV=${AVAIL[0]}
7283 MINI=0; MINV=${AVAIL[0]}
7284 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
7285 #echo OST $i: ${AVAIL[i]}kb
7286 if [[ ${AVAIL[i]} -gt $MAXV ]]; then
7287 MAXV=${AVAIL[i]}; MAXI=$i
7289 if [[ ${AVAIL[i]} -lt $MINV ]]; then
7290 MINV=${AVAIL[i]}; MINI=$i
7293 echo Min free space: OST $MINI: $MINV
7294 echo Max free space: OST $MAXI: $MAXV
7297 test_116a() { # was previously test_116()
7298 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7299 [[ $OSTCOUNT -lt 2 ]] && skip_env "$OSTCOUNT < 2 OSTs" && return
7301 echo -n "Free space priority "
7302 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
7307 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
7308 [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
7310 trap simple_cleanup_common EXIT
7313 # Check if we need to generate uneven OSTs
7314 test_mkdir -p $DIR/$tdir/OST${MINI}
7315 local FILL=$(($MINV / 4))
7316 local DIFF=$(($MAXV - $MINV))
7317 local DIFF2=$(($DIFF * 100 / $MINV))
7319 local threshold=$(do_facet $SINGLEMDS \
7320 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -n1)
7321 threshold=${threshold%%%}
7322 echo -n "Check for uneven OSTs: "
7323 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
7325 if [[ $DIFF2 -gt $threshold ]]; then
7327 echo "Don't need to fill OST$MINI"
7329 # generate uneven OSTs. Write 2% over the QOS threshold value
7331 DIFF=$(($threshold - $DIFF2 + 2))
7332 DIFF2=$(( ($MINV * $DIFF)/100 ))
7333 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
7334 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
7335 error "setstripe failed"
7336 DIFF=$(($DIFF2 / 2048))
7338 while [ $i -lt $DIFF ]; do
7340 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
7341 bs=2M count=1 2>/dev/null
7350 DIFF=$(($MAXV - $MINV))
7351 DIFF2=$(($DIFF * 100 / $MINV))
7352 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
7353 if [[ $DIFF2 -gt $threshold ]]; then
7356 echo "failed - QOS mode won't be used"
7357 skip "QOS imbalance criteria not met"
7358 simple_cleanup_common
7362 MINI1=$MINI; MINV1=$MINV
7363 MAXI1=$MAXI; MAXV1=$MAXV
7365 # now fill using QOS
7366 $SETSTRIPE -c 1 $DIR/$tdir
7367 FILL=$(($FILL / 200))
7368 if [ $FILL -gt 600 ]; then
7371 echo "writing $FILL files to QOS-assigned OSTs"
7373 while [ $i -lt $FILL ]; do
7375 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
7379 echo "wrote $i 200k files"
7383 echo "Note: free space may not be updated, so measurements might be off"
7385 DIFF2=$(($MAXV - $MINV))
7386 echo "free space delta: orig $DIFF final $DIFF2"
7387 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
7388 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
7389 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
7390 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
7391 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
7392 FILL=$(($DIFF2 * 100 / $DIFF - 100))
7394 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
7396 # Figure out which files were written where
7397 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7398 awk '/'$MINI1': / {print $2; exit}')
7400 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7401 echo "$MINC files created on smaller OST $MINI1"
7402 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
7403 awk '/'$MAXI1': / {print $2; exit}')
7405 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
7406 echo "$MAXC files created on larger OST $MAXI1"
7407 FILL=$(($MAXC * 100 / $MINC - 100))
7408 [[ $MINC -gt 0 ]] &&
7409 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
7410 [[ $MAXC -gt $MINC ]] ||
7411 error_ignore LU-9 "stripe QOS didn't balance free space"
7412 simple_cleanup_common
7414 run_test 116a "stripe QOS: free space balance ==================="
7416 test_116b() { # LU-2093
7417 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7418 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
7419 local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
7420 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
7421 [ -z "$old_rr" ] && skip "no QOS" && return 0
7422 do_facet $SINGLEMDS lctl set_param \
7423 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
7425 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
7426 createmany -o $DIR/$tdir/f- 20 || error "can't create"
7427 do_facet $SINGLEMDS lctl set_param fail_loc=0
7429 do_facet $SINGLEMDS lctl set_param \
7430 lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=$old_rr
7432 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
7434 test_117() # bug 10891
7436 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7437 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
7438 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
7439 lctl set_param fail_loc=0x21e
7440 > $DIR/$tfile || error "truncate failed"
7441 lctl set_param fail_loc=0
7442 echo "Truncate succeeded."
7445 run_test 117 "verify osd extend =========="
7447 NO_SLOW_RESENDCOUNT=4
7448 export OLD_RESENDCOUNT=""
7449 set_resend_count () {
7450 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
7451 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -n1)
7452 lctl set_param -n $PROC_RESENDCOUNT $1
7453 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
7456 # for reduce test_118* time (b=14842)
7457 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7459 # Reset async IO behavior after error case
7461 FILE=$DIR/reset_async
7463 # Ensure all OSCs are cleared
7464 $SETSTRIPE -c -1 $FILE
7465 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
7470 test_118a() #bug 11710
7472 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7475 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7476 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7477 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7479 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7480 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7485 run_test 118a "verify O_SYNC works =========="
7489 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7490 remote_ost_nodsh && skip "remote OST with nodsh" && return
7494 #define OBD_FAIL_OST_ENOENT 0x217
7495 set_nodes_failloc "$(osts_nodes)" 0x217
7496 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7498 set_nodes_failloc "$(osts_nodes)" 0
7499 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7500 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7503 if [[ $RC -eq 0 ]]; then
7504 error "Must return error due to dropped pages, rc=$RC"
7508 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7509 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7513 echo "Dirty pages not leaked on ENOENT"
7515 # Due to the above error the OSC will issue all RPCs syncronously
7516 # until a subsequent RPC completes successfully without error.
7517 $MULTIOP $DIR/$tfile Ow4096yc
7522 run_test 118b "Reclaim dirty pages on fatal error =========="
7526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7528 # for 118c, restore the original resend count, LU-1940
7529 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
7530 set_resend_count $OLD_RESENDCOUNT
7531 remote_ost_nodsh && skip "remote OST with nodsh" && return
7535 #define OBD_FAIL_OST_EROFS 0x216
7536 set_nodes_failloc "$(osts_nodes)" 0x216
7538 # multiop should block due to fsync until pages are written
7539 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7543 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7544 error "Multiop failed to block on fsync, pid=$MULTIPID"
7547 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7549 if [[ $WRITEBACK -eq 0 ]]; then
7550 error "No page in writeback, writeback=$WRITEBACK"
7553 set_nodes_failloc "$(osts_nodes)" 0
7556 if [[ $RC -ne 0 ]]; then
7557 error "Multiop fsync failed, rc=$RC"
7560 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7561 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7563 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7564 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7568 echo "Dirty pages flushed via fsync on EROFS"
7571 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7573 # continue to use small resend count to reduce test_118* time (b=14842)
7574 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7579 remote_ost_nodsh && skip "remote OST with nodsh" && return
7583 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7584 set_nodes_failloc "$(osts_nodes)" 0x214
7585 # multiop should block due to fsync until pages are written
7586 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7590 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7591 error "Multiop failed to block on fsync, pid=$MULTIPID"
7594 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7596 if [[ $WRITEBACK -eq 0 ]]; then
7597 error "No page in writeback, writeback=$WRITEBACK"
7600 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7601 set_nodes_failloc "$(osts_nodes)" 0
7603 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7604 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7606 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7607 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7611 echo "Dirty pages gaurenteed flushed via fsync"
7614 run_test 118d "Fsync validation inject a delay of the bulk =========="
7617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7620 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7621 lctl set_param fail_loc=0x8000040a
7623 # Should simulate EINVAL error which is fatal
7624 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7626 if [[ $RC -eq 0 ]]; then
7627 error "Must return error due to dropped pages, rc=$RC"
7630 lctl set_param fail_loc=0x0
7632 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7633 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7634 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7636 if [[ $LOCKED -ne 0 ]]; then
7637 error "Locked pages remain in cache, locked=$LOCKED"
7640 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7641 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7645 echo "No pages locked after fsync"
7650 run_test 118f "Simulate unrecoverable OSC side error =========="
7653 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7656 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7657 lctl set_param fail_loc=0x406
7659 # simulate local -ENOMEM
7660 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7663 lctl set_param fail_loc=0
7664 if [[ $RC -eq 0 ]]; then
7665 error "Must return error due to dropped pages, rc=$RC"
7668 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7669 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7670 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7672 if [[ $LOCKED -ne 0 ]]; then
7673 error "Locked pages remain in cache, locked=$LOCKED"
7676 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7677 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7681 echo "No pages locked after fsync"
7686 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7689 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7690 remote_ost_nodsh && skip "remote OST with nodsh" && return
7694 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7695 set_nodes_failloc "$(osts_nodes)" 0x20e
7696 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7697 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7700 set_nodes_failloc "$(osts_nodes)" 0
7701 if [[ $RC -eq 0 ]]; then
7702 error "Must return error due to dropped pages, rc=$RC"
7705 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7706 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7707 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7709 if [[ $LOCKED -ne 0 ]]; then
7710 error "Locked pages remain in cache, locked=$LOCKED"
7713 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7714 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7718 echo "No pages locked after fsync"
7722 run_test 118h "Verify timeout in handling recoverables errors =========="
7724 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7727 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7728 remote_ost_nodsh && skip "remote OST with nodsh" && return
7732 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7733 set_nodes_failloc "$(osts_nodes)" 0x20e
7735 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7736 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7739 set_nodes_failloc "$(osts_nodes)" 0
7743 if [[ $RC -ne 0 ]]; then
7744 error "got error, but should be not, rc=$RC"
7747 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7748 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7749 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7750 if [[ $LOCKED -ne 0 ]]; then
7751 error "Locked pages remain in cache, locked=$LOCKED"
7754 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7755 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7759 echo "No pages locked after fsync"
7763 run_test 118i "Fix error before timeout in recoverable error =========="
7765 [ "$SLOW" = "no" ] && set_resend_count 4
7768 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7769 remote_ost_nodsh && skip "remote OST with nodsh" && return
7773 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7774 set_nodes_failloc "$(osts_nodes)" 0x220
7776 # return -EIO from OST
7777 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7779 set_nodes_failloc "$(osts_nodes)" 0x0
7780 if [[ $RC -eq 0 ]]; then
7781 error "Must return error due to dropped pages, rc=$RC"
7784 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7785 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7786 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7787 if [[ $LOCKED -ne 0 ]]; then
7788 error "Locked pages remain in cache, locked=$LOCKED"
7791 # in recoverable error on OST we want resend and stay until it finished
7792 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7793 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7797 echo "No pages locked after fsync"
7801 run_test 118j "Simulate unrecoverable OST side error =========="
7805 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7806 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7808 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7809 set_nodes_failloc "$(osts_nodes)" 0x20e
7810 test_mkdir -p $DIR/$tdir
7812 for ((i=0;i<10;i++)); do
7813 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7814 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7821 set_nodes_failloc "$(osts_nodes)" 0
7824 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7830 test_mkdir -p $DIR/$tdir
7831 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7834 run_test 118l "fsync dir ========="
7836 test_118m() # LU-3066
7838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7839 test_mkdir -p $DIR/$tdir
7840 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7843 run_test 118m "fdatasync dir ========="
7845 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7847 test_119a() # bug 11737
7849 BSIZE=$((512 * 1024))
7850 directio write $DIR/$tfile 0 1 $BSIZE
7851 # We ask to read two blocks, which is more than a file size.
7852 # directio will indicate an error when requested and actual
7853 # sizes aren't equeal (a normal situation in this case) and
7854 # print actual read amount.
7855 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7856 if [ "$NOB" != "$BSIZE" ]; then
7857 error "read $NOB bytes instead of $BSIZE"
7861 run_test 119a "Short directIO read must return actual read amount"
7863 test_119b() # bug 11737
7865 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7867 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7868 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7870 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7871 error "direct read failed"
7874 run_test 119b "Sparse directIO read must return actual read amount"
7876 test_119c() # bug 13099
7879 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7880 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7883 run_test 119c "Testing for direct read hitting hole"
7885 test_119d() # bug 15950
7887 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7888 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7889 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7891 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7892 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7893 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7894 lctl set_param fail_loc=0x40d
7895 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7898 cat $DIR/$tfile > /dev/null &
7899 lctl set_param fail_loc=0
7902 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7904 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7905 error "the read rpcs have not completed in 2s"
7907 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7909 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7912 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7913 test_mkdir -p $DIR/$tdir
7914 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7915 skip "no early lock cancel on server" && return 0
7917 lru_resize_disable mdc
7918 lru_resize_disable osc
7919 cancel_lru_locks mdc
7920 # asynchronous object destroy at MDT could cause bl ast to client
7921 cancel_lru_locks osc
7923 stat $DIR/$tdir > /dev/null
7924 can1=$(do_facet $SINGLEMDS \
7925 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7926 awk '/ldlm_cancel/ {print $2}')
7927 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7928 awk '/ldlm_bl_callback/ {print $2}')
7929 test_mkdir -c1 $DIR/$tdir/d1
7930 can2=$(do_facet $SINGLEMDS \
7931 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7932 awk '/ldlm_cancel/ {print $2}')
7933 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7934 awk '/ldlm_bl_callback/ {print $2}')
7935 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7936 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7937 lru_resize_enable mdc
7938 lru_resize_enable osc
7940 run_test 120a "Early Lock Cancel: mkdir test"
7943 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7944 test_mkdir $DIR/$tdir
7945 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7946 skip "no early lock cancel on server" && return 0
7947 lru_resize_disable mdc
7948 lru_resize_disable osc
7949 cancel_lru_locks mdc
7950 stat $DIR/$tdir > /dev/null
7951 can1=$(do_facet $SINGLEMDS \
7952 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7953 awk '/ldlm_cancel/ {print $2}')
7954 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7955 awk '/ldlm_bl_callback/ {print $2}')
7957 can2=$(do_facet $SINGLEMDS \
7958 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7959 awk '/ldlm_cancel/ {print $2}')
7960 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7961 awk '/ldlm_bl_callback/ {print $2}')
7962 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7963 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7964 lru_resize_enable mdc
7965 lru_resize_enable osc
7967 run_test 120b "Early Lock Cancel: create test"
7970 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7971 test_mkdir -c1 $DIR/$tdir
7972 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
7973 skip "no early lock cancel on server" && return 0
7974 lru_resize_disable mdc
7975 lru_resize_disable osc
7976 test_mkdir -p -c1 $DIR/$tdir/d1
7977 test_mkdir -p -c1 $DIR/$tdir/d2
7978 touch $DIR/$tdir/d1/f1
7979 cancel_lru_locks mdc
7980 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7981 can1=$(do_facet $SINGLEMDS \
7982 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7983 awk '/ldlm_cancel/ {print $2}')
7984 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7985 awk '/ldlm_bl_callback/ {print $2}')
7986 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7987 can2=$(do_facet $SINGLEMDS \
7988 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
7989 awk '/ldlm_cancel/ {print $2}')
7990 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
7991 awk '/ldlm_bl_callback/ {print $2}')
7992 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7993 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7994 lru_resize_enable mdc
7995 lru_resize_enable osc
7997 run_test 120c "Early Lock Cancel: link test"
8000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8001 test_mkdir -p -c1 $DIR/$tdir
8002 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel)" ] && \
8003 skip "no early lock cancel on server" && return 0
8004 lru_resize_disable mdc
8005 lru_resize_disable osc
8007 cancel_lru_locks mdc
8008 stat $DIR/$tdir > /dev/null
8009 can1=$(do_facet $SINGLEMDS \
8010 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8011 awk '/ldlm_cancel/ {print $2}')
8012 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8013 awk '/ldlm_bl_callback/ {print $2}')
8014 chmod a+x $DIR/$tdir
8015 can2=$(do_facet $SINGLEMDS \
8016 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8017 awk '/ldlm_cancel/ {print $2}')
8018 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8019 awk '/ldlm_bl_callback/ {print $2}')
8020 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8021 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8022 lru_resize_enable mdc
8023 lru_resize_enable osc
8025 run_test 120d "Early Lock Cancel: setattr test"
8028 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8029 test_mkdir -p -c1 $DIR/$tdir
8030 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8031 skip "no early lock cancel on server" && return 0
8032 lru_resize_disable mdc
8033 lru_resize_disable osc
8034 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
8035 cancel_lru_locks mdc
8036 cancel_lru_locks osc
8037 dd if=$DIR/$tdir/f1 of=/dev/null
8038 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
8039 # XXX client can not do early lock cancel of OST lock
8040 # during unlink (LU-4206), so cancel osc lock now.
8041 cancel_lru_locks osc
8042 can1=$(do_facet $SINGLEMDS \
8043 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8044 awk '/ldlm_cancel/ {print $2}')
8045 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8046 awk '/ldlm_bl_callback/ {print $2}')
8047 unlink $DIR/$tdir/f1
8049 can2=$(do_facet $SINGLEMDS \
8050 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8051 awk '/ldlm_cancel/ {print $2}')
8052 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8053 awk '/ldlm_bl_callback/ {print $2}')
8054 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8055 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8056 lru_resize_enable mdc
8057 lru_resize_enable osc
8059 run_test 120e "Early Lock Cancel: unlink test"
8062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8063 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8064 skip "no early lock cancel on server" && return 0
8065 test_mkdir -p -c1 $DIR/$tdir
8066 lru_resize_disable mdc
8067 lru_resize_disable osc
8068 test_mkdir -p -c1 $DIR/$tdir/d1
8069 test_mkdir -p -c1 $DIR/$tdir/d2
8070 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
8071 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
8072 cancel_lru_locks mdc
8073 cancel_lru_locks osc
8074 dd if=$DIR/$tdir/d1/f1 of=/dev/null
8075 dd if=$DIR/$tdir/d2/f2 of=/dev/null
8076 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
8077 # XXX client can not do early lock cancel of OST lock
8078 # during rename (LU-4206), so cancel osc lock now.
8079 cancel_lru_locks osc
8080 can1=$(do_facet $SINGLEMDS \
8081 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8082 awk '/ldlm_cancel/ {print $2}')
8083 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8084 awk '/ldlm_bl_callback/ {print $2}')
8085 mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
8087 can2=$(do_facet $SINGLEMDS \
8088 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8089 awk '/ldlm_cancel/ {print $2}')
8090 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8091 awk '/ldlm_bl_callback/ {print $2}')
8092 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
8093 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
8094 lru_resize_enable mdc
8095 lru_resize_enable osc
8097 run_test 120f "Early Lock Cancel: rename test"
8100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8101 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
8102 skip "no early lock cancel on server" && return 0
8103 lru_resize_disable mdc
8104 lru_resize_disable osc
8106 echo create $count files
8107 test_mkdir -p $DIR/$tdir
8108 cancel_lru_locks mdc
8109 cancel_lru_locks osc
8112 can0=$(do_facet $SINGLEMDS \
8113 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8114 awk '/ldlm_cancel/ {print $2}')
8115 blk0=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8116 awk '/ldlm_bl_callback/ {print $2}')
8117 createmany -o $DIR/$tdir/f $count
8119 can1=$(do_facet $SINGLEMDS \
8120 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8121 awk '/ldlm_cancel/ {print $2}')
8122 blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8123 awk '/ldlm_bl_callback/ {print $2}')
8125 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
8126 echo rm $count files
8129 can2=$(do_facet $SINGLEMDS \
8130 "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
8131 awk '/ldlm_cancel/ {print $2}')
8132 blk2=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
8133 awk '/ldlm_bl_callback/ {print $2}')
8135 echo total: $count removes in $((t2-t1))
8136 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
8138 # wait for commitment of removal
8139 lru_resize_enable mdc
8140 lru_resize_enable osc
8142 run_test 120g "Early Lock Cancel: performance test"
8144 test_121() { #bug #10589
8145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8147 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
8148 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
8149 lctl set_param fail_loc=0x310
8150 cancel_lru_locks osc > /dev/null
8151 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
8152 lctl set_param fail_loc=0
8153 [[ $reads -eq $writes ]] ||
8154 error "read $reads blocks, must be $writes blocks"
8156 run_test 121 "read cancel race ========="
8158 test_123a() { # was test 123, statahead(bug 11401)
8159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8161 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
8162 log "testing on UP system. Performance may be not as good as expected."
8167 test_mkdir -p $DIR/$tdir
8168 NUMFREE=$(df -i -P $DIR | tail -n 1 | awk '{ print $4 }')
8169 [[ $NUMFREE -gt 100000 ]] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
8171 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
8172 createmany -o $DIR/$tdir/$tfile $j $((i - j))
8174 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8175 lctl set_param -n llite.*.statahead_max 0
8176 lctl get_param llite.*.statahead_max
8177 cancel_lru_locks mdc
8178 cancel_lru_locks osc
8180 time ls -l $DIR/$tdir | wc -l
8182 delta=$((etime - stime))
8183 log "ls $i files without statahead: $delta sec"
8184 lctl set_param llite.*.statahead_max=$max
8186 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8187 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
8188 cancel_lru_locks mdc
8189 cancel_lru_locks osc
8191 time ls -l $DIR/$tdir | wc -l
8193 delta_sa=$((etime - stime))
8194 log "ls $i files with statahead: $delta_sa sec"
8195 lctl get_param -n llite.*.statahead_stats
8196 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
8198 [[ $swrong -lt $ewrong ]] &&
8199 log "statahead was stopped, maybe too many locks held!"
8200 [[ $delta -eq 0 || $delta_sa -eq 0 ]] && continue
8202 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8203 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
8204 lctl set_param -n llite.*.statahead_max 0
8205 lctl get_param llite.*.statahead_max
8206 cancel_lru_locks mdc
8207 cancel_lru_locks osc
8209 time ls -l $DIR/$tdir | wc -l
8211 delta=$((etime - stime))
8212 log "ls $i files again without statahead: $delta sec"
8213 lctl set_param llite.*.statahead_max=$max
8214 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
8215 if [ $SLOWOK -eq 0 ]; then
8216 error "ls $i files is slower with statahead!"
8218 log "ls $i files is slower with statahead!"
8224 [ $delta -gt 20 ] && break
8225 [ $delta -gt 8 ] && MULT=$((50 / delta))
8226 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
8234 delta=$((etime - stime))
8235 log "rm -r $DIR/$tdir/: $delta seconds"
8237 lctl get_param -n llite.*.statahead_stats
8239 run_test 123a "verify statahead work"
8241 test_123b () { # statahead(bug 15027)
8242 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8243 test_mkdir -p $DIR/$tdir
8244 createmany -o $DIR/$tdir/$tfile-%d 1000
8246 cancel_lru_locks mdc
8247 cancel_lru_locks osc
8249 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
8250 lctl set_param fail_loc=0x80000803
8251 ls -lR $DIR/$tdir > /dev/null
8253 lctl set_param fail_loc=0x0
8254 lctl get_param -n llite.*.statahead_stats
8259 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
8262 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8263 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8264 skip "no lru resize on server" && return 0
8266 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
8268 log "create $NR files at $DIR/$tdir"
8269 createmany -o $DIR/$tdir/f $NR ||
8270 error "failed to create $NR files in $DIR/$tdir"
8272 cancel_lru_locks mdc
8273 ls -l $DIR/$tdir > /dev/null
8277 for VALUE in $($LCTL get_param ldlm.namespaces.*mdc-*.lru_size); do
8278 local PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
8279 LRU_SIZE=$($LCTL get_param -n $PARAM)
8280 if [[ $LRU_SIZE -gt $(default_lru_size) ]]; then
8281 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
8283 log "NS=$(basename $NSDIR)"
8288 if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
8289 skip "Not enough cached locks created!"
8296 # We know that lru resize allows one client to hold $LIMIT locks
8297 # for 10h. After that locks begin to be killed by client.
8299 local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
8301 if [ $LIMIT -lt $LRU_SIZE ]; then
8302 skip "Limit is too small $LIMIT"
8306 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
8307 # killing locks. Some time was spent for creating locks. This means
8308 # that up to the moment of sleep finish we must have killed some of
8309 # them (10-100 locks). This depends on how fast ther were created.
8310 # Many of them were touched in almost the same moment and thus will
8311 # be killed in groups.
8312 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
8314 # Use $LRU_SIZE_B here to take into account real number of locks
8315 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
8316 local LRU_SIZE_B=$LRU_SIZE
8318 local OLD_LVF=$($LCTL get_param -n $NSDIR.pool.lock_volume_factor)
8319 log "OLD_LVF=$OLD_LVF"
8320 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $LVF
8322 # Let's make sure that we really have some margin. Client checks
8323 # cached locks every 10 sec.
8325 log "Sleep ${SLEEP} sec"
8327 while ((SEC<$SLEEP)); do
8331 LRU_SIZE=$($LCTL get_param -n $NSDIR/lru_size)
8335 $LCTL set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
8336 local LRU_SIZE_A=$($LCTL get_param -n $NSDIR.lru_size)
8338 [[ $LRU_SIZE_B -gt $LRU_SIZE_A ]] || {
8339 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
8340 unlinkmany $DIR/$tdir/f $NR
8344 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
8345 log "unlink $NR files at $DIR/$tdir"
8346 unlinkmany $DIR/$tdir/f $NR
8348 run_test 124a "lru resize ======================================="
8350 get_max_pool_limit()
8352 local limit=$($LCTL get_param \
8353 -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit)
8356 if [[ $l -gt $max ]]; then
8364 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8365 [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep lru_resize)" ] &&
8366 skip "no lru resize on server" && return 0
8368 LIMIT=$(get_max_pool_limit)
8370 NR=$(($(default_lru_size)*20))
8371 if [[ $NR -gt $LIMIT ]]; then
8372 log "Limit lock number by $LIMIT locks"
8375 lru_resize_disable mdc
8376 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
8377 error "failed to create $DIR/$tdir/disable_lru_resize"
8379 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
8380 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
8381 cancel_lru_locks mdc
8384 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8387 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8390 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
8394 nolruresize_delta=$((etime-stime))
8395 log "ls -la time: $nolruresize_delta seconds"
8396 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8397 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
8399 lru_resize_enable mdc
8400 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
8401 error "failed to create $DIR/$tdir/enable_lru_resize"
8403 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
8404 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
8405 cancel_lru_locks mdc
8408 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8411 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8414 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
8418 lruresize_delta=$((etime-stime))
8419 log "ls -la time: $lruresize_delta seconds"
8420 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
8422 if [ $lruresize_delta -gt $nolruresize_delta ]; then
8423 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
8424 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
8425 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
8427 log "lru resize performs the same with no lru resize"
8429 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
8431 run_test 124b "lru resize (performance test) ======================="
8433 test_125() { # 13358
8434 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8435 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
8436 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
8437 test_mkdir -p $DIR/d125 || error "mkdir failed"
8438 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
8439 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
8440 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
8442 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
8444 test_126() { # bug 12829/13455
8445 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
8446 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
8447 $GSS && skip "must run as gss disabled" && return
8449 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
8450 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
8452 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
8454 run_test 126 "check that the fsgid provided by the client is taken into account"
8456 test_127a() { # bug 15521
8457 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8458 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
8459 $LCTL set_param osc.*.stats=0
8460 FSIZE=$((2048 * 1024))
8461 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8462 cancel_lru_locks osc
8463 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
8465 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
8466 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8467 echo "got $COUNT $NAME"
8468 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
8469 eval $NAME=$COUNT || error "Wrong proc format"
8472 read_bytes|write_bytes)
8473 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
8474 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
8475 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
8476 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
8477 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
8478 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
8479 error "sumsquare is too small: $SUMSQ"
8480 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
8481 error "sumsquare is too big: $SUMSQ"
8485 done < $DIR/${tfile}.tmp
8487 #check that we actually got some stats
8488 [ "$read_bytes" ] || error "Missing read_bytes stats"
8489 [ "$write_bytes" ] || error "Missing write_bytes stats"
8490 [ "$read_bytes" != 0 ] || error "no read done"
8491 [ "$write_bytes" != 0 ] || error "no write done"
8493 run_test 127a "verify the client stats are sane"
8495 test_127b() { # bug LU-333
8496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8497 $LCTL set_param llite.*.stats=0
8498 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
8499 # perform 2 reads and writes so MAX is different from SUM.
8500 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8501 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
8502 cancel_lru_locks osc
8503 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8504 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
8506 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
8507 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
8508 echo "got $COUNT $NAME"
8509 eval $NAME=$COUNT || error "Wrong proc format"
8513 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8514 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8515 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8516 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8519 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
8520 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
8521 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
8522 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
8526 done < $TMP/${tfile}.tmp
8528 #check that we actually got some stats
8529 [ "$read_bytes" ] || error "Missing read_bytes stats"
8530 [ "$write_bytes" ] || error "Missing write_bytes stats"
8531 [ "$read_bytes" != 0 ] || error "no read done"
8532 [ "$write_bytes" != 0 ] || error "no write done"
8534 run_test 127b "verify the llite client stats are sane"
8536 test_128() { # bug 15212
8538 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
8543 result=$(grep error $TMP/$tfile.log)
8545 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
8547 run_test 128 "interactive lfs for 2 consecutive find's"
8554 local LDPROC=/proc/fs/ldiskfs
8555 local facets=$(get_facets MDS)
8557 for facet in ${facets//,/ }; do
8558 canondev=$(ldiskfs_canon \
8559 *.$(convert_facet2label $facet).mntdev $facet)
8560 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
8561 LDPROC=/sys/fs/ldiskfs
8562 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
8567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8568 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
8569 skip "Only applicable to ldiskfs-based MDTs"
8572 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8577 test_mkdir -p $DIR/$tdir
8579 # block size of mds1
8580 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
8581 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
8582 local MAX=$((MDSBLOCKSIZE * 3))
8584 local I=$(stat -c%s "$DIR/$tdir")
8586 local STRIPE_COUNT=1
8587 [[ $MDSCOUNT -ge 2 ]] && STRIPE_COUNT=$($LFS getdirstripe -c $DIR/$tdir)
8588 MAX=$((MAX*STRIPE_COUNT))
8589 while [[ $I -le $MAX ]]; do
8590 $MULTIOP $DIR/$tdir/$J Oc
8592 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8593 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8594 #and EFBIG for previous versions
8595 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8597 echo "return code $rc received as expected"
8598 multiop $DIR/$tdir/$J Oc ||
8599 error_exit "multiop failed w/o dir size limit"
8601 I=$(stat -c%s "$DIR/$tdir")
8603 if [ $(lustre_version_code $SINGLEMDS) -lt \
8604 $(version_code 2.4.51) ]
8606 [[ $I -eq $MAX ]] && return 0
8608 [[ $I -gt $MAX ]] && return 0
8610 error_exit "current dir size $I, previous limit $MAX"
8611 elif [ $rc -ne 0 ]; then
8613 error_exit "return code $rc received instead of expected " \
8614 "$EFBIG or $ENOSPC, files in dir $I"
8617 I=$(stat -c%s "$DIR/$tdir")
8621 error "exceeded dir size limit $MAX($MDSCOUNT) : $I bytes"
8623 run_test 129 "test directory size limit ========================"
8632 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8633 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8636 trap cleanup_130 EXIT RETURN
8638 local fm_file=$DIR/$tfile
8639 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8640 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8641 error "dd failed for $fm_file"
8643 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8644 filefrag -ves $fm_file
8646 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8647 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8648 [ $RC != 0 ] && error "filefrag $fm_file failed"
8650 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8651 grep -v "ext:" | grep -v "found")
8652 lun=$($GETSTRIPE -i $fm_file)
8654 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8657 for line in $filefrag_op
8659 frag_lun=`echo $line | cut -d: -f5`
8660 ext_len=`echo $line | cut -d: -f4`
8661 if (( $frag_lun != $lun )); then
8663 error "FIEMAP on 1-stripe file($fm_file) failed"
8666 (( tot_len += ext_len ))
8669 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8671 error "FIEMAP on 1-stripe file($fm_file) failed;"
8677 echo "FIEMAP on single striped file succeeded"
8679 run_test 130a "FIEMAP (1-stripe file)"
8682 [ "$OSTCOUNT" -lt "2" ] &&
8683 skip_env "skipping FIEMAP on 2-stripe file test" && return
8685 [ "$OSTCOUNT" -ge "10" ] &&
8686 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8688 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8689 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8692 trap cleanup_130 EXIT RETURN
8694 local fm_file=$DIR/$tfile
8695 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8696 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8697 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8699 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8700 error "dd failed on $fm_file"
8702 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8703 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8704 grep -v "ext:" | grep -v "found")
8706 last_lun=$(echo $filefrag_op | cut -d: -f5)
8711 for line in $filefrag_op
8713 frag_lun=`echo $line | cut -d: -f5`
8714 ext_len=`echo $line | cut -d: -f4`
8715 if (( $frag_lun != $last_lun )); then
8716 if (( tot_len != 1024 )); then
8718 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8725 (( tot_len += ext_len ))
8728 if (( num_luns != 2 || tot_len != 1024 )); then
8730 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8736 echo "FIEMAP on 2-stripe file succeeded"
8738 run_test 130b "FIEMAP (2-stripe file)"
8741 [ "$OSTCOUNT" -lt "2" ] &&
8742 skip_env "skipping FIEMAP on 2-stripe file" && return
8744 [ "$OSTCOUNT" -ge "10" ] &&
8745 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8747 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8748 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8751 trap cleanup_130 EXIT RETURN
8753 local fm_file=$DIR/$tfile
8754 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8755 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8756 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8758 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8760 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8761 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8763 last_lun=`echo $filefrag_op | cut -d: -f5`
8768 for line in $filefrag_op
8770 frag_lun=`echo $line | cut -d: -f5`
8771 ext_len=`echo $line | cut -d: -f4`
8772 if (( $frag_lun != $last_lun )); then
8773 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8774 if (( logical != 512 )); then
8776 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8779 if (( tot_len != 512 )); then
8781 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8788 (( tot_len += ext_len ))
8791 if (( num_luns != 2 || tot_len != 512 )); then
8793 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8799 echo "FIEMAP on 2-stripe file with hole succeeded"
8801 run_test 130c "FIEMAP (2-stripe file with hole)"
8804 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8806 [ "$OSTCOUNT" -ge "10" ] &&
8807 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8809 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8810 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8812 trap cleanup_130 EXIT RETURN
8814 local fm_file=$DIR/$tfile
8815 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8816 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8817 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8819 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8820 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8821 error "dd failed on $fm_file"
8823 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8824 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8825 grep -v "ext:" | grep -v "found"`
8827 last_lun=`echo $filefrag_op | cut -d: -f5`
8832 for line in $filefrag_op
8834 frag_lun=`echo $line | cut -d: -f5`
8835 ext_len=`echo $line | cut -d: -f4`
8836 if (( $frag_lun != $last_lun )); then
8837 if (( tot_len != 1024 )); then
8839 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8846 (( tot_len += ext_len ))
8849 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8851 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8857 echo "FIEMAP on N-stripe file succeeded"
8859 run_test 130d "FIEMAP (N-stripe file)"
8862 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8864 [ "$OSTCOUNT" -ge "10" ] &&
8865 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8867 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8868 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8870 trap cleanup_130 EXIT RETURN
8872 local fm_file=$DIR/$tfile
8873 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8874 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8875 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8878 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8879 for ((i = 0; i < $NUM_BLKS; i++))
8881 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8884 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8885 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8887 last_lun=`echo $filefrag_op | cut -d: -f5`
8892 for line in $filefrag_op
8894 frag_lun=`echo $line | cut -d: -f5`
8895 ext_len=`echo $line | cut -d: -f4`
8896 if (( $frag_lun != $last_lun )); then
8897 if (( tot_len != $EXPECTED_LEN )); then
8899 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8906 (( tot_len += ext_len ))
8909 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8911 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8917 echo "FIEMAP with continuation calls succeeded"
8919 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8921 # Test for writev/readv
8923 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8924 error "writev test failed"
8925 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8926 error "readv failed"
8929 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8932 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8933 error "append writev test failed"
8934 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8935 error "append writev test failed"
8938 run_test 131b "test append writev"
8941 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8944 run_test 131c "test read/write on file w/o objects"
8947 rwv -f $DIR/$tfile -w -n 1 1572864
8948 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8949 if [ "$NOB" != 1572864 ]; then
8950 error "Short read filed: read $NOB bytes instead of 1572864"
8954 run_test 131d "test short read"
8957 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8958 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8959 error "read hitting hole failed"
8962 run_test 131e "test read hitting hole"
8968 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8970 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8972 *) error "Wrong argument $1" ;;
8975 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8976 # if the argument $3 is zero, it means any stat increment is ok.
8977 if [[ $3 -gt 0 ]]; then
8978 count=$(echo $res | awk '{ print $2 }')
8979 [[ $count -ne $3 ]] &&
8980 error "The $2 counter on $1 is wrong - expected $3"
8985 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8986 remote_ost_nodsh && skip "remote OST with nodsh" && return
8987 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8989 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8990 { skip "MDS doesn't support rename stats"; return; }
8991 local testdir=$DIR/${tdir}/stats_testdir
8992 mkdir -p $DIR/${tdir}
8995 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8996 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8998 # verify mdt stats first.
8999 mkdir ${testdir} || error "mkdir failed"
9000 check_stats $SINGLEMDS "mkdir" 1
9001 touch ${testdir}/${tfile} || "touch failed"
9002 check_stats $SINGLEMDS "open" 1
9003 check_stats $SINGLEMDS "close" 1
9004 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
9005 check_stats $SINGLEMDS "mknod" 1
9006 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
9007 check_stats $SINGLEMDS "unlink" 1
9008 rm -f ${testdir}/${tfile} || error "file remove failed"
9009 check_stats $SINGLEMDS "unlink" 2
9011 # remove working dir and check mdt stats again.
9012 rmdir ${testdir} || error "rmdir failed"
9013 check_stats $SINGLEMDS "rmdir" 1
9015 local testdir1=$DIR/${tdir}/stats_testdir1
9017 mkdir -p ${testdir1}
9018 touch ${testdir1}/test1
9019 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
9020 check_stats $SINGLEMDS "crossdir_rename" 1
9022 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
9023 check_stats $SINGLEMDS "samedir_rename" 1
9027 run_test 133a "Verifying MDT stats ========================================"
9030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9031 remote_ost_nodsh && skip "remote OST with nodsh" && return
9032 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9033 local testdir=$DIR/${tdir}/stats_testdir
9034 mkdir -p ${testdir} || error "mkdir failed"
9035 touch ${testdir}/${tfile} || "touch failed"
9036 cancel_lru_locks mdc
9039 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9040 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9042 # extra mdt stats verification.
9043 chmod 444 ${testdir}/${tfile} || error "chmod failed"
9044 check_stats $SINGLEMDS "setattr" 1
9045 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9046 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
9048 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
9049 check_stats $SINGLEMDS "getattr" 1
9051 $LFS df || error "lfs failed"
9052 check_stats $SINGLEMDS "statfs" 1
9056 run_test 133b "Verifying extra MDT stats =================================="
9059 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9060 remote_ost_nodsh && skip "remote OST with nodsh" && return
9061 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9062 local testdir=$DIR/${tdir}/stats_testdir
9063 test_mkdir -p ${testdir} || error "mkdir failed"
9065 # verify obdfilter stats.
9066 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9068 cancel_lru_locks osc
9069 wait_delete_completed
9072 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
9073 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
9075 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
9077 cancel_lru_locks osc
9078 check_stats ost "write" 1
9080 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
9081 check_stats ost "read" 1
9083 > ${testdir}/${tfile} || error "truncate failed"
9084 check_stats ost "punch" 1
9086 rm -f ${testdir}/${tfile} || error "file remove failed"
9087 wait_delete_completed
9088 check_stats ost "destroy" 1
9092 run_test 133c "Verifying OST stats ========================================"
9099 while [ $value -ge 2 ]; do
9104 if [ $orig -gt $order ]; then
9112 local size=('K' 'M' 'G' 'T');
9114 local size_string=$value
9116 while [ $value -ge 1024 ]; do
9117 if [ $i -gt 3 ]; then
9118 #T is the biggest unit we get here, if that is bigger,
9120 size_string=${value}T
9123 value=$((value >> 10))
9124 if [ $value -lt 1024 ]; then
9125 size_string=${value}${size[$i]}
9136 local context=${2:-.}
9137 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
9139 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
9144 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9145 remote_ost_nodsh && skip "remote OST with nodsh" && return
9146 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9147 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
9148 { skip "MDS doesn't support rename stats"; return; }
9150 local testdir1=$DIR/${tdir}/stats_testdir1
9151 local testdir2=$DIR/${tdir}/stats_testdir2
9153 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9155 mkdir -p ${testdir1} || error "mkdir failed"
9156 mkdir -p ${testdir2} || error "mkdir failed"
9158 createmany -o $testdir1/test 512 || error "createmany failed"
9160 # check samedir rename size
9161 mv ${testdir1}/test0 ${testdir1}/test_0
9163 local testdir1_size=$(ls -l $DIR/${tdir} |
9164 awk '/stats_testdir1/ {print $5}')
9165 local testdir2_size=$(ls -l $DIR/${tdir} |
9166 awk '/stats_testdir2/ {print $5}')
9168 testdir1_size=$(order_2 $testdir1_size)
9169 testdir2_size=$(order_2 $testdir2_size)
9171 testdir1_size=$(size_in_KMGT $testdir1_size)
9172 testdir2_size=$(size_in_KMGT $testdir2_size)
9174 echo "source rename dir size: ${testdir1_size}"
9175 echo "target rename dir size: ${testdir2_size}"
9177 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
9178 eval $cmd || error "$cmd failed"
9179 local samedir=$($cmd | grep 'same_dir')
9180 local same_sample=$(get_rename_size $testdir1_size)
9181 [ -z "$samedir" ] && error "samedir_rename_size count error"
9182 [[ $same_sample -eq 1 ]] ||
9183 error "samedir_rename_size error $same_sample"
9184 echo "Check same dir rename stats success"
9186 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
9188 # check crossdir rename size
9189 mv ${testdir1}/test_0 ${testdir2}/test_0
9191 testdir1_size=$(ls -l $DIR/${tdir} |
9192 awk '/stats_testdir1/ {print $5}')
9193 testdir2_size=$(ls -l $DIR/${tdir} |
9194 awk '/stats_testdir2/ {print $5}')
9196 testdir1_size=$(order_2 $testdir1_size)
9197 testdir2_size=$(order_2 $testdir2_size)
9199 testdir1_size=$(size_in_KMGT $testdir1_size)
9200 testdir2_size=$(size_in_KMGT $testdir2_size)
9202 echo "source rename dir size: ${testdir1_size}"
9203 echo "target rename dir size: ${testdir2_size}"
9205 eval $cmd || error "$cmd failed"
9206 local crossdir=$($cmd | grep 'crossdir')
9207 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
9208 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
9209 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
9210 [[ $src_sample -eq 1 ]] ||
9211 error "crossdir_rename_size error $src_sample"
9212 [[ $tgt_sample -eq 1 ]] ||
9213 error "crossdir_rename_size error $tgt_sample"
9214 echo "Check cross dir rename stats success"
9217 run_test 133d "Verifying rename_stats ========================================"
9220 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9221 remote_ost_nodsh && skip "remote OST with nodsh" && return
9222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9223 local testdir=$DIR/${tdir}/stats_testdir
9224 local ctr f0 f1 bs=32768 count=42 sum
9226 mkdir -p ${testdir} || error "mkdir failed"
9228 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
9230 for ctr in {write,read}_bytes; do
9232 cancel_lru_locks osc
9234 do_facet ost1 $LCTL set_param -n \
9235 "obdfilter.*.exports.clear=clear"
9237 if [ $ctr = write_bytes ]; then
9239 f1=${testdir}/${tfile}
9241 f0=${testdir}/${tfile}
9245 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
9248 cancel_lru_locks osc
9250 sum=$(do_facet ost1 $LCTL get_param \
9251 "obdfilter.*.exports.*.stats" |
9252 awk -v ctr=$ctr 'BEGIN { sum = 0 }
9253 $1 == ctr { sum += $7 }
9254 END { printf("%0.0f", sum) }')
9256 if ((sum != bs * count)); then
9257 error "Bad $ctr sum, expected $((bs * count)), got $sum"
9263 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
9268 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9269 /sys/fs/lustre/ /sys/fs/lnet/"
9271 for dir in $dirs; do
9272 if [ -d $dir ]; then
9273 proc_dirs="$proc_dirs $dir"
9279 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9280 remote_ost_nodsh && skip "remote OST with nodsh" && return
9281 # First without trusting modes.
9282 find $proc_dirs -exec cat '{}' \; &> /dev/null
9284 # Second verifying readability.
9287 -exec cat '{}' \; &> /dev/null ||
9288 error "proc file read failed"
9290 for facet in $SINGLEMDS ost1; do
9291 do_facet $facet find $proc_dirs \
9292 ! -name req_history \
9293 -exec cat '{}' \\\; &> /dev/null
9295 do_facet $facet find $proc_dirs \
9296 ! -name req_history \
9298 -exec cat '{}' \\\; &> /dev/null ||
9299 error "proc file read failed"
9302 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
9307 local dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/ \
9308 /sys/fs/lustre/ /sys/fs/lnet/"
9310 for dir in $dirs; do
9311 if [ -d $dir ]; then
9312 proc_dirs="$proc_dirs $dir"
9318 # Second verifying readability.
9321 -not -name force_lbug \
9322 -not -name changelog_mask \
9323 -exec badarea_io '{}' \; &> /dev/null ||
9324 error "find $proc_dirs failed"
9326 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
9327 skip "Too old lustre on MDS" && return
9329 [ $(lustre_version_code ost1) -le $(version_code 2.5.54) ] &&
9330 skip "Too old lustre on ost1" && return
9332 for facet in $SINGLEMDS ost1; do
9333 do_facet $facet find $proc_dirs \
9335 -not -name force_lbug \
9336 -not -name changelog_mask \
9337 -exec badarea_io '{}' \\\; &> /dev/null ||
9338 error "$facet find $proc_dirs failed"
9342 # remount the FS in case writes/reads /proc break the FS
9343 cleanup || error "failed to unmount"
9344 setup || error "failed to setup"
9347 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
9349 test_140() { #bug-17379
9350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9351 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
9352 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
9353 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
9355 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
9356 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
9358 while i=`expr $i + 1`; do
9359 test_mkdir -p $i || error "Creating dir $i"
9360 cd $i || error "Changing to $i"
9361 ln -s ../stat stat || error "Creating stat symlink"
9362 # Read the symlink until ELOOP present,
9363 # not LBUGing the system is considered success,
9364 # we didn't overrun the stack.
9365 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
9367 if [ $ret -eq 40 ]; then
9370 error "Open stat symlink"
9376 echo "The symlink depth = $i"
9377 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
9378 error "Invalid symlink depth"
9380 # Test recursive symlink
9381 ln -s symlink_self symlink_self
9382 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
9383 echo "open symlink_self returns $ret"
9384 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
9386 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
9389 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9390 local TF="$TMP/$tfile"
9392 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9394 cancel_lru_locks osc
9395 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
9396 remount_client $MOUNT
9398 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
9401 $TRUNCATE $DIR/$tfile 6000
9402 cancel_lru_locks osc
9403 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
9406 echo "12345" >>$DIR/$tfile
9407 cancel_lru_locks osc
9408 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
9411 echo "12345" >>$DIR/$tfile
9412 cancel_lru_locks osc
9413 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
9418 run_test 150 "truncate/append tests"
9420 #LU-2902 roc_hit was not able to read all values from lproc
9421 function roc_hit_init() {
9422 local list=$(comma_list $(osts_nodes))
9423 local dir=$DIR/$tdir-check
9424 local file=$dir/file
9430 #use setstripe to do a write to every ost
9431 for i in $(seq 0 $((OSTCOUNT-1))); do
9432 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
9433 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
9434 idx=$(printf %04x $i)
9435 BEFORE=$(get_osd_param $list *OST*$idx stats |
9436 awk '$1 == "cache_access" {sum += $7}
9437 END { printf("%0.0f", sum) }')
9439 cancel_lru_locks osc
9440 cat $file >/dev/null
9442 AFTER=$(get_osd_param $list *OST*$idx stats |
9443 awk '$1 == "cache_access" {sum += $7}
9444 END { printf("%0.0f", sum) }')
9446 echo BEFORE:$BEFORE AFTER:$AFTER
9447 if ! let "AFTER - BEFORE == 4"; then
9449 error "roc_hit is not safe to use"
9457 function roc_hit() {
9458 local list=$(comma_list $(osts_nodes))
9459 echo $(get_osd_param $list '' stats |
9460 awk '$1 == "cache_hit" {sum += $7}
9461 END { printf("%0.0f", sum) }')
9464 function set_cache() {
9467 if [ "$2" == "off" ]; then
9470 local list=$(comma_list $(osts_nodes))
9471 set_osd_param $list '' $1_cache_enable $on
9473 cancel_lru_locks osc
9477 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9478 remote_ost_nodsh && skip "remote OST with nodsh" && return
9481 local list=$(comma_list $(osts_nodes))
9483 # check whether obdfilter is cache capable at all
9484 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
9485 echo "not cache-capable obdfilter"
9489 # check cache is enabled on all obdfilters
9490 if get_osd_param $list '' read_cache_enable | grep 0; then
9491 echo "oss cache is disabled"
9495 set_osd_param $list '' writethrough_cache_enable 1
9497 # check write cache is enabled on all obdfilters
9498 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
9499 echo "oss write cache is NOT enabled"
9505 #define OBD_FAIL_OBD_NO_LRU 0x609
9506 do_nodes $list $LCTL set_param fail_loc=0x609
9508 # pages should be in the case right after write
9509 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
9512 local BEFORE=$(roc_hit)
9513 cancel_lru_locks osc
9514 cat $DIR/$tfile >/dev/null
9515 local AFTER=$(roc_hit)
9517 do_nodes $list $LCTL set_param fail_loc=0
9519 if ! let "AFTER - BEFORE == CPAGES"; then
9520 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9523 # the following read invalidates the cache
9524 cancel_lru_locks osc
9525 set_osd_param $list '' read_cache_enable 0
9526 cat $DIR/$tfile >/dev/null
9528 # now data shouldn't be found in the cache
9530 cancel_lru_locks osc
9531 cat $DIR/$tfile >/dev/null
9533 if let "AFTER - BEFORE != 0"; then
9534 error "IN CACHE: before: $BEFORE, after: $AFTER"
9537 set_osd_param $list '' read_cache_enable 1
9540 run_test 151 "test cache on oss and controls ==============================="
9543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9544 local TF="$TMP/$tfile"
9546 # simulate ENOMEM during write
9547 #define OBD_FAIL_OST_NOMEM 0x226
9548 lctl set_param fail_loc=0x80000226
9549 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
9551 sync || error "sync failed"
9552 lctl set_param fail_loc=0
9554 # discard client's cache
9555 cancel_lru_locks osc
9557 # simulate ENOMEM during read
9558 lctl set_param fail_loc=0x80000226
9559 cmp $TF $DIR/$tfile || error "cmp failed"
9560 lctl set_param fail_loc=0
9564 run_test 152 "test read/write with enomem ============================"
9567 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
9569 run_test 153 "test if fdatasync does not crash ======================="
9571 dot_lustre_fid_permission_check() {
9573 local ffid=$MOUNT/.lustre/fid/$fid
9576 echo "stat fid $fid"
9577 stat $ffid > /dev/null || error "stat $ffid failed."
9578 echo "touch fid $fid"
9579 touch $ffid || error "touch $ffid failed."
9580 echo "write to fid $fid"
9581 cat /etc/hosts > $ffid || error "write $ffid failed."
9582 echo "read fid $fid"
9583 diff /etc/hosts $ffid || error "read $ffid failed."
9584 echo "append write to fid $fid"
9585 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9586 echo "rename fid $fid"
9587 mv $ffid $test_dir/$tfile.1 &&
9588 error "rename $ffid to $tfile.1 should fail."
9589 touch $test_dir/$tfile.1
9590 mv $test_dir/$tfile.1 $ffid &&
9591 error "rename $tfile.1 to $ffid should fail."
9592 rm -f $test_dir/$tfile.1
9593 echo "truncate fid $fid"
9594 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9595 if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
9596 echo "link fid $fid"
9597 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9599 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9600 echo "setfacl fid $fid"
9601 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9602 echo "getfacl fid $fid"
9603 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9605 echo "unlink fid $fid"
9606 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9607 echo "mknod fid $fid"
9608 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9610 fid=[0xf00000400:0x1:0x0]
9611 ffid=$MOUNT/.lustre/fid/$fid
9613 echo "stat non-exist fid $fid"
9614 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9615 echo "write to non-exist fid $fid"
9616 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9617 echo "link new fid $fid"
9618 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9620 mkdir -p $test_dir/$tdir
9621 touch $test_dir/$tdir/$tfile
9622 fid=$($LFS path2fid $test_dir/$tdir)
9625 error "error: could not get fid for $test_dir/$dir/$tfile."
9627 ffid=$MOUNT/.lustre/fid/$fid
9630 ls $ffid > /dev/null || error "ls $ffid failed."
9631 echo "touch $fid/$tfile.1"
9632 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9634 echo "touch $MOUNT/.lustre/fid/$tfile"
9635 touch $MOUNT/.lustre/fid/$tfile && \
9636 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9638 echo "setxattr to $MOUNT/.lustre/fid"
9639 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9641 echo "listxattr for $MOUNT/.lustre/fid"
9642 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9644 echo "delxattr from $MOUNT/.lustre/fid"
9645 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9647 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9648 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9649 error "touch invalid fid should fail."
9651 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9652 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9653 error "touch non-normal fid should fail."
9655 echo "rename $tdir to $MOUNT/.lustre/fid"
9656 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9657 error "rename to $MOUNT/.lustre/fid should fail."
9659 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9661 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9662 local new_obf_mode=777
9664 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9665 chmod $new_obf_mode $DIR/.lustre/fid ||
9666 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9668 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9669 [ $obf_mode -eq $new_obf_mode ] ||
9670 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9672 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9673 chmod $old_obf_mode $DIR/.lustre/fid ||
9674 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9677 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9678 fid=$($LFS path2fid $test_dir/$tfile-2)
9680 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.50) ]
9682 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9683 cp /etc/passwd $MOUNT/.lustre/fid/$fid ||
9684 error "create lov data thru .lustre failed"
9686 echo "cp /etc/passwd $test_dir/$tfile-2"
9687 cp /etc/passwd $test_dir/$tfile-2 ||
9688 error "copy to $test_dir/$tfile-2 failed."
9689 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9690 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9691 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9693 rm -rf $test_dir/tfile.lnk
9694 rm -rf $test_dir/$tfile-2
9698 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9699 skip "Need MDS version at least 2.4.1" && return
9702 local FID=$($LFS path2fid $DIR/$tfile)
9703 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9705 # check that we get the same pathname back
9706 local FOUND=$($LFS fid2path $MOUNT "$FID")
9707 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9708 [ "$FOUND" != "$DIR/$tfile" ] &&
9709 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9713 run_test 154A "lfs path2fid and fid2path basic checks"
9716 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9717 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9718 { skip "Need MDS version at least 2.2.51"; return 0; }
9719 [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
9721 cp /etc/hosts $DIR/$tfile
9723 fid=$($LFS path2fid $DIR/$tfile)
9725 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9727 dot_lustre_fid_permission_check "$fid" $DIR ||
9728 error "dot lustre permission check $fid failed"
9730 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9732 touch $MOUNT/.lustre/file &&
9733 error "creation is not allowed under .lustre"
9735 mkdir $MOUNT/.lustre/dir &&
9736 error "mkdir is not allowed under .lustre"
9740 run_test 154a "Open-by-FID"
9743 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9744 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9745 { skip "Need MDS version at least 2.2.51"; return 0; }
9747 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9749 local remote_dir=$DIR/$tdir/remote_dir
9754 $LFS mkdir -i $MDTIDX $remote_dir ||
9755 error "create remote directory failed"
9757 cp /etc/hosts $remote_dir/$tfile
9759 fid=$($LFS path2fid $remote_dir/$tfile)
9761 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9763 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9764 error "dot lustre permission check $fid failed"
9767 run_test 154b "Open-by-FID for remote directory"
9770 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9771 skip "Need MDS version at least 2.4.1" && return
9773 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9774 local FID1=$($LFS path2fid $DIR/$tfile.1)
9775 local FID2=$($LFS path2fid $DIR/$tfile.2)
9776 local FID3=$($LFS path2fid $DIR/$tfile.3)
9779 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9780 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9781 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9783 [ "$FID" = "${!want}" ] ||
9784 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9788 $LFS fid2path $MOUNT "$FID1" "$FID2" "$FID3" | while read PATHNAME;
9790 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9791 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9795 run_test 154c "lfs path2fid and fid2path multiple arguments"
9798 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9799 skip "Need MDS version at least 2.5.53" && return
9802 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9806 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9813 local fid=$($LFS path2fid $DIR/$tfile)
9816 cmd="exec $fd<$DIR/$tfile"
9818 local fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9819 echo "$fid_list" | grep "$fid"
9822 cmd="exec $fd>/dev/null"
9824 if [ $rc -ne 0 ]; then
9825 error "FID $fid not found in open files list $fid_list"
9828 run_test 154d "Verify open file fid"
9832 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
9833 skip "Need MDS version at least 2.6.50" && return
9835 if ls -a $MOUNT | grep -q '^\.lustre$'; then
9836 error ".lustre returned by readdir"
9839 run_test 154e ".lustre is not returned by readdir"
9842 # create parent directory on a single MDT to avoid cross-MDT hardlinks
9843 test_mkdir -p -c1 $DIR/$tdir/d
9844 # test dirs inherit from its stripe
9845 mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
9846 mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
9847 cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
9848 ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
9851 # get fid of parents
9852 local FID0=$($LFS path2fid $DIR/$tdir/d)
9853 local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
9854 local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
9855 local FID3=$($LFS path2fid $DIR)
9857 # check that path2fid --parents returns expected <parent_fid>/name
9858 # 1) test for a directory (single parent)
9859 local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
9860 [ "$parent" == "$FID0/foo1" ] ||
9861 error "expected parent: $FID0/foo1, got: $parent"
9863 # 2) test for a file with nlink > 1 (multiple parents)
9864 parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
9865 echo "$parent" | grep -F "$FID1/$tfile" ||
9866 error "$FID1/$tfile not returned in parent list"
9867 echo "$parent" | grep -F "$FID2/link" ||
9868 error "$FID2/link not returned in parent list"
9870 # 3) get parent by fid
9871 local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
9872 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9873 echo "$parent" | grep -F "$FID1/$tfile" ||
9874 error "$FID1/$tfile not returned in parent list (by fid)"
9875 echo "$parent" | grep -F "$FID2/link" ||
9876 error "$FID2/link not returned in parent list (by fid)"
9878 # 4) test for entry in root directory
9879 parent=$($LFS path2fid --parents $DIR/f)
9880 echo "$parent" | grep -F "$FID3/f" ||
9881 error "$FID3/f not returned in parent list"
9883 # 5) test it on root directory
9884 [ -z "$($LFS path2fid --parents $MOUNT 2>/dev/null)" ] ||
9885 error "$MOUNT should not have parents"
9887 # enable xattr caching and check that linkea is correctly updated
9888 local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
9889 save_lustre_params client "llite.*.xattr_cache" > $save
9890 lctl set_param llite.*.xattr_cache 1
9892 # 6.1) linkea update on rename
9893 mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
9895 # get parents by fid
9896 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9897 # foo1 should no longer be returned in parent list
9898 echo "$parent" | grep -F "$FID1" &&
9899 error "$FID1 should no longer be in parent list"
9900 # the new path should appear
9901 echo "$parent" | grep -F "$FID2/$tfile.moved" ||
9902 error "$FID2/$tfile.moved is not in parent list"
9904 # 6.2) linkea update on unlink
9905 rm -f $DIR/$tdir/d/foo2/link
9906 parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
9907 # foo2/link should no longer be returned in parent list
9908 echo "$parent" | grep -F "$FID2/link" &&
9909 error "$FID2/link should no longer be in parent list"
9913 restore_lustre_params < $save
9915 run_test 154f "get parent fids by reading link ea"
9919 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) ]] ||
9920 { skip "Need MDS version at least 2.6.92"; return 0; }
9923 llapi_fid_test -d $DIR/$tdir
9925 run_test 154g "various llapi FID tests"
9927 test_155_small_load() {
9928 local temp=$TMP/$tfile
9929 local file=$DIR/$tfile
9931 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9932 error "dd of=$temp bs=6096 count=1 failed"
9934 cancel_lru_locks osc
9935 cmp $temp $file || error "$temp $file differ"
9937 $TRUNCATE $temp 6000
9938 $TRUNCATE $file 6000
9939 cmp $temp $file || error "$temp $file differ (truncate1)"
9941 echo "12345" >>$temp
9942 echo "12345" >>$file
9943 cmp $temp $file || error "$temp $file differ (append1)"
9945 echo "12345" >>$temp
9946 echo "12345" >>$file
9947 cmp $temp $file || error "$temp $file differ (append2)"
9953 test_155_big_load() {
9954 remote_ost_nodsh && skip "remote OST with nodsh" && return
9955 local temp=$TMP/$tfile
9956 local file=$DIR/$tfile
9959 local cache_size=$(do_facet ost$((MAXI+1)) \
9960 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9961 local large_file_size=$((cache_size * 2))
9963 echo "OSS cache size: $cache_size KB"
9964 echo "Large file size: $large_file_size KB"
9966 [ $MAXV -le $large_file_size ] && \
9967 skip_env "max available OST size needs > $large_file_size KB" && \
9970 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9972 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9973 error "dd of=$temp bs=$large_file_size count=1k failed"
9976 cancel_lru_locks osc
9977 cmp $temp $file || error "$temp $file differ"
9984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9986 set_cache writethrough on
9989 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9994 set_cache writethrough off
9997 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
10000 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10002 set_cache writethrough on
10003 test_155_small_load
10005 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
10008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10010 set_cache writethrough off
10011 test_155_small_load
10013 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
10016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10018 set_cache writethrough on
10021 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
10024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10026 set_cache writethrough off
10029 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
10032 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10034 set_cache writethrough on
10037 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
10040 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10042 set_cache writethrough off
10045 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
10048 remote_ost_nodsh && skip "remote OST with nodsh" && return
10049 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10053 local file="$DIR/$tfile"
10055 [ "$(facet_fstype ost1)" = "zfs" ] &&
10056 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
10061 log "Turn on read and write cache"
10063 set_cache writethrough on
10065 log "Write data and read it back."
10066 log "Read should be satisfied from the cache."
10067 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10069 cancel_lru_locks osc
10070 cat $file >/dev/null
10072 if ! let "AFTER - BEFORE == CPAGES"; then
10073 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10075 log "cache hits:: before: $BEFORE, after: $AFTER"
10078 log "Read again; it should be satisfied from the cache."
10080 cancel_lru_locks osc
10081 cat $file >/dev/null
10083 if ! let "AFTER - BEFORE == CPAGES"; then
10084 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10086 log "cache hits:: before: $BEFORE, after: $AFTER"
10090 log "Turn off the read cache and turn on the write cache"
10092 set_cache writethrough on
10094 log "Read again; it should be satisfied from the cache."
10096 cancel_lru_locks osc
10097 cat $file >/dev/null
10099 if ! let "AFTER - BEFORE == CPAGES"; then
10100 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10102 log "cache hits:: before: $BEFORE, after: $AFTER"
10105 log "Read again; it should not be satisfied from the cache."
10107 cancel_lru_locks osc
10108 cat $file >/dev/null
10110 if ! let "AFTER - BEFORE == 0"; then
10111 error "IN CACHE: before: $BEFORE, after: $AFTER"
10113 log "cache hits:: before: $BEFORE, after: $AFTER"
10116 log "Write data and read it back."
10117 log "Read should be satisfied from the cache."
10118 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10120 cancel_lru_locks osc
10121 cat $file >/dev/null
10123 if ! let "AFTER - BEFORE == CPAGES"; then
10124 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10126 log "cache hits:: before: $BEFORE, after: $AFTER"
10129 log "Read again; it should not be satisfied from the cache."
10131 cancel_lru_locks osc
10132 cat $file >/dev/null
10134 if ! let "AFTER - BEFORE == 0"; then
10135 error "IN CACHE: before: $BEFORE, after: $AFTER"
10137 log "cache hits:: before: $BEFORE, after: $AFTER"
10141 log "Turn off read and write cache"
10143 set_cache writethrough off
10145 log "Write data and read it back"
10146 log "It should not be satisfied from the cache."
10148 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10149 cancel_lru_locks osc
10151 cat $file >/dev/null
10153 if ! let "AFTER - BEFORE == 0"; then
10154 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10156 log "cache hits:: before: $BEFORE, after: $AFTER"
10159 log "Turn on the read cache and turn off the write cache"
10161 set_cache writethrough off
10163 log "Write data and read it back"
10164 log "It should not be satisfied from the cache."
10166 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
10168 cancel_lru_locks osc
10169 cat $file >/dev/null
10171 if ! let "AFTER - BEFORE == 0"; then
10172 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
10174 log "cache hits:: before: $BEFORE, after: $AFTER"
10177 log "Read again; it should be satisfied from the cache."
10179 cancel_lru_locks osc
10180 cat $file >/dev/null
10182 if ! let "AFTER - BEFORE == CPAGES"; then
10183 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
10185 log "cache hits:: before: $BEFORE, after: $AFTER"
10190 run_test 156 "Verification of tunables ============================"
10194 if [[ $MDSCOUNT -gt 1 ]]; then
10195 error_ignore bz17935 $*
10203 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
10205 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
10207 if [ $MASK -eq 1 ]; then
10208 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
10210 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
10214 changelog_extract_field() {
10218 local identifier=$4
10220 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
10221 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
10226 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10227 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10228 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10229 { skip "Need MDS version at least 2.2.0"; return; }
10231 local CL_USERS="mdd.$MDT0.changelog_users"
10232 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10233 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10234 echo "Registered as changelog user $USER"
10235 $GET_CL_USERS | grep -q $USER ||
10236 error "User $USER not found in changelog_users"
10239 test_mkdir -p $DIR/$tdir/pics/2008/zachy
10240 touch $DIR/$tdir/pics/2008/zachy/timestamp
10241 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
10242 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
10243 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
10244 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
10245 rm $DIR/$tdir/pics/desktop.jpg
10247 $LFS changelog $MDT0 | tail -5
10249 echo "verifying changelog mask"
10250 changelog_chmask "MKDIR"
10251 changelog_chmask "CLOSE"
10253 test_mkdir -p $DIR/$tdir/pics/zach/sofia
10254 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10256 changelog_chmask "MKDIR"
10257 changelog_chmask "CLOSE"
10259 test_mkdir -p $DIR/$tdir/pics/2008/sofia
10260 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
10262 $LFS changelog $MDT0
10263 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
10264 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
10265 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
10266 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
10269 echo "verifying target fid"
10270 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
10271 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
10272 [ "$fidc" == "$fidf" ] ||
10273 err17935 "fid in changelog $fidc != file fid $fidf"
10274 echo "verifying parent fid"
10275 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
10276 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
10277 [ "$fidc" == "$fidf" ] ||
10278 err17935 "pfid in changelog $fidc != dir fid $fidf"
10280 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10281 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
10282 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
10283 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
10284 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
10285 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
10287 MIN_REC=$($GET_CL_USERS |
10288 awk 'min == "" || $2 < min {min = $2}; END {print min}')
10289 FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
10290 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
10291 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
10292 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
10294 # LU-3446 changelog index reset on MDT restart
10295 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10296 CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10297 $LFS changelog_clear $MDT0 $USER 0
10298 stop $SINGLEMDS || error "Fail to stop MDT."
10299 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
10300 CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10301 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
10302 [ $CUR_REC1 == $CUR_REC2 ] ||
10303 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
10305 echo "verifying user deregister"
10306 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10307 $GET_CL_USERS | grep -q $USER &&
10308 error "User $USER still in changelog_users"
10310 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
10311 if [ $USERS -eq 0 ]; then
10312 LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10313 touch $DIR/$tdir/chloe
10314 LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
10315 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
10316 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
10318 echo "$USERS other changelog users; can't verify off"
10321 run_test 160a "changelog sanity"
10323 test_160b() { # LU-3587
10324 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10325 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10326 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
10327 { skip "Need MDS version at least 2.2.0"; return; }
10329 local CL_USERS="mdd.$MDT0.changelog_users"
10330 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
10331 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
10332 echo "Registered as changelog user $USER"
10333 $GET_CL_USERS | grep -q $USER ||
10334 error "User $USER not found in changelog_users"
10336 local LONGNAME1=$(str_repeat a 255)
10337 local LONGNAME2=$(str_repeat b 255)
10340 echo "creating very long named file"
10341 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
10342 echo "moving very long named file"
10343 mv $LONGNAME1 $LONGNAME2
10345 $LFS changelog $MDT0 | grep RENME
10347 echo "deregistering $USER"
10348 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10352 run_test 160b "Verify that very long rename doesn't crash in changelog"
10356 local server_version=$(lustre_version_code $SINGLEMDS)
10358 [[ $server_version -gt $(version_code 2.5.57) ]] ||
10359 [[ $server_version -gt $(version_code 2.5.1) &&
10360 $server_version -lt $(version_code 2.5.50) ]] ||
10361 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
10362 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10364 # Registration step
10365 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10366 changelog_register -n)
10369 mkdir -p $DIR/$tdir
10370 $MCREATE $DIR/$tdir/foo_160c
10371 changelog_chmask "TRUNC"
10372 $TRUNCATE $DIR/$tdir/foo_160c 200
10373 changelog_chmask "TRUNC"
10374 $TRUNCATE $DIR/$tdir/foo_160c 199
10375 $LFS changelog $MDT0
10376 TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
10377 [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
10378 $LFS changelog_clear $MDT0 $USER 0
10380 # Deregistration step
10381 echo "deregistering $USER"
10382 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10384 run_test 160c "verify that changelog log catch the truncate event"
10387 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10388 test_mkdir -p -c1 $DIR/$tdir
10389 cp /etc/hosts $DIR/$tdir/$tfile
10390 test_mkdir -c1 $DIR/$tdir/foo1
10391 test_mkdir -c1 $DIR/$tdir/foo2
10392 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
10393 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
10394 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
10395 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
10396 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
10397 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10398 $LFS fid2path $DIR $FID
10399 err17935 "bad link ea"
10402 rm $DIR/$tdir/foo2/zachary
10404 rm $DIR/$tdir/foo2/thor
10406 rm $DIR/$tdir/$tfile
10408 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
10409 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
10411 $LFS fid2path $DIR $FID
10412 err17935 "bad link rename"
10414 rm $DIR/$tdir/foo2/maggie
10417 local longname=filename_avg_len_is_thirty_two_
10418 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
10419 error "failed to hardlink many files"
10420 links=$($LFS fid2path $DIR $FID | wc -l)
10421 echo -n "${links}/1000 links in link EA"
10422 [[ $links -gt 60 ]] ||
10423 err17935 "expected at least 60 links in link EA"
10424 unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
10425 error "failed to unlink many hardlinks"
10427 run_test 161a "link ea sanity"
10430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10431 [ $MDSCOUNT -lt 2 ] &&
10432 skip "skipping remote directory test" && return
10434 local remote_dir=$DIR/$tdir/remote_dir
10436 mkdir -p $DIR/$tdir
10437 $LFS mkdir -i $MDTIDX $remote_dir ||
10438 error "create remote directory failed"
10440 cp /etc/hosts $remote_dir/$tfile
10441 mkdir -p $remote_dir/foo1
10442 mkdir -p $remote_dir/foo2
10443 ln $remote_dir/$tfile $remote_dir/foo1/sofia
10444 ln $remote_dir/$tfile $remote_dir/foo2/zachary
10445 ln $remote_dir/$tfile $remote_dir/foo1/luna
10446 ln $remote_dir/$tfile $remote_dir/foo2/thor
10448 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
10450 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
10451 $LFS fid2path $DIR $FID
10452 err17935 "bad link ea"
10455 rm $remote_dir/foo2/zachary
10457 rm $remote_dir/foo2/thor
10459 rm $remote_dir/$tfile
10461 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
10462 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
10463 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
10464 $LFS fid2path $DIR $FID
10465 err17935 "bad link rename"
10467 rm $remote_dir/foo2/maggie
10470 local longname=filename_avg_len_is_thirty_two_
10471 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
10472 error "failed to hardlink many files"
10473 links=$($LFS fid2path $DIR $FID | wc -l)
10474 echo -n "${links}/1000 links in link EA"
10475 [[ ${links} -gt 60 ]] ||
10476 err17935 "expected at least 60 links in link EA"
10477 unlinkmany $remote_dir/foo2/$longname 1000 ||
10478 error "failed to unlink many hardlinks"
10480 run_test 161b "link ea sanity under remote directory"
10483 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10484 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10485 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
10486 skip "Need MDS version at least 2.1.5" && return
10488 # define CLF_RENAME_LAST 0x0001
10489 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
10490 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
10491 changelog_register -n)
10493 mkdir -p $DIR/$tdir
10494 touch $DIR/$tdir/foo_161c
10495 touch $DIR/$tdir/bar_161c
10496 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10497 $LFS changelog $MDT0 | grep RENME
10498 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
10500 $LFS changelog_clear $MDT0 $USER 0
10501 if [ x$flags != "x0x1" ]; then
10502 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10504 error "flag $flags is not 0x1"
10506 echo "rename overwrite a target having nlink = 1," \
10507 "changelog record has flags of $flags"
10509 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
10510 touch $DIR/$tdir/foo_161c
10511 touch $DIR/$tdir/bar_161c
10512 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10513 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
10514 $LFS changelog $MDT0 | grep RENME
10515 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10516 $LFS changelog_clear $MDT0 $USER 0
10517 if [ x$flags != "x0x0" ]; then
10518 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10520 error "flag $flags is not 0x0"
10522 echo "rename overwrite a target having nlink > 1," \
10523 "changelog record has flags of $flags"
10525 # rename doesn't overwrite a target (changelog flag 0x0)
10526 touch $DIR/$tdir/foo_161c
10527 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
10528 $LFS changelog $MDT0 | grep RENME
10529 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
10530 $LFS changelog_clear $MDT0 $USER 0
10531 if [ x$flags != "x0x0" ]; then
10532 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10534 error "flag $flags is not 0x0"
10536 echo "rename doesn't overwrite a target," \
10537 "changelog record has flags of $flags"
10539 # define CLF_UNLINK_LAST 0x0001
10540 # unlink a file having nlink = 1 (changelog flag 0x1)
10541 rm -f $DIR/$tdir/foo2_161c
10542 $LFS changelog $MDT0 | grep UNLNK
10543 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10544 $LFS changelog_clear $MDT0 $USER 0
10545 if [ x$flags != "x0x1" ]; then
10546 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10548 error "flag $flags is not 0x1"
10550 echo "unlink a file having nlink = 1," \
10551 "changelog record has flags of $flags"
10553 # unlink a file having nlink > 1 (changelog flag 0x0)
10554 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
10555 rm -f $DIR/$tdir/foobar_161c
10556 $LFS changelog $MDT0 | grep UNLNK
10557 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
10558 $LFS changelog_clear $MDT0 $USER 0
10559 if [ x$flags != "x0x0" ]; then
10560 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
10562 error "flag $flags is not 0x0"
10564 echo "unlink a file having nlink > 1," \
10565 "changelog record has flags of $flags"
10566 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
10568 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
10575 local path=$(${LFS} fid2path $*)
10576 # Remove the '//' indicating a remote directory
10577 path=$(echo $path | sed 's#//#/#g')
10580 if [ $RC -ne 0 ]; then
10581 err17935 "path looked up of $expected failed. Error $RC"
10583 elif [ "${path}" != "${expected}" ]; then
10584 err17935 "path looked up \"${path}\" instead of \"${expected}\""
10587 echo "fid $fid resolves to path $path (expected $expected)"
10591 # Make changes to filesystem
10592 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10593 test_mkdir -p -c1 $DIR/$tdir/d2
10594 touch $DIR/$tdir/d2/$tfile
10595 touch $DIR/$tdir/d2/x1
10596 touch $DIR/$tdir/d2/x2
10597 test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
10598 test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
10600 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
10601 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
10602 error "check path $tdir/d2/$tfile failed"
10605 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
10606 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
10607 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
10608 error "check path $tdir/d2/p/q/r/slink failed"
10610 # softlink to wrong file
10611 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
10612 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
10613 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
10614 error "check path $tdir/d2/p/q/r/slink.wrong failed"
10617 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
10618 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
10619 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
10620 # fid2path dir/fsname should both work
10621 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
10622 error "check path $tdir/d2/a/b/c/new_file failed"
10623 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
10624 error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
10626 # hardlink count: check that there are 2 links
10627 # Doesnt work with CMD yet: 17935
10628 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
10629 err17935 "expected 2 links"
10631 # hardlink indexing: remove the first link
10632 rm $DIR/$tdir/d2/p/q/r/hlink
10633 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
10634 error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
10638 run_test 162 "path lookup sanity"
10641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10642 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10645 $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
10646 error "create striped dir failed"
10648 local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
10649 tail -n 1 | awk '{print $2}')
10650 stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
10652 touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
10653 mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
10656 for ((i=0;i<5;i++)); do
10657 FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
10658 error "get fid for f$i failed"
10659 check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
10660 error "check path $tdir/striped_dir/f$i failed"
10662 FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
10663 error "get fid for d$i failed"
10664 check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
10665 error "check path $tdir/striped_dir/d$i failed"
10670 run_test 162b "striped directory path lookup sanity"
10672 # LU-4239: Verify fid2path works with paths 100 or more directories deep
10674 test_mkdir $DIR/$tdir.local
10675 test_mkdir $DIR/$tdir.remote
10676 local lpath=$tdir.local
10677 local rpath=$tdir.remote
10679 for ((i = 0; i <= 101; i++)); do
10682 FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
10683 error "get fid for local directory $DIR/$lpath failed"
10684 check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
10685 error "check path for local directory $DIR/$lpath failed"
10688 test_mkdir $DIR/$rpath
10689 FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
10690 error "get fid for remote directory $DIR/$rpath failed"
10691 check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
10692 error "check path for remote directory $DIR/$rpath failed"
10697 run_test 162c "fid2path works with paths 100 or more directories deep"
10700 # do directio so as not to populate the page cache
10701 log "creating a 10 Mb file"
10702 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10703 log "starting reads"
10704 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10705 log "truncating the file"
10706 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10708 kill %+ || true # reads might have finished
10709 echo "wait until dd is finished"
10711 log "removing the temporary file"
10712 rm -rf $DIR/$tfile || error "tmp file removal failed"
10714 run_test 169 "parallel read and truncate should not deadlock"
10717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10718 $LCTL clear # bug 18514
10719 $LCTL debug_daemon start $TMP/${tfile}_log_good
10721 $LCTL debug_daemon stop
10722 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
10723 error "sed failed to read log_good"
10725 $LCTL debug_daemon start $TMP/${tfile}_log_good
10727 $LCTL debug_daemon stop
10729 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
10730 error "lctl df log_bad failed"
10732 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10733 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10735 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
10736 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
10738 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
10739 error "bad_line good_line1 good_line2 are empty"
10741 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10742 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
10743 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
10745 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
10746 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
10747 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
10749 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
10750 error "bad_line_new good_line_new are empty"
10752 local expected_good=$((good_line1 + good_line2*2))
10754 rm -f $TMP/${tfile}*
10755 # LU-231, short malformed line may not be counted into bad lines
10756 if [ $bad_line -ne $bad_line_new ] &&
10757 [ $bad_line -ne $((bad_line_new - 1)) ]; then
10758 error "expected $bad_line bad lines, but got $bad_line_new"
10762 if [ $expected_good -ne $good_line_new ]; then
10763 error "expected $expected_good good lines, but got $good_line_new"
10768 run_test 170 "test lctl df to handle corrupted log ====================="
10770 test_171() { # bug20592
10771 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10772 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
10773 $LCTL set_param fail_loc=0x50e
10774 $LCTL set_param fail_val=3000
10775 multiop_bg_pause $DIR/$tfile O_s || true
10777 kill -USR1 $MULTIPID
10781 if dmesg | grep "recursive fault"; then
10782 error "caught a recursive fault"
10784 $LCTL set_param fail_loc=0
10787 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10789 # it would be good to share it with obdfilter-survey/iokit-libecho code
10790 setup_obdecho_osc () {
10793 local obdfilter_name=$2
10794 echo "Creating new osc for $obdfilter_name on $ost_nid"
10795 # make sure we can find loopback nid
10796 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10798 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10799 ${obdfilter_name}_osc_UUID || rc=2; }
10800 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10801 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10805 cleanup_obdecho_osc () {
10806 local obdfilter_name=$1
10807 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10808 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10815 local pages=${3:-64}
10820 local obd_size=$(get_obd_size $node $OBD)
10821 local page_size=$(get_page_size $node)
10822 if [[ -n "$obd_size" ]]; then
10823 local new_count=$((obd_size / (pages * page_size / 1024)))
10824 [[ $new_count -ge $count ]] || count=$new_count
10827 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10828 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10830 if [ $rc -eq 0 ]; then
10831 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10832 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10834 echo "New object id is $id"
10835 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10837 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10838 "test_brw $count w v $pages $id" || rc=4; }
10839 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10841 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10842 "cleanup" || rc=5; }
10843 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10844 "detach" || rc=6; }
10845 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10850 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10851 remote_ost_nodsh && skip "remote OST with nodsh" && return
10853 local rmmod_local=0
10855 if ! module_loaded obdecho; then
10856 load_module obdecho/obdecho
10860 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10861 local host=$(lctl get_param -n osc.$osc.import |
10862 awk '/current_connection:/ {print $2}' )
10863 local target=$(lctl get_param -n osc.$osc.import |
10864 awk '/target:/ {print $2}' )
10865 target=${target%_UUID}
10867 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10868 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10869 [[ -n $target ]] && cleanup_obdecho_osc $target
10870 [ $rmmod_local -eq 1 ] && rmmod obdecho
10873 run_test 180a "test obdecho on osc"
10876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10877 remote_ost_nodsh && skip "remote OST with nodsh" && return
10879 local rmmod_remote=0
10881 do_facet ost1 "lsmod | grep -q obdecho || " \
10882 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10883 "modprobe obdecho; }" && rmmod_remote=1
10884 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10885 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10886 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10889 run_test 180b "test obdecho directly on obdfilter"
10891 test_180c() { # LU-2598
10892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10893 remote_ost_nodsh && skip "remote OST with nodsh" && return
10894 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10895 skip "Need MDS version at least 2.4.0" && return
10898 local rmmod_remote=false
10899 local pages=16384 # 64MB bulk I/O RPC size
10902 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10903 rmmod_remote=true || error "failed to load module obdecho"
10905 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
10907 if [ -n "$target" ]; then
10908 obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
10910 echo "there is no obdfilter target on ost1"
10913 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10916 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10918 test_181() { # bug 22177
10919 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10920 # create enough files to index the directory
10921 createmany -o $DIR/$tdir/foobar 4000
10922 # print attributes for debug purpose
10925 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10927 # remove the files & current working dir
10928 unlinkmany $DIR/$tdir/foobar 4000
10930 kill -USR1 $MULTIPID
10932 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10935 run_test 181 "Test open-unlinked dir ========================"
10938 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10939 # disable MDC RPC lock wouldn't crash client
10943 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10944 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10945 $LCTL set_param fail_loc=0x804
10947 for (( i=0; i < $tcount; i++ )) ; do
10948 mkdir $DIR/$tdir/$i
10949 createmany -o $DIR/$tdir/$i/f- $fcount &
10953 for (( i=0; i < $tcount; i++ )) ; do
10954 unlinkmany $DIR/$tdir/$i/f- $fcount &
10960 $LCTL set_param fail_loc=0
10962 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10964 test_183() { # LU-2275
10965 remote_mds_nodsh && skip "remote MDS with nodsh" && return
10966 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10967 skip "Need MDS version at least 2.3.56" && return
10969 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10970 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10971 echo aaa > $DIR/$tdir/$tfile
10973 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10974 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10976 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10977 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10979 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10981 # Flush negative dentry cache
10982 touch $DIR/$tdir/$tfile
10984 # We are not checking for any leaked references here, they'll
10985 # become evident next time we do cleanup with module unload.
10988 run_test 183 "No crash or request leak in case of strange dispositions ========"
10990 # test suite 184 is for LU-2016, LU-2017
10992 check_swap_layouts_support && return 0
10994 dir0=$DIR/$tdir/$testnum
10995 test_mkdir -p -c1 $dir0 || error "creating dir $dir0"
11000 $SETSTRIPE -c1 $file1
11002 $SETSTRIPE -c2 $file2
11004 gen1=$($GETSTRIPE -g $file1)
11005 gen2=$($GETSTRIPE -g $file2)
11007 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
11008 gen=$($GETSTRIPE -g $file1)
11009 [[ $gen1 != $gen ]] ||
11010 "Layout generation on $file1 does not change"
11011 gen=$($GETSTRIPE -g $file2)
11012 [[ $gen2 != $gen ]] ||
11013 "Layout generation on $file2 does not change"
11015 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
11016 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11018 run_test 184a "Basic layout swap"
11021 check_swap_layouts_support && return 0
11023 dir0=$DIR/$tdir/$testnum
11024 mkdir -p $dir0 || error "creating dir $dir0"
11031 $SETSTRIPE -c1 $file1
11032 $SETSTRIPE -c2 $file2
11033 $SETSTRIPE -c1 $file3
11034 chown $RUNAS_ID $file3
11035 gen1=$($GETSTRIPE -g $file1)
11036 gen2=$($GETSTRIPE -g $file2)
11038 $LFS swap_layouts $dir1 $dir2 &&
11039 error "swap of directories layouts should fail"
11040 $LFS swap_layouts $dir1 $file1 &&
11041 error "swap of directory and file layouts should fail"
11042 $RUNAS $LFS swap_layouts $file1 $file2 &&
11043 error "swap of file we cannot write should fail"
11044 $LFS swap_layouts $file1 $file3 &&
11045 error "swap of file with different owner should fail"
11046 /bin/true # to clear error code
11048 run_test 184b "Forbidden layout swap (will generate errors)"
11051 check_swap_layouts_support && return 0
11053 local dir0=$DIR/$tdir/$testnum
11054 mkdir -p $dir0 || error "creating dir $dir0"
11056 local ref1=$dir0/ref1
11057 local ref2=$dir0/ref2
11058 local file1=$dir0/file1
11059 local file2=$dir0/file2
11060 # create a file large enough for the concurent test
11061 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
11062 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
11063 echo "ref file size: ref1($(stat -c %s $ref1))," \
11064 "ref2($(stat -c %s $ref2))"
11067 dd if=$ref1 of=$file1 bs=16k &
11070 # Make sure dd starts to copy file
11071 while [ ! -f $file1 ]; do sleep 0.1; done
11073 $LFS swap_layouts $file1 $file2
11076 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
11077 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
11079 # how many bytes copied before swapping layout
11080 local copied=$(stat -c %s $file2)
11081 local remaining=$(stat -c %s $ref1)
11082 remaining=$((remaining - copied))
11083 echo "Copied $copied bytes before swapping layout..."
11085 cmp -n $copied $file1 $ref2 | grep differ &&
11086 error "Content mismatch [0, $copied) of ref2 and file1"
11087 cmp -n $copied $file2 $ref1 ||
11088 error "Content mismatch [0, $copied) of ref1 and file2"
11089 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
11090 error "Content mismatch [$copied, EOF) of ref1 and file1"
11093 rm -f $ref1 $ref2 $file1 $file2
11095 run_test 184c "Concurrent write and layout swap"
11098 check_swap_layouts_support && return 0
11099 [ -z "$(which getfattr 2>/dev/null)" ] &&
11100 skip "no getfattr command" && return 0
11102 local file1=$DIR/$tdir/$tfile-1
11103 local file2=$DIR/$tdir/$tfile-2
11104 local file3=$DIR/$tdir/$tfile-3
11108 mkdir -p $DIR/$tdir
11109 touch $file1 || error "create $file1 failed"
11110 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11111 error "create $file2 failed"
11112 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11113 error "create $file3 failed"
11114 lovea1=$($LFS getstripe $file1 | sed 1d)
11116 $LFS swap_layouts $file2 $file3 ||
11117 error "swap $file2 $file3 layouts failed"
11118 $LFS swap_layouts $file1 $file2 ||
11119 error "swap $file1 $file2 layouts failed"
11121 lovea2=$($LFS getstripe $file2 | sed 1d)
11122 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
11124 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11125 [[ -z "$lovea1" ]] || error "$file1 shouldn't have lovea"
11127 run_test 184d "allow stripeless layouts swap"
11130 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
11131 { skip "Need MDS version at least 2.6.94"; return 0; }
11132 check_swap_layouts_support && return 0
11133 [ -z "$(which getfattr 2>/dev/null)" ] &&
11134 skip "no getfattr command" && return 0
11136 local file1=$DIR/$tdir/$tfile-1
11137 local file2=$DIR/$tdir/$tfile-2
11138 local file3=$DIR/$tdir/$tfile-3
11141 mkdir -p $DIR/$tdir
11142 touch $file1 || error "create $file1 failed"
11143 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
11144 error "create $file2 failed"
11145 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
11146 error "create $file3 failed"
11148 $LFS swap_layouts $file1 $file2 ||
11149 error "swap $file1 $file2 layouts failed"
11151 lovea=$(getfattr -n trusted.lov $file1 | grep ^trusted)
11152 [[ -z "$lovea" ]] || error "$file1 shouldn't have lovea"
11154 echo 123 > $file1 || error "Should be able to write into $file1"
11156 $LFS swap_layouts $file1 $file3 ||
11157 error "swap $file1 $file3 layouts failed"
11159 echo 123 > $file1 || error "Should be able to write into $file1"
11161 rm -rf $file1 $file2 $file3
11163 run_test 184e "Recreate layout after stripeless layout swaps"
11165 test_185() { # LU-2441
11166 # LU-3553 - no volatile file support in old servers
11167 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
11168 { skip "Need MDS version at least 2.3.60"; return 0; }
11170 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
11171 touch $DIR/$tdir/spoo
11172 local mtime1=$(stat -c "%Y" $DIR/$tdir)
11173 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
11174 error "cannot create/write a volatile file"
11175 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
11176 error "FID is still valid after close"
11178 multiop_bg_pause $DIR/$tdir vVw4096_c
11185 # assume that the next FID for this client is sequential, since stdout
11186 # is unfortunately eaten by multiop_bg_pause
11187 local n=$((${fidv[1]} + 1))
11188 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
11189 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
11190 error "FID is missing before close"
11191 kill -USR1 $multi_pid
11192 # 1 second delay, so if mtime change we will see it
11194 local mtime2=$(stat -c "%Y" $DIR/$tdir)
11195 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
11197 run_test 185 "Volatile file support"
11200 local dir0=$DIR/$tdir/$testnum
11201 mkdir -p $dir0 || error "creating dir $dir0"
11203 local file=$dir0/file1
11204 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
11205 local dv1=$($LFS data_version $file)
11206 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
11207 local dv2=$($LFS data_version $file)
11208 [[ $dv1 != $dv2 ]] ||
11209 error "data version did not change on write $dv1 == $dv2"
11214 run_test 187a "Test data version change"
11217 local dir0=$DIR/$tdir/$testnum
11218 mkdir -p $dir0 || error "creating dir $dir0"
11220 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
11221 [[ ${DV[0]} != ${DV[1]} ]] ||
11222 error "data version did not change on write"\
11223 " ${DV[0]} == ${DV[1]}"
11228 run_test 187b "Test data version change on volatile file"
11231 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11232 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11234 local POOL=${POOL:-cea1}
11235 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
11236 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
11239 local last_ost=$(($OSTCOUNT - 1))
11241 local ost_list=$(seq $first_ost $ost_step $last_ost)
11242 local ost_range="$first_ost $last_ost $ost_step"
11243 local test_path=$POOL_ROOT/$POOL_DIR_NAME
11244 local file_dir=$POOL_ROOT/file_tst
11245 local subdir=$test_path/subdir
11249 # former test_200a test_200b
11250 pool_add $POOL || { rc=$? ; break; }
11251 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
11252 # former test_200c test_200d
11253 mkdir -p $test_path
11254 pool_set_dir $POOL $test_path || { rc=$? ; break; }
11255 pool_check_dir $POOL $test_path || { rc=$? ; break; }
11257 pool_check_dir $POOL $subdir || { rc=$? ; break; }
11258 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
11259 || { rc=$? ; break; }
11260 # former test_200e test_200f
11261 local files=$((OSTCOUNT*3))
11262 pool_alloc_files $POOL $test_path $files "$ost_list" \
11263 || { rc=$? ; break; }
11264 pool_create_files $POOL $file_dir $files "$ost_list" \
11265 || { rc=$? ; break; }
11266 # former test_200g test_200h
11267 pool_lfs_df $POOL || { rc=$? ; break; }
11268 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
11270 # former test_201a test_201b test_201c
11271 pool_remove_first_target $POOL || { rc=$? ; break; }
11273 local f=$test_path/$tfile
11274 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
11275 pool_remove $POOL $f || { rc=$? ; break; }
11282 run_test 200 "OST pools"
11284 # usage: default_attr <count | size | offset>
11286 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
11289 # usage: check_default_stripe_attr
11290 check_default_stripe_attr() {
11291 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
11293 --stripe-count|--count)
11294 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
11295 --stripe-size|--size)
11296 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
11297 --stripe-index|--index)
11300 error "unknown getstripe attr '$1'"
11303 [ $ACTUAL != $EXPECTED ] &&
11304 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
11308 test_mkdir -p $DIR/$tdir
11309 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
11311 check_default_stripe_attr --stripe-count
11312 check_default_stripe_attr --stripe-size
11313 check_default_stripe_attr --stripe-index
11317 run_test 204a "Print default stripe attributes ================="
11320 test_mkdir -p $DIR/$tdir
11321 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11323 check_default_stripe_attr --stripe-size
11324 check_default_stripe_attr --stripe-index
11328 run_test 204b "Print default stripe size and offset ==========="
11331 test_mkdir -p $DIR/$tdir
11332 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11334 check_default_stripe_attr --stripe-count
11335 check_default_stripe_attr --stripe-index
11339 run_test 204c "Print default stripe count and offset ==========="
11342 test_mkdir -p $DIR/$tdir
11343 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11345 check_default_stripe_attr --stripe-count
11346 check_default_stripe_attr --stripe-size
11350 run_test 204d "Print default stripe count and size ============="
11353 test_mkdir -p $DIR/$tdir
11354 $SETSTRIPE -d $DIR/$tdir
11356 check_default_stripe_attr --stripe-count --raw
11357 check_default_stripe_attr --stripe-size --raw
11358 check_default_stripe_attr --stripe-index --raw
11362 run_test 204e "Print raw stripe attributes ================="
11365 test_mkdir -p $DIR/$tdir
11366 $SETSTRIPE --stripe-count 1 $DIR/$tdir
11368 check_default_stripe_attr --stripe-size --raw
11369 check_default_stripe_attr --stripe-index --raw
11373 run_test 204f "Print raw stripe size and offset ==========="
11376 test_mkdir -p $DIR/$tdir
11377 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
11379 check_default_stripe_attr --stripe-count --raw
11380 check_default_stripe_attr --stripe-index --raw
11384 run_test 204g "Print raw stripe count and offset ==========="
11387 test_mkdir -p $DIR/$tdir
11388 $SETSTRIPE --stripe-index 0 $DIR/$tdir
11390 check_default_stripe_attr --stripe-count --raw
11391 check_default_stripe_attr --stripe-size --raw
11395 run_test 204h "Print raw stripe count and size ============="
11397 # Figure out which job scheduler is being used, if any,
11398 # or use a fake one
11399 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
11400 JOBENV=SLURM_JOB_ID
11401 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
11403 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
11405 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
11406 JOBENV=LOADL_STEP_ID
11407 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
11413 verify_jobstats() {
11417 # clear old jobstats
11418 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
11419 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
11421 # use a new JobID for this test, or we might see an old one
11422 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
11426 log "Using JobID environment variable $JOBENV=$JOBVAL"
11428 if [ $JOBENV = "FAKE_JOBID" ]; then
11429 FAKE_JOBID=$JOBVAL $cmd
11434 if [ "$target" = "mdt" -o "$target" = "both" ]; then
11435 FACET="$SINGLEMDS" # will need to get MDS number for DNE
11436 do_facet $FACET lctl get_param mdt.*.job_stats |
11437 grep $JOBVAL || error "No job stats found on MDT $FACET"
11439 if [ "$target" = "ost" -o "$target" = "both" ]; then
11441 do_facet $FACET lctl get_param obdfilter.*.job_stats |
11442 grep $JOBVAL || error "No job stats found on OST $FACET"
11448 NEW_JOBENV=${1:-$OLD_JOBENV}
11449 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
11450 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
11453 test_205() { # Job stats
11454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11455 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
11456 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
11457 skip "Server doesn't support jobstats" && return 0
11458 [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
11461 OLD_JOBENV=$($LCTL get_param -n jobid_var)
11462 if [ $OLD_JOBENV != $JOBENV ]; then
11463 jobstats_set $JOBENV
11464 trap jobstats_set EXIT
11467 local user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
11468 changelog_register -n)
11469 echo "Registered as changelog user $user"
11472 cmd="mkdir $DIR/$tfile"
11473 verify_jobstats "$cmd" "mdt"
11475 cmd="rm -fr $DIR/$tfile"
11476 verify_jobstats "$cmd" "mdt"
11478 cmd="mknod $DIR/$tfile c 1 3"
11479 verify_jobstats "$cmd" "mdt"
11481 cmd="rm -f $DIR/$tfile"
11482 verify_jobstats "$cmd" "mdt"
11484 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
11485 verify_jobstats "$cmd" "mdt"
11487 cmd="touch $DIR/$tfile"
11488 verify_jobstats "$cmd" "both"
11490 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
11491 verify_jobstats "$cmd" "ost"
11493 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
11494 verify_jobstats "$cmd" "ost"
11496 cmd="$TRUNCATE $DIR/$tfile 0"
11497 verify_jobstats "$cmd" "both"
11499 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
11500 verify_jobstats "$cmd" "mdt"
11502 # Ensure that jobid are present in changelog (if supported by MDS)
11503 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
11505 $LFS changelog $MDT0 | tail -9
11506 jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
11507 [ $jobids -eq 9 ] ||
11508 error "Wrong changelog jobid count $jobids != 9"
11512 jobstats_set $JOBENV
11514 $LFS changelog $MDT0 | tail -1
11515 jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
11516 [ $jobids -eq 0 ] ||
11517 error "Unexpected jobids when jobid_var=$JOBENV"
11521 rm -f $DIR/jobstats_test_rename
11523 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
11525 run_test 205 "Verify job stats"
11527 # LU-1480, LU-1773 and LU-1657
11529 mkdir -p $DIR/$tdir
11530 $SETSTRIPE -c -1 $DIR/$tdir
11531 #define OBD_FAIL_LOV_INIT 0x1403
11532 $LCTL set_param fail_loc=0xa0001403
11533 $LCTL set_param fail_val=1
11534 touch $DIR/$tdir/$tfile || true
11536 run_test 206 "fail lov_init_raid0() doesn't lbug"
11539 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11540 local fsz=`stat -c %s $DIR/$tfile`
11541 cancel_lru_locks mdc
11543 # do not return layout in getattr intent
11544 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
11545 $LCTL set_param fail_loc=0x170
11546 local sz=`stat -c %s $DIR/$tfile`
11548 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
11552 run_test 207a "can refresh layout at glimpse"
11555 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
11556 local cksum=`md5sum $DIR/$tfile`
11557 local fsz=`stat -c %s $DIR/$tfile`
11558 cancel_lru_locks mdc
11559 cancel_lru_locks osc
11561 # do not return layout in getattr intent
11562 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
11563 $LCTL set_param fail_loc=0x171
11565 # it will refresh layout after the file is opened but before read issues
11566 echo checksum is "$cksum"
11567 echo "$cksum" |md5sum -c --quiet || error "file differs"
11571 run_test 207b "can refresh layout at open"
11574 # FIXME: in this test suite, only RD lease is used. This is okay
11575 # for now as only exclusive open is supported. After generic lease
11576 # is done, this test suite should be revised. - Jinshan
11578 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
11579 { skip "Need MDS version at least 2.4.52"; return 0; }
11580 remote_mds_nodsh && skip "remote MDS with nodsh" && return
11582 echo "==== test 1: verify get lease work"
11583 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
11585 echo "==== test 2: verify lease can be broken by upcoming open"
11586 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11590 $MULTIOP $DIR/$tfile oO_RDONLY:c
11591 kill -USR1 $PID && wait $PID || error "break lease error"
11593 echo "==== test 3: verify lease can't be granted if an open already exists"
11594 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
11598 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
11599 kill -USR1 $PID && wait $PID || error "open file error"
11601 echo "==== test 4: lease can sustain over recovery"
11602 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11608 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11610 echo "==== test 5: lease broken can't be regained by replay"
11611 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11615 # open file to break lease and then recovery
11616 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11619 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11623 run_test 208 "Exclusive open"
11626 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11627 skip_env "must have disp_stripe" && return
11630 sync; sleep 5; sync;
11632 echo 3 > /proc/sys/vm/drop_caches
11633 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11635 # open/close 500 times
11636 for i in $(seq 500); do
11640 echo 3 > /proc/sys/vm/drop_caches
11641 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11643 echo "before: $req_before, after: $req_after"
11644 [ $((req_after - req_before)) -ge 300 ] &&
11645 error "open/close requests are not freed"
11648 run_test 209 "read-only open/close requests should be freed promptly"
11652 size=$((size % 8192 + 1))
11653 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11654 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11655 rm -f $DIR/f212 $DIR/f212.xyz
11657 run_test 212 "Sendfile test ============================================"
11660 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11661 cancel_lru_locks osc
11662 lctl set_param fail_loc=0x8000040f
11663 # generate a read lock
11664 cat $DIR/$tfile > /dev/null
11665 # write to the file, it will try to cancel the above read lock.
11666 cat /etc/hosts >> $DIR/$tfile
11668 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11670 test_214() { # for bug 20133
11671 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11672 for (( i=0; i < 340; i++ )) ; do
11673 touch $DIR/$tdir/d214c/a$i
11676 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11677 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11678 ls $DIR/d214c || error "ls $DIR/d214c failed"
11679 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11680 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11682 run_test 214 "hash-indexed directory test - bug 20133"
11684 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11685 create_lnet_proc_files() {
11686 lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
11687 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11689 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11690 rm -f "$TMP/lnet_$1.sys_tmp"
11693 # counterpart of create_lnet_proc_files
11694 remove_lnet_proc_files() {
11695 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11698 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11699 # 3rd arg as regexp for body
11700 check_lnet_proc_stats() {
11701 local l=$(cat "$TMP/lnet_$1" |wc -l)
11702 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11704 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11707 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11708 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11709 # optional and can be regexp for 2nd line (lnet.routes case)
11710 check_lnet_proc_entry() {
11711 local blp=2 # blp stands for 'position of 1st line of body'
11712 [ -z "$5" ] || blp=3 # lnet.routes case
11714 local l=$(cat "$TMP/lnet_$1" |wc -l)
11715 # subtracting one from $blp because the body can be empty
11716 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11718 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11719 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11721 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11722 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11724 # bail out if any unexpected line happened
11725 sed -n "$blp p" "$TMP/lnet_$1" | grep -Ev "$3"
11726 [ "$?" != 0 ] || error "$2 misformatted"
11729 test_215() { # for bugs 18102, 21079, 21517
11730 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11731 local N='(0|[1-9][0-9]*)' # non-negative numeric
11732 local P='[1-9][0-9]*' # positive numeric
11733 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11734 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11735 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11736 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11738 local L1 # regexp for 1st line
11739 local L2 # regexp for 2nd line (optional)
11740 local BR # regexp for the rest (body)
11742 # lnet.stats should look as 11 space-separated non-negative numerics
11743 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11744 create_lnet_proc_files "stats"
11745 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11746 remove_lnet_proc_files "stats"
11748 # lnet.routes should look like this:
11749 # Routing disabled/enabled
11750 # net hops priority state router
11751 # where net is a string like tcp0, hops > 0, priority >= 0,
11752 # state is up/down,
11753 # router is a string like 192.168.1.1@tcp2
11754 L1="^Routing (disabled|enabled)$"
11755 L2="^net +hops +priority +state +router$"
11756 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11757 create_lnet_proc_files "routes"
11758 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11759 remove_lnet_proc_files "routes"
11761 # lnet.routers should look like this:
11762 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11763 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11764 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11765 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11766 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11767 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11768 create_lnet_proc_files "routers"
11769 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11770 remove_lnet_proc_files "routers"
11772 # lnet.peers should look like this:
11773 # nid refs state last max rtr min tx min queue
11774 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11775 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11776 # numeric (0 or >0 or <0), queue >= 0.
11777 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11778 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11779 create_lnet_proc_files "peers"
11780 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11781 remove_lnet_proc_files "peers"
11783 # lnet.buffers should look like this:
11784 # pages count credits min
11785 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11786 L1="^pages +count +credits +min$"
11787 BR="^ +$N +$N +$I +$I$"
11788 create_lnet_proc_files "buffers"
11789 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11790 remove_lnet_proc_files "buffers"
11792 # lnet.nis should look like this:
11793 # nid status alive refs peer rtr max tx min
11794 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11795 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11796 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11797 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11798 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11799 create_lnet_proc_files "nis"
11800 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11801 remove_lnet_proc_files "nis"
11803 # can we successfully write to lnet.stats?
11804 lctl set_param -n stats=0 || error "cannot write to lnet.stats"
11805 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11807 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
11809 test_216() { # bug 20317
11810 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11811 remote_ost_nodsh && skip "remote OST with nodsh" && return
11814 local facets=$(get_facets OST)
11815 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11817 save_lustre_params client "osc.*.contention_seconds" > $p
11818 save_lustre_params $facets \
11819 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11820 save_lustre_params $facets \
11821 "ldlm.namespaces.filter-*.contended_locks" >> $p
11822 save_lustre_params $facets \
11823 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11826 # agressive lockless i/o settings
11827 for node in $(osts_nodes); do
11828 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'
11830 lctl set_param -n osc.*.contention_seconds 60
11832 $DIRECTIO write $DIR/$tfile 0 10 4096
11833 $CHECKSTAT -s 40960 $DIR/$tfile
11835 # disable lockless i/o
11836 for node in $(osts_nodes); do
11837 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'
11839 lctl set_param -n osc.*.contention_seconds 0
11842 dd if=/dev/zero of=$DIR/$tfile count=0
11843 $CHECKSTAT -s 0 $DIR/$tfile
11845 restore_lustre_params <$p
11849 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11851 test_217() { # bug 22430
11852 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11856 for node in $(nodes_list); do
11857 nid=$(host_nids_address $node $NETTYPE)
11858 if [[ $nid = *-* ]] ; then
11859 echo "lctl ping $nid@$NETTYPE"
11860 lctl ping $nid@$NETTYPE
11862 echo "skipping $node (no hyphen detected)"
11866 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11869 # do directio so as not to populate the page cache
11870 log "creating a 10 Mb file"
11871 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11872 log "starting reads"
11873 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11874 log "truncating the file"
11875 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11877 kill %+ || true # reads might have finished
11878 echo "wait until dd is finished"
11880 log "removing the temporary file"
11881 rm -rf $DIR/$tfile || error "tmp file removal failed"
11883 run_test 218 "parallel read and truncate should not deadlock ======================="
11886 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11887 # write one partial page
11888 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11889 # set no grant so vvp_io_commit_write will do sync write
11890 $LCTL set_param fail_loc=0x411
11891 # write a full page at the end of file
11892 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11894 $LCTL set_param fail_loc=0
11895 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11896 $LCTL set_param fail_loc=0x411
11897 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11900 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11901 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11903 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11905 test_220() { #LU-325
11906 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11907 remote_ost_nodsh && skip "remote OST with nodsh" && return
11910 test_mkdir -p $DIR/$tdir
11911 local OST=$($LFS osts | grep ${OSTIDX}": " | \
11912 awk '{print $2}' | sed -e 's/_UUID$//')
11915 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11916 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11917 osc.$mdtosc_proc1.prealloc_last_id)
11918 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11919 osc.$mdtosc_proc1.prealloc_next_id)
11923 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11924 #define OBD_FAIL_OST_ENOINO 0x229
11925 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11926 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11927 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11929 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11931 MDSOBJS=$((last_id - next_id))
11932 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11934 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11935 echo "OST still has $count kbytes free"
11937 echo "create $MDSOBJS files @next_id..."
11938 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11940 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11941 osc.$mdtosc_proc1.prealloc_last_id)
11942 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11943 osc.$mdtosc_proc1.prealloc_next_id)
11945 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11950 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11951 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11953 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11954 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11955 echo "unlink $MDSOBJS files @$next_id..."
11956 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11958 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11962 dd if=`which date` of=$MOUNT/date oflag=sync
11963 chmod +x $MOUNT/date
11965 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11966 $LCTL set_param fail_loc=0x80001401
11968 $MOUNT/date > /dev/null
11971 run_test 221 "make sure fault and truncate race to not cause OOM"
11974 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11976 test_mkdir -p $DIR/$tdir
11977 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11978 createmany -o $DIR/$tdir/$tfile 10
11979 cancel_lru_locks mdc
11980 cancel_lru_locks osc
11981 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11982 $LCTL set_param fail_loc=0x31a
11983 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11984 $LCTL set_param fail_loc=0
11987 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11992 test_mkdir -p $DIR/$tdir
11993 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11994 createmany -o $DIR/$tdir/$tfile 10
11995 cancel_lru_locks mdc
11996 cancel_lru_locks osc
11997 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11998 $LCTL set_param fail_loc=0x31a
11999 rm -r $DIR/$tdir || "AGL for rmdir failed"
12000 $LCTL set_param fail_loc=0
12002 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
12005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12007 test_mkdir -p $DIR/$tdir
12008 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
12009 createmany -o $DIR/$tdir/$tfile 10
12010 cancel_lru_locks mdc
12011 cancel_lru_locks osc
12012 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
12013 $LCTL set_param fail_loc=0x31b
12014 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
12015 $LCTL set_param fail_loc=0
12018 run_test 223 "osc reenqueue if without AGL lock granted ======================="
12020 test_224a() { # LU-1039, MRP-303
12021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12022 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
12023 $LCTL set_param fail_loc=0x508
12024 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
12025 $LCTL set_param fail_loc=0
12028 run_test 224a "Don't panic on bulk IO failure"
12030 test_224b() { # LU-1039, MRP-303
12031 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12032 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
12033 cancel_lru_locks osc
12034 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
12035 $LCTL set_param fail_loc=0x515
12036 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
12037 $LCTL set_param fail_loc=0
12040 run_test 224b "Don't panic on bulk IO failure"
12042 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
12044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12045 if [ -z ${MDSSURVEY} ]; then
12046 skip_env "mds-survey not found" && return
12049 [ $MDSCOUNT -ge 2 ] &&
12050 skip "skipping now for more than one MDT" && return
12052 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12053 { skip "Need MDS version at least 2.2.51"; return; }
12055 local mds=$(facet_host $SINGLEMDS)
12056 local target=$(do_nodes $mds 'lctl dl' | \
12057 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12059 local cmd1="file_count=1000 thrhi=4"
12060 local cmd2="dir_count=2 layer=mdd stripe_count=0"
12061 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12062 local cmd="$cmd1 $cmd2 $cmd3"
12064 rm -f ${TMP}/mds_survey*
12066 eval $cmd || error "mds-survey with zero-stripe failed"
12067 cat ${TMP}/mds_survey*
12068 rm -f ${TMP}/mds_survey*
12070 run_test 225a "Metadata survey sanity with zero-stripe"
12073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12075 if [ -z ${MDSSURVEY} ]; then
12076 skip_env "mds-survey not found" && return
12078 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
12079 { skip "Need MDS version at least 2.2.51"; return; }
12081 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
12082 skip_env "Need to mount OST to test" && return
12085 [ $MDSCOUNT -ge 2 ] &&
12086 skip "skipping now for more than one MDT" && return
12087 local mds=$(facet_host $SINGLEMDS)
12088 local target=$(do_nodes $mds 'lctl dl' | \
12089 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
12091 local cmd1="file_count=1000 thrhi=4"
12092 local cmd2="dir_count=2 layer=mdd stripe_count=1"
12093 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
12094 local cmd="$cmd1 $cmd2 $cmd3"
12096 rm -f ${TMP}/mds_survey*
12098 eval $cmd || error "mds-survey with stripe_count failed"
12099 cat ${TMP}/mds_survey*
12100 rm -f ${TMP}/mds_survey*
12102 run_test 225b "Metadata survey sanity with stripe_count = 1"
12104 mcreate_path2fid () {
12110 local path=$DIR/$tdir/$name
12115 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
12116 error "cannot create $desc"
12118 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
12120 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
12122 fid_path=$($LFS fid2path $MOUNT $fid)
12124 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
12126 [ "$path" == "$fid_path" ] ||
12127 error "fid2path returned $fid_path, expected $path"
12129 echo "pass with $path and $fid"
12134 mkdir -p $DIR/$tdir
12136 mcreate_path2fid 0010666 0 0 fifo "FIFO"
12137 mcreate_path2fid 0020666 1 3 null "character special file (null)"
12138 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
12139 mcreate_path2fid 0040666 0 0 dir "directory"
12140 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
12141 mcreate_path2fid 0100666 0 0 file "regular file"
12142 mcreate_path2fid 0120666 0 0 link "symbolic link"
12143 mcreate_path2fid 0140666 0 0 sock "socket"
12145 run_test 226a "call path2fid and fid2path on files of all type"
12148 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12152 mkdir -p $DIR/$tdir
12153 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
12154 error "create remote directory failed"
12155 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
12156 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
12157 "character special file (null)"
12158 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
12159 "character special file (no device)"
12160 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
12161 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
12162 "block special file (loop)"
12163 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
12164 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
12165 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
12167 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
12169 # LU-1299 Executing or running ldd on a truncated executable does not
12170 # cause an out-of-memory condition.
12172 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12173 [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
12174 dd if=$(which date) of=$MOUNT/date bs=1k count=1
12175 chmod +x $MOUNT/date
12177 $MOUNT/date > /dev/null
12178 ldd $MOUNT/date > /dev/null
12181 run_test 227 "running truncated executable does not cause OOM"
12183 # LU-1512 try to reuse idle OI blocks
12185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12186 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12187 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12188 skip "non-ldiskfs backend" && return
12190 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12191 local myDIR=$DIR/$tdir
12194 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12195 $LCTL set_param fail_loc=0x80001002
12196 createmany -o $myDIR/t- 10000
12197 $LCTL set_param fail_loc=0
12198 # The guard is current the largest FID holder
12200 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12202 local IDX=$(($SEQ % 64))
12204 do_facet $SINGLEMDS sync
12205 # Make sure journal flushed.
12207 local blk1=$(do_facet $SINGLEMDS \
12208 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12209 grep Blockcount | awk '{print $4}')
12211 # Remove old files, some OI blocks will become idle.
12212 unlinkmany $myDIR/t- 10000
12213 # Create new files, idle OI blocks should be reused.
12214 createmany -o $myDIR/t- 2000
12215 do_facet $SINGLEMDS sync
12216 # Make sure journal flushed.
12218 local blk2=$(do_facet $SINGLEMDS \
12219 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12220 grep Blockcount | awk '{print $4}')
12222 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12224 run_test 228a "try to reuse idle OI blocks"
12227 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12228 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12229 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12230 skip "non-ldiskfs backend" && return
12232 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12233 local myDIR=$DIR/$tdir
12236 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12237 $LCTL set_param fail_loc=0x80001002
12238 createmany -o $myDIR/t- 10000
12239 $LCTL set_param fail_loc=0
12240 # The guard is current the largest FID holder
12242 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12244 local IDX=$(($SEQ % 64))
12246 do_facet $SINGLEMDS sync
12247 # Make sure journal flushed.
12249 local blk1=$(do_facet $SINGLEMDS \
12250 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12251 grep Blockcount | awk '{print $4}')
12253 # Remove old files, some OI blocks will become idle.
12254 unlinkmany $myDIR/t- 10000
12257 stop $SINGLEMDS || error "Fail to stop MDT."
12259 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
12261 df $MOUNT || error "Fail to df."
12262 # Create new files, idle OI blocks should be reused.
12263 createmany -o $myDIR/t- 2000
12264 do_facet $SINGLEMDS sync
12265 # Make sure journal flushed.
12267 local blk2=$(do_facet $SINGLEMDS \
12268 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12269 grep Blockcount | awk '{print $4}')
12271 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12273 run_test 228b "idle OI blocks can be reused after MDT restart"
12277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12278 remote_mds_nodsh && skip "remote MDS with nodsh" && return
12279 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
12280 skip "non-ldiskfs backend" && return
12282 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
12283 local myDIR=$DIR/$tdir
12286 #define OBD_FAIL_SEQ_EXHAUST 0x1002
12287 $LCTL set_param fail_loc=0x80001002
12288 # 20000 files can guarantee there are index nodes in the OI file
12289 createmany -o $myDIR/t- 20000
12290 $LCTL set_param fail_loc=0
12291 # The guard is current the largest FID holder
12293 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
12295 local IDX=$(($SEQ % 64))
12297 do_facet $SINGLEMDS sync
12298 # Make sure journal flushed.
12300 local blk1=$(do_facet $SINGLEMDS \
12301 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12302 grep Blockcount | awk '{print $4}')
12304 # Remove old files, some OI blocks will become idle.
12305 unlinkmany $myDIR/t- 20000
12307 # The OI file should become empty now
12309 # Create new files, idle OI blocks should be reused.
12310 createmany -o $myDIR/t- 2000
12311 do_facet $SINGLEMDS sync
12312 # Make sure journal flushed.
12314 local blk2=$(do_facet $SINGLEMDS \
12315 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
12316 grep Blockcount | awk '{print $4}')
12318 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
12320 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
12322 test_229() { # LU-2482, LU-3448
12323 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
12324 skip "No HSM support on MDS of $(get_lustre_version)," \
12325 "need 2.4.53 at least" && return
12326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12327 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
12331 # Create a file with a released layout and stripe count 2.
12332 $MULTIOP $DIR/$tfile H2c ||
12333 error "failed to create file with released layout"
12335 $GETSTRIPE -v $DIR/$tfile
12337 local pattern=$($GETSTRIPE -L $DIR/$tfile)
12338 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
12340 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
12341 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
12342 stat $DIR/$tfile || error "failed to stat released file"
12344 chown $RUNAS_ID $DIR/$tfile ||
12345 error "chown $RUNAS_ID $DIR/$tfile failed"
12347 chgrp $RUNAS_ID $DIR/$tfile ||
12348 error "chgrp $RUNAS_ID $DIR/$tfile failed"
12350 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
12351 rm $DIR/$tfile || error "failed to remove released file"
12353 run_test 229 "getstripe/stat/rm/attr changes work on released files"
12356 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12357 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12360 test_mkdir $DIR/$tdir
12361 test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
12362 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
12363 [ $mdt_idx -ne 0 ] &&
12364 error "create local directory on wrong MDT $mdt_idx"
12366 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
12367 error "create remote directory failed"
12368 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
12369 [ $mdt_idx -ne $MDTIDX ] &&
12370 error "create remote directory on wrong MDT $mdt_idx"
12372 createmany -o $DIR/$tdir/test_230/t- 10 ||
12373 error "create files on remote directory failed"
12374 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
12375 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
12376 rm -r $DIR/$tdir || error "unlink remote directory failed"
12378 run_test 230a "Create remote directory and files under the remote directory"
12381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12382 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12389 local migrate_dir=$DIR/$tdir/migrate_dir
12390 local other_dir=$DIR/$tdir/other_dir
12392 test_mkdir $DIR/$tdir
12393 test_mkdir -i0 -c1 $migrate_dir
12394 test_mkdir -i0 -c1 $other_dir
12395 for ((i=0; i<10; i++)); do
12396 mkdir -p $migrate_dir/dir_${i}
12397 createmany -o $migrate_dir/dir_${i}/f 10 ||
12398 error "create files under remote dir failed $i"
12401 cp /etc/passwd $migrate_dir/$tfile
12402 cp /etc/passwd $other_dir/$tfile
12403 chattr +SAD $migrate_dir
12404 chattr +SAD $migrate_dir/$tfile
12406 local old_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12407 local old_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12408 local old_dir_mode=$(stat -c%f $migrate_dir)
12409 local old_file_mode=$(stat -c%f $migrate_dir/$tfile)
12411 mkdir -p $migrate_dir/dir_default_stripe2
12412 $SETSTRIPE -c 2 $migrate_dir/dir_default_stripe2
12413 $SETSTRIPE -c 2 $migrate_dir/${tfile}_stripe2
12415 mkdir -p $other_dir
12416 ln $migrate_dir/$tfile $other_dir/luna
12417 ln $migrate_dir/$tfile $migrate_dir/sofia
12418 ln $other_dir/$tfile $migrate_dir/david
12419 ln -s $migrate_dir/$tfile $other_dir/zachary
12420 ln -s $migrate_dir/$tfile $migrate_dir/${tfile}_ln
12421 ln -s $other_dir/$tfile $migrate_dir/${tfile}_ln_other
12423 $LFS mv -v -M $MDTIDX $migrate_dir ||
12424 error "migrate remote dir error"
12426 echo "migratate to MDT1, then checking.."
12427 for ((i = 0; i < 10; i++)); do
12428 for file in $(find $migrate_dir/dir_${i}); do
12429 mdt_index=$($LFS getstripe -M $file)
12430 [ $mdt_index == $MDTIDX ] ||
12431 error "$file is not on MDT${MDTIDX}"
12435 # the multiple link file should still in MDT0
12436 mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
12437 [ $mdt_index == 0 ] ||
12438 error "$file is not on MDT${MDTIDX}"
12440 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12441 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12442 error " expect $old_dir_flag get $new_dir_flag"
12444 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12445 [ "$old_file_flag" = "$new_file_flag" ] ||
12446 error " expect $old_file_flag get $new_file_flag"
12448 local new_dir_mode=$(stat -c%f $migrate_dir)
12449 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12450 error "expect mode $old_dir_mode get $new_dir_mode"
12452 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12453 [ "$old_file_mode" = "$new_file_mode" ] ||
12454 error "expect mode $old_file_mode get $new_file_mode"
12456 diff /etc/passwd $migrate_dir/$tfile ||
12457 error "$tfile different after migration"
12459 diff /etc/passwd $other_dir/luna ||
12460 error "luna different after migration"
12462 diff /etc/passwd $migrate_dir/sofia ||
12463 error "sofia different after migration"
12465 diff /etc/passwd $migrate_dir/david ||
12466 error "david different after migration"
12468 diff /etc/passwd $other_dir/zachary ||
12469 error "zachary different after migration"
12471 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12472 error "${tfile}_ln different after migration"
12474 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12475 error "${tfile}_ln_other different after migration"
12477 stripe_count=$($LFS getstripe -c $migrate_dir/dir_default_stripe2)
12478 [ $stripe_count = 2 ] ||
12479 error "dir strpe_count $d != 2 after migration."
12481 stripe_count=$($LFS getstripe -c $migrate_dir/${tfile}_stripe2)
12482 [ $stripe_count = 2 ] ||
12483 error "file strpe_count $d != 2 after migration."
12485 #migrate back to MDT0
12487 $LFS mv -v -M $MDTIDX $migrate_dir ||
12488 error "migrate remote dir error"
12490 echo "migrate back to MDT0, checking.."
12491 for file in $(find $migrate_dir); do
12492 mdt_index=$($LFS getstripe -M $file)
12493 [ $mdt_index == $MDTIDX ] ||
12494 error "$file is not on MDT${MDTIDX}"
12497 local new_dir_flag=$(lsattr -a $migrate_dir | awk '/\/\.$/ {print $1}')
12498 [ "$old_dir_flag" = "$new_dir_flag" ] ||
12499 error " expect $old_dir_flag get $new_dir_flag"
12501 local new_file_flag=$(lsattr $migrate_dir/$tfile | awk '{print $1}')
12502 [ "$old_file_flag" = "$new_file_flag" ] ||
12503 error " expect $old_file_flag get $new_file_flag"
12505 local new_dir_mode=$(stat -c%f $migrate_dir)
12506 [ "$old_dir_mode" = "$new_dir_mode" ] ||
12507 error "expect mode $old_dir_mode get $new_dir_mode"
12509 local new_file_mode=$(stat -c%f $migrate_dir/$tfile)
12510 [ "$old_file_mode" = "$new_file_mode" ] ||
12511 error "expect mode $old_file_mode get $new_file_mode"
12513 diff /etc/passwd ${migrate_dir}/$tfile ||
12514 error "$tfile different after migration"
12516 diff /etc/passwd ${other_dir}/luna ||
12517 error "luna different after migration"
12519 diff /etc/passwd ${migrate_dir}/sofia ||
12520 error "sofia different after migration"
12522 diff /etc/passwd ${other_dir}/zachary ||
12523 error "zachary different after migration"
12525 diff /etc/passwd $migrate_dir/${tfile}_ln ||
12526 error "${tfile}_ln different after migration"
12528 diff /etc/passwd $migrate_dir/${tfile}_ln_other ||
12529 error "${tfile}_ln_other different after migration"
12531 stripe_count=$($LFS getstripe -c ${migrate_dir}/dir_default_stripe2)
12532 [ $stripe_count = 2 ] ||
12533 error "dir strpe_count $d != 2 after migration."
12535 stripe_count=$($LFS getstripe -c ${migrate_dir}/${tfile}_stripe2)
12536 [ $stripe_count = 2 ] ||
12537 error "file strpe_count $d != 2 after migration."
12539 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12541 run_test 230b "migrate directory"
12544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12545 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12549 local migrate_dir=$DIR/$tdir/migrate_dir
12551 #If migrating directory fails in the middle, all entries of
12552 #the directory is still accessiable.
12553 test_mkdir $DIR/$tdir
12554 test_mkdir -i0 -c1 $migrate_dir
12556 createmany -o $migrate_dir/f 10 ||
12557 error "create files under ${migrate_dir} failed"
12559 #failed after migrating 5 entries
12560 #OBD_FAIL_MIGRATE_ENTRIES 0x1801
12561 do_facet mds1 lctl set_param fail_loc=0x20001801
12562 do_facet mds1 lctl set_param fail_val=5
12563 local t=$(ls $migrate_dir | wc -l)
12564 $LFS mv --mdt-index $MDTIDX $migrate_dir &&
12565 error "migrate should fail after 5 entries"
12566 local u=$(ls $migrate_dir | wc -l)
12567 [ "$u" == "$t" ] || error "$u != $t during migration"
12569 for file in $(find $migrate_dir); do
12570 stat $file || error "stat $file failed"
12573 do_facet mds1 lctl set_param fail_loc=0
12574 do_facet mds1 lctl set_param fail_val=0
12576 $LFS mv -M $MDTIDX $migrate_dir ||
12577 error "migrate open files should failed with open files"
12579 echo "Finish migration, then checking.."
12580 for file in $(find $migrate_dir); do
12581 mdt_index=$($LFS getstripe -M $file)
12582 [ $mdt_index == $MDTIDX ] ||
12583 error "$file is not on MDT${MDTIDX}"
12586 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12588 run_test 230c "check directory accessiblity if migration is failed"
12591 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
12592 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12595 local migrate_dir=$DIR/$tdir/migrate_dir
12599 test_mkdir $DIR/$tdir
12600 test_mkdir -i0 -c1 $migrate_dir
12602 for ((i=0; i<100; i++)); do
12603 test_mkdir -i0 -c1 $migrate_dir/dir_${i}
12604 createmany -o $migrate_dir/dir_${i}/f 100 ||
12605 error "create files under remote dir failed $i"
12608 $LFS mv -M $MDTIDX -v $migrate_dir || error "migrate remote dir error"
12610 echo "Finish migration, then checking.."
12611 for file in $(find $migrate_dir); do
12612 mdt_index=$($LFS getstripe -M $file)
12613 [ $mdt_index == $MDTIDX ] ||
12614 error "$file is not on MDT${MDTIDX}"
12617 rm -rf $DIR/$tdir || error "rm dir failed after migration"
12619 run_test 230d "check migrate big directory"
12623 # For simplicity this test assumes that max_pages_per_rpc
12624 # is the same across all OSCs
12625 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -n1)
12626 local bulk_size=$((max_pages * 4096))
12628 mkdir -p $DIR/$tdir
12630 # clear the OSC stats
12631 $LCTL set_param osc.*.stats=0 &>/dev/null
12633 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
12634 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
12635 oflag=direct &>/dev/null || error "dd failed"
12637 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
12638 if [ x$nrpcs != "x1" ]; then
12639 error "found $nrpc ost_write RPCs, not 1 as expected"
12642 # Drop the OSC cache, otherwise we will read from it
12643 cancel_lru_locks osc
12645 # clear the OSC stats
12646 $LCTL set_param osc.*.stats=0 &>/dev/null
12648 # Client reads $bulk_size.
12649 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
12650 iflag=direct &>/dev/null || error "dd failed"
12652 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
12653 if [ x$nrpcs != "x1" ]; then
12654 error "found $nrpc ost_read RPCs, not 1 as expected"
12657 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
12660 mkdir -p $DIR/$tdir
12662 for i in {0..1023}; do
12663 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
12664 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
12665 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
12669 run_test 231b "must not assert on fully utilized OST request buffer"
12672 mkdir -p $DIR/$tdir
12673 #define OBD_FAIL_LDLM_OST_LVB 0x31c
12674 $LCTL set_param fail_loc=0x31c
12676 # ignore dd failure
12677 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
12679 $LCTL set_param fail_loc=0
12680 umount_client $MOUNT || error "umount failed"
12681 mount_client $MOUNT || error "mount failed"
12683 run_test 232 "failed lock should not block umount"
12686 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
12687 { skip "Need MDS version at least 2.3.64"; return; }
12689 local fid=$($LFS path2fid $MOUNT)
12690 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12691 error "cannot access $MOUNT using its FID '$fid'"
12693 run_test 233a "checking that OBF of the FS root succeeds"
12696 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
12697 { skip "Need MDS version at least 2.5.90"; return; }
12699 local fid=$($LFS path2fid $MOUNT/.lustre)
12700 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12701 error "cannot access $MOUNT/.lustre using its FID '$fid'"
12703 fid=$($LFS path2fid $MOUNT/.lustre/fid)
12704 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
12705 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
12707 run_test 233b "checking that OBF of the FS .lustre succeeds"
12710 local p="$TMP/sanityN-$TESTNAME.parameters"
12711 save_lustre_params client "llite.*.xattr_cache" > $p
12712 lctl set_param llite.*.xattr_cache 1 ||
12713 { skip "xattr cache is not supported"; return 0; }
12715 mkdir -p $DIR/$tdir || error "mkdir failed"
12716 touch $DIR/$tdir/$tfile || error "touch failed"
12717 # OBD_FAIL_LLITE_XATTR_ENOMEM
12718 $LCTL set_param fail_loc=0x1405
12719 # output of the form: attr 2 4 44 3 fc13 x86_64
12720 V=($(IFS=".-" rpm -q attr))
12721 if [[ ${V[1]} > 2 || ${V[2]} > 4 || ${V[3]} > 44 ||
12722 ${V[1]} = 2 && ${V[2]} = 4 && ${V[3]} = 44 && ${V[4]} > 6 ]]; then
12723 # attr pre-2.4.44-7 had a bug with rc
12724 # LU-3703 - SLES 11 and FC13 clients have older attr
12725 getfattr -n user.attr $DIR/$tdir/$tfile &&
12726 error "getfattr should have failed with ENOMEM"
12728 skip "LU-3703: attr version $(getfattr --version) too old"
12730 $LCTL set_param fail_loc=0x0
12733 restore_lustre_params < $p
12736 run_test 234 "xattr cache should not crash on ENOMEM"
12739 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
12740 skip "Need MDS version at least 2.4.52" && return
12741 flock_deadlock $DIR/$tfile
12746 124) error "process hangs on a deadlock"
12748 *) error "error executing flock_deadlock $DIR/$tfile"
12752 run_test 235 "LU-1715: flock deadlock detection does not work properly"
12756 check_swap_layouts_support && return 0
12757 test_mkdir -p -c1 $DIR/$tdir || error "mkdir $tdir failed"
12759 local ref1=/etc/passwd
12760 local ref2=/etc/group
12761 local file1=$DIR/$tdir/f1
12762 local file2=$DIR/$tdir/f2
12764 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
12765 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
12766 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
12767 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
12768 local fd=$(free_fd)
12769 local cmd="exec $fd<>$file2"
12772 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
12773 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
12776 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
12781 run_test 236 "Layout swap on open unlinked file"
12783 # test to verify file handle related system calls
12784 # (name_to_handle_at/open_by_handle_at)
12785 # The new system calls are supported in glibc >= 2.14.
12788 echo "Test file_handle syscalls" > $DIR/$tfile ||
12789 error "write failed"
12790 check_fhandle_syscalls $DIR/$tfile ||
12791 error "check_fhandle_syscalls failed"
12793 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
12795 # LU-4659 linkea consistency
12797 local server_version=$(lustre_version_code $SINGLEMDS)
12799 [[ $server_version -gt $(version_code 2.5.57) ]] ||
12800 [[ $server_version -gt $(version_code 2.5.1) &&
12801 $server_version -lt $(version_code 2.5.50) ]] ||
12802 { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
12805 ln $DIR/$tfile $DIR/$tfile.lnk
12806 touch $DIR/$tfile.new
12807 mv $DIR/$tfile.new $DIR/$tfile
12808 local fid1=$($LFS path2fid $DIR/$tfile)
12809 local fid2=$($LFS path2fid $DIR/$tfile.lnk)
12810 local path1=$($LFS fid2path $FSNAME "$fid1")
12811 [ $tfile == $path1 ] || error "linkea inconsistent: $tfile $fid1 $path1"
12812 local path2=$($LFS fid2path $FSNAME "$fid2")
12813 [ $tfile.lnk == $path2 ] ||
12814 error "linkea inconsistent: $tfile.lnk $fid2 $path2!"
12817 run_test 238 "Verify linkea consistency"
12820 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
12821 skip "Need MDS version at least 2.5.60" && return
12822 local list=$(comma_list $(mdts_nodes))
12824 mkdir -p $DIR/$tdir
12825 createmany -o $DIR/$tdir/f- 5000
12826 unlinkmany $DIR/$tdir/f- 5000
12827 do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
12828 changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
12829 osc.*MDT*.sync_in_flight" | calc_sum)
12830 [ "$changes" -eq 0 ] || error "$changes not synced"
12832 run_test 239 "osp_sync test"
12835 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
12837 mkdir -p $DIR/$tdir
12839 $LFS mkdir -i 0 $DIR/$tdir/d0 ||
12840 error "failed to mkdir $DIR/$tdir/d0 on MDT0"
12841 $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
12842 error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
12844 umount_client $MOUNT || error "umount failed"
12845 #define OBD_FAIL_TGT_DELAY_CONDITIONAL 0x713
12846 do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
12847 mount_client $MOUNT || error "failed to mount client"
12849 echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
12850 stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
12852 run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
12855 for LOOP in $(seq $1); do
12856 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 2>/dev/null
12857 cancel_lru_locks osc
12862 for LOOP in $(seq $1); do
12863 dd if=$DIR/$tfile of=/dev/null bs=40960 count=1 \
12864 iflag=direct 2>/dev/null
12869 dd if=/dev/zero of=$DIR/$tfile count=1 bs=40960
12871 cancel_lru_locks osc
12872 test_241_bio 1000 &
12877 run_test 241 "bio vs dio"
12880 mkdir -p $DIR/$tdir
12881 touch $DIR/$tdir/$tfile
12883 #define OBD_FAIL_MDS_READPAGE_PACK 0x105
12884 do_facet mds1 lctl set_param fail_loc=0x105
12885 /bin/ls $DIR/$tdir && error "ls $DIR/$tdir should fail"
12887 do_facet mds1 lctl set_param fail_loc=0
12888 /bin/ls $DIR/$tdir || error "ls $DIR/$tdir failed"
12890 run_test 242 "mdt_readpage failure should not cause directory unreadable"
12894 test_mkdir -p $DIR/$tdir
12895 group_lock_test -d $DIR/$tdir || error "A group lock test failed"
12897 run_test 243 "various group lock tests"
12900 [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
12901 && skip "no 16TB file size limit on ZFS" && return
12903 $SETSTRIPE -c 1 $DIR/$tfile
12904 # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
12905 local size=$((16 * 1024 * 1024 * 1024 * 1024 - 4096 - 1))
12906 $TRUNCATE $DIR/$tfile $size || error "truncate $tfile to $size failed"
12907 dd if=/dev/zero of=$DIR/$tfile bs=10 count=1 oflag=append \
12908 conv=notrunc,fsync && error "append succeeded"
12911 run_test 250 "Write above 16T limit"
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"
13158 test_300_check_default_striped_dir()
13161 local default_count=$2
13162 local default_index=$3
13165 local dir_stripe_index
13168 echo "checking $dirname $default_count $default_index"
13169 $LFS setdirstripe -D -c $default_count -i $default_index \
13170 -t all_char $DIR/$tdir/$dirname ||
13171 error "set default stripe on striped dir error"
13172 stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/$dirname)
13173 [ $stripe_count -eq $default_count ] ||
13174 error "expect $default_count get $stripe_count for $dirname"
13176 stripe_index=$($LFS getdirstripe -D -i $DIR/$tdir/$dirname)
13177 [ $stripe_index -eq $default_index ] ||
13178 error "expect $default_index get $stripe_index for $dirname"
13180 mkdir $DIR/$tdir/$dirname/{test1,test2,test3,test4} ||
13181 error "create dirs failed"
13183 createmany -o $DIR/$tdir/$dirname/f- 10 || error "create files failed"
13184 unlinkmany $DIR/$tdir/$dirname/f- 10 || error "unlink files failed"
13185 for dir in $(find $DIR/$tdir/$dirname/*); do
13186 stripe_count=$($LFS getdirstripe -c $dir)
13187 [ $stripe_count -eq $default_count ] ||
13188 error "stripe count $default_count != $stripe_count for $dir"
13190 stripe_index=$($LFS getdirstripe -i $dir)
13191 [ $default_index -eq -1 -o $stripe_index -eq $default_index ] ||
13192 error "$stripe_index != $default_index for $dir"
13194 #check default stripe
13195 stripe_count=$($LFS getdirstripe -D -c $dir)
13196 [ $stripe_count -eq $default_count ] ||
13197 error "default count $default_count != $stripe_count for $dir"
13199 stripe_index=$($LFS getdirstripe -D -i $dir)
13200 [ $stripe_index -eq $default_index ] ||
13201 error "default index $default_index != $stripe_index for $dir"
13203 rmdir $DIR/$tdir/$dirname/* || error "rmdir failed"
13207 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13213 mkdir $DIR/$tdir/normal_dir
13215 test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
13216 test_300_check_default_striped_dir normal_dir 1 0
13217 test_300_check_default_striped_dir normal_dir 2 1
13218 test_300_check_default_striped_dir normal_dir 2 -1
13220 #delete default stripe information
13221 echo "delete default stripeEA"
13222 $LFS setdirstripe -d $DIR/$tdir/normal_dir ||
13223 error "set default stripe on striped dir error"
13225 mkdir -p $DIR/$tdir/normal_dir/{test1,test2,test3,test4}
13226 for dir in $(find $DIR/$tdir/normal_dir/*); do
13227 stripe_count=$($LFS getdirstripe -c $dir)
13228 [ $stripe_count -eq 0 ] ||
13229 error "expect 1 get $stripe_count for $dir"
13230 stripe_index=$($LFS getdirstripe -i $dir)
13231 [ $stripe_index -eq 0 ] ||
13232 error "expect 0 get $stripe_index for $dir"
13235 run_test 300g "check default striped directory for normal directory"
13238 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13243 $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
13244 $DIR/$tdir/striped_dir ||
13245 error "set striped dir error"
13247 test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
13248 test_300_check_default_striped_dir striped_dir 1 0
13249 test_300_check_default_striped_dir striped_dir 2 1
13250 test_300_check_default_striped_dir striped_dir 2 -1
13252 #delete default stripe information
13253 $LFS setdirstripe -d $DIR/$tdir/striped_dir ||
13254 error "set default stripe on striped dir error"
13256 mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
13257 for dir in $(find $DIR/$tdir/striped_dir/*); do
13258 stripe_count=$($LFS getdirstripe -c $dir)
13259 [ $stripe_count -eq 0 ] ||
13260 error "expect 1 get $stripe_count for $dir"
13263 run_test 300h "check default striped directory for striped directory"
13266 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13267 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
13273 $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
13274 error "set striped dir error"
13276 createmany -o $DIR/$tdir/striped_dir/f- 10 ||
13277 error "create files under striped dir failed"
13279 # unfortunately, we need to umount to clear dir layout cache for now
13280 # once we fully implement dir layout, we can drop this
13281 umount_client $MOUNT || error "umount failed"
13282 mount_client $MOUNT || error "mount failed"
13284 #set the stripe to be unknown hash type
13285 #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901
13286 $LCTL set_param fail_loc=0x1901
13287 for ((i = 0; i < 10; i++)); do
13288 $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
13289 error "stat f-$i failed"
13290 rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
13293 touch $DIR/$tdir/striped_dir/f0 &&
13294 error "create under striped dir with unknown hash should fail"
13296 $LCTL set_param fail_loc=0
13298 umount_client $MOUNT || error "umount failed"
13299 mount_client $MOUNT || error "mount failed"
13303 run_test 300i "client handle unknown hash type striped directory"
13305 test_400a() { # LU-1606, was conf-sanity test_74
13306 local extra_flags=''
13307 local out=$TMP/$tfile
13308 local prefix=/usr/include/lustre
13311 if ! which $CC > /dev/null 2>&1; then
13312 skip_env "$CC is not installed"
13316 if ! [[ -d $prefix ]]; then
13317 # Assume we're running in tree and fixup the include path.
13318 extra_flags+=" -I$LUSTRE/../libcfs/include"
13319 extra_flags+=" -I$LUSTRE/include"
13320 extra_flags+=" -L$LUSTRE/utils"
13323 for prog in $LUSTRE_TESTS_API_DIR/*.c; do
13324 $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
13325 error "client api broken"
13328 run_test 400a "Lustre client api program can compile and link"
13330 test_400b() { # LU-1606, LU-5011
13332 local out=$TMP/$tfile
13333 local prefix=/usr/include/lustre
13335 # We use a hard coded prefix so that this test will not fail
13336 # when run in tree. There are headers in lustre/include/lustre/
13337 # that are not packaged (like lustre_idl.h) and have more
13338 # complicated include dependencies (like config.h and lnet/types.h).
13339 # Since this test about correct packaging we just skip them when
13340 # they don't exist (see below) rather than try to fixup cppflags.
13342 if ! which $CC > /dev/null 2>&1; then
13343 skip_env "$CC is not installed"
13347 for header in $prefix/*.h; do
13348 if ! [[ -f "$header" ]]; then
13352 if [[ "$(basename $header)" == liblustreapi.h ]]; then
13353 continue # liblustreapi.h is deprecated.
13356 $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
13357 error "cannot compile '$header'"
13360 run_test 400b "packaged headers can be compiled"
13363 # tests that do cleanup/setup should be run at the end
13367 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
13369 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
13370 $LCTL set_param fail_loc=0x903
13372 cancel_lru_locks MGC
13374 FAIL_ON_ERROR=true cleanup
13375 FAIL_ON_ERROR=true setup
13377 run_test 900 "umount should not race with any mgc requeue thread"
13380 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
13381 check_and_cleanup_lustre
13382 if [ "$I_MOUNTED" != "yes" ]; then
13383 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true