2 # -*- tab-width: 4; 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"
20 SRCDIR=$(cd $(dirname $0); echo $PWD)
21 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 MCREATE=${MCREATE:-mcreate}
32 OPENFILE=${OPENFILE:-openfile}
33 OPENUNLINK=${OPENUNLINK:-openunlink}
34 export MULTIOP=${MULTIOP:-multiop}
35 READS=${READS:-"reads"}
36 MUNLINK=${MUNLINK:-munlink}
37 SOCKETSERVER=${SOCKETSERVER:-socketserver}
38 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
39 MEMHOG=${MEMHOG:-memhog}
40 DIRECTIO=${DIRECTIO:-directio}
41 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
42 UMOUNT=${UMOUNT:-"umount -d"}
44 CHECK_GRANT=${CHECK_GRANT:-"yes"}
45 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
46 export PARALLEL=${PARALLEL:-"no"}
48 export NAME=${NAME:-local}
55 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
56 . $LUSTRE/tests/test-framework.sh
58 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
61 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 64b 68 71 77f 78 115 124b"
63 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
64 # bug number for skipped test: LU-1593 LU-2610 LU-2833 LU-1957 LU-2805
65 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34h 40 48a 180 184c"
71 pgrep ll_sa > /dev/null && { echo "There are ll_sa thread not exit!"; exit 20; }
72 cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
81 check_kernel_version() {
83 GOT_VER=$(lctl get_param -n version | awk '/kernel:/ {print $2}')
85 patchless|patchless_client) return 0;;
86 *) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
88 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
92 check_swap_layouts_support()
94 $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
95 { skip "Does not support layout lock."; return 0; }
99 if [ "$ONLY" == "cleanup" ]; then
104 check_and_setup_lustre
109 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid | \
110 awk '{gsub(/_UUID/,""); print $1}' | head -1)
111 LOVNAME=$($LCTL get_param -n llite.*.lov.common_name | tail -n 1)
112 OSTCOUNT=$($LCTL get_param -n lov.$LOVNAME.numobd)
113 STRIPECOUNT=$($LCTL get_param -n lov.$LOVNAME.stripecount)
114 STRIPESIZE=$($LCTL get_param -n lov.$LOVNAME.stripesize)
115 ORIGFREE=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
116 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
118 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
119 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
120 rm -rf $DIR/[Rdfs][0-9]*
122 # $RUNAS_ID may get set incorrectly somewhere else
123 [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!"
125 check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS
129 if [ "${ONLY}" = "MOUNT" ] ; then
130 echo "Lustre is up, please go on"
134 echo "preparing for tests involving mounts"
135 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
137 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
138 echo # add a newline after mke2fs.
142 OLDDEBUG=$(lctl get_param -n debug 2> /dev/null)
143 lctl set_param debug=-1 2> /dev/null || true
146 $CHECKSTAT -t file $DIR/$tfile || error "$tfile is not a file"
148 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
150 run_test 0a "touch; rm ====================="
153 chmod 0755 $DIR || error "chmod 0755 $DIR failed"
154 $CHECKSTAT -p 0755 $DIR || error "$DIR permission is not 0755"
156 run_test 0b "chmod 0755 $DIR ============================="
159 $LCTL get_param mdc.*.import | grep "state: FULL" ||
160 error "import not FULL"
161 $LCTL get_param mdc.*.import | grep "target: $FSNAME-MDT" ||
164 run_test 0c "check import proc ============================="
167 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
168 test_mkdir -p $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
169 test_mkdir $DIR/$tdir/d2 && error "we expect EEXIST, but not returned"
170 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a dir"
173 $CHECKSTAT -a $DIR/$tdir || error "$tdir was not removed"
175 run_test 1 "mkdir; remkdir; rmdir =============================="
178 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
179 touch $DIR/$tdir/$tfile || error "touch $tdir/$tfile failed"
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
182 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$file is not removed"
184 run_test 2 "mkdir; touch; rmdir; check file ===================="
187 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
188 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
189 touch $DIR/$tdir/$tfile
190 $CHECKSTAT -t file $DIR/$tdir/$tfile || error "$tdir/$tfile not a file"
192 $CHECKSTAT -a $DIR/$tdir || error "$tdir is not removed"
194 run_test 3 "mkdir; touch; rmdir; check dir ====================="
197 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
198 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
199 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
200 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
201 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
203 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
206 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
207 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
208 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
209 error "$tfile does not have perm 0666 or UID $UID"
210 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
211 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
212 error "$tfile should be 0666 and owned by UID $UID"
214 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
217 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
219 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
220 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
221 error "$tfile should be owned by UID $RUNAS_ID"
222 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
223 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
224 error "$tfile should be owned by UID $RUNAS_ID"
226 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
229 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
231 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
232 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
233 error "$tfile should be owned by GID $UID"
234 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
235 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
236 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
238 run_test 6e "touch f6e; chgrp f6e; $RUNAS chgrp f6e (should return error) =="
241 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
242 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
243 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
244 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
245 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
246 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
247 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
248 error "$tdir/d/subdir should be GID $RUNAS_GID"
250 run_test 6g "Is new dir in sgid dir inheriting group?"
252 test_6h() { # bug 7331
253 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
254 touch $DIR/$tfile || error "touch failed"
255 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
256 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
257 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
258 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
259 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
261 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
264 test_mkdir $DIR/$tdir
265 $MCREATE $DIR/$tdir/$tfile
266 chmod 0666 $DIR/$tdir/$tfile
267 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
268 error "$tdir/$tfile should be mode 0666"
270 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
273 if [ ! -d $DIR/$tdir ]; then
276 $MCREATE $DIR/$tdir/$tfile
277 echo -n foo > $DIR/$tdir/$tfile
278 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
279 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
281 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
284 test_mkdir $DIR/$tdir
285 touch $DIR/$tdir/$tfile
286 chmod 0666 $DIR/$tdir/$tfile
287 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
288 error "$tfile mode not 0666"
290 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
293 test_mkdir $DIR/$tdir
294 test_mkdir $DIR/$tdir/d2
295 test_mkdir $DIR/$tdir/d2/d3
296 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
298 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
301 test_mkdir $DIR/$tdir
302 test_mkdir $DIR/$tdir/d2
303 touch $DIR/$tdir/d2/$tfile
304 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
305 error "$tdir/d2/$tfile not a file"
307 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
310 test_mkdir $DIR/$tdir
311 test_mkdir $DIR/$tdir/d2
312 chmod 0666 $DIR/$tdir/d2
313 chmod 0705 $DIR/$tdir/d2
314 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
315 error "$tdir/d2 mode not 0705"
317 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
320 test_mkdir $DIR/$tdir
321 touch $DIR/$tdir/$tfile
322 chmod 0666 $DIR/$tdir/$tfile
323 chmod 0654 $DIR/$tdir/$tfile
324 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
325 error "$tdir/d2 mode not 0654"
327 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
330 test_mkdir $DIR/$tdir
331 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
333 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
334 error "$tdir/$tfile size not 0 after truncate"
336 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
339 test_mkdir $DIR/$tdir
340 touch $DIR/$tdir/$tfile
342 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
344 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
347 test_mkdir $DIR/$tdir
348 touch $DIR/$tdir/$tfile
349 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
350 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
351 error "$tdir/${tfile_2} not a file after rename"
353 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
356 test_mkdir $DIR/$tdir
357 touch $DIR/$tdir/$tfile
358 rm -rf $DIR/$tdir/$tfile
359 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
361 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
364 test_mkdir -p $DIR/$tdir
365 touch $DIR/$tdir/$tfile
366 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
368 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
369 error "$tdir/l-exist not a symlink"
370 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
371 error "$tdir/l-exist not referencing a file"
372 rm -f $DIR/$tdir/l-exist
373 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
375 run_test 17a "symlinks: create, remove (real) =================="
378 test_mkdir -p $DIR/$tdir
379 ln -s no-such-file $DIR/$tdir/l-dangle
381 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
382 error "$tdir/l-dangle not referencing no-such-file"
383 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
384 error "$tdir/l-dangle not referencing non-existent file"
385 rm -f $DIR/$tdir/l-dangle
386 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
388 run_test 17b "symlinks: create, remove (dangling) =============="
390 test_17c() { # bug 3440 - don't save failed open RPC for replay
391 test_mkdir -p $DIR/$tdir
392 ln -s foo $DIR/$tdir/$tfile
393 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
395 run_test 17c "symlinks: open dangling (should return error) ===="
398 test_mkdir -p $DIR/$tdir
399 ln -s foo $DIR/$tdir/$tfile
400 touch $DIR/$tdir/$tfile || error "creating to new symlink"
402 run_test 17d "symlinks: create dangling ========================"
405 test_mkdir -p $DIR/$tdir
406 local foo=$DIR/$tdir/$tfile
407 ln -s $foo $foo || error "create symlink failed"
408 ls -l $foo || error "ls -l failed"
409 ls $foo && error "ls not failed" || true
411 run_test 17e "symlinks: create recursive symlink (should return error) ===="
414 test_mkdir -p $DIR/d17f
415 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
416 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
417 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
418 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
419 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
420 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
423 run_test 17f "symlinks: long and very long symlink name ========================"
425 # str_repeat(S, N) generate a string that is string S repeated N times
430 while [ $((n -= 1)) -ge 0 ]; do
436 # Long symlinks and LU-2241
438 test_mkdir -p $DIR/$tdir
439 local TESTS="59 60 61 4094 4095"
441 # Fix for inode size boundary in 2.1.4
442 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
445 # Patch not applied to 2.2 or 2.3 branches
446 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
447 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
450 # skip long symlink name for rhel6.5.
451 # rhel6.5 has a limit (PATH_MAX - sizeof(struct filename))
452 grep -q '6.5' /etc/redhat-release && TESTS="59 60 61 4062 4063"
455 local SYMNAME=$(str_repeat 'x' $i)
456 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
457 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
460 run_test 17g "symlinks: really long symlink name and inode boundaries"
462 test_17h() { #bug 17378
463 remote_mds_nodsh && skip "remote MDS with nodsh" && return
464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
466 test_mkdir -p $DIR/$tdir
467 if [ $MDSCOUNT -gt 1 ]; then
468 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
472 $SETSTRIPE -c -1 $DIR/$tdir
473 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
474 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
475 touch $DIR/$tdir/$tfile || true
477 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
479 test_17i() { #bug 20018
480 remote_mds_nodsh && skip "remote MDS with nodsh" && return
481 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
482 test_mkdir -p $DIR/$tdir
483 local foo=$DIR/$tdir/$tfile
485 if [ $MDSCOUNT -gt 1 ]; then
486 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
490 ln -s $foo $foo || error "create symlink failed"
491 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
492 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
493 ls -l $foo && error "error not detected"
496 run_test 17i "don't panic on short symlink"
498 test_17k() { #bug 22301
499 rsync --help | grep -q xattr ||
500 skip_env "$(rsync --version| head -1) does not support xattrs"
501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
502 test_mkdir -p $DIR/$tdir
503 test_mkdir -p $DIR/$tdir.new
504 touch $DIR/$tdir/$tfile
505 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
506 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
507 error "rsync failed with xattrs enabled"
509 run_test 17k "symlinks: rsync with xattrs enabled ========================="
511 test_17l() { # LU-279
513 touch $DIR/$tdir/$tfile
514 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
515 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
516 # -h to not follow symlinks. -m '' to list all the xattrs.
517 # grep to remove first line: '# file: $path'.
518 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
520 lgetxattr_size_check $path $xattr ||
521 error "lgetxattr_size_check $path $xattr failed"
525 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
529 local short_sym="0123456789"
530 local WDIR=$DIR/${tdir}m
537 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
538 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
539 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
541 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
542 skip "only for ldiskfs MDT" && return 0
544 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
548 # create a long symlink file
549 for ((i = 0; i < 4; ++i)); do
550 long_sym=${long_sym}${long_sym}
553 echo "create 512 short and long symlink files under $WDIR"
554 for ((i = 0; i < 256; ++i)); do
555 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
556 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
562 wait_delete_completed
564 echo "recreate the 512 symlink files with a shorter string"
565 for ((i = 0; i < 512; ++i)); do
566 # rewrite the symlink file with a shorter string
567 ln -sf ${long_sym} $WDIR/long-$i
568 ln -sf ${short_sym} $WDIR/short-$i
571 mds_index=$($LFS getstripe -M $WDIR)
572 mds_index=$((mds_index+1))
573 devname=$(mdsdevname $mds_index)
574 cmd="$E2FSCK -fnvd $devname"
576 echo "stop and checking mds${mds_index}: $cmd"
577 # e2fsck should not return error
579 do_facet mds${mds_index} $cmd || rc=$?
581 start mds${mds_index} $devname $MDS_MOUNT_OPTS
582 df $MOUNT > /dev/null 2>&1
583 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
584 "short/long symlink MDT: rc=$rc"
587 run_test 17m "run e2fsck against MDT which contains short/long symlink"
589 check_fs_consistency_17n() {
595 for mdt_index in $(seq 1 $MDSCOUNT); do
596 devname=$(mdsdevname $mdt_index)
597 cmd="$E2FSCK -fnvd $devname"
599 echo "stop and checking mds${mdt_index}: $cmd"
600 # e2fsck should not return error
602 do_facet mds${mdt_index} $cmd || rc=$?
604 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
605 df $MOUNT > /dev/null 2>&1
606 [ $rc -ne 0 ] && break
614 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
615 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
616 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
618 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
619 skip "only for ldiskfs MDT" && return 0
621 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
626 for ((i=0; i<10; i++)); do
627 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
628 error "create remote dir error $i"
629 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
630 error "create files under remote dir failed $i"
633 check_fs_consistency_17n || error "e2fsck report error"
635 for ((i=0;i<10;i++)); do
636 rm -rf $DIR/$tdir/remote_dir_${i} ||
637 error "destroy remote dir error $i"
640 check_fs_consistency_17n || error "e2fsck report error"
642 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
645 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ]] &&
646 skip "Need MDS version at least 2.3.64" && return
648 local WDIR=$DIR/${tdir}o
654 mdt_index=$($LFS getstripe -M $WDIR)
655 mdt_index=$((mdt_index+1))
656 mdtdevname=$(mdsdevname $mdt_index)
660 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
662 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
663 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
664 ls -l $WDIR/$tfile && rc=1
665 do_facet mds${mdt_index} lctl set_param fail_loc=0
666 [[ $rc -ne 0 ]] && error "stat file should fail"
669 run_test 17o "stat file with incompat LMA feature"
672 touch $DIR/f || error "Failed to touch $DIR/f: $?"
673 ls $DIR || error "Failed to ls $DIR: $?"
675 run_test 18 "touch .../f ; ls ... =============================="
681 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
683 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
686 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
688 run_test 19b "ls -l .../f19 (should return error) =============="
691 [ $RUNAS_ID -eq $UID ] &&
692 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
693 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
695 run_test 19c "$RUNAS touch .../f19 (should return error) =="
698 cat $DIR/f19 && error || true
700 run_test 19d "cat .../f19 (should return error) =============="
712 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
714 run_test 20 "touch .../f ; ls -l ... ==========================="
717 test_mkdir -p $DIR/$tdir
718 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
719 ln -s dangle $DIR/$tdir/link
720 echo foo >> $DIR/$tdir/link
721 cat $DIR/$tdir/dangle
722 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
723 $CHECKSTAT -f -t file $DIR/$tdir/link ||
724 error "$tdir/link not linked to a file"
726 run_test 21 "write to dangling link ============================"
730 test_mkdir -p $DIR/$tdir
731 chown $RUNAS_ID:$RUNAS_GID $WDIR
732 (cd $WDIR || error "cd $WDIR failed";
733 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
735 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
736 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
737 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
739 run_test 22 "unpack tar archive as non-root user ==============="
743 test_mkdir -p $DIR/$tdir
744 local file=$DIR/$tdir/$tfile
746 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
747 openfile -f O_CREAT:O_EXCL $file &&
748 error "$file recreate succeeded" || true
750 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
752 test_23b() { # bug 18988
753 test_mkdir -p $DIR/$tdir
754 local file=$DIR/$tdir/$tfile
757 echo foo > $file || error "write filed"
758 echo bar >> $file || error "append filed"
759 $CHECKSTAT -s 8 $file || error "wrong size"
762 run_test 23b "O_APPEND check =========================="
766 echo '-- same directory rename'
767 test_mkdir $DIR/$tdir
768 touch $DIR/$tdir/$tfile.1
769 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
770 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
772 run_test 24a "rename file to non-existent target"
775 test_mkdir $DIR/$tdir
776 touch $DIR/$tdir/$tfile.{1,2}
777 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
778 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
779 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
781 run_test 24b "rename file to existing target"
784 test_mkdir $DIR/$tdir
785 test_mkdir $DIR/$tdir/d$testnum.1
786 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
787 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
788 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
790 run_test 24c "rename directory to non-existent target"
793 test_mkdir $DIR/$tdir
794 test_mkdir $DIR/$tdir/d$testnum.1
795 test_mkdir $DIR/$tdir/d$testnum.2
796 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
797 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
798 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
800 run_test 24d "rename directory to existing target"
803 echo '-- cross directory renames --'
807 mv $DIR/R5a/f $DIR/R5b/g
808 $CHECKSTAT -a $DIR/R5a/f || error
809 $CHECKSTAT -t file $DIR/R5b/g || error
811 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
816 touch $DIR/R6a/f $DIR/R6b/g
817 mv $DIR/R6a/f $DIR/R6b/g
818 $CHECKSTAT -a $DIR/R6a/f || error
819 $CHECKSTAT -t file $DIR/R6b/g || error
821 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
826 test_mkdir $DIR/R7a/d
827 mv $DIR/R7a/d $DIR/R7b/e
828 $CHECKSTAT -a $DIR/R7a/d || error
829 $CHECKSTAT -t dir $DIR/R7b/e || error
831 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
836 test_mkdir $DIR/R8a/d
837 test_mkdir $DIR/R8b/e
838 mrename $DIR/R8a/d $DIR/R8b/e
839 $CHECKSTAT -a $DIR/R8a/d || error
840 $CHECKSTAT -t dir $DIR/R8b/e || error
842 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
845 echo "-- rename error cases"
849 mrename $DIR/R9/f $DIR/R9/a
850 $CHECKSTAT -t file $DIR/R9/f || error
851 $CHECKSTAT -t dir $DIR/R9/a || error
852 $CHECKSTAT -a $DIR/R9/a/f || error
854 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
858 mrename $DIR/R10/f $DIR/R10/g
859 $CHECKSTAT -t dir $DIR/R10 || error
860 $CHECKSTAT -a $DIR/R10/f || error
861 $CHECKSTAT -a $DIR/R10/g || error
863 run_test 24j "source does not exist ============================"
867 test_mkdir $DIR/R11a/d
869 mv $DIR/R11a/f $DIR/R11a/d
870 $CHECKSTAT -a $DIR/R11a/f || error
871 $CHECKSTAT -t file $DIR/R11a/d/f || error
873 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
875 # bug 2429 - rename foo foo foo creates invalid file
878 $MULTIOP $f OcNs || error
880 run_test 24l "Renaming a file to itself ========================"
884 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
885 # on ext3 this does not remove either the source or target files
886 # though the "expected" operation would be to remove the source
887 $CHECKSTAT -t file ${f} || error "${f} missing"
888 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
890 run_test 24m "Renaming a file to a hard link to itself ========="
894 # this stats the old file after it was renamed, so it should fail
898 $CHECKSTAT ${f}.rename
901 run_test 24n "Statting the old file after renaming (Posix rename 2)"
904 check_kernel_version 37 || return 0
905 test_mkdir -p $DIR/d24o
906 rename_many -s random -v -n 10 $DIR/d24o
908 run_test 24o "rename of files during htree split ==============="
913 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
914 mrename $DIR/R12a $DIR/R12b
915 $CHECKSTAT -a $DIR/R12a || error
916 $CHECKSTAT -t dir $DIR/R12b || error
917 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
918 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
920 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
922 cleanup_multiop_pause() {
928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
931 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
932 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
935 trap cleanup_multiop_pause EXIT
936 mrename $DIR/R13a $DIR/R13b
937 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
938 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
939 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
940 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
941 cleanup_multiop_pause
942 wait $MULTIPID || error "multiop close failed"
944 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
946 test_24r() { #bug 3789
948 test_mkdir $DIR/R14a/b
949 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
950 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
951 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
953 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
957 test_mkdir $DIR/R15a/b
958 test_mkdir $DIR/R15a/b/c
959 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
960 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
961 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
963 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
966 test_mkdir $DIR/R16a/b
967 test_mkdir $DIR/R16a/b/c
968 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
969 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
970 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
972 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
974 test_24u() { # bug12192
976 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
977 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
979 run_test 24u "create stripe file"
985 simple_cleanup_common() {
988 wait_delete_completed
991 max_pages_per_rpc() {
992 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
997 local FREE_INODES=$(mdt_free_inodes 0)
998 [ $FREE_INODES -lt $NRFILES ] && \
999 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1003 trap simple_cleanup_common EXIT
1005 # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
1006 [ $(facet_fstype $SINGLEMDS) = "zfs" ] && NRFILES=10000
1009 createmany -m $DIR/$tdir/$tfile $NRFILES
1011 cancel_lru_locks mdc
1012 lctl set_param mdc.*.stats clear
1014 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1016 # LU-5 large readdir
1017 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1018 # 8 bytes for name(filename is mostly 5 in this test) +
1019 # 8 bytes for luda_type
1020 # take into account of overhead in lu_dirpage header and end mark in
1021 # each page, plus one in RPC_NUM calculation.
1023 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1024 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1025 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1026 awk '/^mds_readpage/ {print $2}')
1027 [ $mds_readpage -gt $RPC_NUM ] && \
1028 error "large readdir doesn't take effect"
1030 simple_cleanup_common
1032 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1034 test_24w() { # bug21506
1036 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1037 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1038 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1039 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1040 [ "$SZ1" = "$SZ2" ] || \
1041 error "Error reading at the end of the file $tfile"
1043 run_test 24w "Reading a file larger than 4Gb"
1046 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1047 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1049 local remote_dir=$DIR/$tdir/remote_dir
1052 $LFS mkdir -i $MDTIDX $remote_dir ||
1053 error "create remote directory failed"
1055 mkdir -p $DIR/$tdir/src_dir
1056 touch $DIR/$tdir/src_file
1057 mkdir -p $remote_dir/tgt_dir
1058 touch $remote_dir/tgt_file
1060 mrename $remote_dir $DIR/ &&
1061 error "rename dir cross MDT works!"
1063 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1064 error "rename dir cross MDT works!"
1066 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1067 error "rename file cross MDT works!"
1069 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1070 error "ln file cross MDT should not work!"
1072 rm -rf $DIR/$tdir || error "Can not delete directories"
1074 run_test 24x "cross rename/link should be failed"
1077 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1080 local remote_dir=$DIR/$tdir/remote_dir
1083 $LFS mkdir -i $MDTIDX $remote_dir ||
1084 error "create remote directory failed"
1086 mkdir -p $remote_dir/src_dir
1087 touch $remote_dir/src_file
1088 mkdir -p $remote_dir/tgt_dir
1089 touch $remote_dir/tgt_file
1091 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1092 error "rename subdir in the same remote dir failed!"
1094 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1095 error "rename files in the same remote dir failed!"
1097 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1098 error "link files in the same remote dir failed!"
1100 rm -rf $DIR/$tdir || error "Can not delete directories"
1102 run_test 24y "rename/link on the same dir should succeed"
1105 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1106 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1108 local remote_src=$DIR/$tdir/remote_dir
1109 local remote_tgt=$DIR/$tdir/remote_tgt
1112 $LFS mkdir -i $MDTIDX $remote_src ||
1113 error "create remote directory failed"
1115 $LFS mkdir -i $MDTIDX $remote_tgt ||
1116 error "create remote directory failed"
1118 mrename $remote_src $remote_tgt &&
1119 error "rename remote dirs should not work!"
1121 # If target dir does not exists, it should succeed
1123 mrename $remote_src $remote_tgt ||
1124 error "rename remote dirs(tgt dir does not exists) failed!"
1126 rm -rf $DIR/$tdir || error "Can not delete directories"
1128 run_test 24z "rename one remote dir to another remote dir should fail"
1130 test_24A() { # LU-3182
1135 createmany -m $DIR/$tdir/$tfile $NFILES
1136 local t=`ls $DIR/$tdir | wc -l`
1137 local u=`ls $DIR/$tdir | sort -u | wc -l`
1138 if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
1139 error "Expected $NFILES files, got $t ($u unique)"
1142 rm -rf $DIR/$tdir || error "Can not delete directories"
1144 run_test 24A "readdir() returns correct number of entries."
1147 echo '== symlink sanity ============================================='
1151 touch $DIR/s25/foo || error
1153 run_test 25a "create file in symlinked directory ==============="
1156 [ ! -d $DIR/d25 ] && test_25a
1157 $CHECKSTAT -t file $DIR/s25/foo || error
1159 run_test 25b "lookup file in symlinked directory ==============="
1163 test_mkdir $DIR/d26/d26-2
1164 ln -s d26/d26-2 $DIR/s26
1165 touch $DIR/s26/foo || error
1167 run_test 26a "multiple component symlink ======================="
1170 test_mkdir -p $DIR/d26b/d26-2
1171 ln -s d26b/d26-2/foo $DIR/s26-2
1172 touch $DIR/s26-2 || error
1174 run_test 26b "multiple component symlink at end of lookup ======"
1177 test_mkdir $DIR/d26.2
1178 touch $DIR/d26.2/foo
1179 ln -s d26.2 $DIR/s26.2-1
1180 ln -s s26.2-1 $DIR/s26.2-2
1181 ln -s s26.2-2 $DIR/s26.2-3
1182 chmod 0666 $DIR/s26.2-3/foo
1184 run_test 26c "chain of symlinks ================================"
1186 # recursive symlinks (bug 439)
1188 ln -s d26-3/foo $DIR/d26-3
1190 run_test 26d "create multiple component recursive symlink ======"
1193 [ ! -h $DIR/d26-3 ] && test_26d
1196 run_test 26e "unlink multiple component recursive symlink ======"
1198 # recursive symlinks (bug 7022)
1200 test_mkdir -p $DIR/$tdir
1201 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1202 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1203 test_mkdir -p lndir/bar1 || error "mkdir lndir/bar1 failed"
1204 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1205 cd $tfile || error "cd $tfile failed"
1206 ln -s .. dotdot || error "ln dotdot failed"
1207 ln -s dotdot/lndir lndir || error "ln lndir failed"
1208 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1209 output=`ls $tfile/$tfile/lndir/bar1`
1210 [ "$output" = bar1 ] && error "unexpected output"
1211 rm -r $tfile || error "rm $tfile failed"
1212 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1214 run_test 26f "rm -r of a directory which has recursive symlink ="
1217 echo '== stripe sanity =============================================='
1218 test_mkdir -p $DIR/d27 || error "mkdir failed"
1220 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1221 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1223 log "== test_27a: write to one stripe file ========================="
1224 cp /etc/hosts $DIR/d27/f0 || error
1226 run_test 27a "one stripe file =================================="
1229 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1230 test_mkdir -p $DIR/d27
1231 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1232 $GETSTRIPE -c $DIR/d27/f01
1233 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1234 error "two-stripe file doesn't have two stripes"
1236 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1238 run_test 27b "create and write to two stripe file"
1241 test_mkdir -p $DIR/d27
1242 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1243 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1244 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1246 run_test 27d "create file with default settings ================"
1249 test_mkdir -p $DIR/d27
1250 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1251 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1252 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1254 run_test 27e "setstripe existing file (should return error) ======"
1257 test_mkdir -p $DIR/d27
1258 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1259 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1260 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1262 run_test 27f "setstripe with bad stripe size (should return error)"
1265 test_mkdir -p $DIR/d27
1266 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1267 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1268 error "$DIR/d27/fnone has object"
1270 run_test 27g "$GETSTRIPE with no objects"
1273 touch $DIR/d27/fsome || error "touch failed"
1274 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1276 run_test 27i "$GETSTRIPE with some objects"
1279 test_mkdir -p $DIR/d27
1280 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1282 run_test 27j "setstripe with bad stripe offset (should return error)"
1284 test_27k() { # bug 2844
1285 test_mkdir -p $DIR/d27
1287 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1288 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1289 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1290 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1291 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "1:$BLKSIZE > $LL_MAX_BLKSIZE"
1292 dd if=/dev/zero of=$FILE bs=4k count=1
1293 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1294 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "2:$BLKSIZE > $LL_MAX_BLKSIZE"
1296 run_test 27k "limit i_blksize for broken user apps ============="
1299 test_mkdir -p $DIR/d27
1300 mcreate $DIR/f27l || error "creating file"
1301 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1302 error "setstripe should have failed" || true
1304 run_test 27l "check setstripe permissions (should return error)"
1307 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1309 if [ $ORIGFREE -gt $MAXFREE ]; then
1310 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1313 trap simple_cleanup_common EXIT
1314 test_mkdir -p $DIR/$tdir
1315 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1316 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1317 error "dd should fill OST0"
1319 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1321 [ $i -gt 256 ] && break
1324 touch $DIR/$tdir/f27m_$i
1325 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1326 error "OST0 was full but new created file still use it"
1328 touch $DIR/$tdir/f27m_$i
1329 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1330 error "OST0 was full but new created file still use it"
1331 simple_cleanup_common
1333 run_test 27m "create file while OST0 was full =================="
1336 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1340 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1341 # if the OST isn't full anymore.
1343 local OSTIDX=${1:-""}
1345 local list=$(comma_list $(osts_nodes))
1346 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1348 do_nodes $list lctl set_param fail_loc=0
1349 sync # initiate all OST_DESTROYs from MDS to OST
1353 exhaust_precreations() {
1356 local FAILIDX=${3:-$OSTIDX}
1358 test_mkdir -p $DIR/$tdir
1359 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1360 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1362 local OST=$(ostname_from_index $OSTIDX)
1363 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1364 sed -e 's/_UUID$//;s/^.*-//')
1367 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1368 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1369 osc.$mdtosc_proc1.prealloc_last_id)
1370 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1371 osc.$mdtosc_proc1.prealloc_next_id)
1373 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1374 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1376 test_mkdir -p $DIR/$tdir/${OST}
1377 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1378 #define OBD_FAIL_OST_ENOSPC 0x215
1379 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1380 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1381 echo "Creating to objid $last_id on ost $OST..."
1382 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1383 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1384 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1388 exhaust_all_precreations() {
1390 for (( i=0; i < OSTCOUNT; i++ )) ; do
1391 exhaust_precreations $i $1 -1
1396 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1397 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1398 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1399 remote_ost_nodsh && skip "remote OST with nodsh" && return
1402 rm -f $DIR/$tdir/$tfile
1403 exhaust_precreations 0 0x80000215
1404 $SETSTRIPE -c -1 $DIR/$tdir
1405 touch $DIR/$tdir/$tfile || error
1406 $GETSTRIPE $DIR/$tdir/$tfile
1409 run_test 27n "create file with some full OSTs =================="
1412 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1413 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1414 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1415 remote_ost_nodsh && skip "remote OST with nodsh" && return
1418 rm -f $DIR/$tdir/$tfile
1419 exhaust_all_precreations 0x215
1421 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1426 run_test 27o "create file with all full OSTs (should error) ===="
1429 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1431 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1432 remote_ost_nodsh && skip "remote OST with nodsh" && return
1435 rm -f $DIR/$tdir/$tfile
1436 test_mkdir -p $DIR/$tdir
1438 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1439 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1440 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1442 exhaust_precreations 0 0x80000215
1443 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1444 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1445 $GETSTRIPE $DIR/$tdir/$tfile
1449 run_test 27p "append to a truncated file with some full OSTs ==="
1452 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1453 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1454 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1455 remote_ost_nodsh && skip "remote OST with nodsh" && return
1458 rm -f $DIR/$tdir/$tfile
1460 test_mkdir -p $DIR/$tdir
1461 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1462 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1463 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1465 exhaust_all_precreations 0x215
1467 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1468 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1472 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1475 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1477 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1478 remote_ost_nodsh && skip "remote OST with nodsh" && return
1481 rm -f $DIR/$tdir/$tfile
1482 exhaust_precreations 0 0x80000215
1484 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1488 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1490 test_27s() { # bug 10725
1491 test_mkdir -p $DIR/$tdir
1492 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1493 local stripe_count=0
1494 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1495 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1496 error "stripe width >= 2^32 succeeded" || true
1499 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1501 test_27t() { # bug 10864
1506 $WLFS getstripe $tfile
1509 run_test 27t "check that utils parse path correctly"
1511 test_27u() { # bug 4900
1512 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1513 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1515 local list=$(comma_list $(mdts_nodes))
1517 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1518 do_nodes $list $LCTL set_param fail_loc=0x139
1519 test_mkdir -p $DIR/$tdir
1521 createmany -o $DIR/$tdir/t- 1000
1522 do_nodes $list $LCTL set_param fail_loc=0
1524 TLOG=$DIR/$tfile.getstripe
1525 $GETSTRIPE $DIR/$tdir > $TLOG
1526 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1527 unlinkmany $DIR/$tdir/t- 1000
1528 [ $OBJS -gt 0 ] && \
1529 error "$OBJS objects created on OST-0. See $TLOG" || pass
1531 run_test 27u "skip object creation on OSC w/o objects =========="
1533 test_27v() { # bug 4900
1534 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1535 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1536 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1537 remote_ost_nodsh && skip "remote OST with nodsh" && return
1539 exhaust_all_precreations 0x215
1542 test_mkdir -p $DIR/$tdir
1543 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1545 touch $DIR/$tdir/$tfile
1546 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1548 for (( i=1; i < OSTCOUNT; i++ )); do
1549 do_facet ost$i lctl set_param fail_loc=0x705
1551 local START=`date +%s`
1552 createmany -o $DIR/$tdir/$tfile 32
1554 local FINISH=`date +%s`
1555 local TIMEOUT=`lctl get_param -n timeout`
1556 local PROCESS=$((FINISH - START))
1557 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1558 error "$FINISH - $START >= $TIMEOUT / 2"
1559 sleep $((TIMEOUT / 2 - PROCESS))
1562 run_test 27v "skip object creation on slow OST ================="
1564 test_27w() { # bug 10997
1565 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1566 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1567 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1568 error "stripe size $size != 65536" || true
1569 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1570 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1572 run_test 27w "check $SETSTRIPE -S option"
1575 [ "$OSTCOUNT" -lt "2" ] &&
1576 skip_env "skipping multiple stripe count/offset test" && return
1578 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1579 for i in $(seq 1 $OSTCOUNT); do
1581 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1582 error "setstripe -c $i -i $offset failed"
1583 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1584 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1585 [ $count -ne $i ] && error "stripe count $count != $i" || true
1586 [ $index -ne $offset ] &&
1587 error "stripe offset $index != $offset" || true
1590 run_test 27wa "check $SETSTRIPE -c -i options"
1593 remote_ost_nodsh && skip "remote OST with nodsh" && return
1594 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1595 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1596 OFFSET=$(($OSTCOUNT - 1))
1598 local OST=$(ostname_from_index $OSTIDX)
1600 test_mkdir -p $DIR/$tdir
1601 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1602 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1604 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1605 for i in `seq 0 $OFFSET`; do
1606 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1607 error "OST0 was degraded but new created file still use it"
1609 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1611 run_test 27x "create files while OST0 is degraded"
1614 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1615 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1616 remote_ost_nodsh && skip "remote OST with nodsh" && return
1617 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1619 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1620 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1621 osc.$mdtosc.prealloc_last_id)
1622 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1623 osc.$mdtosc.prealloc_next_id)
1624 local fcount=$((last_id - next_id))
1625 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1626 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1628 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1629 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1630 local OST_DEACTIVE_IDX=-1
1635 for OSC in $MDS_OSCS; do
1636 OST=$(osc_to_ost $OSC)
1637 OSTIDX=$(index_from_ostuuid $OST)
1638 if [ $OST_DEACTIVE_IDX == -1 ]; then
1639 OST_DEACTIVE_IDX=$OSTIDX
1641 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1642 echo $OSC "is Deactivated:"
1643 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1647 OSTIDX=$(index_from_ostuuid $OST)
1649 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1651 for OSC in $MDS_OSCS; do
1652 OST=$(osc_to_ost $OSC)
1653 OSTIDX=$(index_from_ostuuid $OST)
1654 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1655 echo $OST "is degraded:"
1656 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1657 obdfilter.$OST.degraded=1
1662 createmany -o $DIR/$tdir/$tfile $fcount
1664 for OSC in $MDS_OSCS; do
1665 OST=$(osc_to_ost $OSC)
1666 OSTIDX=$(index_from_ostuuid $OST)
1667 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1668 echo $OST "is recovered from degraded:"
1669 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1670 obdfilter.$OST.degraded=0
1672 do_facet $SINGLEMDS lctl --device %$OSC activate
1676 # all osp devices get activated, hence -1 stripe count restored
1679 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1680 # devices get activated.
1682 $SETSTRIPE -c -1 $DIR/$tfile
1683 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1685 [ $stripecnt -ne $OSTCOUNT ] &&
1686 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1689 run_test 27y "create files while OST0 is degraded and the rest inactive"
1695 lmm_count=$($GETSTRIPE -c $1)
1696 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1697 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1699 local old_ifs="$IFS"
1701 fid=($($LFS path2fid $1))
1704 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1705 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1707 # compare lmm_seq and lu_fid->f_seq
1708 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1709 # compare lmm_object_id and lu_fid->oid
1710 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1712 # check the trusted.fid attribute of the OST objects of the file
1713 local have_obdidx=false
1715 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1716 # skip lines up to and including "obdidx"
1717 [ -z "$obdidx" ] && break
1718 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1719 $have_obdidx || continue
1721 local ost=$((obdidx + 1))
1722 local dev=$(ostdevname $ost)
1725 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1727 seq=$(echo $seq | sed -e "s/^0x//g")
1728 if [ $seq == 0 ]; then
1729 oid_hex=$(echo $oid)
1731 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1733 local obj_file="O/$seq/d$((oid %32))/$oid_hex"
1737 # Don't unmount/remount the OSTs if we don't need to do that.
1738 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1739 # update too, until that use mount/ll_decode_filter_fid/mount.
1740 # Re-enable when debugfs will understand new filter_fid.
1742 if false && [ $(facet_fstype ost$ost) == ldiskfs ]; then
1743 ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1744 $dev 2>/dev/null" | grep "parent=")
1747 mount_fstype ost$ost
1748 ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
1749 $(facet_mntpt ost$ost)/$obj_file)
1750 unmount_fstype ost$ost
1751 start ost$ost $dev $OST_MOUNT_OPTS
1754 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1756 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1758 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1759 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1760 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1761 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1762 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1764 if echo $ff_parent | grep -q 'stripe='; then
1765 ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1768 # $LL_DECODE_FILTER_FID does not print "stripe="; look
1769 # into f_ver in this case. See the comment on
1772 ff_pstripe=$(echo $ff_parent | cut -d: -f3 |
1776 # compare lmm_seq and filter_fid->ff_parent.f_seq
1777 [ $ff_pseq = $lmm_seq ] ||
1778 error "FF parent SEQ $ff_pseq != $lmm_seq"
1779 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1780 [ $ff_poid = $lmm_oid ] ||
1781 error "FF parent OID $ff_poid != $lmm_oid"
1782 (($ff_pstripe == $stripe_nr)) ||
1783 error "FF stripe $ff_pstripe != $stripe_nr"
1785 stripe_nr=$((stripe_nr + 1))
1790 remote_ost_nodsh && skip "remote OST with nodsh" && return
1791 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1792 test_mkdir -p $DIR/$tdir
1794 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1795 { error "setstripe -c -1 failed"; return 1; }
1796 # We need to send a write to every object to get parent FID info set.
1797 # This _should_ also work for setattr, but does not currently.
1798 # touch $DIR/$tdir/$tfile-1 ||
1799 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1800 { error "dd $tfile-1 failed"; return 2; }
1801 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1802 { error "setstripe -c -1 failed"; return 3; }
1803 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1804 { error "dd $tfile-2 failed"; return 4; }
1806 # make sure write RPCs have been sent to OSTs
1809 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1810 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1812 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1814 test_27A() { # b=19102
1815 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1816 local restore_size=$($GETSTRIPE -S $MOUNT)
1817 local restore_count=$($GETSTRIPE -c $MOUNT)
1818 local restore_offset=$($GETSTRIPE -i $MOUNT)
1819 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1820 wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/ *//g'" "1" 20 ||
1821 error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
1822 local default_size=$($GETSTRIPE -S $MOUNT)
1823 local default_offset=$($GETSTRIPE -i $MOUNT)
1824 local dsize=$((1024 * 1024))
1825 [ $default_size -eq $dsize ] ||
1826 error "stripe size $default_size != $dsize"
1827 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1828 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1830 run_test 27A "check filesystem-wide default LOV EA values"
1832 test_27B() { # LU-2523
1833 test_mkdir -p $DIR/$tdir
1834 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1836 # open f1 with O_LOV_DELAY_CREATE
1838 # call setstripe ioctl on open file descriptor for f1
1840 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1844 # open f1 with O_LOV_DELAY_CREATE
1846 # call setstripe ioctl on open file descriptor for f1
1848 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1850 # Allow multiop to fail in imitation of NFS's busted semantics.
1853 run_test 27B "call setstripe on open unlinked file/rename victim"
1855 test_27C() { #LU-2871
1856 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1864 test_mkdir -p $DIR/$tdir
1866 for i in $(seq 0 $((OSTCOUNT - 1))); do
1867 # set stripe across all OSTs starting from OST$i
1868 $SETSTRIPE -i $i -c -1 $tfile$i
1869 # get striping information
1870 ost_idx=($($GETSTRIPE $tfile$i |
1871 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1875 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1876 error "${#ost_idx[@]} != $OSTCOUNT"
1878 for index in $(seq 0 $((OSTCOUNT - 1))); do
1880 for j in $(echo ${ost_idx[@]}); do
1881 if [ $index -eq $j ]; then
1887 error "Can not find $index in ${ost_idx[@]}"
1891 run_test 27C "check full striping across all OSTs"
1893 # createtest also checks that device nodes are created and
1894 # then visible correctly (#2091)
1895 test_28() { # bug 2091
1897 $CREATETEST $DIR/d28/ct || error
1899 run_test 28 "create/mknod/mkdir with bad file types ============"
1902 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1903 cancel_lru_locks mdc
1909 declare -i LOCKCOUNTORIG=0
1910 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1911 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1913 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1915 declare -i LOCKUNUSEDCOUNTORIG=0
1916 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1917 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1924 declare -i LOCKCOUNTCURRENT=0
1925 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1926 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1929 declare -i LOCKUNUSEDCOUNTCURRENT=0
1930 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1931 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1934 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1935 lctl set_param -n ldlm.dump_namespaces ""
1936 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1937 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1938 log "dumped log to $TMP/test_29.dk (bug 5793)"
1941 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1942 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1943 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1944 log "dumped log to $TMP/test_29.dk (bug 5793)"
1948 run_test 29 "IT_GETATTR regression ============================"
1950 test_30a() { # was test_30
1951 cp `which ls` $DIR || cp /bin/ls $DIR
1955 run_test 30a "execute binary from Lustre (execve) =============="
1958 cp `which ls` $DIR || cp /bin/ls $DIR
1960 $RUNAS $DIR/ls / || error
1963 run_test 30b "execute binary from Lustre as non-root ==========="
1965 test_30c() { # b=22376
1966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1967 cp `which ls` $DIR || cp /bin/ls $DIR
1969 cancel_lru_locks mdc
1970 cancel_lru_locks osc
1971 $RUNAS $DIR/ls / || error
1974 run_test 30c "execute binary from Lustre without read perms ===="
1977 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1978 $CHECKSTAT -a $DIR/f31 || error
1980 run_test 31a "open-unlink file =================================="
1983 touch $DIR/f31 || error
1984 ln $DIR/f31 $DIR/f31b || error
1985 $MULTIOP $DIR/f31b Ouc || error
1986 $CHECKSTAT -t file $DIR/f31 || error
1988 run_test 31b "unlink file with multiple links while open ======="
1991 touch $DIR/f31 || error
1992 ln $DIR/f31 $DIR/f31c || error
1993 multiop_bg_pause $DIR/f31 O_uc || return 1
1995 $MULTIOP $DIR/f31c Ouc
1996 kill -USR1 $MULTIPID
1999 run_test 31c "open-unlink file with multiple links ============="
2002 opendirunlink $DIR/d31d $DIR/d31d || error
2003 $CHECKSTAT -a $DIR/d31d || error
2005 run_test 31d "remove of open directory ========================="
2007 test_31e() { # bug 2904
2008 check_kernel_version 34 || return 0
2009 openfilleddirunlink $DIR/d31e || error
2011 run_test 31e "remove of open non-empty directory ==============="
2013 test_31f() { # bug 4554
2014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2016 test_mkdir $DIR/d31f
2017 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2018 cp /etc/hosts $DIR/d31f
2020 $GETSTRIPE $DIR/d31f/hosts
2021 multiop_bg_pause $DIR/d31f D_c || return 1
2024 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2025 test_mkdir $DIR/d31f
2026 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2027 cp /etc/hosts $DIR/d31f
2029 $GETSTRIPE $DIR/d31f/hosts
2030 multiop_bg_pause $DIR/d31f D_c || return 1
2033 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2034 wait $MULTIPID || error "first opendir $MULTIPID failed"
2038 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2039 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2042 run_test 31f "remove of open directory with open-unlink file ==="
2045 echo "-- cross directory link --"
2046 test_mkdir $DIR/d31ga
2047 test_mkdir $DIR/d31gb
2049 ln $DIR/d31ga/f $DIR/d31gb/g
2050 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2051 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2052 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2053 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2055 run_test 31g "cross directory link==============="
2058 echo "-- cross directory link --"
2059 test_mkdir $DIR/d31h
2060 test_mkdir $DIR/d31h/dir
2062 ln $DIR/d31h/f $DIR/d31h/dir/g
2063 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2064 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2065 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2066 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2068 run_test 31h "cross directory link under child==============="
2071 echo "-- cross directory link --"
2072 test_mkdir $DIR/d31i
2073 test_mkdir $DIR/d31i/dir
2074 touch $DIR/d31i/dir/f
2075 ln $DIR/d31i/dir/f $DIR/d31i/g
2076 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2077 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2078 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2079 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2081 run_test 31i "cross directory link under parent==============="
2085 test_mkdir $DIR/d31j
2086 test_mkdir $DIR/d31j/dir1
2087 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2088 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2089 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2090 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2093 run_test 31j "link for directory==============="
2097 test_mkdir $DIR/d31k
2099 touch $DIR/d31k/exist
2100 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2101 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2102 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2103 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2104 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2105 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2106 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2109 run_test 31k "link to file: the same, non-existing, dir==============="
2112 test_mkdir $DIR/d31m
2114 test_mkdir $DIR/d31m2
2115 touch $DIR/d31m2/exist
2116 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2117 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2118 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2119 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2120 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2121 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2124 run_test 31m "link to file: the same, non-existing, dir==============="
2127 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2128 nlink=$(stat --format=%h $DIR/$tfile)
2129 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2131 local cmd="exec $fd<$DIR/$tfile"
2134 trap "eval $cmd" EXIT
2135 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2136 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2137 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2138 nlink=$(stat --dereference --format=%h /proc/self/fd/$fd)
2139 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2142 run_test 31n "check link count of unlinked file"
2145 local TEMPNAME=$(mktemp $1_XXXXXX)
2146 mlink $TEMPNAME $1 2> /dev/null &&
2147 echo "$BASHPID: link $TEMPNAME to $1 succeeded"
2151 test_31o() { # LU-2901
2153 for LOOP in $(seq 100); do
2154 rm -f $DIR/$tdir/$tfile*
2155 for THREAD in $(seq 8); do
2156 link_one $DIR/$tdir/$tfile.$LOOP &
2159 local LINKS=$(ls -1 $DIR/$tdir | grep -c $tfile.$LOOP)
2160 [ $LINKS -gt 1 ] && ls $DIR/$tdir &&
2161 error "$LINKS duplicate links to $tfile.$LOOP" &&
2165 run_test 31o "duplicate hard links with same filename"
2167 cleanup_test32_mount() {
2169 $UMOUNT -d $DIR/$tdir/ext2-mountpoint
2173 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2174 echo "== more mountpoints and symlinks ================="
2175 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2176 trap cleanup_test32_mount EXIT
2177 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2178 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2179 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2180 cleanup_test32_mount
2182 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2185 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2186 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2187 trap cleanup_test32_mount EXIT
2188 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2189 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2190 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2191 cleanup_test32_mount
2193 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2196 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2197 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2198 trap cleanup_test32_mount EXIT
2199 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2200 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2201 test_mkdir -p $DIR/$tdir/d2/test_dir
2202 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2203 cleanup_test32_mount
2205 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2209 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2210 trap cleanup_test32_mount EXIT
2211 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2212 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2213 test_mkdir -p $DIR/$tdir/d2/test_dir
2214 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2215 cleanup_test32_mount
2217 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2220 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2221 test_mkdir -p $DIR/d32e/tmp
2222 TMP_DIR=$DIR/d32e/tmp
2223 ln -s $DIR/d32e $TMP_DIR/symlink11
2224 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2225 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2226 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2228 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2231 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2232 test_mkdir -p $DIR/d32f/tmp
2233 TMP_DIR=$DIR/d32f/tmp
2234 ln -s $DIR/d32f $TMP_DIR/symlink11
2235 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2236 ls $DIR/d32f/tmp/symlink11 || error
2237 ls $DIR/d32f/symlink01 || error
2239 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2242 TMP_DIR=$DIR/$tdir/tmp
2243 test_mkdir -p $DIR/$tdir/tmp
2244 test_mkdir $DIR/${tdir}2
2245 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2246 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2247 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2248 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2249 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2250 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2252 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2255 rm -fr $DIR/$tdir $DIR/${tdir}2
2256 TMP_DIR=$DIR/$tdir/tmp
2257 test_mkdir -p $DIR/$tdir/tmp
2258 test_mkdir $DIR/${tdir}2
2259 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2260 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2261 ls $TMP_DIR/symlink12 || error
2262 ls $DIR/$tdir/symlink02 || error
2264 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2268 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2269 trap cleanup_test32_mount EXIT
2270 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2271 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2272 touch $DIR/$tdir/test_file
2273 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2274 cleanup_test32_mount
2276 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2280 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2281 trap cleanup_test32_mount EXIT
2282 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2283 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2284 touch $DIR/$tdir/test_file
2285 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2286 cleanup_test32_mount
2288 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2291 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2293 trap cleanup_test32_mount EXIT
2294 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2295 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2296 test_mkdir -p $DIR/$tdir/d2
2297 touch $DIR/$tdir/d2/test_file || error
2298 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2299 cleanup_test32_mount
2301 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2306 trap cleanup_test32_mount EXIT
2307 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2308 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2309 test_mkdir -p $DIR/$tdir/d2
2310 touch $DIR/$tdir/d2/test_file
2311 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2312 cleanup_test32_mount
2314 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2318 test_mkdir -p $DIR/d32m/tmp
2319 TMP_DIR=$DIR/d32m/tmp
2320 ln -s $DIR $TMP_DIR/symlink11
2321 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2322 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2323 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2325 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2329 test_mkdir -p $DIR/d32n/tmp
2330 TMP_DIR=$DIR/d32n/tmp
2331 ln -s $DIR $TMP_DIR/symlink11
2332 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2333 ls -l $DIR/d32n/tmp/symlink11 || error
2334 ls -l $DIR/d32n/symlink01 || error
2336 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2339 rm -fr $DIR/d32o $DIR/$tfile
2341 test_mkdir -p $DIR/d32o/tmp
2342 TMP_DIR=$DIR/d32o/tmp
2343 ln -s $DIR/$tfile $TMP_DIR/symlink12
2344 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2345 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2346 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2347 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2348 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2350 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2360 test_mkdir -p $DIR/d32p/tmp
2362 TMP_DIR=$DIR/d32p/tmp
2364 ln -s $DIR/$tfile $TMP_DIR/symlink12
2366 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2368 cat $DIR/d32p/tmp/symlink12 || error
2370 cat $DIR/d32p/symlink02 || error
2373 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2375 cleanup_testdir_mount() {
2377 $UMOUNT -d $DIR/$tdir
2381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2382 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2383 trap cleanup_testdir_mount EXIT
2384 test_mkdir -p $DIR/$tdir
2385 touch $DIR/$tdir/under_the_mount
2386 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2387 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2388 cleanup_testdir_mount
2390 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2394 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2395 trap cleanup_testdir_mount EXIT
2396 test_mkdir -p $DIR/$tdir
2397 touch $DIR/$tdir/under_the_mount
2398 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2399 ls $DIR/$tdir | grep -q under_the_mount && error || true
2400 cleanup_testdir_mount
2402 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2407 chmod 444 $DIR/$tfile
2408 chown $RUNAS_ID $DIR/$tfile
2410 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2413 run_test 33aa "write file with mode 444 (should return error) ===="
2417 test_mkdir -p $DIR/d33
2418 chown $RUNAS_ID $DIR/d33
2419 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2420 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2421 error "open RDWR" || true
2423 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2427 test_mkdir -p $DIR/d33
2428 chown $RUNAS_ID $DIR/d33
2429 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2431 run_test 33b "test open file with malformed flags (No panic and return error)"
2434 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2440 remote_ost_nodsh && skip "remote OST with nodsh" && return
2443 test_mkdir -p $DIR/d33
2444 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2447 for ostnum in $(seq $OSTCOUNT); do
2448 # test-framework's OST numbering is one-based, while Lustre's
2450 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2451 # Parsing llobdstat's output sucks; we could grep the /proc
2452 # path, but that's likely to not be as portable as using the
2453 # llobdstat utility. So we parse lctl output instead.
2454 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2455 obdfilter/$ostname/stats |
2456 awk '/^write_bytes/ {print $7}' )
2457 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2458 if (( ${write_bytes:-0} > 0 ))
2465 $all_zeros || return 0
2468 echo foo > $DIR/d33/bar
2472 # Total up write_bytes after writing. We'd better find non-zeros.
2473 for ostnum in $(seq $OSTCOUNT); do
2474 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2475 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2476 obdfilter/$ostname/stats |
2477 awk '/^write_bytes/ {print $7}' )
2478 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2479 if (( ${write_bytes:-0} > 0 ))
2488 for ostnum in $(seq $OSTCOUNT); do
2489 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2490 echo "Check that write_bytes is present in obdfilter/*/stats:"
2491 do_facet ost$ostnum lctl get_param -n \
2492 obdfilter/$ostname/stats
2494 error "OST not keeping write_bytes stats (b22312)"
2497 run_test 33c "test llobdstat and write_bytes"
2500 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2501 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2503 local remote_dir=$DIR/$tdir/remote_dir
2506 $LFS mkdir -i $MDTIDX $remote_dir ||
2507 error "create remote directory failed"
2509 touch $remote_dir/$tfile
2510 chmod 444 $remote_dir/$tfile
2511 chown $RUNAS_ID $remote_dir/$tfile
2513 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2515 chown $RUNAS_ID $remote_dir
2516 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2517 error "create" || true
2518 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2519 error "open RDWR" || true
2520 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2521 error "create" || true
2523 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2525 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2528 $MCREATE $DIR/f34 || error
2529 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2530 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2531 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2532 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2534 run_test 34a "truncate file that has not been opened ==========="
2537 [ ! -f $DIR/f34 ] && test_34a
2538 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2539 $OPENFILE -f O_RDONLY $DIR/f34
2540 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2541 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2543 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2546 [ ! -f $DIR/f34 ] && test_34a
2547 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2548 $OPENFILE -f O_RDWR $DIR/f34
2549 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2550 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2552 run_test 34c "O_RDWR opening file-with-size works =============="
2555 [ ! -f $DIR/f34 ] && test_34a
2556 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2557 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2560 run_test 34d "write to sparse file ============================="
2564 $MCREATE $DIR/f34e || error
2565 $TRUNCATE $DIR/f34e 1000 || error
2566 $CHECKSTAT -s 1000 $DIR/f34e || error
2567 $OPENFILE -f O_RDWR $DIR/f34e
2568 $CHECKSTAT -s 1000 $DIR/f34e || error
2570 run_test 34e "create objects, some with size and some without =="
2572 test_34f() { # bug 6242, 6243
2573 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2576 $MCREATE $DIR/f34f || error
2577 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2578 dd if=$DIR/f34f of=$TMP/f34f
2579 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2580 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2581 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2582 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2583 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2585 run_test 34f "read from a file with no objects until EOF ======="
2588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2589 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2590 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2591 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2592 cancel_lru_locks osc
2593 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2594 error "wrong size after lock cancel"
2596 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2597 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2598 error "expanding truncate failed"
2599 cancel_lru_locks osc
2600 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2601 error "wrong expanded size after lock cancel"
2603 run_test 34g "truncate long file ==============================="
2606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2610 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2611 sync # Flush the cache so that multiop below does not block on cache
2612 # flush when getting the group lock
2613 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2616 # Since just timed wait is not good enough, let's do a sync write
2617 # that way we are sure enough time for a roundtrip + processing
2618 # passed + 2 seconds of extra margin.
2619 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2623 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2624 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2628 local nsz=`stat -c %s $DIR/$tfile`
2629 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2631 run_test 34h "ftruncate file under grouplock should not block"
2634 cp /bin/sh $DIR/f35a
2636 chown $RUNAS_ID $DIR/f35a
2637 $RUNAS $DIR/f35a && error || true
2640 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2644 utime $DIR/f36 || error
2646 run_test 36a "MDS utime check (mknod, utime) ==================="
2650 utime $DIR/f36 || error
2652 run_test 36b "OST utime check (open, utime) ===================="
2657 chown $RUNAS_ID $DIR/d36
2658 $RUNAS utime $DIR/d36/f36 || error
2660 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2663 [ ! -d $DIR/d36 ] && test_36c
2664 echo "" > $DIR/d36/f36
2665 $RUNAS utime $DIR/d36/f36 || error
2667 run_test 36d "non-root OST utime check (open, utime) ==========="
2670 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2671 test_mkdir -p $DIR/$tdir
2672 touch $DIR/$tdir/$tfile
2673 $RUNAS utime $DIR/$tdir/$tfile && \
2674 error "utime worked, expected failure" || true
2676 run_test 36e "utime on non-owned file (should return error) ===="
2680 local LANG_SAVE=$LANG
2681 local LC_LANG_SAVE=$LC_LANG
2682 export LANG=C LC_LANG=C # for date language
2684 DATESTR="Dec 20 2000"
2685 test_mkdir -p $DIR/$tdir
2686 lctl set_param fail_loc=$fl
2688 cp /etc/hosts $DIR/$tdir/$tfile
2689 sync & # write RPC generated with "current" inode timestamp, but delayed
2691 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2692 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2693 cancel_lru_locks osc
2694 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2696 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2697 echo "BEFORE: $LS_BEFORE" && \
2698 echo "AFTER : $LS_AFTER" && \
2699 echo "WANT : $DATESTR" && \
2700 error "$DIR/$tdir/$tfile timestamps changed" || true
2702 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2707 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2708 subr_36fh "0x80000214"
2710 run_test 36f "utime on file racing with OST BRW write =========="
2713 remote_ost_nodsh && skip "remote OST with nodsh" && return
2714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2719 test_mkdir -p $DIR/$tdir
2720 fmd_max_age=$(do_facet ost1 \
2721 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2724 fmd_before=$(do_facet ost1 \
2725 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2726 touch $DIR/$tdir/$tfile
2727 sleep $((fmd_max_age + 12))
2728 fmd_after=$(do_facet ost1 \
2729 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2731 echo "fmd_before: $fmd_before"
2732 echo "fmd_after: $fmd_after"
2733 [ "$fmd_after" -gt "$fmd_before" ] && \
2734 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2735 error "fmd didn't expire after ping" || true
2737 run_test 36g "filter mod data cache expiry ====================="
2740 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2741 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2742 subr_36fh "0x80000227"
2744 run_test 36h "utime on file racing with OST BRW write =========="
2746 # test_37 - duplicate with tests 32q 32r
2749 local file=$DIR/$tfile
2751 openfile -f O_DIRECTORY $file
2754 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2755 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2757 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2761 touch $DIR/${tfile}2
2762 # ls -l $DIR/$tfile $DIR/${tfile}2
2763 # ls -lu $DIR/$tfile $DIR/${tfile}2
2764 # ls -lc $DIR/$tfile $DIR/${tfile}2
2766 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2767 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2769 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2771 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2773 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2774 error "O_TRUNC didn't change timestamps"
2777 run_test 39 "mtime changed on create ==========================="
2780 test_mkdir -p $DIR/$tdir
2781 cp -p /etc/passwd $DIR/$tdir/fopen
2782 cp -p /etc/passwd $DIR/$tdir/flink
2783 cp -p /etc/passwd $DIR/$tdir/funlink
2784 cp -p /etc/passwd $DIR/$tdir/frename
2785 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2788 echo "aaaaaa" >> $DIR/$tdir/fopen
2789 echo "aaaaaa" >> $DIR/$tdir/flink
2790 echo "aaaaaa" >> $DIR/$tdir/funlink
2791 echo "aaaaaa" >> $DIR/$tdir/frename
2793 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2794 local link_new=`stat -c %Y $DIR/$tdir/flink`
2795 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2796 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2798 cat $DIR/$tdir/fopen > /dev/null
2799 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2800 rm -f $DIR/$tdir/funlink2
2801 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2803 for (( i=0; i < 2; i++ )) ; do
2804 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2805 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2806 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2807 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2809 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2810 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2811 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2812 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2814 cancel_lru_locks osc
2815 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2818 run_test 39b "mtime change on open, link, unlink, rename ======"
2820 # this should be set to past
2821 TEST_39_MTIME=`date -d "1 year ago" +%s`
2827 local mtime0=`stat -c %Y $DIR1/$tfile`
2829 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2830 local mtime1=`stat -c %Y $DIR1/$tfile`
2831 [ "$mtime1" = $TEST_39_MTIME ] || \
2832 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2835 echo hello >> $DIR1/$tfile
2837 local mtime2=`stat -c %Y $DIR1/$tfile`
2838 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2839 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2841 mv $DIR1/$tfile $DIR1/$tfile-1
2843 for (( i=0; i < 2; i++ )) ; do
2844 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2845 [ "$mtime2" = "$mtime3" ] || \
2846 error "mtime ($mtime2) changed (to $mtime3) on rename"
2848 cancel_lru_locks osc
2849 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2852 run_test 39c "mtime change on rename ==========================="
2856 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2859 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2861 for (( i=0; i < 2; i++ )) ; do
2862 local mtime=`stat -c %Y $DIR1/$tfile`
2863 [ $mtime = $TEST_39_MTIME ] || \
2864 error "mtime($mtime) is not set to $TEST_39_MTIME"
2866 cancel_lru_locks osc
2867 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2870 run_test 39d "create, utime, stat =============================="
2874 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2876 local mtime1=`stat -c %Y $DIR1/$tfile`
2878 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2880 for (( i=0; i < 2; i++ )) ; do
2881 local mtime2=`stat -c %Y $DIR1/$tfile`
2882 [ $mtime2 = $TEST_39_MTIME ] || \
2883 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2885 cancel_lru_locks osc
2886 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2889 run_test 39e "create, stat, utime, stat ========================"
2893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2895 mtime1=`stat -c %Y $DIR1/$tfile`
2898 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2900 for (( i=0; i < 2; i++ )) ; do
2901 local mtime2=`stat -c %Y $DIR1/$tfile`
2902 [ $mtime2 = $TEST_39_MTIME ] || \
2903 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2905 cancel_lru_locks osc
2906 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2909 run_test 39f "create, stat, sleep, utime, stat ================="
2913 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2914 echo hello >> $DIR1/$tfile
2915 local mtime1=`stat -c %Y $DIR1/$tfile`
2918 chmod o+r $DIR1/$tfile
2920 for (( i=0; i < 2; i++ )) ; do
2921 local mtime2=`stat -c %Y $DIR1/$tfile`
2922 [ "$mtime1" = "$mtime2" ] || \
2923 error "lost mtime: $mtime2, should be $mtime1"
2925 cancel_lru_locks osc
2926 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2929 run_test 39g "write, chmod, stat ==============================="
2933 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2938 echo hello >> $DIR1/$tfile
2939 local mtime1=`stat -c %Y $DIR1/$tfile`
2941 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2943 if [ "$d1" != "$d2" ]; then
2944 echo "write and touch not within one second"
2946 for (( i=0; i < 2; i++ )) ; do
2947 local mtime2=`stat -c %Y $DIR1/$tfile`
2948 [ "$mtime2" = $TEST_39_MTIME ] || \
2949 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2951 cancel_lru_locks osc
2952 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2956 run_test 39h "write, utime within one second, stat ============="
2959 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2963 echo hello >> $DIR1/$tfile
2964 local mtime1=`stat -c %Y $DIR1/$tfile`
2966 mv $DIR1/$tfile $DIR1/$tfile-1
2968 for (( i=0; i < 2; i++ )) ; do
2969 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2971 [ "$mtime1" = "$mtime2" ] || \
2972 error "lost mtime: $mtime2, should be $mtime1"
2974 cancel_lru_locks osc
2975 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2978 run_test 39i "write, rename, stat =============================="
2981 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2982 start_full_debug_logging
2986 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2987 lctl set_param fail_loc=0x80000412
2988 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2989 error "multiop failed"
2991 local mtime1=`stat -c %Y $DIR1/$tfile`
2993 mv $DIR1/$tfile $DIR1/$tfile-1
2995 kill -USR1 $multipid
2996 wait $multipid || error "multiop close failed"
2998 for (( i=0; i < 2; i++ )) ; do
2999 local mtime2=`stat -c %Y $DIR1/$tfile-1`
3000 [ "$mtime1" = "$mtime2" ] ||
3001 error "mtime is lost on close: $mtime2, " \
3004 cancel_lru_locks osc
3005 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3007 lctl set_param fail_loc=0
3008 stop_full_debug_logging
3010 run_test 39j "write, rename, close, stat ======================="
3013 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3017 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3019 local mtime1=`stat -c %Y $DIR1/$tfile`
3021 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3023 kill -USR1 $multipid
3024 wait $multipid || error "multiop close failed"
3026 for (( i=0; i < 2; i++ )) ; do
3027 local mtime2=`stat -c %Y $DIR1/$tfile`
3029 [ "$mtime2" = $TEST_39_MTIME ] || \
3030 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3032 cancel_lru_locks osc
3033 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3036 run_test 39k "write, utime, close, stat ========================"
3038 # this should be set to future
3039 TEST_39_ATIME=`date -d "1 year" +%s`
3042 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3043 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3044 local atime_diff=$(do_facet $SINGLEMDS \
3045 lctl get_param -n mdd.*MDT0000*.atime_diff)
3049 # test setting directory atime to future
3050 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3051 local atime=$(stat -c %X $DIR/$tdir)
3052 [ "$atime" = $TEST_39_ATIME ] || \
3053 error "atime is not set to future: $atime, $TEST_39_ATIME"
3055 # test setting directory atime from future to now
3056 local d1=$(date +%s)
3058 local d2=$(date +%s)
3060 cancel_lru_locks mdc
3061 atime=$(stat -c %X $DIR/$tdir)
3062 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3063 error "atime is not updated from future: $atime, $d1<atime<$d2"
3065 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3068 # test setting directory atime when now > dir atime + atime_diff
3072 cancel_lru_locks mdc
3073 atime=$(stat -c %X $DIR/$tdir)
3074 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3075 error "atime is not updated : $atime, should be $d2"
3077 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3080 # test not setting directory atime when now < dir atime + atime_diff
3082 cancel_lru_locks mdc
3083 atime=$(stat -c %X $DIR/$tdir)
3084 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3085 error "atime is updated to $atime, should remain $d1<atime<$d2"
3087 do_facet $SINGLEMDS \
3088 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3090 run_test 39l "directory atime update ==========================="
3093 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3096 local far_past_mtime=$(date -d "May 29 1953" +%s)
3097 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3099 touch -m -d @$far_past_mtime $DIR1/$tfile
3100 touch -a -d @$far_past_atime $DIR1/$tfile
3102 for (( i=0; i < 2; i++ )) ; do
3103 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3104 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3105 error "atime or mtime set incorrectly"
3107 cancel_lru_locks osc
3108 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3111 run_test 39m "test atime and mtime before 1970"
3113 test_39n() { # LU-3832
3114 local atime_diff=$(do_facet $SINGLEMDS \
3115 lctl get_param -n mdd.*MDT0000*.atime_diff)
3120 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=1
3123 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 status=noxfer
3124 atime0=$(stat -c %X $DIR/$tfile)
3127 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3128 atime1=$(stat -c %X $DIR/$tfile)
3131 cancel_lru_locks mdc
3132 cancel_lru_locks osc
3133 $MULTIOP $DIR/$tfile oO_RDONLY:O_NOATIME:r4096c
3134 atime2=$(stat -c %X $DIR/$tfile)
3136 do_facet $SINGLEMDS \
3137 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3139 [ "$atime0" -eq "$atime1" ] || error "atime0 $atime0 != atime1 $atime1"
3140 [ "$atime1" -eq "$atime2" ] || error "atime0 $atime0 != atime1 $atime1"
3142 run_test 39n "check that O_NOATIME is honored"
3145 TESTDIR=$DIR/$tdir/$tfile
3146 [ -e $TESTDIR ] && rm -rf $TESTDIR
3147 test_mkdir -p $TESTDIR
3153 links2=$(stat -c %h .)
3154 [ $(($links1 + 2)) != $links2 ] &&
3155 error "wrong links count $(($links1 + 2)) != $links2"
3157 links3=$(stat -c %h .)
3158 [ $(($links1 + 1)) != $links3 ] &&
3159 error "wrong links count $links1 != $links3"
3162 run_test 39o "directory cached attributes updated after create ========"
3165 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
3167 TESTDIR=$DIR/$tdir/$tfile
3168 [ -e $TESTDIR ] && rm -rf $TESTDIR
3173 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir1
3174 $LFS mkdir -i $MDTIDX $TESTDIR/remote_dir2
3176 links2=$(stat -c %h .)
3177 [ $(($links1 + 2)) != $links2 ] &&
3178 error "wrong links count $(($links1 + 2)) != $links2"
3180 links3=$(stat -c %h .)
3181 [ $(($links1 + 1)) != $links3 ] &&
3182 error "wrong links count $links1 != $links3"
3185 run_test 39p "remote directory cached attributes updated after create ========"
3189 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3190 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3191 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3192 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3193 error "$tfile is not 4096 bytes in size"
3195 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3199 small_write $DIR/f41 18
3201 run_test 41 "test small file write + fstat ====================="
3203 count_ost_writes() {
3204 lctl get_param -n osc.*.stats |
3205 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3212 BG_DIRTY_RATIO_SAVE=10
3213 MAX_BG_DIRTY_RATIO=25
3217 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3218 # dirty_ratio, dirty_background_ratio
3219 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3220 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3221 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3222 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3224 # if file not here, we are a 2.4 kernel
3225 kill -CONT `pidof kupdated`
3230 # setup the trap first, so someone cannot exit the test at the
3231 # exact wrong time and mess up a machine
3232 trap start_writeback EXIT
3233 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3234 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3235 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3236 sysctl -w vm.dirty_writeback_centisecs=0
3237 sysctl -w vm.dirty_writeback_centisecs=0
3238 # save and increase /proc/sys/vm/dirty_ratio
3239 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3240 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3241 # save and increase /proc/sys/vm/dirty_background_ratio
3242 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3243 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3245 # if file not here, we are a 2.4 kernel
3246 kill -STOP `pidof kupdated`
3250 # ensure that all stripes have some grant before we test client-side cache
3252 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3253 dd if=/dev/zero of=$i bs=4k count=1
3258 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3259 # file truncation, and file removal.
3261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3263 cancel_lru_locks osc
3265 sync; sleep 1; sync # just to be safe
3266 BEFOREWRITES=`count_ost_writes`
3267 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3268 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3269 AFTERWRITES=`count_ost_writes`
3270 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3271 error "$BEFOREWRITES < $AFTERWRITES"
3274 run_test 42a "ensure that we don't flush on close =============="
3277 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3279 cancel_lru_locks osc
3282 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3283 BEFOREWRITES=`count_ost_writes`
3284 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3285 AFTERWRITES=`count_ost_writes`
3286 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3287 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3289 BEFOREWRITES=`count_ost_writes`
3290 sync || error "sync: $?"
3291 AFTERWRITES=`count_ost_writes`
3292 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3293 error "$BEFOREWRITES < $AFTERWRITES on sync"
3295 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3299 run_test 42b "test destroy of file with cached dirty data ======"
3301 # if these tests just want to test the effect of truncation,
3302 # they have to be very careful. consider:
3303 # - the first open gets a {0,EOF}PR lock
3304 # - the first write conflicts and gets a {0, count-1}PW
3305 # - the rest of the writes are under {count,EOF}PW
3306 # - the open for truncate tries to match a {0,EOF}PR
3307 # for the filesize and cancels the PWs.
3308 # any number of fixes (don't get {0,EOF} on open, match
3309 # composite locks, do smarter file size management) fix
3310 # this, but for now we want these tests to verify that
3311 # the cancellation with truncate intent works, so we
3312 # start the file with a full-file pw lock to match against
3313 # until the truncate.
3318 cancel_lru_locks osc
3320 # prime the file with 0,EOF PW to match
3324 # now the real test..
3325 dd if=/dev/zero of=$file bs=1024 count=100
3326 BEFOREWRITES=`count_ost_writes`
3327 $TRUNCATE $file $offset
3328 cancel_lru_locks osc
3329 AFTERWRITES=`count_ost_writes`
3334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3336 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3337 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3340 run_test 42c "test partial truncate of file with cached dirty data"
3343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3345 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3346 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3349 run_test 42d "test complete truncate of file with cached dirty data"
3351 test_42e() { # bug22074
3352 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3353 local TDIR=$DIR/${tdir}e
3354 local pagesz=$(page_size)
3355 local pages=16 # hardcoded 16 pages, don't change it.
3356 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3357 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3361 test_mkdir -p $DIR/${tdir}e
3362 $SETSTRIPE -c 1 $TDIR
3363 createmany -o $TDIR/f $files
3365 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3367 # we assume that with $OSTCOUNT files, at least one of them will
3368 # be allocated on OST0.
3369 warmup_files=$((OSTCOUNT * max_dirty_mb))
3370 createmany -o $TDIR/w $warmup_files
3372 # write a large amount of data into one file and sync, to get good
3373 # avail_grant number from OST.
3374 for ((i=0; i<$warmup_files; i++)); do
3375 idx=$($GETSTRIPE -i $TDIR/w$i)
3376 [ $idx -ne 0 ] && continue
3377 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3380 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3382 $LCTL get_param $proc_osc0/cur_dirty_bytes
3383 $LCTL get_param $proc_osc0/cur_grant_bytes
3385 # create as much dirty pages as we can while not to trigger the actual
3386 # RPCs directly. but depends on the env, VFS may trigger flush during this
3387 # period, hopefully we are good.
3388 for ((i=0; i<$warmup_files; i++)); do
3389 idx=$($GETSTRIPE -i $TDIR/w$i)
3390 [ $idx -ne 0 ] && continue
3391 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3393 $LCTL get_param $proc_osc0/cur_dirty_bytes
3394 $LCTL get_param $proc_osc0/cur_grant_bytes
3396 # perform the real test
3397 $LCTL set_param $proc_osc0/rpc_stats 0
3398 for ((;i<$files; i++)); do
3399 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3400 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3403 $LCTL get_param $proc_osc0/rpc_stats
3406 local have_ppr=false
3407 $LCTL get_param $proc_osc0/rpc_stats |
3408 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3409 # skip lines until we are at the RPC histogram data
3410 [ "$PPR" == "pages" ] && have_ppr=true && continue
3411 $have_ppr || continue
3413 # we only want the percent stat for < 16 pages
3414 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3416 percent=$((percent + WPCT))
3417 if [ $percent -gt 15 ]; then
3418 error "less than 16-pages write RPCs" \
3425 run_test 42e "verify sub-RPC writes are not done synchronously"
3428 test_mkdir -p $DIR/$tdir
3429 cp -p /bin/ls $DIR/$tdir/$tfile
3430 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3432 # give multiop a chance to open
3435 $DIR/$tdir/$tfile && error || true
3438 run_test 43 "execution of file opened for write should return -ETXTBSY"
3441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3442 test_mkdir -p $DIR/$tdir
3443 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3444 cp -p multiop $DIR/$tdir/multiop
3445 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3448 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3449 kill -USR1 $MULTIOP_PID || return 2
3450 wait $MULTIOP_PID || return 3
3451 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3453 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3457 test_mkdir -p $DIR/$tdir
3458 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3459 cp -p multiop $DIR/$tdir/multiop
3460 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/$tfile.junk O_c ||
3463 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3464 kill -USR1 $MULTIOP_PID || return 2
3465 wait $MULTIOP_PID || return 3
3466 rm $TMP/$tfile.junk $DIR/$tdir/multiop
3468 run_test 43b "truncate of file being executed should return -ETXTBSY"
3471 local testdir="$DIR/$tdir"
3472 test_mkdir -p $DIR/$tdir
3474 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3475 ( cd $testdir && md5sum -c)
3477 run_test 43c "md5sum of copy into lustre========================"
3480 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3481 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3482 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3484 run_test 44 "zero length read from a sparse stripe ============="
3487 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3489 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3490 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3491 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3493 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3494 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3497 OFFSETS="0 $((stride/2)) $((stride-1))"
3498 for offset in $OFFSETS ; do
3499 for i in `seq 0 $((nstripe-1))`; do
3500 local GLOBALOFFSETS=""
3501 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3502 local myfn=$DIR/d44a-$size
3503 echo "--------writing $myfn at $size"
3504 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3505 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3506 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3507 || error "ll_sparseness_verify $GLOBALOFFSETS"
3509 for j in `seq 0 $((nstripe-1))`; do
3510 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3511 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3512 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3514 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3515 || error "ll_sparseness_verify $GLOBALOFFSETS"
3520 run_test 44a "test sparse pwrite ==============================="
3524 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3530 before=`dirty_osc_total`
3531 echo executing "\"$*\""
3533 after=`dirty_osc_total`
3534 echo before $before, after $after
3537 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3539 # Obtain grants from OST if it supports it
3540 echo blah > ${f}_grant
3543 do_dirty_record "echo blah > $f"
3544 [ $before -eq $after ] && error "write wasn't cached"
3545 do_dirty_record "> $f"
3546 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3547 do_dirty_record "echo blah > $f"
3548 [ $before -eq $after ] && error "write wasn't cached"
3549 do_dirty_record "sync"
3550 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3551 do_dirty_record "echo blah > $f"
3552 [ $before -eq $after ] && error "write wasn't cached"
3553 do_dirty_record "cancel_lru_locks osc"
3554 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3557 run_test 45 "osc io page accounting ============================"
3559 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3560 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3561 # objects offset and an assert hit when an rpc was built with 1023's mapped
3562 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3564 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3568 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3570 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3571 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3575 run_test 46 "dirtying a previously written page ================"
3577 # test_47 is removed "Device nodes check" is moved to test_28
3579 test_48a() { # bug 2399
3580 check_kernel_version 34 || return 0
3581 test_mkdir -p $DIR/$tdir
3583 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3584 test_mkdir $DIR/$tdir || error "recreate directory failed"
3585 touch foo || error "'touch foo' failed after recreating cwd"
3586 test_mkdir $DIR/$tdir/bar ||
3587 error "'mkdir foo' failed after recreating cwd"
3588 if check_kernel_version 44; then
3589 touch .foo || error "'touch .foo' failed after recreating cwd"
3590 test_mkdir $DIR/$tdir/.bar ||
3591 error "'mkdir .foo' failed after recreating cwd"
3593 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3594 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3595 cd . || error "'cd .' failed after recreating cwd"
3596 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3597 rmdir . && error "'rmdir .' worked after recreating cwd"
3598 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3599 cd .. || error "'cd ..' failed after recreating cwd"
3601 run_test 48a "Access renamed working dir (should return errors)="
3603 test_48b() { # bug 2399
3604 check_kernel_version 34 || return 0
3606 test_mkdir -p $DIR/$tdir
3608 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3609 touch foo && error "'touch foo' worked after removing cwd"
3610 test_mkdir $DIR/$tdir/foo &&
3611 error "'mkdir foo' worked after removing cwd"
3612 if check_kernel_version 44; then
3613 touch .foo && error "'touch .foo' worked after removing cwd"
3614 test_mkdir $DIR/$tdir/.foo &&
3615 error "'mkdir .foo' worked after removing cwd"
3617 ls . > /dev/null && error "'ls .' worked after removing cwd"
3618 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3619 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3620 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3621 rmdir . && error "'rmdir .' worked after removing cwd"
3622 ln -s . foo && error "'ln -s .' worked after removing cwd"
3623 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3625 run_test 48b "Access removed working dir (should return errors)="
3627 test_48c() { # bug 2350
3628 check_kernel_version 36 || return 0
3629 #lctl set_param debug=-1
3632 test_mkdir -p $DIR/$tdir/dir
3634 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3635 $TRACE touch foo && error "touch foo worked after removing cwd"
3636 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3637 if check_kernel_version 44; then
3638 touch .foo && error "touch .foo worked after removing cwd"
3639 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3641 $TRACE ls . && error "'ls .' worked after removing cwd"
3642 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3643 is_patchless || ( $TRACE cd . &&
3644 error "'cd .' worked after removing cwd" )
3645 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3646 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3647 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3648 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3650 run_test 48c "Access removed working subdir (should return errors)"
3652 test_48d() { # bug 2350
3653 check_kernel_version 36 || return 0
3654 #lctl set_param debug=-1
3657 test_mkdir -p $DIR/$tdir/dir
3659 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3660 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3661 $TRACE touch foo && error "'touch foo' worked after removing parent"
3662 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3663 if check_kernel_version 44; then
3664 touch .foo && error "'touch .foo' worked after removing parent"
3666 error "mkdir .foo worked after removing parent"
3668 $TRACE ls . && error "'ls .' worked after removing parent"
3669 $TRACE ls .. && error "'ls ..' worked after removing parent"
3670 is_patchless || ( $TRACE cd . &&
3671 error "'cd .' worked after recreate parent" )
3672 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3673 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3674 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3675 is_patchless || ( $TRACE cd .. &&
3676 error "'cd ..' worked after removing parent" || true )
3678 run_test 48d "Access removed parent subdir (should return errors)"
3680 test_48e() { # bug 4134
3681 check_kernel_version 41 || return 0
3682 #lctl set_param debug=-1
3685 test_mkdir -p $DIR/$tdir/dir
3687 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3688 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3689 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3690 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3691 # On a buggy kernel addition of "touch foo" after cd .. will
3692 # produce kernel oops in lookup_hash_it
3693 touch ../foo && error "'cd ..' worked after recreate parent"
3695 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3697 run_test 48e "Access to recreated parent subdir (should return errors)"
3699 test_49() { # LU-1030
3700 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3701 # get ost1 size - lustre-OST0000
3702 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3703 # write 800M at maximum
3704 [ $ost1_size -gt 819200 ] && ost1_size=819200
3706 lfs setstripe -c 1 -i 0 $DIR/$tfile
3707 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3710 # change max_pages_per_rpc while writing the file
3711 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3712 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3713 # loop until dd process exits
3714 while ps ax -opid | grep -wq $dd_pid; do
3715 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3716 sleep $((RANDOM % 5 + 1))
3718 # restore original max_pages_per_rpc
3719 $LCTL set_param $osc1_mppc=$orig_mppc
3720 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3722 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3726 test_mkdir $DIR/$tdir
3728 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3730 run_test 50 "special situations: /proc symlinks ==============="
3732 test_51a() { # was test_51
3733 # bug 1516 - create an empty entry right after ".." then split dir
3734 test_mkdir -p $DIR/$tdir
3735 touch $DIR/$tdir/foo
3736 $MCREATE $DIR/$tdir/bar
3738 createmany -m $DIR/$tdir/longfile 201
3740 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3741 $MCREATE $DIR/$tdir/longfile$FNUM
3746 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3748 run_test 51a "special situations: split htree with empty entry =="
3750 export NUMTEST=70000
3752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3753 local BASE=$DIR/d${base}.${TESTSUITE}
3755 # cleanup the directory
3760 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3761 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3762 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3765 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3766 echo "reduced count to $NUMTEST due to inodes"
3768 # need to check free space for the directories as well
3769 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3770 numfree=$((blkfree / 4))
3771 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3772 echo "reduced count to $NUMTEST due to blocks"
3774 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3775 echo "failed" > $BASE/fnum
3777 run_test 51b "exceed 64k subdirectory nlink limit"
3779 test_51ba() { # LU-993
3780 local BASE=$DIR/d${base}.${TESTSUITE}
3781 # unlink all but 100 subdirectories, then check it still works
3783 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3785 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3786 local DELETE=$((NUMTEST - LEFT))
3788 # continue on to run this test even if 51b didn't finish,
3789 # just to delete the many subdirectories created.
3790 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3792 # for ldiskfs the nlink count should be 1, but this is OSD specific
3793 # and so this is listed for informational purposes only
3794 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3795 unlinkmany -d $BASE/d $DELETE
3798 if [ $RC -ne 0 ]; then
3799 if [ "$NUMPREV" == "failed" ]; then
3800 skip "previous setup failed"
3803 error "unlink of first $DELETE subdirs failed"
3808 echo "nlink between: $(stat -c %h $BASE)"
3809 # trim the first line of ls output
3810 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3811 [ $FOUND -ne $LEFT ] &&
3812 error "can't find subdirs: found only $FOUND/$LEFT"
3814 unlinkmany -d $BASE/d $DELETE $LEFT ||
3815 error "unlink of second $LEFT subdirs failed"
3816 # regardless of whether the backing filesystem tracks nlink accurately
3817 # or not, the nlink count shouldn't be more than "." and ".." here
3818 local AFTER=$(stat -c %h $BASE)
3819 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3820 echo "nlink after: $AFTER"
3822 run_test 51ba "verify nlink for many subdirectory cleanup"
3825 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3826 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3827 test_mkdir -p $DIR/$tdir
3828 createmany -o $DIR/$tdir/t- 1000
3829 $GETSTRIPE $DIR/$tdir > $TMP/files
3830 for N in `seq 0 $((OSTCOUNT - 1))`; do
3831 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3832 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3833 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3835 unlinkmany $DIR/$tdir/t- 1000
3838 for N in `seq 1 $((OSTCOUNT - 1))`; do
3839 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3840 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3841 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3842 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3844 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3845 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3846 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3847 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3851 run_test 51d "check object distribution ===================="
3854 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3855 test_mkdir -p $DIR/$tdir
3856 touch $DIR/$tdir/foo
3857 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3858 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3859 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3860 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3861 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3863 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3864 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3865 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3867 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3868 cp -r $DIR/$tdir /tmp/
3869 rm -fr $DIR/$tdir || error "cleanup rm failed"
3871 run_test 52a "append-only flag test (should return errors) ====="
3874 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3875 test_mkdir -p $DIR/$tdir
3876 touch $DIR/$tdir/foo
3877 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3878 cat test > $DIR/$tdir/foo && error "cat test worked"
3879 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3880 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3881 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3883 echo foo >> $DIR/$tdir/foo && error "echo worked"
3884 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3885 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3886 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3887 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3889 chattr -i $DIR/$tdir/foo || error "chattr failed"
3891 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3893 run_test 52b "immutable flag test (should return errors) ======="
3896 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3897 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3898 remote_ost_nodsh && skip "remote OST with nodsh" && return
3911 local support_last_seq=true
3913 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
3914 support_last_seq=false
3917 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3919 for value in $(do_facet $SINGLEMDS \
3920 $LCTL get_param osc.$mdtosc.prealloc_last_id) ; do
3921 param=$(echo ${value[0]} | cut -d "=" -f1)
3922 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3924 if $support_last_seq; then
3925 param_seq=$(echo $param |
3926 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3927 mds_last_seq=$(do_facet $SINGLEMDS \
3928 $LCTL get_param -n $param_seq)
3930 mds_last=$(do_facet $SINGLEMDS $LCTL get_param -n $param)
3932 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3933 node=$(facet_active_host ost$((ostnum+1)))
3934 param="obdfilter.$ostname.last_id"
3935 for ost_last in $(do_node $node $LCTL get_param -n $param) ; do
3936 echo "$ostname.last_id=$ost_last; MDS.last_id=$mds_last"
3937 ost_last_id=$ost_last
3939 if $support_last_seq; then
3940 ost_last_id=$(echo $ost_last |
3941 awk -F':' '{print $2}' |
3943 ost_last_seq=$(echo $ost_last |
3944 awk -F':' '{print $1}')
3945 [[ $ost_last_seq = $mds_last_seq ]] || continue
3948 if [[ $ost_last_id != $mds_last ]]; then
3949 error "$ost_last_id != $mds_last"
3956 $found || error "can not match last_seq/last_id for $mdtosc"
3959 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3962 $SOCKETSERVER $DIR/socket ||
3963 error "$SOCKETSERVER $DIR/socket failed: $?"
3964 $SOCKETCLIENT $DIR/socket ||
3965 error "$SOCKETCLIENT $DIR/socket failed: $?"
3966 $MUNLINK $DIR/socket || error "$MUNLINK $DIR/socket failed: $?"
3968 run_test 54a "unix domain socket test =========================="
3974 dd if=/dev/zero of=$f bs=$(page_size) count=1
3976 run_test 54b "char device works in lustre ======================"
3979 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3980 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3981 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3983 for i in $(seq 3 7); do
3984 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3992 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3995 loopdev="$DIR/loop54c"
3998 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3999 mknod $loopdev b 7 $LOOPNUM
4000 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
4001 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
4002 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
4003 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
4005 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
4006 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
4008 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
4013 run_test 54c "block device works in lustre ====================="
4019 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
4021 run_test 54d "fifo device works in lustre ======================"
4024 check_kernel_version 46 || return 0
4027 cp -aL /dev/console $f
4028 echo $string > $f || error "echo $string to $f failed"
4030 run_test 54e "console/tty device works in lustre ======================"
4032 #The test_55 used to be iopen test and it was removed by bz#24037.
4033 #run_test 55 "check iopen_connect_dentry() ======================"
4035 test_56a() { # was test_56
4038 test_mkdir -p $DIR/$tdir/dir
4040 NUMFILESx2=$(($NUMFILES * 2))
4041 for i in `seq 1 $NUMFILES` ; do
4042 touch $DIR/$tdir/file$i
4043 touch $DIR/$tdir/dir/file$i
4046 # test lfs getstripe with --recursive
4047 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
4048 [ $FILENUM -eq $NUMFILESx2 ] ||
4049 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
4050 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
4051 [ $FILENUM -eq $NUMFILES ] ||
4052 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
4053 echo "$GETSTRIPE --recursive passed."
4055 # test lfs getstripe with file instead of dir
4056 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
4057 [ $FILENUM -eq 1 ] || error \
4058 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
4059 echo "$GETSTRIPE file1 passed."
4061 #test lfs getstripe with --verbose
4062 [ `$GETSTRIPE --verbose $DIR/$tdir |
4063 grep -c lmm_magic` -eq $NUMFILES ] ||
4064 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
4065 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
4066 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
4067 echo "$GETSTRIPE --verbose passed."
4069 #test lfs getstripe with --obd
4070 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
4071 grep -q "unknown obduuid" ||
4072 error "$GETSTRIPE --obd wrong_uuid should return error message"
4074 [ "$OSTCOUNT" -lt 2 ] &&
4075 skip_env "skipping other $GETSTRIPE --obd test" && return
4078 OBDUUID=$(ostuuid_from_index $OSTIDX)
4079 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
4080 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
4081 [ $FOUND -eq $FILENUM ] ||
4082 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
4083 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
4084 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
4085 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
4086 error "$GETSTRIPE --obd: should not show file on other obd"
4087 echo "$GETSTRIPE --obd passed"
4089 run_test 56a "check $GETSTRIPE"
4094 local LOCAL_NUMFILES="$1"
4095 local LOCAL_NUMDIRS="$2"
4096 local MKDIR_PARAMS="$3"
4098 if [ ! -d "$TDIR" ] ; then
4100 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
4101 for i in `seq 1 $LOCAL_NUMFILES` ; do
4104 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4105 test_mkdir $TDIR/dir$i
4106 for j in `seq 1 $LOCAL_NUMFILES` ; do
4107 touch $TDIR/dir$i/file$j
4113 setup_56_special() {
4117 if [ ! -e "$TDIR/loop1b" ] ; then
4118 for i in `seq 1 $LOCAL_NUMFILES` ; do
4119 mknod $TDIR/loop${i}b b 7 $i
4120 mknod $TDIR/null${i}c c 1 3
4121 ln -s $TDIR/file1 $TDIR/link${i}l
4123 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4124 mknod $TDIR/dir$i/loop${i}b b 7 $i
4125 mknod $TDIR/dir$i/null${i}c c 1 3
4126 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4135 setup_56 $NUMFILES $NUMDIRS
4137 EXPECTED=$(($NUMDIRS + 2))
4138 # test lfs find with -name
4139 for i in $(seq 1 $NUMFILES) ; do
4140 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4141 [ $NUMS -eq $EXPECTED ] ||
4142 error "lfs find -name \"*$i\" $TDIR wrong: "\
4143 "found $NUMS, expected $EXPECTED"
4146 run_test 56g "check lfs find -name ============================="
4152 setup_56 $NUMFILES $NUMDIRS
4154 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4155 # test lfs find with ! -name
4156 for i in $(seq 1 $NUMFILES) ; do
4157 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4158 [ $NUMS -eq $EXPECTED ] ||
4159 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4160 "found $NUMS, expected $EXPECTED"
4163 run_test 56h "check lfs find ! -name ============================="
4167 test_mkdir -p $DIR/$tdir
4168 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4169 CMD="$LFIND -ost $UUID $DIR/$tdir"
4171 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4173 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4177 setup_56_special $NUMFILES $NUMDIRS
4179 EXPECTED=$((NUMDIRS + 1))
4180 CMD="$LFIND -type d $TDIR"
4181 NUMS=$($CMD | wc -l)
4182 [ $NUMS -eq $EXPECTED ] ||
4183 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4185 run_test 56j "check lfs find -type d ============================="
4189 setup_56_special $NUMFILES $NUMDIRS
4191 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4192 CMD="$LFIND -type f $TDIR"
4193 NUMS=$($CMD | wc -l)
4194 [ $NUMS -eq $EXPECTED ] ||
4195 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4197 run_test 56k "check lfs find -type f ============================="
4201 setup_56_special $NUMFILES $NUMDIRS
4203 EXPECTED=$((NUMDIRS + NUMFILES))
4204 CMD="$LFIND -type b $TDIR"
4205 NUMS=$($CMD | wc -l)
4206 [ $NUMS -eq $EXPECTED ] ||
4207 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4209 run_test 56l "check lfs find -type b ============================="
4213 setup_56_special $NUMFILES $NUMDIRS
4215 EXPECTED=$((NUMDIRS + NUMFILES))
4216 CMD="$LFIND -type c $TDIR"
4217 NUMS=$($CMD | wc -l)
4218 [ $NUMS -eq $EXPECTED ] ||
4219 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4221 run_test 56m "check lfs find -type c ============================="
4225 setup_56_special $NUMFILES $NUMDIRS
4227 EXPECTED=$((NUMDIRS + NUMFILES))
4228 CMD="$LFIND -type l $TDIR"
4229 NUMS=$($CMD | wc -l)
4230 [ $NUMS -eq $EXPECTED ] ||
4231 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4233 run_test 56n "check lfs find -type l ============================="
4237 setup_56 $NUMFILES $NUMDIRS
4239 utime $TDIR/file1 > /dev/null || error "utime (1)"
4240 utime $TDIR/file2 > /dev/null || error "utime (2)"
4241 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4242 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4243 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4244 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4247 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4248 [ $NUMS -eq $EXPECTED ] || \
4249 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4252 CMD="$LFIND -mtime 0 $TDIR"
4253 NUMS=$($CMD | wc -l)
4254 [ $NUMS -eq $EXPECTED ] ||
4255 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4257 run_test 56o "check lfs find -mtime for old files =========================="
4260 [ $RUNAS_ID -eq $UID ] &&
4261 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4264 setup_56 $NUMFILES $NUMDIRS
4266 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4268 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4269 NUMS=$($CMD | wc -l)
4270 [ $NUMS -eq $EXPECTED ] || \
4271 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4273 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4274 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4275 NUMS=$($CMD | wc -l)
4276 [ $NUMS -eq $EXPECTED ] || \
4277 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4279 run_test 56p "check lfs find -uid and ! -uid ==============================="
4282 [ $RUNAS_ID -eq $UID ] &&
4283 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4286 setup_56 $NUMFILES $NUMDIRS
4288 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4291 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4292 NUMS=$($CMD | wc -l)
4293 [ $NUMS -eq $EXPECTED ] ||
4294 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4296 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4297 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4298 NUMS=$($CMD | wc -l)
4299 [ $NUMS -eq $EXPECTED ] ||
4300 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4302 run_test 56q "check lfs find -gid and ! -gid ==============================="
4306 setup_56 $NUMFILES $NUMDIRS
4309 CMD="$LFIND -size 0 -type f $TDIR"
4310 NUMS=$($CMD | wc -l)
4311 [ $NUMS -eq $EXPECTED ] ||
4312 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4314 CMD="$LFIND ! -size 0 -type f $TDIR"
4315 NUMS=$($CMD | wc -l)
4316 [ $NUMS -eq $EXPECTED ] ||
4317 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4318 echo "test" > $TDIR/$tfile
4319 echo "test2" > $TDIR/$tfile.2 && sync
4321 CMD="$LFIND -size 5 -type f $TDIR"
4322 NUMS=$($CMD | wc -l)
4323 [ $NUMS -eq $EXPECTED ] ||
4324 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4326 CMD="$LFIND -size +5 -type f $TDIR"
4327 NUMS=$($CMD | wc -l)
4328 [ $NUMS -eq $EXPECTED ] ||
4329 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4331 CMD="$LFIND -size +0 -type f $TDIR"
4332 NUMS=$($CMD | wc -l)
4333 [ $NUMS -eq $EXPECTED ] ||
4334 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4336 CMD="$LFIND ! -size -5 -type f $TDIR"
4337 NUMS=$($CMD | wc -l)
4338 [ $NUMS -eq $EXPECTED ] ||
4339 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4341 CMD="$LFIND -size -5 -type f $TDIR"
4342 NUMS=$($CMD | wc -l)
4343 [ $NUMS -eq $EXPECTED ] ||
4344 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4346 run_test 56r "check lfs find -size works =========================="
4348 test_56s() { # LU-611
4350 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4352 if [ $OSTCOUNT -gt 1 ]; then
4353 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4357 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4361 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4362 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4363 NUMS=$($CMD | wc -l)
4364 [ $NUMS -eq $EXPECTED ] ||
4365 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4367 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4368 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4369 NUMS=$($CMD | wc -l)
4370 [ $NUMS -eq $EXPECTED ] ||
4371 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4374 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4375 NUMS=$($CMD | wc -l)
4376 [ $NUMS -eq $EXPECTED ] ||
4377 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4379 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4380 NUMS=$($CMD | wc -l)
4381 [ $NUMS -eq $EXPECTED ] ||
4382 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4385 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4386 NUMS=$($CMD | wc -l)
4387 [ $NUMS -eq $EXPECTED ] ||
4388 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4390 run_test 56s "check lfs find -stripe-count works"
4392 test_56t() { # LU-611
4394 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4396 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4398 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4399 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4400 NUMS=$($CMD | wc -l)
4401 [ $NUMS -eq $EXPECTED ] ||
4402 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4404 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4405 NUMS=$($CMD | wc -l)
4406 [ $NUMS -eq $EXPECTED ] ||
4407 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4409 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4410 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4411 NUMS=$($CMD | wc -l)
4412 [ $NUMS -eq $EXPECTED ] ||
4413 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4415 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4416 NUMS=$($CMD | wc -l)
4417 [ $NUMS -eq $EXPECTED ] ||
4418 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4421 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4422 NUMS=$($CMD | wc -l)
4423 [ $NUMS -eq $EXPECTED ] ||
4424 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4426 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4427 NUMS=$($CMD | wc -l)
4428 [ $NUMS -eq $EXPECTED ] ||
4429 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4432 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4433 NUMS=$($CMD | wc -l)
4434 [ $NUMS -eq $EXPECTED ] ||
4435 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4437 run_test 56t "check lfs find -stripe-size works"
4439 test_56u() { # LU-611
4441 setup_56 $NUMFILES $NUMDIRS "-i 0"
4443 if [ $OSTCOUNT -gt 1 ]; then
4444 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4450 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4451 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4452 NUMS=$($CMD | wc -l)
4453 [ $NUMS -eq $EXPECTED ] ||
4454 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4457 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4458 NUMS=$($CMD | wc -l)
4459 [ $NUMS -eq $EXPECTED ] ||
4460 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4462 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4463 NUMS=$($CMD | wc -l)
4464 [ $NUMS -eq $EXPECTED ] ||
4465 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4468 # This should produce an error and not return any files
4469 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4470 NUMS=$($CMD 2>/dev/null | wc -l)
4471 [ $NUMS -eq $EXPECTED ] ||
4472 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4474 if [ $OSTCOUNT -gt 1 ]; then
4475 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4476 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4477 NUMS=$($CMD | wc -l)
4478 [ $NUMS -eq $EXPECTED ] ||
4479 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4482 run_test 56u "check lfs find -stripe-index works"
4489 setup_56 $NUMFILES $NUMDIRS
4491 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4492 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4494 for file in $($LFIND -mdt $UUID $TDIR); do
4495 file_mdt_idx=$($GETSTRIPE -M $file)
4496 [ $file_mdt_idx -eq $MDT_IDX ] ||
4497 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4500 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4502 # Get and check the actual stripe count of one file.
4503 # Usage: check_stripe_count <file> <expected_stripe_count>
4504 check_stripe_count() {
4509 [[ -z "$file" || -z "$expected" ]] &&
4510 error "check_stripe_count: invalid argument!"
4512 local cmd="$GETSTRIPE -c $file"
4513 actual=$($cmd) || error "$cmd failed"
4514 actual=${actual%% *}
4516 if [[ $actual -ne $expected ]]; then
4517 [[ $expected -eq -1 ]] ||
4518 error "$cmd wrong: found $actual, expected $expected"
4519 [[ $actual -eq $OSTCOUNT ]] ||
4520 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4525 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4528 rm -rf $TDIR || error "remove $TDIR failed"
4529 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4532 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4533 error "$GETSTRIPE -S -d $TDIR failed"
4534 stripe_size=${stripe_size%% *}
4536 local file_size=$((stripe_size * OSTCOUNT))
4537 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4538 local required_space=$((file_num * file_size))
4539 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4540 [[ $free_space -le $((required_space / 1024)) ]] &&
4541 skip_env "need at least $required_space bytes free space," \
4542 "have $free_space kbytes" && return
4545 local dd_count=$((file_size / dd_bs))
4547 # write data into the files
4551 for i in $(seq 1 $NUMFILES); do
4553 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4554 error "write data into $file failed"
4556 for i in $(seq 1 $NUMDIRS); do
4557 for j in $(seq 1 $NUMFILES); do
4558 file=$TDIR/dir$i/file$j
4559 yes | dd bs=$dd_bs count=$dd_count of=$file \
4561 error "write data into $file failed"
4566 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4569 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4571 eval $cmd || error "$cmd failed"
4573 check_stripe_count $TDIR/file1 $expected
4576 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4578 eval $cmd || error "$cmd failed"
4580 for j in $(seq 1 $NUMFILES); do
4581 check_stripe_count $TDIR/dir1/file$j $expected
4584 # lfs_migrate works with lfs find
4585 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4586 $LFS_MIGRATE -y -c $expected"
4588 eval $cmd || error "$cmd failed"
4590 for i in $(seq 2 $NUMFILES); do
4591 check_stripe_count $TDIR/file$i $expected
4593 for i in $(seq 2 $NUMDIRS); do
4594 for j in $(seq 1 $NUMFILES); do
4595 check_stripe_count $TDIR/dir$i/file$j $expected
4599 run_test 56w "check lfs_migrate -c stripe_count works"
4602 check_swap_layouts_support && return 0
4603 [ "$OSTCOUNT" -lt "2" ] &&
4604 skip_env "need 2 OST, skipping test" && return
4606 local dir0=$DIR/$tdir/$testnum
4607 mkdir -p $dir0 || error "creating dir $dir0"
4609 local ref1=/etc/passwd
4610 local file1=$dir0/file1
4612 $SETSTRIPE -c 2 $file1
4614 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4615 stripe=$($GETSTRIPE -c $file1)
4616 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4617 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4622 run_test 56x "lfs migration support"
4625 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
4626 skip "No HSM support on MDS of $(get_lustre_version)," \
4627 "need 2.4.53 at least" && return
4630 local dir0=$DIR/$tdir/$testnum
4631 mkdir -p $dir0 || error "creating dir $dir0"
4632 local f1=$dir0/file1
4633 local f2=$dir0/file2
4635 touch $f1 || error "creating std file $f1"
4636 $MULTIOP $f2 H2c || error "creating released file $f2"
4638 # a directory can be raid0, so ask only for files
4639 res=$($LFIND $dir0 -L raid0 -type f | wc -l)
4640 [[ $res == 2 ]] || error "search raid0: found $res files != 2"
4642 res=$($LFIND $dir0 \! -L raid0 -type f | wc -l)
4643 [[ $res == 0 ]] || error "search !raid0: found $res files != 0"
4645 # only files can be released, so no need to force file search
4646 res=$($LFIND $dir0 -L released)
4647 [[ $res == $f2 ]] || error "search released: found $res != $f2"
4649 res=$($LFIND $dir0 \! -L released)
4650 [[ $res == $f1 ]] || error "search !released: found $res != $f1"
4653 run_test 56y "lfs find -L raid0|released"
4656 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4657 # note test will not do anything if MDS is not local
4658 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4659 skip "Only applicable to ldiskfs-based MDTs"
4663 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4664 local MNTDEV="osd*.*MDT*.mntdev"
4665 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4666 [ -z "$DEV" ] && error "can't access $MNTDEV"
4667 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4668 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4669 error "can't access $DEV"
4670 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4671 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4675 run_test 57a "verify MDS filesystem created with large inodes =="
4678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4679 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4680 skip "Only applicable to ldiskfs-based MDTs"
4684 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4689 local FILEN=$dir/f$FILECOUNT
4691 rm -rf $dir || error "removing $dir"
4692 test_mkdir -p $dir || error "creating $dir"
4693 local num=$(get_mds_dir $dir)
4696 echo "mcreating $FILECOUNT files"
4697 createmany -m $dir/f 1 $FILECOUNT || \
4698 error "creating files in $dir"
4700 # verify that files do not have EAs yet
4701 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4702 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4706 df $dir #make sure we get new statfs data
4707 local MDSFREE=$(do_facet $mymds \
4708 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4709 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4710 echo "opening files to create objects/EAs"
4712 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4713 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4716 # verify that files have EAs now
4717 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4718 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4720 sleep 1 #make sure we get new statfs data
4722 local MDSFREE2=$(do_facet $mymds \
4723 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4724 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4725 if [ "$MDCFREE2" -lt "$((MDCFREE - 16))" ]; then
4726 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4727 error "MDC before $MDCFREE != after $MDCFREE2"
4729 echo "MDC before $MDCFREE != after $MDCFREE2"
4730 echo "unable to confirm if MDS has large inodes"
4735 run_test 57b "default LOV EAs are stored inside large inodes ==="
4738 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4739 [ -z "$(which wiretest 2>/dev/null)" ] &&
4740 skip_env "could not find wiretest" && return
4743 run_test 58 "verify cross-platform wire constants =============="
4746 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4747 echo "touch 130 files"
4748 createmany -o $DIR/f59- 130
4750 unlinkmany $DIR/f59- 130
4752 # wait for commitment of removal
4753 wait_delete_completed
4755 run_test 59 "verify cancellation of llog records async ========="
4757 TEST60_HEAD="test_60 run $RANDOM"
4759 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4760 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4761 do_facet mgs "! which run-llog.sh &> /dev/null" &&
4762 skip_env "missing subtest run-llog.sh" && return
4763 log "$TEST60_HEAD - from kernel mode"
4764 do_facet mgs sh run-llog.sh
4766 run_test 60a "llog sanity tests run from kernel module =========="
4768 test_60b() { # bug 6411
4769 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4771 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4783 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4785 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4788 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4789 echo "create 5000 files"
4790 createmany -o $DIR/f60c- 5000
4791 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4792 lctl set_param fail_loc=0x80000137
4793 unlinkmany $DIR/f60c- 5000
4794 lctl set_param fail_loc=0
4796 run_test 60c "unlink file when mds full"
4799 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4800 SAVEPRINTK=$(lctl get_param -n printk)
4802 # verify "lctl mark" is even working"
4803 MESSAGE="test message ID $RANDOM $$"
4804 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4805 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4807 lctl set_param printk=0 || error "set lnet.printk failed"
4808 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4809 MESSAGE="new test message ID $RANDOM $$"
4810 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4811 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4812 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4814 lctl set_param -n printk="$SAVEPRINTK"
4816 run_test 60d "test printk console message masking"
4819 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4821 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4822 cancel_lru_locks osc
4823 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4826 run_test 61 "mmap() writes don't make sync hang ================"
4828 # bug 2330 - insufficient obd_match error checking causes LBUG
4830 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4833 cancel_lru_locks osc
4834 lctl set_param fail_loc=0x405
4835 cat $f && error "cat succeeded, expect -EIO"
4836 lctl set_param fail_loc=0
4838 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4839 # match every page all of the time.
4840 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4842 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4843 test_63a() { # was test_63
4844 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4845 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4846 lctl set_param -n osc.*.max_dirty_mb 0
4847 for i in `seq 10` ; do
4848 dd if=/dev/zero of=$DIR/f63 bs=8k &
4854 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4855 rm -f $DIR/f63 || true
4857 run_test 63a "Verify oig_wait interruption does not crash ======="
4859 # bug 2248 - async write errors didn't return to application on sync
4860 # bug 3677 - async write errors left page locked
4862 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4864 lctl set_param debug=-1
4866 # ensure we have a grant to do async writes
4867 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4870 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4871 lctl set_param fail_loc=0x80000406
4872 $MULTIOP $DIR/$tfile Owy && \
4873 error "sync didn't return ENOMEM"
4874 sync; sleep 2; sync # do a real sync this time to flush page
4875 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4876 error "locked page left in cache after async error" || true
4879 run_test 63b "async write errors should be returned to fsync ==="
4882 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4884 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4886 run_test 64a "verify filter grant calculations (in kernel) ====="
4889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4890 sh oos.sh $MOUNT || error "oos.sh failed: $?"
4892 run_test 64b "check out-of-space detection on client ==========="
4895 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4897 run_test 64c "verify grant shrink ========================------"
4899 # bug 1414 - set/get directories' stripe info
4901 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4902 test_mkdir -p $DIR/$tdir
4904 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4906 run_test 65a "directory with no stripe info ===================="
4909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4910 test_mkdir -p $DIR/$tdir
4911 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4914 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4916 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4919 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4920 if [ $OSTCOUNT -gt 1 ]; then
4921 test_mkdir -p $DIR/$tdir
4922 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4923 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4925 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4928 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4931 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4932 test_mkdir -p $DIR/$tdir
4933 if [ $STRIPECOUNT -le 0 ]; then
4935 elif [ $STRIPECOUNT -gt 2000 ]; then
4936 #LOV_MAX_STRIPE_COUNT is 2000
4937 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4939 sc=$(($STRIPECOUNT - 1))
4941 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4942 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4943 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4944 error "lverify failed"
4946 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4949 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4950 test_mkdir -p $DIR/$tdir
4952 $SETSTRIPE $DIR/$tdir || error "setstripe"
4953 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4954 error "no stripe info failed"
4956 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4958 run_test 65e "directory setstripe defaults ======================="
4961 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4962 test_mkdir -p $DIR/${tdir}f
4963 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4965 run_test 65f "dir setstripe permission (should return error) ==="
4968 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4969 test_mkdir -p $DIR/$tdir
4970 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4972 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4973 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4974 error "delete default stripe failed"
4976 run_test 65g "directory setstripe -d ==========================="
4979 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4980 test_mkdir -p $DIR/$tdir
4981 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4983 test_mkdir -p $DIR/$tdir/dd1
4984 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4985 error "stripe info inherit failed"
4987 run_test 65h "directory stripe info inherit ===================="
4989 test_65i() { # bug6367
4990 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4991 $SETSTRIPE -S 65536 -c -1 $MOUNT
4993 run_test 65i "set non-default striping on root directory (bug 6367)="
4995 test_65ia() { # bug12836
4996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4997 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4999 run_test 65ia "getstripe on -1 default directory striping"
5001 test_65ib() { # bug12836
5002 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5003 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
5005 run_test 65ib "getstripe -v on -1 default directory striping"
5007 test_65ic() { # bug12836
5008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5009 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
5011 run_test 65ic "new find on -1 default directory striping"
5013 test_65j() { # bug6367
5014 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5016 # if we aren't already remounting for each test, do so for this test
5017 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
5018 cleanup || error "failed to unmount"
5021 $SETSTRIPE -d $MOUNT || error "setstripe failed"
5023 run_test 65j "set default striping on root directory (bug 6367)="
5025 test_65k() { # bug11679
5026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5027 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
5028 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5030 echo "Check OST status: "
5031 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
5032 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
5034 for OSC in $MDS_OSCS; do
5035 echo $OSC "is activate"
5036 do_facet $SINGLEMDS lctl --device %$OSC activate
5040 for INACTIVE_OSC in $MDS_OSCS; do
5041 echo "Deactivate: " $INACTIVE_OSC
5042 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
5043 for STRIPE_OSC in $MDS_OSCS; do
5044 OST=`osc_to_ost $STRIPE_OSC`
5045 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
5046 awk -F: /$OST/'{ print $1 }' | head -n 1`
5048 [ -f $DIR/$tdir/$IDX ] && continue
5049 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
5050 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
5052 [ $RC -ne 0 ] && error "setstripe should have succeeded"
5055 echo $INACTIVE_OSC "is Activate."
5056 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
5059 run_test 65k "validate manual striping works properly with deactivated OSCs"
5061 test_65l() { # bug 12836
5062 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5063 test_mkdir -p $DIR/$tdir/test_dir
5064 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
5065 $LFS find -mtime -1 $DIR/$tdir >/dev/null
5067 run_test 65l "lfs find on -1 stripe dir ========================"
5069 # bug 2543 - update blocks count on client
5071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5073 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
5074 sync; sync_all_data; sync; sync_all_data
5075 cancel_lru_locks osc
5076 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
5077 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
5079 run_test 66 "update inode blocks count on client ==============="
5084 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5086 if [ ! -z "$LLOOP" ]; then
5087 if swapon -s | grep -q $LLOOP; then
5088 swapoff $LLOOP || error "swapoff failed"
5091 $LCTL blockdev_detach $LLOOP || error "detach failed"
5095 if [ ! -z "$LLITELOOPLOAD" ]; then
5103 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
5107 swapon -s | awk '($1 == "'$1'") { print $4 }'
5110 # test case for lloop driver, basic function
5112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5113 [ "$UID" != 0 ] && skip_env "must run as root" && return
5114 llite_lloop_enabled || \
5115 { skip_env "llite_lloop module disabled" && return; }
5117 trap cleanup_68 EXIT
5119 if ! module_loaded llite_lloop; then
5120 if load_module llite/llite_lloop; then
5123 skip_env "can't find module llite_lloop"
5128 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5129 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
5130 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
5132 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
5133 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5137 run_test 68a "lloop driver - basic test ========================"
5139 # excercise swapping to lustre by adding a high priority swapfile entry
5140 # and then consuming memory until it is used.
5141 test_68b() { # was test_68
5142 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5143 [ "$UID" != 0 ] && skip_env "must run as root" && return
5144 lctl get_param -n devices | grep -q obdfilter && \
5145 skip "local OST" && return
5147 grep -q llite_lloop /proc/modules
5148 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5150 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5151 skip "can't reliably test swap with TCP" && return
5153 MEMTOTAL=`meminfo MemTotal`
5154 NR_BLOCKS=$((MEMTOTAL>>8))
5155 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5157 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5158 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5161 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5163 trap cleanup_68 EXIT
5165 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5167 echo "before: `swapon -s | grep $LLOOP`"
5168 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5169 echo "after: `swapon -s | grep $LLOOP`"
5170 SWAPUSED=`swap_used $LLOOP`
5174 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5176 run_test 68b "support swapping to Lustre ========================"
5178 # bug5265, obdfilter oa2dentry return -ENOENT
5179 # #define OBD_FAIL_OST_ENOENT 0x217
5181 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5182 remote_ost_nodsh && skip "remote OST with nodsh" && return
5185 $SETSTRIPE -c 1 -i 0 $f
5187 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5189 do_facet ost1 lctl set_param fail_loc=0x217
5190 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5191 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5193 do_facet ost1 lctl set_param fail_loc=0
5194 $DIRECTIO write $f 0 2 || error "write error"
5196 cancel_lru_locks osc
5197 $DIRECTIO read $f 0 1 || error "read error"
5199 do_facet ost1 lctl set_param fail_loc=0x217
5200 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5202 do_facet ost1 lctl set_param fail_loc=0
5205 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5208 test_mkdir -p $DIR/$tdir
5209 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5211 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5213 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5214 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5215 [ "$RUNAS_ID" = "$UID" ] &&
5216 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5218 # Check that testing environment is properly set up. Skip if not
5219 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5220 skip_env "User $RUNAS_ID does not exist - skipping"
5223 # We had better clear the $DIR to get enough space for dd
5226 chmod 777 $DIR/$tfile
5227 chmod ug+s $DIR/$tfile
5228 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5229 error "$RUNAS dd $DIR/$tfile failed"
5230 # See if we are still setuid/sgid
5231 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5232 error "S/gid is not dropped on write"
5233 # Now test that MDS is updated too
5234 cancel_lru_locks mdc
5235 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5236 error "S/gid is not dropped on MDS"
5239 run_test 72a "Test that remove suid works properly (bug5695) ===="
5241 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5244 [ "$RUNAS_ID" = "$UID" ] && \
5245 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5246 [ "$RUNAS_ID" -eq 0 ] && \
5247 skip_env "RUNAS_ID = 0 -- skipping" && return
5249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5250 # Check that testing environment is properly set up. Skip if not
5251 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5252 skip_env "User $RUNAS_ID does not exist - skipping"
5255 touch $DIR/${tfile}-f{g,u}
5256 test_mkdir $DIR/${tfile}-dg
5257 test_mkdir $DIR/${tfile}-du
5258 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5259 chmod g+s $DIR/${tfile}-{f,d}g
5260 chmod u+s $DIR/${tfile}-{f,d}u
5261 for perm in 777 2777 4777; do
5262 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5263 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5264 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5265 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5269 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5271 # bug 3462 - multiple simultaneous MDC requests
5273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5274 test_mkdir $DIR/d73-1
5275 test_mkdir $DIR/d73-2
5276 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5279 lctl set_param fail_loc=0x80000129
5280 $MULTIOP $DIR/d73-1/f73-2 Oc &
5282 lctl set_param fail_loc=0
5284 $MULTIOP $DIR/d73-2/f73-3 Oc &
5288 wait $pid1 || return 1
5292 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5293 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5294 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5298 run_test 73 "multiple MDC requests (should not deadlock)"
5300 test_74a() { # bug 6149, 6184
5301 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5302 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5304 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5305 # will spin in a tight reconnection loop
5307 lctl set_param fail_loc=0x8000030e
5308 # get any lock that won't be difficult - lookup works.
5310 lctl set_param fail_loc=0
5314 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5316 test_74b() { # bug 13310
5317 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5318 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5320 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5321 # will spin in a tight reconnection loop
5322 lctl set_param fail_loc=0x8000030e
5323 # get a "difficult" lock
5325 lctl set_param fail_loc=0
5329 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5332 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5333 #define OBD_FAIL_LDLM_NEW_LOCK
5334 lctl set_param fail_loc=0x80000319
5335 touch $DIR/$tfile && error "Touch successful"
5338 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5341 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5344 get_inode_slab_tunables() {
5345 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5348 set_inode_slab_tunables() {
5349 echo "lustre_inode_cache $1" > /proc/slabinfo
5352 test_76() { # Now for bug 20433, added originally in bug 1443
5353 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5354 local SLAB_SETTINGS=`get_inode_slab_tunables`
5355 local CPUS=`getconf _NPROCESSORS_ONLN`
5356 # we cannot set limit below 1 which means 1 inode in each
5357 # per-cpu cache is still allowed
5358 set_inode_slab_tunables "1 1 0"
5359 cancel_lru_locks osc
5360 BEFORE_INODES=`num_inodes`
5361 echo "before inodes: $BEFORE_INODES"
5363 [ "$SLOW" = "no" ] && COUNT=100
5364 for i in `seq $COUNT`; do
5368 cancel_lru_locks osc
5369 AFTER_INODES=`num_inodes`
5370 echo "after inodes: $AFTER_INODES"
5372 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5374 AFTER_INODES=`num_inodes`
5376 echo "wait $wait seconds inodes: $AFTER_INODES"
5377 if [ $wait -gt 30 ]; then
5378 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5381 set_inode_slab_tunables "$SLAB_SETTINGS"
5383 run_test 76 "confirm clients recycle inodes properly ===="
5389 # Note: in sptlrpc modes which enable its own bulk checksum, the
5390 # original crc32_le bulk checksum will be automatically disabled,
5391 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5392 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5393 # In this case set_checksums() will not be no-op, because sptlrpc
5394 # bulk checksum will be enabled all through the test.
5396 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5397 lctl set_param -n osc.*.checksums $1
5401 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5402 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5403 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5404 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5407 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5408 log "set checksum type to $1"
5411 F77_TMP=$TMP/f77-temp
5414 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5415 error "error writing to $F77_TMP"
5418 test_77a() { # bug 10889
5419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5420 $GSS && skip "could not run with gss" && return
5421 [ ! -f $F77_TMP ] && setup_f77
5423 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5427 run_test 77a "normal checksum read/write operation"
5429 test_77b() { # bug 10889
5430 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5431 $GSS && skip "could not run with gss" && return
5432 [ ! -f $F77_TMP ] && setup_f77
5433 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5434 $LCTL set_param fail_loc=0x80000409
5437 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ conv=sync ||
5438 error "dd error: $?"
5439 $LCTL set_param fail_loc=0
5441 for algo in $CKSUM_TYPES; do
5442 cancel_lru_locks osc
5443 set_checksum_type $algo
5444 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5445 $LCTL set_param fail_loc=0x80000408
5446 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5447 $LCTL set_param fail_loc=0
5450 set_checksum_type $ORIG_CSUM_TYPE
5453 run_test 77b "checksum error on client write, read"
5455 test_77d() { # bug 10889
5456 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5457 $GSS && skip "could not run with gss" && return
5458 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5459 $LCTL set_param fail_loc=0x80000409
5461 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5462 error "direct write: rc=$?"
5463 $LCTL set_param fail_loc=0
5466 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5467 $LCTL set_param fail_loc=0x80000408
5469 cancel_lru_locks osc
5470 $DIRECTIO read $DIR/$tfile 0 $F77SZ $((1024 * 1024)) ||
5471 error "direct read: rc=$?"
5472 $LCTL set_param fail_loc=0
5475 run_test 77d "checksum error on OST direct write, read"
5477 test_77f() { # bug 10889
5478 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5479 $GSS && skip "could not run with gss" && return
5481 for algo in $CKSUM_TYPES; do
5482 cancel_lru_locks osc
5483 set_checksum_type $algo
5484 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5485 $LCTL set_param fail_loc=0x409
5486 $DIRECTIO write $DIR/$tfile 0 $F77SZ $((1024 * 1024)) &&
5487 error "direct write succeeded"
5488 $LCTL set_param fail_loc=0
5490 set_checksum_type $ORIG_CSUM_TYPE
5493 run_test 77f "repeat checksum error on write (expect error)"
5495 test_77g() { # bug 10889
5496 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5497 $GSS && skip "could not run with gss" && return
5498 remote_ost_nodsh && skip "remote OST with nodsh" && return
5500 [ ! -f $F77_TMP ] && setup_f77
5502 $SETSTRIPE -c 1 -i 0 $DIR/$tfile
5503 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5504 do_facet ost1 lctl set_param fail_loc=0x8000021a
5506 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
5507 error "write error: rc=$?"
5508 do_facet ost1 lctl set_param fail_loc=0
5511 cancel_lru_locks osc
5512 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5513 do_facet ost1 lctl set_param fail_loc=0x8000021b
5515 cmp $F77_TMP $DIR/$tfile || error "file compare failed"
5516 do_facet ost1 lctl set_param fail_loc=0
5519 run_test 77g "checksum error on OST write, read"
5521 test_77i() { # bug 13805
5522 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5523 $GSS && skip "could not run with gss" && return
5524 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5525 lctl set_param fail_loc=0x40b
5526 remount_client $MOUNT
5527 lctl set_param fail_loc=0
5528 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5529 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5530 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5531 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5533 remount_client $MOUNT
5535 run_test 77i "client not supporting OSD_CONNECT_CKSUM"
5537 test_77j() { # bug 13805
5538 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5539 $GSS && skip "could not run with gss" && return
5540 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5541 lctl set_param fail_loc=0x40c
5542 remount_client $MOUNT
5543 lctl set_param fail_loc=0
5544 sleep 2 # wait async osc connect to finish
5545 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5546 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5547 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5548 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5550 remount_client $MOUNT
5552 run_test 77j "client only supporting ADLER32"
5554 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5558 test_78() { # bug 10901
5559 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5560 remote_ost || { skip_env "local OST" && return; }
5563 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5564 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5565 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5566 echo "MemTotal: $MEMTOTAL"
5567 # reserve 256MB of memory for the kernel and other running processes,
5568 # and then take 1/2 of the remaining memory for the read/write buffers.
5569 if [ $MEMTOTAL -gt 512 ] ;then
5570 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5572 # for those poor memory-starved high-end clusters...
5573 MEMTOTAL=$((MEMTOTAL / 2))
5575 echo "Mem to use for directio: $MEMTOTAL"
5576 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5577 [ $F78SIZE -gt 512 ] && F78SIZE=512
5578 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5579 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5580 echo "Smallest OST: $SMALLESTOST"
5581 [ $SMALLESTOST -lt 10240 ] && \
5582 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5584 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5585 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5587 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5588 echo "File size: $F78SIZE"
5589 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5590 for i in `seq 1 $NSEQ`
5592 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5593 echo directIO rdwr round $i of $NSEQ
5594 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5599 run_test 78 "handle large O_DIRECT writes correctly ============"
5601 test_79() { # bug 12743
5602 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5603 wait_delete_completed
5605 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5606 BKFREE=$(calc_osc_kbytes kbytesfree)
5607 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5609 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5610 DFTOTAL=`echo $STRING | cut -d, -f1`
5611 DFUSED=`echo $STRING | cut -d, -f2`
5612 DFAVAIL=`echo $STRING | cut -d, -f3`
5613 DFFREE=$(($DFTOTAL - $DFUSED))
5615 ALLOWANCE=$((64 * $OSTCOUNT))
5617 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5618 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5619 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5621 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5622 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5623 error "df free($DFFREE) mismatch OST free($BKFREE)"
5625 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5626 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5627 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5630 run_test 79 "df report consistency check ======================="
5632 test_80() { # bug 10718
5633 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5634 # relax strong synchronous semantics for slow backends like ZFS
5635 local soc="obdfilter.*.sync_on_lock_cancel"
5636 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5638 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5639 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5640 facet_active_host $host; done | sort -u)
5641 do_nodes $hosts lctl set_param $soc=never
5644 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5646 local BEFORE=`date +%s`
5647 cancel_lru_locks osc
5648 local AFTER=`date +%s`
5649 local DIFF=$((AFTER-BEFORE))
5650 if [ $DIFF -gt 1 ] ; then
5651 error "elapsed for 1M@1T = $DIFF"
5654 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5658 run_test 80 "Page eviction is equally fast at high offsets too ===="
5660 test_81a() { # LU-456
5661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5662 remote_ost_nodsh && skip "remote OST with nodsh" && return
5663 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5664 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5665 do_facet ost1 lctl set_param fail_loc=0x80000228
5667 # write should trigger a retry and success
5668 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5669 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5671 if [ $RC -ne 0 ] ; then
5672 error "write should success, but failed for $RC"
5675 run_test 81a "OST should retry write when get -ENOSPC ==============="
5677 test_81b() { # LU-456
5678 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5679 remote_ost_nodsh && skip "remote OST with nodsh" && return
5680 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5681 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5682 do_facet ost1 lctl set_param fail_loc=0x228
5684 # write should retry several times and return -ENOSPC finally
5685 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5686 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5689 if [ $RC -ne $ENOSPC ] ; then
5690 error "dd should fail for -ENOSPC, but succeed."
5693 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5695 test_82() { # LU-1031
5696 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5700 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5702 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5704 kill -USR1 $MULTIPID2
5706 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5707 error "First grouplock does not block second one"
5709 echo "Second grouplock blocks first one"
5711 kill -USR1 $MULTIPID1
5715 run_test 82 "Basic grouplock test ==============================="
5718 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5720 test_mkdir -p $DIR/d99cvsroot
5721 chown $RUNAS_ID $DIR/d99cvsroot
5722 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5725 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5728 run_test 99a "cvs init ========================================="
5731 [ -z "$(which cvs 2>/dev/null)" ] &&
5732 skip_env "could not find cvs" && return
5733 [ ! -d $DIR/d99cvsroot ] && test_99a
5735 # some versions of cvs import exit(1) when asked to import links or
5736 # files they can't read. ignore those files.
5737 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5738 ! -perm +4 -printf '-I %f\n')
5739 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5740 d99reposname vtag rtag
5742 run_test 99b "cvs import ======================================="
5745 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5746 [ ! -d $DIR/d99cvsroot ] && test_99b
5748 test_mkdir -p $DIR/d99reposname
5749 chown $RUNAS_ID $DIR/d99reposname
5750 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5752 run_test 99c "cvs checkout ====================================="
5755 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5756 [ ! -d $DIR/d99cvsroot ] && test_99c
5757 cd $DIR/d99reposname
5759 $RUNAS cvs add -m 'addmsg' foo99
5761 run_test 99d "cvs add =========================================="
5764 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5765 [ ! -d $DIR/d99cvsroot ] && test_99c
5766 cd $DIR/d99reposname
5769 run_test 99e "cvs update ======================================="
5772 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5773 [ ! -d $DIR/d99cvsroot ] && test_99d
5774 cd $DIR/d99reposname
5775 $RUNAS cvs commit -m 'nomsg' foo99
5776 rm -fr $DIR/d99cvsroot
5778 run_test 99f "cvs commit ======================================="
5781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5782 [ "$NETTYPE" = tcp ] || \
5783 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5786 remote_ost_nodsh && skip "remote OST with nodsh" && return
5787 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5789 { skip "useless for local single node setup" && return; }
5791 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5792 [ "$PROT" != "tcp" ] && continue
5793 RPORT=$(echo $REMOTE | cut -d: -f2)
5794 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5797 LPORT=`echo $LOCAL | cut -d: -f2`
5798 if [ $LPORT -ge 1024 ]; then
5799 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5801 error_exit "local: $LPORT > 1024, remote: $RPORT"
5804 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5806 run_test 100 "check local port using privileged port ==========="
5808 function get_named_value()
5817 echo $line | sed "s/^$tag[ ]*//"
5824 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5825 awk '/^max_cached_mb/ { print $2 }')
5828 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5833 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5834 [ $MDSCOUNT -ge 2 ] && skip "skip now for >= 2 MDTs" && return #LU-4322
5838 local cache_limit=32
5840 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5841 trap cleanup_101a EXIT
5842 $LCTL set_param -n llite.*.read_ahead_stats 0
5843 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5846 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5848 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5849 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5852 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5853 get_named_value 'read but discarded' | cut -d" " -f1`; do
5854 discard=$(($discard + $s))
5858 if [ $(($discard * 10)) -gt $nreads ] ;then
5859 $LCTL get_param osc.*-osc*.rpc_stats
5860 $LCTL get_param llite.*.read_ahead_stats
5861 error "too many ($discard) discarded pages"
5863 rm -f $DIR/$tfile || true
5865 run_test 101a "check read-ahead for random reads ================"
5868 test_mkdir -p $DIR/$tdir
5870 STRIPE_COUNT=$OSTCOUNT
5873 local list=$(comma_list $(osts_nodes))
5874 set_osd_param $list '' read_cache_enable 0
5875 set_osd_param $list '' writethrough_cache_enable 0
5877 trap cleanup_test101bc EXIT
5878 # prepare the read-ahead file
5879 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5881 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5884 cleanup_test101bc() {
5889 local list=$(comma_list $(osts_nodes))
5890 set_osd_param $list '' read_cache_enable 1
5891 set_osd_param $list '' writethrough_cache_enable 1
5895 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5900 local STRIPE_SIZE=1048576
5901 local RA_INC=1048576
5902 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5903 local FILE_LENGTH=$((64*100))
5904 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5905 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5906 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5907 get_named_value 'read but discarded' | \
5908 cut -d" " -f1 | calc_total`
5909 if [ $DISCARD -gt $discard_limit ]; then
5910 $LCTL get_param llite.*.read_ahead_stats
5911 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5913 echo "Read-ahead success for size ${READ_SIZE}"
5918 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5919 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5920 local STRIPE_SIZE=1048576
5921 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5922 local FILE_LENGTH=$((STRIPE_SIZE*100))
5923 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5924 # prepare the read-ahead file
5926 cancel_lru_locks osc
5927 for BIDX in 2 4 8 16 32 64 128 256
5929 local BSIZE=$((BIDX*4096))
5930 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5931 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5932 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5933 $LCTL set_param -n llite.*.read_ahead_stats 0
5934 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5935 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5936 cancel_lru_locks osc
5942 run_test 101b "check stride-io mode read-ahead ================="
5945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5946 local STRIPE_SIZE=1048576
5947 local FILE_LENGTH=$((STRIPE_SIZE*100))
5953 cancel_lru_locks osc
5954 $LCTL set_param osc.*.rpc_stats 0
5955 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5956 for osc_rpc_stats in $($LCTL get_param -N osc.*.rpc_stats); do
5957 local stats=$($LCTL get_param -n $osc_rpc_stats)
5958 local lines=$(echo "$stats" | awk 'END {print NR;}')
5961 if [ $lines -le 20 ]; then
5964 for size in 1 2 4 8; do
5965 local rpc=$(echo "$stats" |
5966 awk '($1 == "'$size':") {print $2; exit; }')
5968 error "Small $((size*4))k read IO $rpc !"
5970 echo "$osc_rpc_stats check passed!"
5975 run_test 101c "check stripe_size aligned read-ahead ================="
5978 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5979 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5983 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5984 local file=$DIR/$tfile
5985 local sz_MB=${FILESIZE_101d:-500}
5986 local ra_MB=${READAHEAD_MB:-40}
5988 local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
5989 [ $free_MB -lt $sz_MB ] &&
5990 skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
5992 echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
5993 $SETSTRIPE -c -1 $file || error "setstripe failed"
5995 dd if=/dev/zero of=$file bs=1M count=$sz_MB || error "dd failed"
5996 echo Cancel LRU locks on lustre client to flush the client cache
5997 cancel_lru_locks osc
5999 echo Disable read-ahead
6000 local old_READAHEAD=$(set_read_ahead 0)
6002 echo Reading the test file $file with read-ahead disabled
6003 local raOFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6005 echo Cancel LRU locks on lustre client to flush the client cache
6006 cancel_lru_locks osc
6007 echo Enable read-ahead with ${ra_MB}MB
6008 set_read_ahead $ra_MB
6010 echo Reading the test file $file with read-ahead enabled
6011 local raON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$sz_MB")
6013 echo "read-ahead disabled time read $raOFF"
6014 echo "read-ahead enabled time read $raON"
6016 set_read_ahead $old_READAHEAD
6018 wait_delete_completed
6020 [ $raOFF -le 1 -o $raON -lt $raOFF ] ||
6021 error "readahead ${raON}s > no-readahead ${raOFF}s ${sz_MB}M"
6023 run_test 101d "file read with and without read-ahead enabled"
6026 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6027 local file=$DIR/$tfile
6028 local size_KB=500 #KB
6032 local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
6033 local need_KB=$((count * size_KB))
6034 [ $free_KB -le $need_KB ] &&
6035 skip_env "Need free space $need_KB, have $free_KB" && return
6037 echo "Creating $count ${size_KB}K test files"
6038 for ((i = 0; i < $count; i++)); do
6039 dd if=/dev/zero of=$file.$i bs=$bsize count=$size_KB 2>/dev/null
6042 echo "Cancel LRU locks on lustre client to flush the client cache"
6043 cancel_lru_locks osc
6045 echo "Reset readahead stats"
6046 $LCTL set_param -n llite.*.read_ahead_stats 0
6048 for ((i = 0; i < $count; i++)); do
6049 dd if=$file.$i of=/dev/null bs=$bsize count=$size_KB 2>/dev/null
6052 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6053 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6055 for ((i = 0; i < $count; i++)); do
6056 rm -rf $file.$i 2>/dev/null
6059 #10000 means 20% reads are missing in readahead
6060 [ $miss -lt 10000 ] || error "misses too much for small reads"
6062 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
6064 cleanup_test101f() {
6066 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
6067 rm -rf $DIR/$tfile 2>/dev/null
6071 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6072 local file=$DIR/$tfile
6075 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
6076 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
6077 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
6078 trap cleanup_test101f EXIT
6080 echo Cancel LRU locks on lustre client to flush the client cache
6081 cancel_lru_locks osc
6083 echo Reset readahead stats
6084 $LCTL set_param -n llite.*.read_ahead_stats 0
6085 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
6086 # readahead should read in 2M file on second read, so only miss
6088 echo Random 4K reads on 2M file for 1000 times
6089 $READS -f $file -s 2097152 -b 4096 -n $nreads
6091 echo checking missing pages
6092 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
6093 get_named_value 'misses' | cut -d" " -f1 | calc_total)
6095 [ $miss -lt 3 ] || error "misses too much pages!"
6098 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
6101 test_mkdir -p $DIR/$tdir
6102 chown $RUNAS_ID $DIR/$tdir
6105 STRIPE_COUNT=$OSTCOUNT
6106 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
6108 trap cleanup_test102 EXIT
6110 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6112 for num in 1 2 3 4; do
6113 for count in $(seq 1 $STRIPE_COUNT); do
6114 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6115 local size=`expr $STRIPE_SIZE \* $num`
6116 local file=file"$num-$idx-$count"
6117 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6123 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6129 rm -rf $DIR/d0.sanity/d102
6133 local testfile=$DIR/xattr_testfile
6137 [ "$UID" != 0 ] && skip_env "must run as root" && return
6138 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6139 skip_env "must have user_xattr" && return
6141 [ -z "$(which setfattr 2>/dev/null)" ] &&
6142 skip_env "could not find setfattr" && return
6144 echo "set/get xattr..."
6145 setfattr -n trusted.name1 -v value1 $testfile ||
6146 error "setfattr -n trusted.name1=value1 $testfile failed"
6147 getfattr -n trusted.name1 $testfile 2> /dev/null |
6148 grep "trusted.name1=.value1" ||
6149 error "$testfile missing trusted.name1=value1"
6151 setfattr -n user.author1 -v author1 $testfile ||
6152 error "setfattr -n user.author1=author1 $testfile failed"
6153 getfattr -n user.author1 $testfile 2> /dev/null |
6154 grep "user.author1=.author1" ||
6155 error "$testfile missing trusted.author1=author1"
6158 setfattr -n trusted.name2 -v value2 $testfile ||
6159 error "$testfile unable to set trusted.name2"
6160 setfattr -n trusted.name3 -v value3 $testfile ||
6161 error "$testfile unable to set trusted.name3"
6162 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6163 grep "trusted.name" | wc -l) -eq 3 ] ||
6164 error "$testfile missing 3 trusted.name xattrs"
6166 setfattr -n user.author2 -v author2 $testfile ||
6167 error "$testfile unable to set user.author2"
6168 setfattr -n user.author3 -v author3 $testfile ||
6169 error "$testfile unable to set user.author3"
6170 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6171 grep "user.author" | wc -l) -eq 3 ] ||
6172 error "$testfile missing 3 user.author xattrs"
6174 echo "remove xattr..."
6175 setfattr -x trusted.name1 $testfile ||
6176 error "$testfile error deleting trusted.name1"
6177 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6178 error "$testfile did not delete trusted.name1 xattr"
6180 setfattr -x user.author1 $testfile ||
6181 error "$testfile error deleting user.author1"
6182 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6183 error "$testfile did not delete trusted.name1 xattr"
6185 # b10667: setting lustre special xattr be silently discarded
6186 echo "set lustre special xattr ..."
6187 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6188 error "$testfile allowed setting trusted.lov"
6190 run_test 102a "user xattr test =================================="
6193 # b10930: get/set/list trusted.lov xattr
6194 echo "get/set/list trusted.lov xattr ..."
6195 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6196 local testfile=$DIR/$tfile
6197 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6198 error "setstripe failed"
6199 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6200 error "getstripe failed"
6201 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6202 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6204 local testfile2=${testfile}2
6205 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6206 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6209 setfattr -n trusted.lov -v $value $testfile2
6210 local stripe_size=$($GETSTRIPE -S $testfile2)
6211 local stripe_count=$($GETSTRIPE -c $testfile2)
6212 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6213 [ $stripe_count -eq $STRIPECOUNT ] ||
6214 error "stripe count $stripe_count != $STRIPECOUNT"
6217 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6220 # b10930: get/set/list lustre.lov xattr
6221 echo "get/set/list lustre.lov xattr ..."
6222 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6223 test_mkdir -p $DIR/$tdir
6224 chown $RUNAS_ID $DIR/$tdir
6225 local testfile=$DIR/$tdir/$tfile
6226 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6227 error "setstripe failed"
6228 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6229 error "getstripe failed"
6230 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6231 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6233 local testfile2=${testfile}2
6234 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6235 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6237 $RUNAS $MCREATE $testfile2
6238 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6239 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6240 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6241 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6242 [ $stripe_count -eq $STRIPECOUNT ] ||
6243 error "stripe count $stripe_count != $STRIPECOUNT"
6245 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6247 compare_stripe_info1() {
6248 local stripe_index_all_zero=true
6250 for num in 1 2 3 4; do
6251 for count in $(seq 1 $STRIPE_COUNT); do
6252 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6253 local size=$((STRIPE_SIZE * num))
6254 local file=file"$num-$offset-$count"
6255 stripe_size=$(lfs getstripe -S $PWD/$file)
6256 [ $stripe_size -ne $size ] &&
6257 error "$file: size $stripe_size != $size"
6258 stripe_count=$(lfs getstripe -c $PWD/$file)
6259 # allow fewer stripes to be created, ORI-601
6260 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6261 error "$file: count $stripe_count != $count"
6262 stripe_index=$(lfs getstripe -i $PWD/$file)
6263 [ $stripe_index -ne 0 ] &&
6264 stripe_index_all_zero=false
6268 $stripe_index_all_zero &&
6269 error "all files are being extracted starting from OST index 0"
6274 [ -n "$(which tar 2>/dev/null)" ] &&
6275 strings $(which tar) | grep -q "lustre" && echo tar
6279 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6280 # b10930: tar test for trusted.lov xattr
6281 TAR=$(find_lustre_tar)
6282 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6283 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6285 test_mkdir -p $DIR/d102d
6286 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6288 compare_stripe_info1
6290 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6294 # b10930: tar test for trusted.lov xattr
6295 TAR=$(find_lustre_tar)
6296 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6297 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6299 test_mkdir -p $DIR/d102f
6301 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6303 compare_stripe_info1
6305 run_test 102f "tar copy files, not keep osts ==========="
6308 local xsize=${1:-1024} # in bytes
6309 local file=$DIR/$tfile
6311 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6312 skip "must have user_xattr" && return 0
6313 [ -z "$(which setfattr 2>/dev/null)" ] &&
6314 skip_env "could not find setfattr" && return 0
6315 [ -z "$(which getfattr 2>/dev/null)" ] &&
6316 skip_env "could not find getfattr" && return 0
6320 local value="$(generate_string $xsize)"
6322 local xbig=trusted.big
6323 log "save $xbig on $file"
6324 setfattr -n $xbig -v $value $file ||
6325 error "saving $xbig on $file failed"
6327 local orig=$(get_xattr_value $xbig $file)
6328 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6330 local xsml=trusted.sml
6331 log "save $xsml on $file"
6332 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6334 local new=$(get_xattr_value $xbig $file)
6335 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6337 log "grow $xsml on $file"
6338 setfattr -n $xsml -v "$value" $file ||
6339 error "growing $xsml on $file failed"
6341 new=$(get_xattr_value $xbig $file)
6342 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6343 log "$xbig still valid after growing $xsml"
6348 test_102h() { # bug 15777
6351 run_test 102h "grow xattr from inside inode to external block"
6354 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6355 grow_xattr $(max_xattr_size)
6357 run_test 102ha "grow xattr from inside inode to external inode"
6359 test_102i() { # bug 17038
6361 ln -s $DIR/$tfile $DIR/${tfile}link
6362 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6363 getfattr -h -n trusted.lov $DIR/${tfile}link 2>&1 | grep -i "no such attr" || error "error for lgetxattr on $DIR/${tfile}link is not ENODATA"
6364 rm -f $DIR/$tfile $DIR/${tfile}link
6366 run_test 102i "lgetxattr test on symbolic link ============"
6369 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6370 TAR=$(find_lustre_tar)
6371 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6372 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6373 setup_test102 "$RUNAS"
6374 test_mkdir -p $DIR/d102j
6375 chown $RUNAS_ID $DIR/d102j
6376 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6378 compare_stripe_info1 "$RUNAS"
6380 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6384 # b22187 just check that does not crash for regular file.
6385 setfattr -n trusted.lov $DIR/$tfile
6386 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6387 local test_kdir=$DIR/d102k
6388 test_mkdir $test_kdir
6389 local default_size=`$GETSTRIPE -S $test_kdir`
6390 local default_count=`$GETSTRIPE -c $test_kdir`
6391 local default_offset=`$GETSTRIPE -i $test_kdir`
6392 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6393 error 'dir setstripe failed'
6394 setfattr -n trusted.lov $test_kdir
6395 local stripe_size=`$GETSTRIPE -S $test_kdir`
6396 local stripe_count=`$GETSTRIPE -c $test_kdir`
6397 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6398 [ $stripe_size -eq $default_size ] ||
6399 error "stripe size $stripe_size != $default_size"
6400 [ $stripe_count -eq $default_count ] ||
6401 error "stripe count $stripe_count != $default_count"
6402 [ $stripe_offset -eq $default_offset ] ||
6403 error "stripe offset $stripe_offset != $default_offset"
6404 rm -rf $DIR/$tfile $test_kdir
6406 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6409 # LU-532 trusted. xattr is invisible to non-root
6410 local testfile=$DIR/$tfile
6414 echo "listxattr as user..."
6415 chown $RUNAS_ID $testfile
6416 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6417 grep -q "trusted" &&
6418 error "$testfile trusted xattrs are user visible"
6422 run_test 102l "listxattr size test =================================="
6424 test_102m() { # LU-3403 llite: error of listxattr when buffer is small
6425 local path=$DIR/$tfile
6428 listxattr_size_check $path || error "listattr_size_check $path failed"
6430 run_test 102m "Ensure listxattr fails on small bufffer ========"
6434 getxattr() { # getxattr path name
6435 # Return the base64 encoding of the value of xattr name on path.
6439 # # getfattr --absolute-names --encoding=base64 --name=trusted.lov $path
6441 # trusted.lov=0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6443 # We print just 0s0AvRCwEAAAAGAAAAAAAAAAAEAAACAAAAAAAQAAEAA...AAAAAAAAA=
6445 getfattr --absolute-names --encoding=base64 --name=$name $path |
6446 awk -F= -v name=$name '$1 == name {
6447 print substr($0, index($0, "=") + 1);
6451 test_102n() { # LU-4101 mdt: protect internal xattrs
6452 local file0=$DIR/$tfile.0
6453 local file1=$DIR/$tfile.1
6454 local xattr0=$TMP/$tfile.0
6455 local xattr1=$TMP/$tfile.1
6459 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
6461 skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
6465 rm -rf $file0 $file1 $xattr0 $xattr1
6468 # Get 'before' xattrs of $file1.
6469 getfattr --absolute-names --dump --match=- $file1 > $xattr0
6471 for name in lov lma lmv link fid version som hsm lfsck_namespace; do
6472 # Try to copy xattr from $file0 to $file1.
6473 value=$(getxattr $file0 trusted.$name 2> /dev/null)
6475 setfattr --name=trusted.$name --value="$value" $file1 ||
6476 error "setxattr 'trusted.$name' failed"
6478 # Try to set a garbage xattr.
6479 value=0sVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIGl0c2VsZi4=
6481 setfattr --name=trusted.$name --value="$value" $file1 ||
6482 error "setxattr 'trusted.$name' failed"
6484 # Try to remove the xattr from $file1. We don't care if this
6485 # appears to succeed or fail, we just don't want there to be
6486 # any changes or crashes.
6487 setfattr --remove=$trusted.$name $file1 2> /dev/null
6490 # Get 'after' xattrs of file1.
6491 getfattr --absolute-names --dump --match=- $file1 > $xattr1
6493 if ! diff $xattr0 $xattr1; then
6494 error "before and after xattrs of '$file1' differ"
6497 rm -rf $file0 $file1 $xattr0 $xattr1
6501 run_test 102n "silently ignore setxattr on internal trusted xattrs"
6505 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6510 [ "$UID" != 0 ] && skip_env "must run as root" && return
6511 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6512 skip "must have acl enabled" && return
6513 [ -z "$(which setfacl 2>/dev/null)" ] &&
6514 skip_env "could not find setfacl" && return
6515 $GSS && skip "could not run under gss" && return
6517 declare -a identity_old
6519 for num in $(seq $MDSCOUNT); do
6520 switch_identity $num true || identity_old[$num]=$?
6527 echo "performing cp ..."
6528 run_acl_subtest cp || error "run_acl_subtest cp failed"
6529 echo "performing getfacl-noacl..."
6530 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6531 echo "performing misc..."
6532 run_acl_subtest misc || error "misc test failed"
6533 echo "performing permissions..."
6534 run_acl_subtest permissions || error "permissions failed"
6535 echo "performing setfacl..."
6536 run_acl_subtest setfacl || error "setfacl test failed"
6538 # inheritance test got from HP
6539 echo "performing inheritance..."
6540 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6541 chmod +x make-tree || error "chmod +x failed"
6542 run_acl_subtest inheritance || error "inheritance test failed"
6545 echo "LU-974 ignore umask when acl is enabled..."
6546 run_acl_subtest 974 || error "LU-974 umask test failed"
6547 if [ $MDSCOUNT -ge 2 ]; then
6548 run_acl_subtest 974_remote ||
6549 error "LU-974 umask test failed under remote dir"
6552 echo "LU-2561 newly created file is same size as directory..."
6553 run_acl_subtest 2561 || error "LU-2561 test failed"
6558 for num in $(seq $MDSCOUNT); do
6559 if [ "${identity_old[$num]}" = 1 ]; then
6560 switch_identity $num false || identity_old[$num]=$?
6564 run_test 103 "acl test ========================================="
6567 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6569 lfs df || error "lfs df failed"
6570 lfs df -ih || error "lfs df -ih failed"
6571 lfs df -h $DIR || error "lfs df -h $DIR failed"
6572 lfs df -i $DIR || error "lfs df -i $DIR failed"
6573 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6574 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6576 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6577 lctl --device %$OSC deactivate
6578 lfs df || error "lfs df with deactivated OSC failed"
6579 lctl --device %$OSC activate
6580 # wait the osc back to normal
6581 wait_osc_import_state client ost FULL
6583 lfs df || error "lfs df with reactivated OSC failed"
6586 run_test 104a "lfs df [-ih] [path] test ========================="
6589 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6590 [ $RUNAS_ID -eq $UID ] &&
6591 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6593 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6594 grep "Permission denied" | wc -l)))
6595 if [ $denied_cnt -ne 0 ]; then
6596 error "lfs check servers test failed"
6599 run_test 104b "$RUNAS lfs check servers test ===================="
6602 # doesn't work on 2.4 kernels
6604 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6605 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6607 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6611 run_test 105a "flock when mounted without -o flock test ========"
6615 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6616 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6618 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6622 run_test 105b "fcntl when mounted without -o flock test ========"
6626 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6627 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6629 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6633 run_test 105c "lockf when mounted without -o flock test ========"
6635 test_105d() { # bug 15924
6636 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6637 test_mkdir -p $DIR/$tdir
6638 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6639 skip "mount w/o flock enabled" && return
6640 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6641 $LCTL set_param fail_loc=0x80000315
6642 flocks_test 2 $DIR/$tdir
6644 run_test 105d "flock race (should not freeze) ========"
6646 test_105e() { # bug 22660 && 22040
6647 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6648 skip "mount w/o flock enabled" && return
6650 flocks_test 3 $DIR/$tfile
6652 run_test 105e "Two conflicting flocks from same process ======="
6654 test_106() { #bug 10921
6655 test_mkdir -p $DIR/$tdir
6656 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6657 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6659 run_test 106 "attempt exec of dir followed by chown of that dir"
6662 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6669 local save_pattern=$(sysctl -n kernel.core_pattern)
6670 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6671 sysctl -w kernel.core_pattern=$file
6672 sysctl -w kernel.core_uses_pid=0
6680 kill -s 11 $SLEEPPID
6682 if [ -e $file ]; then
6683 size=`stat -c%s $file`
6684 [ $size -eq 0 ] && error "Fail to create core file $file"
6686 error "Fail to create core file $file"
6689 sysctl -w kernel.core_pattern=$save_pattern
6690 sysctl -w kernel.core_uses_pid=$save_uses_pid
6693 run_test 107 "Coredump on SIG"
6696 test_mkdir -p $DIR/$tdir
6697 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6698 error "mkdir with 255 char failed"
6699 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6700 error "mkdir with 256 char should fail, but did not"
6701 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6702 error "create with 255 char failed"
6703 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6704 error "create with 256 char should fail, but did not"
6709 run_test 110 "filename length checking"
6712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6713 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6715 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6717 echo "Starting with $OSTIO_pre threads"
6720 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6721 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6722 echo "$NUMTEST creates/unlinks"
6723 test_mkdir -p $DIR/$tdir
6724 createmany -o $DIR/$tdir/$tfile $NUMTEST
6725 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6727 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6730 # don't return an error
6731 [ $OSTIO_post == $OSTIO_pre ] && echo \
6732 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6733 echo "This may be fine, depending on what ran before this test" &&
6734 echo "and how fast this system is." && return
6736 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6738 run_test 115 "verify dynamic thread creation===================="
6741 wait_delete_completed
6742 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6743 echo OST kbytes available: ${AVAIL[@]}
6744 MAXI=0; MAXV=${AVAIL[0]}
6745 MINI=0; MINV=${AVAIL[0]}
6746 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6747 #echo OST $i: ${AVAIL[i]}kb
6748 if [ ${AVAIL[i]} -gt $MAXV ]; then
6749 MAXV=${AVAIL[i]}; MAXI=$i
6751 if [ ${AVAIL[i]} -lt $MINV ]; then
6752 MINV=${AVAIL[i]}; MINI=$i
6755 echo Min free space: OST $MINI: $MINV
6756 echo Max free space: OST $MAXI: $MAXV
6759 test_116a() { # was previously test_116()
6760 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6761 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6763 echo -n "Free space priority "
6764 do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
6769 [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
6770 trap simple_cleanup_common EXIT
6772 # Check if we need to generate uneven OSTs
6773 test_mkdir -p $DIR/$tdir/OST${MINI}
6774 local FILL=$(($MINV / 4))
6775 local DIFF=$(($MAXV - $MINV))
6776 local DIFF2=$(($DIFF * 100 / $MINV))
6778 local threshold=$(do_facet $SINGLEMDS \
6779 lctl get_param -n *.*MDT0000-mdtlov.qos_threshold_rr | head -1)
6780 threshold=${threshold%%%}
6781 echo -n "Check for uneven OSTs: "
6782 echo -n "diff=${DIFF}KB (${DIFF2}%) must be > ${threshold}% ..."
6784 if [ $DIFF2 -gt $threshold ]; then
6786 echo "Don't need to fill OST$MINI"
6788 # generate uneven OSTs. Write 2% over the QOS threshold value
6790 DIFF=$(($threshold - $DIFF2 + 2))
6791 DIFF2=$(( ($MINV * $DIFF)/100 ))
6792 echo "Fill ${DIFF}% remaining space in OST${MINI} with ${DIFF2}KB"
6793 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI} ||
6794 error "setstripe failed"
6795 DIFF=$(($DIFF2 / 2048))
6797 while [ $i -lt $DIFF ]; do
6799 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i \
6800 bs=2M count=1 2>/dev/null
6809 DIFF=$(($MAXV - $MINV))
6810 DIFF2=$(($DIFF * 100 / $MINV))
6811 echo -n "diff=${DIFF}=${DIFF2}% must be > ${threshold}% for QOS mode..."
6812 if [ $DIFF2 -gt $threshold ]; then
6815 echo "failed - QOS mode won't be used"
6816 skip "QOS imbalance criteria not met"
6817 simple_cleanup_common
6821 MINI1=$MINI; MINV1=$MINV
6822 MAXI1=$MAXI; MAXV1=$MAXV
6824 # now fill using QOS
6825 $SETSTRIPE -c 1 $DIR/$tdir
6826 FILL=$(($FILL / 200))
6827 if [ $FILL -gt 600 ]; then
6830 echo "writing $FILL files to QOS-assigned OSTs"
6832 while [ $i -lt $FILL ]; do
6834 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=200k \
6838 echo "wrote $i 200k files"
6842 echo "Note: free space may not be updated, so measurements might be off"
6844 DIFF2=$(($MAXV - $MINV))
6845 echo "free space delta: orig $DIFF final $DIFF2"
6846 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6847 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6848 echo "Wrote ${DIFF}KB to smaller OST $MINI1"
6849 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6850 echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
6851 FILL=$(($DIFF2 * 100 / $DIFF - 100))
6853 echo "Wrote ${FILL}% more data to larger OST $MAXI1"
6855 # Figure out which files were written where
6856 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6857 awk '/'$MINI1': / {print $2; exit}')
6859 MINC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6860 echo "$MINC files created on smaller OST $MINI1"
6861 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6862 awk '/'$MAXI1': / {print $2; exit}')
6864 MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
6865 echo "$MAXC files created on larger OST $MAXI1"
6866 FILL=$(($MAXC * 100 / $MINC - 100))
6868 echo "Wrote ${FILL}% more files to larger OST $MAXI1"
6869 [ $MAXC -gt $MINC ] ||
6870 error_ignore LU-9 "stripe QOS didn't balance free space"
6871 simple_cleanup_common
6873 run_test 116a "stripe QOS: free space balance ==================="
6875 test_116b() { # LU-2093
6876 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6877 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6879 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6880 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6882 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6883 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6884 do_facet $SINGLEMDS lctl set_param fail_loc=0
6886 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6888 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6890 test_117() # bug 10891
6892 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6893 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6894 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6895 lctl set_param fail_loc=0x21e
6896 > $DIR/$tfile || error "truncate failed"
6897 lctl set_param fail_loc=0
6898 echo "Truncate succeeded."
6901 run_test 117 "verify osd extend =========="
6903 NO_SLOW_RESENDCOUNT=4
6904 export OLD_RESENDCOUNT=""
6905 set_resend_count () {
6906 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6907 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6908 lctl set_param -n $PROC_RESENDCOUNT $1
6909 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6912 # for reduce test_118* time (b=14842)
6913 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6915 # Reset async IO behavior after error case
6917 FILE=$DIR/reset_async
6919 # Ensure all OSCs are cleared
6920 $SETSTRIPE -c -1 $FILE
6921 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6926 test_118a() #bug 11710
6928 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6931 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6932 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6933 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6935 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6936 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6941 run_test 118a "verify O_SYNC works =========="
6945 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6946 remote_ost_nodsh && skip "remote OST with nodsh" && return
6950 #define OBD_FAIL_OST_ENOENT 0x217
6951 set_nodes_failloc "$(osts_nodes)" 0x217
6952 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6954 set_nodes_failloc "$(osts_nodes)" 0
6955 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6956 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6959 if [[ $RC -eq 0 ]]; then
6960 error "Must return error due to dropped pages, rc=$RC"
6964 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6965 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6969 echo "Dirty pages not leaked on ENOENT"
6971 # Due to the above error the OSC will issue all RPCs syncronously
6972 # until a subsequent RPC completes successfully without error.
6973 $MULTIOP $DIR/$tfile Ow4096yc
6978 run_test 118b "Reclaim dirty pages on fatal error =========="
6982 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6984 # for 118c, restore the original resend count, LU-1940
6985 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
6986 set_resend_count $OLD_RESENDCOUNT
6987 remote_ost_nodsh && skip "remote OST with nodsh" && return
6991 #define OBD_FAIL_OST_EROFS 0x216
6992 set_nodes_failloc "$(osts_nodes)" 0x216
6994 # multiop should block due to fsync until pages are written
6995 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6999 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7000 error "Multiop failed to block on fsync, pid=$MULTIPID"
7003 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7005 if [[ $WRITEBACK -eq 0 ]]; then
7006 error "No page in writeback, writeback=$WRITEBACK"
7009 set_nodes_failloc "$(osts_nodes)" 0
7012 if [[ $RC -ne 0 ]]; then
7013 error "Multiop fsync failed, rc=$RC"
7016 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7017 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7019 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7020 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7024 echo "Dirty pages flushed via fsync on EROFS"
7027 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
7029 # continue to use small resend count to reduce test_118* time (b=14842)
7030 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
7034 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7035 remote_ost_nodsh && skip "remote OST with nodsh" && return
7039 #define OBD_FAIL_OST_BRW_PAUSE_BULK
7040 set_nodes_failloc "$(osts_nodes)" 0x214
7041 # multiop should block due to fsync until pages are written
7042 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7046 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
7047 error "Multiop failed to block on fsync, pid=$MULTIPID"
7050 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7052 if [[ $WRITEBACK -eq 0 ]]; then
7053 error "No page in writeback, writeback=$WRITEBACK"
7056 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
7057 set_nodes_failloc "$(osts_nodes)" 0
7059 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7060 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7062 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7063 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7067 echo "Dirty pages gaurenteed flushed via fsync"
7070 run_test 118d "Fsync validation inject a delay of the bulk =========="
7073 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7076 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
7077 lctl set_param fail_loc=0x8000040a
7079 # Should simulate EINVAL error which is fatal
7080 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7082 if [[ $RC -eq 0 ]]; then
7083 error "Must return error due to dropped pages, rc=$RC"
7086 lctl set_param fail_loc=0x0
7088 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7089 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7090 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7092 if [[ $LOCKED -ne 0 ]]; then
7093 error "Locked pages remain in cache, locked=$LOCKED"
7096 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7097 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7101 echo "No pages locked after fsync"
7106 run_test 118f "Simulate unrecoverable OSC side error =========="
7109 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7112 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
7113 lctl set_param fail_loc=0x406
7115 # simulate local -ENOMEM
7116 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7119 lctl set_param fail_loc=0
7120 if [[ $RC -eq 0 ]]; then
7121 error "Must return error due to dropped pages, rc=$RC"
7124 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7125 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7126 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7128 if [[ $LOCKED -ne 0 ]]; then
7129 error "Locked pages remain in cache, locked=$LOCKED"
7132 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7133 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7137 echo "No pages locked after fsync"
7142 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
7145 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7146 remote_ost_nodsh && skip "remote OST with nodsh" && return
7150 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7151 set_nodes_failloc "$(osts_nodes)" 0x20e
7152 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7153 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7156 set_nodes_failloc "$(osts_nodes)" 0
7157 if [[ $RC -eq 0 ]]; then
7158 error "Must return error due to dropped pages, rc=$RC"
7161 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7162 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7163 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
7165 if [[ $LOCKED -ne 0 ]]; then
7166 error "Locked pages remain in cache, locked=$LOCKED"
7169 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7170 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7174 echo "No pages locked after fsync"
7178 run_test 118h "Verify timeout in handling recoverables errors =========="
7180 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7183 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7184 remote_ost_nodsh && skip "remote OST with nodsh" && return
7188 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7189 set_nodes_failloc "$(osts_nodes)" 0x20e
7191 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
7192 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
7195 set_nodes_failloc "$(osts_nodes)" 0
7199 if [[ $RC -ne 0 ]]; then
7200 error "got error, but should be not, rc=$RC"
7203 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7204 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7205 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7206 if [[ $LOCKED -ne 0 ]]; then
7207 error "Locked pages remain in cache, locked=$LOCKED"
7210 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7211 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7215 echo "No pages locked after fsync"
7219 run_test 118i "Fix error before timeout in recoverable error =========="
7221 [ "$SLOW" = "no" ] && set_resend_count 4
7224 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7225 remote_ost_nodsh && skip "remote OST with nodsh" && return
7229 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7230 set_nodes_failloc "$(osts_nodes)" 0x220
7232 # return -EIO from OST
7233 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7235 set_nodes_failloc "$(osts_nodes)" 0x0
7236 if [[ $RC -eq 0 ]]; then
7237 error "Must return error due to dropped pages, rc=$RC"
7240 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7241 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7242 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7243 if [[ $LOCKED -ne 0 ]]; then
7244 error "Locked pages remain in cache, locked=$LOCKED"
7247 # in recoverable error on OST we want resend and stay until it finished
7248 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7249 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7253 echo "No pages locked after fsync"
7257 run_test 118j "Simulate unrecoverable OST side error =========="
7261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7262 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7264 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7265 set_nodes_failloc "$(osts_nodes)" 0x20e
7266 test_mkdir -p $DIR/$tdir
7268 for ((i=0;i<10;i++)); do
7269 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7270 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7277 set_nodes_failloc "$(osts_nodes)" 0
7280 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7286 test_mkdir -p $DIR/$tdir
7287 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7290 run_test 118l "fsync dir ========="
7292 test_118m() # LU-3066
7294 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7295 test_mkdir -p $DIR/$tdir
7296 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7299 run_test 118m "fdatasync dir ========="
7301 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7303 test_119a() # bug 11737
7305 BSIZE=$((512 * 1024))
7306 directio write $DIR/$tfile 0 1 $BSIZE
7307 # We ask to read two blocks, which is more than a file size.
7308 # directio will indicate an error when requested and actual
7309 # sizes aren't equeal (a normal situation in this case) and
7310 # print actual read amount.
7311 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7312 if [ "$NOB" != "$BSIZE" ]; then
7313 error "read $NOB bytes instead of $BSIZE"
7317 run_test 119a "Short directIO read must return actual read amount"
7319 test_119b() # bug 11737
7321 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7323 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7324 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7326 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7327 error "direct read failed"
7330 run_test 119b "Sparse directIO read must return actual read amount"
7332 test_119c() # bug 13099
7335 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7336 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7339 run_test 119c "Testing for direct read hitting hole"
7341 test_119d() # bug 15950
7343 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7344 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7345 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7347 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7348 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7349 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7350 lctl set_param fail_loc=0x40d
7351 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7354 cat $DIR/$tfile > /dev/null &
7355 lctl set_param fail_loc=0
7358 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7360 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7361 error "the read rpcs have not completed in 2s"
7363 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7365 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7368 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7369 test_mkdir -p $DIR/$tdir
7370 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7371 skip "no early lock cancel on server" && return 0
7373 lru_resize_disable mdc
7374 lru_resize_disable osc
7375 cancel_lru_locks mdc
7376 # asynchronous object destroy at MDT could cause bl ast to client
7377 cancel_lru_locks osc
7379 stat $DIR/$tdir > /dev/null
7380 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7381 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7382 test_mkdir $DIR/$tdir/d1
7383 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7384 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7385 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7386 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7387 lru_resize_enable mdc
7388 lru_resize_enable osc
7390 run_test 120a "Early Lock Cancel: mkdir test"
7393 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7394 test_mkdir -p $DIR/$tdir
7395 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7396 skip "no early lock cancel on server" && return 0
7397 lru_resize_disable mdc
7398 lru_resize_disable osc
7399 cancel_lru_locks mdc
7400 stat $DIR/$tdir > /dev/null
7401 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7402 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7404 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7405 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7406 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7407 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7408 lru_resize_enable mdc
7409 lru_resize_enable osc
7411 run_test 120b "Early Lock Cancel: create test"
7414 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7415 test_mkdir -p $DIR/$tdir
7416 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7417 skip "no early lock cancel on server" && return 0
7418 lru_resize_disable mdc
7419 lru_resize_disable osc
7420 test_mkdir -p $DIR/$tdir/d1
7421 test_mkdir -p $DIR/$tdir/d2
7422 touch $DIR/$tdir/d1/f1
7423 cancel_lru_locks mdc
7424 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7425 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7426 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7427 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7428 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7429 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7430 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7431 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7432 lru_resize_enable mdc
7433 lru_resize_enable osc
7435 run_test 120c "Early Lock Cancel: link test"
7438 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7439 test_mkdir -p $DIR/$tdir
7440 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7441 skip "no early lock cancel on server" && return 0
7442 lru_resize_disable mdc
7443 lru_resize_disable osc
7445 cancel_lru_locks mdc
7446 stat $DIR/$tdir > /dev/null
7447 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7448 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7449 chmod a+x $DIR/$tdir
7450 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7451 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7452 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7453 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7454 lru_resize_enable mdc
7455 lru_resize_enable osc
7457 run_test 120d "Early Lock Cancel: setattr test"
7460 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7461 test_mkdir -p $DIR/$tdir
7462 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7463 skip "no early lock cancel on server" && return 0
7464 lru_resize_disable mdc
7465 lru_resize_disable osc
7466 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7467 cancel_lru_locks mdc
7468 cancel_lru_locks osc
7469 dd if=$DIR/$tdir/f1 of=/dev/null
7470 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7471 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7472 awk '/ldlm_cancel/ {print $2}'`
7473 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7474 awk '/ldlm_bl_callback/ {print $2}'`
7475 unlink $DIR/$tdir/f1
7476 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7477 awk '/ldlm_cancel/ {print $2}'`
7478 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7479 awk '/ldlm_bl_callback/ {print $2}'`
7480 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7481 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7482 lru_resize_enable mdc
7483 lru_resize_enable osc
7485 run_test 120e "Early Lock Cancel: unlink test"
7488 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7489 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7490 skip "no early lock cancel on server" && return 0
7491 test_mkdir -p $DIR/$tdir
7492 lru_resize_disable mdc
7493 lru_resize_disable osc
7494 test_mkdir -p $DIR/$tdir/d1
7495 test_mkdir -p $DIR/$tdir/d2
7496 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7497 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7498 cancel_lru_locks mdc
7499 cancel_lru_locks osc
7500 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7501 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7502 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7503 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7504 awk '/ldlm_cancel/ {print $2}'`
7505 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7506 awk '/ldlm_bl_callback/ {print $2}'`
7507 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7508 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7509 awk '/ldlm_cancel/ {print $2}'`
7510 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7511 awk '/ldlm_bl_callback/ {print $2}'`
7512 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7513 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7514 lru_resize_enable mdc
7515 lru_resize_enable osc
7517 run_test 120f "Early Lock Cancel: rename test"
7520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7521 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7522 skip "no early lock cancel on server" && return 0
7523 lru_resize_disable mdc
7524 lru_resize_disable osc
7526 echo create $count files
7527 test_mkdir -p $DIR/$tdir
7528 cancel_lru_locks mdc
7529 cancel_lru_locks osc
7532 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7533 awk '/ldlm_cancel/ {print $2}'`
7534 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7535 awk '/ldlm_bl_callback/ {print $2}'`
7536 createmany -o $DIR/$tdir/f $count
7538 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7539 awk '/ldlm_cancel/ {print $2}'`
7540 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7541 awk '/ldlm_bl_callback/ {print $2}'`
7543 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7544 echo rm $count files
7547 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7548 awk '/ldlm_cancel/ {print $2}'`
7549 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7550 awk '/ldlm_bl_callback/ {print $2}'`
7552 echo total: $count removes in $((t2-t1))
7553 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7555 # wait for commitment of removal
7556 lru_resize_enable mdc
7557 lru_resize_enable osc
7559 run_test 120g "Early Lock Cancel: performance test"
7561 test_121() { #bug #10589
7562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7564 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7565 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7566 lctl set_param fail_loc=0x310
7567 cancel_lru_locks osc > /dev/null
7568 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7569 lctl set_param fail_loc=0
7570 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7572 run_test 121 "read cancel race ========="
7574 test_123a() { # was test 123, statahead(bug 11401)
7575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7577 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7578 log "testing on UP system. Performance may be not as good as expected."
7583 test_mkdir -p $DIR/$tdir
7584 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7585 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7587 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7588 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7590 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7591 lctl set_param -n llite.*.statahead_max 0
7592 lctl get_param llite.*.statahead_max
7593 cancel_lru_locks mdc
7594 cancel_lru_locks osc
7596 time ls -l $DIR/$tdir | wc -l
7598 delta=$((etime - stime))
7599 log "ls $i files without statahead: $delta sec"
7600 lctl set_param llite.*.statahead_max=$max
7602 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7603 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7604 cancel_lru_locks mdc
7605 cancel_lru_locks osc
7607 time ls -l $DIR/$tdir | wc -l
7609 delta_sa=$((etime - stime))
7610 log "ls $i files with statahead: $delta_sa sec"
7611 lctl get_param -n llite.*.statahead_stats
7612 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7614 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7615 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7617 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7618 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7619 lctl set_param -n llite.*.statahead_max 0
7620 lctl get_param llite.*.statahead_max
7621 cancel_lru_locks mdc
7622 cancel_lru_locks osc
7624 time ls -l $DIR/$tdir | wc -l
7626 delta=$((etime - stime))
7627 log "ls $i files again without statahead: $delta sec"
7628 lctl set_param llite.*.statahead_max=$max
7629 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7630 if [ $SLOWOK -eq 0 ]; then
7631 error "ls $i files is slower with statahead!"
7633 log "ls $i files is slower with statahead!"
7639 [ $delta -gt 20 ] && break
7640 [ $delta -gt 8 ] && MULT=$((50 / delta))
7641 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7649 delta=$((etime - stime))
7650 log "rm -r $DIR/$tdir/: $delta seconds"
7652 lctl get_param -n llite.*.statahead_stats
7654 run_test 123a "verify statahead work"
7656 test_123b () { # statahead(bug 15027)
7657 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7658 test_mkdir -p $DIR/$tdir
7659 createmany -o $DIR/$tdir/$tfile-%d 1000
7661 cancel_lru_locks mdc
7662 cancel_lru_locks osc
7664 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7665 lctl set_param fail_loc=0x80000803
7666 ls -lR $DIR/$tdir > /dev/null
7668 lctl set_param fail_loc=0x0
7669 lctl get_param -n llite.*.statahead_stats
7674 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7677 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7678 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7679 skip "no lru resize on server" && return 0
7681 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7683 log "create $NR files at $DIR/$tdir"
7684 createmany -o $DIR/$tdir/f $NR ||
7685 error "failed to create $NR files in $DIR/$tdir"
7687 cancel_lru_locks mdc
7688 ls -l $DIR/$tdir > /dev/null
7692 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7693 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7694 LRU_SIZE=$(lctl get_param -n $PARAM)
7695 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7696 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7698 log "NS=$(basename $NSDIR)"
7703 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7704 skip "Not enough cached locks created!"
7711 # We know that lru resize allows one client to hold $LIMIT locks
7712 # for 10h. After that locks begin to be killed by client.
7714 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7717 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7718 # killing locks. Some time was spent for creating locks. This means
7719 # that up to the moment of sleep finish we must have killed some of
7720 # them (10-100 locks). This depends on how fast ther were created.
7721 # Many of them were touched in almost the same moment and thus will
7722 # be killed in groups.
7723 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7725 # Use $LRU_SIZE_B here to take into account real number of locks
7726 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7727 local LRU_SIZE_B=$LRU_SIZE
7729 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7730 log "OLD_LVF=$OLD_LVF"
7731 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7733 # Let's make sure that we really have some margin. Client checks
7734 # cached locks every 10 sec.
7736 log "Sleep ${SLEEP} sec"
7738 while ((SEC<$SLEEP)); do
7742 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7746 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7747 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7749 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7750 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7751 unlinkmany $DIR/$tdir/f $NR
7755 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7756 log "unlink $NR files at $DIR/$tdir"
7757 unlinkmany $DIR/$tdir/f $NR
7759 run_test 124a "lru resize ======================================="
7761 get_max_pool_limit()
7763 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7766 if test $l -gt $max; then
7774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7775 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7776 skip "no lru resize on server" && return 0
7778 LIMIT=`get_max_pool_limit`
7780 NR=$(($(default_lru_size)*20))
7781 if [ $NR -gt $LIMIT ]; then
7782 log "Limit lock number by $LIMIT locks"
7785 lru_resize_disable mdc
7786 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7787 error "failed to create $DIR/$tdir/disable_lru_resize"
7789 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7790 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7791 cancel_lru_locks mdc
7794 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7797 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7800 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7804 nolruresize_delta=$((etime-stime))
7805 log "ls -la time: $nolruresize_delta seconds"
7806 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7807 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7809 lru_resize_enable mdc
7810 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7811 error "failed to create $DIR/$tdir/enable_lru_resize"
7813 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7814 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7815 cancel_lru_locks mdc
7818 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7821 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7824 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7828 lruresize_delta=$((etime-stime))
7829 log "ls -la time: $lruresize_delta seconds"
7830 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7832 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7833 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7834 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7835 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7837 log "lru resize performs the same with no lru resize"
7839 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7841 run_test 124b "lru resize (performance test) ======================="
7843 test_125() { # 13358
7844 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7845 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7846 test_mkdir -p $DIR/d125 || error "mkdir failed"
7847 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7848 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7849 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7851 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7853 test_126() { # bug 12829/13455
7854 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7855 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7856 $GSS && skip "must run as gss disabled" && return
7858 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7859 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7861 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7863 run_test 126 "check that the fsgid provided by the client is taken into account"
7865 test_127a() { # bug 15521
7866 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7867 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7868 $LCTL set_param osc.*.stats=0
7869 FSIZE=$((2048 * 1024))
7870 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7871 cancel_lru_locks osc
7872 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7874 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7875 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7876 echo "got $COUNT $NAME"
7877 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7878 eval $NAME=$COUNT || error "Wrong proc format"
7881 read_bytes|write_bytes)
7882 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7883 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7884 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7885 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7886 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7887 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7888 error "sumsquare is too small: $SUMSQ"
7889 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7890 error "sumsquare is too big: $SUMSQ"
7894 done < $DIR/${tfile}.tmp
7896 #check that we actually got some stats
7897 [ "$read_bytes" ] || error "Missing read_bytes stats"
7898 [ "$write_bytes" ] || error "Missing write_bytes stats"
7899 [ "$read_bytes" != 0 ] || error "no read done"
7900 [ "$write_bytes" != 0 ] || error "no write done"
7902 run_test 127a "verify the client stats are sane"
7904 test_127b() { # bug LU-333
7905 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7906 $LCTL set_param llite.*.stats=0
7907 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7908 # perform 2 reads and writes so MAX is different from SUM.
7909 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7910 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7911 cancel_lru_locks osc
7912 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7913 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7915 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7916 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7917 echo "got $COUNT $NAME"
7918 eval $NAME=$COUNT || error "Wrong proc format"
7922 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7923 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7924 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7925 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7928 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7929 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7930 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7931 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7935 done < $TMP/${tfile}.tmp
7937 #check that we actually got some stats
7938 [ "$read_bytes" ] || error "Missing read_bytes stats"
7939 [ "$write_bytes" ] || error "Missing write_bytes stats"
7940 [ "$read_bytes" != 0 ] || error "no read done"
7941 [ "$write_bytes" != 0 ] || error "no write done"
7943 run_test 127b "verify the llite client stats are sane"
7945 test_128() { # bug 15212
7947 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7952 result=$(grep error $TMP/$tfile.log)
7954 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7956 run_test 128 "interactive lfs for 2 consecutive find's"
7963 local LDPROC=/proc/fs/ldiskfs
7964 local facets=$(get_facets MDS)
7966 for facet in ${facets//,/ }; do
7967 canondev=$(ldiskfs_canon \
7968 *.$(convert_facet2label $facet).mntdev $facet)
7969 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7970 LDPROC=/sys/fs/ldiskfs
7971 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7976 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7977 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7978 skip "Only applicable to ldiskfs-based MDTs"
7981 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7987 test_mkdir -p $DIR/$tdir
7989 # block size of mds1
7990 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
7991 local MDSBLOCKSIZE=$($LCTL get_param -n mdc.*MDT0000*.blocksize)
7992 local MAX=$((MDSBLOCKSIZE * 3))
7994 local I=$(stat -c%s "$DIR/$tdir")
7996 while [ ! $I -gt $MAX ]; do
7997 $MULTIOP $DIR/$tdir/$J Oc
7999 #check two errors ENOSPC for new version of ext4 max_dir_size patch
8000 #mainline kernel commit df981d03eeff7971ac7e6ff37000bfa702327ef1
8001 #and EFBIG for previous versions
8002 if [ $rc -eq $EFBIG -o $rc -eq $ENOSPC ]; then
8004 echo "return code $rc received as expected"
8005 multiop $DIR/$tdir/$J Oc ||
8006 error_exit "multiop failed w/o dir size limit"
8008 I=$(stat -c%s "$DIR/$tdir")
8010 if [ $(lustre_version_code $SINGLEMDS) -lt \
8011 $(version_code 2.4.51) ]
8013 [ $I -eq $MAX ] && return 0
8015 [ $I -gt $MAX ] && return 0
8017 error_exit "current dir size $I, previous limit $MAX"
8018 elif [ $rc -ne 0 ]; then
8020 error_exit "return code $rc received instead of expected " \
8021 "$EFBIG or $ENOSPC, files in dir $I"
8024 I=$(stat -c%s "$DIR/$tdir")
8028 error "exceeded dir size limit $MAX x $MDSCOUNT $MAX : $I bytes"
8030 run_test 129 "test directory size limit ========================"
8039 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8040 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8043 trap cleanup_130 EXIT RETURN
8045 local fm_file=$DIR/$tfile
8046 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
8047 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
8048 error "dd failed for $fm_file"
8050 # LU-1795: test filefrag/FIEMAP once, even if unsupported
8051 filefrag -ves $fm_file
8053 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8054 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8055 [ $RC != 0 ] && error "filefrag $fm_file failed"
8057 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8058 grep -v "ext:" | grep -v "found")
8059 lun=$($GETSTRIPE -i $fm_file)
8061 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
8064 for line in $filefrag_op
8066 frag_lun=`echo $line | cut -d: -f5`
8067 ext_len=`echo $line | cut -d: -f4`
8068 if (( $frag_lun != $lun )); then
8070 error "FIEMAP on 1-stripe file($fm_file) failed"
8073 (( tot_len += ext_len ))
8076 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
8078 error "FIEMAP on 1-stripe file($fm_file) failed;"
8084 echo "FIEMAP on single striped file succeeded"
8086 run_test 130a "FIEMAP (1-stripe file)"
8089 [ "$OSTCOUNT" -lt "2" ] &&
8090 skip_env "skipping FIEMAP on 2-stripe file test" && return
8092 [ "$OSTCOUNT" -ge "10" ] &&
8093 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8095 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8096 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
8099 trap cleanup_130 EXIT RETURN
8101 local fm_file=$DIR/$tfile
8102 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8103 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8104 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8106 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
8107 error "dd failed on $fm_file"
8109 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8110 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
8111 grep -v "ext:" | grep -v "found")
8113 last_lun=$(echo $filefrag_op | cut -d: -f5)
8118 for line in $filefrag_op
8120 frag_lun=`echo $line | cut -d: -f5`
8121 ext_len=`echo $line | cut -d: -f4`
8122 if (( $frag_lun != $last_lun )); then
8123 if (( tot_len != 1024 )); then
8125 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
8132 (( tot_len += ext_len ))
8135 if (( num_luns != 2 || tot_len != 1024 )); then
8137 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8143 echo "FIEMAP on 2-stripe file succeeded"
8145 run_test 130b "FIEMAP (2-stripe file)"
8148 [ "$OSTCOUNT" -lt "2" ] &&
8149 skip_env "skipping FIEMAP on 2-stripe file" && return
8151 [ "$OSTCOUNT" -ge "10" ] &&
8152 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8154 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8155 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
8158 trap cleanup_130 EXIT RETURN
8160 local fm_file=$DIR/$tfile
8161 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
8162 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8163 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8165 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
8167 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8168 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
8170 last_lun=`echo $filefrag_op | cut -d: -f5`
8175 for line in $filefrag_op
8177 frag_lun=`echo $line | cut -d: -f5`
8178 ext_len=`echo $line | cut -d: -f4`
8179 if (( $frag_lun != $last_lun )); then
8180 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
8181 if (( logical != 512 )); then
8183 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
8186 if (( tot_len != 512 )); then
8188 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8195 (( tot_len += ext_len ))
8198 if (( num_luns != 2 || tot_len != 512 )); then
8200 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8206 echo "FIEMAP on 2-stripe file with hole succeeded"
8208 run_test 130c "FIEMAP (2-stripe file with hole)"
8211 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
8213 [ "$OSTCOUNT" -ge "10" ] &&
8214 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8216 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8217 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8219 trap cleanup_130 EXIT RETURN
8221 local fm_file=$DIR/$tfile
8222 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
8223 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8224 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8226 local actual_stripecnt=$($GETSTRIPE -c $fm_file)
8227 dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripecnt ||
8228 error "dd failed on $fm_file"
8230 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8231 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" |
8232 grep -v "ext:" | grep -v "found"`
8234 last_lun=`echo $filefrag_op | cut -d: -f5`
8239 for line in $filefrag_op
8241 frag_lun=`echo $line | cut -d: -f5`
8242 ext_len=`echo $line | cut -d: -f4`
8243 if (( $frag_lun != $last_lun )); then
8244 if (( tot_len != 1024 )); then
8246 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8253 (( tot_len += ext_len ))
8256 if (( num_luns != actual_stripecnt || tot_len != 1024 )); then
8258 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8264 echo "FIEMAP on N-stripe file succeeded"
8266 run_test 130d "FIEMAP (N-stripe file)"
8269 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8271 [ "$OSTCOUNT" -ge "10" ] &&
8272 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8274 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8275 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8277 trap cleanup_130 EXIT RETURN
8279 local fm_file=$DIR/$tfile
8280 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8281 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8282 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8285 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8286 for ((i = 0; i < $NUM_BLKS; i++))
8288 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8291 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8292 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8294 last_lun=`echo $filefrag_op | cut -d: -f5`
8299 for line in $filefrag_op
8301 frag_lun=`echo $line | cut -d: -f5`
8302 ext_len=`echo $line | cut -d: -f4`
8303 if (( $frag_lun != $last_lun )); then
8304 if (( tot_len != $EXPECTED_LEN )); then
8306 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8313 (( tot_len += ext_len ))
8316 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8318 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8324 echo "FIEMAP with continuation calls succeeded"
8326 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8328 # Test for writev/readv
8330 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8331 error "writev test failed"
8332 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8333 error "readv failed"
8336 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8339 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8340 error "append writev test failed"
8341 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8342 error "append writev test failed"
8345 run_test 131b "test append writev"
8348 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8351 run_test 131c "test read/write on file w/o objects"
8354 rwv -f $DIR/$tfile -w -n 1 1572864
8355 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8356 if [ "$NOB" != 1572864 ]; then
8357 error "Short read filed: read $NOB bytes instead of 1572864"
8361 run_test 131d "test short read"
8364 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8365 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8366 error "read hitting hole failed"
8369 run_test 131e "test read hitting hole"
8374 for node in $(osts_nodes); do
8375 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8376 [ x$gl = x"" ] && gl=0
8377 gl_sum=$((gl_sum + gl))
8387 if [ x$som = x"enabled" ]; then
8388 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8389 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8390 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8392 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8393 MOUNTOPT="$MOUNTOPT,som_preview"
8394 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8397 # do remount to make new mount-conf parameters actual
8404 test_132() { #1028, SOM
8405 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8406 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8407 local num=$(get_mds_dir $DIR)
8408 local mymds=mds${num}
8409 local MOUNTOPT_SAVE=$MOUNTOPT
8411 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8412 cancel_lru_locks osc
8414 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8416 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8417 stat $DIR/$tfile >/dev/null
8418 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8419 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8421 som_mode_switch $som1 $gl1 $gl2
8423 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8424 cancel_lru_locks osc
8426 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8427 if [ $som1 == $som2 ]; then
8428 error "som is still "$som2
8429 if [ x$som2 = x"enabled" ]; then
8436 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8437 stat $DIR/$tfile >/dev/null
8438 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8439 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8440 som_mode_switch $som2 $gl1 $gl2
8441 MOUNTOPT=$MOUNTOPT_SAVE
8443 run_test 132 "som avoids glimpse rpc"
8449 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8451 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8453 *) error "Wrong argument $1" ;;
8456 count=`echo $res | awk '{print $2}'`
8457 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8458 # if the argument $3 is zero, it means any stat increment is ok.
8459 if [ $3 -gt 0 ] ; then
8460 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8465 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8466 remote_ost_nodsh && skip "remote OST with nodsh" && return
8467 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8469 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8470 { skip "MDS doesn't support rename stats"; return; }
8471 local testdir=$DIR/${tdir}/stats_testdir
8472 mkdir -p $DIR/${tdir}
8475 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8476 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8478 # verify mdt stats first.
8479 mkdir ${testdir} || error "mkdir failed"
8480 check_stats $SINGLEMDS "mkdir" 1
8481 touch ${testdir}/${tfile} || "touch failed"
8482 check_stats $SINGLEMDS "open" 1
8483 check_stats $SINGLEMDS "close" 1
8484 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8485 check_stats $SINGLEMDS "mknod" 1
8486 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8487 check_stats $SINGLEMDS "unlink" 1
8488 rm -f ${testdir}/${tfile} || error "file remove failed"
8489 check_stats $SINGLEMDS "unlink" 2
8491 # remove working dir and check mdt stats again.
8492 rmdir ${testdir} || error "rmdir failed"
8493 check_stats $SINGLEMDS "rmdir" 1
8495 local testdir1=$DIR/${tdir}/stats_testdir1
8497 mkdir -p ${testdir1}
8498 touch ${testdir1}/test1
8499 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8500 check_stats $SINGLEMDS "crossdir_rename" 1
8502 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8503 check_stats $SINGLEMDS "samedir_rename" 1
8507 run_test 133a "Verifying MDT stats ========================================"
8510 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8511 remote_ost_nodsh && skip "remote OST with nodsh" && return
8512 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8513 local testdir=$DIR/${tdir}/stats_testdir
8514 mkdir -p ${testdir} || error "mkdir failed"
8515 touch ${testdir}/${tfile} || "touch failed"
8516 cancel_lru_locks mdc
8519 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8520 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8522 # extra mdt stats verification.
8523 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8524 check_stats $SINGLEMDS "setattr" 1
8525 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8526 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8528 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8529 check_stats $SINGLEMDS "getattr" 1
8531 $LFS df || error "lfs failed"
8532 check_stats $SINGLEMDS "statfs" 1
8536 run_test 133b "Verifying extra MDT stats =================================="
8539 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8540 remote_ost_nodsh && skip "remote OST with nodsh" && return
8541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8542 local testdir=$DIR/${tdir}/stats_testdir
8543 test_mkdir -p ${testdir} || error "mkdir failed"
8545 # verify obdfilter stats.
8546 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8548 cancel_lru_locks osc
8549 wait_delete_completed
8552 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8553 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8555 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8557 cancel_lru_locks osc
8558 check_stats ost "write" 1
8560 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8561 check_stats ost "read" 1
8563 > ${testdir}/${tfile} || error "truncate failed"
8564 check_stats ost "punch" 1
8566 rm -f ${testdir}/${tfile} || error "file remove failed"
8567 wait_delete_completed
8568 check_stats ost "destroy" 1
8572 run_test 133c "Verifying OST stats ========================================"
8579 while [ $value -ge 2 ]; do
8584 if [ $orig -gt $order ]; then
8592 local size=('K' 'M' 'G' 'T');
8594 local size_string=$value
8596 while [ $value -ge 1024 ]; do
8597 if [ $i -gt 3 ]; then
8598 #T is the biggest unit we get here, if that is bigger,
8600 size_string=${value}T
8603 value=$((value >> 10))
8604 if [ $value -lt 1024 ]; then
8605 size_string=${value}${size[$i]}
8616 local context=${2:-.}
8617 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8619 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8624 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8625 remote_ost_nodsh && skip "remote OST with nodsh" && return
8626 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8627 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8628 { skip "MDS doesn't support rename stats"; return; }
8630 local testdir1=$DIR/${tdir}/stats_testdir1
8631 local testdir2=$DIR/${tdir}/stats_testdir2
8633 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8635 mkdir -p ${testdir1} || error "mkdir failed"
8636 mkdir -p ${testdir2} || error "mkdir failed"
8638 createmany -o $testdir1/test 512 || error "createmany failed"
8640 # check samedir rename size
8641 mv ${testdir1}/test0 ${testdir1}/test_0
8643 local testdir1_size=$(ls -l $DIR/${tdir} |
8644 awk '/stats_testdir1/ {print $5}')
8645 local testdir2_size=$(ls -l $DIR/${tdir} |
8646 awk '/stats_testdir2/ {print $5}')
8648 testdir1_size=$(order_2 $testdir1_size)
8649 testdir2_size=$(order_2 $testdir2_size)
8651 testdir1_size=$(size_in_KMGT $testdir1_size)
8652 testdir2_size=$(size_in_KMGT $testdir2_size)
8654 echo "source rename dir size: ${testdir1_size}"
8655 echo "target rename dir size: ${testdir2_size}"
8657 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8658 eval $cmd || error "$cmd failed"
8659 local samedir=$($cmd | grep 'same_dir')
8660 local same_sample=$(get_rename_size $testdir1_size)
8661 [ -z "$samedir" ] && error "samedir_rename_size count error"
8662 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8663 echo "Check same dir rename stats success"
8665 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8667 # check crossdir rename size
8668 mv ${testdir1}/test_0 ${testdir2}/test_0
8670 testdir1_size=$(ls -l $DIR/${tdir} |
8671 awk '/stats_testdir1/ {print $5}')
8672 testdir2_size=$(ls -l $DIR/${tdir} |
8673 awk '/stats_testdir2/ {print $5}')
8675 testdir1_size=$(order_2 $testdir1_size)
8676 testdir2_size=$(order_2 $testdir2_size)
8678 testdir1_size=$(size_in_KMGT $testdir1_size)
8679 testdir2_size=$(size_in_KMGT $testdir2_size)
8681 echo "source rename dir size: ${testdir1_size}"
8682 echo "target rename dir size: ${testdir2_size}"
8684 eval $cmd || error "$cmd failed"
8685 local crossdir=$($cmd | grep 'crossdir')
8686 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8687 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8688 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8689 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8690 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8691 echo "Check cross dir rename stats success"
8694 run_test 133d "Verifying rename_stats ========================================"
8697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8698 local testdir=$DIR/${tdir}/stats_testdir
8699 local ctr f0 f1 bs=32768 count=42 sum
8701 remote_ost_nodsh && skip "remote OST with nodsh" && return
8702 mkdir -p ${testdir} || error "mkdir failed"
8704 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8706 for ctr in {write,read}_bytes; do
8708 cancel_lru_locks osc
8710 do_facet ost1 $LCTL set_param -n \
8711 "obdfilter.*.exports.clear=clear"
8713 if [ $ctr = write_bytes ]; then
8715 f1=${testdir}/${tfile}
8717 f0=${testdir}/${tfile}
8721 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8724 cancel_lru_locks osc
8726 sum=$(do_facet ost1 $LCTL get_param \
8727 "obdfilter.*.exports.*.stats" | \
8730 $1 == ctr { sum += $7 }
8733 if ((sum != bs * count)); then
8734 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8740 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8743 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8746 # First without trusting modes.
8748 -exec cat '{}' \; &> /dev/null
8750 # Second verifying readability.
8754 -exec cat '{}' \; > /dev/null ||
8755 error "proc file read failed"
8757 for facet in $SINGLEMDS ost1; do
8758 do_facet $facet find $proc_dirs \
8759 -not -name req_history \
8760 -exec cat '{}' \\\; &> /dev/null
8762 do_facet $facet find $proc_dirs \
8763 -not -name req_history \
8766 -exec cat '{}' \\\; > /dev/null ||
8767 error "proc file read failed"
8770 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8772 test_140() { #bug-17379
8773 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8774 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8775 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8776 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8778 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8779 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8781 while i=`expr $i + 1`; do
8782 test_mkdir -p $i || error "Creating dir $i"
8783 cd $i || error "Changing to $i"
8784 ln -s ../stat stat || error "Creating stat symlink"
8785 # Read the symlink until ELOOP present,
8786 # not LBUGing the system is considered success,
8787 # we didn't overrun the stack.
8788 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8790 if [ $ret -eq 40 ]; then
8793 error "Open stat symlink"
8799 echo "The symlink depth = $i"
8800 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8801 error "Invalid symlink depth"
8803 # Test recursive symlink
8804 ln -s symlink_self symlink_self
8805 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8806 echo "open symlink_self returns $ret"
8807 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8809 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8813 local TF="$TMP/$tfile"
8815 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8817 cancel_lru_locks osc
8818 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8819 remount_client $MOUNT
8821 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8824 $TRUNCATE $DIR/$tfile 6000
8825 cancel_lru_locks osc
8826 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8829 echo "12345" >>$DIR/$tfile
8830 cancel_lru_locks osc
8831 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8834 echo "12345" >>$DIR/$tfile
8835 cancel_lru_locks osc
8836 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8841 run_test 150 "truncate/append tests"
8843 #LU-2902 roc_hit was not able to read all values from lproc
8844 function roc_hit_init() {
8845 local list=$(comma_list $(osts_nodes))
8846 local dir=$DIR/$tdir-check
8847 local file=$dir/file
8853 #use setstripe to do a write to every ost
8854 for i in $(seq 0 $((OSTCOUNT-1))); do
8855 $SETSTRIPE -c 1 -i $i $dir || error "$SETSTRIPE $file failed"
8856 dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
8857 idx=$(printf %04x $i)
8858 BEFORE=$(get_osd_param $list *OST*$idx stats |
8859 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8860 if [ -z "$BEFORE" ]; then
8864 cancel_lru_locks osc
8865 cat $file >/dev/null
8867 AFTER=$(get_osd_param $list *OST*$idx stats |
8868 awk '$1 == "cache_access" {sum += $2} END { print sum }')
8870 echo BEFORE:$BEFORE AFTER:$AFTER
8871 if ! let "AFTER - BEFORE == 4"; then
8873 error "roc_hit is not safe to use"
8881 function roc_hit() {
8882 local list=$(comma_list $(osts_nodes))
8883 echo $(get_osd_param $list '' stats |
8884 awk '$1 == "cache_hit" {sum += $2} END { print sum }')
8887 function set_cache() {
8890 if [ "$2" == "off" ]; then
8893 local list=$(comma_list $(osts_nodes))
8894 set_osd_param $list '' $1_cache_enable $on
8896 cancel_lru_locks osc
8900 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8901 remote_ost_nodsh && skip "remote OST with nodsh" && return
8904 local list=$(comma_list $(osts_nodes))
8906 # check whether obdfilter is cache capable at all
8907 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8908 echo "not cache-capable obdfilter"
8912 # check cache is enabled on all obdfilters
8913 if get_osd_param $list '' read_cache_enable | grep 0; then
8914 echo "oss cache is disabled"
8918 set_osd_param $list '' writethrough_cache_enable 1
8920 # check write cache is enabled on all obdfilters
8921 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8922 echo "oss write cache is NOT enabled"
8928 #define OBD_FAIL_OBD_NO_LRU 0x609
8929 do_nodes $list $LCTL set_param fail_loc=0x609
8931 # pages should be in the case right after write
8932 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
8935 local BEFORE=$(roc_hit)
8936 cancel_lru_locks osc
8937 cat $DIR/$tfile >/dev/null
8938 local AFTER=$(roc_hit)
8940 do_nodes $list $LCTL set_param fail_loc=0
8942 if ! let "AFTER - BEFORE == CPAGES"; then
8943 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8946 # the following read invalidates the cache
8947 cancel_lru_locks osc
8948 set_osd_param $list '' read_cache_enable 0
8949 cat $DIR/$tfile >/dev/null
8951 # now data shouldn't be found in the cache
8953 cancel_lru_locks osc
8954 cat $DIR/$tfile >/dev/null
8956 if let "AFTER - BEFORE != 0"; then
8957 error "IN CACHE: before: $BEFORE, after: $AFTER"
8960 set_osd_param $list '' read_cache_enable 1
8963 run_test 151 "test cache on oss and controls ==============================="
8966 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8967 local TF="$TMP/$tfile"
8969 # simulate ENOMEM during write
8970 #define OBD_FAIL_OST_NOMEM 0x226
8971 lctl set_param fail_loc=0x80000226
8972 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8974 sync || error "sync failed"
8975 lctl set_param fail_loc=0
8977 # discard client's cache
8978 cancel_lru_locks osc
8980 # simulate ENOMEM during read
8981 lctl set_param fail_loc=0x80000226
8982 cmp $TF $DIR/$tfile || error "cmp failed"
8983 lctl set_param fail_loc=0
8987 run_test 152 "test read/write with enomem ============================"
8990 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8992 run_test 153 "test if fdatasync does not crash ======================="
8994 dot_lustre_fid_permission_check() {
8996 local ffid=$MOUNT/.lustre/fid/$fid
8999 echo "stat fid $fid"
9000 stat $ffid > /dev/null || error "stat $ffid failed."
9001 echo "touch fid $fid"
9002 touch $ffid || error "touch $ffid failed."
9003 echo "write to fid $fid"
9004 cat /etc/hosts > $ffid || error "write $ffid failed."
9005 echo "read fid $fid"
9006 diff /etc/hosts $ffid || error "read $ffid failed."
9007 echo "append write to fid $fid"
9008 cat /etc/hosts >> $ffid || error "append write $ffid failed."
9009 echo "rename fid $fid"
9010 mv $ffid $test_dir/$tfile.1 &&
9011 error "rename $ffid to $tfile.1 should fail."
9012 touch $test_dir/$tfile.1
9013 mv $test_dir/$tfile.1 $ffid &&
9014 error "rename $tfile.1 to $ffid should fail."
9015 rm -f $test_dir/$tfile.1
9016 echo "truncate fid $fid"
9017 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
9018 echo "link fid $fid"
9019 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
9020 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
9021 echo "setfacl fid $fid"
9022 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
9023 echo "getfacl fid $fid"
9024 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
9026 echo "unlink fid $fid"
9027 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
9028 echo "mknod fid $fid"
9029 mknod $ffid c 1 3 && error "mknod $ffid should fail."
9031 fid=[0xf00000400:0x1:0x0]
9032 ffid=$MOUNT/.lustre/fid/$fid
9034 echo "stat non-exist fid $fid"
9035 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
9036 echo "write to non-exist fid $fid"
9037 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
9038 echo "link new fid $fid"
9039 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
9041 mkdir -p $test_dir/$tdir
9042 touch $test_dir/$tdir/$tfile
9043 fid=$($LFS path2fid $test_dir/$tdir)
9046 error "error: could not get fid for $test_dir/$dir/$tfile."
9048 ffid=$MOUNT/.lustre/fid/$fid
9051 ls $ffid > /dev/null || error "ls $ffid failed."
9052 echo "touch $fid/$tfile.1"
9053 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
9055 echo "touch $MOUNT/.lustre/fid/$tfile"
9056 touch $MOUNT/.lustre/fid/$tfile && \
9057 error "touch $MOUNT/.lustre/fid/$tfile should fail."
9059 echo "setxattr to $MOUNT/.lustre/fid"
9060 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
9062 echo "listxattr for $MOUNT/.lustre/fid"
9063 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
9065 echo "delxattr from $MOUNT/.lustre/fid"
9066 setfattr -x trusted.name1 $MOUNT/.lustre/fid
9068 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
9069 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
9070 error "touch invalid fid should fail."
9072 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
9073 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
9074 error "touch non-normal fid should fail."
9076 echo "rename $tdir to $MOUNT/.lustre/fid"
9077 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
9078 error "rename to $MOUNT/.lustre/fid should fail."
9080 if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.51) ]
9082 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
9083 local new_obf_mode=777
9085 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
9086 chmod $new_obf_mode $DIR/.lustre/fid ||
9087 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
9089 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
9090 [ $obf_mode -eq $new_obf_mode ] ||
9091 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
9093 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
9094 chmod $old_obf_mode $DIR/.lustre/fid ||
9095 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
9098 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
9099 fid=$($LFS path2fid $test_dir/$tfile-2)
9100 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
9101 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
9102 error "create lov data thru .lustre should fail."
9103 echo "cp /etc/passwd $test_dir/$tfile-2"
9104 cp /etc/passwd $test_dir/$tfile-2 ||
9105 error "copy to $test_dir/$tfile-2 failed."
9106 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
9107 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
9108 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
9110 rm -rf $test_dir/tfile.lnk
9111 rm -rf $test_dir/$tfile-2
9115 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9116 skip "Need MDS version at least 2.4.1" && return
9119 local FID=$($LFS path2fid $DIR/$tfile)
9120 [ -z "$FID" ] && error "path2fid unable to get $DIR/$tfile FID"
9122 # check that we get the same pathname back
9123 local FOUND=$($LFS fid2path $MOUNT $FID)
9124 [ -z "$FOUND" ] && error "fid2path unable to get $FID path"
9125 [ "$FOUND" != "$DIR/$tfile" ] &&
9126 error "fid2path(path2fid($DIR/$tfile)) = $FOUND != $DIR/$tfile"
9130 run_test 154A "lfs path2fid and fid2path basic checks"
9133 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9134 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9135 { skip "Need MDS version at least 2.2.51"; return 0; }
9137 cp /etc/hosts $DIR/$tfile
9139 fid=$($LFS path2fid $DIR/$tfile)
9141 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
9143 dot_lustre_fid_permission_check "$fid" $DIR ||
9144 error "dot lustre permission check $fid failed"
9146 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
9148 touch $MOUNT/.lustre/file &&
9149 error "creation is not allowed under .lustre"
9151 mkdir $MOUNT/.lustre/dir &&
9152 error "mkdir is not allowed under .lustre"
9156 run_test 154a "Open-by-FID"
9159 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9160 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
9161 { skip "Need MDS version at least 2.2.51"; return 0; }
9163 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
9165 local remote_dir=$DIR/$tdir/remote_dir
9170 $LFS mkdir -i $MDTIDX $remote_dir ||
9171 error "create remote directory failed"
9173 cp /etc/hosts $remote_dir/$tfile
9175 fid=$($LFS path2fid $remote_dir/$tfile)
9177 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
9179 dot_lustre_fid_permission_check "$fid" $remote_dir ||
9180 error "dot lustre permission check $fid failed"
9183 run_test 154b "Open-by-FID for remote directory"
9186 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
9187 skip "Need MDS version at least 2.4.1" && return
9189 touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
9190 local FID1=$($LFS path2fid $DIR/$tfile.1)
9191 local FID2=$($LFS path2fid $DIR/$tfile.2)
9192 local FID3=$($LFS path2fid $DIR/$tfile.3)
9195 $LFS path2fid $DIR/$tfile.[123] | while read PATHNAME FID; do
9196 [ "$PATHNAME" = "$DIR/$tfile.$N:" ] ||
9197 error "path2fid pathname $PATHNAME != $DIR/$tfile.$N:"
9199 [ "$FID" = "${!want}" ] ||
9200 error "path2fid $PATHNAME FID $FID != FID$N ${!want}"
9204 $LFS fid2path $MOUNT $FID1 $FID2 $FID3 | while read PATHNAME; do
9205 [ "$PATHNAME" = "$DIR/$tfile.$N" ] ||
9206 error "fid2path pathname $PATHNAME != $DIR/$tfile.$N:"
9210 run_test 154c "lfs path2fid and fid2path multiple arguments"
9213 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
9214 skip "Need MDS version at least 2.5.53" && return
9217 nid=$($LCTL list_nids | sed "s/\./\\\./g")
9221 local proc_ofile="mdt.*.exports.'$nid'.open_files"
9228 fid=$($LFS path2fid $DIR/$tfile)
9231 cmd="exec $fd<$DIR/$tfile"
9233 fid_list=$(do_facet $SINGLEMDS $LCTL get_param $proc_ofile)
9234 echo $fid_list | grep $fid
9237 cmd="exec $fd>/dev/null"
9239 if [ $rc -ne 0 ]; then
9240 error "FID $fid not found in open files list $fid_list"
9243 run_test 154d "Verify open file fid"
9245 test_155_small_load() {
9246 local temp=$TMP/$tfile
9247 local file=$DIR/$tfile
9249 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
9250 error "dd of=$temp bs=6096 count=1 failed"
9252 cancel_lru_locks osc
9253 cmp $temp $file || error "$temp $file differ"
9255 $TRUNCATE $temp 6000
9256 $TRUNCATE $file 6000
9257 cmp $temp $file || error "$temp $file differ (truncate1)"
9259 echo "12345" >>$temp
9260 echo "12345" >>$file
9261 cmp $temp $file || error "$temp $file differ (append1)"
9263 echo "12345" >>$temp
9264 echo "12345" >>$file
9265 cmp $temp $file || error "$temp $file differ (append2)"
9271 test_155_big_load() {
9272 remote_ost_nodsh && skip "remote OST with nodsh" && return
9273 local temp=$TMP/$tfile
9274 local file=$DIR/$tfile
9277 local cache_size=$(do_facet ost$((MAXI+1)) \
9278 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
9279 local large_file_size=$((cache_size * 2))
9281 echo "OSS cache size: $cache_size KB"
9282 echo "Large file size: $large_file_size KB"
9284 [ $MAXV -le $large_file_size ] && \
9285 skip_env "max available OST size needs > $large_file_size KB" && \
9288 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
9290 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
9291 error "dd of=$temp bs=$large_file_size count=1k failed"
9294 cancel_lru_locks osc
9295 cmp $temp $file || error "$temp $file differ"
9302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9304 set_cache writethrough on
9307 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
9310 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9312 set_cache writethrough off
9315 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
9318 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9320 set_cache writethrough on
9323 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
9326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9328 set_cache writethrough off
9331 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
9334 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9336 set_cache writethrough on
9339 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
9342 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9344 set_cache writethrough off
9347 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
9350 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9352 set_cache writethrough on
9355 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
9358 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9360 set_cache writethrough off
9363 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9366 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9370 local file="$DIR/$tfile"
9372 [ "$(facet_fstype ost1)" = "zfs" ] &&
9373 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9378 log "Turn on read and write cache"
9380 set_cache writethrough on
9382 log "Write data and read it back."
9383 log "Read should be satisfied from the cache."
9384 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9386 cancel_lru_locks osc
9387 cat $file >/dev/null
9389 if ! let "AFTER - BEFORE == CPAGES"; then
9390 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9392 log "cache hits:: before: $BEFORE, after: $AFTER"
9395 log "Read again; it should be satisfied from the cache."
9397 cancel_lru_locks osc
9398 cat $file >/dev/null
9400 if ! let "AFTER - BEFORE == CPAGES"; then
9401 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9403 log "cache hits:: before: $BEFORE, after: $AFTER"
9407 log "Turn off the read cache and turn on the write cache"
9409 set_cache writethrough on
9411 log "Read again; it should be satisfied from the cache."
9413 cancel_lru_locks osc
9414 cat $file >/dev/null
9416 if ! let "AFTER - BEFORE == CPAGES"; then
9417 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9419 log "cache hits:: before: $BEFORE, after: $AFTER"
9422 log "Read again; it should not be satisfied from the cache."
9424 cancel_lru_locks osc
9425 cat $file >/dev/null
9427 if ! let "AFTER - BEFORE == 0"; then
9428 error "IN CACHE: before: $BEFORE, after: $AFTER"
9430 log "cache hits:: before: $BEFORE, after: $AFTER"
9433 log "Write data and read it back."
9434 log "Read should be satisfied from the cache."
9435 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9437 cancel_lru_locks osc
9438 cat $file >/dev/null
9440 if ! let "AFTER - BEFORE == CPAGES"; then
9441 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9443 log "cache hits:: before: $BEFORE, after: $AFTER"
9446 log "Read again; it should not be satisfied from the cache."
9448 cancel_lru_locks osc
9449 cat $file >/dev/null
9451 if ! let "AFTER - BEFORE == 0"; then
9452 error "IN CACHE: before: $BEFORE, after: $AFTER"
9454 log "cache hits:: before: $BEFORE, after: $AFTER"
9458 log "Turn off read and write cache"
9460 set_cache writethrough off
9462 log "Write data and read it back"
9463 log "It should not be satisfied from the cache."
9465 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9466 cancel_lru_locks osc
9468 cat $file >/dev/null
9470 if ! let "AFTER - BEFORE == 0"; then
9471 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9473 log "cache hits:: before: $BEFORE, after: $AFTER"
9476 log "Turn on the read cache and turn off the write cache"
9478 set_cache writethrough off
9480 log "Write data and read it back"
9481 log "It should not be satisfied from the cache."
9483 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9485 cancel_lru_locks osc
9486 cat $file >/dev/null
9488 if ! let "AFTER - BEFORE == 0"; then
9489 error_ignore bz20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9491 log "cache hits:: before: $BEFORE, after: $AFTER"
9494 log "Read again; it should be satisfied from the cache."
9496 cancel_lru_locks osc
9497 cat $file >/dev/null
9499 if ! let "AFTER - BEFORE == CPAGES"; then
9500 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9502 log "cache hits:: before: $BEFORE, after: $AFTER"
9507 run_test 156 "Verification of tunables ============================"
9511 if [ $MDSCOUNT -gt 1 ]; then
9512 error_ignore bz17935 $*
9520 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9522 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9524 if [ $MASK -eq 1 ]; then
9525 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9527 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9531 changelog_extract_field() {
9537 $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
9538 print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
9543 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9544 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9545 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9546 { skip "Need MDS version at least 2.2.0"; return; }
9548 local CL_USERS="mdd.$MDT0.changelog_users"
9549 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9550 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9551 echo "Registered as changelog user $USER"
9552 $GET_CL_USERS | grep -q $USER ||
9553 error "User $USER not found in changelog_users"
9556 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9557 touch $DIR/$tdir/pics/2008/zachy/timestamp
9558 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9559 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9560 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9561 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9562 rm $DIR/$tdir/pics/desktop.jpg
9564 $LFS changelog $MDT0 | tail -5
9566 echo "verifying changelog mask"
9567 changelog_chmask "MKDIR"
9568 changelog_chmask "CLOSE"
9570 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9571 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9573 changelog_chmask "MKDIR"
9574 changelog_chmask "CLOSE"
9576 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9577 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9579 $LFS changelog $MDT0
9580 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9581 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9582 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9583 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9586 echo "verifying target fid"
9587 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
9588 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9589 [ "$fidc" == "$fidf" ] ||
9590 err17935 "fid in changelog $fidc != file fid $fidf"
9591 echo "verifying parent fid"
9592 fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
9593 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9594 [ "$fidc" == "$fidf" ] ||
9595 err17935 "pfid in changelog $fidc != dir fid $fidf"
9597 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9598 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9599 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9600 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9601 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9602 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9604 MIN_REC=$($GET_CL_USERS |
9605 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9606 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9607 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9608 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9609 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9611 # LU-3446 changelog index reset on MDT restart
9612 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9613 CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9614 $LFS changelog_clear $MDT0 $USER 0
9615 stop $SINGLEMDS || error "Fail to stop MDT."
9616 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9617 CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9618 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9619 [ $CUR_REC1 == $CUR_REC2 ] ||
9620 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9622 echo "verifying user deregister"
9623 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9624 $GET_CL_USERS | grep -q $USER &&
9625 error "User $USER still in changelog_users"
9627 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9628 if [ $USERS -eq 0 ]; then
9629 LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9630 touch $DIR/$tdir/chloe
9631 LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9632 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9633 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9635 echo "$USERS other changelog users; can't verify off"
9638 run_test 160a "changelog sanity"
9640 test_160b() { # LU-3587
9641 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9642 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9643 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9644 { skip "Need MDS version at least 2.2.0"; return; }
9646 local CL_USERS="mdd.$MDT0.changelog_users"
9647 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9648 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9649 echo "Registered as changelog user $USER"
9650 $GET_CL_USERS | grep -q $USER ||
9651 error "User $USER not found in changelog_users"
9653 local LONGNAME1=$(str_repeat a 255)
9654 local LONGNAME2=$(str_repeat b 255)
9657 echo "creating very long named file"
9658 touch $LONGNAME1 || error "create of $LONGNAME1 failed"
9659 echo "moving very long named file"
9660 mv $LONGNAME1 $LONGNAME2
9662 $LFS changelog $MDT0 | grep RENME
9664 echo "deregistering $USER"
9665 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9669 run_test 160b "Verify that very long rename doesn't crash in changelog"
9672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9673 test_mkdir -p $DIR/$tdir
9674 cp /etc/hosts $DIR/$tdir/$tfile
9675 test_mkdir $DIR/$tdir/foo1
9676 test_mkdir $DIR/$tdir/foo2
9677 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9678 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9679 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9680 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9681 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9682 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9683 $LFS fid2path $DIR $FID
9684 err17935 "bad link ea"
9687 rm $DIR/$tdir/foo2/zachary
9689 rm $DIR/$tdir/foo2/thor
9691 rm $DIR/$tdir/$tfile
9693 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9694 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9696 $LFS fid2path $DIR $FID
9697 err17935 "bad link rename"
9699 rm $DIR/$tdir/foo2/maggie
9702 local longname=filename_avg_len_is_thirty_two_
9703 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9704 error "failed to hardlink many files"
9705 links=$($LFS fid2path $DIR $FID | wc -l)
9706 echo -n "${links}/1000 links in link EA"
9707 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9708 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9709 error "failed to unlink many hardlinks"
9711 run_test 161a "link ea sanity"
9714 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9715 [ $MDSCOUNT -lt 2 ] &&
9716 skip "skipping remote directory test" && return
9718 local remote_dir=$DIR/$tdir/remote_dir
9721 $LFS mkdir -i $MDTIDX $remote_dir ||
9722 error "create remote directory failed"
9724 cp /etc/hosts $remote_dir/$tfile
9725 mkdir -p $remote_dir/foo1
9726 mkdir -p $remote_dir/foo2
9727 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9728 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9729 ln $remote_dir/$tfile $remote_dir/foo1/luna
9730 ln $remote_dir/$tfile $remote_dir/foo2/thor
9732 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9734 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9735 $LFS fid2path $DIR $FID
9736 err17935 "bad link ea"
9739 rm $remote_dir/foo2/zachary
9741 rm $remote_dir/foo2/thor
9743 rm $remote_dir/$tfile
9745 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9746 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9747 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9748 $LFS fid2path $DIR $FID
9749 err17935 "bad link rename"
9751 rm $remote_dir/foo2/maggie
9754 local longname=filename_avg_len_is_thirty_two_
9755 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9756 error "failed to hardlink many files"
9757 links=$($LFS fid2path $DIR $FID | wc -l)
9758 echo -n "${links}/1000 links in link EA"
9759 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9760 unlinkmany $remote_dir/foo2/$longname 1000 ||
9761 error "failed to unlink many hardlinks"
9763 run_test 161b "link ea sanity under remote directory"
9766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9767 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
9768 skip "Need MDS version at least 2.1.5" && return
9770 # define CLF_RENAME_LAST 0x0001
9771 # rename overwrite a target having nlink = 1 (changelog flag 0x1)
9772 local USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
9773 changelog_register -n)
9776 touch $DIR/$tdir/foo_161c
9777 touch $DIR/$tdir/bar_161c
9778 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9779 $LFS changelog $MDT0 | grep RENME
9780 local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
9782 $LFS changelog_clear $MDT0 $USER 0
9783 if [ x$flags != "x0x1" ]; then
9784 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9786 error "flag $flags is not 0x1"
9788 echo "rename overwrite a target having nlink = 1," \
9789 "changelog record has flags of $flags"
9791 # rename overwrite a target having nlink > 1 (changelog flag 0x0)
9792 touch $DIR/$tdir/foo_161c
9793 touch $DIR/$tdir/bar_161c
9794 ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9795 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
9796 $LFS changelog $MDT0 | grep RENME
9797 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9798 $LFS changelog_clear $MDT0 $USER 0
9799 if [ x$flags != "x0x0" ]; then
9800 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9802 error "flag $flags is not 0x0"
9804 echo "rename overwrite a target having nlink > 1," \
9805 "changelog record has flags of $flags"
9807 # rename doesn't overwrite a target (changelog flag 0x0)
9808 touch $DIR/$tdir/foo_161c
9809 mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
9810 $LFS changelog $MDT0 | grep RENME
9811 flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
9812 $LFS changelog_clear $MDT0 $USER 0
9813 if [ x$flags != "x0x0" ]; then
9814 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9816 error "flag $flags is not 0x0"
9818 echo "rename doesn't overwrite a target," \
9819 "changelog record has flags of $flags"
9821 # define CLF_UNLINK_LAST 0x0001
9822 # unlink a file having nlink = 1 (changelog flag 0x1)
9823 rm -f $DIR/$tdir/foo2_161c
9824 $LFS changelog $MDT0 | grep UNLNK
9825 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9826 $LFS changelog_clear $MDT0 $USER 0
9827 if [ x$flags != "x0x1" ]; then
9828 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9830 error "flag $flags is not 0x1"
9832 echo "unlink a file having nlink = 1," \
9833 "changelog record has flags of $flags"
9835 # unlink a file having nlink > 1 (changelog flag 0x0)
9836 ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
9837 rm -f $DIR/$tdir/foobar_161c
9838 $LFS changelog $MDT0 | grep UNLNK
9839 flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
9840 $LFS changelog_clear $MDT0 $USER 0
9841 if [ x$flags != "x0x0" ]; then
9842 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister \
9844 error "flag $flags is not 0x0"
9846 echo "unlink a file having nlink > 1," \
9847 "changelog record has flags of $flags"
9848 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9850 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
9857 local path=$(${LFS} fid2path $*)
9860 if [ $RC -ne 0 ]; then
9861 err17935 "path looked up of $expected failed. Error $RC"
9863 elif [ "${path}" != "${expected}" ]; then
9864 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9867 echo "fid $fid resolves to path $path (expected $expected)"
9871 # Make changes to filesystem
9872 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9873 test_mkdir -p $DIR/$tdir/d2
9874 touch $DIR/$tdir/d2/$tfile
9875 touch $DIR/$tdir/d2/x1
9876 touch $DIR/$tdir/d2/x2
9877 test_mkdir -p $DIR/$tdir/d2/a/b/c
9878 test_mkdir -p $DIR/$tdir/d2/p/q/r
9880 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9881 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9884 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9885 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9886 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9888 # softlink to wrong file
9889 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9890 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9891 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9894 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9895 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9896 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9897 # fid2path dir/fsname should both work
9898 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9899 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9901 # hardlink count: check that there are 2 links
9902 # Doesnt work with CMD yet: 17935
9903 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9904 err17935 "expected 2 links"
9906 # hardlink indexing: remove the first link
9907 rm $DIR/$tdir/d2/p/q/r/hlink
9908 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9912 run_test 162 "path lookup sanity"
9915 # do directio so as not to populate the page cache
9916 log "creating a 10 Mb file"
9917 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9918 log "starting reads"
9919 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9920 log "truncating the file"
9921 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9923 kill %+ || true # reads might have finished
9924 echo "wait until dd is finished"
9926 log "removing the temporary file"
9927 rm -rf $DIR/$tfile || error "tmp file removal failed"
9929 run_test 169 "parallel read and truncate should not deadlock"
9932 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9933 $LCTL clear # bug 18514
9934 $LCTL debug_daemon start $TMP/${tfile}_log_good
9936 $LCTL debug_daemon stop
9937 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9938 error "sed failed to read log_good"
9940 $LCTL debug_daemon start $TMP/${tfile}_log_good
9942 $LCTL debug_daemon stop
9944 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9945 error "lctl df log_bad failed"
9947 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9948 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9950 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9951 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9953 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9954 error "bad_line good_line1 good_line2 are empty"
9956 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9957 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9958 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9960 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9961 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9962 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9964 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9965 error "bad_line_new good_line_new are empty"
9967 local expected_good=$((good_line1 + good_line2*2))
9969 rm -f $TMP/${tfile}*
9970 # LU-231, short malformed line may not be counted into bad lines
9971 if [ $bad_line -ne $bad_line_new ] &&
9972 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9973 error "expected $bad_line bad lines, but got $bad_line_new"
9977 if [ $expected_good -ne $good_line_new ]; then
9978 error "expected $expected_good good lines, but got $good_line_new"
9983 run_test 170 "test lctl df to handle corrupted log ====================="
9985 test_171() { # bug20592
9986 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9987 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9988 $LCTL set_param fail_loc=0x50e
9989 $LCTL set_param fail_val=3000
9990 multiop_bg_pause $DIR/$tfile O_s || true
9992 kill -USR1 $MULTIPID
9996 if dmesg | grep "recursive fault"; then
9997 error "caught a recursive fault"
9999 $LCTL set_param fail_loc=0
10002 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
10004 # it would be good to share it with obdfilter-survey/libecho code
10005 setup_obdecho_osc () {
10008 local obdfilter_name=$2
10009 echo "Creating new osc for $obdfilter_name on $ost_nid"
10010 # make sure we can find loopback nid
10011 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
10013 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
10014 ${obdfilter_name}_osc_UUID || rc=2; }
10015 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
10016 ${obdfilter_name}_UUID $ost_nid || rc=3; }
10020 cleanup_obdecho_osc () {
10021 local obdfilter_name=$1
10022 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
10023 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
10030 local pages=${3:-64}
10035 local obd_size=$(get_obd_size $node $OBD)
10036 local page_size=$(get_page_size $node)
10037 if [[ -n "$obd_size" ]]; then
10038 local new_count=$((obd_size / (pages * page_size / 1024)))
10039 [[ $new_count -ge $count ]] || count=$new_count
10042 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
10043 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
10045 if [ $rc -eq 0 ]; then
10046 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
10047 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
10049 echo "New object id is $id"
10050 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
10052 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
10053 "test_brw $count w v $pages $id" || rc=4; }
10054 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
10056 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
10057 "cleanup" || rc=5; }
10058 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
10059 "detach" || rc=6; }
10060 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
10065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10066 remote_ost_nodsh && skip "remote OST with nodsh" && return
10068 local rmmod_local=0
10070 if ! module_loaded obdecho; then
10071 load_module obdecho/obdecho
10075 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
10076 local host=$(lctl get_param -n osc.$osc.import |
10077 awk '/current_connection:/ {print $2}' )
10078 local target=$(lctl get_param -n osc.$osc.import |
10079 awk '/target:/ {print $2}' )
10080 target=${target%_UUID}
10082 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
10083 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
10084 [[ -n $target ]] && cleanup_obdecho_osc $target
10085 [ $rmmod_local -eq 1 ] && rmmod obdecho
10088 run_test 180a "test obdecho on osc"
10091 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10092 remote_ost_nodsh && skip "remote OST with nodsh" && return
10094 local rmmod_remote=0
10096 do_facet ost1 "lsmod | grep -q obdecho || " \
10097 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
10098 "modprobe obdecho; }" && rmmod_remote=1
10099 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
10100 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
10101 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
10104 run_test 180b "test obdecho directly on obdfilter"
10106 test_180c() { # LU-2598
10107 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10108 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
10109 skip "Need MDS version at least 2.4.0" && return
10112 local rmmod_remote=false
10113 local pages=16384 # 64MB bulk I/O RPC size
10116 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
10117 rmmod_remote=true || error "failed to load module obdecho"
10119 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4}'|head -1)
10120 if [[ -n $target ]]; then
10121 obdecho_test "$target" ost1 "$pages" ||
10122 rc=${PIPESTATUS[0]}
10124 echo "there is no obdfilter target on ost1"
10127 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
10130 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
10132 test_181() { # bug 22177
10133 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10134 # create enough files to index the directory
10135 createmany -o $DIR/$tdir/foobar 4000
10136 # print attributes for debug purpose
10139 multiop_bg_pause $DIR/$tdir D_Sc || return 1
10141 # remove the files & current working dir
10142 unlinkmany $DIR/$tdir/foobar 4000
10144 kill -USR1 $MULTIPID
10146 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
10149 run_test 181 "Test open-unlinked dir ========================"
10152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10153 # disable MDC RPC lock wouldn't crash client
10157 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10158 #define OBD_FAIL_MDC_RPCS_SEM 0x804
10159 $LCTL set_param fail_loc=0x804
10161 for (( i=0; i < $tcount; i++ )) ; do
10162 mkdir $DIR/$tdir/$i
10163 createmany -o $DIR/$tdir/$i/f- $fcount &
10167 for (( i=0; i < $tcount; i++ )) ; do
10168 unlinkmany $DIR/$tdir/$i/f- $fcount &
10174 $LCTL set_param fail_loc=0
10176 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
10178 test_183() { # LU-2275
10179 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
10180 skip "Need MDS version at least 2.3.56" && return
10182 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10183 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10184 echo aaa > $DIR/$tdir/$tfile
10186 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
10187 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
10189 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
10190 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
10192 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
10194 # Flush negative dentry cache
10195 touch $DIR/$tdir/$tfile
10197 # We are not checking for any leaked references here, they'll
10198 # become evident next time we do cleanup with module unload.
10201 run_test 183 "No crash or request leak in case of strange dispositions ========"
10203 # test suite 184 is for LU-2016, LU-2017
10205 check_swap_layouts_support && return 0
10207 dir0=$DIR/$tdir/$testnum
10208 test_mkdir -p $dir0 || error "creating dir $dir0"
10213 $SETSTRIPE -c1 $file1
10215 $SETSTRIPE -c2 $file2
10217 gen1=$($GETSTRIPE -g $file1)
10218 gen2=$($GETSTRIPE -g $file2)
10220 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
10221 gen=$($GETSTRIPE -g $file1)
10222 [[ $gen1 != $gen ]] ||
10223 "Layout generation on $file1 does not change"
10224 gen=$($GETSTRIPE -g $file2)
10225 [[ $gen2 != $gen ]] ||
10226 "Layout generation on $file2 does not change"
10228 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
10229 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
10231 run_test 184a "Basic layout swap"
10234 check_swap_layouts_support && return 0
10236 dir0=$DIR/$tdir/$testnum
10237 mkdir -p $dir0 || error "creating dir $dir0"
10244 $SETSTRIPE -c1 $file1
10245 $SETSTRIPE -c2 $file2
10246 $SETSTRIPE -c1 $file3
10247 chown $RUNAS_ID $file3
10248 gen1=$($GETSTRIPE -g $file1)
10249 gen2=$($GETSTRIPE -g $file2)
10251 $LFS swap_layouts $dir1 $dir2 &&
10252 error "swap of directories layouts should fail"
10253 $LFS swap_layouts $dir1 $file1 &&
10254 error "swap of directory and file layouts should fail"
10255 $RUNAS $LFS swap_layouts $file1 $file2 &&
10256 error "swap of file we cannot write should fail"
10257 $LFS swap_layouts $file1 $file3 &&
10258 error "swap of file with different owner should fail"
10259 /bin/true # to clear error code
10261 run_test 184b "Forbidden layout swap (will generate errors)"
10264 check_swap_layouts_support && return 0
10266 local dir0=$DIR/$tdir/$testnum
10267 mkdir -p $dir0 || error "creating dir $dir0"
10269 local ref1=$dir0/ref1
10270 local ref2=$dir0/ref2
10271 local file1=$dir0/file1
10272 local file2=$dir0/file2
10273 # create a file large enough for the concurent test
10274 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
10275 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
10276 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
10279 dd if=$ref1 of=$file1 bs=16k &
10282 # Make sure dd starts to copy file
10283 while [ ! -f $file1 ]; do sleep 0.1; done
10285 $LFS swap_layouts $file1 $file2
10288 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
10289 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
10291 # how many bytes copied before swapping layout
10292 local copied=`stat -c %s $file2`
10293 local remaining=`stat -c %s $ref1`
10294 remaining=$((remaining - copied))
10295 echo "Copied $copied bytes before swapping layout..."
10297 cmp -n $copied $file1 $ref2 | grep differ &&
10298 error "Content mismatch [0, $copied) of ref2 and file1"
10299 cmp -n $copied $file2 $ref1 ||
10300 error "Content mismatch [0, $copied) of ref1 and file2"
10301 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
10302 error "Content mismatch [$copied, EOF) of ref1 and file1"
10305 rm -f $ref1 $ref2 $file1 $file2
10307 run_test 184c "Concurrent write and layout swap"
10310 check_swap_layouts_support && return 0
10312 local file1=$DIR/$tdir/$tfile-1
10313 local file2=$DIR/$tdir/$tfile-2
10314 local file3=$DIR/$tdir/$tfile-3
10318 mkdir -p $DIR/$tdir
10319 touch $file1 || error "create $file1 failed"
10320 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
10321 error "create $file2 failed"
10322 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
10323 error "create $file3 failed"
10324 lovea1=$($LFS getstripe $file1 | sed 1d)
10326 $LFS swap_layouts $file2 $file3 ||
10327 error "swap $file2 $file3 layouts failed"
10328 $LFS swap_layouts $file1 $file2 ||
10329 error "swap $file1 $file2 layouts failed"
10331 lovea2=$($LFS getstripe $file2 | sed 1d)
10332 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
10334 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
10335 [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
10337 run_test 184d "allow stripeless layouts swap"
10340 test_185() { # LU-2441
10341 # LU-3553 - no volatile file support in old servers
10342 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
10343 { skip "Need MDS version at least 2.3.60"; return 0; }
10345 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
10346 touch $DIR/$tdir/spoo
10347 local mtime1=$(stat -c "%Y" $DIR/$tdir)
10348 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
10349 error "cannot create/write a volatile file"
10350 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
10351 error "FID is still valid after close"
10353 multiop_bg_pause $DIR/$tdir vVw4096_c
10360 # assume that the next FID for this client is sequential, since stdout
10361 # is unfortunately eaten by multiop_bg_pause
10362 local n=$((${fidv[1]} + 1))
10363 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
10364 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
10365 error "FID is missing before close"
10366 kill -USR1 $multi_pid
10367 # 1 second delay, so if mtime change we will see it
10369 local mtime2=$(stat -c "%Y" $DIR/$tdir)
10370 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
10372 run_test 185 "Volatile file support"
10375 local dir0=$DIR/$tdir/$testnum
10376 mkdir -p $dir0 || error "creating dir $dir0"
10378 local file=$dir0/file1
10379 dd if=/dev/urandom of=$file count=10 bs=1M conv=fsync
10380 local dv1=$($LFS data_version $file)
10381 dd if=/dev/urandom of=$file seek=10 count=1 bs=1M conv=fsync
10382 local dv2=$($LFS data_version $file)
10383 [[ $dv1 != $dv2 ]] ||
10384 error "data version did not change on write $dv1 == $dv2"
10389 run_test 187a "Test data version change"
10392 local dir0=$DIR/$tdir/$testnum
10393 mkdir -p $dir0 || error "creating dir $dir0"
10395 declare -a DV=$($MULTIOP $dir0 Vw1000xYw1000xY | cut -f3 -d" ")
10396 [[ ${DV[0]} != ${DV[1]} ]] ||
10397 error "data version did not change on write"\
10398 " ${DV[0]} == ${DV[1]}"
10403 run_test 187b "Test data version change on volatile file"
10406 check_file_in_pool()
10411 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
10414 for t in $tlist ; do
10415 [ "$i" -eq "$t" ] && continue 2
10418 echo "pool list: $tlist"
10419 echo "striping: $res"
10420 error_noexit "$file not allocated in $pool"
10427 echo "Creating new pool"
10430 create_pool $FSNAME.$pool ||
10431 { error_noexit "No pool created, result code $?"; return 1; }
10432 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
10433 { error_noexit "$pool not in lfs pool_list"; return 2; }
10436 pool_add_targets() {
10437 echo "Adding targets to pool"
10443 local list=$(seq $first $step $last)
10445 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
10446 do_facet mgs $LCTL pool_add \
10447 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
10448 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
10449 | sort -u | tr '\n' ' ' " "$t" || {
10450 error_noexit "Add to pool failed"
10453 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
10454 local addcount=$(((last - first) / step + 1))
10455 [ $lfscount -eq $addcount ] || {
10456 error_noexit "lfs pool_list bad ost count" \
10457 "$lfscount != $addcount"
10465 echo "Setting pool on directory $tdir"
10467 $SETSTRIPE -c 2 -p $pool $tdir && return 0
10469 error_noexit "Cannot set pool $pool to $tdir"
10476 echo "Checking pool on directory $tdir"
10478 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
10479 [ "$res" = "$pool" ] && return 0
10481 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
10485 pool_dir_rel_path() {
10486 echo "Testing relative path works well"
10491 mkdir -p $root/$tdir/$tdir
10493 pool_set_dir $pool $tdir || return 1
10494 pool_set_dir $pool ./$tdir || return 2
10495 pool_set_dir $pool ../$tdir || return 3
10496 pool_set_dir $pool ../$tdir/$tdir || return 4
10497 rm -rf $tdir; cd - > /dev/null
10500 pool_alloc_files() {
10501 echo "Checking files allocation from directory pool"
10508 for i in $(seq -w 1 $count)
10510 local file=$tdir/file-$i
10512 check_file_in_pool $file $pool "$tlist" || \
10513 failed=$((failed + 1))
10515 [ "$failed" = 0 ] && return 0
10517 error_noexit "$failed files not allocated in $pool"
10521 pool_create_files() {
10522 echo "Creating files in pool"
10530 for i in $(seq -w 1 $count)
10532 local file=$tdir/spoo-$i
10533 $SETSTRIPE -p $pool $file
10534 check_file_in_pool $file $pool "$tlist" || \
10535 failed=$((failed + 1))
10537 [ "$failed" = 0 ] && return 0
10539 error_noexit "$failed files not allocated in $pool"
10544 echo "Checking 'lfs df' output"
10547 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10549 local res=$($LFS df --pool $FSNAME.$pool |
10551 grep "$FSNAME-OST" |
10553 [ "$res" = "$t" ] && return 0
10555 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10559 pool_file_rel_path() {
10560 echo "Creating files in a pool with relative pathname"
10565 { error_noexit "unable to create $tdir"; return 1 ; }
10566 local file="/..$tdir/$tfile-1"
10567 $SETSTRIPE -p $pool $file ||
10568 { error_noexit "unable to create $file" ; return 2 ; }
10571 $SETSTRIPE -p $pool $tfile-2 || {
10572 error_noexit "unable to create $tfile-2 in $tdir"
10577 pool_remove_first_target() {
10578 echo "Removing first target from a pool"
10581 local pname="lov.$FSNAME-*.pools.$pool"
10582 local t=$($LCTL get_param -n $pname | head -1)
10583 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10584 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10585 error_noexit "$t not removed from $FSNAME.$pool"
10590 pool_remove_all_targets() {
10591 echo "Removing all targets from pool"
10594 local pname="lov.$FSNAME-*.pools.$pool"
10595 for t in $($LCTL get_param -n $pname | sort -u)
10597 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10599 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10600 error_noexit "Pool $FSNAME.$pool cannot be drained"
10603 # striping on an empty/nonexistant pool should fall back
10604 # to "pool of everything"
10606 error_noexit "failed to use fallback striping for empty pool"
10609 # setstripe on an empty pool should fail
10610 $SETSTRIPE -p $pool $file 2>/dev/null && {
10611 error_noexit "expected failure when creating file" \
10619 echo "Destroying pool"
10623 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10626 # striping on an empty/nonexistant pool should fall back
10627 # to "pool of everything"
10629 error_noexit "failed to use fallback striping for missing pool"
10632 # setstripe on an empty pool should fail
10633 $SETSTRIPE -p $pool $file 2>/dev/null && {
10634 error_noexit "expected failure when creating file" \
10635 "with missing pool"
10639 # get param should return err once pool is gone
10640 if wait_update $HOSTNAME "lctl get_param -n \
10641 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10643 remove_pool_from_list $FSNAME.$pool
10646 error_noexit "Pool $FSNAME.$pool is not destroyed"
10651 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10652 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10654 local POOL=${POOL:-cea1}
10655 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10656 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10659 local last_ost=$(($OSTCOUNT - 1))
10661 local ost_list=$(seq $first_ost $ost_step $last_ost)
10662 local ost_range="$first_ost $last_ost $ost_step"
10663 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10664 local file_dir=$POOL_ROOT/file_tst
10668 # former test_200a test_200b
10669 pool_add $POOL || { rc=$? ; break; }
10670 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10671 # former test_200c test_200d
10672 mkdir -p $test_path
10673 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10674 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10675 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10676 || { rc=$? ; break; }
10677 # former test_200e test_200f
10678 local files=$((OSTCOUNT*3))
10679 pool_alloc_files $POOL $test_path $files "$ost_list" \
10680 || { rc=$? ; break; }
10681 pool_create_files $POOL $file_dir $files "$ost_list" \
10682 || { rc=$? ; break; }
10683 # former test_200g test_200h
10684 pool_lfs_df $POOL || { rc=$? ; break; }
10685 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10687 # former test_201a test_201b test_201c
10688 pool_remove_first_target $POOL || { rc=$? ; break; }
10690 local f=$test_path/$tfile
10691 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10692 pool_remove $POOL $f || { rc=$? ; break; }
10699 run_test 200 "OST pools"
10701 # usage: default_attr <count | size | offset>
10703 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10706 # usage: check_default_stripe_attr
10707 check_default_stripe_attr() {
10708 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10710 --stripe-count|--count)
10711 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10712 --stripe-size|--size)
10713 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10714 --stripe-index|--index)
10717 error "unknown getstripe attr '$1'"
10720 [ $ACTUAL != $EXPECTED ] &&
10721 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10725 test_mkdir -p $DIR/$tdir
10726 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10728 check_default_stripe_attr --stripe-count
10729 check_default_stripe_attr --stripe-size
10730 check_default_stripe_attr --stripe-index
10734 run_test 204a "Print default stripe attributes ================="
10737 test_mkdir -p $DIR/$tdir
10738 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10740 check_default_stripe_attr --stripe-size
10741 check_default_stripe_attr --stripe-index
10745 run_test 204b "Print default stripe size and offset ==========="
10748 test_mkdir -p $DIR/$tdir
10749 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10751 check_default_stripe_attr --stripe-count
10752 check_default_stripe_attr --stripe-index
10756 run_test 204c "Print default stripe count and offset ==========="
10759 test_mkdir -p $DIR/$tdir
10760 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10762 check_default_stripe_attr --stripe-count
10763 check_default_stripe_attr --stripe-size
10767 run_test 204d "Print default stripe count and size ============="
10770 test_mkdir -p $DIR/$tdir
10771 $SETSTRIPE -d $DIR/$tdir
10773 check_default_stripe_attr --stripe-count --raw
10774 check_default_stripe_attr --stripe-size --raw
10775 check_default_stripe_attr --stripe-index --raw
10779 run_test 204e "Print raw stripe attributes ================="
10782 test_mkdir -p $DIR/$tdir
10783 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10785 check_default_stripe_attr --stripe-size --raw
10786 check_default_stripe_attr --stripe-index --raw
10790 run_test 204f "Print raw stripe size and offset ==========="
10793 test_mkdir -p $DIR/$tdir
10794 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10796 check_default_stripe_attr --stripe-count --raw
10797 check_default_stripe_attr --stripe-index --raw
10801 run_test 204g "Print raw stripe count and offset ==========="
10804 test_mkdir -p $DIR/$tdir
10805 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10807 check_default_stripe_attr --stripe-count --raw
10808 check_default_stripe_attr --stripe-size --raw
10812 run_test 204h "Print raw stripe count and size ============="
10814 # Figure out which job scheduler is being used, if any,
10815 # or use a fake one
10816 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10817 JOBENV=SLURM_JOB_ID
10818 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10820 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10822 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10823 JOBENV=LOADL_STEP_ID
10824 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10830 verify_jobstats() {
10834 # clear old jobstats
10835 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10836 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10838 # use a new JobID for this test, or we might see an old one
10839 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10843 log "Using JobID environment variable $JOBENV=$JOBVAL"
10845 if [ $JOBENV = "FAKE_JOBID" ]; then
10846 FAKE_JOBID=$JOBVAL $cmd
10851 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10852 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10853 do_facet $FACET lctl get_param mdt.*.job_stats |
10854 grep $JOBVAL || error "No job stats found on MDT $FACET"
10856 if [ "$target" = "ost" -o "$target" = "both" ]; then
10858 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10859 grep $JOBVAL || error "No job stats found on OST $FACET"
10865 NEW_JOBENV=${1:-$OLD_JOBENV}
10866 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10867 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10870 test_205() { # Job stats
10871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10872 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10873 skip "Server doesn't support jobstats" && return 0
10876 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10877 if [ $OLD_JOBENV != $JOBENV ]; then
10878 jobstats_set $JOBENV
10879 trap jobstats_set EXIT
10883 cmd="mkdir $DIR/$tfile"
10884 verify_jobstats "$cmd" "mdt"
10886 cmd="rm -fr $DIR/$tfile"
10887 verify_jobstats "$cmd" "mdt"
10889 cmd="mknod $DIR/$tfile c 1 3"
10890 verify_jobstats "$cmd" "mdt"
10892 cmd="rm -f $DIR/$tfile"
10893 verify_jobstats "$cmd" "mdt"
10895 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10896 verify_jobstats "$cmd" "mdt"
10898 cmd="touch $DIR/$tfile"
10899 verify_jobstats "$cmd" "both"
10901 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10902 verify_jobstats "$cmd" "ost"
10904 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10905 verify_jobstats "$cmd" "ost"
10907 cmd="$TRUNCATE $DIR/$tfile 0"
10908 verify_jobstats "$cmd" "both"
10910 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10911 verify_jobstats "$cmd" "mdt"
10914 rm -f $DIR/jobstats_test_rename
10916 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10918 run_test 205 "Verify job stats"
10920 # LU-1480, LU-1773 and LU-1657
10922 mkdir -p $DIR/$tdir
10923 lfs setstripe -c -1 $DIR/$tdir
10924 #define OBD_FAIL_LOV_INIT 0x1403
10925 $LCTL set_param fail_loc=0xa0001403
10926 $LCTL set_param fail_val=1
10927 touch $DIR/$tdir/$tfile || true
10929 run_test 206 "fail lov_init_raid0() doesn't lbug"
10932 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10933 local fsz=`stat -c %s $DIR/$tfile`
10934 cancel_lru_locks mdc
10936 # do not return layout in getattr intent
10937 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10938 $LCTL set_param fail_loc=0x170
10939 local sz=`stat -c %s $DIR/$tfile`
10941 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
10945 run_test 207a "can refresh layout at glimpse"
10948 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10949 local cksum=`md5sum $DIR/$tfile`
10950 local fsz=`stat -c %s $DIR/$tfile`
10951 cancel_lru_locks mdc
10952 cancel_lru_locks osc
10954 # do not return layout in getattr intent
10955 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
10956 $LCTL set_param fail_loc=0x171
10958 # it will refresh layout after the file is opened but before read issues
10959 echo checksum is "$cksum"
10960 echo "$cksum" |md5sum -c --quiet || error "file differs"
10964 run_test 207b "can refresh layout at open"
10967 # FIXME: in this test suite, only RD lease is used. This is okay
10968 # for now as only exclusive open is supported. After generic lease
10969 # is done, this test suite should be revised. - Jinshan
10971 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
10972 { skip "Need MDS version at least 2.4.52"; return 0; }
10974 echo "==== test 1: verify get lease work"
10975 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
10977 echo "==== test 2: verify lease can be broken by upcoming open"
10978 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
10982 $MULTIOP $DIR/$tfile oO_RDONLY:c
10983 kill -USR1 $PID && wait $PID || error "break lease error"
10985 echo "==== test 3: verify lease can't be granted if an open already exists"
10986 $MULTIOP $DIR/$tfile oO_RDONLY:_c &
10990 $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
10991 kill -USR1 $PID && wait $PID || error "open file error"
10993 echo "==== test 4: lease can sustain over recovery"
10994 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
11000 kill -USR1 $PID && wait $PID || error "lease broken over recovery"
11002 echo "==== test 5: lease broken can't be regained by replay"
11003 $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
11007 # open file to break lease and then recovery
11008 $MULTIOP $DIR/$tfile oO_RDWR:c || error "open file error"
11011 kill -USR1 $PID && wait $PID || error "lease not broken over recovery"
11015 run_test 208 "Exclusive open"
11018 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
11019 skip_env "must have disp_stripe" && return
11022 sync; sleep 5; sync;
11024 echo 3 > /proc/sys/vm/drop_caches
11025 req_before=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11027 # open/close 500 times
11028 for i in $(seq 500); do
11032 echo 3 > /proc/sys/vm/drop_caches
11033 req_after=$(awk '/ptlrpc_cache / { print $2 }' /proc/slabinfo)
11035 echo "before: $req_before, after: $req_after"
11036 [ $((req_after - req_before)) -ge 300 ] &&
11037 error "open/close requests are not freed"
11040 run_test 209 "read-only open/close requests should be freed promptly"
11044 size=$((size % 8192 + 1))
11045 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
11046 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
11047 rm -f $DIR/f212 $DIR/f212.xyz
11049 run_test 212 "Sendfile test ============================================"
11052 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
11053 cancel_lru_locks osc
11054 lctl set_param fail_loc=0x8000040f
11055 # generate a read lock
11056 cat $DIR/$tfile > /dev/null
11057 # write to the file, it will try to cancel the above read lock.
11058 cat /etc/hosts >> $DIR/$tfile
11060 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
11062 test_214() { # for bug 20133
11063 mkdir -p $DIR/$tdir/d214c || error "mkdir $DIR/$tdir/d214c failed"
11064 for (( i=0; i < 340; i++ )) ; do
11065 touch $DIR/$tdir/d214c/a$i
11068 ls -l $DIR/$tdir || error "ls -l $DIR/d214p failed"
11069 mv $DIR/$tdir/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
11070 ls $DIR/d214c || error "ls $DIR/d214c failed"
11071 rm -rf $DIR/$tdir || error "rm -rf $DIR/d214* failed"
11072 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
11074 run_test 214 "hash-indexed directory test - bug 20133"
11076 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
11077 create_lnet_proc_files() {
11078 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
11079 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
11081 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
11082 rm -f "$TMP/lnet_$1.sys_tmp"
11085 # counterpart of create_lnet_proc_files
11086 remove_lnet_proc_files() {
11087 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
11090 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11091 # 3rd arg as regexp for body
11092 check_lnet_proc_stats() {
11093 local l=$(cat "$TMP/lnet_$1" |wc -l)
11094 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
11096 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
11099 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
11100 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
11101 # optional and can be regexp for 2nd line (lnet.routes case)
11102 check_lnet_proc_entry() {
11103 local blp=2 # blp stands for 'position of 1st line of body'
11104 [ "$5" = "" ] || blp=3 # lnet.routes case
11106 local l=$(cat "$TMP/lnet_$1" |wc -l)
11107 # subtracting one from $blp because the body can be empty
11108 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
11110 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
11111 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
11113 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
11114 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
11116 # bail out if any unexpected line happened
11117 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
11118 [ "$?" != 0 ] || error "$2 misformatted"
11121 test_215() { # for bugs 18102, 21079, 21517
11122 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11123 local N='(0|[1-9][0-9]*)' # non-negative numeric
11124 local P='[1-9][0-9]*' # positive numeric
11125 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
11126 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
11127 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
11128 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
11130 local L1 # regexp for 1st line
11131 local L2 # regexp for 2nd line (optional)
11132 local BR # regexp for the rest (body)
11134 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
11135 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
11136 create_lnet_proc_files "stats"
11137 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
11138 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
11139 remove_lnet_proc_files "stats"
11141 # /proc/sys/lnet/routes should look like this:
11142 # Routing disabled/enabled
11143 # net hops priority state router
11144 # where net is a string like tcp0, hops > 0, priority >= 0,
11145 # state is up/down,
11146 # router is a string like 192.168.1.1@tcp2
11147 L1="^Routing (disabled|enabled)$"
11148 L2="^net +hops +priority +state +router$"
11149 BR="^$NET +$N +(0|1) +(up|down) +$NID$"
11150 create_lnet_proc_files "routes"
11151 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
11152 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
11153 remove_lnet_proc_files "routes"
11155 # /proc/sys/lnet/routers should look like this:
11156 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
11157 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
11158 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
11159 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
11160 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
11161 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
11162 create_lnet_proc_files "routers"
11163 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
11164 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
11165 remove_lnet_proc_files "routers"
11167 # /proc/sys/lnet/peers should look like this:
11168 # nid refs state last max rtr min tx min queue
11169 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
11170 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
11171 # numeric (0 or >0 or <0), queue >= 0.
11172 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
11173 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
11174 create_lnet_proc_files "peers"
11175 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
11176 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
11177 remove_lnet_proc_files "peers"
11179 # /proc/sys/lnet/buffers should look like this:
11180 # pages count credits min
11181 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
11182 L1="^pages +count +credits +min$"
11183 BR="^ +$N +$N +$I +$I$"
11184 create_lnet_proc_files "buffers"
11185 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
11186 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
11187 remove_lnet_proc_files "buffers"
11189 # /proc/sys/lnet/nis should look like this:
11190 # nid status alive refs peer rtr max tx min
11191 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
11192 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
11193 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
11194 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
11195 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
11196 create_lnet_proc_files "nis"
11197 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
11198 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
11199 remove_lnet_proc_files "nis"
11201 # can we successfully write to /proc/sys/lnet/stats?
11202 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
11203 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
11205 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
11207 test_216() { # bug 20317
11208 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11209 remote_ost_nodsh && skip "remote OST with nodsh" && return
11212 local facets=$(get_facets OST)
11213 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
11215 save_lustre_params client "osc.*.contention_seconds" > $p
11216 save_lustre_params $facets \
11217 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
11218 save_lustre_params $facets \
11219 "ldlm.namespaces.filter-*.contended_locks" >> $p
11220 save_lustre_params $facets \
11221 "ldlm.namespaces.filter-*.contention_seconds" >> $p
11224 # agressive lockless i/o settings
11225 for node in $(osts_nodes); do
11226 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'
11228 lctl set_param -n osc.*.contention_seconds 60
11230 $DIRECTIO write $DIR/$tfile 0 10 4096
11231 $CHECKSTAT -s 40960 $DIR/$tfile
11233 # disable lockless i/o
11234 for node in $(osts_nodes); do
11235 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'
11237 lctl set_param -n osc.*.contention_seconds 0
11240 dd if=/dev/zero of=$DIR/$tfile count=0
11241 $CHECKSTAT -s 0 $DIR/$tfile
11243 restore_lustre_params <$p
11247 run_test 216 "check lockless direct write works and updates file size and kms correctly"
11249 test_217() { # bug 22430
11250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11254 for node in $(nodes_list); do
11255 nid=$(host_nids_address $node $NETTYPE)
11256 if [[ $nid = *-* ]] ; then
11257 echo "lctl ping $nid@$NETTYPE"
11258 lctl ping $nid@$NETTYPE
11260 echo "skipping $node (no hyphen detected)"
11264 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
11267 # do directio so as not to populate the page cache
11268 log "creating a 10 Mb file"
11269 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
11270 log "starting reads"
11271 dd if=$DIR/$tfile of=/dev/null bs=4096 &
11272 log "truncating the file"
11273 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
11275 kill %+ || true # reads might have finished
11276 echo "wait until dd is finished"
11278 log "removing the temporary file"
11279 rm -rf $DIR/$tfile || error "tmp file removal failed"
11281 run_test 218 "parallel read and truncate should not deadlock ======================="
11284 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11285 # write one partial page
11286 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
11287 # set no grant so vvp_io_commit_write will do sync write
11288 $LCTL set_param fail_loc=0x411
11289 # write a full page at the end of file
11290 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
11292 $LCTL set_param fail_loc=0
11293 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
11294 $LCTL set_param fail_loc=0x411
11295 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
11298 dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
11299 $CHECKSTAT -s 1024 $DIR/$tfile-2 || error "checkstat wrong size"
11301 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
11303 test_220() { #LU-325
11304 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11305 remote_ost_nodsh && skip "remote OST with nodsh" && return
11308 test_mkdir -p $DIR/$tdir
11309 local OST=$(lfs osts | grep ${OSTIDX}": " | \
11310 awk '{print $2}' | sed -e 's/_UUID$//')
11313 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
11314 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
11315 osc.$mdtosc_proc1.prealloc_last_id)
11316 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
11317 osc.$mdtosc_proc1.prealloc_next_id)
11321 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
11322 #define OBD_FAIL_OST_ENOINO 0x229
11323 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
11324 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
11325 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
11327 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
11329 MDSOBJS=$((last_id - next_id))
11330 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
11332 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
11333 echo "OST still has $count kbytes free"
11335 echo "create $MDSOBJS files @next_id..."
11336 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
11338 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11339 osc.$mdtosc_proc1.prealloc_last_id)
11340 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
11341 osc.$mdtosc_proc1.prealloc_next_id)
11343 echo "after creation, last_id=$last_id2, next_id=$next_id2"
11348 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
11349 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
11351 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
11352 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
11353 echo "unlink $MDSOBJS files @$next_id..."
11354 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
11356 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
11359 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11360 dd if=`which date` of=$MOUNT/date oflag=sync
11361 chmod +x $MOUNT/date
11363 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
11364 $LCTL set_param fail_loc=0x80001401
11366 $MOUNT/date > /dev/null
11369 run_test 221 "make sure fault and truncate race to not cause OOM"
11372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11374 test_mkdir -p $DIR/$tdir
11375 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11376 createmany -o $DIR/$tdir/$tfile 10
11377 cancel_lru_locks mdc
11378 cancel_lru_locks osc
11379 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11380 $LCTL set_param fail_loc=0x31a
11381 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
11382 $LCTL set_param fail_loc=0
11385 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
11388 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11390 test_mkdir -p $DIR/$tdir
11391 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11392 createmany -o $DIR/$tdir/$tfile 10
11393 cancel_lru_locks mdc
11394 cancel_lru_locks osc
11395 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
11396 $LCTL set_param fail_loc=0x31a
11397 rm -r $DIR/$tdir || "AGL for rmdir failed"
11398 $LCTL set_param fail_loc=0
11400 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
11403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11405 test_mkdir -p $DIR/$tdir
11406 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
11407 createmany -o $DIR/$tdir/$tfile 10
11408 cancel_lru_locks mdc
11409 cancel_lru_locks osc
11410 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
11411 $LCTL set_param fail_loc=0x31b
11412 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
11413 $LCTL set_param fail_loc=0
11416 run_test 223 "osc reenqueue if without AGL lock granted ======================="
11418 test_224a() { # LU-1039, MRP-303
11419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11420 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
11421 $LCTL set_param fail_loc=0x508
11422 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
11423 $LCTL set_param fail_loc=0
11426 run_test 224a "Don't panic on bulk IO failure"
11428 test_224b() { # LU-1039, MRP-303
11429 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11430 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
11431 cancel_lru_locks osc
11432 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
11433 $LCTL set_param fail_loc=0x515
11434 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
11435 $LCTL set_param fail_loc=0
11438 run_test 224b "Don't panic on bulk IO failure"
11440 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
11442 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11443 if [ -z ${MDSSURVEY} ]; then
11444 skip_env "mds-survey not found" && return
11447 [ $MDSCOUNT -ge 2 ] &&
11448 skip "skipping now for more than one MDT" && return
11450 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11451 { skip "Need MDS version at least 2.2.51"; return; }
11453 local mds=$(facet_host $SINGLEMDS)
11454 local target=$(do_nodes $mds 'lctl dl' | \
11455 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11457 local cmd1="file_count=1000 thrhi=4"
11458 local cmd2="dir_count=2 layer=mdd stripe_count=0"
11459 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11460 local cmd="$cmd1 $cmd2 $cmd3"
11462 rm -f ${TMP}/mds_survey*
11464 eval $cmd || error "mds-survey with zero-stripe failed"
11465 cat ${TMP}/mds_survey*
11466 rm -f ${TMP}/mds_survey*
11468 run_test 225a "Metadata survey sanity with zero-stripe"
11471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11473 if [ -z ${MDSSURVEY} ]; then
11474 skip_env "mds-survey not found" && return
11476 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
11477 { skip "Need MDS version at least 2.2.51"; return; }
11479 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
11480 skip_env "Need to mount OST to test" && return
11483 [ $MDSCOUNT -ge 2 ] &&
11484 skip "skipping now for more than one MDT" && return
11485 local mds=$(facet_host $SINGLEMDS)
11486 local target=$(do_nodes $mds 'lctl dl' | \
11487 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
11489 local cmd1="file_count=1000 thrhi=4"
11490 local cmd2="dir_count=2 layer=mdd stripe_count=1"
11491 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
11492 local cmd="$cmd1 $cmd2 $cmd3"
11494 rm -f ${TMP}/mds_survey*
11496 eval $cmd || error "mds-survey with stripe_count failed"
11497 cat ${TMP}/mds_survey*
11498 rm -f ${TMP}/mds_survey*
11500 run_test 225b "Metadata survey sanity with stripe_count = 1"
11502 mcreate_path2fid () {
11508 local path=$DIR/$tdir/$name
11513 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
11514 error "cannot create $desc"
11516 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
11518 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
11520 fid_path=$($LFS fid2path $MOUNT $fid)
11522 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
11524 [ "$path" == "$fid_path" ] ||
11525 error "fid2path returned $fid_path, expected $path"
11527 echo "pass with $path and $fid"
11532 mkdir -p $DIR/$tdir
11534 mcreate_path2fid 0010666 0 0 fifo "FIFO"
11535 mcreate_path2fid 0020666 1 3 null "character special file (null)"
11536 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
11537 mcreate_path2fid 0040666 0 0 dir "directory"
11538 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
11539 mcreate_path2fid 0100666 0 0 file "regular file"
11540 mcreate_path2fid 0120666 0 0 link "symbolic link"
11541 mcreate_path2fid 0140666 0 0 sock "socket"
11543 run_test 226a "call path2fid and fid2path on files of all type"
11546 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11550 mkdir -p $DIR/$tdir
11551 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
11552 error "create remote directory failed"
11553 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
11554 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
11555 "character special file (null)"
11556 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
11557 "character special file (no device)"
11558 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
11559 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
11560 "block special file (loop)"
11561 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
11562 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
11563 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
11565 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
11567 # LU-1299 Executing or running ldd on a truncated executable does not
11568 # cause an out-of-memory condition.
11570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11571 dd if=`which date` of=$MOUNT/date bs=1k count=1
11572 chmod +x $MOUNT/date
11574 $MOUNT/date > /dev/null
11575 ldd $MOUNT/date > /dev/null
11578 run_test 227 "running truncated executable does not cause OOM"
11580 # LU-1512 try to reuse idle OI blocks
11582 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11583 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11584 skip "non-ldiskfs backend" && return
11586 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11587 local myDIR=$DIR/$tdir
11590 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11591 $LCTL set_param fail_loc=0x80001002
11592 createmany -o $myDIR/t- 10000
11593 $LCTL set_param fail_loc=0
11594 # The guard is current the largest FID holder
11596 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11598 local IDX=$(($SEQ % 64))
11600 do_facet $SINGLEMDS sync
11601 # Make sure journal flushed.
11603 local blk1=$(do_facet $SINGLEMDS \
11604 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11605 grep Blockcount | awk '{print $4}')
11607 # Remove old files, some OI blocks will become idle.
11608 unlinkmany $myDIR/t- 10000
11609 # Create new files, idle OI blocks should be reused.
11610 createmany -o $myDIR/t- 2000
11611 do_facet $SINGLEMDS sync
11612 # Make sure journal flushed.
11614 local blk2=$(do_facet $SINGLEMDS \
11615 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11616 grep Blockcount | awk '{print $4}')
11618 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11620 run_test 228a "try to reuse idle OI blocks"
11623 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11624 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11625 skip "non-ldiskfs backend" && return
11627 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11628 local myDIR=$DIR/$tdir
11631 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11632 $LCTL set_param fail_loc=0x80001002
11633 createmany -o $myDIR/t- 10000
11634 $LCTL set_param fail_loc=0
11635 # The guard is current the largest FID holder
11637 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11639 local IDX=$(($SEQ % 64))
11641 do_facet $SINGLEMDS sync
11642 # Make sure journal flushed.
11644 local blk1=$(do_facet $SINGLEMDS \
11645 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11646 grep Blockcount | awk '{print $4}')
11648 # Remove old files, some OI blocks will become idle.
11649 unlinkmany $myDIR/t- 10000
11652 stop $SINGLEMDS || error "Fail to stop MDT."
11654 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11656 df $MOUNT || error "Fail to df."
11657 # Create new files, idle OI blocks should be reused.
11658 createmany -o $myDIR/t- 2000
11659 do_facet $SINGLEMDS sync
11660 # Make sure journal flushed.
11662 local blk2=$(do_facet $SINGLEMDS \
11663 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11664 grep Blockcount | awk '{print $4}')
11666 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11668 run_test 228b "idle OI blocks can be reused after MDT restart"
11672 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11673 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11674 skip "non-ldiskfs backend" && return
11676 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11677 local myDIR=$DIR/$tdir
11680 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11681 $LCTL set_param fail_loc=0x80001002
11682 # 20000 files can guarantee there are index nodes in the OI file
11683 createmany -o $myDIR/t- 20000
11684 $LCTL set_param fail_loc=0
11685 # The guard is current the largest FID holder
11687 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11689 local IDX=$(($SEQ % 64))
11691 do_facet $SINGLEMDS sync
11692 # Make sure journal flushed.
11694 local blk1=$(do_facet $SINGLEMDS \
11695 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11696 grep Blockcount | awk '{print $4}')
11698 # Remove old files, some OI blocks will become idle.
11699 unlinkmany $myDIR/t- 20000
11701 # The OI file should become empty now
11703 # Create new files, idle OI blocks should be reused.
11704 createmany -o $myDIR/t- 2000
11705 do_facet $SINGLEMDS sync
11706 # Make sure journal flushed.
11708 local blk2=$(do_facet $SINGLEMDS \
11709 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11710 grep Blockcount | awk '{print $4}')
11712 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11714 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11716 test_229() { # LU-2482, LU-3448
11717 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
11718 skip "No HSM support on MDS of $(get_lustre_version)," \
11719 "need 2.4.53 at least" && return
11720 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11721 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
11725 # Create a file with a released layout and stripe count 2.
11726 $MULTIOP $DIR/$tfile H2c ||
11727 error "failed to create file with released layout"
11729 $GETSTRIPE -v $DIR/$tfile
11731 local pattern=$($GETSTRIPE -L $DIR/$tfile)
11732 [ X"$pattern" = X"80000001" ] || error "pattern error ($pattern)"
11734 local stripe_count=$($GETSTRIPE -c $DIR/$tfile) || error "getstripe"
11735 [ $stripe_count -eq 2 ] || error "stripe count not 2 ($stripe_count)"
11736 stat $DIR/$tfile || error "failed to stat released file"
11738 chown $RUNAS_ID $DIR/$tfile ||
11739 error "chown $RUNAS_ID $DIR/$tfile failed"
11741 chgrp $RUNAS_ID $DIR/$tfile ||
11742 error "chgrp $RUNAS_ID $DIR/$tfile failed"
11744 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
11745 rm $DIR/$tfile || error "failed to remove released file"
11747 run_test 229 "getstripe/stat/rm/attr changes work on released files"
11750 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11754 mkdir -p $DIR/$tdir/test_230_local
11755 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11756 [ $mdt_idx -ne 0 ] &&
11757 error "create local directory on wrong MDT $mdt_idx"
11759 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11760 error "create remote directory failed"
11761 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11762 [ $mdt_idx -ne $MDTIDX ] &&
11763 error "create remote directory on wrong MDT $mdt_idx"
11765 createmany -o $DIR/$tdir/test_230/t- 10 ||
11766 error "create files on remote directory failed"
11767 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11768 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11769 rm -r $DIR/$tdir || error "unlink remote directory failed"
11771 run_test 230a "Create remote directory and files under the remote directory"
11774 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11775 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11777 local remote_dir=$DIR/$tdir/remote_dir
11780 mkdir -p $DIR/$tdir
11781 $LFS mkdir -i $MDTIDX $remote_dir ||
11782 error "create remote directory failed"
11784 $LFS mkdir -i 0 $remote_dir/new_dir &&
11785 error "nested remote directory create succeed!"
11787 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
11788 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
11789 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
11792 error "create remote directory failed after set enable_remote_dir"
11794 rm -rf $remote_dir || error "first unlink remote directory failed"
11796 $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
11797 error "chown worked"
11799 do_facet mds$MDTIDX lctl set_param \
11800 mdt.*.enable_remote_dir_gid=$RUNAS_GID
11801 $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
11802 do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
11805 error "create remote dir failed after set enable_remote_dir_gid"
11807 rm -r $DIR/$tdir || error "second unlink remote directory failed"
11809 run_test 230b "nested remote directory should be failed"
11813 # For simplicity this test assumes that max_pages_per_rpc
11814 # is the same across all OSCs
11815 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
11816 local bulk_size=$((max_pages * 4096))
11818 mkdir -p $DIR/$tdir
11820 # clear the OSC stats
11821 $LCTL set_param osc.*.stats=0 &>/dev/null
11823 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
11824 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
11825 oflag=direct &>/dev/null || error "dd failed"
11827 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
11828 if [ x$nrpcs != "x1" ]; then
11829 error "found $nrpc ost_write RPCs, not 1 as expected"
11832 # Drop the OSC cache, otherwise we will read from it
11833 cancel_lru_locks osc
11835 # clear the OSC stats
11836 $LCTL set_param osc.*.stats=0 &>/dev/null
11838 # Client reads $bulk_size.
11839 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
11840 iflag=direct &>/dev/null || error "dd failed"
11842 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
11843 if [ x$nrpcs != "x1" ]; then
11844 error "found $nrpc ost_read RPCs, not 1 as expected"
11847 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
11850 mkdir -p $DIR/$tdir
11852 for i in {0..1023}; do
11853 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
11854 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
11855 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
11859 run_test 231b "must not assert on fully utilized OST request buffer"
11862 mkdir -p $DIR/$tdir
11863 #define OBD_FAIL_LDLM_OST_LVB 0x31c
11864 $LCTL set_param fail_loc=0x31c
11866 # ignore dd failure
11867 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
11869 $LCTL set_param fail_loc=0
11870 umount_client $MOUNT || error "umount failed"
11871 mount_client $MOUNT || error "mount failed"
11873 run_test 232 "failed lock should not block umount"
11876 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
11877 { skip "Need MDS version at least 2.3.64"; return; }
11879 local fid=$($LFS path2fid $MOUNT)
11880 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11881 error "cannot access $MOUNT using its FID '$fid'"
11883 run_test 233a "checking that OBF of the FS root succeeds"
11886 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
11887 { skip "Need MDS version at least 2.5.90"; return; }
11889 local fid=$($LFS path2fid $MOUNT/.lustre)
11890 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11891 error "cannot access $MOUNT/.lustre using its FID '$fid'"
11893 fid=$($LFS path2fid $MOUNT/.lustre/fid)
11894 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11895 error "cannot access $MOUNT/.lustre/fid using its FID '$fid'"
11897 run_test 233b "checking that OBF of the FS .lustre succeeds"
11900 local p="$TMP/sanityN-$TESTNAME.parameters"
11901 save_lustre_params client "llite.*.xattr_cache" > $p
11902 lctl set_param llite.*.xattr_cache 1 ||
11903 { skip "xattr cache is not supported"; return 0; }
11905 mkdir -p $DIR/$tdir || error "mkdir failed"
11906 touch $DIR/$tdir/$tfile || error "touch failed"
11907 # OBD_FAIL_LLITE_XATTR_ENOMEM
11908 $LCTL set_param fail_loc=0x1405
11909 if [ ! -f /etc/SuSE-release ]; then
11910 # attr pre-2.4.44-7 had a bug with rc
11911 # LU-3703 - SLES clients have older attr
11912 getfattr -n user.attr $DIR/$tdir/$tfile &&
11913 error "getfattr should have failed with ENOMEM"
11915 $LCTL set_param fail_loc=0x0
11918 restore_lustre_params < $p
11921 run_test 234 "xattr cache should not crash on ENOMEM"
11924 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
11925 skip "Need MDS version at least 2.4.52" && return
11926 flock_deadlock $DIR/$tfile
11931 124) error "process hangs on a deadlock"
11933 *) error "error executing flock_deadlock $DIR/$tfile"
11937 run_test 235 "LU-1715: flock deadlock detection does not work properly"
11941 check_swap_layouts_support && return 0
11942 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
11944 local ref1=/etc/passwd
11945 local ref2=/etc/group
11946 local file1=$DIR/$tdir/f1
11947 local file2=$DIR/$tdir/f2
11949 $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
11950 cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
11951 $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
11952 cp $ref2 $file2 || error "cp $ref2 $file2 failed: rc = $?"
11953 local fd=$(free_fd)
11954 local cmd="exec $fd<>$file2"
11957 $LFS swap_layouts $file1 /proc/self/fd/${fd} ||
11958 error "cannot swap layouts of '$file1' and /proc/self/fd/${fd}"
11961 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
11966 run_test 236 "Layout swap on open unlinked file"
11968 # test to verify file handle related system calls
11969 # (name_to_handle_at/open_by_handle_at)
11970 # The new system calls are supported in glibc >= 2.14.
11973 echo "Test file_handle syscalls" > $DIR/$tfile
11974 check_fhandle_syscalls $DIR/$tfile ||
11975 error "check_fhandle_syscalls failed"
11977 run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
11980 # tests that do cleanup/setup should be run at the end
11984 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11986 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
11987 $LCTL set_param fail_loc=0x903
11988 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
11989 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
11992 FAIL_ON_ERROR=true cleanup
11993 FAIL_ON_ERROR=true setup
11995 run_test 900 "umount should not race with any mgc requeue thread"
11998 check_and_cleanup_lustre
11999 if [ "$I_MOUNTED" != "yes" ]; then
12000 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true