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 0 "touch .../$tfile ; rm .../$tfile ====================="
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 $CHECKSTAT -t dir $DIR/$tdir || error "$tdir is not a directory"
199 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
200 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
202 run_test 4 "mkdir =============================================="
205 test_mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
206 test_mkdir $DIR/$tdir/d2 || error "mkdir $tdir/d2 failed"
207 chmod 0707 $DIR/$tdir/d2 || error "chmod 0707 $tdir/d2 failed"
208 $CHECKSTAT -t dir -p 0707 $DIR/$tdir/d2 || error "$tdir/d2 not mode 707"
209 $CHECKSTAT -t dir $DIR/$tdir/d2 || error "$tdir/d2 is not a directory"
211 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
214 touch $DIR/$tfile || error "touch $DIR/$tfile failed"
215 chmod 0666 $DIR/$tfile || error "chmod 0666 $tfile failed"
216 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
217 error "$tfile does not have perm 0666 or UID $UID"
219 run_test 6a "touch .../f6a; chmod .../f6a ======================"
222 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
223 if [ ! -f $DIR/$tfile ]; then
225 chmod 0666 $DIR/$tfile
227 $RUNAS chmod 0444 $DIR/$tfile && error "chmod $tfile worked on UID $UID"
228 $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/$tfile ||
229 error "$tfile should be 0666 and owned by UID $UID"
231 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
234 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
236 chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
237 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
238 error "$tfile should be owned by UID $RUNAS_ID"
240 run_test 6c "touch .../f6c; chown .../f6c ======================"
243 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
244 if [ ! -f $DIR/$tfile ]; then
246 chown $RUNAS_ID $DIR/$tfile
248 $RUNAS chown $UID $DIR/$tfile && error "chown $UID $file succeeded"
249 $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
250 error "$tfile should be owned by UID $RUNAS_ID"
252 run_test 6d "$RUNAS chown .../f6c (should return error) =="
255 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
257 chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
258 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
259 error "$tfile should be owned by GID $UID"
261 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
264 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
265 if [ ! -f $DIR/$tfile ]; then
267 chgrp $RUNAS_ID $DIR/$tfile
269 $RUNAS chgrp $UID $DIR/$tfile && error "chgrp $UID $file succeeded"
270 $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
271 error "$tfile should be owned by UID $UID and GID $RUNAS_ID"
273 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
276 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
277 test_mkdir $DIR/$tdir || error "mkdir $tfile failed"
278 chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
279 $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
280 chmod g+s $DIR/$tdir/d || error "chmod g+s $tdir/d failed"
281 test_mkdir $DIR/$tdir/d/subdir || error "mkdir $tdir/d/subdir failed"
282 $CHECKSTAT -g \#$RUNAS_GID $DIR/$tdir/d/subdir ||
283 error "$tdir/d/subdir should be GID $RUNAS_GID"
285 run_test 6g "Is new dir in sgid dir inheriting group?"
287 test_6h() { # bug 7331
288 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
289 touch $DIR/$tfile || error "touch failed"
290 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
291 $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
292 error "chown $RUNAS_ID:0 $tfile worked as GID $RUNAS_GID"
293 $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_GID $DIR/$tfile ||
294 error "$tdir/$tfile should be UID $RUNAS_UID GID $RUNAS_GID"
296 run_test 6h "$RUNAS chown RUNAS_ID.0 .../f6h (should return error)"
299 test_mkdir $DIR/$tdir
300 $MCREATE $DIR/$tdir/$tfile
301 chmod 0666 $DIR/$tdir/$tfile
302 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
303 error "$tdir/$tfile should be mode 0666"
305 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
308 if [ ! -d $DIR/$tdir ]; then
311 $MCREATE $DIR/$tdir/$tfile
312 echo -n foo > $DIR/$tdir/$tfile
313 [ "$(cat $DIR/$tdir/$tfile)" = "foo" ] || error "$tdir/$tfile not 'foo'"
314 $CHECKSTAT -t file -s 3 $DIR/$tdir/$tfile || error "$tfile size not 3"
316 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
319 test_mkdir $DIR/$tdir
320 touch $DIR/$tdir/$tfile
321 chmod 0666 $DIR/$tdir/$tfile
322 $CHECKSTAT -t file -p 0666 $DIR/$tdir/$tfile ||
323 error "$tfile mode not 0666"
325 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
328 test_mkdir $DIR/$tdir
329 test_mkdir $DIR/$tdir/d2
330 test_mkdir $DIR/$tdir/d2/d3
331 $CHECKSTAT -t dir $DIR/$tdir/d2/d3 || error "$tdir/d2/d3 not a dir"
333 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
336 test_mkdir $DIR/$tdir
337 test_mkdir $DIR/$tdir/d2
338 touch $DIR/$tdir/d2/$tfile
339 $CHECKSTAT -t file $DIR/$tdir/d2/$tfile ||
340 error "$tdir/d2/$tfile not a file"
342 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
345 test_mkdir $DIR/$tdir
346 test_mkdir $DIR/$tdir/d2
347 chmod 0666 $DIR/$tdir/d2
348 chmod 0705 $DIR/$tdir/d2
349 $CHECKSTAT -t dir -p 0705 $DIR/$tdir/d2 ||
350 error "$tdir/d2 mode not 0705"
352 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
355 test_mkdir $DIR/$tdir
356 touch $DIR/$tdir/$tfile
357 chmod 0666 $DIR/$tdir/$tfile
358 chmod 0654 $DIR/$tdir/$tfile
359 $CHECKSTAT -t file -p 0654 $DIR/$tdir/$tfile ||
360 error "$tdir/d2 mode not 0654"
362 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
365 test_mkdir $DIR/$tdir
366 dd if=/dev/zero of=$DIR/$tdir/$tfile count=10
368 $CHECKSTAT -t file -s 0 $DIR/$tdir/$tfile ||
369 error "$tdir/$tfile size not 0 after truncate"
371 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
374 test_mkdir $DIR/$tdir
375 touch $DIR/$tdir/$tfile
377 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
379 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
382 test_mkdir $DIR/$tdir
383 touch $DIR/$tdir/$tfile
384 mv $DIR/$tdir/$tfile $DIR/$tdir/${tfile}_2
385 $CHECKSTAT -t file $DIR/$tdir/${tfile}_2 ||
386 error "$tdir/${tfile_2} not a file after rename"
388 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
391 test_mkdir $DIR/$tdir
392 touch $DIR/$tdir/$tfile
393 rm -rf $DIR/$tdir/$tfile
394 $CHECKSTAT -a $DIR/$tdir/$tfile || error "$tdir/$tfile not removed"
396 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
399 test_mkdir -p $DIR/$tdir
400 touch $DIR/$tdir/$tfile
401 ln -s $DIR/$tdir/$tfile $DIR/$tdir/l-exist
403 $CHECKSTAT -l $DIR/$tdir/$tfile $DIR/$tdir/l-exist ||
404 error "$tdir/l-exist not a symlink"
405 $CHECKSTAT -f -t f $DIR/$tdir/l-exist ||
406 error "$tdir/l-exist not referencing a file"
407 rm -f $DIR/$tdir/l-exist
408 $CHECKSTAT -a $DIR/$tdir/l-exist || error "$tdir/l-exist not removed"
410 run_test 17a "symlinks: create, remove (real) =================="
413 test_mkdir -p $DIR/$tdir
414 ln -s no-such-file $DIR/$tdir/l-dangle
416 $CHECKSTAT -l no-such-file $DIR/$tdir/l-dangle ||
417 error "$tdir/l-dangle not referencing no-such-file"
418 $CHECKSTAT -fa $DIR/$tdir/l-dangle ||
419 error "$tdir/l-dangle not referencing non-existent file"
420 rm -f $DIR/$tdir/l-dangle
421 $CHECKSTAT -a $DIR/$tdir/l-dangle || error "$tdir/l-dangle not removed"
423 run_test 17b "symlinks: create, remove (dangling) =============="
425 test_17c() { # bug 3440 - don't save failed open RPC for replay
426 test_mkdir -p $DIR/$tdir
427 ln -s foo $DIR/$tdir/$tfile
428 cat $DIR/$tdir/$tfile && error "opened non-existent symlink" || true
430 run_test 17c "symlinks: open dangling (should return error) ===="
433 test_mkdir -p $DIR/$tdir
434 ln -s foo $DIR/$tdir/$tfile
435 touch $DIR/$tdir/$tfile || error "creating to new symlink"
437 run_test 17d "symlinks: create dangling ========================"
440 test_mkdir -p $DIR/$tdir
441 local foo=$DIR/$tdir/$tfile
442 ln -s $foo $foo || error "create symlink failed"
443 ls -l $foo || error "ls -l failed"
444 ls $foo && error "ls not failed" || true
446 run_test 17e "symlinks: create recursive symlink (should return error) ===="
449 test_mkdir -p $DIR/d17f
450 ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
451 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
452 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
453 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
454 ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
455 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
458 run_test 17f "symlinks: long and very long symlink name ========================"
460 # str_repeat(S, N) generate a string that is string S repeated N times
465 while [ $((n -= 1)) -ge 0 ]; do
471 # Long symlinks and LU-2241
473 test_mkdir -p $DIR/$tdir
474 local TESTS="59 60 61 4094 4095"
476 # Fix for inode size boundary in 2.1.4
477 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.4) ] &&
480 # Patch not applied to 2.2 or 2.3 branches
481 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
482 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.3.55) ] &&
486 local SYMNAME=$(str_repeat 'x' $i)
487 ln -s $SYMNAME $DIR/$tdir/f$i || error "failed $i-char symlink"
488 readlink $DIR/$tdir/f$i || error "failed $i-char readlink"
491 run_test 17g "symlinks: really long symlink name and inode boundaries"
493 test_17h() { #bug 17378
494 remote_mds_nodsh && skip "remote MDS with nodsh" && return
495 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
497 test_mkdir -p $DIR/$tdir
498 if [ $MDSCOUNT -gt 1 ]; then
499 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
503 $SETSTRIPE -c -1 $DIR/$tdir
504 #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
505 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
506 touch $DIR/$tdir/$tfile || true
508 run_test 17h "create objects: lov_free_memmd() doesn't lbug"
510 test_17i() { #bug 20018
511 remote_mds_nodsh && skip "remote MDS with nodsh" && return
512 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
513 test_mkdir -p $DIR/$tdir
514 local foo=$DIR/$tdir/$tfile
516 if [ $MDSCOUNT -gt 1 ]; then
517 mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
521 ln -s $foo $foo || error "create symlink failed"
522 #define OBD_FAIL_MDS_READLINK_EPROTO 0x143
523 do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
524 ls -l $foo && error "error not detected"
527 run_test 17i "don't panic on short symlink"
529 test_17k() { #bug 22301
530 rsync --help | grep -q xattr ||
531 skip_env "$(rsync --version| head -1) does not support xattrs"
532 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
533 test_mkdir -p $DIR/$tdir
534 test_mkdir -p $DIR/$tdir.new
535 touch $DIR/$tdir/$tfile
536 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
537 rsync -av -X $DIR/$tdir/ $DIR/$tdir.new ||
538 error "rsync failed with xattrs enabled"
540 run_test 17k "symlinks: rsync with xattrs enabled ========================="
542 test_17l() { # LU-279
544 touch $DIR/$tdir/$tfile
545 ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
546 for path in "$DIR/$tdir" "$DIR/$tdir/$tfile" "$DIR/$tdir/$tfile.lnk"; do
547 # -h to not follow symlinks. -m '' to list all the xattrs.
548 # grep to remove first line: '# file: $path'.
549 for xattr in `getfattr -hm '' $path 2>/dev/null | grep -v '^#'`;
551 lgetxattr_size_check $path $xattr ||
552 error "lgetxattr_size_check $path $xattr failed"
556 run_test 17l "Ensure lgetxattr's returned xattr size is consistent ========"
560 local short_sym="0123456789"
561 local WDIR=$DIR/${tdir}m
568 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
569 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
570 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
572 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
573 skip "only for ldiskfs MDT" && return 0
575 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
579 # create a long symlink file
580 for ((i = 0; i < 4; ++i)); do
581 long_sym=${long_sym}${long_sym}
584 echo "create 512 short and long symlink files under $WDIR"
585 for ((i = 0; i < 256; ++i)); do
586 ln -sf ${long_sym}"a5a5" $WDIR/long-$i
587 ln -sf ${short_sym}"a5a5" $WDIR/short-$i
593 wait_delete_completed
595 echo "recreate the 512 symlink files with a shorter string"
596 for ((i = 0; i < 512; ++i)); do
597 # rewrite the symlink file with a shorter string
598 ln -sf ${long_sym} $WDIR/long-$i
599 ln -sf ${short_sym} $WDIR/short-$i
602 mds_index=$($LFS getstripe -M $WDIR)
603 mds_index=$((mds_index+1))
604 devname=$(mdsdevname $mds_index)
605 cmd="$E2FSCK -fnvd $devname"
607 echo "stop and checking mds${mds_index}: $cmd"
608 # e2fsck should not return error
609 stop mds${mds_index} -f
610 do_facet mds${mds_index} $cmd || rc=$?
612 start mds${mds_index} $devname $MDS_MOUNT_OPTS
613 df $MOUNT > /dev/null 2>&1
614 [ $rc -ne 0 ] && error "e2fsck should not report error upon "\
615 "short/long symlink MDT: rc=$rc"
618 run_test 17m "run e2fsck against MDT which contains short/long symlink"
620 check_fs_consistency_17n() {
626 for mdt_index in $(seq 1 $MDSCOUNT); do
627 devname=$(mdsdevname $mdt_index)
628 cmd="$E2FSCK -fnvd $devname"
630 echo "stop and checking mds${mdt_index}: $cmd"
631 # e2fsck should not return error
633 do_facet mds${mdt_index} $cmd || rc=$?
635 start mds${mdt_index} $devname $MDS_MOUNT_OPTS
636 df $MOUNT > /dev/null 2>&1
637 [ $rc -ne 0 ] && break
645 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
646 [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
647 skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
649 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
650 skip "only for ldiskfs MDT" && return 0
652 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
654 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
657 for ((i=0; i<10; i++)); do
658 $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
659 error "create remote dir error $i"
660 createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
661 error "create files under remote dir failed $i"
664 check_fs_consistency_17n || error "e2fsck report error"
666 for ((i=0;i<10;i++)); do
667 rm -rf $DIR/$tdir/remote_dir_${i} ||
668 error "destroy remote dir error $i"
671 check_fs_consistency_17n || error "e2fsck report error"
673 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
676 local WDIR=$DIR/${tdir}o
682 mdt_index=$($LFS getstripe -M $WDIR)
683 mdt_index=$((mdt_index+1))
684 mdtdevname=$(mdsdevname $mdt_index)
688 start mds${mdt_index} $mdtdevname $MDS_MOUNT_OPTS
690 #define OBD_FAIL_OSD_LMA_INCOMPAT 0x194
691 do_facet mds${mdt_index} lctl set_param fail_loc=0x194
692 ls -l $WDIR/$tfile && rc=1
693 do_facet mds${mdt_index} lctl set_param fail_loc=0
694 [[ $rc -ne 0 ]] && error "stat file should fail"
697 run_test 17o "stat file with incompat LMA feature"
700 touch $DIR/f || error "Failed to touch $DIR/f: $?"
701 ls $DIR || error "Failed to ls $DIR: $?"
703 run_test 18 "touch .../f ; ls ... =============================="
709 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
711 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
714 ls -l $DIR/$tfile && error "ls -l $tfile failed"|| true
716 run_test 19b "ls -l .../f19 (should return error) =============="
719 [ $RUNAS_ID -eq $UID ] &&
720 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
721 $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
723 run_test 19c "$RUNAS touch .../f19 (should return error) =="
726 cat $DIR/f19 && error || true
728 run_test 19d "cat .../f19 (should return error) =============="
740 $CHECKSTAT -a $DIR/$tfile || error "$tfile was not removed"
742 run_test 20 "touch .../f ; ls -l ... ==========================="
745 test_mkdir -p $DIR/$tdir
746 [ -f $DIR/$tdir/dangle ] && rm -f $DIR/$tdir/dangle
747 ln -s dangle $DIR/$tdir/link
748 echo foo >> $DIR/$tdir/link
749 cat $DIR/$tdir/dangle
750 $CHECKSTAT -t link $DIR/$tdir/link || error "$tdir/link not a link"
751 $CHECKSTAT -f -t file $DIR/$tdir/link ||
752 error "$tdir/link not linked to a file"
754 run_test 21 "write to dangling link ============================"
758 test_mkdir -p $DIR/$tdir
759 chown $RUNAS_ID:$RUNAS_GID $WDIR
760 (cd $WDIR || error "cd $WDIR failed";
761 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
763 ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
764 $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
765 $CHECKSTAT -u \#$RUNAS_ID -g \#$RUNAS_GID $WDIR/etc || error "checkstat -u failed"
767 run_test 22 "unpack tar archive as non-root user ==============="
771 test_mkdir -p $DIR/$tdir
772 local file=$DIR/$tdir/$tfile
774 openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
775 openfile -f O_CREAT:O_EXCL $file &&
776 error "$file recreate succeeded" || true
778 run_test 23a "O_CREAT|O_EXCL in subdir =========================="
780 test_23b() { # bug 18988
781 test_mkdir -p $DIR/$tdir
782 local file=$DIR/$tdir/$tfile
785 echo foo > $file || error "write filed"
786 echo bar >> $file || error "append filed"
787 $CHECKSTAT -s 8 $file || error "wrong size"
790 run_test 23b "O_APPEND check =========================="
794 echo '-- same directory rename'
795 test_mkdir $DIR/$tdir
796 touch $DIR/$tdir/$tfile.1
797 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
798 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
800 run_test 24a "rename file to non-existent target"
803 test_mkdir $DIR/$tdir
804 touch $DIR/$tdir/$tfile.{1,2}
805 mv $DIR/$tdir/$tfile.1 $DIR/$tdir/$tfile.2
806 $CHECKSTAT -a $DIR/$tdir/$tfile.1 || error "$tfile.1 exists"
807 $CHECKSTAT -t file $DIR/$tdir/$tfile.2 || error "$tfile.2 not a file"
809 run_test 24b "rename file to existing target"
812 test_mkdir $DIR/$tdir
813 test_mkdir $DIR/$tdir/d$testnum.1
814 mv $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
815 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
816 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
818 run_test 24c "rename directory to non-existent target"
821 test_mkdir $DIR/$tdir
822 test_mkdir $DIR/$tdir/d$testnum.1
823 test_mkdir $DIR/$tdir/d$ttestnum.2
824 mrename $DIR/$tdir/d$testnum.1 $DIR/$tdir/d$testnum.2
825 $CHECKSTAT -a $DIR/$tdir/d$testnum.1 || error "d$testnum.1 exists"
826 $CHECKSTAT -t dir $DIR/$tdir/d$testnum.2 || error "d$testnum.2 not dir"
828 run_test 24d "rename directory to existing target"
831 echo '-- cross directory renames --'
835 mv $DIR/R5a/f $DIR/R5b/g
836 $CHECKSTAT -a $DIR/R5a/f || error
837 $CHECKSTAT -t file $DIR/R5b/g || error
839 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
844 touch $DIR/R6a/f $DIR/R6b/g
845 mv $DIR/R6a/f $DIR/R6b/g
846 $CHECKSTAT -a $DIR/R6a/f || error
847 $CHECKSTAT -t file $DIR/R6b/g || error
849 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
854 test_mkdir $DIR/R7a/d
855 mv $DIR/R7a/d $DIR/R7b/e
856 $CHECKSTAT -a $DIR/R7a/d || error
857 $CHECKSTAT -t dir $DIR/R7b/e || error
859 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
864 test_mkdir $DIR/R8a/d
865 test_mkdir $DIR/R8b/e
866 mrename $DIR/R8a/d $DIR/R8b/e
867 $CHECKSTAT -a $DIR/R8a/d || error
868 $CHECKSTAT -t dir $DIR/R8b/e || error
870 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
873 echo "-- rename error cases"
877 mrename $DIR/R9/f $DIR/R9/a
878 $CHECKSTAT -t file $DIR/R9/f || error
879 $CHECKSTAT -t dir $DIR/R9/a || error
880 $CHECKSTAT -a $DIR/R9/a/f || error
882 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
886 mrename $DIR/R10/f $DIR/R10/g
887 $CHECKSTAT -t dir $DIR/R10 || error
888 $CHECKSTAT -a $DIR/R10/f || error
889 $CHECKSTAT -a $DIR/R10/g || error
891 run_test 24j "source does not exist ============================"
895 test_mkdir $DIR/R11a/d
897 mv $DIR/R11a/f $DIR/R11a/d
898 $CHECKSTAT -a $DIR/R11a/f || error
899 $CHECKSTAT -t file $DIR/R11a/d/f || error
901 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
903 # bug 2429 - rename foo foo foo creates invalid file
906 $MULTIOP $f OcNs || error
908 run_test 24l "Renaming a file to itself ========================"
912 $MULTIOP $f OcLN ${f}2 ${f}2 || error "link ${f}2 ${f}2 failed"
913 # on ext3 this does not remove either the source or target files
914 # though the "expected" operation would be to remove the source
915 $CHECKSTAT -t file ${f} || error "${f} missing"
916 $CHECKSTAT -t file ${f}2 || error "${f}2 missing"
918 run_test 24m "Renaming a file to a hard link to itself ========="
922 # this stats the old file after it was renamed, so it should fail
926 $CHECKSTAT ${f}.rename
929 run_test 24n "Statting the old file after renaming (Posix rename 2)"
932 check_kernel_version 37 || return 0
933 test_mkdir -p $DIR/d24o
934 rename_many -s random -v -n 10 $DIR/d24o
936 run_test 24o "rename of files during htree split ==============="
941 DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
942 mrename $DIR/R12a $DIR/R12b
943 $CHECKSTAT -a $DIR/R12a || error
944 $CHECKSTAT -t dir $DIR/R12b || error
945 DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
946 [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
948 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
950 cleanup_multiop_pause() {
956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
959 local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
960 multiop_bg_pause $DIR/R13b D_c || error "multiop failed to start"
963 trap cleanup_multiop_pause EXIT
964 mrename $DIR/R13a $DIR/R13b
965 $CHECKSTAT -a $DIR/R13a || error "R13a still exists"
966 $CHECKSTAT -t dir $DIR/R13b || error "R13b does not exist"
967 local DIRINO2=$(ls -lid $DIR/R13b | awk '{ print $1 }')
968 [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
969 cleanup_multiop_pause
970 wait $MULTIPID || error "multiop close failed"
972 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
974 test_24r() { #bug 3789
976 test_mkdir $DIR/R14a/b
977 mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
978 $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
979 $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
981 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
985 test_mkdir $DIR/R15a/b
986 test_mkdir $DIR/R15a/b/c
987 mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
988 $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
989 $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
991 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
994 test_mkdir $DIR/R16a/b
995 test_mkdir $DIR/R16a/b/c
996 mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
997 $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
998 $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
1000 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
1002 test_24u() { # bug12192
1004 $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
1005 $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
1007 run_test 24u "create stripe file"
1013 simple_cleanup_common() {
1016 wait_delete_completed
1019 max_pages_per_rpc() {
1020 $LCTL get_param -n mdc.*.max_pages_per_rpc | head -1
1024 local NRFILES=100000
1025 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
1026 [ $FREE_INODES -lt $NRFILES ] && \
1027 skip "not enough free inodes $FREE_INODES required $NRFILES" &&
1030 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1031 trap simple_cleanup_common EXIT
1034 createmany -m $DIR/$tdir/$tfile $NRFILES
1036 cancel_lru_locks mdc
1037 lctl set_param mdc.*.stats clear
1039 ls $DIR/$tdir >/dev/null || error "error in listing large dir"
1041 # LU-5 large readdir
1042 # DIRENT_SIZE = 32 bytes for sizeof(struct lu_dirent) +
1043 # 8 bytes for name(filename is mostly 5 in this test) +
1044 # 8 bytes for luda_type
1045 # take into account of overhead in lu_dirpage header and end mark in
1046 # each page, plus one in RPC_NUM calculation.
1048 RPC_SIZE=$(($(max_pages_per_rpc) * $(page_size)))
1049 RPC_NUM=$(((NRFILES * DIRENT_SIZE + RPC_SIZE - 1) / RPC_SIZE + 1))
1050 mds_readpage=$(lctl get_param mdc.*MDT0000*.stats | \
1051 awk '/^mds_readpage/ {print $2}')
1052 [ $mds_readpage -gt $RPC_NUM ] && \
1053 error "large readdir doesn't take effect"
1055 simple_cleanup_common
1057 run_test 24v "list directory with large files (handle hash collision, bug: 17560)"
1059 test_24w() { # bug21506
1061 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=4096 || return 1
1062 dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
1063 dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
1064 SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
1065 [ "$SZ1" = "$SZ2" ] || \
1066 error "Error reading at the end of the file $tfile"
1068 run_test 24w "Reading a file larger than 4Gb"
1071 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1072 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1074 local remote_dir=$DIR/$tdir/remote_dir
1077 $LFS mkdir -i $MDTIDX $remote_dir ||
1078 error "create remote directory failed"
1080 mkdir -p $DIR/$tdir/src_dir
1081 touch $DIR/$tdir/src_file
1082 mkdir -p $remote_dir/tgt_dir
1083 touch $remote_dir/tgt_file
1085 mrename $DIR/$tdir/src_dir $remote_dir/tgt_dir &&
1086 error "rename dir cross MDT works!"
1088 mrename $DIR/$tdir/src_file $remote_dir/tgt_file &&
1089 error "rename file cross MDT works!"
1091 ln $DIR/$tdir/src_file $remote_dir/tgt_file1 &&
1092 error "ln file cross MDT should not work!"
1094 rm -rf $DIR/$tdir || error "Can not delete directories"
1096 run_test 24x "cross rename/link should be failed"
1099 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1100 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1102 local remote_dir=$DIR/$tdir/remote_dir
1105 $LFS mkdir -i $MDTIDX $remote_dir ||
1106 error "create remote directory failed"
1108 mkdir -p $remote_dir/src_dir
1109 touch $remote_dir/src_file
1110 mkdir -p $remote_dir/tgt_dir
1111 touch $remote_dir/tgt_file
1113 mrename $remote_dir/src_dir $remote_dir/tgt_dir ||
1114 error "rename subdir in the same remote dir failed!"
1116 mrename $remote_dir/src_file $remote_dir/tgt_file ||
1117 error "rename files in the same remote dir failed!"
1119 ln $remote_dir/tgt_file $remote_dir/tgt_file1 ||
1120 error "link files in the same remote dir failed!"
1122 rm -rf $DIR/$tdir || error "Can not delete directories"
1124 run_test 24y "rename/link on the same dir should succeed"
1127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
1128 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1130 local remote_src=$DIR/$tdir/remote_dir
1131 local remote_tgt=$DIR/$tdir/remote_tgt
1134 $LFS mkdir -i $MDTIDX $remote_src ||
1135 error "create remote directory failed"
1137 $LFS mkdir -i $MDTIDX $remote_tgt ||
1138 error "create remote directory failed"
1140 mrename $remote_src $remote_tgt &&
1141 error "rename remote dirs should not work!"
1143 # If target dir does not exists, it should succeed
1145 mrename $remote_src $remote_tgt ||
1146 error "rename remote dirs(tgt dir does not exists) failed!"
1148 rm -rf $DIR/$tdir || error "Can not delete directories"
1150 run_test 24z "rename one remote dir to another remote dir should fail"
1153 echo '== symlink sanity ============================================='
1157 touch $DIR/s25/foo || error
1159 run_test 25a "create file in symlinked directory ==============="
1162 [ ! -d $DIR/d25 ] && test_25a
1163 $CHECKSTAT -t file $DIR/s25/foo || error
1165 run_test 25b "lookup file in symlinked directory ==============="
1169 test_mkdir $DIR/d26/d26-2
1170 ln -s d26/d26-2 $DIR/s26
1171 touch $DIR/s26/foo || error
1173 run_test 26a "multiple component symlink ======================="
1176 test_mkdir -p $DIR/d26b/d26-2
1177 ln -s d26b/d26-2/foo $DIR/s26-2
1178 touch $DIR/s26-2 || error
1180 run_test 26b "multiple component symlink at end of lookup ======"
1183 test_mkdir $DIR/d26.2
1184 touch $DIR/d26.2/foo
1185 ln -s d26.2 $DIR/s26.2-1
1186 ln -s s26.2-1 $DIR/s26.2-2
1187 ln -s s26.2-2 $DIR/s26.2-3
1188 chmod 0666 $DIR/s26.2-3/foo
1190 run_test 26c "chain of symlinks ================================"
1192 # recursive symlinks (bug 439)
1194 ln -s d26-3/foo $DIR/d26-3
1196 run_test 26d "create multiple component recursive symlink ======"
1199 [ ! -h $DIR/d26-3 ] && test_26d
1202 run_test 26e "unlink multiple component recursive symlink ======"
1204 # recursive symlinks (bug 7022)
1206 test_mkdir -p $DIR/$tdir
1207 test_mkdir $DIR/$tdir/$tfile || error "mkdir $DIR/$tdir/$tfile failed"
1208 cd $DIR/$tdir/$tfile || error "cd $DIR/$tdir/$tfile failed"
1209 test_mkdir -p lndir bar1 || error "mkdir lndir/bar1 failed"
1210 test_mkdir $DIR/$tdir/$tfile/$tfile || error "mkdir $tfile failed"
1211 cd $tfile || error "cd $tfile failed"
1212 ln -s .. dotdot || error "ln dotdot failed"
1213 ln -s dotdot/lndir lndir || error "ln lndir failed"
1214 cd $DIR/$tdir || error "cd $DIR/$tdir failed"
1215 output=`ls $tfile/$tfile/lndir/bar1`
1216 [ "$output" = bar1 ] && error "unexpected output"
1217 rm -r $tfile || error "rm $tfile failed"
1218 $CHECKSTAT -a $DIR/$tfile || error "$tfile not gone"
1220 run_test 26f "rm -r of a directory which has recursive symlink ="
1223 echo '== stripe sanity =============================================='
1224 test_mkdir -p $DIR/d27 || error "mkdir failed"
1226 $SETSTRIPE -c 1 $DIR/d27/f0 || error "setstripe failed"
1227 $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
1229 log "== test_27a: write to one stripe file ========================="
1230 cp /etc/hosts $DIR/d27/f0 || error
1232 run_test 27a "one stripe file =================================="
1235 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
1236 test_mkdir -p $DIR/d27
1237 $SETSTRIPE -c 2 $DIR/d27/f01 || error "setstripe failed"
1238 $GETSTRIPE -c $DIR/d27/f01
1239 [ $($GETSTRIPE -c $DIR/d27/f01) -eq 2 ] ||
1240 error "two-stripe file doesn't have two stripes"
1242 run_test 27b "create two stripe file"
1245 [ -f $DIR/d27/f01 ] || skip "test_27b not run" && return
1247 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
1249 run_test 27c "write to two stripe file"
1252 test_mkdir -p $DIR/d27
1253 $SETSTRIPE -c 0 -i -1 -S 0 $DIR/d27/fdef || error "setstripe failed"
1254 $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
1255 dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
1257 run_test 27d "create file with default settings ================"
1260 test_mkdir -p $DIR/d27
1261 $SETSTRIPE -c 2 $DIR/d27/f12 || error "setstripe failed"
1262 $SETSTRIPE -c 2 $DIR/d27/f12 && error "setstripe succeeded twice"
1263 $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
1265 run_test 27e "setstripe existing file (should return error) ======"
1268 test_mkdir -p $DIR/d27
1269 $SETSTRIPE -S 100 -i 0 -c 1 $DIR/d27/fbad && error "setstripe failed"
1270 dd if=/dev/zero of=$DIR/d27/fbad bs=4k count=4 || error "dd failed"
1271 $GETSTRIPE $DIR/d27/fbad || error "$GETSTRIPE failed"
1273 run_test 27f "setstripe with bad stripe size (should return error)"
1276 test_mkdir -p $DIR/d27
1277 $MCREATE $DIR/d27/fnone || error "mcreate failed"
1278 $GETSTRIPE $DIR/d27/fnone 2>&1 | grep "no stripe info" ||
1279 error "$DIR/d27/fnone has object"
1281 run_test 27g "$GETSTRIPE with no objects"
1284 touch $DIR/d27/fsome || error "touch failed"
1285 [ $($GETSTRIPE -c $DIR/d27/fsome) -gt 0 ] || error "missing objects"
1287 run_test 27i "$GETSTRIPE with some objects"
1290 test_mkdir -p $DIR/d27
1291 $SETSTRIPE -i $OSTCOUNT $DIR/d27/f27j && error "setstripe failed"||true
1293 run_test 27j "setstripe with bad stripe offset (should return error)"
1295 test_27k() { # bug 2844
1296 test_mkdir -p $DIR/d27
1298 LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
1299 [ ! -d $DIR/d27 ] && test_mkdir -p $DIR d27
1300 $SETSTRIPE -S 67108864 $FILE || error "setstripe failed"
1301 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1302 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1303 dd if=/dev/zero of=$FILE bs=4k count=1
1304 BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
1305 [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
1307 run_test 27k "limit i_blksize for broken user apps ============="
1310 test_mkdir -p $DIR/d27
1311 mcreate $DIR/f27l || error "creating file"
1312 $RUNAS $SETSTRIPE -c 1 $DIR/f27l && \
1313 error "setstripe should have failed" || true
1315 run_test 27l "check setstripe permissions (should return error)"
1318 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" &&
1320 if [ $ORIGFREE -gt $MAXFREE ]; then
1321 skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
1324 trap simple_cleanup_common EXIT
1325 test_mkdir -p $DIR/$tdir
1326 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_1
1327 dd if=/dev/zero of=$DIR/$tdir/f27m_1 bs=1024 count=$MAXFREE &&
1328 error "dd should fill OST0"
1330 while $SETSTRIPE -i 0 -c 1 $DIR/$tdir/f27m_$i; do
1332 [ $i -gt 256 ] && break
1335 touch $DIR/$tdir/f27m_$i
1336 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1337 error "OST0 was full but new created file still use it"
1339 touch $DIR/$tdir/f27m_$i
1340 [ `$GETSTRIPE $DIR/$tdir/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] &&
1341 error "OST0 was full but new created file still use it"
1342 simple_cleanup_common
1344 run_test 27m "create file while OST0 was full =================="
1347 local DELAY=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage | head -n 1 | awk '{print $1 * 2}')
1351 # OSCs keep a NOSPC flag that will be reset after ~5s (qos_maxage)
1352 # if the OST isn't full anymore.
1354 local OSTIDX=${1:-""}
1356 local list=$(comma_list $(osts_nodes))
1357 [ "$OSTIDX" ] && list=$(facet_host ost$((OSTIDX + 1)))
1359 do_nodes $list lctl set_param fail_loc=0
1360 sync # initiate all OST_DESTROYs from MDS to OST
1364 exhaust_precreations() {
1367 local FAILIDX=${3:-$OSTIDX}
1369 test_mkdir -p $DIR/$tdir
1370 local MDSIDX=$(get_mds_dir "$DIR/$tdir")
1371 echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
1373 local OST=$(ostname_from_index $OSTIDX)
1374 local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
1375 sed -e 's/_UUID$//;s/^.*-//')
1378 local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
1379 local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1380 osc.$mdtosc_proc1.prealloc_last_id)
1381 local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
1382 osc.$mdtosc_proc1.prealloc_next_id)
1384 local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
1385 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1387 test_mkdir -p $DIR/$tdir/${OST}
1388 $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
1389 #define OBD_FAIL_OST_ENOSPC 0x215
1390 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
1391 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
1392 echo "Creating to objid $last_id on ost $OST..."
1393 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1394 do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
1395 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
1399 exhaust_all_precreations() {
1401 for (( i=0; i < OSTCOUNT; i++ )) ; do
1402 exhaust_precreations $i $1 -1
1407 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1408 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1409 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1410 remote_ost_nodsh && skip "remote OST with nodsh" && return
1413 rm -f $DIR/$tdir/$tfile
1414 exhaust_precreations 0 0x80000215
1415 $SETSTRIPE -c -1 $DIR/$tdir
1416 touch $DIR/$tdir/$tfile || error
1417 $GETSTRIPE $DIR/$tdir/$tfile
1420 run_test 27n "create file with some full OSTs =================="
1423 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1424 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1425 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1426 remote_ost_nodsh && skip "remote OST with nodsh" && return
1429 rm -f $DIR/$tdir/$tfile
1430 exhaust_all_precreations 0x215
1432 touch $DIR/$tdir/$tfile && error "able to create $DIR/$tdir/$tfile"
1437 run_test 27o "create file with all full OSTs (should error) ===="
1440 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1441 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1442 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1443 remote_ost_nodsh && skip "remote OST with nodsh" && return
1446 rm -f $DIR/$tdir/$tfile
1447 test_mkdir -p $DIR/$tdir
1449 $MCREATE $DIR/$tdir/$tfile || error "mcreate failed"
1450 $TRUNCATE $DIR/$tdir/$tfile 80000000 || error "truncate failed"
1451 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1453 exhaust_precreations 0 0x80000215
1454 echo foo >> $DIR/$tdir/$tfile || error "append failed"
1455 $CHECKSTAT -s 80000004 $DIR/$tdir/$tfile || error "checkstat failed"
1456 $GETSTRIPE $DIR/$tdir/$tfile
1460 run_test 27p "append to a truncated file with some full OSTs ==="
1463 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1464 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1465 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1466 remote_ost_nodsh && skip "remote OST with nodsh" && return
1469 rm -f $DIR/$tdir/$tfile
1471 test_mkdir -p $DIR/$tdir
1472 $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
1473 $TRUNCATE $DIR/$tdir/$tfile 80000000 ||error "truncate $DIR/$tdir/$tfile failed"
1474 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat failed"
1476 exhaust_all_precreations 0x215
1478 echo foo >> $DIR/$tdir/$tfile && error "append succeeded"
1479 $CHECKSTAT -s 80000000 $DIR/$tdir/$tfile || error "checkstat 2 failed"
1483 run_test 27q "append to truncated file with all OSTs full (should error) ==="
1486 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1487 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1488 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1489 remote_ost_nodsh && skip "remote OST with nodsh" && return
1492 rm -f $DIR/$tdir/$tfile
1493 exhaust_precreations 0 0x80000215
1495 $SETSTRIPE -i 0 -c 2 $DIR/$tdir/$tfile # && error
1499 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
1501 test_27s() { # bug 10725
1502 test_mkdir -p $DIR/$tdir
1503 local stripe_size=$((4096 * 1024 * 1024)) # 2^32
1504 local stripe_count=0
1505 [ $OSTCOUNT -eq 1 ] || stripe_count=2
1506 $SETSTRIPE -S $stripe_size -c $stripe_count $DIR/$tdir &&
1507 error "stripe width >= 2^32 succeeded" || true
1510 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
1512 test_27t() { # bug 10864
1517 $WLFS getstripe $tfile
1520 run_test 27t "check that utils parse path correctly"
1522 test_27u() { # bug 4900
1523 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1524 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1526 local list=$(comma_list $(mdts_nodes))
1528 #define OBD_FAIL_MDS_OSC_PRECREATE 0x139
1529 do_nodes $list $LCTL set_param fail_loc=0x139
1530 test_mkdir -p $DIR/$tdir
1532 createmany -o $DIR/$tdir/t- 1000
1533 do_nodes $list $LCTL set_param fail_loc=0
1535 TLOG=$DIR/$tfile.getstripe
1536 $GETSTRIPE $DIR/$tdir > $TLOG
1537 OBJS=`awk -vobj=0 '($1 == 0) { obj += 1 } END { print obj;}' $TLOG`
1538 unlinkmany $DIR/$tdir/t- 1000
1539 [ $OBJS -gt 0 ] && \
1540 error "$OBJS objects created on OST-0. See $TLOG" || pass
1542 run_test 27u "skip object creation on OSC w/o objects =========="
1544 test_27v() { # bug 4900
1545 [ "$OSTCOUNT" -lt "2" ] && skip_env "too few OSTs" && return
1546 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1548 remote_ost_nodsh && skip "remote OST with nodsh" && return
1550 exhaust_all_precreations 0x215
1553 test_mkdir -p $DIR/$tdir
1554 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1556 touch $DIR/$tdir/$tfile
1557 #define OBD_FAIL_TGT_DELAY_PRECREATE 0x705
1559 for (( i=1; i < OSTCOUNT; i++ )); do
1560 do_facet ost$i lctl set_param fail_loc=0x705
1562 local START=`date +%s`
1563 createmany -o $DIR/$tdir/$tfile 32
1565 local FINISH=`date +%s`
1566 local TIMEOUT=`lctl get_param -n timeout`
1567 local PROCESS=$((FINISH - START))
1568 [ $PROCESS -ge $((TIMEOUT / 2)) ] && \
1569 error "$FINISH - $START >= $TIMEOUT / 2"
1570 sleep $((TIMEOUT / 2 - PROCESS))
1573 run_test 27v "skip object creation on slow OST ================="
1575 test_27w() { # bug 10997
1576 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1577 $SETSTRIPE -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
1578 [ $($GETSTRIPE -S $DIR/$tdir/f0) -ne 65536 ] &&
1579 error "stripe size $size != 65536" || true
1580 [ $($GETSTRIPE -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
1581 error "$GETSTRIPE -d $DIR/$tdir failed" || true
1583 run_test 27w "check $SETSTRIPE -S option"
1586 [ "$OSTCOUNT" -lt "2" ] &&
1587 skip_env "skipping multiple stripe count/offset test" && return
1589 test_mkdir -p $DIR/$tdir || error "mkdir failed"
1590 for i in $(seq 1 $OSTCOUNT); do
1592 $SETSTRIPE -c $i -i $offset $DIR/$tdir/f$i ||
1593 error "setstripe -c $i -i $offset failed"
1594 count=$($GETSTRIPE -c $DIR/$tdir/f$i)
1595 index=$($GETSTRIPE -i $DIR/$tdir/f$i)
1596 [ $count -ne $i ] && error "stripe count $count != $i" || true
1597 [ $index -ne $offset ] &&
1598 error "stripe offset $index != $offset" || true
1601 run_test 27wa "check $SETSTRIPE -c -i options"
1604 remote_ost_nodsh && skip "remote OST with nodsh" && return
1605 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
1606 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1607 OFFSET=$(($OSTCOUNT - 1))
1609 local OST=$(ostname_from_index $OSTIDX)
1611 test_mkdir -p $DIR/$tdir
1612 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe per file
1613 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 1
1615 createmany -o $DIR/$tdir/$tfile $OSTCOUNT
1616 for i in `seq 0 $OFFSET`; do
1617 [ `$GETSTRIPE $DIR/$tdir/$tfile$i | grep -A 10 obdidx | awk '{print $1}' | grep -w "$OSTIDX"` ] &&
1618 error "OST0 was degraded but new created file still use it"
1620 do_facet ost$((OSTIDX + 1)) lctl set_param -n obdfilter.$OST.degraded 0
1622 run_test 27x "create files while OST0 is degraded"
1625 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1626 remote_mds_nodsh && skip "remote MDS with nodsh" && return
1627 remote_ost_nodsh && skip "remote OST with nodsh" && return
1628 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1630 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1631 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1632 osc.$mdtosc.prealloc_last_id)
1633 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1634 osc.$mdtosc.prealloc_next_id)
1635 local fcount=$((last_id - next_id))
1636 [ $fcount -eq 0 ] && skip "not enough space on OST0" && return
1637 [ $fcount -gt $OSTCOUNT ] && fcount=$OSTCOUNT
1639 local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
1640 awk '/[oO][sS][cC].*md[ts]/ { print $4 }')
1641 local OST_DEACTIVE_IDX=-1
1646 for OSC in $MDS_OSCS; do
1647 OST=$(osc_to_ost $OSC)
1648 OSTIDX=$(index_from_ostuuid $OST)
1649 if [ $OST_DEACTIVE_IDX == -1 ]; then
1650 OST_DEACTIVE_IDX=$OSTIDX
1652 if [ $OSTIDX != $OST_DEACTIVE_IDX ]; then
1653 echo $OSC "is Deactivated:"
1654 do_facet $SINGLEMDS lctl --device %$OSC deactivate
1658 OSTIDX=$(index_from_ostuuid $OST)
1660 $SETSTRIPE -c 1 $DIR/$tdir # 1 stripe / file
1662 for OSC in $MDS_OSCS; do
1663 OST=$(osc_to_ost $OSC)
1664 OSTIDX=$(index_from_ostuuid $OST)
1665 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1666 echo $OST "is degraded:"
1667 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1668 obdfilter.$OST.degraded=1
1673 createmany -o $DIR/$tdir/$tfile $fcount
1675 for OSC in $MDS_OSCS; do
1676 OST=$(osc_to_ost $OSC)
1677 OSTIDX=$(index_from_ostuuid $OST)
1678 if [ $OSTIDX == $OST_DEACTIVE_IDX ]; then
1679 echo $OST "is recovered from degraded:"
1680 do_facet ost$((OSTIDX+1)) lctl set_param -n \
1681 obdfilter.$OST.degraded=0
1683 do_facet $SINGLEMDS lctl --device %$OSC activate
1687 # all osp devices get activated, hence -1 stripe count restored
1690 # sleep 2*lod_qos_maxage seconds waiting for lod qos to notice osp
1691 # devices get activated.
1693 $SETSTRIPE -c -1 $DIR/$tfile
1694 stripecnt=$($GETSTRIPE -c $DIR/$tfile)
1696 [ $stripecnt -ne $OSTCOUNT ] &&
1697 error "Of $OSTCOUNT OSTs, only $stripecnt is available"
1700 run_test 27y "create files while OST0 is degraded and the rest inactive"
1706 lmm_count=$($GETSTRIPE -c $1)
1707 lmm_seq=$($GETSTRIPE -v $1 | awk '/lmm_seq/ { print $2 }')
1708 lmm_oid=$($GETSTRIPE -v $1 | awk '/lmm_object_id/ { print $2 }')
1710 local old_ifs="$IFS"
1712 fid=($($LFS path2fid $1))
1715 log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
1716 log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
1718 # compare lmm_seq and lu_fid->f_seq
1719 [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
1720 # compare lmm_object_id and lu_fid->oid
1721 [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
1723 # check the trusted.fid attribute of the OST objects of the file
1724 local have_obdidx=false
1726 $GETSTRIPE $1 | while read obdidx oid hex seq; do
1727 # skip lines up to and including "obdidx"
1728 [ -z "$obdidx" ] && break
1729 [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
1730 $have_obdidx || continue
1732 local ost=$((obdidx + 1))
1733 local dev=$(ostdevname $ost)
1736 if [ $(facet_fstype ost$ost) != ldiskfs ]; then
1737 echo "Currently only works with ldiskfs-based OSTs"
1741 log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
1743 #don't unmount/remount the OSTs if we don't need to do that
1744 # LU-2577 changes filter_fid to be smaller, so debugfs needs
1745 # update too, until that use mount/ll_decode_filter_fid/mount
1746 local dir=$(facet_mntpt ost$ost)
1747 local opts=${OST_MOUNT_OPTS}
1749 if ! do_facet ost$ost test -b ${dev}; then
1750 opts=$(csa_add "$opts" -o loop)
1754 do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir ||
1755 { error "mounting $dev as $FSTYPE failed"; return 3; }
1757 seq=$(echo $seq | sed -e "s/^0x//g")
1758 if [ $seq == 0 ]; then
1759 oid_hex=$(echo $oid)
1761 oid_hex=$(echo $hex | sed -e "s/^0x//g")
1763 local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid_hex)
1764 local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file)
1765 do_facet ost$ost umount -d $dir
1766 start ost$ost $dev $OST_MOUNT_OPTS
1768 # re-enable when debugfs will understand new filter_fid
1769 #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
1770 # $dev 2>/dev/null" | grep "parent=")
1772 [ -z "$ff" ] && error "$obj_file: no filter_fid info"
1774 echo "$ff" | sed -e 's#.*objid=#got: objid=#'
1776 # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
1777 # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
1778 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//')
1779 local ff_pseq=$(echo $ff_parent | cut -d: -f1)
1780 local ff_poid=$(echo $ff_parent | cut -d: -f2)
1781 local ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
1783 # compare lmm_seq and filter_fid->ff_parent.f_seq
1784 [ $ff_pseq = $lmm_seq ] ||
1785 error "FF parent SEQ $ff_pseq != $lmm_seq"
1786 # compare lmm_object_id and filter_fid->ff_parent.f_oid
1787 [ $ff_poid = $lmm_oid ] ||
1788 error "FF parent OID $ff_poid != $lmm_oid"
1789 [ $ff_pstripe = $stripe_nr ] ||
1790 error "FF stripe $ff_pstripe != $stripe_nr"
1792 stripe_nr=$((stripe_nr + 1))
1797 remote_ost_nodsh && skip "remote OST with nodsh" && return
1798 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1799 test_mkdir -p $DIR/$tdir
1801 $SETSTRIPE -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
1802 { error "setstripe -c -1 failed"; return 1; }
1803 # We need to send a write to every object to get parent FID info set.
1804 # This _should_ also work for setattr, but does not currently.
1805 # touch $DIR/$tdir/$tfile-1 ||
1806 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
1807 { error "dd $tfile-1 failed"; return 2; }
1808 $SETSTRIPE -c -1 -i $((OSTCOUNT - 1)) -S 1M $DIR/$tdir/$tfile-2 ||
1809 { error "setstripe -c -1 failed"; return 3; }
1810 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
1811 { error "dd $tfile-2 failed"; return 4; }
1813 # make sure write RPCs have been sent to OSTs
1816 check_seq_oid $DIR/$tdir/$tfile-1 || return 5
1817 check_seq_oid $DIR/$tdir/$tfile-2 || return 6
1819 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
1821 test_27A() { # b=19102
1822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1823 local restore_size=$($GETSTRIPE -S $MOUNT)
1824 local restore_count=$($GETSTRIPE -c $MOUNT)
1825 local restore_offset=$($GETSTRIPE -i $MOUNT)
1826 $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
1827 local default_size=$($GETSTRIPE -S $MOUNT)
1828 local default_count=$($GETSTRIPE -c $MOUNT)
1829 local default_offset=$($GETSTRIPE -i $MOUNT)
1830 local dsize=$((1024 * 1024))
1831 [ $default_size -eq $dsize ] ||
1832 error "stripe size $default_size != $dsize"
1833 [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
1834 [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
1835 $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
1837 run_test 27A "check filesystem-wide default LOV EA values"
1839 test_27B() { # LU-2523
1840 test_mkdir -p $DIR/$tdir
1841 rm -f $DIR/$tdir/f0 $DIR/$tdir/f1
1843 # open f1 with O_LOV_DELAY_CREATE
1845 # call setstripe ioctl on open file descriptor for f1
1847 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:nB1c \
1851 # open f1 with O_LOV_DELAY_CREATE
1853 # call setstripe ioctl on open file descriptor for f1
1855 multiop $DIR/$tdir/f1 oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:uB1c
1857 # Allow multiop to fail in imitation of NFS's busted semantics.
1860 run_test 27B "call setstripe on open unlinked file/rename victim"
1862 test_27C() { #LU-2871
1863 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
1871 test_mkdir -p $DIR/$tdir
1873 for i in $(seq 0 $((OSTCOUNT - 1))); do
1874 # set stripe across all OSTs starting from OST$i
1875 $SETSTRIPE -i $i -c -1 $tfile$i
1876 # get striping information
1877 ost_idx=($($GETSTRIPE $tfile$i |
1878 tail -n $((OSTCOUNT + 1)) | awk '{print $1}'))
1882 [ ${#ost_idx[@]} -eq $OSTCOUNT ] ||
1883 error "${#ost_idx[@]} != $OSTCOUNT"
1885 for index in $(seq 0 $((OSTCOUNT - 1))); do
1887 for j in $(echo ${ost_idx[@]}); do
1888 if [ $index -eq $j ]; then
1894 error "Can not find $index in ${ost_idx[@]}"
1898 run_test 27C "check full striping across all OSTs"
1900 # createtest also checks that device nodes are created and
1901 # then visible correctly (#2091)
1902 test_28() { # bug 2091
1904 $CREATETEST $DIR/d28/ct || error
1906 run_test 28 "create/mknod/mkdir with bad file types ============"
1909 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1910 cancel_lru_locks mdc
1916 declare -i LOCKCOUNTORIG=0
1917 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1918 let LOCKCOUNTORIG=$LOCKCOUNTORIG+$lock_count
1920 [ $LOCKCOUNTORIG -eq 0 ] && echo "No mdc lock count" && return 1
1922 declare -i LOCKUNUSEDCOUNTORIG=0
1923 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1924 let LOCKUNUSEDCOUNTORIG=$LOCKUNUSEDCOUNTORIG+$unused_count
1931 declare -i LOCKCOUNTCURRENT=0
1932 for lock_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_count); do
1933 let LOCKCOUNTCURRENT=$LOCKCOUNTCURRENT+$lock_count
1936 declare -i LOCKUNUSEDCOUNTCURRENT=0
1937 for unused_count in $(lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count); do
1938 let LOCKUNUSEDCOUNTCURRENT=$LOCKUNUSEDCOUNTCURRENT+$unused_count
1941 if [ "$LOCKCOUNTCURRENT" -gt "$LOCKCOUNTORIG" ]; then
1942 lctl set_param -n ldlm.dump_namespaces ""
1943 error "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
1944 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1945 log "dumped log to $TMP/test_29.dk (bug 5793)"
1948 if [ "$LOCKUNUSEDCOUNTCURRENT" -gt "$LOCKUNUSEDCOUNTORIG" ]; then
1949 error "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
1950 $LCTL dk | sort -k4 -t: > $TMP/test_29.dk
1951 log "dumped log to $TMP/test_29.dk (bug 5793)"
1955 run_test 29 "IT_GETATTR regression ============================"
1957 test_30a() { # was test_30
1958 cp `which ls` $DIR || cp /bin/ls $DIR
1962 run_test 30a "execute binary from Lustre (execve) =============="
1965 cp `which ls` $DIR || cp /bin/ls $DIR
1967 $RUNAS $DIR/ls / || error
1970 run_test 30b "execute binary from Lustre as non-root ==========="
1972 test_30c() { # b=22376
1973 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
1974 cp `which ls` $DIR || cp /bin/ls $DIR
1976 cancel_lru_locks mdc
1977 cancel_lru_locks osc
1978 $RUNAS $DIR/ls / || error
1981 run_test 30c "execute binary from Lustre without read perms ===="
1984 $OPENUNLINK $DIR/f31 $DIR/f31 || error
1985 $CHECKSTAT -a $DIR/f31 || error
1987 run_test 31a "open-unlink file =================================="
1990 touch $DIR/f31 || error
1991 ln $DIR/f31 $DIR/f31b || error
1992 $MULTIOP $DIR/f31b Ouc || error
1993 $CHECKSTAT -t file $DIR/f31 || error
1995 run_test 31b "unlink file with multiple links while open ======="
1998 touch $DIR/f31 || error
1999 ln $DIR/f31 $DIR/f31c || error
2000 multiop_bg_pause $DIR/f31 O_uc || return 1
2002 $MULTIOP $DIR/f31c Ouc
2003 kill -USR1 $MULTIPID
2006 run_test 31c "open-unlink file with multiple links ============="
2009 opendirunlink $DIR/d31d $DIR/d31d || error
2010 $CHECKSTAT -a $DIR/d31d || error
2012 run_test 31d "remove of open directory ========================="
2014 test_31e() { # bug 2904
2015 check_kernel_version 34 || return 0
2016 openfilleddirunlink $DIR/d31e || error
2018 run_test 31e "remove of open non-empty directory ==============="
2020 test_31f() { # bug 4554
2021 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2023 test_mkdir $DIR/d31f
2024 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2025 cp /etc/hosts $DIR/d31f
2027 $GETSTRIPE $DIR/d31f/hosts
2028 multiop_bg_pause $DIR/d31f D_c || return 1
2031 rm -rv $DIR/d31f || error "first of $DIR/d31f"
2032 test_mkdir $DIR/d31f
2033 $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
2034 cp /etc/hosts $DIR/d31f
2036 $GETSTRIPE $DIR/d31f/hosts
2037 multiop_bg_pause $DIR/d31f D_c || return 1
2040 kill -USR1 $MULTIPID || error "first opendir $MULTIPID not running"
2041 wait $MULTIPID || error "first opendir $MULTIPID failed"
2045 kill -USR1 $MULTIPID2 || error "second opendir $MULTIPID not running"
2046 wait $MULTIPID2 || error "second opendir $MULTIPID2 failed"
2049 run_test 31f "remove of open directory with open-unlink file ==="
2052 echo "-- cross directory link --"
2053 test_mkdir $DIR/d31ga
2054 test_mkdir $DIR/d31gb
2056 ln $DIR/d31ga/f $DIR/d31gb/g
2057 $CHECKSTAT -t file $DIR/d31ga/f || error "source"
2058 [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
2059 $CHECKSTAT -t file $DIR/d31gb/g || error "target"
2060 [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
2062 run_test 31g "cross directory link==============="
2065 echo "-- cross directory link --"
2066 test_mkdir $DIR/d31h
2067 test_mkdir $DIR/d31h/dir
2069 ln $DIR/d31h/f $DIR/d31h/dir/g
2070 $CHECKSTAT -t file $DIR/d31h/f || error "source"
2071 [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
2072 $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
2073 [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
2075 run_test 31h "cross directory link under child==============="
2078 echo "-- cross directory link --"
2079 test_mkdir $DIR/d31i
2080 test_mkdir $DIR/d31i/dir
2081 touch $DIR/d31i/dir/f
2082 ln $DIR/d31i/dir/f $DIR/d31i/g
2083 $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
2084 [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
2085 $CHECKSTAT -t file $DIR/d31i/g || error "target"
2086 [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
2088 run_test 31i "cross directory link under parent==============="
2092 test_mkdir $DIR/d31j
2093 test_mkdir $DIR/d31j/dir1
2094 ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
2095 link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
2096 mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
2097 mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
2100 run_test 31j "link for directory==============="
2104 test_mkdir $DIR/d31k
2106 touch $DIR/d31k/exist
2107 mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
2108 mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
2109 mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
2110 mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
2111 mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
2112 mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
2113 mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
2116 run_test 31k "link to file: the same, non-existing, dir==============="
2119 test_mkdir $DIR/d31m
2121 test_mkdir $DIR/d31m2
2122 touch $DIR/d31m2/exist
2123 mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
2124 mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
2125 mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
2126 mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
2127 mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
2128 mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
2131 run_test 31m "link to file: the same, non-existing, dir==============="
2134 [ -e /proc/self/fd/173 ] && echo "skipping, fd 173 is in use" && return
2135 touch $DIR/$tfile || error "cannot create '$DIR/$tfile'"
2136 nlink=$(stat --format=%h $DIR/$tfile)
2137 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2138 exec 173<$DIR/$tfile
2139 trap "exec 173<&-" EXIT
2140 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2141 [ ${nlink:--1} -eq 1 ] || error "nlink is $nlink, expected 1"
2142 rm $DIR/$tfile || error "cannot remove '$DIR/$tfile'"
2143 nlink=$(stat --dereference --format=%h /proc/self/fd/173)
2144 [ ${nlink:--1} -eq 0 ] || error "nlink is $nlink, expected 0"
2147 run_test 31n "check link count of unlinked file"
2149 cleanup_test32_mount() {
2151 $UMOUNT $DIR/$tdir/ext2-mountpoint
2155 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2156 echo "== more mountpoints and symlinks ================="
2157 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2158 trap cleanup_test32_mount EXIT
2159 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2160 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2161 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
2162 cleanup_test32_mount
2164 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
2167 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2168 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2169 trap cleanup_test32_mount EXIT
2170 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2171 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2172 ls -al $DIR/$tdir/ext2-mountpoint/.. || error
2173 cleanup_test32_mount
2175 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
2178 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2179 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2180 trap cleanup_test32_mount EXIT
2181 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2182 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2183 test_mkdir -p $DIR/$tdir/d2/test_dir
2184 $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2185 cleanup_test32_mount
2187 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
2190 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2191 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2192 trap cleanup_test32_mount EXIT
2193 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2194 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2195 test_mkdir -p $DIR/$tdir/d2/test_dir
2196 ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
2197 cleanup_test32_mount
2199 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
2202 [ -e $DIR/d32e ] && rm -fr $DIR/d32e
2203 test_mkdir -p $DIR/d32e/tmp
2204 TMP_DIR=$DIR/d32e/tmp
2205 ln -s $DIR/d32e $TMP_DIR/symlink11
2206 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2207 $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
2208 $CHECKSTAT -t link $DIR/d32e/symlink01 || error
2210 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
2213 [ -e $DIR/d32f ] && rm -fr $DIR/d32f
2214 test_mkdir -p $DIR/d32f/tmp
2215 TMP_DIR=$DIR/d32f/tmp
2216 ln -s $DIR/d32f $TMP_DIR/symlink11
2217 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2218 ls $DIR/d32f/tmp/symlink11 || error
2219 ls $DIR/d32f/symlink01 || error
2221 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
2224 TMP_DIR=$DIR/$tdir/tmp
2225 test_mkdir -p $DIR/$tdir/tmp
2226 test_mkdir $DIR/${tdir}2
2227 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2228 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2229 $CHECKSTAT -t link $TMP_DIR/symlink12 || error
2230 $CHECKSTAT -t link $DIR/$tdir/symlink02 || error
2231 $CHECKSTAT -t dir -f $TMP_DIR/symlink12 || error
2232 $CHECKSTAT -t dir -f $DIR/$tdir/symlink02 || error
2234 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2237 rm -fr $DIR/$tdir $DIR/${tdir}2
2238 TMP_DIR=$DIR/$tdir/tmp
2239 test_mkdir -p $DIR/$tdir/tmp
2240 test_mkdir $DIR/${tdir}2
2241 ln -s $DIR/${tdir}2 $TMP_DIR/symlink12
2242 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2243 ls $TMP_DIR/symlink12 || error
2244 ls $DIR/$tdir/symlink02 || error
2246 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
2249 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2250 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2251 trap cleanup_test32_mount EXIT
2252 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2253 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2254 touch $DIR/$tdir/test_file
2255 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
2256 cleanup_test32_mount
2258 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
2261 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2262 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2263 trap cleanup_test32_mount EXIT
2264 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2265 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2266 touch $DIR/$tdir/test_file
2267 cat $DIR/$tdir/ext2-mountpoint/../test_file || error
2268 cleanup_test32_mount
2270 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
2273 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2275 trap cleanup_test32_mount EXIT
2276 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2277 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
2278 test_mkdir -p $DIR/$tdir/d2
2279 touch $DIR/$tdir/d2/test_file || error
2280 $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2281 cleanup_test32_mount
2283 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
2286 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2288 trap cleanup_test32_mount EXIT
2289 test_mkdir -p $DIR/$tdir/ext2-mountpoint
2290 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
2291 test_mkdir -p $DIR/$tdir/d2
2292 touch $DIR/$tdir/d2/test_file
2293 cat $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
2294 cleanup_test32_mount
2296 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
2300 test_mkdir -p $DIR/d32m/tmp
2301 TMP_DIR=$DIR/d32m/tmp
2302 ln -s $DIR $TMP_DIR/symlink11
2303 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2304 $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
2305 $CHECKSTAT -t link $DIR/d32m/symlink01 || error
2307 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
2311 test_mkdir -p $DIR/d32n/tmp
2312 TMP_DIR=$DIR/d32n/tmp
2313 ln -s $DIR $TMP_DIR/symlink11
2314 ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
2315 ls -l $DIR/d32n/tmp/symlink11 || error
2316 ls -l $DIR/d32n/symlink01 || error
2318 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
2321 rm -fr $DIR/d32o $DIR/$tfile
2323 test_mkdir -p $DIR/d32o/tmp
2324 TMP_DIR=$DIR/d32o/tmp
2325 ln -s $DIR/$tfile $TMP_DIR/symlink12
2326 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2327 $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
2328 $CHECKSTAT -t link $DIR/d32o/symlink02 || error
2329 $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
2330 $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
2332 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
2342 test_mkdir -p $DIR/d32p/tmp
2344 TMP_DIR=$DIR/d32p/tmp
2346 ln -s $DIR/$tfile $TMP_DIR/symlink12
2348 ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
2350 cat $DIR/d32p/tmp/symlink12 || error
2352 cat $DIR/d32p/symlink02 || error
2355 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
2357 cleanup_testdir_mount() {
2363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2364 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2365 trap cleanup_testdir_mount EXIT
2366 test_mkdir -p $DIR/$tdir
2367 touch $DIR/$tdir/under_the_mount
2368 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2369 ls $DIR/$tdir | grep "\<under_the_mount\>" && error
2370 cleanup_testdir_mount
2372 run_test 32q "stat follows mountpoints in Lustre (should return error)"
2375 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2376 [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
2377 trap cleanup_testdir_mount EXIT
2378 test_mkdir -p $DIR/$tdir
2379 touch $DIR/$tdir/under_the_mount
2380 mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir
2381 ls $DIR/$tdir | grep -q under_the_mount && error || true
2382 cleanup_testdir_mount
2384 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
2389 chmod 444 $DIR/$tfile
2390 chown $RUNAS_ID $DIR/$tfile
2392 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2395 run_test 33aa "write file with mode 444 (should return error) ===="
2399 test_mkdir -p $DIR/d33
2400 chown $RUNAS_ID $DIR/d33
2401 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33|| error "create"
2402 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && \
2403 error "open RDWR" || true
2405 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
2409 test_mkdir -p $DIR/d33
2410 chown $RUNAS_ID $DIR/d33
2411 $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
2413 run_test 33b "test open file with malformed flags (No panic and return error)"
2416 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2422 remote_ost_nodsh && skip "remote OST with nodsh" && return
2425 test_mkdir -p $DIR/d33
2426 # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0
2429 for ostnum in $(seq $OSTCOUNT); do
2430 # test-framework's OST numbering is one-based, while Lustre's
2432 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2433 # Parsing llobdstat's output sucks; we could grep the /proc
2434 # path, but that's likely to not be as portable as using the
2435 # llobdstat utility. So we parse lctl output instead.
2436 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2437 obdfilter/$ostname/stats |
2438 awk '/^write_bytes/ {print $7}' )
2439 echo "baseline_write_bytes@$OSTnum/$ostname=$write_bytes"
2440 if (( ${write_bytes:-0} > 0 ))
2447 $all_zeros || return 0
2450 echo foo > $DIR/d33/bar
2454 # Total up write_bytes after writing. We'd better find non-zeros.
2455 for ostnum in $(seq $OSTCOUNT); do
2456 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2457 write_bytes=$(do_facet ost$ostnum lctl get_param -n \
2458 obdfilter/$ostname/stats |
2459 awk '/^write_bytes/ {print $7}' )
2460 echo "write_bytes@$OSTnum/$ostname=$write_bytes"
2461 if (( ${write_bytes:-0} > 0 ))
2470 for ostnum in $(seq $OSTCOUNT); do
2471 ostname=$(printf "$FSNAME-OST%.4x" $((ostnum - 1)))
2472 echo "Check that write_bytes is present in obdfilter/*/stats:"
2473 do_facet ost$ostnum lctl get_param -n \
2474 obdfilter/$ostname/stats
2476 error "OST not keeping write_bytes stats (b22312)"
2479 run_test 33c "test llobdstat and write_bytes"
2482 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
2483 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2485 local remote_dir=$DIR/$tdir/remote_dir
2488 $LFS mkdir -i $MDTIDX $remote_dir ||
2489 error "create remote directory failed"
2491 touch $remote_dir/$tfile
2492 chmod 444 $remote_dir/$tfile
2493 chown $RUNAS_ID $remote_dir/$tfile
2495 $RUNAS $OPENFILE -f O_RDWR $DIR/$tfile && error || true
2497 chown $RUNAS_ID $remote_dir
2498 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 ||
2499 error "create" || true
2500 $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $remote_dir/f33 &&
2501 error "open RDWR" || true
2502 $RUNAS $OPENFILE -f 1286739555 $remote_dir/f33 &&
2503 error "create" || true
2505 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
2507 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
2510 $MCREATE $DIR/f34 || error
2511 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2512 $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
2513 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2514 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2516 run_test 34a "truncate file that has not been opened ==========="
2519 [ ! -f $DIR/f34 ] && test_34a
2520 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2521 $OPENFILE -f O_RDONLY $DIR/f34
2522 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
2523 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2525 run_test 34b "O_RDONLY opening file doesn't create objects ====="
2528 [ ! -f $DIR/f34 ] && test_34a
2529 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2530 $OPENFILE -f O_RDWR $DIR/f34
2531 $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
2532 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2534 run_test 34c "O_RDWR opening file-with-size works =============="
2537 [ ! -f $DIR/f34 ] && test_34a
2538 dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
2539 $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
2542 run_test 34d "write to sparse file ============================="
2546 $MCREATE $DIR/f34e || error
2547 $TRUNCATE $DIR/f34e 1000 || error
2548 $CHECKSTAT -s 1000 $DIR/f34e || error
2549 $OPENFILE -f O_RDWR $DIR/f34e
2550 $CHECKSTAT -s 1000 $DIR/f34e || error
2552 run_test 34e "create objects, some with size and some without =="
2554 test_34f() { # bug 6242, 6243
2555 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2558 $MCREATE $DIR/f34f || error
2559 $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
2560 dd if=$DIR/f34f of=$TMP/f34f
2561 $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
2562 dd if=/dev/zero of=$TMP/f34fzero bs=$SIZE34F count=1
2563 cmp $DIR/f34f $TMP/f34fzero || error "$DIR/f34f not all zero"
2564 cmp $TMP/f34f $TMP/f34fzero || error "$TMP/f34f not all zero"
2565 rm $TMP/f34f $TMP/f34fzero $DIR/f34f
2567 run_test 34f "read from a file with no objects until EOF ======="
2570 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2571 dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
2572 $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
2573 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
2574 cancel_lru_locks osc
2575 $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
2576 error "wrong size after lock cancel"
2578 $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
2579 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2580 error "expanding truncate failed"
2581 cancel_lru_locks osc
2582 $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
2583 error "wrong expanded size after lock cancel"
2585 run_test 34g "truncate long file ==============================="
2588 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2592 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
2593 sync # Flush the cache so that multiop below does not block on cache
2594 # flush when getting the group lock
2595 $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
2598 # Since just timed wait is not good enough, let's do a sync write
2599 # that way we are sure enough time for a roundtrip + processing
2600 # passed + 2 seconds of extra margin.
2601 dd if=/dev/zero of=$DIR/${tfile}-1 bs=4096 oflag=direct count=1
2605 if [[ `ps h -o comm -p $MULTIPID` == "multiop" ]]; then
2606 error "Multiop blocked on ftruncate, pid=$MULTIPID"
2610 local nsz=`stat -c %s $DIR/$tfile`
2611 [[ $nsz == $sz ]] || error "New size wrong $nsz != $sz"
2613 run_test 34h "ftruncate file under grouplock should not block"
2616 cp /bin/sh $DIR/f35a
2618 chown $RUNAS_ID $DIR/f35a
2619 $RUNAS $DIR/f35a && error || true
2622 run_test 35a "exec file with mode 444 (should return and not leak) ====="
2626 utime $DIR/f36 || error
2628 run_test 36a "MDS utime check (mknod, utime) ==================="
2632 utime $DIR/f36 || error
2634 run_test 36b "OST utime check (open, utime) ===================="
2639 chown $RUNAS_ID $DIR/d36
2640 $RUNAS utime $DIR/d36/f36 || error
2642 run_test 36c "non-root MDS utime check (mknod, utime) =========="
2645 [ ! -d $DIR/d36 ] && test_36c
2646 echo "" > $DIR/d36/f36
2647 $RUNAS utime $DIR/d36/f36 || error
2649 run_test 36d "non-root OST utime check (open, utime) ==========="
2652 [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
2653 test_mkdir -p $DIR/$tdir
2654 touch $DIR/$tdir/$tfile
2655 $RUNAS utime $DIR/$tdir/$tfile && \
2656 error "utime worked, expected failure" || true
2658 run_test 36e "utime on non-owned file (should return error) ===="
2662 local LANG_SAVE=$LANG
2663 local LC_LANG_SAVE=$LC_LANG
2664 export LANG=C LC_LANG=C # for date language
2666 DATESTR="Dec 20 2000"
2667 test_mkdir -p $DIR/$tdir
2668 lctl set_param fail_loc=$fl
2670 cp /etc/hosts $DIR/$tdir/$tfile
2671 sync & # write RPC generated with "current" inode timestamp, but delayed
2673 touch --date="$DATESTR" $DIR/$tdir/$tfile # setattr timestamp in past
2674 LS_BEFORE="`ls -l $DIR/$tdir/$tfile`" # old timestamp from client cache
2675 cancel_lru_locks osc
2676 LS_AFTER="`ls -l $DIR/$tdir/$tfile`" # timestamp from OST object
2678 [ "$LS_BEFORE" != "$LS_AFTER" ] && \
2679 echo "BEFORE: $LS_BEFORE" && \
2680 echo "AFTER : $LS_AFTER" && \
2681 echo "WANT : $DATESTR" && \
2682 error "$DIR/$tdir/$tfile timestamps changed" || true
2684 export LANG=$LANG_SAVE LC_LANG=$LC_LANG_SAVE
2688 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2689 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2690 subr_36fh "0x80000214"
2692 run_test 36f "utime on file racing with OST BRW write =========="
2695 remote_ost_nodsh && skip "remote OST with nodsh" && return
2696 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2701 test_mkdir -p $DIR/$tdir
2702 fmd_max_age=$(do_facet ost1 \
2703 "lctl get_param -n obdfilter.*.client_cache_seconds 2> /dev/null | \
2706 fmd_before=$(do_facet ost1 \
2707 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2708 touch $DIR/$tdir/$tfile
2709 sleep $((fmd_max_age + 12))
2710 fmd_after=$(do_facet ost1 \
2711 "awk '/ll_fmd_cache/ {print \\\$2}' /proc/slabinfo")
2713 echo "fmd_before: $fmd_before"
2714 echo "fmd_after: $fmd_after"
2715 [ "$fmd_after" -gt "$fmd_before" ] && \
2716 echo "AFTER: $fmd_after > BEFORE: $fmd_before" && \
2717 error "fmd didn't expire after ping" || true
2719 run_test 36g "filter mod data cache expiry ====================="
2722 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2723 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
2724 subr_36fh "0x80000227"
2726 run_test 36h "utime on file racing with OST BRW write =========="
2728 # test_37 - duplicate with tests 32q 32r
2731 local file=$DIR/$tfile
2733 openfile -f O_DIRECTORY $file
2736 [ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
2737 [ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
2739 run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
2743 touch $DIR/${tfile}2
2744 # ls -l $DIR/$tfile $DIR/${tfile}2
2745 # ls -lu $DIR/$tfile $DIR/${tfile}2
2746 # ls -lc $DIR/$tfile $DIR/${tfile}2
2748 $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/${tfile}2
2749 if [ ! $DIR/${tfile}2 -nt $DIR/$tfile ]; then
2751 ls -l --full-time $DIR/$tfile $DIR/${tfile}2
2753 ls -lu --full-time $DIR/$tfile $DIR/${tfile}2
2755 ls -lc --full-time $DIR/$tfile $DIR/${tfile}2
2756 error "O_TRUNC didn't change timestamps"
2759 run_test 39 "mtime changed on create ==========================="
2762 test_mkdir -p $DIR/$tdir
2763 cp -p /etc/passwd $DIR/$tdir/fopen
2764 cp -p /etc/passwd $DIR/$tdir/flink
2765 cp -p /etc/passwd $DIR/$tdir/funlink
2766 cp -p /etc/passwd $DIR/$tdir/frename
2767 ln $DIR/$tdir/funlink $DIR/$tdir/funlink2
2770 echo "aaaaaa" >> $DIR/$tdir/fopen
2771 echo "aaaaaa" >> $DIR/$tdir/flink
2772 echo "aaaaaa" >> $DIR/$tdir/funlink
2773 echo "aaaaaa" >> $DIR/$tdir/frename
2775 local open_new=`stat -c %Y $DIR/$tdir/fopen`
2776 local link_new=`stat -c %Y $DIR/$tdir/flink`
2777 local unlink_new=`stat -c %Y $DIR/$tdir/funlink`
2778 local rename_new=`stat -c %Y $DIR/$tdir/frename`
2780 cat $DIR/$tdir/fopen > /dev/null
2781 ln $DIR/$tdir/flink $DIR/$tdir/flink2
2782 rm -f $DIR/$tdir/funlink2
2783 mv -f $DIR/$tdir/frename $DIR/$tdir/frename2
2785 for (( i=0; i < 2; i++ )) ; do
2786 local open_new2=`stat -c %Y $DIR/$tdir/fopen`
2787 local link_new2=`stat -c %Y $DIR/$tdir/flink`
2788 local unlink_new2=`stat -c %Y $DIR/$tdir/funlink`
2789 local rename_new2=`stat -c %Y $DIR/$tdir/frename2`
2791 [ $open_new2 -eq $open_new ] || error "open file reverses mtime"
2792 [ $link_new2 -eq $link_new ] || error "link file reverses mtime"
2793 [ $unlink_new2 -eq $unlink_new ] || error "unlink file reverses mtime"
2794 [ $rename_new2 -eq $rename_new ] || error "rename file reverses mtime"
2796 cancel_lru_locks osc
2797 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2800 run_test 39b "mtime change on open, link, unlink, rename ======"
2802 # this should be set to past
2803 TEST_39_MTIME=`date -d "1 year ago" +%s`
2809 local mtime0=`stat -c %Y $DIR1/$tfile`
2811 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2812 local mtime1=`stat -c %Y $DIR1/$tfile`
2813 [ "$mtime1" = $TEST_39_MTIME ] || \
2814 error "mtime is not set to past: $mtime1, should be $TEST_39_MTIME"
2817 echo hello >> $DIR1/$tfile
2819 local mtime2=`stat -c %Y $DIR1/$tfile`
2820 [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] || \
2821 error "mtime is not updated on write: $d1 <= $mtime2 <= $d2"
2823 mv $DIR1/$tfile $DIR1/$tfile-1
2825 for (( i=0; i < 2; i++ )) ; do
2826 local mtime3=`stat -c %Y $DIR1/$tfile-1`
2827 [ "$mtime2" = "$mtime3" ] || \
2828 error "mtime ($mtime2) changed (to $mtime3) on rename"
2830 cancel_lru_locks osc
2831 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2834 run_test 39c "mtime change on rename ==========================="
2838 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2841 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2843 for (( i=0; i < 2; i++ )) ; do
2844 local mtime=`stat -c %Y $DIR1/$tfile`
2845 [ $mtime = $TEST_39_MTIME ] || \
2846 error "mtime($mtime) is not set to $TEST_39_MTIME"
2848 cancel_lru_locks osc
2849 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2852 run_test 39d "create, utime, stat =============================="
2856 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2858 local mtime1=`stat -c %Y $DIR1/$tfile`
2860 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2862 for (( i=0; i < 2; i++ )) ; do
2863 local mtime2=`stat -c %Y $DIR1/$tfile`
2864 [ $mtime2 = $TEST_39_MTIME ] || \
2865 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2867 cancel_lru_locks osc
2868 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2871 run_test 39e "create, stat, utime, stat ========================"
2875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2877 mtime1=`stat -c %Y $DIR1/$tfile`
2880 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2882 for (( i=0; i < 2; i++ )) ; do
2883 local mtime2=`stat -c %Y $DIR1/$tfile`
2884 [ $mtime2 = $TEST_39_MTIME ] || \
2885 error "mtime($mtime2) is not set to $TEST_39_MTIME"
2887 cancel_lru_locks osc
2888 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2891 run_test 39f "create, stat, sleep, utime, stat ================="
2895 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2896 echo hello >> $DIR1/$tfile
2897 local mtime1=`stat -c %Y $DIR1/$tfile`
2900 chmod o+r $DIR1/$tfile
2902 for (( i=0; i < 2; i++ )) ; do
2903 local mtime2=`stat -c %Y $DIR1/$tfile`
2904 [ "$mtime1" = "$mtime2" ] || \
2905 error "lost mtime: $mtime2, should be $mtime1"
2907 cancel_lru_locks osc
2908 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2911 run_test 39g "write, chmod, stat ==============================="
2915 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2920 echo hello >> $DIR1/$tfile
2921 local mtime1=`stat -c %Y $DIR1/$tfile`
2923 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
2925 if [ "$d1" != "$d2" ]; then
2926 echo "write and touch not within one second"
2928 for (( i=0; i < 2; i++ )) ; do
2929 local mtime2=`stat -c %Y $DIR1/$tfile`
2930 [ "$mtime2" = $TEST_39_MTIME ] || \
2931 error "lost mtime: $mtime2, should be $TEST_39_MTIME"
2933 cancel_lru_locks osc
2934 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2938 run_test 39h "write, utime within one second, stat ============="
2941 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2945 echo hello >> $DIR1/$tfile
2946 local mtime1=`stat -c %Y $DIR1/$tfile`
2948 mv $DIR1/$tfile $DIR1/$tfile-1
2950 for (( i=0; i < 2; i++ )) ; do
2951 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2953 [ "$mtime1" = "$mtime2" ] || \
2954 error "lost mtime: $mtime2, should be $mtime1"
2956 cancel_lru_locks osc
2957 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2960 run_test 39i "write, rename, stat =============================="
2963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2964 start_full_debug_logging
2968 #define OBD_FAIL_OSC_DELAY_SETTIME 0x412
2969 lctl set_param fail_loc=0x80000412
2970 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c ||
2971 error "multiop failed"
2973 local mtime1=`stat -c %Y $DIR1/$tfile`
2975 mv $DIR1/$tfile $DIR1/$tfile-1
2977 kill -USR1 $multipid
2978 wait $multipid || error "multiop close failed"
2980 for (( i=0; i < 2; i++ )) ; do
2981 local mtime2=`stat -c %Y $DIR1/$tfile-1`
2982 [ "$mtime1" = "$mtime2" ] ||
2983 error "mtime is lost on close: $mtime2, " \
2986 cancel_lru_locks osc
2987 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
2989 lctl set_param fail_loc=0
2990 stop_full_debug_logging
2992 run_test 39j "write, rename, close, stat ======================="
2995 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
2999 multiop_bg_pause $DIR1/$tfile oO_RDWR:w2097152_c || error "multiop failed"
3001 local mtime1=`stat -c %Y $DIR1/$tfile`
3003 touch -m -d @$TEST_39_MTIME $DIR1/$tfile
3005 kill -USR1 $multipid
3006 wait $multipid || error "multiop close failed"
3008 for (( i=0; i < 2; i++ )) ; do
3009 local mtime2=`stat -c %Y $DIR1/$tfile`
3011 [ "$mtime2" = $TEST_39_MTIME ] || \
3012 error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
3014 cancel_lru_locks osc
3015 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3018 run_test 39k "write, utime, close, stat ========================"
3020 # this should be set to future
3021 TEST_39_ATIME=`date -d "1 year" +%s`
3024 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3025 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3026 local atime_diff=$(do_facet $SINGLEMDS \
3027 lctl get_param -n mdd.*MDT0000*.atime_diff)
3031 # test setting directory atime to future
3032 touch -a -d @$TEST_39_ATIME $DIR/$tdir
3033 local atime=$(stat -c %X $DIR/$tdir)
3034 [ "$atime" = $TEST_39_ATIME ] || \
3035 error "atime is not set to future: $atime, $TEST_39_ATIME"
3037 # test setting directory atime from future to now
3038 local d1=$(date +%s)
3040 local d2=$(date +%s)
3042 cancel_lru_locks mdc
3043 atime=$(stat -c %X $DIR/$tdir)
3044 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3045 error "atime is not updated from future: $atime, $d1<atime<$d2"
3047 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=2
3050 # test setting directory atime when now > dir atime + atime_diff
3054 cancel_lru_locks mdc
3055 atime=$(stat -c %X $DIR/$tdir)
3056 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3057 error "atime is not updated : $atime, should be $d2"
3059 do_facet $SINGLEMDS lctl set_param -n mdd.*MDT0000*.atime_diff=60
3062 # test not setting directory atime when now < dir atime + atime_diff
3064 cancel_lru_locks mdc
3065 atime=$(stat -c %X $DIR/$tdir)
3066 [ "$atime" -ge "$d1" -a "$atime" -le "$d2" ] || \
3067 error "atime is updated to $atime, should remain $d1<atime<$d2"
3069 do_facet $SINGLEMDS \
3070 lctl set_param -n mdd.*MDT0000*.atime_diff=$atime_diff
3072 run_test 39l "directory atime update ==========================="
3075 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3078 local far_past_mtime=$(date -d "May 29 1953" +%s)
3079 local far_past_atime=$(date -d "Dec 17 1903" +%s)
3081 touch -m -d @$far_past_mtime $DIR1/$tfile
3082 touch -a -d @$far_past_atime $DIR1/$tfile
3084 for (( i=0; i < 2; i++ )) ; do
3085 local timestamps=$(stat -c "%X %Y" $DIR1/$tfile)
3086 [ "$timestamps" = "$far_past_atime $far_past_mtime" ] || \
3087 error "atime or mtime set incorrectly"
3089 cancel_lru_locks osc
3090 if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
3093 run_test 39m "test atime and mtime before 1970"
3096 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3097 $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/$tfile &&
3098 error "openfile O_WRONLY:O_TRUNC $tfile failed"
3099 $CHECKSTAT -t file -s 4096 $DIR/$tfile ||
3100 error "$tfile is not 4096 bytes in size"
3102 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
3106 small_write $DIR/f41 18
3108 run_test 41 "test small file write + fstat ====================="
3110 count_ost_writes() {
3111 lctl get_param -n osc.*.stats |
3112 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
3119 BG_DIRTY_RATIO_SAVE=10
3120 MAX_BG_DIRTY_RATIO=25
3124 # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
3125 # dirty_ratio, dirty_background_ratio
3126 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3127 sysctl -w vm.dirty_writeback_centisecs=$WRITEBACK_SAVE
3128 sysctl -w vm.dirty_background_ratio=$BG_DIRTY_RATIO_SAVE
3129 sysctl -w vm.dirty_ratio=$DIRTY_RATIO_SAVE
3131 # if file not here, we are a 2.4 kernel
3132 kill -CONT `pidof kupdated`
3137 # setup the trap first, so someone cannot exit the test at the
3138 # exact wrong time and mess up a machine
3139 trap start_writeback EXIT
3140 # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
3141 if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
3142 WRITEBACK_SAVE=`sysctl -n vm.dirty_writeback_centisecs`
3143 sysctl -w vm.dirty_writeback_centisecs=0
3144 sysctl -w vm.dirty_writeback_centisecs=0
3145 # save and increase /proc/sys/vm/dirty_ratio
3146 DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_ratio`
3147 sysctl -w vm.dirty_ratio=$MAX_DIRTY_RATIO
3148 # save and increase /proc/sys/vm/dirty_background_ratio
3149 BG_DIRTY_RATIO_SAVE=`sysctl -n vm.dirty_background_ratio`
3150 sysctl -w vm.dirty_background_ratio=$MAX_BG_DIRTY_RATIO
3152 # if file not here, we are a 2.4 kernel
3153 kill -STOP `pidof kupdated`
3157 # ensure that all stripes have some grant before we test client-side cache
3159 for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
3160 dd if=/dev/zero of=$i bs=4k count=1
3165 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
3166 # file truncation, and file removal.
3168 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3170 cancel_lru_locks osc
3172 sync; sleep 1; sync # just to be safe
3173 BEFOREWRITES=`count_ost_writes`
3174 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur_grant_bytes | grep "[0-9]"
3175 dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
3176 AFTERWRITES=`count_ost_writes`
3177 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3178 error "$BEFOREWRITES < $AFTERWRITES"
3181 run_test 42a "ensure that we don't flush on close =============="
3184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3186 cancel_lru_locks osc
3189 dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
3190 BEFOREWRITES=`count_ost_writes`
3191 $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
3192 AFTERWRITES=`count_ost_writes`
3193 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3194 error "$BEFOREWRITES < $AFTERWRITES on unlink"
3196 BEFOREWRITES=`count_ost_writes`
3197 sync || error "sync: $?"
3198 AFTERWRITES=`count_ost_writes`
3199 if [ $BEFOREWRITES -lt $AFTERWRITES ]; then
3200 error "$BEFOREWRITES < $AFTERWRITES on sync"
3202 dmesg | grep 'error from obd_brw_async' && error 'error writing back'
3206 run_test 42b "test destroy of file with cached dirty data ======"
3208 # if these tests just want to test the effect of truncation,
3209 # they have to be very careful. consider:
3210 # - the first open gets a {0,EOF}PR lock
3211 # - the first write conflicts and gets a {0, count-1}PW
3212 # - the rest of the writes are under {count,EOF}PW
3213 # - the open for truncate tries to match a {0,EOF}PR
3214 # for the filesize and cancels the PWs.
3215 # any number of fixes (don't get {0,EOF} on open, match
3216 # composite locks, do smarter file size management) fix
3217 # this, but for now we want these tests to verify that
3218 # the cancellation with truncate intent works, so we
3219 # start the file with a full-file pw lock to match against
3220 # until the truncate.
3225 cancel_lru_locks osc
3227 # prime the file with 0,EOF PW to match
3231 # now the real test..
3232 dd if=/dev/zero of=$file bs=1024 count=100
3233 BEFOREWRITES=`count_ost_writes`
3234 $TRUNCATE $file $offset
3235 cancel_lru_locks osc
3236 AFTERWRITES=`count_ost_writes`
3241 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3243 [ $BEFOREWRITES -eq $AFTERWRITES ] && \
3244 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
3247 run_test 42c "test partial truncate of file with cached dirty data"
3250 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3252 [ $BEFOREWRITES -eq $AFTERWRITES ] || \
3253 error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
3256 run_test 42d "test complete truncate of file with cached dirty data"
3258 test_42e() { # bug22074
3259 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3260 local TDIR=$DIR/${tdir}e
3261 local pagesz=$(page_size)
3262 local pages=16 # hardcoded 16 pages, don't change it.
3263 local files=$((OSTCOUNT * 500)) # hopefully 500 files on each OST
3264 local proc_osc0="osc.${FSNAME}-OST0000-osc-[^MDT]*"
3268 test_mkdir -p $DIR/${tdir}e
3269 $SETSTRIPE -c 1 $TDIR
3270 createmany -o $TDIR/f $files
3272 max_dirty_mb=$($LCTL get_param -n $proc_osc0/max_dirty_mb)
3274 # we assume that with $OSTCOUNT files, at least one of them will
3275 # be allocated on OST0.
3276 warmup_files=$((OSTCOUNT * max_dirty_mb))
3277 createmany -o $TDIR/w $warmup_files
3279 # write a large amount of data into one file and sync, to get good
3280 # avail_grant number from OST.
3281 for ((i=0; i<$warmup_files; i++)); do
3282 idx=$($GETSTRIPE -i $TDIR/w$i)
3283 [ $idx -ne 0 ] && continue
3284 dd if=/dev/zero of=$TDIR/w$i bs="$max_dirty_mb"M count=1
3287 [ $i -gt $warmup_files ] && error "OST0 is still cold"
3289 $LCTL get_param $proc_osc0/cur_dirty_bytes
3290 $LCTL get_param $proc_osc0/cur_grant_bytes
3292 # create as much dirty pages as we can while not to trigger the actual
3293 # RPCs directly. but depends on the env, VFS may trigger flush during this
3294 # period, hopefully we are good.
3295 for ((i=0; i<$warmup_files; i++)); do
3296 idx=$($GETSTRIPE -i $TDIR/w$i)
3297 [ $idx -ne 0 ] && continue
3298 dd if=/dev/zero of=$TDIR/w$i bs=1M count=1 2>/dev/null
3300 $LCTL get_param $proc_osc0/cur_dirty_bytes
3301 $LCTL get_param $proc_osc0/cur_grant_bytes
3303 # perform the real test
3304 $LCTL set_param $proc_osc0/rpc_stats 0
3305 for ((;i<$files; i++)); do
3306 [ $($GETSTRIPE -i $TDIR/f$i) -eq 0 ] || continue
3307 dd if=/dev/zero of=$TDIR/f$i bs=$pagesz count=$pages 2>/dev/null
3310 $LCTL get_param $proc_osc0/rpc_stats
3313 local have_ppr=false
3314 $LCTL get_param $proc_osc0/rpc_stats |
3315 while read PPR RRPC RPCT RCUM BAR WRPC WPCT WCUM; do
3316 # skip lines until we are at the RPC histogram data
3317 [ "$PPR" == "pages" ] && have_ppr=true && continue
3318 $have_ppr || continue
3320 # we only want the percent stat for < 16 pages
3321 [ $(echo $PPR | tr -d ':') -ge $pages ] && break
3323 percent=$((percent + WPCT))
3324 if [ $percent -gt 15 ]; then
3325 error "less than 16-pages write RPCs" \
3332 run_test 42e "verify sub-RPC writes are not done synchronously"
3335 test_mkdir -p $DIR/$tdir
3336 cp -p /bin/ls $DIR/$tdir/$tfile
3337 $MULTIOP $DIR/$tdir/$tfile Ow_c &
3339 # give multiop a chance to open
3342 $DIR/$tdir/$tfile && error || true
3345 run_test 43 "execution of file opened for write should return -ETXTBSY"
3348 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3349 test_mkdir -p $DIR/$tdir
3350 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3351 cp -p multiop $DIR/$tdir/multiop
3352 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3355 $MULTIOP $DIR/$tdir/multiop Oc && error "expected error, got success"
3356 kill -USR1 $MULTIOP_PID || return 2
3357 wait $MULTIOP_PID || return 3
3360 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
3363 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3364 test_mkdir -p $DIR/$tdir
3365 cp -p `which $MULTIOP` $DIR/$tdir/multiop ||
3366 cp -p multiop $DIR/$tdir/multiop
3367 MULTIOP_PROG=$DIR/$tdir/multiop multiop_bg_pause $TMP/test43.junk O_c ||
3370 $TRUNCATE $DIR/$tdir/multiop 0 && error "expected error, got success"
3371 kill -USR1 $MULTIOP_PID || return 2
3372 wait $MULTIOP_PID || return 3
3375 run_test 43b "truncate of file being executed should return -ETXTBSY"
3378 local testdir="$DIR/$tdir"
3379 test_mkdir -p $DIR/$tdir
3381 ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
3382 ( cd $testdir && md5sum -c)
3384 run_test 43c "md5sum of copy into lustre========================"
3387 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
3388 dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
3389 dd if=$DIR/f1 bs=4k count=1 > /dev/null
3391 run_test 44 "zero length read from a sparse stripe ============="
3394 local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
3396 [ -z "$nstripe" ] && skip "can't get stripe info" && return
3397 [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
3398 local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
3400 if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then
3401 nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
3404 OFFSETS="0 $((stride/2)) $((stride-1))"
3405 for offset in $OFFSETS ; do
3406 for i in `seq 0 $((nstripe-1))`; do
3407 local GLOBALOFFSETS=""
3408 local size=$((((i + 2 * $nstripe )*$stride + $offset))) # Bytes
3409 local myfn=$DIR/d44a-$size
3410 echo "--------writing $myfn at $size"
3411 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3412 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3413 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3414 || error "ll_sparseness_verify $GLOBALOFFSETS"
3416 for j in `seq 0 $((nstripe-1))`; do
3417 size=$((((j + $nstripe )*$stride + $offset))) # Bytes
3418 ll_sparseness_write $myfn $size || error "ll_sparseness_write"
3419 GLOBALOFFSETS="$GLOBALOFFSETS $size"
3421 ll_sparseness_verify $myfn $GLOBALOFFSETS \
3422 || error "ll_sparseness_verify $GLOBALOFFSETS"
3427 run_test 44a "test sparse pwrite ==============================="
3431 for d in `lctl get_param -n osc.*.cur_dirty_bytes`; do
3437 before=`dirty_osc_total`
3438 echo executing "\"$*\""
3440 after=`dirty_osc_total`
3441 echo before $before, after $after
3444 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3446 # Obtain grants from OST if it supports it
3447 echo blah > ${f}_grant
3450 do_dirty_record "echo blah > $f"
3451 [ $before -eq $after ] && error "write wasn't cached"
3452 do_dirty_record "> $f"
3453 [ $before -gt $after ] || error "truncate didn't lower dirty count"
3454 do_dirty_record "echo blah > $f"
3455 [ $before -eq $after ] && error "write wasn't cached"
3456 do_dirty_record "sync"
3457 [ $before -gt $after ] || error "writeback didn't lower dirty count"
3458 do_dirty_record "echo blah > $f"
3459 [ $before -eq $after ] && error "write wasn't cached"
3460 do_dirty_record "cancel_lru_locks osc"
3461 [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
3464 run_test 45 "osc io page accounting ============================"
3466 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object. this
3467 # test tickles a bug where re-dirtying a page was failing to be mapped to the
3468 # objects offset and an assert hit when an rpc was built with 1023's mapped
3469 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
3471 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3475 dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3477 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
3478 dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
3482 run_test 46 "dirtying a previously written page ================"
3484 # test_47 is removed "Device nodes check" is moved to test_28
3486 test_48a() { # bug 2399
3487 check_kernel_version 34 || return 0
3488 test_mkdir -p $DIR/$tdir
3490 mv $DIR/$tdir $DIR/d48.new || error "move directory failed"
3491 test_mkdir $DIR/$tdir || error "recreate directory failed"
3492 touch foo || error "'touch foo' failed after recreating cwd"
3493 test_mkdir $DIR/$tdir/bar ||
3494 error "'mkdir foo' failed after recreating cwd"
3495 if check_kernel_version 44; then
3496 touch .foo || error "'touch .foo' failed after recreating cwd"
3497 test_mkdir $DIR/$tdir/.bar ||
3498 error "'mkdir .foo' failed after recreating cwd"
3500 ls . > /dev/null || error "'ls .' failed after recreating cwd"
3501 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3502 cd . || error "'cd .' failed after recreating cwd"
3503 test_mkdir . && error "'mkdir .' worked after recreating cwd"
3504 rmdir . && error "'rmdir .' worked after recreating cwd"
3505 ln -s . baz || error "'ln -s .' failed after recreating cwd"
3506 cd .. || error "'cd ..' failed after recreating cwd"
3508 run_test 48a "Access renamed working dir (should return errors)="
3510 test_48b() { # bug 2399
3511 check_kernel_version 34 || return 0
3513 test_mkdir -p $DIR/$tdir
3515 rmdir $DIR/$tdir || error "remove cwd $DIR/$tdir failed"
3516 touch foo && error "'touch foo' worked after removing cwd"
3517 test_mkdir $DIR/$tdir/foo &&
3518 error "'mkdir foo' worked after removing cwd"
3519 if check_kernel_version 44; then
3520 touch .foo && error "'touch .foo' worked after removing cwd"
3521 test_mkdir $DIR/$tdir/.foo &&
3522 error "'mkdir .foo' worked after removing cwd"
3524 ls . > /dev/null && error "'ls .' worked after removing cwd"
3525 ls .. > /dev/null || error "'ls ..' failed after removing cwd"
3526 is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
3527 test_mkdir $DIR/$tdir/. && error "'mkdir .' worked after removing cwd"
3528 rmdir . && error "'rmdir .' worked after removing cwd"
3529 ln -s . foo && error "'ln -s .' worked after removing cwd"
3530 cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3517
3532 run_test 48b "Access removed working dir (should return errors)="
3534 test_48c() { # bug 2350
3535 check_kernel_version 36 || return 0
3536 #lctl set_param debug=-1
3539 test_mkdir -p $DIR/$tdir/dir
3541 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3542 $TRACE touch foo && error "touch foo worked after removing cwd"
3543 $TRACE test_mkdir foo && error "'mkdir foo' worked after removing cwd"
3544 if check_kernel_version 44; then
3545 touch .foo && error "touch .foo worked after removing cwd"
3546 test_mkdir .foo && error "mkdir .foo worked after removing cwd"
3548 $TRACE ls . && error "'ls .' worked after removing cwd"
3549 $TRACE ls .. || error "'ls ..' failed after removing cwd"
3550 is_patchless || ( $TRACE cd . &&
3551 error "'cd .' worked after removing cwd" )
3552 $TRACE test_mkdir . && error "'mkdir .' worked after removing cwd"
3553 $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
3554 $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
3555 $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
3557 run_test 48c "Access removed working subdir (should return errors)"
3559 test_48d() { # bug 2350
3560 check_kernel_version 36 || return 0
3561 #lctl set_param debug=-1
3564 test_mkdir -p $DIR/$tdir/dir
3566 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3567 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3568 $TRACE touch foo && error "'touch foo' worked after removing parent"
3569 $TRACE test_mkdir foo && error "mkdir foo worked after removing parent"
3570 if check_kernel_version 44; then
3571 touch .foo && error "'touch .foo' worked after removing parent"
3573 error "mkdir .foo worked after removing parent"
3575 $TRACE ls . && error "'ls .' worked after removing parent"
3576 $TRACE ls .. && error "'ls ..' worked after removing parent"
3577 is_patchless || ( $TRACE cd . &&
3578 error "'cd .' worked after recreate parent" )
3579 $TRACE test_mkdir . && error "'mkdir .' worked after removing parent"
3580 $TRACE rmdir . && error "'rmdir .' worked after removing parent"
3581 $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
3582 is_patchless || ( $TRACE cd .. &&
3583 error "'cd ..' worked after removing parent" || true )
3585 run_test 48d "Access removed parent subdir (should return errors)"
3587 test_48e() { # bug 4134
3588 check_kernel_version 41 || return 0
3589 #lctl set_param debug=-1
3592 test_mkdir -p $DIR/$tdir/dir
3594 $TRACE rmdir $DIR/$tdir/dir || error "remove cwd $DIR/$tdir/dir failed"
3595 $TRACE rmdir $DIR/$tdir || error "remove parent $DIR/$tdir failed"
3596 $TRACE touch $DIR/$tdir || error "'touch $DIR/$tdir' failed"
3597 $TRACE chmod +x $DIR/$tdir || error "'chmod +x $DIR/$tdir' failed"
3598 # On a buggy kernel addition of "touch foo" after cd .. will
3599 # produce kernel oops in lookup_hash_it
3600 touch ../foo && error "'cd ..' worked after recreate parent"
3602 $TRACE rm $DIR/$tdir || error "rm '$DIR/$tdir' failed"
3604 run_test 48e "Access to recreated parent subdir (should return errors)"
3606 test_49() { # LU-1030
3607 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3608 # get ost1 size - lustre-OST0000
3609 ost1_size=$(do_facet ost1 lfs df |grep ${ost1_svc} |awk '{print $4}')
3610 # write 800M at maximum
3611 [ $ost1_size -gt 819200 ] && ost1_size=819200
3613 lfs setstripe -c 1 -i 0 $DIR/$tfile
3614 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((ost1_size >> 2)) &
3617 # change max_pages_per_rpc while writing the file
3618 local osc1_mppc=osc.$(get_osc_import_name client ost1).max_pages_per_rpc
3619 local orig_mppc=`$LCTL get_param -n $osc1_mppc`
3620 # loop until dd process exits
3621 while ps ax -opid | grep -wq $dd_pid; do
3622 $LCTL set_param $osc1_mppc=$((RANDOM % 256 + 1))
3623 sleep $((RANDOM % 5 + 1))
3625 # restore original max_pages_per_rpc
3626 $LCTL set_param $osc1_mppc=$orig_mppc
3627 rm $DIR/$tfile || error "rm $DIR/$tfile failed"
3629 run_test 49 "Change max_pages_per_rpc won't break osc extent"
3633 test_mkdir $DIR/$tdir
3635 ls /proc/$$/cwd || error "ls /proc/$$/cwd failed"
3637 run_test 50 "special situations: /proc symlinks ==============="
3639 test_51a() { # was test_51
3640 # bug 1516 - create an empty entry right after ".." then split dir
3641 test_mkdir -p $DIR/$tdir
3642 touch $DIR/$tdir/foo
3643 $MCREATE $DIR/$tdir/bar
3645 createmany -m $DIR/$tdir/longfile 201
3647 while [ $(ls -sd $DIR/$tdir | awk '{ print $1 }') -eq 4 ]; do
3648 $MCREATE $DIR/$tdir/longfile$FNUM
3653 ls -l $DIR/$tdir > /dev/null || error "ls -l $DIR/$tdir failed"
3655 run_test 51a "special situations: split htree with empty entry =="
3657 export NUMTEST=70000
3659 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3660 local BASE=$DIR/$tdir
3662 # cleanup the directory
3667 local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
3668 local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
3669 [ $numfree -lt 21000 ] && skip "not enough free inodes ($numfree)" &&
3672 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3673 echo "reduced count to $NUMTEST due to inodes"
3675 # need to check free space for the directories as well
3676 local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
3677 numfree=$((blkfree / 4))
3678 [ $numfree -lt $NUMTEST ] && NUMTEST=$(($numfree - 50)) &&
3679 echo "reduced count to $NUMTEST due to blocks"
3681 createmany -d $BASE/d $NUMTEST && echo $NUMTEST > $BASE/fnum ||
3682 echo "failed" > $BASE/fnum
3684 run_test 51b "exceed 64k subdirectory nlink limit"
3686 test_51ba() { # LU-993
3687 local BASE=$DIR/$tdir
3688 # unlink all but 100 subdirectories, then check it still works
3690 [ -f $BASE/fnum ] && local NUMPREV=$(cat $BASE/fnum) && rm $BASE/fnum
3692 [ "$NUMPREV" != "failed" ] && NUMTEST=$NUMPREV
3693 local DELETE=$((NUMTEST - LEFT))
3695 # continue on to run this test even if 51b didn't finish,
3696 # just to delete the many subdirectories created.
3697 [ ! -d "${BASE}/d1" ] && skip "test_51b() not run" && return 0
3699 # for ldiskfs the nlink count should be 1, but this is OSD specific
3700 # and so this is listed for informational purposes only
3701 echo "nlink before: $(stat -c %h $BASE), created before: $NUMTEST"
3702 unlinkmany -d $BASE/d $DELETE
3705 if [ $RC -ne 0 ]; then
3706 if [ "$NUMPREV" == "failed" ]; then
3707 skip "previous setup failed"
3710 error "unlink of first $DELETE subdirs failed"
3715 echo "nlink between: $(stat -c %h $BASE)"
3716 # trim the first line of ls output
3717 local FOUND=$(($(ls -l ${BASE} | wc -l) - 1))
3718 [ $FOUND -ne $LEFT ] &&
3719 error "can't find subdirs: found only $FOUND/$LEFT"
3721 unlinkmany -d $BASE/d $DELETE $LEFT ||
3722 error "unlink of second $LEFT subdirs failed"
3723 # regardless of whether the backing filesystem tracks nlink accurately
3724 # or not, the nlink count shouldn't be more than "." and ".." here
3725 local AFTER=$(stat -c %h $BASE)
3726 [ $AFTER -gt 2 ] && error "nlink after: $AFTER > 2" ||
3727 echo "nlink after: $AFTER"
3729 run_test 51ba "verify nlink for many subdirectory cleanup"
3732 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3733 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping test with few OSTs" && return
3734 test_mkdir -p $DIR/$tdir
3735 createmany -o $DIR/$tdir/t- 1000
3736 $GETSTRIPE $DIR/$tdir > $TMP/files
3737 for N in `seq 0 $((OSTCOUNT - 1))`; do
3738 OBJS[$N]=`awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}' $TMP/files`
3739 OBJS0[$N]=`grep -A 1 idx $TMP/files | awk -vobjs=0 '($1 == '$N') { objs += 1 } END { print objs;}'`
3740 log "OST$N has ${OBJS[$N]} objects, ${OBJS0[$N]} are index 0"
3742 unlinkmany $DIR/$tdir/t- 1000
3745 for N in `seq 1 $((OSTCOUNT - 1))`; do
3746 [ ${OBJS[$N]} -lt $((${OBJS[$NLAST]} - 20)) ] && \
3747 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3748 [ ${OBJS[$N]} -gt $((${OBJS[$NLAST]} + 20)) ] && \
3749 error "OST $N has less objects vs OST $NLAST (${OBJS[$N]} < ${OBJS[$NLAST]}"
3751 [ ${OBJS0[$N]} -lt $((${OBJS0[$NLAST]} - 20)) ] && \
3752 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3753 [ ${OBJS0[$N]} -gt $((${OBJS0[$NLAST]} + 20)) ] && \
3754 error "OST $N has less #0 objects vs OST $NLAST (${OBJS0[$N]} < ${OBJS0[$NLAST]}"
3758 run_test 51d "check object distribution ===================="
3761 [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
3762 test_mkdir -p $DIR/$tdir
3763 touch $DIR/$tdir/foo
3764 chattr +a $DIR/$tdir/foo || error "chattr +a failed"
3765 echo bar >> $DIR/$tdir/foo || error "append bar failed"
3766 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3767 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3768 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3770 echo foo >> $DIR/$tdir/foo || error "append foo failed"
3771 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3772 lsattr $DIR/$tdir/foo | egrep -q "^-+a[-e]+ $DIR/$tdir/foo" ||
3774 chattr -a $DIR/$tdir/foo || error "chattr -a failed"
3775 cp -r $DIR/$tdir /tmp/
3776 rm -fr $DIR/$tdir || error "cleanup rm failed"
3778 run_test 52a "append-only flag test (should return errors) ====="
3781 [ -f $DIR/$tdir/foo ] && chattr -i $DIR/$tdir/foo
3782 test_mkdir -p $DIR/$tdir
3783 touch $DIR/$tdir/foo
3784 chattr +i $DIR/$tdir/foo || error "chattr +i failed"
3785 cat test > $DIR/$tdir/foo && error "cat test worked"
3786 cp /etc/hosts $DIR/$tdir/foo && error "cp worked"
3787 rm -f $DIR/$tdir/foo 2>/dev/null && error "rm worked"
3788 link $DIR/$tdir/foo $DIR/$tdir/foo_link 2>/dev/null &&
3790 echo foo >> $DIR/$tdir/foo && error "echo worked"
3791 mrename $DIR/$tdir/foo $DIR/$tdir/foo_ren && error "rename worked"
3792 [ -f $DIR/$tdir/foo ] || error "$tdir/foo is not a file"
3793 [ -f $DIR/$tdir/foo_ren ] && error "$tdir/foo_ren is not a file"
3794 lsattr $DIR/$tdir/foo | egrep -q "^-+i[-e]+ $DIR/$tdir/foo" ||
3796 chattr -i $DIR/$tdir/foo || error "chattr failed"
3798 rm -fr $DIR/$tdir || error "unable to remove $DIR/$tdir"
3800 run_test 52b "immutable flag test (should return errors) ======="
3803 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3804 remote_mds_nodsh && skip "remote MDS with nodsh" && return
3805 remote_ost_nodsh && skip "remote OST with nodsh" && return
3820 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS)
3821 for value in $(do_facet $SINGLEMDS lctl get_param osc.$mdtosc.prealloc_last_id) ; do
3822 param=$(echo ${value[0]} | cut -d "=" -f1)
3823 ostname=$(echo $param | cut -d "." -f2 | cut -d - -f 1-2)
3824 param_seq=$(echo ${param} |
3825 sed -e s/prealloc_last_id/prealloc_last_seq/g)
3826 mds_last_seq=$(do_facet $SINGLEMDS lctl get_param -n $param_seq)
3827 mds_last=$(do_facet $SINGLEMDS lctl get_param -n $param)
3829 ostnum=$(index_from_ostuuid ${ostname}_UUID)
3830 node=$(facet_active_host ost$((ostnum+1)))
3831 param="obdfilter.$ostname.last_id"
3832 for ost_last in $(do_node $node lctl get_param -n $param) ; do
3833 echo "$ostname.last_id=$ost_last ;MDS.last_id=$mds_last"
3834 ost_last_id=$(echo $ost_last | awk -F':' '{print $2}' |
3836 ost_last_seq=$(echo $ost_last | awk -F':' '{print $1}')
3837 if [ $ost_last_seq = $mds_last_seq ]; then
3838 if [ $ost_last_id != $mds_last ]; then
3839 error "$ost_last != $mds_last_id"
3847 [ $found = 0 ] && error "can not match last_seq/last_id for $mdtosc"
3850 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
3853 [ ! -f "$SOCKETSERVER" ] &&
3854 skip_env "no socketserver, skipping" && return
3855 [ ! -f "$SOCKETCLIENT" ] &&
3856 skip_env "no socketclient, skipping" && return
3857 $SOCKETSERVER $DIR/socket
3858 $SOCKETCLIENT $DIR/socket || error "$SOCKETCLIENT $DIR/socket failed"
3859 $MUNLINK $DIR/socket
3861 run_test 54a "unix domain socket test =========================="
3867 dd if=/dev/zero of=$f bs=$(page_size) count=1
3869 run_test 54b "char device works in lustre ======================"
3872 [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
3873 [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
3874 [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
3876 for i in $(seq 3 7); do
3877 losetup $LOOPBASE$i > /dev/null 2>&1 && continue
3885 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
3888 loopdev="$DIR/loop54c"
3891 [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
3892 mknod $loopdev b 7 $LOOPNUM
3893 echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
3894 dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
3895 losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
3896 mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
3898 mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
3899 dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
3901 dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
3906 run_test 54c "block device works in lustre ====================="
3912 [ "$string" = $(echo $string > $f | cat $f) ] || error "$f != $string"
3914 run_test 54d "fifo device works in lustre ======================"
3917 check_kernel_version 46 || return 0
3920 cp -aL /dev/console $f
3921 echo $string > $f || error "echo $string to $f failed"
3923 run_test 54e "console/tty device works in lustre ======================"
3925 #The test_55 used to be iopen test and it was removed by bz#24037.
3926 #run_test 55 "check iopen_connect_dentry() ======================"
3928 test_56a() { # was test_56
3931 test_mkdir $DIR/$tdir
3932 test_mkdir $DIR/$tdir/dir
3934 NUMFILESx2=$(($NUMFILES * 2))
3935 for i in `seq 1 $NUMFILES` ; do
3936 touch $DIR/$tdir/file$i
3937 touch $DIR/$tdir/dir/file$i
3940 # test lfs getstripe with --recursive
3941 FILENUM=`$GETSTRIPE --recursive $DIR/$tdir | grep -c obdidx`
3942 [ $FILENUM -eq $NUMFILESx2 ] ||
3943 error "$GETSTRIPE --recursive: found $FILENUM, not $NUMFILESx2"
3944 FILENUM=`$GETSTRIPE $DIR/$tdir | grep -c obdidx`
3945 [ $FILENUM -eq $NUMFILES ] ||
3946 error "$GETSTRIPE $DIR/$tdir: found $FILENUM, not $NUMFILES"
3947 echo "$GETSTRIPE --recursive passed."
3949 # test lfs getstripe with file instead of dir
3950 FILENUM=`$GETSTRIPE $DIR/$tdir/file1 | grep -c obdidx`
3951 [ $FILENUM -eq 1 ] || error \
3952 "$GETSTRIPE $DIR/$tdir/file1: found $FILENUM, not 1"
3953 echo "$GETSTRIPE file1 passed."
3955 #test lfs getstripe with --verbose
3956 [ `$GETSTRIPE --verbose $DIR/$tdir |
3957 grep -c lmm_magic` -eq $NUMFILES ] ||
3958 error "$GETSTRIPE --verbose $DIR/$tdir: want $NUMFILES"
3959 [ `$GETSTRIPE $DIR/$tdir | grep -c lmm_magic` -eq 0 ] ||
3960 error "$GETSTRIPE $DIR/$tdir: showed lmm_magic"
3961 echo "$GETSTRIPE --verbose passed."
3963 #test lfs getstripe with --obd
3964 $GETSTRIPE --obd wrong_uuid $DIR/$tdir 2>&1 |
3965 grep -q "unknown obduuid" ||
3966 error "$GETSTRIPE --obd wrong_uuid should return error message"
3968 [ "$OSTCOUNT" -lt 2 ] &&
3969 skip_env "skipping other $GETSTRIPE --obd test" && return
3972 OBDUUID=$(ostuuid_from_index $OSTIDX)
3973 FILENUM=`$GETSTRIPE -ir $DIR/$tdir | grep -x $OSTIDX | wc -l`
3974 FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/$tdir | grep obdidx | wc -l`
3975 [ $FOUND -eq $FILENUM ] ||
3976 error "$GETSTRIPE --obd wrong: found $FOUND, expected $FILENUM"
3977 [ `$GETSTRIPE -r -v --obd $OBDUUID $DIR/$tdir |
3978 sed '/^[ ]*'${OSTIDX}'[ ]/d' |
3979 sed -n '/^[ ]*[0-9][0-9]*[ ]/p' | wc -l` -eq 0 ] ||
3980 error "$GETSTRIPE --obd: should not show file on other obd"
3981 echo "$GETSTRIPE --obd passed"
3983 run_test 56a "check $GETSTRIPE"
3988 local LOCAL_NUMFILES="$1"
3989 local LOCAL_NUMDIRS="$2"
3990 local MKDIR_PARAMS="$3"
3992 if [ ! -d "$TDIR" ] ; then
3994 [ "$MKDIR_PARAMS" ] && $SETSTRIPE $MKDIR_PARAMS $TDIR
3995 for i in `seq 1 $LOCAL_NUMFILES` ; do
3998 for i in `seq 1 $LOCAL_NUMDIRS` ; do
3999 test_mkdir $TDIR/dir$i
4000 for j in `seq 1 $LOCAL_NUMFILES` ; do
4001 touch $TDIR/dir$i/file$j
4007 setup_56_special() {
4011 if [ ! -e "$TDIR/loop1b" ] ; then
4012 for i in `seq 1 $LOCAL_NUMFILES` ; do
4013 mknod $TDIR/loop${i}b b 7 $i
4014 mknod $TDIR/null${i}c c 1 3
4015 ln -s $TDIR/file1 $TDIR/link${i}l
4017 for i in `seq 1 $LOCAL_NUMDIRS` ; do
4018 mknod $TDIR/dir$i/loop${i}b b 7 $i
4019 mknod $TDIR/dir$i/null${i}c c 1 3
4020 ln -s $TDIR/dir$i/file1 $TDIR/dir$i/link${i}l
4029 setup_56 $NUMFILES $NUMDIRS
4031 EXPECTED=$(($NUMDIRS + 2))
4032 # test lfs find with -name
4033 for i in $(seq 1 $NUMFILES) ; do
4034 NUMS=$($LFIND -name "*$i" $TDIR | wc -l)
4035 [ $NUMS -eq $EXPECTED ] ||
4036 error "lfs find -name \"*$i\" $TDIR wrong: "\
4037 "found $NUMS, expected $EXPECTED"
4040 run_test 56g "check lfs find -name ============================="
4046 setup_56 $NUMFILES $NUMDIRS
4048 EXPECTED=$(((NUMDIRS + 1) * (NUMFILES - 1) + NUMFILES))
4049 # test lfs find with ! -name
4050 for i in $(seq 1 $NUMFILES) ; do
4051 NUMS=$($LFIND ! -name "*$i" $TDIR | wc -l)
4052 [ $NUMS -eq $EXPECTED ] ||
4053 error "lfs find ! -name \"*$i\" $TDIR wrong: "\
4054 "found $NUMS, expected $EXPECTED"
4057 run_test 56h "check lfs find ! -name ============================="
4061 test_mkdir -p $DIR/$tdir
4062 UUID=$(ostuuid_from_index 0 $DIR/$tdir)
4063 CMD="$LFIND -ost $UUID $DIR/$tdir"
4065 [ -z "$OUT" ] || error "\"$CMD\" returned directory '$OUT'"
4067 run_test 56i "check 'lfs find -ost UUID' skips directories ======="
4071 setup_56_special $NUMFILES $NUMDIRS
4073 EXPECTED=$((NUMDIRS + 1))
4074 CMD="$LFIND -type d $TDIR"
4075 NUMS=$($CMD | wc -l)
4076 [ $NUMS -eq $EXPECTED ] ||
4077 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4079 run_test 56j "check lfs find -type d ============================="
4083 setup_56_special $NUMFILES $NUMDIRS
4085 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4086 CMD="$LFIND -type f $TDIR"
4087 NUMS=$($CMD | wc -l)
4088 [ $NUMS -eq $EXPECTED ] ||
4089 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4091 run_test 56k "check lfs find -type f ============================="
4095 setup_56_special $NUMFILES $NUMDIRS
4097 EXPECTED=$((NUMDIRS + NUMFILES))
4098 CMD="$LFIND -type b $TDIR"
4099 NUMS=$($CMD | wc -l)
4100 [ $NUMS -eq $EXPECTED ] ||
4101 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4103 run_test 56l "check lfs find -type b ============================="
4107 setup_56_special $NUMFILES $NUMDIRS
4109 EXPECTED=$((NUMDIRS + NUMFILES))
4110 CMD="$LFIND -type c $TDIR"
4111 NUMS=$($CMD | wc -l)
4112 [ $NUMS -eq $EXPECTED ] ||
4113 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4115 run_test 56m "check lfs find -type c ============================="
4119 setup_56_special $NUMFILES $NUMDIRS
4121 EXPECTED=$((NUMDIRS + NUMFILES))
4122 CMD="$LFIND -type l $TDIR"
4123 NUMS=$($CMD | wc -l)
4124 [ $NUMS -eq $EXPECTED ] ||
4125 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4127 run_test 56n "check lfs find -type l ============================="
4131 setup_56 $NUMFILES $NUMDIRS
4133 utime $TDIR/file1 > /dev/null || error "utime (1)"
4134 utime $TDIR/file2 > /dev/null || error "utime (2)"
4135 utime $TDIR/dir1 > /dev/null || error "utime (3)"
4136 utime $TDIR/dir2 > /dev/null || error "utime (4)"
4137 utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
4138 dd if=/dev/zero count=1 >> $TDIR/dir1/file1 && sync
4141 NUMS=`$LFIND -mtime +0 $TDIR | wc -l`
4142 [ $NUMS -eq $EXPECTED ] || \
4143 error "lfs find -mtime +0 $TDIR wrong: found $NUMS, expected $EXPECTED"
4146 CMD="$LFIND -mtime 0 $TDIR"
4147 NUMS=$($CMD | wc -l)
4148 [ $NUMS -eq $EXPECTED ] ||
4149 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4151 run_test 56o "check lfs find -mtime for old files =========================="
4154 [ $RUNAS_ID -eq $UID ] &&
4155 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4158 setup_56 $NUMFILES $NUMDIRS
4160 chown $RUNAS_ID $TDIR/file* || error "chown $DIR/${tdir}g/file$i failed"
4162 CMD="$LFIND -uid $RUNAS_ID $TDIR"
4163 NUMS=$($CMD | wc -l)
4164 [ $NUMS -eq $EXPECTED ] || \
4165 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4167 EXPECTED=$(((NUMFILES + 1) * NUMDIRS + 1))
4168 CMD="$LFIND ! -uid $RUNAS_ID $TDIR"
4169 NUMS=$($CMD | wc -l)
4170 [ $NUMS -eq $EXPECTED ] || \
4171 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4173 run_test 56p "check lfs find -uid and ! -uid ==============================="
4176 [ $RUNAS_ID -eq $UID ] &&
4177 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
4180 setup_56 $NUMFILES $NUMDIRS
4182 chgrp $RUNAS_GID $TDIR/file* || error "chown $TDIR/file$i failed"
4185 CMD="$LFIND -gid $RUNAS_GID $TDIR"
4186 NUMS=$($CMD | wc -l)
4187 [ $NUMS -eq $EXPECTED ] ||
4188 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4190 EXPECTED=$(( ($NUMFILES+1) * $NUMDIRS + 1))
4191 CMD="$LFIND ! -gid $RUNAS_GID $TDIR"
4192 NUMS=$($CMD | wc -l)
4193 [ $NUMS -eq $EXPECTED ] ||
4194 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4196 run_test 56q "check lfs find -gid and ! -gid ==============================="
4200 setup_56 $NUMFILES $NUMDIRS
4203 CMD="$LFIND -size 0 -type f $TDIR"
4204 NUMS=$($CMD | wc -l)
4205 [ $NUMS -eq $EXPECTED ] ||
4206 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4208 CMD="$LFIND ! -size 0 -type f $TDIR"
4209 NUMS=$($CMD | wc -l)
4210 [ $NUMS -eq $EXPECTED ] ||
4211 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4212 echo "test" > $TDIR/$tfile
4213 echo "test2" > $TDIR/$tfile.2 && sync
4215 CMD="$LFIND -size 5 -type f $TDIR"
4216 NUMS=$($CMD | wc -l)
4217 [ $NUMS -eq $EXPECTED ] ||
4218 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4220 CMD="$LFIND -size +5 -type f $TDIR"
4221 NUMS=$($CMD | wc -l)
4222 [ $NUMS -eq $EXPECTED ] ||
4223 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4225 CMD="$LFIND -size +0 -type f $TDIR"
4226 NUMS=$($CMD | wc -l)
4227 [ $NUMS -eq $EXPECTED ] ||
4228 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4230 CMD="$LFIND ! -size -5 -type f $TDIR"
4231 NUMS=$($CMD | wc -l)
4232 [ $NUMS -eq $EXPECTED ] ||
4233 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4235 CMD="$LFIND -size -5 -type f $TDIR"
4236 NUMS=$($CMD | wc -l)
4237 [ $NUMS -eq $EXPECTED ] ||
4238 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4240 run_test 56r "check lfs find -size works =========================="
4242 test_56s() { # LU-611
4244 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4246 if [ $OSTCOUNT -gt 1 ]; then
4247 $SETSTRIPE -c 1 $TDIR/$tfile.{0,1,2,3}
4251 ONESTRIPE=$(((NUMDIRS + 1) * NUMFILES))
4255 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4256 CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
4257 NUMS=$($CMD | wc -l)
4258 [ $NUMS -eq $EXPECTED ] ||
4259 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4261 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
4262 CMD="$LFIND -stripe-count +0 -type f $TDIR"
4263 NUMS=$($CMD | wc -l)
4264 [ $NUMS -eq $EXPECTED ] ||
4265 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4268 CMD="$LFIND -stripe-count 1 -type f $TDIR"
4269 NUMS=$($CMD | wc -l)
4270 [ $NUMS -eq $EXPECTED ] ||
4271 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4273 CMD="$LFIND -stripe-count -2 -type f $TDIR"
4274 NUMS=$($CMD | wc -l)
4275 [ $NUMS -eq $EXPECTED ] ||
4276 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4279 CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
4280 NUMS=$($CMD | wc -l)
4281 [ $NUMS -eq $EXPECTED ] ||
4282 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4284 run_test 56s "check lfs find -stripe-count works"
4286 test_56t() { # LU-611
4288 setup_56 $NUMFILES $NUMDIRS "-s 512k"
4290 $SETSTRIPE -S 256k $TDIR/$tfile.{0,1,2,3}
4292 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4293 CMD="$LFIND -stripe-size 512k -type f $TDIR"
4294 NUMS=$($CMD | wc -l)
4295 [ $NUMS -eq $EXPECTED ] ||
4296 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4298 CMD="$LFIND -stripe-size +320k -type f $TDIR"
4299 NUMS=$($CMD | wc -l)
4300 [ $NUMS -eq $EXPECTED ] ||
4301 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4303 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + 4))
4304 CMD="$LFIND -stripe-size +200k -type f $TDIR"
4305 NUMS=$($CMD | wc -l)
4306 [ $NUMS -eq $EXPECTED ] ||
4307 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4309 CMD="$LFIND -stripe-size -640k -type f $TDIR"
4310 NUMS=$($CMD | wc -l)
4311 [ $NUMS -eq $EXPECTED ] ||
4312 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4315 CMD="$LFIND -stripe-size 256k -type f $TDIR"
4316 NUMS=$($CMD | wc -l)
4317 [ $NUMS -eq $EXPECTED ] ||
4318 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4320 CMD="$LFIND -stripe-size -320k -type f $TDIR"
4321 NUMS=$($CMD | wc -l)
4322 [ $NUMS -eq $EXPECTED ] ||
4323 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4326 CMD="$LFIND -stripe-size 1024k -type f $TDIR"
4327 NUMS=$($CMD | wc -l)
4328 [ $NUMS -eq $EXPECTED ] ||
4329 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4331 run_test 56t "check lfs find -stripe-size works"
4333 test_56u() { # LU-611
4335 setup_56 $NUMFILES $NUMDIRS "-i 0"
4337 if [ $OSTCOUNT -gt 1 ]; then
4338 $SETSTRIPE -i 1 $TDIR/$tfile.{0,1,2,3}
4344 EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
4345 CMD="$LFIND -stripe-index 0 -type f $TDIR"
4346 NUMS=$($CMD | wc -l)
4347 [ $NUMS -eq $EXPECTED ] ||
4348 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4351 CMD="$LFIND -stripe-index 1 -type f $TDIR"
4352 NUMS=$($CMD | wc -l)
4353 [ $NUMS -eq $EXPECTED ] ||
4354 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4356 CMD="$LFIND ! -stripe-index 0 -type f $TDIR"
4357 NUMS=$($CMD | wc -l)
4358 [ $NUMS -eq $EXPECTED ] ||
4359 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4362 # This should produce an error and not return any files
4363 CMD="$LFIND -stripe-index $OSTCOUNT -type f $TDIR"
4364 NUMS=$($CMD 2>/dev/null | wc -l)
4365 [ $NUMS -eq $EXPECTED ] ||
4366 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4368 if [ $OSTCOUNT -gt 1 ]; then
4369 EXPECTED=$(((NUMDIRS + 1) * NUMFILES + ONESTRIPE))
4370 CMD="$LFIND -stripe-index 0,1 -type f $TDIR"
4371 NUMS=$($CMD | wc -l)
4372 [ $NUMS -eq $EXPECTED ] ||
4373 error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
4376 run_test 56u "check lfs find -stripe-index works"
4383 setup_56 $NUMFILES $NUMDIRS
4385 UUID=$(mdtuuid_from_index $MDT_IDX $TDIR)
4386 [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT index $MDT_IDX"
4388 for file in $($LFIND -mdt $UUID $TDIR); do
4389 file_mdt_idx=$($GETSTRIPE -M $file)
4390 [ $file_mdt_idx -eq $MDT_IDX ] ||
4391 error "'lfind -mdt $UUID' != 'getstripe -M' ($file_mdt_idx)"
4394 run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
4396 # Get and check the actual stripe count of one file.
4397 # Usage: check_stripe_count <file> <expected_stripe_count>
4398 check_stripe_count() {
4403 [[ -z "$file" || -z "$expected" ]] &&
4404 error "check_stripe_count: invalid argument!"
4406 local cmd="$GETSTRIPE -c $file"
4407 actual=$($cmd) || error "$cmd failed"
4408 actual=${actual%% *}
4410 if [[ $actual -ne $expected ]]; then
4411 [[ $expected -eq -1 ]] ||
4412 error "$cmd wrong: found $actual, expected $expected"
4413 [[ $actual -eq $OSTCOUNT ]] ||
4414 error "$cmd wrong: found $actual, expected $OSTCOUNT"
4419 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4422 rm -rf $TDIR || error "remove $TDIR failed"
4423 setup_56 $NUMFILES $NUMDIRS "-c $OSTCOUNT"
4426 stripe_size=$($GETSTRIPE -S -d $TDIR) ||
4427 error "$GETSTRIPE -S -d $TDIR failed"
4428 stripe_size=${stripe_size%% *}
4430 local file_size=$((stripe_size * OSTCOUNT))
4431 local file_num=$((NUMDIRS * NUMFILES + NUMFILES))
4432 local required_space=$((file_num * file_size))
4433 local free_space=$($LCTL get_param -n lov.$LOVNAME.kbytesavail)
4434 [[ $free_space -le $((required_space / 1024)) ]] &&
4435 skip_env "need at least $required_space bytes free space," \
4436 "have $free_space kbytes" && return
4439 local dd_count=$((file_size / dd_bs))
4441 # write data into the files
4445 for i in $(seq 1 $NUMFILES); do
4447 yes | dd bs=$dd_bs count=$dd_count of=$file >/dev/null 2>&1 ||
4448 error "write data into $file failed"
4450 for i in $(seq 1 $NUMDIRS); do
4451 for j in $(seq 1 $NUMFILES); do
4452 file=$TDIR/dir$i/file$j
4453 yes | dd bs=$dd_bs count=$dd_count of=$file \
4455 error "write data into $file failed"
4460 [[ $OSTCOUNT -gt 1 ]] && expected=$((OSTCOUNT - 1))
4463 local cmd="$LFS_MIGRATE -y -c $expected $TDIR/file1"
4465 eval $cmd || error "$cmd failed"
4467 check_stripe_count $TDIR/file1 $expected
4470 cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
4472 eval $cmd || error "$cmd failed"
4474 for j in $(seq 1 $NUMFILES); do
4475 check_stripe_count $TDIR/dir1/file$j $expected
4478 # lfs_migrate works with lfs find
4479 cmd="$LFIND -stripe_count $OSTCOUNT -type f $TDIR |
4480 $LFS_MIGRATE -y -c $expected"
4482 eval $cmd || error "$cmd failed"
4484 for i in $(seq 2 $NUMFILES); do
4485 check_stripe_count $TDIR/file$i $expected
4487 for i in $(seq 2 $NUMDIRS); do
4488 for j in $(seq 1 $NUMFILES); do
4489 check_stripe_count $TDIR/dir$i/file$j $expected
4493 run_test 56w "check lfs_migrate -c stripe_count works"
4496 check_swap_layouts_support && return 0
4497 [ "$OSTCOUNT" -lt "2" ] &&
4498 skip_env "need 2 OST, skipping test" && return
4500 local dir0=$DIR/$tdir/$testnum
4501 mkdir -p $dir0 || error "creating dir $dir0"
4503 local ref1=/etc/passwd
4504 local file1=$dir0/file1
4506 $SETSTRIPE -c 2 $file1
4508 $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
4509 stripe=$($GETSTRIPE -c $file1)
4510 [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
4511 cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
4516 run_test 56x "lfs migration support"
4519 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4520 # note test will not do anything if MDS is not local
4521 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4522 skip "Only applicable to ldiskfs-based MDTs"
4526 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4527 local MNTDEV="osd*.*MDT*.mntdev"
4528 DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
4529 [ -z "$DEV" ] && error "can't access $MNTDEV"
4530 for DEV in $(do_facet $SINGLEMDS lctl get_param -n $MNTDEV); do
4531 do_facet $SINGLEMDS $DUMPE2FS -h $DEV > $TMP/t57a.dump ||
4532 error "can't access $DEV"
4533 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
4534 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
4538 run_test 57a "verify MDS filesystem created with large inodes =="
4541 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4542 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
4543 skip "Only applicable to ldiskfs-based MDTs"
4547 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4552 local FILEN=$dir/f$FILECOUNT
4554 rm -rf $dir || error "removing $dir"
4555 test_mkdir -p $dir || error "creating $dir"
4556 local num=$(get_mds_dir $dir)
4559 echo "mcreating $FILECOUNT files"
4560 createmany -m $dir/f 1 $FILECOUNT || \
4561 error "creating files in $dir"
4563 # verify that files do not have EAs yet
4564 $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
4565 $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
4569 df $dir #make sure we get new statfs data
4570 local MDSFREE=$(do_facet $mymds \
4571 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4572 local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4573 echo "opening files to create objects/EAs"
4575 for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
4576 $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
4579 # verify that files have EAs now
4580 $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
4581 $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
4583 sleep 1 #make sure we get new statfs data
4585 local MDSFREE2=$(do_facet $mymds \
4586 lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
4587 local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
4588 if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
4589 if [ "$MDSFREE" != "$MDSFREE2" ]; then
4590 error "MDC before $MDCFREE != after $MDCFREE2"
4592 echo "MDC before $MDCFREE != after $MDCFREE2"
4593 echo "unable to confirm if MDS has large inodes"
4598 run_test 57b "default LOV EAs are stored inside large inodes ==="
4601 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4602 [ -z "$(which wiretest 2>/dev/null)" ] &&
4603 skip_env "could not find wiretest" && return
4606 run_test 58 "verify cross-platform wire constants =============="
4609 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4610 echo "touch 130 files"
4611 createmany -o $DIR/f59- 130
4613 unlinkmany $DIR/f59- 130
4615 # wait for commitment of removal
4616 wait_delete_completed
4618 run_test 59 "verify cancellation of llog records async ========="
4620 TEST60_HEAD="test_60 run $RANDOM"
4622 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4623 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
4624 [ ! -f run-llog.sh ] && skip_env "missing subtest run-llog.sh" && return
4625 log "$TEST60_HEAD - from kernel mode"
4626 do_facet mgs sh run-llog.sh
4628 run_test 60a "llog sanity tests run from kernel module =========="
4630 test_60b() { # bug 6411
4631 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4633 LLOG_COUNT=`dmesg | awk "/$TEST60_HEAD/{marker = 1; from_marker = 0;}
4645 [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages ($LLOG_COUNT)"|| true
4647 run_test 60b "limit repeated messages from CERROR/CWARN ========"
4650 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4651 echo "create 5000 files"
4652 createmany -o $DIR/f60c- 5000
4653 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED 0x137
4654 lctl set_param fail_loc=0x80000137
4655 unlinkmany $DIR/f60c- 5000
4656 lctl set_param fail_loc=0
4658 run_test 60c "unlink file when mds full"
4661 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4662 SAVEPRINTK=$(lctl get_param -n printk)
4664 # verify "lctl mark" is even working"
4665 MESSAGE="test message ID $RANDOM $$"
4666 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4667 dmesg | grep -q "$MESSAGE" || error "didn't find debug marker in log"
4669 lctl set_param printk=0 || error "set lnet.printk failed"
4670 lctl get_param -n printk | grep emerg || error "lnet.printk dropped emerg"
4671 MESSAGE="new test message ID $RANDOM $$"
4672 # Assume here that libcfs_debug_mark_buffer() uses D_WARNING
4673 $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
4674 dmesg | grep -q "$MESSAGE" && error "D_WARNING wasn't masked" || true
4676 lctl set_param -n printk="$SAVEPRINTK"
4678 run_test 60d "test printk console message masking"
4681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4683 dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
4684 cancel_lru_locks osc
4685 $MULTIOP $f OSMWUc || error "$MULTIOP $f failed"
4688 run_test 61 "mmap() writes don't make sync hang ================"
4690 # bug 2330 - insufficient obd_match error checking causes LBUG
4692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4695 cancel_lru_locks osc
4696 lctl set_param fail_loc=0x405
4697 cat $f && error "cat succeeded, expect -EIO"
4698 lctl set_param fail_loc=0
4700 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
4701 # match every page all of the time.
4702 #run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
4704 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
4705 test_63a() { # was test_63
4706 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4707 MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
4708 lctl set_param -n osc.*.max_dirty_mb 0
4709 for i in `seq 10` ; do
4710 dd if=/dev/zero of=$DIR/f63 bs=8k &
4716 lctl set_param -n osc.*.max_dirty_mb $MAX_DIRTY_MB
4717 rm -f $DIR/f63 || true
4719 run_test 63a "Verify oig_wait interruption does not crash ======="
4721 # bug 2248 - async write errors didn't return to application on sync
4722 # bug 3677 - async write errors left page locked
4724 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4726 lctl set_param debug=-1
4728 # ensure we have a grant to do async writes
4729 dd if=/dev/zero of=$DIR/$tfile bs=4k count=1
4732 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
4733 lctl set_param fail_loc=0x80000406
4734 $MULTIOP $DIR/$tfile Owy && \
4735 error "sync didn't return ENOMEM"
4736 sync; sleep 2; sync # do a real sync this time to flush page
4737 lctl get_param -n llite.*.dump_page_cache | grep locked && \
4738 error "locked page left in cache after async error" || true
4741 run_test 63b "async write errors should be returned to fsync ==="
4744 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4746 lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
4748 run_test 64a "verify filter grant calculations (in kernel) ====="
4751 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4752 [ ! -f oos.sh ] && skip_env "missing subtest oos.sh" && return
4755 run_test 64b "check out-of-space detection on client ==========="
4758 $LCTL set_param osc.*OST0000-osc-[^mM]*.cur_grant_bytes=0
4760 run_test 64c "verify grant shrink ========================------"
4762 # bug 1414 - set/get directories' stripe info
4764 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4765 test_mkdir -p $DIR/$tdir
4767 $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
4769 run_test 65a "directory with no stripe info ===================="
4772 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4773 test_mkdir -p $DIR/$tdir
4774 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4777 $LVERIFY $DIR/$tdir $DIR/$tdir/f2 || error "lverify failed"
4779 run_test 65b "directory setstripe -S $((STRIPESIZE * 2)) -i 0 -c 1"
4782 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4783 if [ $OSTCOUNT -gt 1 ]; then
4784 test_mkdir -p $DIR/$tdir
4785 $SETSTRIPE -S $(($STRIPESIZE * 4)) -i 1 \
4786 -c $(($OSTCOUNT - 1)) $DIR/$tdir || error "setstripe"
4788 $LVERIFY $DIR/$tdir $DIR/$tdir/f3 || error "lverify failed"
4791 run_test 65c "directory setstripe -S $((STRIPESIZE*4)) -i 1 -c $((OSTCOUNT-1))"
4794 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4795 test_mkdir -p $DIR/$tdir
4796 if [ $STRIPECOUNT -le 0 ]; then
4798 elif [ $STRIPECOUNT -gt 2000 ]; then
4799 #LOV_MAX_STRIPE_COUNT is 2000
4800 [ $OSTCOUNT -gt 2000 ] && sc=2000 || sc=$(($OSTCOUNT - 1))
4802 sc=$(($STRIPECOUNT - 1))
4804 $SETSTRIPE -S $STRIPESIZE -c $sc $DIR/$tdir || error "setstripe"
4805 touch $DIR/$tdir/f4 $DIR/$tdir/f5
4806 $LVERIFY $DIR/$tdir $DIR/$tdir/f4 $DIR/$tdir/f5 ||
4807 error "lverify failed"
4809 run_test 65d "directory setstripe -S $STRIPESIZE -c stripe_count"
4812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4813 test_mkdir -p $DIR/$tdir
4815 $SETSTRIPE $DIR/$tdir || error "setstripe"
4816 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4817 error "no stripe info failed"
4819 $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
4821 run_test 65e "directory setstripe defaults ======================="
4824 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4825 test_mkdir -p $DIR/${tdir}f
4826 $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
4828 run_test 65f "dir setstripe permission (should return error) ==="
4831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4832 test_mkdir -p $DIR/$tdir
4833 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4835 $SETSTRIPE -d $DIR/$tdir || error "setstripe"
4836 $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
4837 error "delete default stripe failed"
4839 run_test 65g "directory setstripe -d ==========================="
4842 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4843 test_mkdir -p $DIR/$tdir
4844 $SETSTRIPE -S $((STRIPESIZE * 2)) -i 0 -c 1 $DIR/$tdir ||
4846 test_mkdir -p $DIR/$tdir/dd1
4847 [ $($GETSTRIPE -c $DIR/$tdir) == $($GETSTRIPE -c $DIR/$tdir/dd1) ] ||
4848 error "stripe info inherit failed"
4850 run_test 65h "directory stripe info inherit ===================="
4852 test_65i() { # bug6367
4853 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4854 $SETSTRIPE -S 65536 -c -1 $MOUNT
4856 run_test 65i "set non-default striping on root directory (bug 6367)="
4858 test_65ia() { # bug12836
4859 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4860 $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
4862 run_test 65ia "getstripe on -1 default directory striping"
4864 test_65ib() { # bug12836
4865 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4866 $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
4868 run_test 65ib "getstripe -v on -1 default directory striping"
4870 test_65ic() { # bug12836
4871 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4872 $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
4874 run_test 65ic "new find on -1 default directory striping"
4876 test_65j() { # bug6367
4877 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4879 # if we aren't already remounting for each test, do so for this test
4880 if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
4881 cleanup || error "failed to unmount"
4884 $SETSTRIPE -d $MOUNT || error "setstripe failed"
4886 run_test 65j "set default striping on root directory (bug 6367)="
4888 test_65k() { # bug11679
4889 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4890 [ "$OSTCOUNT" -lt 2 ] && skip_env "too few OSTs" && return
4891 remote_mds_nodsh && skip "remote MDS with nodsh" && return
4893 echo "Check OST status: "
4894 local MDS_OSCS=`do_facet $SINGLEMDS lctl dl |
4895 awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
4897 for OSC in $MDS_OSCS; do
4898 echo $OSC "is activate"
4899 do_facet $SINGLEMDS lctl --device %$OSC activate
4903 for INACTIVE_OSC in $MDS_OSCS; do
4904 echo "Deactivate: " $INACTIVE_OSC
4905 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC deactivate
4906 for STRIPE_OSC in $MDS_OSCS; do
4907 OST=`osc_to_ost $STRIPE_OSC`
4908 IDX=`do_facet $SINGLEMDS lctl get_param -n lov.*md*.target_obd |
4909 awk -F: /$OST/'{ print $1 }' | head -n 1`
4911 [ -f $DIR/$tdir/$IDX ] && continue
4912 echo "$SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX"
4913 $SETSTRIPE -i $IDX -c 1 $DIR/$tdir/$IDX
4915 [ $RC -ne 0 ] && error "setstripe should have succeeded"
4918 echo $INACTIVE_OSC "is Activate."
4919 do_facet $SINGLEMDS lctl --device %$INACTIVE_OSC activate
4922 run_test 65k "validate manual striping works properly with deactivated OSCs"
4924 test_65l() { # bug 12836
4925 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4926 test_mkdir -p $DIR/$tdir/test_dir
4927 $SETSTRIPE -c -1 $DIR/$tdir/test_dir
4928 $LFS find -mtime -1 $DIR/$tdir >/dev/null
4930 run_test 65l "lfs find on -1 stripe dir ========================"
4932 # bug 2543 - update blocks count on client
4934 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4936 dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
4937 sync; sync_all_data; sync; sync_all_data
4938 cancel_lru_locks osc
4939 BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
4940 [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
4942 run_test 66 "update inode blocks count on client ==============="
4947 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4949 if [ ! -z "$LLOOP" ]; then
4950 if swapon -s | grep -q $LLOOP; then
4951 swapoff $LLOOP || error "swapoff failed"
4954 $LCTL blockdev_detach $LLOOP || error "detach failed"
4958 if [ ! -z "$LLITELOOPLOAD" ]; then
4966 awk '($1 == "'$1':") { print $2 }' /proc/meminfo
4970 swapon -s | awk '($1 == "'$1'") { print $4 }'
4973 # test case for lloop driver, basic function
4975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
4976 [ "$UID" != 0 ] && skip_env "must run as root" && return
4977 llite_lloop_enabled || \
4978 { skip_env "llite_lloop module disabled" && return; }
4980 trap cleanup_68 EXIT
4982 if ! module_loaded llite_lloop; then
4983 if load_module llite/llite_lloop; then
4986 skip_env "can't find module llite_lloop"
4991 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
4992 dd if=/dev/zero of=$DIR/f68a bs=4k count=1024
4993 $LCTL blockdev_attach $DIR/f68a $LLOOP || error "attach failed"
4995 directio rdwr $LLOOP 0 1024 4096 || error "direct write failed"
4996 directio rdwr $LLOOP 0 1025 4096 && error "direct write should fail"
5000 run_test 68a "lloop driver - basic test ========================"
5002 # excercise swapping to lustre by adding a high priority swapfile entry
5003 # and then consuming memory until it is used.
5004 test_68b() { # was test_68
5005 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5006 [ "$UID" != 0 ] && skip_env "must run as root" && return
5007 lctl get_param -n devices | grep -q obdfilter && \
5008 skip "local OST" && return
5010 grep -q llite_lloop /proc/modules
5011 [ $? -ne 0 ] && skip "can't find module llite_lloop" && return
5013 [ -z "`$LCTL list_nids | grep -v tcp`" ] && \
5014 skip "can't reliably test swap with TCP" && return
5016 MEMTOTAL=`meminfo MemTotal`
5017 NR_BLOCKS=$((MEMTOTAL>>8))
5018 [[ $NR_BLOCKS -le 2048 ]] && NR_BLOCKS=2048
5020 LLOOP=$TMP/lloop.`date +%s`.`date +%N`
5021 dd if=/dev/zero of=$DIR/f68b bs=64k seek=$NR_BLOCKS count=1
5024 $LCTL blockdev_attach $DIR/f68b $LLOOP || error "attach failed"
5026 trap cleanup_68 EXIT
5028 swapon -p 32767 $LLOOP || error "swapon $LLOOP failed"
5030 echo "before: `swapon -s | grep $LLOOP`"
5031 $MEMHOG $MEMTOTAL || error "error allocating $MEMTOTAL kB"
5032 echo "after: `swapon -s | grep $LLOOP`"
5033 SWAPUSED=`swap_used $LLOOP`
5037 [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
5039 run_test 68b "support swapping to Lustre ========================"
5041 # bug5265, obdfilter oa2dentry return -ENOENT
5042 # #define OBD_FAIL_OST_ENOENT 0x217
5044 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5045 remote_ost_nodsh && skip "remote OST with nodsh" && return
5048 $SETSTRIPE -c 1 -i 0 $f
5050 $DIRECTIO write ${f}.2 0 1 || error "directio write error"
5052 do_facet ost1 lctl set_param fail_loc=0x217
5053 $TRUNCATE $f 1 # vmtruncate() will ignore truncate() error.
5054 $DIRECTIO write $f 0 2 && error "write succeeded, expect -ENOENT"
5056 do_facet ost1 lctl set_param fail_loc=0
5057 $DIRECTIO write $f 0 2 || error "write error"
5059 cancel_lru_locks osc
5060 $DIRECTIO read $f 0 1 || error "read error"
5062 do_facet ost1 lctl set_param fail_loc=0x217
5063 $DIRECTIO read $f 1 1 && error "read succeeded, expect -ENOENT"
5065 do_facet ost1 lctl set_param fail_loc=0
5068 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
5071 test_mkdir -p $DIR/$tdir
5072 sh rundbench -C -D $DIR/$tdir 2 || error "dbench failed!"
5074 run_test 71 "Running dbench on lustre (don't segment fault) ===="
5076 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
5077 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5078 [ "$RUNAS_ID" = "$UID" ] &&
5079 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5081 # Check that testing environment is properly set up. Skip if not
5082 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
5083 skip_env "User $RUNAS_ID does not exist - skipping"
5086 # We had better clear the $DIR to get enough space for dd
5089 chmod 777 $DIR/$tfile
5090 chmod ug+s $DIR/$tfile
5091 $RUNAS dd if=/dev/zero of=$DIR/$tfile bs=512 count=1 ||
5092 error "$RUNAS dd $DIR/$tfile failed"
5093 # See if we are still setuid/sgid
5094 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5095 error "S/gid is not dropped on write"
5096 # Now test that MDS is updated too
5097 cancel_lru_locks mdc
5098 test -u $DIR/$tfile -o -g $DIR/$tfile &&
5099 error "S/gid is not dropped on MDS"
5102 run_test 72a "Test that remove suid works properly (bug5695) ===="
5104 test_72b() { # bug 24226 -- keep mode setting when size is not changing
5107 [ "$RUNAS_ID" = "$UID" ] && \
5108 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
5109 [ "$RUNAS_ID" -eq 0 ] && \
5110 skip_env "RUNAS_ID = 0 -- skipping" && return
5112 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5113 # Check that testing environment is properly set up. Skip if not
5114 FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
5115 skip_env "User $RUNAS_ID does not exist - skipping"
5118 touch $DIR/${tfile}-f{g,u}
5119 test_mkdir $DIR/${tfile}-dg
5120 test_mkdir $DIR/${tfile}-du
5121 chmod 770 $DIR/${tfile}-{f,d}{g,u}
5122 chmod g+s $DIR/${tfile}-{f,d}g
5123 chmod u+s $DIR/${tfile}-{f,d}u
5124 for perm in 777 2777 4777; do
5125 $RUNAS chmod $perm $DIR/${tfile}-fg && error "S/gid file allowed improper chmod to $perm"
5126 $RUNAS chmod $perm $DIR/${tfile}-fu && error "S/uid file allowed improper chmod to $perm"
5127 $RUNAS chmod $perm $DIR/${tfile}-dg && error "S/gid dir allowed improper chmod to $perm"
5128 $RUNAS chmod $perm $DIR/${tfile}-du && error "S/uid dir allowed improper chmod to $perm"
5132 run_test 72b "Test that we keep mode setting if without file data changed (bug 24226)"
5134 # bug 3462 - multiple simultaneous MDC requests
5136 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5137 test_mkdir $DIR/d73-1
5138 test_mkdir $DIR/d73-2
5139 multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
5142 lctl set_param fail_loc=0x80000129
5143 $MULTIOP $DIR/d73-1/f73-2 Oc &
5145 lctl set_param fail_loc=0
5147 $MULTIOP $DIR/d73-2/f73-3 Oc &
5151 wait $pid1 || return 1
5155 $CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
5156 $CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
5157 $CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
5161 run_test 73 "multiple MDC requests (should not deadlock)"
5163 test_74a() { # bug 6149, 6184
5164 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5165 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5167 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5168 # will spin in a tight reconnection loop
5170 lctl set_param fail_loc=0x8000030e
5171 # get any lock that won't be difficult - lookup works.
5173 lctl set_param fail_loc=0
5177 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
5179 test_74b() { # bug 13310
5180 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5181 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
5183 # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
5184 # will spin in a tight reconnection loop
5185 lctl set_param fail_loc=0x8000030e
5186 # get a "difficult" lock
5188 lctl set_param fail_loc=0
5192 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
5195 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5196 #define OBD_FAIL_LDLM_NEW_LOCK
5197 lctl set_param fail_loc=0x80000319
5198 touch $DIR/$tfile && error "Touch successful"
5201 run_test 74c "ldlm_lock_create error path, (shouldn't LBUG)"
5204 awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
5207 get_inode_slab_tunables() {
5208 awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
5211 set_inode_slab_tunables() {
5212 echo "lustre_inode_cache $1" > /proc/slabinfo
5215 test_76() { # Now for bug 20433, added originally in bug 1443
5216 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5217 local SLAB_SETTINGS=`get_inode_slab_tunables`
5218 local CPUS=`getconf _NPROCESSORS_ONLN`
5219 # we cannot set limit below 1 which means 1 inode in each
5220 # per-cpu cache is still allowed
5221 set_inode_slab_tunables "1 1 0"
5222 cancel_lru_locks osc
5223 BEFORE_INODES=`num_inodes`
5224 echo "before inodes: $BEFORE_INODES"
5226 [ "$SLOW" = "no" ] && COUNT=100
5227 for i in `seq $COUNT`; do
5231 cancel_lru_locks osc
5232 AFTER_INODES=`num_inodes`
5233 echo "after inodes: $AFTER_INODES"
5235 while [ $((AFTER_INODES-1*CPUS)) -gt $BEFORE_INODES ]; do
5237 AFTER_INODES=`num_inodes`
5239 echo "wait $wait seconds inodes: $AFTER_INODES"
5240 if [ $wait -gt 30 ]; then
5241 error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
5244 set_inode_slab_tunables "$SLAB_SETTINGS"
5246 run_test 76 "confirm clients recycle inodes properly ===="
5252 # Note: in sptlrpc modes which enable its own bulk checksum, the
5253 # original crc32_le bulk checksum will be automatically disabled,
5254 # and the OBD_FAIL_OSC_CHECKSUM_SEND/OBD_FAIL_OSC_CHECKSUM_RECEIVE
5255 # will be checked by sptlrpc code against sptlrpc bulk checksum.
5256 # In this case set_checksums() will not be no-op, because sptlrpc
5257 # bulk checksum will be enabled all through the test.
5259 [ "$ORIG_CSUM" ] || ORIG_CSUM=`lctl get_param -n osc.*.checksums | head -n1`
5260 lctl set_param -n osc.*.checksums $1
5264 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
5265 sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
5266 CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
5267 [ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
5270 lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
5271 log "set checksum type to $1"
5274 F77_TMP=$TMP/f77-temp
5277 dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
5278 error "error writing to $F77_TMP"
5281 test_77a() { # bug 10889
5282 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5283 $GSS && skip "could not run with gss" && return
5284 [ ! -f $F77_TMP ] && setup_f77
5286 dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
5290 run_test 77a "normal checksum read/write operation ============="
5292 test_77b() { # bug 10889
5293 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5294 $GSS && skip "could not run with gss" && return
5295 [ ! -f $F77_TMP ] && setup_f77
5296 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5297 lctl set_param fail_loc=0x80000409
5299 dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
5300 error "dd error: $?"
5301 lctl set_param fail_loc=0
5304 run_test 77b "checksum error on client write ===================="
5306 test_77c() { # bug 10889
5307 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5308 $GSS && skip "could not run with gss" && return
5309 [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return
5311 for algo in $CKSUM_TYPES; do
5312 cancel_lru_locks osc
5313 set_checksum_type $algo
5314 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5315 lctl set_param fail_loc=0x80000408
5316 cmp $F77_TMP $DIR/f77b || error "file compare failed"
5317 lctl set_param fail_loc=0
5320 set_checksum_type $ORIG_CSUM_TYPE
5323 run_test 77c "checksum error on client read ==================="
5325 test_77d() { # bug 10889
5326 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5327 $GSS && skip "could not run with gss" && return
5328 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5329 lctl set_param fail_loc=0x80000409
5331 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5332 error "direct write: rc=$?"
5333 lctl set_param fail_loc=0
5336 run_test 77d "checksum error on OST direct write ==============="
5338 test_77e() { # bug 10889
5339 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5340 $GSS && skip "could not run with gss" && return
5341 [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return
5342 #define OBD_FAIL_OSC_CHECKSUM_RECEIVE 0x408
5343 lctl set_param fail_loc=0x80000408
5345 cancel_lru_locks osc
5346 directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
5347 error "direct read: rc=$?"
5348 lctl set_param fail_loc=0
5351 run_test 77e "checksum error on OST direct read ================"
5353 test_77f() { # bug 10889
5354 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5355 $GSS && skip "could not run with gss" && return
5357 for algo in $CKSUM_TYPES; do
5358 cancel_lru_locks osc
5359 set_checksum_type $algo
5360 #define OBD_FAIL_OSC_CHECKSUM_SEND 0x409
5361 lctl set_param fail_loc=0x409
5362 directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
5363 error "direct write succeeded"
5364 lctl set_param fail_loc=0
5366 set_checksum_type $ORIG_CSUM_TYPE
5369 run_test 77f "repeat checksum error on write (expect error) ===="
5371 test_77g() { # bug 10889
5372 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5373 $GSS && skip "could not run with gss" && return
5374 remote_ost_nodsh && skip "remote OST with nodsh" && return
5376 [ ! -f $F77_TMP ] && setup_f77
5378 $SETSTRIPE -c 1 -i 0 $DIR/f77g
5379 #define OBD_FAIL_OST_CHECKSUM_RECEIVE 0x21a
5380 do_facet ost1 lctl set_param fail_loc=0x8000021a
5382 dd if=$F77_TMP of=$DIR/f77g bs=1M count=$F77SZ || \
5383 error "write error: rc=$?"
5384 do_facet ost1 lctl set_param fail_loc=0
5387 run_test 77g "checksum error on OST write ======================"
5389 test_77h() { # bug 10889
5390 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5391 $GSS && skip "could not run with gss" && return
5392 remote_ost_nodsh && skip "remote OST with nodsh" && return
5394 [ ! -f $DIR/f77g ] && skip "requires 77g - skipping" && return
5395 cancel_lru_locks osc
5396 #define OBD_FAIL_OST_CHECKSUM_SEND 0x21b
5397 do_facet ost1 lctl set_param fail_loc=0x8000021b
5399 cmp $F77_TMP $DIR/f77g || error "file compare failed"
5400 do_facet ost1 lctl set_param fail_loc=0
5403 run_test 77h "checksum error on OST read ======================="
5405 test_77i() { # bug 13805
5406 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5407 $GSS && skip "could not run with gss" && return
5408 #define OBD_FAIL_OSC_CONNECT_CKSUM 0x40b
5409 lctl set_param fail_loc=0x40b
5410 remount_client $MOUNT
5411 lctl set_param fail_loc=0
5412 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5413 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5414 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5415 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5417 remount_client $MOUNT
5419 run_test 77i "client not supporting OSD_CONNECT_CKSUM =========="
5421 test_77j() { # bug 13805
5422 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5423 $GSS && skip "could not run with gss" && return
5424 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY 0x40c
5425 lctl set_param fail_loc=0x40c
5426 remount_client $MOUNT
5427 lctl set_param fail_loc=0
5428 sleep 2 # wait async osc connect to finish
5429 for VALUE in `lctl get_param osc.*osc-[^mM]*.checksum_type`; do
5430 PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
5431 algo=`lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g'`
5432 [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
5434 remount_client $MOUNT
5436 run_test 77j "client only supporting ADLER32 ===================="
5438 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
5442 test_78() { # bug 10901
5443 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5444 remote_ost || { skip_env "local OST" && return; }
5447 F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
5448 echo "MemFree: $F78SIZE, Max file size: $MAXFREE"
5449 MEMTOTAL=$(($(awk '/MemTotal:/ { print $2 }' /proc/meminfo) / 1024))
5450 echo "MemTotal: $MEMTOTAL"
5451 # reserve 256MB of memory for the kernel and other running processes,
5452 # and then take 1/2 of the remaining memory for the read/write buffers.
5453 if [ $MEMTOTAL -gt 512 ] ;then
5454 MEMTOTAL=$(((MEMTOTAL - 256 ) / 2))
5456 # for those poor memory-starved high-end clusters...
5457 MEMTOTAL=$((MEMTOTAL / 2))
5459 echo "Mem to use for directio: $MEMTOTAL"
5460 [ $F78SIZE -gt $MEMTOTAL ] && F78SIZE=$MEMTOTAL
5461 [ $F78SIZE -gt 512 ] && F78SIZE=512
5462 [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
5463 SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
5464 echo "Smallest OST: $SMALLESTOST"
5465 [ $SMALLESTOST -lt 10240 ] && \
5466 skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
5468 [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024 - 80)) ] && \
5469 F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024 - 80))
5471 [ "$SLOW" = "no" ] && NSEQ=1 && [ $F78SIZE -gt 32 ] && F78SIZE=32
5472 echo "File size: $F78SIZE"
5473 $SETSTRIPE -c $OSTCOUNT $DIR/$tfile || error "setstripe failed"
5474 for i in `seq 1 $NSEQ`
5476 FSIZE=$(($F78SIZE / ($NSEQ - $i + 1)))
5477 echo directIO rdwr round $i of $NSEQ
5478 $DIRECTIO rdwr $DIR/$tfile 0 $FSIZE 1048576||error "rdwr failed"
5483 run_test 78 "handle large O_DIRECT writes correctly ============"
5485 test_79() { # bug 12743
5486 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5487 wait_delete_completed
5489 BKTOTAL=$(calc_osc_kbytes kbytestotal)
5490 BKFREE=$(calc_osc_kbytes kbytesfree)
5491 BKAVAIL=$(calc_osc_kbytes kbytesavail)
5493 STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
5494 DFTOTAL=`echo $STRING | cut -d, -f1`
5495 DFUSED=`echo $STRING | cut -d, -f2`
5496 DFAVAIL=`echo $STRING | cut -d, -f3`
5497 DFFREE=$(($DFTOTAL - $DFUSED))
5499 ALLOWANCE=$((64 * $OSTCOUNT))
5501 if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
5502 [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
5503 error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
5505 if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
5506 [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
5507 error "df free($DFFREE) mismatch OST free($BKFREE)"
5509 if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
5510 [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
5511 error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
5514 run_test 79 "df report consistency check ======================="
5516 test_80() { # bug 10718
5517 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5518 # relax strong synchronous semantics for slow backends like ZFS
5519 local soc="obdfilter.*.sync_on_lock_cancel"
5520 local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
5522 if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
5523 hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
5524 facet_active_host $host; done | sort -u)
5525 do_nodes $hosts lctl set_param $soc=never
5528 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
5530 local BEFORE=`date +%s`
5531 cancel_lru_locks osc
5532 local AFTER=`date +%s`
5533 local DIFF=$((AFTER-BEFORE))
5534 if [ $DIFF -gt 1 ] ; then
5535 error "elapsed for 1M@1T = $DIFF"
5538 [ -n "$hosts" ] && do_nodes $hosts lctl set_param $soc=$soc_old
5542 run_test 80 "Page eviction is equally fast at high offsets too ===="
5544 test_81a() { # LU-456
5545 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5546 remote_ost_nodsh && skip "remote OST with nodsh" && return
5547 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5548 # MUST OR with the OBD_FAIL_ONCE (0x80000000)
5549 do_facet ost1 lctl set_param fail_loc=0x80000228
5551 # write should trigger a retry and success
5552 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5553 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5555 if [ $RC -ne 0 ] ; then
5556 error "write should success, but failed for $RC"
5559 run_test 81a "OST should retry write when get -ENOSPC ==============="
5561 test_81b() { # LU-456
5562 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5563 remote_ost_nodsh && skip "remote OST with nodsh" && return
5564 # define OBD_FAIL_OST_MAPBLK_ENOSPC 0x228
5565 # Don't OR with the OBD_FAIL_ONCE (0x80000000)
5566 do_facet ost1 lctl set_param fail_loc=0x228
5568 # write should retry several times and return -ENOSPC finally
5569 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
5570 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
5573 if [ $RC -ne $ENOSPC ] ; then
5574 error "dd should fail for -ENOSPC, but succeed."
5577 run_test 81b "OST should return -ENOSPC when retry still fails ======="
5579 test_82() { # LU-1031
5580 dd if=/dev/zero of=$DIR/$tfile bs=1M count=10
5584 multiop_bg_pause $DIR/$tfile OG${gid1}_g${gid1}c || return 1
5586 multiop_bg_pause $DIR/$tfile O_G${gid2}r10g${gid2}c || return 2
5588 kill -USR1 $MULTIPID2
5590 if [[ `ps h -o comm -p $MULTIPID2` == "" ]]; then
5591 error "First grouplock does not block second one"
5593 echo "Second grouplock blocks first one"
5595 kill -USR1 $MULTIPID1
5599 run_test 82 "Basic grouplock test ==============================="
5602 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
5604 test_mkdir -p $DIR/d99cvsroot
5605 chown $RUNAS_ID $DIR/d99cvsroot
5606 local oldPWD=$PWD # bug 13584, use $TMP as working dir
5609 $RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
5612 run_test 99a "cvs init ========================================="
5615 [ -z "$(which cvs 2>/dev/null)" ] &&
5616 skip_env "could not find cvs" && return
5617 [ ! -d $DIR/d99cvsroot ] && test_99a
5619 # some versions of cvs import exit(1) when asked to import links or
5620 # files they can't read. ignore those files.
5621 TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
5622 ! -perm +4 -printf '-I %f\n')
5623 $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
5624 d99reposname vtag rtag
5626 run_test 99b "cvs import ======================================="
5629 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5630 [ ! -d $DIR/d99cvsroot ] && test_99b
5632 test_mkdir -p $DIR/d99reposname
5633 chown $RUNAS_ID $DIR/d99reposname
5634 $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
5636 run_test 99c "cvs checkout ====================================="
5639 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5640 [ ! -d $DIR/d99cvsroot ] && test_99c
5641 cd $DIR/d99reposname
5643 $RUNAS cvs add -m 'addmsg' foo99
5645 run_test 99d "cvs add =========================================="
5648 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5649 [ ! -d $DIR/d99cvsroot ] && test_99c
5650 cd $DIR/d99reposname
5653 run_test 99e "cvs update ======================================="
5656 [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" && return
5657 [ ! -d $DIR/d99cvsroot ] && test_99d
5658 cd $DIR/d99reposname
5659 $RUNAS cvs commit -m 'nomsg' foo99
5660 rm -fr $DIR/d99cvsroot
5662 run_test 99f "cvs commit ======================================="
5665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5666 [ "$NETTYPE" = tcp ] || \
5667 { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" && \
5670 remote_ost_nodsh && skip "remote OST with nodsh" && return
5671 remote_mds_nodsh && skip "remote MDS with nodsh" && return
5673 { skip "useless for local single node setup" && return; }
5675 netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
5676 [ "$PROT" != "tcp" ] && continue
5677 RPORT=$(echo $REMOTE | cut -d: -f2)
5678 [ "$RPORT" != "$ACCEPTOR_PORT" ] && continue
5681 LPORT=`echo $LOCAL | cut -d: -f2`
5682 if [ $LPORT -ge 1024 ]; then
5683 echo "bad: $PROT $SND $RCV $LOCAL $REMOTE $STAT"
5685 error_exit "local: $LPORT > 1024, remote: $RPORT"
5688 [ "$rc" = 0 ] || error_exit "privileged port not found" )
5690 run_test 100 "check local port using privileged port ==========="
5692 function get_named_value()
5701 echo $line | sed "s/^$tag[ ]*//"
5708 export CACHE_MAX=$($LCTL get_param -n llite.*.max_cached_mb |
5709 awk '/^max_cached_mb/ { print $2 }')
5712 $LCTL set_param -n llite.*.max_cached_mb $CACHE_MAX
5717 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5721 local cache_limit=32
5723 $LCTL set_param -n osc.*-osc*.rpc_stats 0
5724 trap cleanup_101a EXIT
5725 $LCTL set_param -n llite.*.read_ahead_stats 0
5726 $LCTL set_param -n llite.*.max_cached_mb $cache_limit
5729 # randomly read 10000 of 64K chunks from file 3x 32MB in size
5731 echo "nreads: $nreads file size: $((cache_limit * 3))MB"
5732 $READS -f $DIR/$tfile -s$((cache_limit * 3192 * 1024)) -b65536 -C -n$nreads -t 180
5735 for s in `$LCTL get_param -n llite.*.read_ahead_stats | \
5736 get_named_value 'read but discarded' | cut -d" " -f1`; do
5737 discard=$(($discard + $s))
5741 if [ $(($discard * 10)) -gt $nreads ] ;then
5742 $LCTL get_param osc.*-osc*.rpc_stats
5743 $LCTL get_param llite.*.read_ahead_stats
5744 error "too many ($discard) discarded pages"
5746 rm -f $DIR/$tfile || true
5748 run_test 101a "check read-ahead for random reads ================"
5751 test_mkdir -p $DIR/$tdir
5753 STRIPE_COUNT=$OSTCOUNT
5756 local list=$(comma_list $(osts_nodes))
5757 set_osd_param $list '' read_cache_enable 0
5758 set_osd_param $list '' writethrough_cache_enable 0
5760 trap cleanup_test101bc EXIT
5761 # prepare the read-ahead file
5762 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT $DIR/$tfile
5764 dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
5767 cleanup_test101bc() {
5772 local list=$(comma_list $(osts_nodes))
5773 set_osd_param $list '' read_cache_enable 1
5774 set_osd_param $list '' writethrough_cache_enable 1
5778 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
5783 local STRIPE_SIZE=1048576
5784 local RA_INC=1048576
5785 local STRIDE_LENGTH=$((STRIPE_SIZE/READ_SIZE))
5786 local FILE_LENGTH=$((64*100))
5787 local discard_limit=$((((STRIDE_LENGTH - 1)*3/(STRIDE_LENGTH*OSTCOUNT))* \
5788 (STRIDE_LENGTH*OSTCOUNT - STRIDE_LENGTH)))
5789 DISCARD=`$LCTL get_param -n llite.*.read_ahead_stats | \
5790 get_named_value 'read but discarded' | \
5791 cut -d" " -f1 | calc_total`
5792 if [ $DISCARD -gt $discard_limit ]; then
5793 $LCTL get_param llite.*.read_ahead_stats
5794 error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
5796 echo "Read-ahead success for size ${READ_SIZE}"
5801 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5802 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping stride IO stride-ahead test" && return
5803 local STRIPE_SIZE=1048576
5804 local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
5805 local FILE_LENGTH=$((STRIPE_SIZE*100))
5806 local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
5807 # prepare the read-ahead file
5809 cancel_lru_locks osc
5810 for BIDX in 2 4 8 16 32 64 128 256
5812 local BSIZE=$((BIDX*4096))
5813 local READ_COUNT=$((STRIPE_SIZE/BSIZE))
5814 local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
5815 local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
5816 $LCTL set_param -n llite.*.read_ahead_stats 0
5817 $READS -f $DIR/$tfile -l $STRIDE_LENGTH -o $OFFSET \
5818 -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
5819 cancel_lru_locks osc
5825 run_test 101b "check stride-io mode read-ahead ================="
5828 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5829 local STRIPE_SIZE=1048576
5830 local FILE_LENGTH=$((STRIPE_SIZE*100))
5836 cancel_lru_locks osc
5837 $LCTL set_param osc.*.rpc_stats 0
5838 $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
5839 for osc in $($LCTL get_param -N osc.*); do
5840 if [ "$osc" == "osc.num_refs" ]; then
5844 local lines=$($LCTL get_param -n ${osc}.rpc_stats | wc | awk '{print $1}')
5845 if [ $lines -le 20 ]; then
5849 local rpc4k=$($LCTL get_param -n ${osc}.rpc_stats |
5850 awk '$1 == "1:" { print $2; exit; }')
5851 local rpc8k=$($LCTL get_param -n ${osc}.rpc_stats |
5852 awk '$1 == "2:" { print $2; exit; }')
5853 local rpc16k=$($LCTL get_param -n ${osc}.rpc_stats |
5854 awk '$1 == "4:" { print $2; exit; }')
5855 local rpc32k=$($LCTL get_param -n ${osc}.rpc_stats |
5856 awk '$1 == "8:" { print $2; exit; }')
5858 [ $rpc4k != 0 ] && error "Small 4k read IO ${rpc4k}!"
5859 [ $rpc8k != 0 ] && error "Small 8k read IO ${rpc8k}!"
5860 [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
5861 [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
5862 echo "${osc} rpc check passed!"
5867 run_test 101c "check stripe_size aligned read-ahead ================="
5870 $LCTL get_param -n llite.*.max_read_ahead_mb | head -n 1
5871 $LCTL set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
5875 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5876 local file=$DIR/$tfile
5877 local size=${FILESIZE_101c:-500}
5878 local ra_MB=${READAHEAD_MB:-40}
5880 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5881 [ $space -gt $((size * 1024)) ] ||
5882 { skip "Need free space ${size}M, have $space" && return; }
5884 echo Creating ${size}M test file $file
5885 dd if=/dev/zero of=$file bs=1M count=$size || error "dd failed"
5886 echo Cancel LRU locks on lustre client to flush the client cache
5887 cancel_lru_locks osc
5889 echo Disable read-ahead
5890 local old_READAHEAD=$(set_read_ahead 0)
5892 echo Reading the test file $file with read-ahead disabled
5893 time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5895 echo Cancel LRU locks on lustre client to flush the client cache
5896 cancel_lru_locks osc
5897 echo Enable read-ahead with ${ra_MB}MB
5898 set_read_ahead $ra_MB
5900 echo Reading the test file $file with read-ahead enabled
5901 time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
5903 echo read-ahead disabled time read $time_ra_OFF
5904 echo read-ahead enabled time read $time_ra_ON
5906 set_read_ahead $old_READAHEAD
5908 wait_delete_completed
5910 [ $time_ra_ON -lt $time_ra_OFF ] ||
5911 error "read-ahead enabled time read (${time_ra_ON}s) is more than
5912 read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
5914 run_test 101d "file read with and without read-ahead enabled ================="
5917 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5918 local file=$DIR/$tfile
5923 local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
5924 local need_space=$((count * size))
5925 [ $space -gt $need_space ] ||
5926 { skip_env "Need free space $need_space, have $space" && return; }
5928 echo Creating $count ${size}K test files
5929 for ((i = 0; i < $count; i++)); do
5930 dd if=/dev/zero of=${file}_${i} bs=$blksize count=$size 2>/dev/null
5933 echo Cancel LRU locks on lustre client to flush the client cache
5934 cancel_lru_locks osc
5936 echo Reset readahead stats
5937 $LCTL set_param -n llite.*.read_ahead_stats 0
5939 for ((i = 0; i < $count; i++)); do
5940 dd if=${file}_${i} of=/dev/null bs=$blksize count=$size 2>/dev/null
5943 local miss=$($LCTL get_param -n llite.*.read_ahead_stats | \
5944 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5946 for ((i = 0; i < $count; i++)); do
5947 rm -rf ${file}_${i} 2>/dev/null
5950 #10000 means 20% reads are missing in readahead
5951 [ $miss -lt 10000 ] || error "misses too much for small reads"
5953 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
5955 cleanup_test101f() {
5957 $LCTL set_param -n llite.*.max_read_ahead_whole_mb $MAX_WHOLE_MB
5958 rm -rf $DIR/$tfile 2>/dev/null
5962 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
5963 local file=$DIR/$tfile
5966 MAX_WHOLE_MB=$($LCTL get_param -n llite.*.max_read_ahead_whole_mb)
5967 $LCTL set_param -n llite.*.max_read_ahead_whole_mb 2
5968 dd if=/dev/zero of=${file} bs=2097152 count=1 2>/dev/null
5969 trap cleanup_test101f EXIT
5971 echo Cancel LRU locks on lustre client to flush the client cache
5972 cancel_lru_locks osc
5974 echo Reset readahead stats
5975 $LCTL set_param -n llite.*.read_ahead_stats 0
5976 # Random read in a 2M file, because max_read_ahead_whole_mb = 2M,
5977 # readahead should read in 2M file on second read, so only miss
5979 echo Random 4K reads on 2M file for 1000 times
5980 $READS -f $file -s 2097152 -b 4096 -n $nreads
5982 echo checking missing pages
5983 local miss=$($LCTL get_param -n llite.*.read_ahead_stats |
5984 get_named_value 'misses' | cut -d" " -f1 | calc_total)
5986 [ $miss -lt 3 ] || error "misses too much pages!"
5989 run_test 101f "check read-ahead for max_read_ahead_whole_mb"
5992 test_mkdir -p $DIR/$tdir
5993 chown $RUNAS_ID $DIR/$tdir
5996 STRIPE_COUNT=$OSTCOUNT
5997 [ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
5999 trap cleanup_test102 EXIT
6001 $1 $SETSTRIPE -S $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT $tdir
6003 for num in 1 2 3 4; do
6004 for count in $(seq 1 $STRIPE_COUNT); do
6005 for idx in $(seq 0 $[$STRIPE_COUNT - 1]); do
6006 local size=`expr $STRIPE_SIZE \* $num`
6007 local file=file"$num-$idx-$count"
6008 $1 $SETSTRIPE -S $size -i $idx -c $count $file
6014 $1 $TAR cf $TMP/f102.tar $tdir --xattrs
6020 rm -rf $DIR/d0.sanity/d102
6024 local testfile=$DIR/xattr_testfile
6028 [ "$UID" != 0 ] && skip_env "must run as root" && return
6029 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
6030 skip_env "must have user_xattr" && return
6032 [ -z "$(which setfattr 2>/dev/null)" ] &&
6033 skip_env "could not find setfattr" && return
6035 echo "set/get xattr..."
6036 setfattr -n trusted.name1 -v value1 $testfile ||
6037 error "setfattr -n trusted.name1=value1 $testfile failed"
6038 getfattr -n trusted.name1 $testfile 2> /dev/null |
6039 grep "trusted.name1=.value1" ||
6040 error "$testfile missing trusted.name1=value1"
6042 setfattr -n user.author1 -v author1 $testfile ||
6043 error "setfattr -n user.author1=author1 $testfile failed"
6044 getfattr -n user.author1 $testfile 2> /dev/null |
6045 grep "user.author1=.author1" ||
6046 error "$testfile missing trusted.author1=author1"
6049 setfattr -n trusted.name2 -v value2 $testfile ||
6050 error "$testfile unable to set trusted.name2"
6051 setfattr -n trusted.name3 -v value3 $testfile ||
6052 error "$testfile unable to set trusted.name3"
6053 [ $(getfattr -d -m "^trusted" $testfile 2> /dev/null |
6054 grep "trusted.name" | wc -l) -eq 3 ] ||
6055 error "$testfile missing 3 trusted.name xattrs"
6057 setfattr -n user.author2 -v author2 $testfile ||
6058 error "$testfile unable to set user.author2"
6059 setfattr -n user.author3 -v author3 $testfile ||
6060 error "$testfile unable to set user.author3"
6061 [ $(getfattr -d -m "^user" $testfile 2> /dev/null |
6062 grep "user.author" | wc -l) -eq 3 ] ||
6063 error "$testfile missing 3 user.author xattrs"
6065 echo "remove xattr..."
6066 setfattr -x trusted.name1 $testfile ||
6067 error "$testfile error deleting trusted.name1"
6068 getfattr -d -m trusted $testfile 2> /dev/null | grep "trusted.name1" &&
6069 error "$testfile did not delete trusted.name1 xattr"
6071 setfattr -x user.author1 $testfile ||
6072 error "$testfile error deleting user.author1"
6073 getfattr -d -m user $testfile 2> /dev/null | grep "user.author1" &&
6074 error "$testfile did not delete trusted.name1 xattr"
6076 # b10667: setting lustre special xattr be silently discarded
6077 echo "set lustre special xattr ..."
6078 setfattr -n "trusted.lov" -v "invalid value" $testfile ||
6079 error "$testfile allowed setting trusted.lov"
6081 run_test 102a "user xattr test =================================="
6084 # b10930: get/set/list trusted.lov xattr
6085 echo "get/set/list trusted.lov xattr ..."
6086 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6087 local testfile=$DIR/$tfile
6088 $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6089 error "setstripe failed"
6090 local STRIPECOUNT=$($GETSTRIPE -c $testfile) ||
6091 error "getstripe failed"
6092 getfattr -d -m "^trusted" $testfile 2> /dev/null | \
6093 grep "trusted.lov" || error "can't get trusted.lov from $testfile"
6095 local testfile2=${testfile}2
6096 local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
6097 grep "trusted.lov" |sed -e 's/[^=]\+=//'`
6100 setfattr -n trusted.lov -v $value $testfile2
6101 local stripe_size=$($GETSTRIPE -S $testfile2)
6102 local stripe_count=$($GETSTRIPE -c $testfile2)
6103 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6104 [ $stripe_count -eq $STRIPECOUNT ] ||
6105 error "stripe count $stripe_count != $STRIPECOUNT"
6108 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
6111 # b10930: get/set/list lustre.lov xattr
6112 echo "get/set/list lustre.lov xattr ..."
6113 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
6114 test_mkdir -p $DIR/$tdir
6115 chown $RUNAS_ID $DIR/$tdir
6116 local testfile=$DIR/$tdir/$tfile
6117 $RUNAS $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
6118 error "setstripe failed"
6119 local STRIPECOUNT=$($RUNAS $GETSTRIPE -c $testfile) ||
6120 error "getstripe failed"
6121 $RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
6122 grep "lustre.lov" || error "can't get lustre.lov from $testfile"
6124 local testfile2=${testfile}2
6125 local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
6126 grep "lustre.lov" |sed -e 's/[^=]\+=//' `
6128 $RUNAS $MCREATE $testfile2
6129 $RUNAS setfattr -n lustre.lov -v $value $testfile2
6130 local stripe_size=$($RUNAS $GETSTRIPE -S $testfile2)
6131 local stripe_count=$($RUNAS $GETSTRIPE -c $testfile2)
6132 [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
6133 [ $stripe_count -eq $STRIPECOUNT ] ||
6134 error "stripe count $stripe_count != $STRIPECOUNT"
6136 run_test 102c "non-root getfattr/setfattr for lustre.lov EAs ==========="
6138 compare_stripe_info1() {
6139 local stripe_index_all_zero=true
6141 for num in 1 2 3 4; do
6142 for count in $(seq 1 $STRIPE_COUNT); do
6143 for offset in $(seq 0 $[$STRIPE_COUNT - 1]); do
6144 local size=$((STRIPE_SIZE * num))
6145 local file=file"$num-$offset-$count"
6146 stripe_size=$(lfs getstripe -S $PWD/$file)
6147 [ $stripe_size -ne $size ] &&
6148 error "$file: size $stripe_size != $size"
6149 stripe_count=$(lfs getstripe -c $PWD/$file)
6150 # allow fewer stripes to be created, ORI-601
6151 [ $stripe_count -lt $(((3 * count + 3) / 4)) ]&&
6152 error "$file: count $stripe_count != $count"
6153 stripe_index=$(lfs getstripe -i $PWD/$file)
6154 [ $stripe_index -ne 0 ] &&
6155 stripe_index_all_zero=false
6159 $stripe_index_all_zero &&
6160 error "all files are being extracted starting from OST index 0"
6165 [ -n "$(which tar 2>/dev/null)" ] &&
6166 strings $(which tar) | grep -q "lustre" && echo tar
6170 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6171 # b10930: tar test for trusted.lov xattr
6172 TAR=$(find_lustre_tar)
6173 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6174 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6176 test_mkdir -p $DIR/d102d
6177 $TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
6179 compare_stripe_info1
6181 run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
6184 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6185 # b10930: tar test for trusted.lov xattr
6186 TAR=$(find_lustre_tar)
6187 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6188 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6190 test_mkdir -p $DIR/d102f
6192 $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
6194 compare_stripe_info1
6196 run_test 102f "tar copy files, not keep osts ==========="
6199 local xsize=${1:-1024} # in bytes
6200 local file=$DIR/$tfile
6202 [ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
6203 skip "must have user_xattr" && return 0
6204 [ -z "$(which setfattr 2>/dev/null)" ] &&
6205 skip_env "could not find setfattr" && return 0
6206 [ -z "$(which getfattr 2>/dev/null)" ] &&
6207 skip_env "could not find getfattr" && return 0
6211 local value="$(generate_string $xsize)"
6213 local xbig=trusted.big
6214 log "save $xbig on $file"
6215 setfattr -n $xbig -v $value $file ||
6216 error "saving $xbig on $file failed"
6218 local orig=$(get_xattr_value $xbig $file)
6219 [[ "$orig" != "$value" ]] && error "$xbig different after saving $xbig"
6221 local xsml=trusted.sml
6222 log "save $xsml on $file"
6223 setfattr -n $xsml -v val $file || error "saving $xsml on $file failed"
6225 local new=$(get_xattr_value $xbig $file)
6226 [[ "$new" != "$orig" ]] && error "$xbig different after saving $xsml"
6228 log "grow $xsml on $file"
6229 setfattr -n $xsml -v "$value" $file ||
6230 error "growing $xsml on $file failed"
6232 new=$(get_xattr_value $xbig $file)
6233 [[ "$new" != "$orig" ]] && error "$xbig different after growing $xsml"
6234 log "$xbig still valid after growing $xsml"
6239 test_102h() { # bug 15777
6242 run_test 102h "grow xattr from inside inode to external block"
6245 large_xattr_enabled || { skip "large_xattr disabled" && return; }
6246 grow_xattr $(max_xattr_size)
6248 run_test 102ha "grow xattr from inside inode to external inode"
6250 test_102i() { # bug 17038
6252 ln -s $DIR/$tfile $DIR/${tfile}link
6253 getfattr -n trusted.lov $DIR/$tfile || error "lgetxattr on $DIR/$tfile failed"
6254 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"
6255 rm -f $DIR/$tfile $DIR/${tfile}link
6257 run_test 102i "lgetxattr test on symbolic link ============"
6260 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6261 TAR=$(find_lustre_tar)
6262 [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
6263 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping N-stripe test" && return
6264 setup_test102 "$RUNAS"
6265 test_mkdir -p $DIR/d102j
6266 chown $RUNAS_ID $DIR/d102j
6267 $RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
6269 compare_stripe_info1 "$RUNAS"
6271 run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
6275 # b22187 just check that does not crash for regular file.
6276 setfattr -n trusted.lov $DIR/$tfile
6277 # b22187 'setfattr -n trusted.lov' should work as remove LOV EA for directories
6278 local test_kdir=$DIR/d102k
6279 test_mkdir $test_kdir
6280 local default_size=`$GETSTRIPE -S $test_kdir`
6281 local default_count=`$GETSTRIPE -c $test_kdir`
6282 local default_offset=`$GETSTRIPE -i $test_kdir`
6283 $SETSTRIPE -S 65536 -i 0 -c $OSTCOUNT $test_kdir ||
6284 error 'dir setstripe failed'
6285 setfattr -n trusted.lov $test_kdir
6286 local stripe_size=`$GETSTRIPE -S $test_kdir`
6287 local stripe_count=`$GETSTRIPE -c $test_kdir`
6288 local stripe_offset=`$GETSTRIPE -i $test_kdir`
6289 [ $stripe_size -eq $default_size ] ||
6290 error "stripe size $stripe_size != $default_size"
6291 [ $stripe_count -eq $default_count ] ||
6292 error "stripe count $stripe_count != $default_count"
6293 [ $stripe_offset -eq $default_offset ] ||
6294 error "stripe offset $stripe_offset != $default_offset"
6295 rm -rf $DIR/$tfile $test_kdir
6297 run_test 102k "setfattr without parameter of value shouldn't cause a crash"
6300 # LU-532 trusted. xattr is invisible to non-root
6301 local testfile=$DIR/$tfile
6305 echo "listxattr as user..."
6306 chown $RUNAS_ID $testfile
6307 $RUNAS getfattr -d -m '.*' $testfile 2>&1 |
6308 grep -q "trusted" &&
6309 error "$testfile trusted xattrs are user visible"
6313 run_test 102l "listxattr filter test =================================="
6319 $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
6324 [ "$UID" != 0 ] && skip_env "must run as root" && return
6325 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
6326 skip "must have acl enabled" && return
6327 [ -z "$(which setfacl 2>/dev/null)" ] &&
6328 skip_env "could not find setfacl" && return
6329 $GSS && skip "could not run under gss" && return
6331 declare -a identity_old
6333 for num in $(seq $MDSCOUNT); do
6334 switch_identity $num true || identity_old[$num]=$?
6341 echo "performing cp ..."
6342 run_acl_subtest cp || error "run_acl_subtest cp failed"
6343 echo "performing getfacl-noacl..."
6344 run_acl_subtest getfacl-noacl || error "getfacl-noacl test failed"
6345 echo "performing misc..."
6346 run_acl_subtest misc || error "misc test failed"
6347 echo "performing permissions..."
6348 run_acl_subtest permissions || error "permissions failed"
6349 echo "performing setfacl..."
6350 run_acl_subtest setfacl || error "setfacl test failed"
6352 # inheritance test got from HP
6353 echo "performing inheritance..."
6354 cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
6355 chmod +x make-tree || error "chmod +x failed"
6356 run_acl_subtest inheritance || error "inheritance test failed"
6359 echo "LU-974 ignore umask when acl is enabled..."
6360 run_acl_subtest 974 || error "LU-974 umask test failed"
6361 if [ $MDSCOUNT -ge 2 ]; then
6362 run_acl_subtest 974_remote ||
6363 error "LU-974 umask test failed under remote dir"
6366 echo "LU-2561 newly created file is same size as directory..."
6367 run_acl_subtest 2561 || error "LU-2561 test failed"
6372 for num in $(seq $MDSCOUNT); do
6373 if [ "${identity_old[$num]}" = 1 ]; then
6374 switch_identity $num false || identity_old[$num]=$?
6378 run_test 103 "acl test ========================================="
6381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6383 lfs df || error "lfs df failed"
6384 lfs df -ih || error "lfs df -ih failed"
6385 lfs df -h $DIR || error "lfs df -h $DIR failed"
6386 lfs df -i $DIR || error "lfs df -i $DIR failed"
6387 lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
6388 lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
6390 local OSC=$(lctl dl | grep OST0000-osc-[^M] | awk '{ print $4 }')
6391 lctl --device %$OSC deactivate
6392 lfs df || error "lfs df with deactivated OSC failed"
6393 lctl --device %$OSC activate
6394 # wait the osc back to normal
6395 wait_osc_import_state client ost FULL
6397 lfs df || error "lfs df with reactivated OSC failed"
6400 run_test 104a "lfs df [-ih] [path] test ========================="
6403 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6404 [ $RUNAS_ID -eq $UID ] &&
6405 skip_env "RUNAS_ID = UID = $UID -- skipping" && return
6407 denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
6408 grep "Permission denied" | wc -l)))
6409 if [ $denied_cnt -ne 0 ]; then
6410 error "lfs check servers test failed"
6413 run_test 104b "$RUNAS lfs check servers test ===================="
6416 # doesn't work on 2.4 kernels
6418 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6419 flocks_test 1 on -f $DIR/$tfile || error "fail flock on"
6421 flocks_test 1 off -f $DIR/$tfile || error "fail flock off"
6425 run_test 105a "flock when mounted without -o flock test ========"
6429 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6430 flocks_test 1 on -c $DIR/$tfile || error "fail flock on"
6432 flocks_test 1 off -c $DIR/$tfile || error "fail flock off"
6436 run_test 105b "fcntl when mounted without -o flock test ========"
6440 if [ -n "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ]; then
6441 flocks_test 1 on -l $DIR/$tfile || error "fail flock on"
6443 flocks_test 1 off -l $DIR/$tfile || error "fail flock off"
6447 run_test 105c "lockf when mounted without -o flock test ========"
6449 test_105d() { # bug 15924
6450 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6451 test_mkdir -p $DIR/$tdir
6452 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6453 skip "mount w/o flock enabled" && return
6454 #define OBD_FAIL_LDLM_CP_CB_WAIT 0x315
6455 $LCTL set_param fail_loc=0x80000315
6456 flocks_test 2 $DIR/$tdir
6458 run_test 105d "flock race (should not freeze) ========"
6460 test_105e() { # bug 22660 && 22040
6461 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] &&
6462 skip "mount w/o flock enabled" && return
6464 flocks_test 3 $DIR/$tfile
6466 run_test 105e "Two conflicting flocks from same process ======="
6468 test_106() { #bug 10921
6469 test_mkdir -p $DIR/$tdir
6470 $DIR/$tdir && error "exec $DIR/$tdir succeeded"
6471 chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
6473 run_test 106 "attempt exec of dir followed by chown of that dir"
6476 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6483 local save_pattern=$(sysctl -n kernel.core_pattern)
6484 local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
6485 sysctl -w kernel.core_pattern=$file
6486 sysctl -w kernel.core_uses_pid=0
6494 kill -s 11 $SLEEPPID
6496 if [ -e $file ]; then
6497 size=`stat -c%s $file`
6498 [ $size -eq 0 ] && error "Fail to create core file $file"
6500 error "Fail to create core file $file"
6503 sysctl -w kernel.core_pattern=$save_pattern
6504 sysctl -w kernel.core_uses_pid=$save_uses_pid
6507 run_test 107 "Coredump on SIG"
6510 test_mkdir -p $DIR/$tdir
6511 test_mkdir $DIR/$tdir/$(str_repeat 'a' 255) ||
6512 error "mkdir with 255 char failed"
6513 test_mkdir $DIR/$tdir/$(str_repeat 'b' 256) &&
6514 error "mkdir with 256 char should fail, but did not"
6515 touch $DIR/$tdir/$(str_repeat 'x' 255) ||
6516 error "create with 255 char failed"
6517 touch $DIR/$tdir/$(str_repeat 'y' 256) &&
6518 error "create with 256 char should fail, but did not"
6523 run_test 110 "filename length checking"
6526 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6527 OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6529 [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
6531 echo "Starting with $OSTIO_pre threads"
6534 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
6535 [ $NUMFREE -lt $NUMTEST ] && NUMTEST=$(($NUMFREE - 1000))
6536 echo "$NUMTEST creates/unlinks"
6537 test_mkdir -p $DIR/$tdir
6538 createmany -o $DIR/$tdir/$tfile $NUMTEST
6539 unlinkmany $DIR/$tdir/$tfile $NUMTEST
6541 OSTIO_post=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
6544 # don't return an error
6545 [ $OSTIO_post == $OSTIO_pre ] && echo \
6546 "WARNING: No new ll_ost_io threads were created ($OSTIO_pre)" &&
6547 echo "This may be fine, depending on what ran before this test" &&
6548 echo "and how fast this system is." && return
6550 echo "Started with $OSTIO_pre threads, ended with $OSTIO_post"
6552 run_test 115 "verify dynamic thread creation===================="
6555 wait_delete_completed
6556 AVAIL=($(lctl get_param -n osc.*[oO][sS][cC]-[^M]*.kbytesavail))
6557 echo OST kbytes available: ${AVAIL[@]}
6558 MAXI=0; MAXV=${AVAIL[0]}
6559 MINI=0; MINV=${AVAIL[0]}
6560 for ((i = 0; i < ${#AVAIL[@]}; i++)); do
6561 #echo OST $i: ${AVAIL[i]}kb
6562 if [ ${AVAIL[i]} -gt $MAXV ]; then
6563 MAXV=${AVAIL[i]}; MAXI=$i
6565 if [ ${AVAIL[i]} -lt $MINV ]; then
6566 MINV=${AVAIL[i]}; MINI=$i
6569 echo Min free space: OST $MINI: $MINV
6570 echo Max free space: OST $MAXI: $MAXV
6573 test_116a() { # was previously test_116()
6574 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6575 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs" && return
6577 echo -n "Free space priority "
6578 lctl get_param -n lov.*-clilov-*.qos_prio_free
6581 [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
6584 # generate uneven OSTs
6585 test_mkdir -p $DIR/$tdir/OST${MINI}
6588 echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
6589 $SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
6591 while [ $FILL -gt 0 ]; do
6593 dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
6594 FILL=$(($FILL - 2048))
6602 DIFF=$(($MAXV - $MINV))
6603 DIFF2=$(($DIFF * 100 / $MINV))
6604 echo -n "diff=${DIFF}=${DIFF2}% must be > 20% for QOS mode..."
6605 if [ $DIFF2 -gt 20 ]; then
6608 echo "failed - QOS mode won't be used"
6609 error_ignore "QOS imbalance criteria not met"
6613 MINI1=$MINI; MINV1=$MINV
6614 MAXI1=$MAXI; MAXV1=$MAXV
6616 # now fill using QOS
6617 echo writing a bunch of files to QOS-assigned OSTs
6618 $SETSTRIPE -c 1 $DIR/$tdir
6620 while [ $FILL -gt 0 ]; do
6622 dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
6623 FILL=$(($FILL - 200))
6626 echo "wrote $i 200k files"
6630 echo "Note: free space may not be updated, so measurements might be off"
6632 DIFF2=$(($MAXV - $MINV))
6633 echo "free space delta: orig $DIFF final $DIFF2"
6634 [ $DIFF2 -gt $DIFF ] && echo "delta got worse!"
6635 DIFF=$(($MINV1 - ${AVAIL[$MINI1]}))
6636 echo "Wrote $DIFF to smaller OST $MINI1"
6637 DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
6638 echo "Wrote $DIFF2 to larger OST $MAXI1"
6639 [ $DIFF -gt 0 ] && echo "Wrote $(($DIFF2 * 100 / $DIFF - 100))% more data to larger OST $MAXI1"
6641 # Figure out which files were written where
6642 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6643 awk '/'$MINI1': / {print $2; exit}')
6645 MINC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6646 echo "$MINC files created on smaller OST $MINI1"
6647 UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
6648 awk '/'$MAXI1': / {print $2; exit}')
6650 MAXC=$($GETSTRIPE --obd $UUID $DIR/$tdir | wc -l)
6651 echo "$MAXC files created on larger OST $MAXI1"
6652 [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
6653 [ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
6657 run_test 116a "stripe QOS: free space balance ==================="
6659 test_116b() { # LU-2093
6660 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6661 #define OBD_FAIL_MDS_OSC_CREATE_FAIL 0x147
6663 old_rr=$(do_facet $SINGLEMDS lctl get_param -n lov.*mdtlov*.qos_threshold_rr)
6664 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr 0
6666 do_facet $SINGLEMDS lctl set_param fail_loc=0x147
6667 createmany -o $DIR/$tdir/f- 20 || error "can't create"
6668 do_facet $SINGLEMDS lctl set_param fail_loc=0
6670 do_facet $SINGLEMDS lctl set_param lov.*mdtlov*.qos_threshold_rr $old_rr
6672 run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
6674 test_117() # bug 10891
6676 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6677 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
6678 #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
6679 lctl set_param fail_loc=0x21e
6680 > $DIR/$tfile || error "truncate failed"
6681 lctl set_param fail_loc=0
6682 echo "Truncate succeeded."
6685 run_test 117 "verify fsfilt_extend =========="
6687 NO_SLOW_RESENDCOUNT=4
6688 export OLD_RESENDCOUNT=""
6689 set_resend_count () {
6690 local PROC_RESENDCOUNT="osc.${FSNAME}-OST*-osc-*.resend_count"
6691 OLD_RESENDCOUNT=$(lctl get_param -n $PROC_RESENDCOUNT | head -1)
6692 lctl set_param -n $PROC_RESENDCOUNT $1
6693 echo resend_count is set to $(lctl get_param -n $PROC_RESENDCOUNT)
6696 # for reduce test_118* time (b=14842)
6697 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6699 # Reset async IO behavior after error case
6701 FILE=$DIR/reset_async
6703 # Ensure all OSCs are cleared
6704 $SETSTRIPE -c -1 $FILE
6705 dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
6710 test_118a() #bug 11710
6712 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6715 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6716 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6717 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6719 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6720 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6725 run_test 118a "verify O_SYNC works =========="
6729 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6730 remote_ost_nodsh && skip "remote OST with nodsh" && return
6734 #define OBD_FAIL_OST_ENOENT 0x217
6735 set_nodes_failloc "$(osts_nodes)" 0x217
6736 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6738 set_nodes_failloc "$(osts_nodes)" 0
6739 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6740 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6743 if [[ $RC -eq 0 ]]; then
6744 error "Must return error due to dropped pages, rc=$RC"
6748 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6749 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6753 echo "Dirty pages not leaked on ENOENT"
6755 # Due to the above error the OSC will issue all RPCs syncronously
6756 # until a subsequent RPC completes successfully without error.
6757 $MULTIOP $DIR/$tfile Ow4096yc
6762 run_test 118b "Reclaim dirty pages on fatal error =========="
6766 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6768 # for 118c, restore the original resend count, LU-1940
6769 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
6770 set_resend_count $OLD_RESENDCOUNT
6771 remote_ost_nodsh && skip "remote OST with nodsh" && return
6775 #define OBD_FAIL_OST_EROFS 0x216
6776 set_nodes_failloc "$(osts_nodes)" 0x216
6778 # multiop should block due to fsync until pages are written
6779 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6783 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6784 error "Multiop failed to block on fsync, pid=$MULTIPID"
6787 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6789 if [[ $WRITEBACK -eq 0 ]]; then
6790 error "No page in writeback, writeback=$WRITEBACK"
6793 set_nodes_failloc "$(osts_nodes)" 0
6796 if [[ $RC -ne 0 ]]; then
6797 error "Multiop fsync failed, rc=$RC"
6800 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6801 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6803 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6804 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6808 echo "Dirty pages flushed via fsync on EROFS"
6811 run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
6813 # continue to use small resend count to reduce test_118* time (b=14842)
6814 [ "$SLOW" = "no" ] && set_resend_count $NO_SLOW_RESENDCOUNT
6818 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6819 remote_ost_nodsh && skip "remote OST with nodsh" && return
6823 #define OBD_FAIL_OST_BRW_PAUSE_BULK
6824 set_nodes_failloc "$(osts_nodes)" 0x214
6825 # multiop should block due to fsync until pages are written
6826 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6830 if [[ `ps h -o comm -p $MULTIPID` != "multiop" ]]; then
6831 error "Multiop failed to block on fsync, pid=$MULTIPID"
6834 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6836 if [[ $WRITEBACK -eq 0 ]]; then
6837 error "No page in writeback, writeback=$WRITEBACK"
6840 wait $MULTIPID || error "Multiop fsync failed, rc=$?"
6841 set_nodes_failloc "$(osts_nodes)" 0
6843 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6844 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6846 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6847 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6851 echo "Dirty pages gaurenteed flushed via fsync"
6854 run_test 118d "Fsync validation inject a delay of the bulk =========="
6857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6860 #define OBD_FAIL_OSC_BRW_PREP_REQ2 0x40a
6861 lctl set_param fail_loc=0x8000040a
6863 # Should simulate EINVAL error which is fatal
6864 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6866 if [[ $RC -eq 0 ]]; then
6867 error "Must return error due to dropped pages, rc=$RC"
6870 lctl set_param fail_loc=0x0
6872 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6873 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6874 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6876 if [[ $LOCKED -ne 0 ]]; then
6877 error "Locked pages remain in cache, locked=$LOCKED"
6880 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6881 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6885 echo "No pages locked after fsync"
6890 run_test 118f "Simulate unrecoverable OSC side error =========="
6893 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6896 #define OBD_FAIL_OSC_BRW_PREP_REQ 0x406
6897 lctl set_param fail_loc=0x406
6899 # simulate local -ENOMEM
6900 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6903 lctl set_param fail_loc=0
6904 if [[ $RC -eq 0 ]]; then
6905 error "Must return error due to dropped pages, rc=$RC"
6908 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6909 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6910 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6912 if [[ $LOCKED -ne 0 ]]; then
6913 error "Locked pages remain in cache, locked=$LOCKED"
6916 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6917 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6921 echo "No pages locked after fsync"
6926 run_test 118g "Don't stay in wait if we got local -ENOMEM =========="
6929 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6930 remote_ost_nodsh && skip "remote OST with nodsh" && return
6934 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6935 set_nodes_failloc "$(osts_nodes)" 0x20e
6936 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6937 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
6940 set_nodes_failloc "$(osts_nodes)" 0
6941 if [[ $RC -eq 0 ]]; then
6942 error "Must return error due to dropped pages, rc=$RC"
6945 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6946 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6947 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache |
6949 if [[ $LOCKED -ne 0 ]]; then
6950 error "Locked pages remain in cache, locked=$LOCKED"
6953 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6954 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6958 echo "No pages locked after fsync"
6962 run_test 118h "Verify timeout in handling recoverables errors =========="
6964 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
6967 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
6968 remote_ost_nodsh && skip "remote OST with nodsh" && return
6972 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
6973 set_nodes_failloc "$(osts_nodes)" 0x20e
6975 # Should simulate ENOMEM error which is recoverable and should be handled by timeout
6976 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
6979 set_nodes_failloc "$(osts_nodes)" 0
6983 if [[ $RC -ne 0 ]]; then
6984 error "got error, but should be not, rc=$RC"
6987 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
6988 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
6989 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
6990 if [[ $LOCKED -ne 0 ]]; then
6991 error "Locked pages remain in cache, locked=$LOCKED"
6994 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
6995 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
6999 echo "No pages locked after fsync"
7003 run_test 118i "Fix error before timeout in recoverable error =========="
7005 [ "$SLOW" = "no" ] && set_resend_count 4
7008 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7009 remote_ost_nodsh && skip "remote OST with nodsh" && return
7013 #define OBD_FAIL_OST_BRW_WRITE_BULK2 0x220
7014 set_nodes_failloc "$(osts_nodes)" 0x220
7016 # return -EIO from OST
7017 $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
7019 set_nodes_failloc "$(osts_nodes)" 0x0
7020 if [[ $RC -eq 0 ]]; then
7021 error "Must return error due to dropped pages, rc=$RC"
7024 LOCKED=$(lctl get_param -n llite.*.dump_page_cache | grep -c locked)
7025 DIRTY=$(lctl get_param -n llite.*.dump_page_cache | grep -c dirty)
7026 WRITEBACK=$(lctl get_param -n llite.*.dump_page_cache | grep -c writeback)
7027 if [[ $LOCKED -ne 0 ]]; then
7028 error "Locked pages remain in cache, locked=$LOCKED"
7031 # in recoverable error on OST we want resend and stay until it finished
7032 if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
7033 error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
7037 echo "No pages locked after fsync"
7041 run_test 118j "Simulate unrecoverable OST side error =========="
7045 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7046 remote_ost_nodsh && skip "remote OSTs with nodsh" && return
7048 #define OBD_FAIL_OST_BRW_WRITE_BULK 0x20e
7049 set_nodes_failloc "$(osts_nodes)" 0x20e
7050 test_mkdir -p $DIR/$tdir
7052 for ((i=0;i<10;i++)); do
7053 (dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1M count=10 || \
7054 error "dd to $DIR/$tdir/$tfile-$i failed" )&
7061 set_nodes_failloc "$(osts_nodes)" 0
7064 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
7068 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7070 test_mkdir -p $DIR/$tdir
7071 $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
7074 run_test 118l "fsync dir ========="
7076 test_118m() # LU-3066
7078 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7079 test_mkdir -p $DIR/$tdir
7080 $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
7083 run_test 118m "fdatasync dir ========="
7085 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
7087 test_119a() # bug 11737
7089 BSIZE=$((512 * 1024))
7090 directio write $DIR/$tfile 0 1 $BSIZE
7091 # We ask to read two blocks, which is more than a file size.
7092 # directio will indicate an error when requested and actual
7093 # sizes aren't equeal (a normal situation in this case) and
7094 # print actual read amount.
7095 NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
7096 if [ "$NOB" != "$BSIZE" ]; then
7097 error "read $NOB bytes instead of $BSIZE"
7101 run_test 119a "Short directIO read must return actual read amount"
7103 test_119b() # bug 11737
7105 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping 2-stripe test" && return
7107 $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
7108 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
7110 $MULTIOP $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
7111 error "direct read failed"
7114 run_test 119b "Sparse directIO read must return actual read amount"
7116 test_119c() # bug 13099
7119 directio write $DIR/$tfile 3 1 $BSIZE || error "direct write failed"
7120 directio readhole $DIR/$tfile 0 2 $BSIZE || error "reading hole failed"
7123 run_test 119c "Testing for direct read hitting hole"
7125 test_119d() # bug 15950
7127 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7128 MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
7129 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
7131 $SETSTRIPE $DIR/$tfile -i 0 -c 1 || error "setstripe failed"
7132 $DIRECTIO write $DIR/$tfile 0 1 $BSIZE || error "first directio failed"
7133 #define OBD_FAIL_OSC_DIO_PAUSE 0x40d
7134 lctl set_param fail_loc=0x40d
7135 $DIRECTIO write $DIR/$tfile 1 4 $BSIZE &
7138 cat $DIR/$tfile > /dev/null &
7139 lctl set_param fail_loc=0
7142 log "the DIO writes have completed, now wait for the reads (should not block very long)"
7144 [ -n "`ps h -p $pid_reads -o comm`" ] && \
7145 error "the read rpcs have not completed in 2s"
7147 $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight $MAX_RPCS_IN_FLIGHT
7149 run_test 119d "The DIO path should try to send a new rpc once one is completed"
7152 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7153 test_mkdir -p $DIR/$tdir
7154 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7155 skip "no early lock cancel on server" && return 0
7157 lru_resize_disable mdc
7158 lru_resize_disable osc
7159 cancel_lru_locks mdc
7160 # asynchronous object destroy at MDT could cause bl ast to client
7161 cancel_lru_locks osc
7163 stat $DIR/$tdir > /dev/null
7164 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7165 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7166 test_mkdir $DIR/$tdir/d1
7167 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7168 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7169 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7170 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7171 lru_resize_enable mdc
7172 lru_resize_enable osc
7174 run_test 120a "Early Lock Cancel: mkdir test"
7177 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7178 test_mkdir -p $DIR/$tdir
7179 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7180 skip "no early lock cancel on server" && return 0
7181 lru_resize_disable mdc
7182 lru_resize_disable osc
7183 cancel_lru_locks mdc
7184 stat $DIR/$tdir > /dev/null
7185 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7186 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7188 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7189 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7190 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7191 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7192 lru_resize_enable mdc
7193 lru_resize_enable osc
7195 run_test 120b "Early Lock Cancel: create test"
7198 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7199 test_mkdir -p $DIR/$tdir
7200 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7201 skip "no early lock cancel on server" && return 0
7202 lru_resize_disable mdc
7203 lru_resize_disable osc
7204 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7205 touch $DIR/$tdir/d1/f1
7206 cancel_lru_locks mdc
7207 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
7208 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7209 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7210 ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7211 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7212 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7213 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7214 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7215 lru_resize_enable mdc
7216 lru_resize_enable osc
7218 run_test 120c "Early Lock Cancel: link test"
7221 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7222 test_mkdir -p $DIR/$tdir
7223 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7224 skip "no early lock cancel on server" && return 0
7225 lru_resize_disable mdc
7226 lru_resize_disable osc
7228 cancel_lru_locks mdc
7229 stat $DIR/$tdir > /dev/null
7230 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7231 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7232 chmod a+x $DIR/$tdir
7233 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats | awk '/ldlm_cancel/ {print $2}'`
7234 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats | awk '/ldlm_bl_callback/ {print $2}'`
7235 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7236 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7237 lru_resize_enable mdc
7238 lru_resize_enable osc
7240 run_test 120d "Early Lock Cancel: setattr test"
7243 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7244 test_mkdir -p $DIR/$tdir
7245 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7246 skip "no early lock cancel on server" && return 0
7247 lru_resize_disable mdc
7248 lru_resize_disable osc
7249 dd if=/dev/zero of=$DIR/$tdir/f1 count=1
7250 cancel_lru_locks mdc
7251 cancel_lru_locks osc
7252 dd if=$DIR/$tdir/f1 of=/dev/null
7253 stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
7254 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7255 awk '/ldlm_cancel/ {print $2}'`
7256 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7257 awk '/ldlm_bl_callback/ {print $2}'`
7258 unlink $DIR/$tdir/f1
7259 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7260 awk '/ldlm_cancel/ {print $2}'`
7261 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7262 awk '/ldlm_bl_callback/ {print $2}'`
7263 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7264 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7265 lru_resize_enable mdc
7266 lru_resize_enable osc
7268 run_test 120e "Early Lock Cancel: unlink test"
7271 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7272 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7273 skip "no early lock cancel on server" && return 0
7274 test_mkdir -p $DIR/$tdir
7275 lru_resize_disable mdc
7276 lru_resize_disable osc
7277 test_mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
7278 dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
7279 dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
7280 cancel_lru_locks mdc
7281 cancel_lru_locks osc
7282 dd if=$DIR/$tdir/d1/f1 of=/dev/null
7283 dd if=$DIR/$tdir/d2/f2 of=/dev/null
7284 stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
7285 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7286 awk '/ldlm_cancel/ {print $2}'`
7287 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7288 awk '/ldlm_bl_callback/ {print $2}'`
7289 mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
7290 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7291 awk '/ldlm_cancel/ {print $2}'`
7292 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7293 awk '/ldlm_bl_callback/ {print $2}'`
7294 [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
7295 [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
7296 lru_resize_enable mdc
7297 lru_resize_enable osc
7299 run_test 120f "Early Lock Cancel: rename test"
7302 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7303 [ -z "`lctl get_param -n mdc.*.connect_flags | grep early_lock_cancel`" ] && \
7304 skip "no early lock cancel on server" && return 0
7305 lru_resize_disable mdc
7306 lru_resize_disable osc
7308 echo create $count files
7309 test_mkdir -p $DIR/$tdir
7310 cancel_lru_locks mdc
7311 cancel_lru_locks osc
7314 can0=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7315 awk '/ldlm_cancel/ {print $2}'`
7316 blk0=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7317 awk '/ldlm_bl_callback/ {print $2}'`
7318 createmany -o $DIR/$tdir/f $count
7320 can1=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7321 awk '/ldlm_cancel/ {print $2}'`
7322 blk1=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7323 awk '/ldlm_bl_callback/ {print $2}'`
7325 echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
7326 echo rm $count files
7329 can2=`lctl get_param -n ldlm.services.ldlm_canceld.stats |
7330 awk '/ldlm_cancel/ {print $2}'`
7331 blk2=`lctl get_param -n ldlm.services.ldlm_cbd.stats |
7332 awk '/ldlm_bl_callback/ {print $2}'`
7334 echo total: $count removes in $((t2-t1))
7335 echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
7337 # wait for commitment of removal
7338 lru_resize_enable mdc
7339 lru_resize_enable osc
7341 run_test 120g "Early Lock Cancel: performance test"
7343 test_121() { #bug #10589
7344 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7346 writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
7347 #define OBD_FAIL_LDLM_CANCEL_RACE 0x310
7348 lctl set_param fail_loc=0x310
7349 cancel_lru_locks osc > /dev/null
7350 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
7351 lctl set_param fail_loc=0
7352 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
7354 run_test 121 "read cancel race ========="
7356 test_123a() { # was test 123, statahead(bug 11401)
7357 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7359 if [ -z "$(grep "processor.*: 1" /proc/cpuinfo)" ]; then
7360 log "testing on UP system. Performance may be not as good as expected."
7365 test_mkdir -p $DIR/$tdir
7366 NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
7367 [ $NUMFREE -gt 100000 ] && NUMFREE=100000 || NUMFREE=$((NUMFREE-1000))
7369 for ((i=100, j=0; i<=$NUMFREE; j=$i, i=$((i * MULT)) )); do
7370 createmany -o $DIR/$tdir/$tfile $j $((i - j))
7372 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7373 lctl set_param -n llite.*.statahead_max 0
7374 lctl get_param llite.*.statahead_max
7375 cancel_lru_locks mdc
7376 cancel_lru_locks osc
7378 time ls -l $DIR/$tdir | wc -l
7380 delta=$((etime - stime))
7381 log "ls $i files without statahead: $delta sec"
7382 lctl set_param llite.*.statahead_max=$max
7384 swrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7385 lctl get_param -n llite.*.statahead_max | grep '[0-9]'
7386 cancel_lru_locks mdc
7387 cancel_lru_locks osc
7389 time ls -l $DIR/$tdir | wc -l
7391 delta_sa=$((etime - stime))
7392 log "ls $i files with statahead: $delta_sa sec"
7393 lctl get_param -n llite.*.statahead_stats
7394 ewrong=`lctl get_param -n llite.*.statahead_stats | grep "statahead wrong:" | awk '{print $3}'`
7396 [ $swrong -lt $ewrong ] && log "statahead was stopped, maybe too many locks held!"
7397 [ $delta -eq 0 -o $delta_sa -eq 0 ] && continue
7399 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7400 max=`lctl get_param -n llite.*.statahead_max | head -n 1`
7401 lctl set_param -n llite.*.statahead_max 0
7402 lctl get_param llite.*.statahead_max
7403 cancel_lru_locks mdc
7404 cancel_lru_locks osc
7406 time ls -l $DIR/$tdir | wc -l
7408 delta=$((etime - stime))
7409 log "ls $i files again without statahead: $delta sec"
7410 lctl set_param llite.*.statahead_max=$max
7411 if [ $((delta_sa * 100)) -gt $((delta * 105)) -a $delta_sa -gt $((delta + 2)) ]; then
7412 if [ $SLOWOK -eq 0 ]; then
7413 error "ls $i files is slower with statahead!"
7415 log "ls $i files is slower with statahead!"
7421 [ $delta -gt 20 ] && break
7422 [ $delta -gt 8 ] && MULT=$((50 / delta))
7423 [ "$SLOW" = "no" -a $delta -gt 5 ] && break
7431 delta=$((etime - stime))
7432 log "rm -r $DIR/$tdir/: $delta seconds"
7434 lctl get_param -n llite.*.statahead_stats
7436 run_test 123a "verify statahead work"
7438 test_123b () { # statahead(bug 15027)
7439 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7440 test_mkdir -p $DIR/$tdir
7441 createmany -o $DIR/$tdir/$tfile-%d 1000
7443 cancel_lru_locks mdc
7444 cancel_lru_locks osc
7446 #define OBD_FAIL_MDC_GETATTR_ENQUEUE 0x803
7447 lctl set_param fail_loc=0x80000803
7448 ls -lR $DIR/$tdir > /dev/null
7450 lctl set_param fail_loc=0x0
7451 lctl get_param -n llite.*.statahead_stats
7456 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
7459 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7460 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7461 skip "no lru resize on server" && return 0
7463 test_mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
7465 log "create $NR files at $DIR/$tdir"
7466 createmany -o $DIR/$tdir/f $NR ||
7467 error "failed to create $NR files in $DIR/$tdir"
7469 cancel_lru_locks mdc
7470 ls -l $DIR/$tdir > /dev/null
7474 for VALUE in `lctl get_param ldlm.namespaces.*mdc-*.lru_size`; do
7475 local PARAM=`echo ${VALUE[0]} | cut -d "=" -f1`
7476 LRU_SIZE=$(lctl get_param -n $PARAM)
7477 if [ $LRU_SIZE -gt $(default_lru_size) ]; then
7478 NSDIR=$(echo $PARAM | cut -d "." -f1-3)
7480 log "NS=$(basename $NSDIR)"
7485 if [ -z "$NSDIR" -o $LRU_SIZE -lt $(default_lru_size) ]; then
7486 skip "Not enough cached locks created!"
7493 # We know that lru resize allows one client to hold $LIMIT locks
7494 # for 10h. After that locks begin to be killed by client.
7496 local LIMIT=`lctl get_param -n $NSDIR.pool.limit`
7499 # Make LVF so higher that sleeping for $SLEEP is enough to _start_
7500 # killing locks. Some time was spent for creating locks. This means
7501 # that up to the moment of sleep finish we must have killed some of
7502 # them (10-100 locks). This depends on how fast ther were created.
7503 # Many of them were touched in almost the same moment and thus will
7504 # be killed in groups.
7505 local LVF=$(($MAX_HRS * 60 * 60 / $SLEEP * $LIMIT / $LRU_SIZE))
7507 # Use $LRU_SIZE_B here to take into account real number of locks
7508 # created in the case of CMD, LRU_SIZE_B != $NR in most of cases
7509 local LRU_SIZE_B=$LRU_SIZE
7511 local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
7512 log "OLD_LVF=$OLD_LVF"
7513 lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
7515 # Let's make sure that we really have some margin. Client checks
7516 # cached locks every 10 sec.
7518 log "Sleep ${SLEEP} sec"
7520 while ((SEC<$SLEEP)); do
7524 LRU_SIZE=`lctl get_param -n $NSDIR/lru_size`
7528 lctl set_param -n $NSDIR.pool.lock_volume_factor $OLD_LVF
7529 local LRU_SIZE_A=`lctl get_param -n $NSDIR.lru_size`
7531 [ $LRU_SIZE_B -gt $LRU_SIZE_A ] || {
7532 error "No locks dropped in ${SLEEP}s. LRU size: $LRU_SIZE_A"
7533 unlinkmany $DIR/$tdir/f $NR
7537 log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in ${SLEEP}s"
7538 log "unlink $NR files at $DIR/$tdir"
7539 unlinkmany $DIR/$tdir/f $NR
7541 run_test 124a "lru resize ======================================="
7543 get_max_pool_limit()
7545 local limit=`lctl get_param -n ldlm.namespaces.*-MDT0000-mdc-*.pool.limit`
7548 if test $l -gt $max; then
7556 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7557 [ -z "`lctl get_param -n mdc.*.connect_flags | grep lru_resize`" ] && \
7558 skip "no lru resize on server" && return 0
7560 LIMIT=`get_max_pool_limit`
7562 NR=$(($(default_lru_size)*20))
7563 if [ $NR -gt $LIMIT ]; then
7564 log "Limit lock number by $LIMIT locks"
7567 lru_resize_disable mdc
7568 test_mkdir -p $DIR/$tdir/disable_lru_resize ||
7569 error "failed to create $DIR/$tdir/disable_lru_resize"
7571 createmany -o $DIR/$tdir/disable_lru_resize/f $NR
7572 log "doing ls -la $DIR/$tdir/disable_lru_resize 3 times"
7573 cancel_lru_locks mdc
7576 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7579 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7582 ls -la $DIR/$tdir/disable_lru_resize > /dev/null &
7586 nolruresize_delta=$((etime-stime))
7587 log "ls -la time: $nolruresize_delta seconds"
7588 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7589 unlinkmany $DIR/$tdir/disable_lru_resize/f $NR
7591 lru_resize_enable mdc
7592 test_mkdir -p $DIR/$tdir/enable_lru_resize ||
7593 error "failed to create $DIR/$tdir/enable_lru_resize"
7595 createmany -o $DIR/$tdir/enable_lru_resize/f $NR
7596 log "doing ls -la $DIR/$tdir/enable_lru_resize 3 times"
7597 cancel_lru_locks mdc
7600 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7603 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7606 ls -la $DIR/$tdir/enable_lru_resize > /dev/null &
7610 lruresize_delta=$((etime-stime))
7611 log "ls -la time: $lruresize_delta seconds"
7612 log "lru_size = $(lctl get_param -n ldlm.namespaces.*mdc*.lru_size)"
7614 if [ $lruresize_delta -gt $nolruresize_delta ]; then
7615 log "ls -la is $(((lruresize_delta - $nolruresize_delta) * 100 / $nolruresize_delta))% slower with lru resize enabled"
7616 elif [ $nolruresize_delta -gt $lruresize_delta ]; then
7617 log "ls -la is $(((nolruresize_delta - $lruresize_delta) * 100 / $nolruresize_delta))% faster with lru resize enabled"
7619 log "lru resize performs the same with no lru resize"
7621 unlinkmany $DIR/$tdir/enable_lru_resize/f $NR
7623 run_test 124b "lru resize (performance test) ======================="
7625 test_125() { # 13358
7626 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7627 [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
7628 test_mkdir -p $DIR/d125 || error "mkdir failed"
7629 $SETSTRIPE -S 65536 -c -1 $DIR/d125 || error "setstripe failed"
7630 setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
7631 ls -ld $DIR/d125 || error "cannot access $DIR/d125"
7633 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
7635 test_126() { # bug 12829/13455
7636 [ -z "$(lctl get_param -n llite.*.client_type | grep local)" ] && skip "must run as local client" && return
7637 [ "$UID" != 0 ] && skip_env "skipping $TESTNAME (must run as root)" && return
7638 $GSS && skip "must run as gss disabled" && return
7640 $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
7641 gid=`ls -n $DIR/$tfile | awk '{print $4}'`
7643 [ $gid -eq "1" ] || error "gid is set to" $gid "instead of 1"
7645 run_test 126 "check that the fsgid provided by the client is taken into account"
7647 test_127a() { # bug 15521
7648 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7649 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
7650 $LCTL set_param osc.*.stats=0
7651 FSIZE=$((2048 * 1024))
7652 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7653 cancel_lru_locks osc
7654 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
7656 $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
7657 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7658 echo "got $COUNT $NAME"
7659 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
7660 eval $NAME=$COUNT || error "Wrong proc format"
7663 read_bytes|write_bytes)
7664 [ $MIN -lt 4096 ] && error "min is too small: $MIN"
7665 [ $MIN -gt $FSIZE ] && error "min is too big: $MIN"
7666 [ $MAX -lt 4096 ] && error "max is too small: $MAX"
7667 [ $MAX -gt $FSIZE ] && error "max is too big: $MAX"
7668 [ $SUM -ne $FSIZE ] && error "sum is wrong: $SUM"
7669 [ $SUMSQ -lt $(((FSIZE /4096) * (4096 * 4096))) ] &&
7670 error "sumsquare is too small: $SUMSQ"
7671 [ $SUMSQ -gt $((FSIZE * FSIZE)) ] &&
7672 error "sumsquare is too big: $SUMSQ"
7676 done < $DIR/${tfile}.tmp
7678 #check that we actually got some stats
7679 [ "$read_bytes" ] || error "Missing read_bytes stats"
7680 [ "$write_bytes" ] || error "Missing write_bytes stats"
7681 [ "$read_bytes" != 0 ] || error "no read done"
7682 [ "$write_bytes" != 0 ] || error "no write done"
7684 run_test 127a "verify the client stats are sane"
7686 test_127b() { # bug LU-333
7687 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7688 $LCTL set_param llite.*.stats=0
7689 FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
7690 # perform 2 reads and writes so MAX is different from SUM.
7691 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7692 dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
7693 cancel_lru_locks osc
7694 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7695 dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
7697 $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
7698 while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
7699 echo "got $COUNT $NAME"
7700 eval $NAME=$COUNT || error "Wrong proc format"
7704 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7705 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7706 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7707 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7710 [ $COUNT -ne 2 ] && error "count is not 2: $COUNT"
7711 [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN"
7712 [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX"
7713 [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM"
7717 done < $TMP/${tfile}.tmp
7719 #check that we actually got some stats
7720 [ "$read_bytes" ] || error "Missing read_bytes stats"
7721 [ "$write_bytes" ] || error "Missing write_bytes stats"
7722 [ "$read_bytes" != 0 ] || error "no read done"
7723 [ "$write_bytes" != 0 ] || error "no write done"
7725 run_test 127b "verify the llite client stats are sane"
7727 test_128() { # bug 15212
7729 $LFS 2>&1 <<-EOF | tee $TMP/$tfile.log
7734 result=$(grep error $TMP/$tfile.log)
7736 [ -z "$result" ] || error "consecutive find's under interactive lfs failed"
7738 run_test 128 "interactive lfs for 2 consecutive find's"
7745 local LDPROC=/proc/fs/ldiskfs
7746 local facets=$(get_facets MDS)
7748 for facet in ${facets//,/ }; do
7749 canondev=$(ldiskfs_canon \
7750 *.$(convert_facet2label $facet).mntdev $facet)
7751 do_facet $facet "test -e $LDPROC/$canondev/max_dir_size" ||
7752 LDPROC=/sys/fs/ldiskfs
7753 do_facet $facet "echo $1 >$LDPROC/$canondev/max_dir_size"
7758 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
7759 if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
7760 skip "Only applicable to ldiskfs-based MDTs"
7763 remote_mds_nodsh && skip "remote MDS with nodsh" && return
7769 test_mkdir -p $DIR/$tdir
7773 while [ ! $I -gt $((MAX * MDSCOUNT)) ]; do
7774 $MULTIOP $DIR/$tdir/$J Oc
7776 if [ $rc -eq $EFBIG ]; then
7778 echo "return code $rc received as expected"
7780 elif [ $rc -ne 0 ]; then
7782 error_exit "return code $rc received instead of expected $EFBIG"
7785 I=$(stat -c%s "$DIR/$tdir")
7789 error "exceeded dir size limit $MAX x $MDSCOUNT $((MAX * MDSCOUNT)) : $I bytes"
7791 run_test 129 "test directory size limit ========================"
7800 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7801 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7804 trap cleanup_130 EXIT RETURN
7806 local fm_file=$DIR/$tfile
7807 $SETSTRIPE -S 65536 -c 1 $fm_file || error "setstripe on $fm_file"
7808 dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
7809 error "dd failed for $fm_file"
7811 # LU-1795: test filefrag/FIEMAP once, even if unsupported
7812 filefrag -ves $fm_file
7814 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7815 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7816 [ $RC != 0 ] && error "filefrag $fm_file failed"
7818 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7819 grep -v "ext:" | grep -v "found")
7820 lun=$($GETSTRIPE -i $fm_file)
7822 start_blk=`echo $filefrag_op | cut -d: -f2 | cut -d. -f1`
7825 for line in $filefrag_op
7827 frag_lun=`echo $line | cut -d: -f5`
7828 ext_len=`echo $line | cut -d: -f4`
7829 if (( $frag_lun != $lun )); then
7831 error "FIEMAP on 1-stripe file($fm_file) failed"
7834 (( tot_len += ext_len ))
7837 if (( lun != frag_lun || start_blk != 0 || tot_len != 64 )); then
7839 error "FIEMAP on 1-stripe file($fm_file) failed;"
7845 echo "FIEMAP on single striped file succeeded"
7847 run_test 130a "FIEMAP (1-stripe file)"
7850 [ "$OSTCOUNT" -lt "2" ] &&
7851 skip_env "skipping FIEMAP on 2-stripe file test" && return
7853 [ "$OSTCOUNT" -ge "10" ] &&
7854 skip_env "skipping FIEMAP with >= 10 OSTs" && return
7856 local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7857 [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
7860 trap cleanup_130 EXIT RETURN
7862 local fm_file=$DIR/$tfile
7863 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7864 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7865 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7867 dd if=/dev/zero of=$fm_file bs=1M count=2 ||
7868 error "dd failed on $fm_file"
7870 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7871 filefrag_op=$(filefrag -ve $fm_file | grep -A 100 "ext:" |
7872 grep -v "ext:" | grep -v "found")
7874 last_lun=$(echo $filefrag_op | cut -d: -f5)
7879 for line in $filefrag_op
7881 frag_lun=`echo $line | cut -d: -f5`
7882 ext_len=`echo $line | cut -d: -f4`
7883 if (( $frag_lun != $last_lun )); then
7884 if (( tot_len != 1024 )); then
7886 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
7893 (( tot_len += ext_len ))
7896 if (( num_luns != 2 || tot_len != 1024 )); then
7898 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7904 echo "FIEMAP on 2-stripe file succeeded"
7906 run_test 130b "FIEMAP (2-stripe file)"
7909 [ "$OSTCOUNT" -lt "2" ] &&
7910 skip_env "skipping FIEMAP on 2-stripe file" && return
7912 [ "$OSTCOUNT" -ge "10" ] &&
7913 skip_env "skipping FIEMAP with >= 10 OSTs" && return
7915 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7916 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
7919 trap cleanup_130 EXIT RETURN
7921 local fm_file=$DIR/$tfile
7922 $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
7923 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7924 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7926 dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
7928 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7929 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7931 last_lun=`echo $filefrag_op | cut -d: -f5`
7936 for line in $filefrag_op
7938 frag_lun=`echo $line | cut -d: -f5`
7939 ext_len=`echo $line | cut -d: -f4`
7940 if (( $frag_lun != $last_lun )); then
7941 logical=`echo $line | cut -d: -f2 | cut -d. -f1`
7942 if (( logical != 512 )); then
7944 error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
7947 if (( tot_len != 512 )); then
7949 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
7956 (( tot_len += ext_len ))
7959 if (( num_luns != 2 || tot_len != 512 )); then
7961 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
7967 echo "FIEMAP on 2-stripe file with hole succeeded"
7969 run_test 130c "FIEMAP (2-stripe file with hole)"
7972 [ "$OSTCOUNT" -lt "3" ] && skip_env "skipping FIEMAP on N-stripe file test" && return
7974 [ "$OSTCOUNT" -ge "10" ] &&
7975 skip_env "skipping FIEMAP with >= 10 OSTs" && return
7977 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
7978 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
7980 trap cleanup_130 EXIT RETURN
7982 local fm_file=$DIR/$tfile
7983 $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file||error "setstripe on $fm_file"
7984 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
7985 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
7986 dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
7988 filefrag -ves $fm_file || error "filefrag $fm_file failed"
7989 filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
7991 last_lun=`echo $filefrag_op | cut -d: -f5`
7996 for line in $filefrag_op
7998 frag_lun=`echo $line | cut -d: -f5`
7999 ext_len=`echo $line | cut -d: -f4`
8000 if (( $frag_lun != $last_lun )); then
8001 if (( tot_len != 1024 )); then
8003 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
8010 (( tot_len += ext_len ))
8013 if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
8015 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8021 echo "FIEMAP on N-stripe file succeeded"
8023 run_test 130d "FIEMAP (N-stripe file)"
8026 [ "$OSTCOUNT" -lt "2" ] && skip_env "skipping continuation FIEMAP test" && return
8028 [ "$OSTCOUNT" -ge "10" ] &&
8029 skip_env "skipping FIEMAP with >= 10 OSTs" && return
8031 filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
8032 [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
8034 trap cleanup_130 EXIT RETURN
8036 local fm_file=$DIR/$tfile
8037 $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
8038 [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
8039 skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
8042 EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
8043 for ((i = 0; i < $NUM_BLKS; i++))
8045 dd if=/dev/zero of=$fm_file count=1 bs=64k seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
8048 filefrag -ves $fm_file || error "filefrag $fm_file failed"
8049 filefrag_op=`filefrag -ve $fm_file | grep -A 12000 "ext:" | grep -v "ext:" | grep -v "found"`
8051 last_lun=`echo $filefrag_op | cut -d: -f5`
8056 for line in $filefrag_op
8058 frag_lun=`echo $line | cut -d: -f5`
8059 ext_len=`echo $line | cut -d: -f4`
8060 if (( $frag_lun != $last_lun )); then
8061 if (( tot_len != $EXPECTED_LEN )); then
8063 error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
8070 (( tot_len += ext_len ))
8073 if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
8075 error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
8081 echo "FIEMAP with continuation calls succeeded"
8083 run_test 130e "FIEMAP (test continuation FIEMAP calls)"
8085 # Test for writev/readv
8087 rwv -f $DIR/$tfile -w -n 3 524288 1048576 1572864 || \
8088 error "writev test failed"
8089 rwv -f $DIR/$tfile -r -v -n 2 1572864 1048576 || \
8090 error "readv failed"
8093 run_test 131a "test iov's crossing stripe boundary for writev/readv"
8096 rwv -f $DIR/$tfile -w -a -n 3 524288 1048576 1572864 || \
8097 error "append writev test failed"
8098 rwv -f $DIR/$tfile -w -a -n 2 1572864 1048576 || \
8099 error "append writev test failed"
8102 run_test 131b "test append writev"
8105 rwv -f $DIR/$tfile -w -d -n 1 1048576 || return 0
8108 run_test 131c "test read/write on file w/o objects"
8111 rwv -f $DIR/$tfile -w -n 1 1572864
8112 NOB=`rwv -f $DIR/$tfile -r -n 3 524288 524288 1048576 | awk '/error/ {print $6}'`
8113 if [ "$NOB" != 1572864 ]; then
8114 error "Short read filed: read $NOB bytes instead of 1572864"
8118 run_test 131d "test short read"
8121 rwv -f $DIR/$tfile -w -s 1048576 -n 1 1048576
8122 rwv -f $DIR/$tfile -r -z -s 0 -n 1 524288 || \
8123 error "read hitting hole failed"
8126 run_test 131e "test read hitting hole"
8131 for node in $(osts_nodes); do
8132 gl=$(do_node $node "$LCTL get_param -n ost.OSS.ost.stats" | awk '/'$token'/ {print $2}' | head -n 1)
8133 [ x$gl = x"" ] && gl=0
8134 gl_sum=$((gl_sum + gl))
8144 if [ x$som = x"enabled" ]; then
8145 [ $((gl2 - gl1)) -gt 0 ] && error "no glimpse RPC is expected"
8146 MOUNTOPT=`echo $MOUNTOPT | sed 's/som_preview//g'`
8147 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=disabled"
8149 [ $((gl2 - gl1)) -gt 0 ] || error "some glimpse RPC is expected"
8150 MOUNTOPT="$MOUNTOPT,som_preview"
8151 do_facet mgs "$LCTL conf_param $FSNAME.mdt.som=enabled"
8154 # do remount to make new mount-conf parameters actual
8161 test_132() { #1028, SOM
8162 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8163 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8164 local num=$(get_mds_dir $DIR)
8165 local mymds=mds${num}
8166 local MOUNTOPT_SAVE=$MOUNTOPT
8168 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8169 cancel_lru_locks osc
8171 som1=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8173 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8174 stat $DIR/$tfile >/dev/null
8175 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8176 echo "====> SOM is "$som1", "$((gl2 - gl1))" glimpse RPC occured"
8178 som_mode_switch $som1 $gl1 $gl2
8180 dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
8181 cancel_lru_locks osc
8183 som2=$(do_facet $mymds "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
8184 if [ $som1 == $som2 ]; then
8185 error "som is still "$som2
8186 if [ x$som2 = x"enabled" ]; then
8193 gl1=$(get_ost_param "ldlm_glimpse_enqueue")
8194 stat $DIR/$tfile >/dev/null
8195 gl2=$(get_ost_param "ldlm_glimpse_enqueue")
8196 echo "====> SOM is "$som2", "$((gl2 - gl1))" glimpse RPC occured"
8197 som_mode_switch $som2 $gl1 $gl2
8198 MOUNTOPT=$MOUNTOPT_SAVE
8200 run_test 132 "som avoids glimpse rpc"
8206 $SINGLEMDS) res=`do_facet $SINGLEMDS $LCTL get_param mdt.$FSNAME-MDT0000.md_stats | grep "$2"`
8208 ost) res=`do_facet ost1 $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "$2"`
8210 *) error "Wrong argument $1" ;;
8213 count=`echo $res | awk '{print $2}'`
8214 [ -z "$res" ] && error "The counter for $2 on $1 was not incremented"
8215 # if the argument $3 is zero, it means any stat increment is ok.
8216 if [ $3 -gt 0 ] ; then
8217 [ $count -ne $3 ] && error "The $2 counter on $1 is wrong - expected $3"
8222 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8223 remote_ost_nodsh && skip "remote OST with nodsh" && return
8224 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8226 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8227 { skip "MDS doesn't support rename stats"; return; }
8228 local testdir=$DIR/${tdir}/stats_testdir
8229 mkdir -p $DIR/${tdir}
8232 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8233 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8235 # verify mdt stats first.
8236 mkdir ${testdir} || error "mkdir failed"
8237 check_stats $SINGLEMDS "mkdir" 1
8238 touch ${testdir}/${tfile} || "touch failed"
8239 check_stats $SINGLEMDS "open" 1
8240 check_stats $SINGLEMDS "close" 1
8241 mknod ${testdir}/${tfile}-pipe p || "mknod failed"
8242 check_stats $SINGLEMDS "mknod" 1
8243 rm -f ${testdir}/${tfile}-pipe || "pipe remove failed"
8244 check_stats $SINGLEMDS "unlink" 1
8245 rm -f ${testdir}/${tfile} || error "file remove failed"
8246 check_stats $SINGLEMDS "unlink" 2
8248 # remove working dir and check mdt stats again.
8249 rmdir ${testdir} || error "rmdir failed"
8250 check_stats $SINGLEMDS "rmdir" 1
8252 local testdir1=$DIR/${tdir}/stats_testdir1
8254 mkdir -p ${testdir1}
8255 touch ${testdir1}/test1
8256 mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
8257 check_stats $SINGLEMDS "crossdir_rename" 1
8259 mv ${testdir}/test1 ${testdir}/test0 || error "file samedir rename"
8260 check_stats $SINGLEMDS "samedir_rename" 1
8264 run_test 133a "Verifying MDT stats ========================================"
8267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8268 remote_ost_nodsh && skip "remote OST with nodsh" && return
8269 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8270 local testdir=$DIR/${tdir}/stats_testdir
8271 mkdir -p ${testdir} || error "mkdir failed"
8272 touch ${testdir}/${tfile} || "touch failed"
8273 cancel_lru_locks mdc
8276 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8277 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8279 # extra mdt stats verification.
8280 chmod 444 ${testdir}/${tfile} || error "chmod failed"
8281 check_stats $SINGLEMDS "setattr" 1
8282 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8283 if [ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]
8285 ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
8286 check_stats $SINGLEMDS "getattr" 1
8288 $LFS df || error "lfs failed"
8289 check_stats $SINGLEMDS "statfs" 1
8293 run_test 133b "Verifying extra MDT stats =================================="
8296 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8297 remote_ost_nodsh && skip "remote OST with nodsh" && return
8298 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8299 local testdir=$DIR/${tdir}/stats_testdir
8300 test_mkdir -p ${testdir} || error "mkdir failed"
8302 # verify obdfilter stats.
8303 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8305 cancel_lru_locks osc
8306 wait_delete_completed
8309 do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
8310 do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
8312 dd if=/dev/zero of=${testdir}/${tfile} conv=notrunc bs=512k count=1 || error "dd failed"
8314 cancel_lru_locks osc
8315 check_stats ost "write" 1
8317 dd if=${testdir}/${tfile} of=/dev/null bs=1k count=1 || error "dd failed"
8318 check_stats ost "read" 1
8320 > ${testdir}/${tfile} || error "truncate failed"
8321 check_stats ost "punch" 1
8323 rm -f ${testdir}/${tfile} || error "file remove failed"
8324 wait_delete_completed
8325 check_stats ost "destroy" 1
8329 run_test 133c "Verifying OST stats ========================================"
8336 while [ $value -ge 2 ]; do
8341 if [ $orig -gt $order ]; then
8349 local size=('K' 'M' 'G' 'T');
8351 local size_string=$value
8353 while [ $value -ge 1024 ]; do
8354 if [ $i -gt 3 ]; then
8355 #T is the biggest unit we get here, if that is bigger,
8357 size_string=${value}T
8360 value=$((value >> 10))
8361 if [ $value -lt 1024 ]; then
8362 size_string=${value}${size[$i]}
8373 local context=${2:-.}
8374 local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
8376 awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
8381 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8382 remote_ost_nodsh && skip "remote OST with nodsh" && return
8383 remote_mds_nodsh && skip "remote MDS with nodsh" && return
8384 do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
8385 { skip "MDS doesn't support rename stats"; return; }
8387 local testdir1=$DIR/${tdir}/stats_testdir1
8388 local testdir2=$DIR/${tdir}/stats_testdir2
8390 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8392 mkdir -p ${testdir1} || error "mkdir failed"
8393 mkdir -p ${testdir2} || error "mkdir failed"
8395 createmany -o $testdir1/test 512 || error "createmany failed"
8397 # check samedir rename size
8398 mv ${testdir1}/test0 ${testdir1}/test_0
8400 local testdir1_size=$(ls -l $DIR/${tdir} |
8401 awk '/stats_testdir1/ {print $5}')
8402 local testdir2_size=$(ls -l $DIR/${tdir} |
8403 awk '/stats_testdir2/ {print $5}')
8405 testdir1_size=$(order_2 $testdir1_size)
8406 testdir2_size=$(order_2 $testdir2_size)
8408 testdir1_size=$(size_in_KMGT $testdir1_size)
8409 testdir2_size=$(size_in_KMGT $testdir2_size)
8411 echo "source rename dir size: ${testdir1_size}"
8412 echo "target rename dir size: ${testdir2_size}"
8414 local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
8415 eval $cmd || error "$cmd failed"
8416 local samedir=$($cmd | grep 'same_dir')
8417 local same_sample=$(get_rename_size $testdir1_size)
8418 [ -z "$samedir" ] && error "samedir_rename_size count error"
8419 [ "$same_sample" -eq 1 ] || error "samedir_rename_size error $same_sample"
8420 echo "Check same dir rename stats success"
8422 do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
8424 # check crossdir rename size
8425 mv ${testdir1}/test_0 ${testdir2}/test_0
8427 testdir1_size=$(ls -l $DIR/${tdir} |
8428 awk '/stats_testdir1/ {print $5}')
8429 testdir2_size=$(ls -l $DIR/${tdir} |
8430 awk '/stats_testdir2/ {print $5}')
8432 testdir1_size=$(order_2 $testdir1_size)
8433 testdir2_size=$(order_2 $testdir2_size)
8435 testdir1_size=$(size_in_KMGT $testdir1_size)
8436 testdir2_size=$(size_in_KMGT $testdir2_size)
8438 echo "source rename dir size: ${testdir1_size}"
8439 echo "target rename dir size: ${testdir2_size}"
8441 eval $cmd || error "$cmd failed"
8442 local crossdir=$($cmd | grep 'crossdir')
8443 local src_sample=$(get_rename_size $testdir1_size crossdir_src)
8444 local tgt_sample=$(get_rename_size $testdir2_size crossdir_tgt)
8445 [ -z "$crossdir" ] && error "crossdir_rename_size count error"
8446 [ "$src_sample" -eq 1 ] || error "crossdir_rename_size error $src_sample"
8447 [ "$tgt_sample" -eq 1 ] || error "crossdir_rename_size error $tgt_sample"
8448 echo "Check cross dir rename stats success"
8451 run_test 133d "Verifying rename_stats ========================================"
8454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8455 local testdir=$DIR/${tdir}/stats_testdir
8456 local ctr f0 f1 bs=32768 count=42 sum
8458 remote_ost_nodsh && skip "remote OST with nodsh" && return
8459 mkdir -p ${testdir} || error "mkdir failed"
8461 $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile}
8463 for ctr in {write,read}_bytes; do
8465 cancel_lru_locks osc
8467 do_facet ost1 $LCTL set_param -n \
8468 "obdfilter.*.exports.clear=clear"
8470 if [ $ctr = write_bytes ]; then
8472 f1=${testdir}/${tfile}
8474 f0=${testdir}/${tfile}
8478 dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \
8481 cancel_lru_locks osc
8483 sum=$(do_facet ost1 $LCTL get_param \
8484 "obdfilter.*.exports.*.stats" | \
8487 $1 == ctr { sum += $7 }
8490 if ((sum != bs * count)); then
8491 error "Bad $ctr sum, expected $((bs * count)), got $sum"
8497 run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
8500 local proc_dirs="/proc/fs/lustre/ /proc/sys/lnet/ /proc/sys/lustre/"
8503 # First without trusting modes.
8505 -exec cat '{}' \; &> /dev/null
8507 # Second verifying readability.
8511 -exec cat '{}' \; > /dev/null ||
8512 error "proc file read failed"
8514 for facet in $SINGLEMDS ost1; do
8515 do_facet $facet find $proc_dirs \
8516 -not -name req_history \
8517 -exec cat '{}' \\\; &> /dev/null
8519 do_facet $facet find $proc_dirs \
8520 -not -name req_history \
8523 -exec cat '{}' \\\; > /dev/null ||
8524 error "proc file read failed"
8527 run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
8529 test_140() { #bug-17379
8530 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8531 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir"
8532 cd $DIR/$tdir || error "Changing to $DIR/$tdir"
8533 cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
8535 # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
8536 # For kernel > 3.5, bellow only tests consecutive symlink (MAX 40)
8538 while i=`expr $i + 1`; do
8539 test_mkdir -p $i || error "Creating dir $i"
8540 cd $i || error "Changing to $i"
8541 ln -s ../stat stat || error "Creating stat symlink"
8542 # Read the symlink until ELOOP present,
8543 # not LBUGing the system is considered success,
8544 # we didn't overrun the stack.
8545 $OPENFILE -f O_RDONLY stat >/dev/null 2>&1; ret=$?
8547 if [ $ret -eq 40 ]; then
8550 error "Open stat symlink"
8556 echo "The symlink depth = $i"
8557 [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 -o $i -eq 40 ] ||
8558 error "Invalid symlink depth"
8560 # Test recursive symlink
8561 ln -s symlink_self symlink_self
8562 $OPENFILE -f O_RDONLY symlink_self >/dev/null 2>&1; ret=$?
8563 echo "open symlink_self returns $ret"
8564 [ $ret -eq 40 ] || error "recursive symlink doesn't return -ELOOP"
8566 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
8569 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8570 local TF="$TMP/$tfile"
8572 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8574 cancel_lru_locks osc
8575 cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
8576 remount_client $MOUNT
8578 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
8581 $TRUNCATE $DIR/$tfile 6000
8582 cancel_lru_locks osc
8583 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
8586 echo "12345" >>$DIR/$tfile
8587 cancel_lru_locks osc
8588 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
8591 echo "12345" >>$DIR/$tfile
8592 cancel_lru_locks osc
8593 cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
8598 run_test 150 "truncate/append tests"
8600 function roc_hit() {
8601 local list=$(comma_list $(osts_nodes))
8602 #debug temp debug for LU-2902: lets see what values we get back
8603 echo $(get_osd_param $list '' stats) 1>&2
8604 echo $(get_osd_param $list '' stats |
8605 awk '/'cache_hit'/ {sum+=$2} END {print sum}')
8608 function set_cache() {
8611 if [ "$2" == "off" ]; then
8614 local list=$(comma_list $(osts_nodes))
8615 set_osd_param $list '' $1_cache_enable $on
8617 cancel_lru_locks osc
8621 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8622 remote_ost_nodsh && skip "remote OST with nodsh" && return
8625 local list=$(comma_list $(osts_nodes))
8627 # check whether obdfilter is cache capable at all
8628 if ! get_osd_param $list '' read_cache_enable >/dev/null; then
8629 echo "not cache-capable obdfilter"
8633 # check cache is enabled on all obdfilters
8634 if get_osd_param $list '' read_cache_enable | grep 0; then
8635 echo "oss cache is disabled"
8639 set_osd_param $list '' writethrough_cache_enable 1
8641 # check write cache is enabled on all obdfilters
8642 if get_osd_param $list '' writethrough_cache_enable | grep 0; then
8643 echo "oss write cache is NOT enabled"
8647 #define OBD_FAIL_OBD_NO_LRU 0x609
8648 do_nodes $list $LCTL set_param fail_loc=0x609
8650 # pages should be in the case right after write
8651 dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES ||
8654 local BEFORE=$(roc_hit)
8655 cancel_lru_locks osc
8656 cat $DIR/$tfile >/dev/null
8657 local AFTER=$(roc_hit)
8659 do_nodes $list $LCTL set_param fail_loc=0
8661 if ! let "AFTER - BEFORE == CPAGES"; then
8662 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
8665 # the following read invalidates the cache
8666 cancel_lru_locks osc
8667 set_osd_param $list '' read_cache_enable 0
8668 cat $DIR/$tfile >/dev/null
8670 # now data shouldn't be found in the cache
8672 cancel_lru_locks osc
8673 cat $DIR/$tfile >/dev/null
8675 if let "AFTER - BEFORE != 0"; then
8676 error "IN CACHE: before: $BEFORE, after: $AFTER"
8679 set_osd_param $list '' read_cache_enable 1
8682 run_test 151 "test cache on oss and controls ==============================="
8685 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8686 local TF="$TMP/$tfile"
8688 # simulate ENOMEM during write
8689 #define OBD_FAIL_OST_NOMEM 0x226
8690 lctl set_param fail_loc=0x80000226
8691 dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
8693 sync || error "sync failed"
8694 lctl set_param fail_loc=0
8696 # discard client's cache
8697 cancel_lru_locks osc
8699 # simulate ENOMEM during read
8700 lctl set_param fail_loc=0x80000226
8701 cmp $TF $DIR/$tfile || error "cmp failed"
8702 lctl set_param fail_loc=0
8706 run_test 152 "test read/write with enomem ============================"
8709 $MULTIOP $DIR/$tfile Ow4096Ycu || error "multiop failed"
8711 run_test 153 "test if fdatasync does not crash ======================="
8713 dot_lustre_fid_permission_check() {
8715 local ffid=$MOUNT/.lustre/fid/$fid
8718 echo "stat fid $fid"
8719 stat $ffid > /dev/null || error "stat $ffid failed."
8720 echo "touch fid $fid"
8721 touch $ffid || error "touch $ffid failed."
8722 echo "write to fid $fid"
8723 cat /etc/hosts > $ffid || error "write $ffid failed."
8724 echo "read fid $fid"
8725 diff /etc/hosts $ffid || error "read $ffid failed."
8726 echo "append write to fid $fid"
8727 cat /etc/hosts >> $ffid || error "append write $ffid failed."
8728 echo "rename fid $fid"
8729 mv $ffid $test_dir/$tfile.1 &&
8730 error "rename $ffid to $tfile.1 should fail."
8731 touch $test_dir/$tfile.1
8732 mv $test_dir/$tfile.1 $ffid &&
8733 error "rename $tfile.1 to $ffid should fail."
8734 rm -f $test_dir/$tfile.1
8735 echo "truncate fid $fid"
8736 $TRUNCATE $ffid 777 || error "truncate $ffid failed."
8737 echo "link fid $fid"
8738 ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
8739 if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
8740 echo "setfacl fid $fid"
8741 setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
8742 echo "getfacl fid $fid"
8743 getfacl $ffid >/dev/null || error "getfacl $ffid failed."
8745 echo "unlink fid $fid"
8746 unlink $MOUNT/.lustre/fid/$fid && error "unlink $ffid should fail."
8747 echo "mknod fid $fid"
8748 mknod $ffid c 1 3 && error "mknod $ffid should fail."
8750 fid=[0xf00000400:0x1:0x0]
8751 ffid=$MOUNT/.lustre/fid/$fid
8753 echo "stat non-exist fid $fid"
8754 stat $ffid > /dev/null && error "stat non-exist $ffid should fail."
8755 echo "write to non-exist fid $fid"
8756 cat /etc/hosts > $ffid && error "write non-exist $ffid should fail."
8757 echo "link new fid $fid"
8758 ln $test_dir/$tfile $ffid && error "link $ffid should fail."
8760 mkdir -p $test_dir/$tdir
8761 touch $test_dir/$tdir/$tfile
8762 fid=$($LFS path2fid $test_dir/$tdir)
8765 error "error: could not get fid for $test_dir/$dir/$tfile."
8767 ffid=$MOUNT/.lustre/fid/$fid
8770 ls $ffid > /dev/null || error "ls $ffid failed."
8771 echo "touch $fid/$tfile.1"
8772 touch $ffid/$tfile.1 || error "touch $ffid/$tfile.1 failed."
8774 echo "touch $MOUNT/.lustre/fid/$tfile"
8775 touch $MOUNT/.lustre/fid/$tfile && \
8776 error "touch $MOUNT/.lustre/fid/$tfile should fail."
8778 echo "setxattr to $MOUNT/.lustre/fid"
8779 setfattr -n trusted.name1 -v value1 $MOUNT/.lustre/fid
8781 echo "listxattr for $MOUNT/.lustre/fid"
8782 getfattr -d -m "^trusted" $MOUNT/.lustre/fid
8784 echo "delxattr from $MOUNT/.lustre/fid"
8785 setfattr -x trusted.name1 $MOUNT/.lustre/fid
8787 echo "touch invalid fid: $MOUNT/.lustre/fid/[0x200000400:0x2:0x3]"
8788 touch $MOUNT/.lustre/fid/[0x200000400:0x2:0x3] &&
8789 error "touch invalid fid should fail."
8791 echo "touch non-normal fid: $MOUNT/.lustre/fid/[0x1:0x2:0x0]"
8792 touch $MOUNT/.lustre/fid/[0x1:0x2:0x0] &&
8793 error "touch non-normal fid should fail."
8795 echo "rename $tdir to $MOUNT/.lustre/fid"
8796 mrename $test_dir/$tdir $MOUNT/.lustre/fid &&
8797 error "rename to $MOUNT/.lustre/fid should fail."
8799 local old_obf_mode=$(stat --format="%a" $DIR/.lustre/fid)
8800 local new_obf_mode=777
8802 echo "change mode of $DIR/.lustre/fid to $new_obf_mode"
8803 chmod $new_obf_mode $DIR/.lustre/fid ||
8804 error "chmod $new_obf_mode $DIR/.lustre/fid failed"
8806 local obf_mode=$(stat --format=%a $DIR/.lustre/fid)
8807 [ $obf_mode -eq $new_obf_mode ] ||
8808 error "stat $DIR/.lustre/fid returned wrong mode $obf_mode"
8810 echo "restore mode of $DIR/.lustre/fid to $old_obf_mode"
8811 chmod $old_obf_mode $DIR/.lustre/fid ||
8812 error "chmod $old_obf_mode $DIR/.lustre/fid failed"
8814 $OPENFILE -f O_LOV_DELAY_CREATE:O_CREAT $test_dir/$tfile-2
8815 fid=$($LFS path2fid $test_dir/$tfile-2)
8816 echo "cp /etc/passwd $MOUNT/.lustre/fid/$fid"
8817 cp /etc/passwd $MOUNT/.lustre/fid/$fid &&
8818 error "create lov data thru .lustre should fail."
8819 echo "cp /etc/passwd $test_dir/$tfile-2"
8820 cp /etc/passwd $test_dir/$tfile-2 ||
8821 error "copy to $test_dir/$tfile-2 failed."
8822 echo "diff /etc/passwd $MOUNT/.lustre/fid/$fid"
8823 diff /etc/passwd $MOUNT/.lustre/fid/$fid ||
8824 error "diff /etc/passwd $MOUNT/.lustre/fid/$fid failed."
8826 rm -rf $test_dir/tfile.lnk
8827 rm -rf $test_dir/$tfile-2
8831 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8832 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8833 { skip "Need MDS version at least 2.2.51"; return 0; }
8835 cp /etc/hosts $DIR/$tfile
8837 fid=$($LFS path2fid $DIR/$tfile)
8839 [ $rc -ne 0 ] && error "error: could not get fid for $DIR/$tfile."
8841 dot_lustre_fid_permission_check "$fid" $DIR ||
8842 error "dot lustre permission check $fid failed"
8844 rm -rf $MOUNT/.lustre && error ".lustre is not allowed to be unlinked"
8846 touch $MOUNT/.lustre/file &&
8847 error "creation is not allowed under .lustre"
8849 mkdir $MOUNT/.lustre/dir &&
8850 error "mkdir is not allowed under .lustre"
8854 run_test 154a "Open-by-FID"
8857 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8858 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
8859 { skip "Need MDS version at least 2.2.51"; return 0; }
8861 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
8863 local remote_dir=$DIR/$tdir/remote_dir
8868 $LFS mkdir -i $MDTIDX $remote_dir ||
8869 error "create remote directory failed"
8871 cp /etc/hosts $remote_dir/$tfile
8873 fid=$($LFS path2fid $remote_dir/$tfile)
8875 [ $rc -ne 0 ] && error "error: could not get fid for $remote_dir/$tfile"
8877 dot_lustre_fid_permission_check "$fid" $remote_dir ||
8878 error "dot lustre permission check $fid failed"
8881 run_test 154b "Open-by-FID for remote directory"
8883 test_155_small_load() {
8884 local temp=$TMP/$tfile
8885 local file=$DIR/$tfile
8887 dd if=/dev/urandom of=$temp bs=6096 count=1 || \
8888 error "dd of=$temp bs=6096 count=1 failed"
8890 cancel_lru_locks osc
8891 cmp $temp $file || error "$temp $file differ"
8893 $TRUNCATE $temp 6000
8894 $TRUNCATE $file 6000
8895 cmp $temp $file || error "$temp $file differ (truncate1)"
8897 echo "12345" >>$temp
8898 echo "12345" >>$file
8899 cmp $temp $file || error "$temp $file differ (append1)"
8901 echo "12345" >>$temp
8902 echo "12345" >>$file
8903 cmp $temp $file || error "$temp $file differ (append2)"
8909 test_155_big_load() {
8910 remote_ost_nodsh && skip "remote OST with nodsh" && return
8911 local temp=$TMP/$tfile
8912 local file=$DIR/$tfile
8915 local cache_size=$(do_facet ost$((MAXI+1)) \
8916 "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
8917 local large_file_size=$((cache_size * 2))
8919 echo "OSS cache size: $cache_size KB"
8920 echo "Large file size: $large_file_size KB"
8922 [ $MAXV -le $large_file_size ] && \
8923 skip_env "max available OST size needs > $large_file_size KB" && \
8926 $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
8928 dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
8929 error "dd of=$temp bs=$large_file_size count=1k failed"
8932 cancel_lru_locks osc
8933 cmp $temp $file || error "$temp $file differ"
8940 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8942 set_cache writethrough on
8945 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
8948 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8950 set_cache writethrough off
8953 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
8956 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8958 set_cache writethrough on
8961 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
8964 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8966 set_cache writethrough off
8969 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
8972 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8974 set_cache writethrough on
8977 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
8980 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8982 set_cache writethrough off
8985 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
8988 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8990 set_cache writethrough on
8993 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
8996 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
8998 set_cache writethrough off
9001 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
9004 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9008 local file="$DIR/$tfile"
9010 [ "$(facet_fstype ost1)" = "zfs" ] &&
9011 skip "LU-1956/LU-2261: stats unimplemented on OSD ZFS" &&
9014 log "Turn on read and write cache"
9016 set_cache writethrough on
9018 log "Write data and read it back."
9019 log "Read should be satisfied from the cache."
9020 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9022 cancel_lru_locks osc
9023 cat $file >/dev/null
9025 if ! let "AFTER - BEFORE == CPAGES"; then
9026 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9028 log "cache hits:: before: $BEFORE, after: $AFTER"
9031 log "Read again; it should be satisfied from the cache."
9033 cancel_lru_locks osc
9034 cat $file >/dev/null
9036 if ! let "AFTER - BEFORE == CPAGES"; then
9037 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9039 log "cache hits:: before: $BEFORE, after: $AFTER"
9043 log "Turn off the read cache and turn on the write cache"
9045 set_cache writethrough on
9047 log "Read again; it should be satisfied from the cache."
9049 cancel_lru_locks osc
9050 cat $file >/dev/null
9052 if ! let "AFTER - BEFORE == CPAGES"; then
9053 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9055 log "cache hits:: before: $BEFORE, after: $AFTER"
9058 log "Read again; it should not be satisfied from the cache."
9060 cancel_lru_locks osc
9061 cat $file >/dev/null
9063 if ! let "AFTER - BEFORE == 0"; then
9064 error "IN CACHE: before: $BEFORE, after: $AFTER"
9066 log "cache hits:: before: $BEFORE, after: $AFTER"
9069 log "Write data and read it back."
9070 log "Read should be satisfied from the cache."
9071 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9073 cancel_lru_locks osc
9074 cat $file >/dev/null
9076 if ! let "AFTER - BEFORE == CPAGES"; then
9077 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9079 log "cache hits:: before: $BEFORE, after: $AFTER"
9082 log "Read again; it should not be satisfied from the cache."
9084 cancel_lru_locks osc
9085 cat $file >/dev/null
9087 if ! let "AFTER - BEFORE == 0"; then
9088 error "IN CACHE: before: $BEFORE, after: $AFTER"
9090 log "cache hits:: before: $BEFORE, after: $AFTER"
9094 log "Turn off read and write cache"
9096 set_cache writethrough off
9098 log "Write data and read it back"
9099 log "It should not be satisfied from the cache."
9101 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9102 cancel_lru_locks osc
9104 cat $file >/dev/null
9106 if ! let "AFTER - BEFORE == 0"; then
9107 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9109 log "cache hits:: before: $BEFORE, after: $AFTER"
9113 log "Turn on the read cache and turn off the write cache"
9115 set_cache writethrough off
9117 log "Write data and read it back"
9118 log "It should not be satisfied from the cache."
9120 dd if=/dev/urandom of=$file bs=4k count=$CPAGES || error "dd failed"
9122 cancel_lru_locks osc
9123 cat $file >/dev/null
9125 if ! let "AFTER - BEFORE == 0"; then
9126 error_ignore 20762 "IN CACHE: before: $BEFORE, after: $AFTER"
9128 log "cache hits:: before: $BEFORE, after: $AFTER"
9131 log "Read again; it should be satisfied from the cache."
9133 cancel_lru_locks osc
9134 cat $file >/dev/null
9136 if ! let "AFTER - BEFORE == CPAGES"; then
9137 error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
9139 log "cache hits:: before: $BEFORE, after: $AFTER"
9144 run_test 156 "Verification of tunables ============================"
9148 if [ $MDSCOUNT -gt 1 ]; then
9149 error_ignore 17935 $*
9157 local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
9159 MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
9161 if [ $MASK -eq 1 ]; then
9162 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
9164 do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
9169 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9170 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9171 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
9172 { skip "Need MDS version at least 2.2.0"; return; }
9174 local CL_USERS="mdd.$MDT0.changelog_users"
9175 local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
9176 USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_register -n)
9177 echo "Registered as changelog user $USER"
9178 $GET_CL_USERS | grep -q $USER ||
9179 error "User $USER not found in changelog_users"
9182 test_mkdir -p $DIR/$tdir/pics/2008/zachy
9183 touch $DIR/$tdir/pics/2008/zachy/timestamp
9184 cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
9185 mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
9186 ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
9187 ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
9188 rm $DIR/$tdir/pics/desktop.jpg
9190 $LFS changelog $MDT0 | tail -5
9192 echo "verifying changelog mask"
9193 changelog_chmask "MKDIR"
9194 changelog_chmask "CLOSE"
9196 test_mkdir -p $DIR/$tdir/pics/zach/sofia
9197 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9199 changelog_chmask "MKDIR"
9200 changelog_chmask "CLOSE"
9202 test_mkdir -p $DIR/$tdir/pics/2008/sofia
9203 echo "zzzzzz" > $DIR/$tdir/pics/zach/file
9205 $LFS changelog $MDT0
9206 MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
9207 CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
9208 [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
9209 [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
9212 echo "verifying target fid"
9213 fidc=$($LFS changelog $MDT0|awk '/CREAT.*timestamp$/{print $6}'|tail -1)
9214 fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
9215 [ "$fidc" == "t=$fidf" ] ||
9216 err17935 "fid in changelog $fidc != file fid $fidf"
9217 echo "verifying parent fid"
9218 fidc=$($LFS changelog $MDT0|awk '/CREAT.*timestamp$/{print $7}'|tail -1)
9219 fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
9220 [ "$fidc" == "p=$fidf" ] ||
9221 err17935 "pfid in changelog $fidc != dir fid $fidf"
9223 USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9224 $LFS changelog_clear $MDT0 $USER $(($USER_REC1 + 5))
9225 USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$USER\" {print \$2}")
9226 echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
9227 [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
9228 err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
9230 MIN_REC=$($GET_CL_USERS |
9231 awk 'min == "" || $2 < min {min = $2}; END {print min}')
9232 FIRST_REC=$($LFS changelog $MDT0 | head -1 | awk '{print $1}')
9233 echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
9234 [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
9235 err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
9237 # LU-3446 changelog index reset on MDT restart
9238 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
9239 CUR_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9240 $LFS changelog_clear $MDT0 $USER 0
9241 stop $SINGLEMDS || error "Fail to stop MDT."
9242 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
9243 CUR_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9244 echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
9245 [ $CUR_REC1 == $CUR_REC2 ] ||
9246 err17935 "current index should be $CUR_REC1 is $CUR_REC2"
9248 echo "verifying user deregister"
9249 do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $USER
9250 $GET_CL_USERS | grep -q $USER &&
9251 error "User $USER still in changelog_users"
9253 USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
9254 if [ $USERS -eq 0 ]; then
9255 LAST_REC1=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9256 touch $DIR/$tdir/chloe
9257 LAST_REC2=$($GET_CL_USERS | head -1 | cut -f3 -d' ')
9258 echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
9259 [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
9261 echo "$USERS other changelog users; can't verify off"
9264 run_test 160 "changelog sanity"
9267 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9268 test_mkdir -p $DIR/$tdir
9269 cp /etc/hosts $DIR/$tdir/$tfile
9270 test_mkdir $DIR/$tdir/foo1
9271 test_mkdir $DIR/$tdir/foo2
9272 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/sofia
9273 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/zachary
9274 ln $DIR/$tdir/$tfile $DIR/$tdir/foo1/luna
9275 ln $DIR/$tdir/$tfile $DIR/$tdir/foo2/thor
9276 local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
9277 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9278 $LFS fid2path $DIR $FID
9279 err17935 "bad link ea"
9282 rm $DIR/$tdir/foo2/zachary
9284 rm $DIR/$tdir/foo2/thor
9286 rm $DIR/$tdir/$tfile
9288 mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
9289 if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
9291 $LFS fid2path $DIR $FID
9292 err17935 "bad link rename"
9294 rm $DIR/$tdir/foo2/maggie
9297 local longname=filename_avg_len_is_thirty_two_
9298 createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 || \
9299 error "failed to hardlink many files"
9300 links=$($LFS fid2path $DIR $FID | wc -l)
9301 echo -n "${links}/1000 links in link EA"
9302 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9303 unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
9304 error "failed to unlink many hardlinks"
9306 run_test 161a "link ea sanity"
9309 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9310 [ $MDSCOUNT -lt 2 ] &&
9311 skip "skipping remote directory test" && return
9313 local remote_dir=$DIR/$tdir/remote_dir
9316 $LFS mkdir -i $MDTIDX $remote_dir ||
9317 error "create remote directory failed"
9319 cp /etc/hosts $remote_dir/$tfile
9320 mkdir -p $remote_dir/foo1
9321 mkdir -p $remote_dir/foo2
9322 ln $remote_dir/$tfile $remote_dir/foo1/sofia
9323 ln $remote_dir/$tfile $remote_dir/foo2/zachary
9324 ln $remote_dir/$tfile $remote_dir/foo1/luna
9325 ln $remote_dir/$tfile $remote_dir/foo2/thor
9327 local FID=$($LFS path2fid $remote_dir/$tfile | tr -d '[' |
9329 if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
9330 $LFS fid2path $DIR $FID
9331 err17935 "bad link ea"
9334 rm $remote_dir/foo2/zachary
9336 rm $remote_dir/foo2/thor
9338 rm $remote_dir/$tfile
9340 mv $remote_dir/foo1/sofia $remote_dir/foo2/maggie
9341 local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
9342 if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
9343 $LFS fid2path $DIR $FID
9344 err17935 "bad link rename"
9346 rm $remote_dir/foo2/maggie
9349 local longname=filename_avg_len_is_thirty_two_
9350 createmany -l$remote_dir/foo1/luna $remote_dir/foo2/$longname 1000 ||
9351 error "failed to hardlink many files"
9352 links=$($LFS fid2path $DIR $FID | wc -l)
9353 echo -n "${links}/1000 links in link EA"
9354 [ ${links} -gt 60 ] || err17935 "expected at least 60 links in link EA"
9355 unlinkmany $remote_dir/foo2/$longname 1000 ||
9356 error "failed to unlink many hardlinks"
9358 run_test 161b "link ea sanity under remote directory"
9365 local path=$(${LFS} fid2path $*)
9368 if [ $RC -ne 0 ]; then
9369 err17935 "path looked up of $expected failed. Error $RC"
9371 elif [ "${path}" != "${expected}" ]; then
9372 err17935 "path looked up \"${path}\" instead of \"${expected}\""
9375 echo "fid $fid resolves to path $path (expected $expected)"
9379 # Make changes to filesystem
9380 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9381 test_mkdir -p $DIR/$tdir/d2
9382 touch $DIR/$tdir/d2/$tfile
9383 touch $DIR/$tdir/d2/x1
9384 touch $DIR/$tdir/d2/x2
9385 test_mkdir -p $DIR/$tdir/d2/a/b/c
9386 test_mkdir -p $DIR/$tdir/d2/p/q/r
9388 FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
9389 check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
9392 ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
9393 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
9394 check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
9396 # softlink to wrong file
9397 ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
9398 FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
9399 check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
9402 ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
9403 mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
9404 FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
9405 # fid2path dir/fsname should both work
9406 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
9407 check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
9409 # hardlink count: check that there are 2 links
9410 # Doesnt work with CMD yet: 17935
9411 ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
9412 err17935 "expected 2 links"
9414 # hardlink indexing: remove the first link
9415 rm $DIR/$tdir/d2/p/q/r/hlink
9416 check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
9420 run_test 162 "path lookup sanity"
9423 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9424 remote_mds_nodsh && skip "remote MDS with nodsh" && return
9425 copytool --test $FSNAME || { skip "copytool not runnable: $?" && return; }
9428 local uuid=$($LCTL get_param -n mdc.${FSNAME}-MDT0000-mdc-*.uuid)
9429 # this proc file is temporary and linux-only
9430 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT0000.mdccomm=$uuid ||\
9431 error "kernel->userspace send failed"
9434 run_test 163 "kernel <-> userspace comms"
9437 # do directio so as not to populate the page cache
9438 log "creating a 10 Mb file"
9439 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
9440 log "starting reads"
9441 dd if=$DIR/$tfile of=/dev/null bs=4096 &
9442 log "truncating the file"
9443 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
9445 kill %+ || true # reads might have finished
9446 echo "wait until dd is finished"
9448 log "removing the temporary file"
9449 rm -rf $DIR/$tfile || error "tmp file removal failed"
9451 run_test 169 "parallel read and truncate should not deadlock"
9454 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9455 $LCTL clear # bug 18514
9456 $LCTL debug_daemon start $TMP/${tfile}_log_good
9458 $LCTL debug_daemon stop
9459 sed -e "s/^...../a/g" $TMP/${tfile}_log_good > $TMP/${tfile}_log_bad ||
9460 error "sed failed to read log_good"
9462 $LCTL debug_daemon start $TMP/${tfile}_log_good
9464 $LCTL debug_daemon stop
9466 $LCTL df $TMP/${tfile}_log_bad > $TMP/${tfile}_log_bad.out 2>&1 ||
9467 error "lctl df log_bad failed"
9469 local bad_line=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9470 local good_line1=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9472 $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
9473 local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
9475 [ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
9476 error "bad_line good_line1 good_line2 are empty"
9478 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9479 cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
9480 cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
9482 $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
9483 local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
9484 local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
9486 [ "$bad_line_new" ] && [ "$good_line_new" ] ||
9487 error "bad_line_new good_line_new are empty"
9489 local expected_good=$((good_line1 + good_line2*2))
9491 rm -f $TMP/${tfile}*
9492 # LU-231, short malformed line may not be counted into bad lines
9493 if [ $bad_line -ne $bad_line_new ] &&
9494 [ $bad_line -ne $((bad_line_new - 1)) ]; then
9495 error "expected $bad_line bad lines, but got $bad_line_new"
9499 if [ $expected_good -ne $good_line_new ]; then
9500 error "expected $expected_good good lines, but got $good_line_new"
9505 run_test 170 "test lctl df to handle corrupted log ====================="
9507 test_171() { # bug20592
9508 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9509 #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e
9510 $LCTL set_param fail_loc=0x50e
9511 $LCTL set_param fail_val=3000
9512 multiop_bg_pause $DIR/$tfile O_s || true
9514 kill -USR1 $MULTIPID
9518 if dmesg | grep "recursive fault"; then
9519 error "caught a recursive fault"
9521 $LCTL set_param fail_loc=0
9524 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
9526 # it would be good to share it with obdfilter-survey/libecho code
9527 setup_obdecho_osc () {
9530 local obdfilter_name=$2
9531 echo "Creating new osc for $obdfilter_name on $ost_nid"
9532 # make sure we can find loopback nid
9533 $LCTL add_uuid $ost_nid $ost_nid >/dev/null 2>&1
9535 [ $rc -eq 0 ] && { $LCTL attach osc ${obdfilter_name}_osc \
9536 ${obdfilter_name}_osc_UUID || rc=2; }
9537 [ $rc -eq 0 ] && { $LCTL --device ${obdfilter_name}_osc setup \
9538 ${obdfilter_name}_UUID $ost_nid || rc=3; }
9542 cleanup_obdecho_osc () {
9543 local obdfilter_name=$1
9544 $LCTL --device ${obdfilter_name}_osc cleanup >/dev/null
9545 $LCTL --device ${obdfilter_name}_osc detach >/dev/null
9552 local pages=${3:-64}
9555 do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
9556 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" ||
9558 if [ $rc -eq 0 ]; then
9559 id=$(do_facet $node "$LCTL --device ec create 1" | awk '/object id/ {print $6}')
9560 [ ${PIPESTATUS[0]} -eq 0 -a -n "$id" ] || rc=3
9562 echo "New object id is $id"
9563 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec getattr $id" ||
9565 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec " \
9566 "test_brw 10 w v $pages $id" || rc=4; }
9567 [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec destroy $id 1" ||
9569 [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec " \
9570 "cleanup" || rc=5; }
9571 [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec " \
9573 [ $rc -ne 0 ] && echo "obecho_create_test failed: $rc"
9578 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9579 remote_ost_nodsh && skip "remote OST with nodsh" && return
9583 if ! module_loaded obdecho; then
9584 load_module obdecho/obdecho
9588 local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
9589 local host=$(lctl get_param -n osc.$osc.import |
9590 awk '/current_connection:/ {print $2}' )
9591 local target=$(lctl get_param -n osc.$osc.import |
9592 awk '/target:/ {print $2}' )
9593 target=${target%_UUID}
9595 [[ -n $target ]] && { setup_obdecho_osc $host $target || rc=1; } || rc=1
9596 [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
9597 [[ -n $target ]] && cleanup_obdecho_osc $target
9598 [ $rmmod_local -eq 1 ] && rmmod obdecho
9601 run_test 180a "test obdecho on osc"
9604 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9605 remote_ost_nodsh && skip "remote OST with nodsh" && return
9607 local rmmod_remote=0
9609 do_facet ost1 "lsmod | grep -q obdecho || " \
9610 "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \
9611 "modprobe obdecho; }" && rmmod_remote=1
9612 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
9613 [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
9614 [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho"
9617 run_test 180b "test obdecho directly on obdfilter"
9619 test_180c() { # LU-2598
9620 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9621 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
9622 skip "Need MDS version at least 2.4.0" && return
9625 local rmmod_remote=false
9626 local pages=16384 # 64MB bulk I/O RPC size
9629 do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
9630 rmmod_remote=true || error "failed to load module obdecho"
9632 target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4}'|head -1)
9633 if [[ -n $target ]]; then
9634 obdecho_test "$target" ost1 "$pages" ||
9637 echo "there is no obdfilter target on ost1"
9640 $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
9643 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
9645 test_181() { # bug 22177
9646 test_mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9647 # create enough files to index the directory
9648 createmany -o $DIR/$tdir/foobar 4000
9649 # print attributes for debug purpose
9652 multiop_bg_pause $DIR/$tdir D_Sc || return 1
9654 # remove the files & current working dir
9655 unlinkmany $DIR/$tdir/foobar 4000
9657 kill -USR1 $MULTIPID
9659 stat $DIR/$tdir && error "open-unlinked dir was not removed!"
9662 run_test 181 "Test open-unlinked dir ========================"
9665 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9666 # disable MDC RPC lock wouldn't crash client
9670 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9671 #define OBD_FAIL_MDC_RPCS_SEM 0x804
9672 $LCTL set_param fail_loc=0x804
9674 for (( i=0; i < $tcount; i++ )) ; do
9676 createmany -o $DIR/$tdir/$i/f- $fcount &
9680 for (( i=0; i < $tcount; i++ )) ; do
9681 unlinkmany $DIR/$tdir/$i/f- $fcount &
9687 $LCTL set_param fail_loc=0
9689 run_test 182 "Disable MDC RPCs semaphore wouldn't crash client ================"
9691 test_183() { # LU-2275
9692 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
9693 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9694 echo aaa > $DIR/$tdir/$tfile
9696 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE 0x148
9697 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x148
9699 ls -l $DIR/$tdir && error "ls succeeded, should have failed"
9700 cat $DIR/$tdir/$tfile && error "cat succeeded, should have failed"
9702 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
9704 # Flush negative dentry cache
9705 touch $DIR/$tdir/$tfile
9707 # We are not checking for any leaked references here, they'll
9708 # become evident next time we do cleanup with module unload.
9711 run_test 183 "No crash or request leak in case of strange dispositions ========"
9713 # test suite 184 is for LU-2016, LU-2017
9715 check_swap_layouts_support && return 0
9717 dir0=$DIR/$tdir/$testnum
9718 test_mkdir -p $dir0 || error "creating dir $dir0"
9723 $SETSTRIPE -c1 $file1
9725 $SETSTRIPE -c2 $file2
9727 gen1=$($GETSTRIPE -g $file1)
9728 gen2=$($GETSTRIPE -g $file2)
9730 $LFS swap_layouts $file1 $file2 || error "swap of file layout failed"
9731 gen=$($GETSTRIPE -g $file1)
9732 [[ $gen1 != $gen ]] ||
9733 "Layout generation on $file1 does not change"
9734 gen=$($GETSTRIPE -g $file2)
9735 [[ $gen2 != $gen ]] ||
9736 "Layout generation on $file2 does not change"
9738 cmp $ref1 $file2 || error "content compare failed ($ref1 != $file2)"
9739 cmp $ref2 $file1 || error "content compare failed ($ref2 != $file1)"
9741 run_test 184a "Basic layout swap"
9744 check_swap_layouts_support && return 0
9746 dir0=$DIR/$tdir/$testnum
9747 mkdir -p $dir0 || error "creating dir $dir0"
9754 $SETSTRIPE -c1 $file1
9755 $SETSTRIPE -c2 $file2
9756 $SETSTRIPE -c1 $file3
9757 chown $RUNAS_ID $file3
9758 gen1=$($GETSTRIPE -g $file1)
9759 gen2=$($GETSTRIPE -g $file2)
9761 $LFS swap_layouts $dir1 $dir2 &&
9762 error "swap of directories layouts should fail"
9763 $LFS swap_layouts $dir1 $file1 &&
9764 error "swap of directory and file layouts should fail"
9765 $RUNAS $LFS swap_layouts $file1 $file2 &&
9766 error "swap of file we cannot write should fail"
9767 $LFS swap_layouts $file1 $file3 &&
9768 error "swap of file with different owner should fail"
9769 /bin/true # to clear error code
9771 run_test 184b "Forbidden layout swap (will generate errors)"
9774 check_swap_layouts_support && return 0
9776 local dir0=$DIR/$tdir/$testnum
9777 mkdir -p $dir0 || error "creating dir $dir0"
9779 local ref1=$dir0/ref1
9780 local ref2=$dir0/ref2
9781 local file1=$dir0/file1
9782 local file2=$dir0/file2
9783 # create a file large enough for the concurent test
9784 dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
9785 dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
9786 echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
9789 dd if=$ref1 of=$file1 bs=16k &
9792 # Make sure dd starts to copy file
9793 while [ ! -f $file1 ]; do sleep 0.1; done
9795 $LFS swap_layouts $file1 $file2
9798 [[ $? == 0 ]] || error "concurrent write on $file1 failed"
9799 [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
9801 # how many bytes copied before swapping layout
9802 local copied=`stat -c %s $file2`
9803 local remaining=`stat -c %s $ref1`
9804 remaining=$((remaining - copied))
9805 echo "Copied $copied bytes before swapping layout..."
9807 cmp -n $copied $file1 $ref2 | grep differ &&
9808 error "Content mismatch [0, $copied) of ref2 and file1"
9809 cmp -n $copied $file2 $ref1 ||
9810 error "Content mismatch [0, $copied) of ref1 and file2"
9811 cmp -i $copied:$copied -n $remaining $file1 $ref1 ||
9812 error "Content mismatch [$copied, EOF) of ref1 and file1"
9815 rm -f $ref1 $ref2 $file1 $file2
9817 run_test 184c "Concurrent write and layout swap"
9820 check_swap_layouts_support && return 0
9822 local file1=$DIR/$tdir/$tfile-1
9823 local file2=$DIR/$tdir/$tfile-2
9824 local file3=$DIR/$tdir/$tfile-3
9829 touch $file1 || error "create $file1 failed"
9830 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file2 ||
9831 error "create $file2 failed"
9832 $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE $file3 ||
9833 error "create $file3 failed"
9834 lovea1=$($LFS getstripe $file1 | sed 1d)
9836 $LFS swap_layouts $file2 $file3 ||
9837 error "swap $file2 $file3 layouts failed"
9838 $LFS swap_layouts $file1 $file2 ||
9839 error "swap $file1 $file2 layouts failed"
9841 lovea2=$($LFS getstripe $file2 | sed 1d)
9842 [ "$lovea1" == "$lovea2" ] || error "lovea $lovea1 != $lovea2"
9844 lovea1=$(getfattr -n trusted.lov $file1 | grep ^trusted)
9845 [ -z $lovea1 ] || error "$file1 shouldn't have lovea"
9847 run_test 184d "allow stripeless layouts swap"
9850 test_185() { # LU-2441
9851 mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
9852 touch $DIR/$tdir/spoo
9853 local mtime1=$(stat -c "%Y" $DIR/$tdir)
9854 local fid=$($MULTIOP $DIR/$tdir VFw4096c) ||
9855 error "cannot create/write a volatile file"
9856 $CHECKSTAT -t file $MOUNT/.lustre/fid/$fid 2>/dev/null &&
9857 error "FID is still valid after close"
9859 multiop_bg_pause $DIR/$tdir vVw4096_c
9866 # assume that the next FID for this client is sequential, since stdout
9867 # is unfortunately eaten by multiop_bg_pause
9868 local n=$((${fidv[1]} + 1))
9869 local next_fid="${fidv[0]}:$(printf "0x%x" $n):${fidv[2]}"
9870 $CHECKSTAT -t file $MOUNT/.lustre/fid/$next_fid ||
9871 error "FID is missing before close"
9872 kill -USR1 $multi_pid
9873 # 1 second delay, so if mtime change we will see it
9875 local mtime2=$(stat -c "%Y" $DIR/$tdir)
9876 [[ $mtime1 == $mtime2 ]] || error "mtime has changed"
9878 run_test 185 "Volatile file support"
9881 check_file_in_pool()
9886 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
9889 for t in $tlist ; do
9890 [ "$i" -eq "$t" ] && continue 2
9893 echo "pool list: $tlist"
9894 echo "striping: $res"
9895 error_noexit "$file not allocated in $pool"
9902 echo "Creating new pool"
9905 create_pool $FSNAME.$pool ||
9906 { error_noexit "No pool created, result code $?"; return 1; }
9907 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
9908 { error_noexit "$pool not in lfs pool_list"; return 2; }
9911 pool_add_targets() {
9912 echo "Adding targets to pool"
9918 local list=$(seq $first $step $last)
9920 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
9921 do_facet mgs $LCTL pool_add \
9922 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
9923 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
9924 | sort -u | tr '\n' ' ' " "$t" || {
9925 error_noexit "Add to pool failed"
9928 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
9929 local addcount=$(((last - first) / step + 1))
9930 [ $lfscount -eq $addcount ] || {
9931 error_noexit "lfs pool_list bad ost count" \
9932 "$lfscount != $addcount"
9940 echo "Setting pool on directory $tdir"
9942 $SETSTRIPE -c 2 -p $pool $tdir && return 0
9944 error_noexit "Cannot set pool $pool to $tdir"
9951 echo "Checking pool on directory $tdir"
9953 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
9954 [ "$res" = "$pool" ] && return 0
9956 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
9960 pool_dir_rel_path() {
9961 echo "Testing relative path works well"
9966 mkdir -p $root/$tdir/$tdir
9968 pool_set_dir $pool $tdir || return 1
9969 pool_set_dir $pool ./$tdir || return 2
9970 pool_set_dir $pool ../$tdir || return 3
9971 pool_set_dir $pool ../$tdir/$tdir || return 4
9972 rm -rf $tdir; cd - > /dev/null
9975 pool_alloc_files() {
9976 echo "Checking files allocation from directory pool"
9983 for i in $(seq -w 1 $count)
9985 local file=$tdir/file-$i
9987 check_file_in_pool $file $pool "$tlist" || \
9988 failed=$((failed + 1))
9990 [ "$failed" = 0 ] && return 0
9992 error_noexit "$failed files not allocated in $pool"
9996 pool_create_files() {
9997 echo "Creating files in pool"
10005 for i in $(seq -w 1 $count)
10007 local file=$tdir/spoo-$i
10008 $SETSTRIPE -p $pool $file
10009 check_file_in_pool $file $pool "$tlist" || \
10010 failed=$((failed + 1))
10012 [ "$failed" = 0 ] && return 0
10014 error_noexit "$failed files not allocated in $pool"
10019 echo "Checking 'lfs df' output"
10022 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
10024 local res=$($LFS df --pool $FSNAME.$pool |
10026 grep "$FSNAME-OST" |
10028 [ "$res" = "$t" ] && return 0
10030 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
10034 pool_file_rel_path() {
10035 echo "Creating files in a pool with relative pathname"
10040 { error_noexit "unable to create $tdir"; return 1 ; }
10041 local file="/..$tdir/$tfile-1"
10042 $SETSTRIPE -p $pool $file ||
10043 { error_noexit "unable to create $file" ; return 2 ; }
10046 $SETSTRIPE -p $pool $tfile-2 || {
10047 error_noexit "unable to create $tfile-2 in $tdir"
10052 pool_remove_first_target() {
10053 echo "Removing first target from a pool"
10056 local pname="lov.$FSNAME-*.pools.$pool"
10057 local t=$($LCTL get_param -n $pname | head -1)
10058 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10059 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
10060 error_noexit "$t not removed from $FSNAME.$pool"
10065 pool_remove_all_targets() {
10066 echo "Removing all targets from pool"
10069 local pname="lov.$FSNAME-*.pools.$pool"
10070 for t in $($LCTL get_param -n $pname | sort -u)
10072 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
10074 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
10075 error_noexit "Pool $FSNAME.$pool cannot be drained"
10078 # striping on an empty/nonexistant pool should fall back
10079 # to "pool of everything"
10081 error_noexit "failed to use fallback striping for empty pool"
10084 # setstripe on an empty pool should fail
10085 $SETSTRIPE -p $pool $file 2>/dev/null && {
10086 error_noexit "expected failure when creating file" \
10094 echo "Destroying pool"
10098 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
10101 # striping on an empty/nonexistant pool should fall back
10102 # to "pool of everything"
10104 error_noexit "failed to use fallback striping for missing pool"
10107 # setstripe on an empty pool should fail
10108 $SETSTRIPE -p $pool $file 2>/dev/null && {
10109 error_noexit "expected failure when creating file" \
10110 "with missing pool"
10114 # get param should return err once pool is gone
10115 if wait_update $HOSTNAME "lctl get_param -n \
10116 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
10118 remove_pool_from_list $FSNAME.$pool
10121 error_noexit "Pool $FSNAME.$pool is not destroyed"
10126 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10127 remote_mgs_nodsh && skip "remote MGS with nodsh" && return
10129 local POOL=${POOL:-cea1}
10130 local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
10131 local POOL_DIR_NAME=${POOL_DIR_NAME:-dir_tst}
10134 local last_ost=$(($OSTCOUNT - 1))
10136 local ost_list=$(seq $first_ost $ost_step $last_ost)
10137 local ost_range="$first_ost $last_ost $ost_step"
10138 local test_path=$POOL_ROOT/$POOL_DIR_NAME
10139 local file_dir=$POOL_ROOT/file_tst
10143 # former test_200a test_200b
10144 pool_add $POOL || { rc=$? ; break; }
10145 pool_add_targets $POOL $ost_range || { rc=$? ; break; }
10146 # former test_200c test_200d
10147 mkdir -p $test_path
10148 pool_set_dir $POOL $test_path || { rc=$? ; break; }
10149 pool_check_dir $POOL $test_path || { rc=$? ; break; }
10150 pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
10151 || { rc=$? ; break; }
10152 # former test_200e test_200f
10153 local files=$((OSTCOUNT*3))
10154 pool_alloc_files $POOL $test_path $files "$ost_list" \
10155 || { rc=$? ; break; }
10156 pool_create_files $POOL $file_dir $files "$ost_list" \
10157 || { rc=$? ; break; }
10158 # former test_200g test_200h
10159 pool_lfs_df $POOL || { rc=$? ; break; }
10160 pool_file_rel_path $POOL $test_path || { rc=$? ; break; }
10162 # former test_201a test_201b test_201c
10163 pool_remove_first_target $POOL || { rc=$? ; break; }
10165 local f=$test_path/$tfile
10166 pool_remove_all_targets $POOL $f || { rc=$? ; break; }
10167 pool_remove $POOL $f || { rc=$? ; break; }
10174 run_test 200 "OST pools"
10176 # usage: default_attr <count | size | offset>
10178 $LCTL get_param -n lov.$FSNAME-clilov-\*.stripe${1}
10181 # usage: check_default_stripe_attr
10182 check_default_stripe_attr() {
10183 ACTUAL=$($GETSTRIPE $* $DIR/$tdir)
10185 --stripe-count|--count)
10186 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr count);;
10187 --stripe-size|--size)
10188 [ -n "$2" ] && EXPECTED=0 || EXPECTED=$(default_attr size);;
10189 --stripe-index|--index)
10192 error "unknown getstripe attr '$1'"
10195 [ $ACTUAL != $EXPECTED ] &&
10196 error "$DIR/$tdir has $1 '$ACTUAL', not '$EXPECTED'"
10200 test_mkdir -p $DIR/$tdir
10201 $SETSTRIPE --stripe-count 0 --stripe-size 0 --stripe-index -1 $DIR/$tdir
10203 check_default_stripe_attr --stripe-count
10204 check_default_stripe_attr --stripe-size
10205 check_default_stripe_attr --stripe-index
10209 run_test 204a "Print default stripe attributes ================="
10212 test_mkdir -p $DIR/$tdir
10213 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10215 check_default_stripe_attr --stripe-size
10216 check_default_stripe_attr --stripe-index
10220 run_test 204b "Print default stripe size and offset ==========="
10223 test_mkdir -p $DIR/$tdir
10224 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10226 check_default_stripe_attr --stripe-count
10227 check_default_stripe_attr --stripe-index
10231 run_test 204c "Print default stripe count and offset ==========="
10234 test_mkdir -p $DIR/$tdir
10235 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10237 check_default_stripe_attr --stripe-count
10238 check_default_stripe_attr --stripe-size
10242 run_test 204d "Print default stripe count and size ============="
10245 test_mkdir -p $DIR/$tdir
10246 $SETSTRIPE -d $DIR/$tdir
10248 check_default_stripe_attr --stripe-count --raw
10249 check_default_stripe_attr --stripe-size --raw
10250 check_default_stripe_attr --stripe-index --raw
10254 run_test 204e "Print raw stripe attributes ================="
10257 test_mkdir -p $DIR/$tdir
10258 $SETSTRIPE --stripe-count 1 $DIR/$tdir
10260 check_default_stripe_attr --stripe-size --raw
10261 check_default_stripe_attr --stripe-index --raw
10265 run_test 204f "Print raw stripe size and offset ==========="
10268 test_mkdir -p $DIR/$tdir
10269 $SETSTRIPE --stripe-size 65536 $DIR/$tdir
10271 check_default_stripe_attr --stripe-count --raw
10272 check_default_stripe_attr --stripe-index --raw
10276 run_test 204g "Print raw stripe count and offset ==========="
10279 test_mkdir -p $DIR/$tdir
10280 $SETSTRIPE --stripe-index 0 $DIR/$tdir
10282 check_default_stripe_attr --stripe-count --raw
10283 check_default_stripe_attr --stripe-size --raw
10287 run_test 204h "Print raw stripe count and size ============="
10289 # Figure out which job scheduler is being used, if any,
10290 # or use a fake one
10291 if [ -n "$SLURM_JOB_ID" ]; then # SLURM
10292 JOBENV=SLURM_JOB_ID
10293 elif [ -n "$LSB_JOBID" ]; then # Load Sharing Facility
10295 elif [ -n "$PBS_JOBID" ]; then # PBS/Maui/Moab
10297 elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
10298 JOBENV=LOADL_STEP_ID
10299 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
10305 verify_jobstats() {
10309 # clear old jobstats
10310 do_facet $SINGLEMDS lctl set_param mdt.*.job_stats="clear"
10311 do_facet ost1 lctl set_param obdfilter.*.job_stats="clear"
10313 # use a new JobID for this test, or we might see an old one
10314 [ "$JOBENV" = "FAKE_JOBID" ] && FAKE_JOBID=test_id.$testnum.$RANDOM
10318 log "Using JobID environment variable $JOBENV=$JOBVAL"
10320 if [ $JOBENV = "FAKE_JOBID" ]; then
10321 FAKE_JOBID=$JOBVAL $cmd
10326 if [ "$target" = "mdt" -o "$target" = "both" ]; then
10327 FACET="$SINGLEMDS" # will need to get MDS number for DNE
10328 do_facet $FACET lctl get_param mdt.*.job_stats |
10329 grep $JOBVAL || error "No job stats found on MDT $FACET"
10331 if [ "$target" = "ost" -o "$target" = "both" ]; then
10333 do_facet $FACET lctl get_param obdfilter.*.job_stats |
10334 grep $JOBVAL || error "No job stats found on OST $FACET"
10340 NEW_JOBENV=${1:-$OLD_JOBENV}
10341 do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
10342 wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
10345 test_205() { # Job stats
10346 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10347 [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
10348 skip "Server doesn't support jobstats" && return 0
10351 OLD_JOBENV=`$LCTL get_param -n jobid_var`
10352 if [ $OLD_JOBENV != $JOBENV ]; then
10353 jobstats_set $JOBENV
10354 trap jobstats_set EXIT
10358 cmd="mkdir $DIR/$tfile"
10359 verify_jobstats "$cmd" "mdt"
10361 cmd="rm -fr $DIR/$tfile"
10362 verify_jobstats "$cmd" "mdt"
10364 cmd="mknod $DIR/$tfile c 1 3"
10365 verify_jobstats "$cmd" "mdt"
10367 cmd="rm -f $DIR/$tfile"
10368 verify_jobstats "$cmd" "mdt"
10370 cmd="$SETSTRIPE -i 0 -c 1 $DIR/$tfile"
10371 verify_jobstats "$cmd" "mdt"
10373 cmd="touch $DIR/$tfile"
10374 verify_jobstats "$cmd" "both"
10376 cmd="dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 oflag=sync"
10377 verify_jobstats "$cmd" "ost"
10379 cmd="dd if=$DIR/$tfile of=/dev/null bs=1M count=1 iflag=direct"
10380 verify_jobstats "$cmd" "ost"
10382 cmd="$TRUNCATE $DIR/$tfile 0"
10383 verify_jobstats "$cmd" "both"
10385 cmd="mv -f $DIR/$tfile $DIR/jobstats_test_rename"
10386 verify_jobstats "$cmd" "mdt"
10389 rm -f $DIR/jobstats_test_rename
10391 [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
10393 run_test 205 "Verify job stats"
10395 # LU-1480, LU-1773 and LU-1657
10397 mkdir -p $DIR/$tdir
10398 lfs setstripe -c -1 $DIR/$tdir
10399 #define OBD_FAIL_LOV_INIT 0x1403
10400 $LCTL set_param fail_loc=0xa0001403
10401 $LCTL set_param fail_val=1
10402 touch $DIR/$tdir/$tfile || true
10404 run_test 206 "fail lov_init_raid0() doesn't lbug"
10407 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10408 local fsz=`stat -c %s $DIR/$tfile`
10409 cancel_lru_locks mdc
10411 # do not return layout in getattr intent
10412 #define OBD_FAIL_MDS_NO_LL_GETATTR 0x170
10413 $LCTL set_param fail_loc=0x170
10414 local sz=`stat -c %s $DIR/$tfile`
10416 [ $fsz -eq $sz ] || error "file size expected $fsz, actual $sz"
10420 run_test 207a "can refresh layout at glimpse"
10423 dd if=/dev/zero of=$DIR/$tfile bs=4k count=$((RANDOM%10+1))
10424 local cksum=`md5sum $DIR/$tfile`
10425 local fsz=`stat -c %s $DIR/$tfile`
10426 cancel_lru_locks mdc
10427 cancel_lru_locks osc
10429 # do not return layout in getattr intent
10430 #define OBD_FAIL_MDS_NO_LL_OPEN 0x171
10431 $LCTL set_param fail_loc=0x171
10433 # it will refresh layout after the file is opened but before read issues
10434 echo checksum is "$cksum"
10435 echo "$cksum" |md5sum -c --quiet || error "file differs"
10439 run_test 207b "can refresh layout at open"
10443 size=$((size % 8192 + 1))
10444 dd if=/dev/urandom of=$DIR/f212 bs=1k count=$size
10445 sendfile $DIR/f212 $DIR/f212.xyz || error "sendfile wrong"
10446 rm -f $DIR/f212 $DIR/f212.xyz
10448 run_test 212 "Sendfile test ============================================"
10451 dd if=/dev/zero of=$DIR/$tfile bs=4k count=4
10452 cancel_lru_locks osc
10453 lctl set_param fail_loc=0x8000040f
10454 # generate a read lock
10455 cat $DIR/$tfile > /dev/null
10456 # write to the file, it will try to cancel the above read lock.
10457 cat /etc/hosts >> $DIR/$tfile
10459 run_test 213 "OSC lock completion and cancel race don't crash - bug 18829"
10461 test_214() { # for bug 20133
10462 test_mkdir -p $DIR/d214p/d214c
10463 for (( i=0; i < 340; i++ )) ; do
10464 touch $DIR/d214p/d214c/a$i
10467 ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
10468 mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
10469 ls $DIR/d214c || error "ls $DIR/d214c failed"
10470 rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
10472 run_test 214 "hash-indexed directory test - bug 20133"
10474 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
10475 create_lnet_proc_files() {
10476 cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/lnet/$1"
10477 sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
10479 sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
10480 rm -f "$TMP/lnet_$1.sys_tmp"
10483 # counterpart of create_lnet_proc_files
10484 remove_lnet_proc_files() {
10485 rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
10488 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10489 # 3rd arg as regexp for body
10490 check_lnet_proc_stats() {
10491 local l=$(cat "$TMP/lnet_$1" |wc -l)
10492 [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
10494 grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
10497 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
10498 # 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
10499 # optional and can be regexp for 2nd line (lnet.routes case)
10500 check_lnet_proc_entry() {
10501 local blp=2 # blp stands for 'position of 1st line of body'
10502 [ "$5" = "" ] || blp=3 # lnet.routes case
10504 local l=$(cat "$TMP/lnet_$1" |wc -l)
10505 # subtracting one from $blp because the body can be empty
10506 [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
10508 sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
10509 (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
10511 [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
10512 (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
10514 # bail out if any unexpected line happened
10515 sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
10516 [ "$?" != 0 ] || error "$2 misformatted"
10519 test_215() { # for bugs 18102, 21079, 21517
10520 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10521 local N='(0|[1-9][0-9]*)' # non-negative numeric
10522 local P='[1-9][0-9]*' # positive numeric
10523 local I='(0|-?[1-9][0-9]*|NA)' # any numeric (0 | >0 | <0) or NA if no value
10524 local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
10525 local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
10526 local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
10528 local L1 # regexp for 1st line
10529 local L2 # regexp for 2nd line (optional)
10530 local BR # regexp for the rest (body)
10532 # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
10533 BR="^$N $N $N $N $N $N $N $N $N $N $N$"
10534 create_lnet_proc_files "stats"
10535 check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
10536 check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
10537 remove_lnet_proc_files "stats"
10539 # /proc/sys/lnet/routes should look like this:
10540 # Routing disabled/enabled
10541 # net hops state router
10542 # where net is a string like tcp0, hops >= 0, state is up/down,
10543 # router is a string like 192.168.1.1@tcp2
10544 L1="^Routing (disabled|enabled)$"
10545 L2="^net +hops +state +router$"
10546 BR="^$NET +$N +(up|down) +$NID$"
10547 create_lnet_proc_files "routes"
10548 check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
10549 check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
10550 remove_lnet_proc_files "routes"
10552 # /proc/sys/lnet/routers should look like this:
10553 # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
10554 # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
10555 # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
10556 # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
10557 L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
10558 BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
10559 create_lnet_proc_files "routers"
10560 check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
10561 check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
10562 remove_lnet_proc_files "routers"
10564 # /proc/sys/lnet/peers should look like this:
10565 # nid refs state last max rtr min tx min queue
10566 # where nid is a string like 192.168.1.1@tcp2, refs > 0,
10567 # state is up/down/NA, max >= 0. last, rtr, min, tx, min are
10568 # numeric (0 or >0 or <0), queue >= 0.
10569 L1="^nid +refs +state +last +max +rtr +min +tx +min +queue$"
10570 BR="^$NID +$P +(up|down|NA) +$I +$N +$I +$I +$I +$I +$N$"
10571 create_lnet_proc_files "peers"
10572 check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
10573 check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
10574 remove_lnet_proc_files "peers"
10576 # /proc/sys/lnet/buffers should look like this:
10577 # pages count credits min
10578 # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
10579 L1="^pages +count +credits +min$"
10580 BR="^ +$N +$N +$I +$I$"
10581 create_lnet_proc_files "buffers"
10582 check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
10583 check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
10584 remove_lnet_proc_files "buffers"
10586 # /proc/sys/lnet/nis should look like this:
10587 # nid status alive refs peer rtr max tx min
10588 # where nid is a string like 192.168.1.1@tcp2, status is up/down,
10589 # alive is numeric (0 or >0 or <0), refs >= 0, peer >= 0,
10590 # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
10591 L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
10592 BR="^$NID +(up|down) +$I +$N +$N +$N +$N +$I +$I$"
10593 create_lnet_proc_files "nis"
10594 check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
10595 check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
10596 remove_lnet_proc_files "nis"
10598 # can we successfully write to /proc/sys/lnet/stats?
10599 echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
10600 sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
10602 run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
10604 test_216() { # bug 20317
10605 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10606 remote_ost_nodsh && skip "remote OST with nodsh" && return
10609 local facets=$(get_facets OST)
10610 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
10612 save_lustre_params client "osc.*.contention_seconds" > $p
10613 save_lustre_params $facets \
10614 "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
10615 save_lustre_params $facets \
10616 "ldlm.namespaces.filter-*.contended_locks" >> $p
10617 save_lustre_params $facets \
10618 "ldlm.namespaces.filter-*.contention_seconds" >> $p
10621 # agressive lockless i/o settings
10622 for node in $(osts_nodes); do
10623 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'
10625 lctl set_param -n osc.*.contention_seconds 60
10627 $DIRECTIO write $DIR/$tfile 0 10 4096
10628 $CHECKSTAT -s 40960 $DIR/$tfile
10630 # disable lockless i/o
10631 for node in $(osts_nodes); do
10632 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'
10634 lctl set_param -n osc.*.contention_seconds 0
10637 dd if=/dev/zero of=$DIR/$tfile count=0
10638 $CHECKSTAT -s 0 $DIR/$tfile
10640 restore_lustre_params <$p
10644 run_test 216 "check lockless direct write works and updates file size and kms correctly"
10646 test_217() { # bug 22430
10647 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10651 for node in $(nodes_list); do
10652 nid=$(host_nids_address $node $NETTYPE)
10653 if [[ $nid = *-* ]] ; then
10654 echo "lctl ping $nid@$NETTYPE"
10655 lctl ping $nid@$NETTYPE
10657 echo "skipping $node (no hyphen detected)"
10661 run_test 217 "check lctl ping for hostnames with hiphen ('-')"
10664 # do directio so as not to populate the page cache
10665 log "creating a 10 Mb file"
10666 $MULTIOP $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
10667 log "starting reads"
10668 dd if=$DIR/$tfile of=/dev/null bs=4096 &
10669 log "truncating the file"
10670 $MULTIOP $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
10672 kill %+ || true # reads might have finished
10673 echo "wait until dd is finished"
10675 log "removing the temporary file"
10676 rm -rf $DIR/$tfile || error "tmp file removal failed"
10678 run_test 218 "parallel read and truncate should not deadlock ======================="
10681 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10682 # write one partial page
10683 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
10684 # set no grant so vvp_io_commit_write will do sync write
10685 $LCTL set_param fail_loc=0x411
10686 # write a full page at the end of file
10687 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
10689 $LCTL set_param fail_loc=0
10690 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
10691 $LCTL set_param fail_loc=0x411
10692 dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
10694 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
10696 test_220() { #LU-325
10697 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10698 remote_ost_nodsh && skip "remote OST with nodsh" && return
10701 test_mkdir -p $DIR/$tdir
10702 local OST=$(lfs osts | grep ${OSTIDX}": " | \
10703 awk '{print $2}' | sed -e 's/_UUID$//')
10706 local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $OST)
10707 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
10708 osc.$mdtosc_proc1.prealloc_last_id)
10709 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
10710 osc.$mdtosc_proc1.prealloc_next_id)
10714 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=-1
10715 #define OBD_FAIL_OST_ENOINO 0x229
10716 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x229
10717 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
10718 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $OST || return 2
10720 $SETSTRIPE $DIR/$tdir -i $OSTIDX -c 1 -p $FSNAME.$TESTNAME
10722 MDSOBJS=$((last_id - next_id))
10723 echo "preallocated objects on MDS is $MDSOBJS" "($last_id - $next_id)"
10725 blocks=$($LFS df $MOUNT | awk '($1 == '$OSTIDX') { print $4 }')
10726 echo "OST still has $count kbytes free"
10728 echo "create $MDSOBJS files @next_id..."
10729 createmany -o $DIR/$tdir/f $MDSOBJS || return 3
10731 local last_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10732 osc.$mdtosc_proc1.prealloc_last_id)
10733 local next_id2=$(do_facet mds${MDSIDX} lctl get_param -n \
10734 osc.$mdtosc_proc1.prealloc_next_id)
10736 echo "after creation, last_id=$last_id2, next_id=$next_id2"
10741 do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=0
10742 do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0
10744 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $OST || return 4
10745 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
10746 echo "unlink $MDSOBJS files @$next_id..."
10747 unlinkmany $DIR/$tdir/f $MDSOBJS || return 6
10749 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
10752 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10753 dd if=`which date` of=$MOUNT/date oflag=sync
10754 chmod +x $MOUNT/date
10756 #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE 0x1401
10757 $LCTL set_param fail_loc=0x80001401
10759 $MOUNT/date > /dev/null
10762 run_test 221 "make sure fault and truncate race to not cause OOM"
10765 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10767 test_mkdir -p $DIR/$tdir
10768 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10769 createmany -o $DIR/$tdir/$tfile 10
10770 cancel_lru_locks mdc
10771 cancel_lru_locks osc
10772 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10773 $LCTL set_param fail_loc=0x31a
10774 ls -l $DIR/$tdir > /dev/null || error "AGL for ls failed"
10775 $LCTL set_param fail_loc=0
10778 run_test 222a "AGL for ls should not trigger CLIO lock failure ================"
10781 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10783 test_mkdir -p $DIR/$tdir
10784 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10785 createmany -o $DIR/$tdir/$tfile 10
10786 cancel_lru_locks mdc
10787 cancel_lru_locks osc
10788 #define OBD_FAIL_LDLM_AGL_DELAY 0x31a
10789 $LCTL set_param fail_loc=0x31a
10790 rm -r $DIR/$tdir || "AGL for rmdir failed"
10791 $LCTL set_param fail_loc=0
10793 run_test 222b "AGL for rmdir should not trigger CLIO lock failure ============="
10796 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10798 test_mkdir -p $DIR/$tdir
10799 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
10800 createmany -o $DIR/$tdir/$tfile 10
10801 cancel_lru_locks mdc
10802 cancel_lru_locks osc
10803 #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b
10804 $LCTL set_param fail_loc=0x31b
10805 ls -l $DIR/$tdir > /dev/null || error "reenqueue failed"
10806 $LCTL set_param fail_loc=0
10809 run_test 223 "osc reenqueue if without AGL lock granted ======================="
10811 test_224a() { # LU-1039, MRP-303
10812 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10813 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB 0x508
10814 $LCTL set_param fail_loc=0x508
10815 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
10816 $LCTL set_param fail_loc=0
10819 run_test 224a "Don't panic on bulk IO failure"
10821 test_224b() { # LU-1039, MRP-303
10822 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10823 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
10824 cancel_lru_locks osc
10825 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515
10826 $LCTL set_param fail_loc=0x515
10827 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
10828 $LCTL set_param fail_loc=0
10831 run_test 224b "Don't panic on bulk IO failure"
10833 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
10835 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10836 if [ -z ${MDSSURVEY} ]; then
10837 skip_env "mds-survey not found" && return
10840 [ $MDSCOUNT -ge 2 ] &&
10841 skip "skipping now for more than one MDT" && return
10843 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10844 { skip "Need MDS version at least 2.2.51"; return; }
10846 local mds=$(facet_host $SINGLEMDS)
10847 local target=$(do_nodes $mds 'lctl dl' | \
10848 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10850 local cmd1="file_count=1000 thrhi=4"
10851 local cmd2="dir_count=2 layer=mdd stripe_count=0"
10852 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10853 local cmd="$cmd1 $cmd2 $cmd3"
10855 rm -f ${TMP}/mds_survey*
10857 eval $cmd || error "mds-survey with zero-stripe failed"
10858 cat ${TMP}/mds_survey*
10859 rm -f ${TMP}/mds_survey*
10861 run_test 225a "Metadata survey sanity with zero-stripe"
10864 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10866 if [ -z ${MDSSURVEY} ]; then
10867 skip_env "mds-survey not found" && return
10869 [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
10870 { skip "Need MDS version at least 2.2.51"; return; }
10872 if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
10873 skip_env "Need to mount OST to test" && return
10876 [ $MDSCOUNT -ge 2 ] &&
10877 skip "skipping now for more than one MDT" && return
10878 local mds=$(facet_host $SINGLEMDS)
10879 local target=$(do_nodes $mds 'lctl dl' | \
10880 awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
10882 local cmd1="file_count=1000 thrhi=4"
10883 local cmd2="dir_count=2 layer=mdd stripe_count=1"
10884 local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
10885 local cmd="$cmd1 $cmd2 $cmd3"
10887 rm -f ${TMP}/mds_survey*
10889 eval $cmd || error "mds-survey with stripe_count failed"
10890 cat ${TMP}/mds_survey*
10891 rm -f ${TMP}/mds_survey*
10893 run_test 225b "Metadata survey sanity with stripe_count = 1"
10895 mcreate_path2fid () {
10901 local path=$DIR/$tdir/$name
10906 $MCREATE --mode=$1 --major=$2 --minor=$3 $path ||
10907 error "cannot create $desc"
10909 fid=$($LFS path2fid $path | tr -d '[' | tr -d ']')
10911 [ $rc -ne 0 ] && error "cannot get fid of a $desc"
10913 fid_path=$($LFS fid2path $MOUNT $fid)
10915 [ $rc -ne 0 ] && error "cannot get path of $desc by $DIR $path $fid"
10917 [ "$path" == "$fid_path" ] ||
10918 error "fid2path returned $fid_path, expected $path"
10920 echo "pass with $path and $fid"
10925 mkdir -p $DIR/$tdir
10927 mcreate_path2fid 0010666 0 0 fifo "FIFO"
10928 mcreate_path2fid 0020666 1 3 null "character special file (null)"
10929 mcreate_path2fid 0020666 1 255 none "character special file (no device)"
10930 mcreate_path2fid 0040666 0 0 dir "directory"
10931 mcreate_path2fid 0060666 7 0 loop0 "block special file (loop)"
10932 mcreate_path2fid 0100666 0 0 file "regular file"
10933 mcreate_path2fid 0120666 0 0 link "symbolic link"
10934 mcreate_path2fid 0140666 0 0 sock "socket"
10936 run_test 226a "call path2fid and fid2path on files of all type"
10939 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
10943 mkdir -p $DIR/$tdir
10944 $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
10945 error "create remote directory failed"
10946 mcreate_path2fid 0010666 0 0 "remote_dir/fifo" "FIFO"
10947 mcreate_path2fid 0020666 1 3 "remote_dir/null" \
10948 "character special file (null)"
10949 mcreate_path2fid 0020666 1 255 "remote_dir/none" \
10950 "character special file (no device)"
10951 mcreate_path2fid 0040666 0 0 "remote_dir/dir" "directory"
10952 mcreate_path2fid 0060666 7 0 "remote_dir/loop0" \
10953 "block special file (loop)"
10954 mcreate_path2fid 0100666 0 0 "remote_dir/file" "regular file"
10955 mcreate_path2fid 0120666 0 0 "remote_dir/link" "symbolic link"
10956 mcreate_path2fid 0140666 0 0 "remote_dir/sock" "socket"
10958 run_test 226b "call path2fid and fid2path on files of all type under remote dir"
10960 # LU-1299 Executing or running ldd on a truncated executable does not
10961 # cause an out-of-memory condition.
10963 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10964 dd if=`which date` of=$MOUNT/date bs=1k count=1
10965 chmod +x $MOUNT/date
10967 $MOUNT/date > /dev/null
10968 ldd $MOUNT/date > /dev/null
10971 run_test 227 "running truncated executable does not cause OOM"
10973 # LU-1512 try to reuse idle OI blocks
10975 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
10976 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
10977 skip "non-ldiskfs backend" && return
10979 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
10980 local myDIR=$DIR/$tdir
10983 #define OBD_FAIL_SEQ_EXHAUST 0x1002
10984 $LCTL set_param fail_loc=0x80001002
10985 createmany -o $myDIR/t- 10000
10986 $LCTL set_param fail_loc=0
10987 # The guard is current the largest FID holder
10989 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
10991 local IDX=$(($SEQ % 64))
10993 do_facet $SINGLEMDS sync
10994 # Make sure journal flushed.
10996 local blk1=$(do_facet $SINGLEMDS \
10997 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
10998 grep Blockcount | awk '{print $4}')
11000 # Remove old files, some OI blocks will become idle.
11001 unlinkmany $myDIR/t- 10000
11002 # Create new files, idle OI blocks should be reused.
11003 createmany -o $myDIR/t- 2000
11004 do_facet $SINGLEMDS sync
11005 # Make sure journal flushed.
11007 local blk2=$(do_facet $SINGLEMDS \
11008 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11009 grep Blockcount | awk '{print $4}')
11011 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11013 run_test 228a "try to reuse idle OI blocks"
11016 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11017 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11018 skip "non-ldiskfs backend" && return
11020 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11021 local myDIR=$DIR/$tdir
11024 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11025 $LCTL set_param fail_loc=0x80001002
11026 createmany -o $myDIR/t- 10000
11027 $LCTL set_param fail_loc=0
11028 # The guard is current the largest FID holder
11030 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11032 local IDX=$(($SEQ % 64))
11034 do_facet $SINGLEMDS sync
11035 # Make sure journal flushed.
11037 local blk1=$(do_facet $SINGLEMDS \
11038 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11039 grep Blockcount | awk '{print $4}')
11041 # Remove old files, some OI blocks will become idle.
11042 unlinkmany $myDIR/t- 10000
11045 stop $SINGLEMDS || error "Fail to stop MDT."
11047 start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
11049 df $MOUNT || error "Fail to df."
11050 # Create new files, idle OI blocks should be reused.
11051 createmany -o $myDIR/t- 2000
11052 do_facet $SINGLEMDS sync
11053 # Make sure journal flushed.
11055 local blk2=$(do_facet $SINGLEMDS \
11056 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11057 grep Blockcount | awk '{print $4}')
11059 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11061 run_test 228b "idle OI blocks can be reused after MDT restart"
11065 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11066 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
11067 skip "non-ldiskfs backend" && return
11069 local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
11070 local myDIR=$DIR/$tdir
11073 #define OBD_FAIL_SEQ_EXHAUST 0x1002
11074 $LCTL set_param fail_loc=0x80001002
11075 # 20000 files can guarantee there are index nodes in the OI file
11076 createmany -o $myDIR/t- 20000
11077 $LCTL set_param fail_loc=0
11078 # The guard is current the largest FID holder
11080 local SEQ=$($LFS path2fid $myDIR/guard | awk -F ':' '{print $1}' |
11082 local IDX=$(($SEQ % 64))
11084 do_facet $SINGLEMDS sync
11085 # Make sure journal flushed.
11087 local blk1=$(do_facet $SINGLEMDS \
11088 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11089 grep Blockcount | awk '{print $4}')
11091 # Remove old files, some OI blocks will become idle.
11092 unlinkmany $myDIR/t- 20000
11094 # The OI file should become empty now
11096 # Create new files, idle OI blocks should be reused.
11097 createmany -o $myDIR/t- 2000
11098 do_facet $SINGLEMDS sync
11099 # Make sure journal flushed.
11101 local blk2=$(do_facet $SINGLEMDS \
11102 "$DEBUGFS -c -R \\\"stat oi.16.${IDX}\\\" $MDT_DEV" |
11103 grep Blockcount | awk '{print $4}')
11105 [ $blk1 == $blk2 ] || error "old blk1=$blk1, new blk2=$blk2, unmatched!"
11107 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
11110 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11111 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11114 mkdir -p $DIR/$tdir/test_230_local
11115 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
11116 [ $mdt_idx -ne 0 ] &&
11117 error "create local directory on wrong MDT $mdt_idx"
11119 $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
11120 error "create remote directory failed"
11121 local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
11122 [ $mdt_idx -ne $MDTIDX ] &&
11123 error "create remote directory on wrong MDT $mdt_idx"
11125 createmany -o $DIR/$tdir/test_230/t- 10 ||
11126 error "create files on remote directory failed"
11127 mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
11128 [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
11129 rm -r $DIR/$tdir || error "unlink remote directory failed"
11131 run_test 230a "Create remote directory and files under the remote directory"
11134 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
11137 local remote_dir=$DIR/$tdir/remote_dir
11140 mkdir -p $DIR/$tdir
11141 $LFS mkdir -i $MDTIDX $remote_dir ||
11142 error "create remote directory failed"
11144 $LFS mkdir -i 0 $remote_dir/new_dir &&
11145 error "nested remote directory create succeed!"
11147 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=1
11148 $LFS mkdir -i 0 $remote_dir/new_dir || rc=$?
11149 do_facet mds$((MDTIDX + 1)) lctl set_param mdt.*.enable_remote_dir=0
11152 error "create remote directory failed after set enable_remote_dir"
11154 rm -rf $remote_dir || error "first unlink remote directory failed"
11156 $RUNAS -G$RUNAS_GID $LFS mkdir -i $MDTIDX $DIR/$tfile &&
11157 error "chown worked"
11159 do_facet mds$MDTIDX lctl set_param \
11160 mdt.*.enable_remote_dir_gid=$RUNAS_GID
11161 $LFS mkdir -i $MDTIDX $remote_dir || rc=$?
11162 do_facet mds$MDTIDX lctl set_param mdt.*.enable_remote_dir_gid=0
11165 error "create remote dir failed after set enable_remote_dir_gid"
11167 rm -r $DIR/$tdir || error "second unlink remote directory failed"
11169 run_test 230b "nested remote directory should be failed"
11173 # For simplicity this test assumes that max_pages_per_rpc
11174 # is the same across all OSCs
11175 local max_pages=$($LCTL get_param -n osc.*.max_pages_per_rpc | head -1)
11176 local bulk_size=$((max_pages * 4096))
11178 mkdir -p $DIR/$tdir
11180 # clear the OSC stats
11181 $LCTL set_param osc.*.stats=0 &>/dev/null
11183 # Client writes $bulk_size - there must be 1 rpc for $max_pages.
11184 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$bulk_size count=1 \
11185 oflag=direct &>/dev/null || error "dd failed"
11187 local nrpcs=$($LCTL get_param osc.*.stats |awk '/ost_write/ {print $2}')
11188 if [ x$nrpcs != "x1" ]; then
11189 error "found $nrpc ost_write RPCs, not 1 as expected"
11192 # Drop the OSC cache, otherwise we will read from it
11193 cancel_lru_locks osc
11195 # clear the OSC stats
11196 $LCTL set_param osc.*.stats=0 &>/dev/null
11198 # Client reads $bulk_size.
11199 dd if=$DIR/$tdir/$tfile of=/dev/null bs=$bulk_size count=1 \
11200 iflag=direct &>/dev/null || error "dd failed"
11202 nrpcs=$($LCTL get_param osc.*.stats | awk '/ost_read/ { print $2 }')
11203 if [ x$nrpcs != "x1" ]; then
11204 error "found $nrpc ost_read RPCs, not 1 as expected"
11207 run_test 231a "checking that reading/writing of BRW RPC size results in one RPC"
11210 mkdir -p $DIR/$tdir
11212 for i in {0..1023}; do
11213 dd if=/dev/zero of=$DIR/$tdir/$tfile conv=notrunc \
11214 seek=$((2 * i)) bs=4096 count=1 &>/dev/null ||
11215 error "dd of=$DIR/$tdir/$tfile seek=$((2 * i)) failed"
11219 run_test 231b "must not assert on fully utilized OST request buffer"
11222 mkdir -p $DIR/$tdir
11223 #define OBD_FAIL_LDLM_OST_LVB 0x31c
11224 $LCTL set_param fail_loc=0x31c
11226 # ignore dd failure
11227 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 || true
11229 $LCTL set_param fail_loc=0
11230 umount_client $MOUNT || error "umount failed"
11231 mount_client $MOUNT || error "mount failed"
11233 run_test 232 "failed lock should not block umount"
11236 local fid=$($LFS path2fid $MOUNT)
11237 stat $MOUNT/.lustre/fid/$fid > /dev/null ||
11238 error "cannot access $MOUNT using its FID '$fid'"
11240 run_test 233 "checking that OBF of the FS root succeeds"
11243 # tests that do cleanup/setup should be run at the end
11247 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
11249 #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG 0x903
11250 $LCTL set_param fail_loc=0x903
11251 # cancel_lru_locks mgc - does not work due to lctl set_param syntax
11252 for ls in /proc/fs/lustre/ldlm/namespaces/MGC*/lru_size; do
11255 FAIL_ON_ERROR=true cleanup
11256 FAIL_ON_ERROR=true setup
11258 run_test 900 "umount should not race with any mgc requeue thread"
11261 check_and_cleanup_lustre
11262 if [ "$I_MOUNTED" != "yes" ]; then
11263 lctl set_param debug="$OLDDEBUG" 2> /dev/null || true